Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
9584cf0a
A
ant-design
项目概览
wanjj_1210
/
ant-design
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9584cf0a
编写于
3月 30, 2016
作者:
A
afc163
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1295 from waywardmonkeys/more-class-conversion
Convert more createClass over to extending Component.
上级
fd1d54cf
0acce38f
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
187 addition
and
191 deletion
+187
-191
components/affix/index.jsx
components/affix/index.jsx
+13
-15
components/modal/Modal.jsx
components/modal/Modal.jsx
+23
-27
components/popconfirm/index.jsx
components/popconfirm/index.jsx
+34
-27
components/progress/index.jsx
components/progress/index.jsx
+26
-26
components/time-picker/index.jsx
components/time-picker/index.jsx
+27
-32
components/upload/index.jsx
components/upload/index.jsx
+49
-50
components/upload/uploadList.jsx
components/upload/uploadList.jsx
+15
-14
未找到文件。
components/affix/index.jsx
浏览文件 @
9584cf0a
...
...
@@ -32,19 +32,20 @@ function getOffset(element) {
};
}
const
Affix
=
React
.
createClass
(
{
propTypes
:
{
export
default
class
Affix
extends
React
.
Component
{
static
propTypes
=
{
offsetTop
:
React
.
PropTypes
.
number
,
offsetBottom
:
React
.
PropTypes
.
number
,
}
,
}
getInitialState
()
{
return
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
affixStyle
:
null
,
};
}
,
}
handleScroll
()
{
handleScroll
=
()
=>
{
let
{
offsetTop
,
offsetBottom
}
=
this
.
props
;
const
scrollTop
=
getScroll
(
window
,
true
);
const
elemOffset
=
getOffset
(
ReactDOM
.
findDOMNode
(
this
));
...
...
@@ -90,12 +91,12 @@ const Affix = React.createClass({
affixStyle
:
null
,
});
}
}
,
}
componentDidMount
()
{
this
.
scrollEvent
=
Dom
.
addEventListener
(
window
,
'
scroll
'
,
this
.
handleScroll
);
this
.
resizeEvent
=
Dom
.
addEventListener
(
window
,
'
resize
'
,
this
.
handleScroll
);
}
,
}
componentWillUnmount
()
{
if
(
this
.
scrollEvent
)
{
...
...
@@ -104,7 +105,7 @@ const Affix = React.createClass({
if
(
this
.
resizeEvent
)
{
this
.
resizeEvent
.
remove
();
}
}
,
}
render
()
{
const
className
=
classNames
({
...
...
@@ -119,8 +120,5 @@ const Affix = React.createClass({
</
div
>
</
div
>
);
},
});
export
default
Affix
;
}
}
components/modal/Modal.jsx
浏览文件 @
9584cf0a
...
...
@@ -8,9 +8,8 @@ function noop() {}
let
mousePosition
;
let
mousePositionEventBinded
;
const
Modal
=
React
.
createClass
({
getDefaultProps
()
{
return
{
export
default
class
Modal
extends
React
.
Component
{
static
defaultProps
=
{
prefixCls
:
'
ant-modal
'
,
onOk
:
noop
,
onCancel
:
noop
,
...
...
@@ -19,14 +18,9 @@ const Modal = React.createClass({
maskAnimation
:
'
fade
'
,
confirmLoading
:
false
,
visible
:
false
,
};
},
contextTypes
:
{
antLocale
:
React
.
PropTypes
.
object
,
},
}
propTypes
:
{
static
propTypes
=
{
prefixCls
:
PropTypes
.
string
,
onOk
:
PropTypes
.
func
,
onCancel
:
PropTypes
.
func
,
...
...
@@ -39,15 +33,19 @@ const Modal = React.createClass({
footer
:
PropTypes
.
node
,
title
:
PropTypes
.
node
,
closable
:
PropTypes
.
bool
,
},
}
static
contextTypes
=
{
antLocale
:
React
.
PropTypes
.
object
,
}
handleCancel
(
e
)
{
handleCancel
=
(
e
)
=>
{
this
.
props
.
onCancel
(
e
);
}
,
}
handleOk
()
{
handleOk
=
()
=>
{
this
.
props
.
onOk
();
}
,
}
componentDidMount
()
{
if
(
mousePositionEventBinded
)
{
...
...
@@ -65,7 +63,7 @@ const Modal = React.createClass({
setTimeout
(()
=>
mousePosition
=
null
,
20
);
});
mousePositionEventBinded
=
true
;
}
,
}
render
()
{
let
props
=
this
.
props
;
...
...
@@ -97,6 +95,4 @@ const Modal = React.createClass({
visible
=
{
props
.
visible
}
mousePosition
=
{
mousePosition
}
/>
);
}
});
export
default
Modal
;
}
components/popconfirm/index.jsx
浏览文件 @
9584cf0a
...
...
@@ -22,14 +22,8 @@ const transitionNames = {
rightBottom
:
'
zoom-left
'
,
};
export
default
React
.
createClass
({
getInitialState
()
{
return
{
visible
:
false
};
},
getDefaultProps
()
{
return
{
export
default
class
Popconfirm
extends
React
.
Component
{
static
defaultProps
=
{
transitionName
:
''
,
placement
:
'
top
'
,
trigger
:
'
click
'
,
...
...
@@ -37,33 +31,46 @@ export default React.createClass({
onConfirm
:
noop
,
onCancel
:
noop
,
onVisibleChange
()
{},
};
},
contextTypes
:
{
}
static
contextTypes
=
{
antLocale
:
React
.
PropTypes
.
object
,
},
}
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
visible
:
false
};
}
componentWillReceiveProps
(
nextProps
)
{
if
(
'
visible
'
in
nextProps
)
{
this
.
setState
({
visible
:
nextProps
.
visible
});
}
},
confirm
()
{
}
confirm
=
()
=>
{
this
.
setVisible
(
false
);
this
.
props
.
onConfirm
.
call
(
this
);
},
cancel
()
{
}
cancel
=
()
=>
{
this
.
setVisible
(
false
);
this
.
props
.
onCancel
.
call
(
this
);
},
onVisibleChange
(
visible
)
{
}
onVisibleChange
=
(
visible
)
=>
{
this
.
setVisible
(
visible
);
},
}
setVisible
(
visible
)
{
if
(
!
(
'
visible
'
in
this
.
props
))
{
this
.
setState
({
visible
});
}
this
.
props
.
onVisibleChange
(
visible
);
},
}
render
()
{
const
{
title
,
placement
,
overlayStyle
,
trigger
,
...
restProps
}
=
this
.
props
;
let
{
okText
,
cancelText
}
=
this
.
props
;
...
...
@@ -103,4 +110,4 @@ export default React.createClass({
</
Tooltip
>
);
}
}
);
}
components/progress/index.jsx
浏览文件 @
9584cf0a
...
...
@@ -10,24 +10,24 @@ const statusColorMap = {
success
:
'
#87d068
'
};
let
Line
=
React
.
createClass
({
propTypes
:
{
class
Line
extends
React
.
Component
{
static
defaultProps
=
{
percent
:
0
,
strokeWidth
:
10
,
status
:
'
normal
'
,
// exception active
showInfo
:
true
,
trailColor
:
'
#f3f3f3
'
}
static
propTypes
=
{
status
:
React
.
PropTypes
.
oneOf
([
'
normal
'
,
'
exception
'
,
'
active
'
,
'
success
'
]),
showInfo
:
React
.
PropTypes
.
bool
,
percent
:
React
.
PropTypes
.
number
,
strokeWidth
:
React
.
PropTypes
.
number
,
trailColor
:
React
.
PropTypes
.
string
,
format
:
React
.
PropTypes
.
func
,
},
getDefaultProps
()
{
return
{
percent
:
0
,
strokeWidth
:
10
,
status
:
'
normal
'
,
// exception active
showInfo
:
true
,
trailColor
:
'
#f3f3f3
'
};
},
}
render
()
{
let
props
=
{
...
this
.
props
};
...
...
@@ -77,26 +77,26 @@ let Line = React.createClass({
</
div
>
);
}
}
);
}
let
Circle
=
React
.
createClass
({
propTypes
:
{
class
Circle
extends
React
.
Component
{
static
defaultProps
=
{
width
:
132
,
percent
:
0
,
strokeWidth
:
6
,
status
:
'
normal
'
,
// exception
trailColor
:
'
#f3f3f3
'
,
}
static
propTypes
=
{
status
:
React
.
PropTypes
.
oneOf
([
'
normal
'
,
'
exception
'
,
'
success
'
]),
percent
:
React
.
PropTypes
.
number
,
strokeWidth
:
React
.
PropTypes
.
number
,
width
:
React
.
PropTypes
.
number
,
trailColor
:
React
.
PropTypes
.
string
,
format
:
React
.
PropTypes
.
func
,
},
getDefaultProps
()
{
return
{
width
:
132
,
percent
:
0
,
strokeWidth
:
6
,
status
:
'
normal
'
,
// exception
trailColor
:
'
#f3f3f3
'
,
};
},
}
render
()
{
let
props
=
{
...
this
.
props
};
...
...
@@ -141,7 +141,7 @@ let Circle = React.createClass({
</
div
>
);
}
}
);
}
export
default
{
Line
,
...
...
components/time-picker/index.jsx
浏览文件 @
9584cf0a
...
...
@@ -5,9 +5,8 @@ import defaultLocale from './locale/zh_CN';
import
classNames
from
'
classnames
'
;
import
GregorianCalendar
from
'
gregorian-calendar
'
;
const
TimePicker
=
React
.
createClass
({
getDefaultProps
()
{
return
{
export
default
class
TimePicker
extends
React
.
Component
{
static
defaultProps
=
{
format
:
'
HH:mm:ss
'
,
prefixCls
:
'
ant-time-picker
'
,
onChange
()
{
...
...
@@ -23,16 +22,15 @@ const TimePicker = React.createClass({
hideDisabledOptions
:
false
,
placement
:
'
bottomLeft
'
,
transitionName
:
'
slide-up
'
,
};
},
}
contextTypes
:
{
static
contextTypes
=
{
antLocale
:
React
.
PropTypes
.
object
,
}
,
}
getFormatter
()
{
return
new
DateTimeFormat
(
this
.
props
.
format
);
}
,
}
/**
* 获得输入框的 className
...
...
@@ -45,7 +43,7 @@ const TimePicker = React.createClass({
sizeClass
=
'
ant-input-sm
'
;
}
return
sizeClass
;
}
,
}
/**
* 获得输入框的默认值
...
...
@@ -64,14 +62,14 @@ const TimePicker = React.createClass({
}
}
return
value
;
}
,
}
handleChange
(
value
)
{
handleChange
=
(
value
)
=>
{
this
.
props
.
onChange
(
value
?
new
Date
(
value
.
getTime
())
:
null
,
value
?
this
.
getFormatter
().
format
(
value
)
:
''
,
);
}
,
}
getLocale
()
{
let
locale
=
defaultLocale
;
...
...
@@ -80,7 +78,7 @@ const TimePicker = React.createClass({
}
// 统一合并为完整的 Locale
return
{
...
locale
,
...
this
.
props
.
locale
};
}
,
}
render
()
{
const
locale
=
this
.
getLocale
();
...
...
@@ -116,7 +114,4 @@ const TimePicker = React.createClass({
/>
);
}
});
export
default
TimePicker
;
}
components/upload/index.jsx
浏览文件 @
9584cf0a
...
...
@@ -52,15 +52,39 @@ function genPercentAdd() {
};
}
const
Upload
=
React
.
createClass
({
getInitialState
()
{
return
{
class
UploadDragger
extends
React
.
Component
{
render
()
{
return
<
Upload
{
...
this
.
props
}
type
=
"drag"
style
=
{
{
height
:
this
.
props
.
height
}
}
/>;
}
}
export
default
class
Upload
extends
React
.
Component
{
static
Dragger
=
UploadDragger
;
static
defaultProps
=
{
type
:
'
select
'
,
// do not set
// name: '',
multiple
:
false
,
action
:
''
,
data
:
{},
accept
:
''
,
onChange
:
noop
,
beforeUpload
:
T
,
showUploadList
:
true
,
listType
:
'
text
'
,
// or pictrue
className
:
''
,
}
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
fileList
:
this
.
props
.
fileList
||
this
.
props
.
defaultFileList
||
[],
dragState
:
'
drop
'
};
}
,
}
onStart
(
file
)
{
onStart
=
(
file
)
=>
{
if
(
this
.
recentUploadStatus
===
false
)
return
;
let
targetItem
;
...
...
@@ -85,7 +109,7 @@ const Upload = React.createClass({
if
(
!
window
.
FormData
)
{
this
.
autoUpdateProgress
(
0
,
targetItem
);
}
}
,
}
autoUpdateProgress
(
percent
,
file
)
{
const
getPercent
=
genPercentAdd
();
...
...
@@ -96,7 +120,7 @@ const Upload = React.createClass({
percent
:
curPercent
},
file
);
},
200
);
}
,
}
removeFile
(
file
)
{
let
fileList
=
this
.
state
.
fileList
;
...
...
@@ -107,9 +131,9 @@ const Upload = React.createClass({
return
fileList
;
}
return
null
;
}
,
}
onSuccess
(
response
,
file
)
{
onSuccess
=
(
response
,
file
)
=>
{
this
.
clearProgressTimer
();
try
{
if
(
typeof
response
===
'
string
'
)
{
...
...
@@ -127,9 +151,9 @@ const Upload = React.createClass({
fileList
});
}
}
,
}
onProgress
(
e
,
file
)
{
onProgress
=
(
e
,
file
)
=>
{
let
fileList
=
this
.
state
.
fileList
;
let
targetItem
=
getFileItem
(
file
,
fileList
);
if
(
!
targetItem
)
return
;
...
...
@@ -139,9 +163,9 @@ const Upload = React.createClass({
file
:
targetItem
,
fileList
:
this
.
state
.
fileList
});
}
,
}
onError
(
error
,
response
,
file
)
{
onError
=
(
error
,
response
,
file
)
=>
{
this
.
clearProgressTimer
();
let
fileList
=
this
.
state
.
fileList
;
let
targetItem
=
getFileItem
(
file
,
fileList
);
...
...
@@ -149,12 +173,12 @@ const Upload = React.createClass({
targetItem
.
response
=
response
;
targetItem
.
status
=
'
error
'
;
this
.
handleRemove
(
targetItem
);
}
,
}
beforeUpload
(
file
)
{
this
.
recentUploadStatus
=
this
.
props
.
beforeUpload
(
file
);
return
this
.
recentUploadStatus
;
}
,
}
handleRemove
(
file
)
{
let
fileList
=
this
.
removeFile
(
file
);
...
...
@@ -164,38 +188,21 @@ const Upload = React.createClass({
fileList
,
});
}
}
,
}
handleManualRemove
(
file
)
{
handleManualRemove
=
(
file
)
=>
{
/*eslint-disable */
file
.
status
=
'
removed
'
;
/*eslint-enable */
this
.
handleRemove
(
file
);
}
,
}
onChange
(
info
)
{
onChange
=
(
info
)
=>
{
this
.
setState
({
fileList
:
info
.
fileList
});
this
.
props
.
onChange
(
info
);
},
getDefaultProps
()
{
return
{
type
:
'
select
'
,
// do not set
// name: '',
multiple
:
false
,
action
:
''
,
data
:
{},
accept
:
''
,
onChange
:
noop
,
beforeUpload
:
T
,
showUploadList
:
true
,
listType
:
'
text
'
,
// or pictrue
className
:
''
,
};
},
}
componentWillReceiveProps
(
nextProps
)
{
if
(
'
fileList
'
in
nextProps
)
{
...
...
@@ -203,17 +210,17 @@ const Upload = React.createClass({
fileList
:
nextProps
.
fileList
||
[],
});
}
}
,
}
onFileDrop
(
e
)
{
onFileDrop
=
(
e
)
=>
{
this
.
setState
({
dragState
:
e
.
type
});
}
,
}
clearProgressTimer
()
{
clearInterval
(
this
.
progressTimer
);
}
,
}
render
()
{
let
type
=
this
.
props
.
type
||
'
select
'
;
...
...
@@ -283,12 +290,4 @@ const Upload = React.createClass({
);
}
}
});
Upload
.
Dragger
=
React
.
createClass
({
render
()
{
return
<
Upload
{
...
this
.
props
}
type
=
"drag"
style
=
{
{
height
:
this
.
props
.
height
}
}
/>;
}
});
export
default
Upload
;
}
components/upload/uploadList.jsx
浏览文件 @
9584cf0a
...
...
@@ -14,9 +14,8 @@ const previewFile = function (file, callback) {
reader
.
readAsDataURL
(
file
);
};
export
default
React
.
createClass
({
getDefaultProps
()
{
return
{
export
default
class
UploadList
extends
React
.
Component
{
static
defaultProps
=
{
listType
:
'
text
'
,
// or picture
items
:
[],
progressAttr
:
{
...
...
@@ -24,10 +23,11 @@ export default React.createClass({
showInfo
:
false
}
};
},
handleClose
(
file
)
{
this
.
props
.
onRemove
(
file
);
},
}
componentDidUpdate
()
{
if
(
this
.
props
.
listType
!==
'
picture
'
&&
this
.
props
.
listType
!==
'
picture-card
'
)
{
return
;
...
...
@@ -50,7 +50,8 @@ export default React.createClass({
this
.
forceUpdate
();
});
});
},
}
render
()
{
let
list
=
this
.
props
.
items
.
map
(
file
=>
{
let
progress
;
...
...
@@ -115,4 +116,4 @@ export default React.createClass({
</
div
>
);
}
}
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录