feffery_antd_components 0.2.10-rc15 → 0.2.10-rc16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESCRIPTION +1 -1
- package/Project.toml +1 -1
- package/build/lib/feffery_antd_components/__init__.py +1 -1
- package/build/lib/feffery_antd_components/async-antd_table.js +1 -1
- package/build/lib/feffery_antd_components/async-antd_upload.js +1 -1
- package/build/lib/feffery_antd_components/async-data_entry.js +1 -0
- package/build/lib/feffery_antd_components/feffery_antd_components.min.js +1 -1
- package/build/lib/feffery_antd_components/package-info.json +1 -1
- package/feffery_antd_components/__init__.py +1 -1
- package/feffery_antd_components/async-antd_table.js +1 -1
- package/feffery_antd_components/async-antd_upload.js +1 -1
- package/feffery_antd_components/async-data_entry.js +1 -0
- package/feffery_antd_components/feffery_antd_components.min.js +1 -1
- package/feffery_antd_components/package-info.json +1 -1
- package/package.json +1 -1
- package/src/lib/components/dataEntry/AntdCascader.react.js +9 -147
- package/src/lib/components/dataEntry/AntdCheckbox.react.js +9 -74
- package/src/lib/components/dataEntry/AntdCheckboxGroup.react.js +9 -71
- package/src/lib/components/dataEntry/AntdDatePicker.react.js +10 -425
- package/src/lib/components/dataEntry/AntdDateRangePicker.react.js +9 -446
- package/src/lib/components/dataEntry/AntdInput.react.js +11 -325
- package/src/lib/components/dataEntry/AntdInputNumber.react.js +9 -134
- package/src/lib/components/dataEntry/AntdMentions.react.js +9 -113
- package/src/lib/components/dataEntry/AntdRadioGroup.react.js +9 -135
- package/src/lib/components/dataEntry/AntdRate.react.js +9 -76
- package/src/lib/components/dataEntry/AntdSegmentedColoring.react.js +9 -206
- package/src/lib/components/dataEntry/AntdSelect.react.js +10 -288
- package/src/lib/components/dataEntry/AntdSlider.react.js +9 -123
- package/src/lib/components/dataEntry/AntdSwitch.react.js +9 -84
- package/src/lib/components/dataEntry/AntdTimePicker.react.js +9 -125
- package/src/lib/components/dataEntry/AntdTimeRangePicker.react.js +9 -141
- package/src/lib/components/dataEntry/AntdTransfer.react.js +9 -132
- package/src/lib/components/dataEntry/AntdTreeSelect.react.js +11 -207
- package/src/lib/components/dataEntry/check-card/AntdCheckCard.react.js +10 -66
- package/src/lib/components/dataEntry/check-card/AntdCheckCardGroup.react.js +10 -79
- package/src/lib/components/dataEntry/form/AntdForm.react.js +9 -42
- package/src/lib/components/dataEntry/form/AntdFormItem.react.js +9 -54
- package/src/lib/fragments/AntdTable.react.js +29 -12
- package/src/lib/fragments/dataEntry/AntdCascader.react.js +157 -0
- package/src/lib/fragments/dataEntry/AntdCheckbox.react.js +85 -0
- package/src/lib/fragments/dataEntry/AntdCheckboxGroup.react.js +82 -0
- package/src/lib/fragments/dataEntry/AntdDatePicker.react.js +436 -0
- package/src/lib/fragments/dataEntry/AntdDateRangePicker.react.js +458 -0
- package/src/lib/fragments/dataEntry/AntdInput.react.js +333 -0
- package/src/lib/fragments/dataEntry/AntdInputNumber.react.js +145 -0
- package/src/lib/fragments/dataEntry/AntdMentions.react.js +124 -0
- package/src/lib/fragments/dataEntry/AntdRadioGroup.react.js +146 -0
- package/src/lib/fragments/dataEntry/AntdRate.react.js +87 -0
- package/src/lib/fragments/dataEntry/AntdSegmentedColoring.react.js +219 -0
- package/src/lib/fragments/dataEntry/AntdSelect.react.js +298 -0
- package/src/lib/fragments/dataEntry/AntdSlider.react.js +134 -0
- package/src/lib/fragments/dataEntry/AntdSwitch.react.js +95 -0
- package/src/lib/fragments/dataEntry/AntdTimePicker.react.js +136 -0
- package/src/lib/fragments/dataEntry/AntdTimeRangePicker.react.js +152 -0
- package/src/lib/fragments/dataEntry/AntdTransfer.react.js +143 -0
- package/src/lib/fragments/dataEntry/AntdTreeSelect.react.js +216 -0
- package/src/lib/fragments/dataEntry/check-card/AntdCheckCard.react.js +77 -0
- package/src/lib/fragments/dataEntry/check-card/AntdCheckCardGroup.react.js +89 -0
- package/src/lib/fragments/dataEntry/form/AntdForm.react.js +53 -0
- package/src/lib/fragments/dataEntry/form/AntdFormItem.react.js +65 -0
- package/usage.py +94 -51
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import React, { useEffect, useContext } from 'react';
|
|
2
|
+
import { useRequest } from 'ahooks';
|
|
3
|
+
import { Select, ConfigProvider } from 'antd';
|
|
4
|
+
import { isUndefined, isString } from 'lodash';
|
|
5
|
+
import useCss from '../../hooks/useCss';
|
|
6
|
+
import { str2Locale } from '../../components/locales.react';
|
|
7
|
+
import PropsContext from '../../contexts/PropsContext';
|
|
8
|
+
import { propTypes, defaultProps } from '../../components/dataEntry/AntdSelect.react';
|
|
9
|
+
|
|
10
|
+
const { Option, OptGroup } = Select;
|
|
11
|
+
|
|
12
|
+
// 定义下拉选择组件AntdSelect,api参数参考https://ant.design/components/select-cn/
|
|
13
|
+
const AntdSelect = (props) => {
|
|
14
|
+
|
|
15
|
+
// 取得必要属性或参数
|
|
16
|
+
let {
|
|
17
|
+
id,
|
|
18
|
+
style,
|
|
19
|
+
className,
|
|
20
|
+
key,
|
|
21
|
+
locale,
|
|
22
|
+
setProps,
|
|
23
|
+
placeholder,
|
|
24
|
+
size,
|
|
25
|
+
bordered,
|
|
26
|
+
options,
|
|
27
|
+
colorsNameWidth,
|
|
28
|
+
allowClear,
|
|
29
|
+
disabled,
|
|
30
|
+
value,
|
|
31
|
+
mode,
|
|
32
|
+
defaultValue,
|
|
33
|
+
maxTagCount,
|
|
34
|
+
listHeight,
|
|
35
|
+
colorsMode,
|
|
36
|
+
placement,
|
|
37
|
+
status,
|
|
38
|
+
optionFilterProp,
|
|
39
|
+
optionFilterMode,
|
|
40
|
+
autoSpin,
|
|
41
|
+
debounceWait,
|
|
42
|
+
autoClearSearchValue,
|
|
43
|
+
emptyContent,
|
|
44
|
+
loadingEmptyContent,
|
|
45
|
+
dropdownBefore,
|
|
46
|
+
dropdownAfter,
|
|
47
|
+
popupContainer,
|
|
48
|
+
readOnly,
|
|
49
|
+
loading_state,
|
|
50
|
+
persistence,
|
|
51
|
+
persisted_props,
|
|
52
|
+
persistence_type,
|
|
53
|
+
batchPropsNames
|
|
54
|
+
} = props;
|
|
55
|
+
|
|
56
|
+
// 批属性监听
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (batchPropsNames && batchPropsNames.length !== 0) {
|
|
59
|
+
let _batchPropsValues = {};
|
|
60
|
+
for (let propName of batchPropsNames) {
|
|
61
|
+
_batchPropsValues[propName] = props[propName];
|
|
62
|
+
}
|
|
63
|
+
setProps({
|
|
64
|
+
batchPropsValues: _batchPropsValues
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const context = useContext(PropsContext)
|
|
70
|
+
locale = (context && context.locale) || locale
|
|
71
|
+
|
|
72
|
+
// 处理multiple模式下,defaultValue或value为None的显示异常问题 #78
|
|
73
|
+
if (mode === 'multiple') {
|
|
74
|
+
defaultValue = defaultValue || []
|
|
75
|
+
value = value || []
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
// 初始化value
|
|
80
|
+
if (defaultValue && !value) {
|
|
81
|
+
// 当defaultValue不为空且value为空时,为value初始化defaultValue对应的value值
|
|
82
|
+
setProps({ value: defaultValue })
|
|
83
|
+
}
|
|
84
|
+
}, [])
|
|
85
|
+
|
|
86
|
+
// 用于获取用户已选择值的回调函数
|
|
87
|
+
const updateSelectedValue = (value) => {
|
|
88
|
+
setProps({ value: value })
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const { run: onDebounceSearch } = useRequest(
|
|
92
|
+
(e) => {
|
|
93
|
+
setProps({ debounceSearchValue: e })
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
debounceWait: Math.max(debounceWait, 200),
|
|
97
|
+
manual: true
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
const onSearch = e => {
|
|
102
|
+
setProps({
|
|
103
|
+
searchValue: e
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 解决options为none时的问题
|
|
108
|
+
options = options || []
|
|
109
|
+
|
|
110
|
+
// 基于dash端传入的options参数,推导出对应的组件
|
|
111
|
+
let optionsJsx = [];
|
|
112
|
+
for (let i = 0; i < options.length; i++) {
|
|
113
|
+
// 当存在分组时
|
|
114
|
+
if (options[i].hasOwnProperty('group')) {
|
|
115
|
+
let groupOptions = [];
|
|
116
|
+
// 构造OptGroup > Option结构
|
|
117
|
+
for (let j = 0; j < options[i].options.length; j++) {
|
|
118
|
+
groupOptions.push(
|
|
119
|
+
<Option value={options[i].options[j].value} disabled={options[i].options[j].disabled}>
|
|
120
|
+
{
|
|
121
|
+
options[i].options[j].colors ?
|
|
122
|
+
<div style={{ display: 'flex' }}>
|
|
123
|
+
<div style={{
|
|
124
|
+
flex: 'none',
|
|
125
|
+
textAlign: 'center',
|
|
126
|
+
width: colorsNameWidth,
|
|
127
|
+
fontSize: 12
|
|
128
|
+
}}>{options[i].options[j].label}</div>
|
|
129
|
+
{
|
|
130
|
+
colorsMode === 'sequential' ? <div style={{
|
|
131
|
+
margin: "1px 0 1px 10px",
|
|
132
|
+
borderRadius: "2px",
|
|
133
|
+
flex: 'auto',
|
|
134
|
+
background: options[i].options[j].colors.length > 1 ?
|
|
135
|
+
`linear-gradient(to right, ${options[i].options[j].colors.join()})` : options[i].options[j].colors[0]
|
|
136
|
+
}} /> : <div style={{
|
|
137
|
+
margin: "1px 0 1px 10px",
|
|
138
|
+
borderRadius: "2px",
|
|
139
|
+
flex: 'auto',
|
|
140
|
+
'display': 'flex'
|
|
141
|
+
}} >{
|
|
142
|
+
options[i].options[j].colors.map(c => <div style={{
|
|
143
|
+
flex: 'auto',
|
|
144
|
+
background: c
|
|
145
|
+
}} />)
|
|
146
|
+
}</ div>
|
|
147
|
+
}
|
|
148
|
+
</div> : options[i].options[j].label
|
|
149
|
+
}
|
|
150
|
+
</Option>
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
optionsJsx.push(<OptGroup label={options[i].group}>{groupOptions}</OptGroup>)
|
|
154
|
+
} else {
|
|
155
|
+
optionsJsx.push(<Option value={options[i].value} disabled={options[i].disabled}>
|
|
156
|
+
{
|
|
157
|
+
options[i].colors ?
|
|
158
|
+
<div style={{ display: 'flex' }}>
|
|
159
|
+
<div style={{
|
|
160
|
+
flex: 'none',
|
|
161
|
+
textAlign: 'center',
|
|
162
|
+
fontSize: 12,
|
|
163
|
+
width: colorsNameWidth
|
|
164
|
+
}}>{options[i].label}</div>
|
|
165
|
+
{
|
|
166
|
+
colorsMode === 'sequential' ? <div style={{
|
|
167
|
+
margin: "1px 0 1px 10px",
|
|
168
|
+
borderRadius: "2px",
|
|
169
|
+
flex: 'auto',
|
|
170
|
+
background: options[i].colors.length > 1 ?
|
|
171
|
+
`linear-gradient(to right, ${options[i].colors.join()})` : options[i].colors[0]
|
|
172
|
+
}} /> : <div style={{
|
|
173
|
+
margin: "1px 0 1px 10px",
|
|
174
|
+
borderRadius: "2px",
|
|
175
|
+
flex: 'auto',
|
|
176
|
+
'display': 'flex'
|
|
177
|
+
}} >{
|
|
178
|
+
options[i].colors.map(c => <div style={{
|
|
179
|
+
flex: 'auto',
|
|
180
|
+
background: c
|
|
181
|
+
}} />)
|
|
182
|
+
}</ div>
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
</div> : options[i].label
|
|
186
|
+
}
|
|
187
|
+
</Option>)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 处理optionFilterProp映射
|
|
192
|
+
if (optionFilterProp === 'label') {
|
|
193
|
+
optionFilterProp = 'children'
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 返回定制化的前端组件
|
|
197
|
+
return (
|
|
198
|
+
<ConfigProvider locale={str2Locale.get(locale)}>
|
|
199
|
+
<Select
|
|
200
|
+
id={id}
|
|
201
|
+
className={
|
|
202
|
+
isString(className) ?
|
|
203
|
+
className :
|
|
204
|
+
(className ? useCss(className) : undefined)
|
|
205
|
+
}
|
|
206
|
+
style={style}
|
|
207
|
+
key={key}
|
|
208
|
+
mode={mode}
|
|
209
|
+
allowClear={isUndefined(readOnly) ? allowClear : !readOnly}
|
|
210
|
+
placeholder={placeholder}
|
|
211
|
+
size={
|
|
212
|
+
context && !isUndefined(context.componentSize) ?
|
|
213
|
+
context.componentSize :
|
|
214
|
+
size
|
|
215
|
+
}
|
|
216
|
+
bordered={bordered}
|
|
217
|
+
value={value}
|
|
218
|
+
defaultValue={defaultValue}
|
|
219
|
+
onChange={updateSelectedValue}
|
|
220
|
+
maxTagCount={maxTagCount}
|
|
221
|
+
listHeight={listHeight}
|
|
222
|
+
disabled={
|
|
223
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
224
|
+
context.componentDisabled :
|
|
225
|
+
disabled
|
|
226
|
+
}
|
|
227
|
+
showSearch={true}
|
|
228
|
+
placement={placement}
|
|
229
|
+
status={status}
|
|
230
|
+
optionFilterProp={optionFilterProp}
|
|
231
|
+
filterOption={
|
|
232
|
+
(inputValue, option) => {
|
|
233
|
+
// 处理''特殊情况
|
|
234
|
+
inputValue = inputValue || ''
|
|
235
|
+
if (inputValue !== '') {
|
|
236
|
+
if (optionFilterMode === 'case-insensitive') {
|
|
237
|
+
// 进行大小写不敏感筛选
|
|
238
|
+
return (option[optionFilterProp] || '').toLowerCase()
|
|
239
|
+
.includes(inputValue.toLowerCase())
|
|
240
|
+
} else if (optionFilterMode === 'case-sensitive') {
|
|
241
|
+
// 判断输入的内容是否是当前选项筛选依据字段值的子串
|
|
242
|
+
return option[optionFilterProp].includes(inputValue)
|
|
243
|
+
} else if (optionFilterMode === 'regex') {
|
|
244
|
+
// 判断输入的正则规则是否匹配当前选项筛选依据字段值
|
|
245
|
+
try {
|
|
246
|
+
// 尝试进行正则匹配
|
|
247
|
+
return eval(`/${inputValue}/`).test(option[optionFilterProp])
|
|
248
|
+
} catch {
|
|
249
|
+
// 忽略非法的正则表达式
|
|
250
|
+
return false
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return false
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
autoClearSearchValue={autoClearSearchValue}
|
|
258
|
+
onSearch={(e) => {
|
|
259
|
+
onSearch(e)
|
|
260
|
+
onDebounceSearch(e)
|
|
261
|
+
}}
|
|
262
|
+
loading={autoSpin && loading_state.is_loading}
|
|
263
|
+
notFoundContent={autoSpin && loading_state.is_loading ? loadingEmptyContent : emptyContent}
|
|
264
|
+
dropdownRender={
|
|
265
|
+
(dropdownBefore || dropdownAfter) ?
|
|
266
|
+
(menu) => {
|
|
267
|
+
return (
|
|
268
|
+
<>
|
|
269
|
+
{dropdownBefore}
|
|
270
|
+
{menu}
|
|
271
|
+
{dropdownAfter}
|
|
272
|
+
</>
|
|
273
|
+
);
|
|
274
|
+
} : undefined
|
|
275
|
+
}
|
|
276
|
+
persistence={persistence}
|
|
277
|
+
persisted_props={persisted_props}
|
|
278
|
+
persistence_type={persistence_type}
|
|
279
|
+
data-dash-is-loading={
|
|
280
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
281
|
+
}
|
|
282
|
+
getPopupContainer={
|
|
283
|
+
popupContainer === 'parent' ?
|
|
284
|
+
(triggerNode) => triggerNode.parentNode :
|
|
285
|
+
undefined
|
|
286
|
+
}
|
|
287
|
+
open={isUndefined(readOnly) || !readOnly ? undefined : false}
|
|
288
|
+
>
|
|
289
|
+
{optionsJsx}
|
|
290
|
+
</Select>
|
|
291
|
+
</ConfigProvider>
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export default AntdSelect;
|
|
296
|
+
|
|
297
|
+
AntdSelect.defaultProps = defaultProps;
|
|
298
|
+
AntdSelect.propTypes = propTypes;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React, { useEffect, useContext } from 'react';
|
|
2
|
+
import { Slider } from 'antd';
|
|
3
|
+
import { isString, isUndefined } from 'lodash';
|
|
4
|
+
import useCss from '../../hooks/useCss';
|
|
5
|
+
import PropsContext from '../../contexts/PropsContext';
|
|
6
|
+
import { propTypes, defaultProps } from '../../components/dataEntry/AntdSlider.react';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// 定义滑动输入条组件AntdSlider,api参数参考https://ant.design/components/slider-cn/
|
|
10
|
+
const AntdSlider = (props) => {
|
|
11
|
+
// 取得必要属性或参数
|
|
12
|
+
let {
|
|
13
|
+
id,
|
|
14
|
+
className,
|
|
15
|
+
style,
|
|
16
|
+
railStyle,
|
|
17
|
+
key,
|
|
18
|
+
value,
|
|
19
|
+
defaultValue,
|
|
20
|
+
disabled,
|
|
21
|
+
vertical,
|
|
22
|
+
range,
|
|
23
|
+
min,
|
|
24
|
+
max,
|
|
25
|
+
step,
|
|
26
|
+
marks,
|
|
27
|
+
tooltipVisible,
|
|
28
|
+
tooltipPrefix,
|
|
29
|
+
tooltipSuffix,
|
|
30
|
+
popupContainer,
|
|
31
|
+
readOnly,
|
|
32
|
+
loading_state,
|
|
33
|
+
setProps,
|
|
34
|
+
persistence,
|
|
35
|
+
persisted_props,
|
|
36
|
+
persistence_type,
|
|
37
|
+
batchPropsNames
|
|
38
|
+
} = props;
|
|
39
|
+
|
|
40
|
+
// 批属性监听
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (batchPropsNames && batchPropsNames.length !== 0) {
|
|
43
|
+
let _batchPropsValues = {};
|
|
44
|
+
for (let propName of batchPropsNames) {
|
|
45
|
+
_batchPropsValues[propName] = props[propName];
|
|
46
|
+
}
|
|
47
|
+
setProps({
|
|
48
|
+
batchPropsValues: _batchPropsValues
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const context = useContext(PropsContext)
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
// 初始化value
|
|
57
|
+
if (range) {
|
|
58
|
+
// 范围选择模式时
|
|
59
|
+
if (!value) {
|
|
60
|
+
setProps({
|
|
61
|
+
value: defaultValue || [min, max],
|
|
62
|
+
defaultValue: defaultValue || [min, max]
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
// 单值选择模式时
|
|
67
|
+
if (!value && value !== 0) {
|
|
68
|
+
setProps({
|
|
69
|
+
value: (defaultValue || defaultValue === 0) ? defaultValue : max,
|
|
70
|
+
defaultValue: (defaultValue || defaultValue === 0) ? defaultValue : max
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, [])
|
|
75
|
+
|
|
76
|
+
// 设置tipFormatter格式化函数
|
|
77
|
+
const formatter = (e) => {
|
|
78
|
+
return tooltipPrefix + `${e}` + tooltipSuffix
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 监听用户完成拖拽的动作
|
|
82
|
+
const onChange = (e) => {
|
|
83
|
+
if (!readOnly) {
|
|
84
|
+
setProps({ value: e })
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 返回定制化的前端组件
|
|
89
|
+
return (
|
|
90
|
+
<Slider
|
|
91
|
+
id={id}
|
|
92
|
+
className={
|
|
93
|
+
isString(className) ?
|
|
94
|
+
className :
|
|
95
|
+
(className ? useCss(className) : undefined)
|
|
96
|
+
}
|
|
97
|
+
style={style}
|
|
98
|
+
railStyle={railStyle}
|
|
99
|
+
key={key}
|
|
100
|
+
value={value}
|
|
101
|
+
defaultValue={defaultValue}
|
|
102
|
+
disabled={
|
|
103
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
104
|
+
context.componentDisabled :
|
|
105
|
+
disabled
|
|
106
|
+
}
|
|
107
|
+
vertical={vertical}
|
|
108
|
+
range={range}
|
|
109
|
+
min={min}
|
|
110
|
+
max={max}
|
|
111
|
+
step={step}
|
|
112
|
+
marks={marks}
|
|
113
|
+
tooltip={{
|
|
114
|
+
open: tooltipVisible,
|
|
115
|
+
getPopupContainer: popupContainer === 'parent' ?
|
|
116
|
+
(triggerNode) => triggerNode.parentNode :
|
|
117
|
+
undefined,
|
|
118
|
+
formatter: formatter
|
|
119
|
+
}}
|
|
120
|
+
onChange={onChange}
|
|
121
|
+
persistence={persistence}
|
|
122
|
+
persisted_props={persisted_props}
|
|
123
|
+
persistence_type={persistence_type}
|
|
124
|
+
data-dash-is-loading={
|
|
125
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
126
|
+
}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default AntdSlider;
|
|
132
|
+
|
|
133
|
+
AntdSlider.defaultProps = defaultProps;
|
|
134
|
+
AntdSlider.propTypes = propTypes;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React, { useEffect, useContext } from 'react';
|
|
2
|
+
import { Switch } from 'antd';
|
|
3
|
+
import { isUndefined, isString } from 'lodash';
|
|
4
|
+
import useCss from '../../hooks/useCss';
|
|
5
|
+
import PropsContext from '../../contexts/PropsContext';
|
|
6
|
+
import { propTypes, defaultProps } from '../../components/dataEntry/AntdSwitch.react';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// 定义开关组件AntdSwitch,api参数参考https://ant.design/components/switch-cn/
|
|
10
|
+
const AntdSwitch = (props) => {
|
|
11
|
+
// 取得必要属性或参数
|
|
12
|
+
let {
|
|
13
|
+
id,
|
|
14
|
+
style,
|
|
15
|
+
className,
|
|
16
|
+
key,
|
|
17
|
+
disabled,
|
|
18
|
+
checked,
|
|
19
|
+
checkedChildren,
|
|
20
|
+
unCheckedChildren,
|
|
21
|
+
size,
|
|
22
|
+
loading,
|
|
23
|
+
readOnly,
|
|
24
|
+
setProps,
|
|
25
|
+
persistence,
|
|
26
|
+
persisted_props,
|
|
27
|
+
persistence_type,
|
|
28
|
+
loading_state,
|
|
29
|
+
batchPropsNames
|
|
30
|
+
} = props;
|
|
31
|
+
|
|
32
|
+
// 批属性监听
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (batchPropsNames && batchPropsNames.length !== 0) {
|
|
35
|
+
let _batchPropsValues = {};
|
|
36
|
+
for (let propName of batchPropsNames) {
|
|
37
|
+
_batchPropsValues[propName] = props[propName];
|
|
38
|
+
}
|
|
39
|
+
setProps({
|
|
40
|
+
batchPropsValues: _batchPropsValues
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const context = useContext(PropsContext)
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (isUndefined(checked)) {
|
|
49
|
+
setProps({ checked: false })
|
|
50
|
+
}
|
|
51
|
+
}, [])
|
|
52
|
+
|
|
53
|
+
const onChange = checked => {
|
|
54
|
+
if (!readOnly) {
|
|
55
|
+
setProps({ checked: checked })
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 返回定制化的前端组件
|
|
60
|
+
return (
|
|
61
|
+
<Switch
|
|
62
|
+
id={id}
|
|
63
|
+
className={
|
|
64
|
+
isString(className) ?
|
|
65
|
+
className :
|
|
66
|
+
(className ? useCss(className) : undefined)
|
|
67
|
+
}
|
|
68
|
+
style={style}
|
|
69
|
+
key={key}
|
|
70
|
+
disabled={
|
|
71
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
72
|
+
context.componentDisabled :
|
|
73
|
+
disabled
|
|
74
|
+
}
|
|
75
|
+
defaultChecked={checked}
|
|
76
|
+
checkedChildren={checkedChildren}
|
|
77
|
+
checked={checked}
|
|
78
|
+
unCheckedChildren={unCheckedChildren}
|
|
79
|
+
size={size}
|
|
80
|
+
loading={loading}
|
|
81
|
+
onChange={onChange}
|
|
82
|
+
persistence={persistence}
|
|
83
|
+
persisted_props={persisted_props}
|
|
84
|
+
persistence_type={persistence_type}
|
|
85
|
+
data-dash-is-loading={
|
|
86
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
87
|
+
}
|
|
88
|
+
/>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default AntdSwitch;
|
|
93
|
+
|
|
94
|
+
AntdSwitch.defaultProps = defaultProps;
|
|
95
|
+
AntdSwitch.propTypes = propTypes;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React, { useEffect, useContext } from 'react';
|
|
2
|
+
import { TimePicker, ConfigProvider } from 'antd';
|
|
3
|
+
import moment from 'moment';
|
|
4
|
+
import { isString, isUndefined } from 'lodash';
|
|
5
|
+
import { str2Locale } from '../../components/locales.react';
|
|
6
|
+
import useCss from '../../hooks/useCss';
|
|
7
|
+
import PropsContext from '../../contexts/PropsContext';
|
|
8
|
+
import { propTypes, defaultProps } from '../../components/dataEntry/AntdTimePicker.react';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
// 定义时间选择组件AntdTimePicker,api参数参考https://ant.design/components/time-picker-cn/
|
|
12
|
+
const AntdTimePicker = (props) => {
|
|
13
|
+
// 取得必要属性或参数
|
|
14
|
+
let {
|
|
15
|
+
id,
|
|
16
|
+
className,
|
|
17
|
+
style,
|
|
18
|
+
key,
|
|
19
|
+
locale,
|
|
20
|
+
setProps,
|
|
21
|
+
disabled,
|
|
22
|
+
hourStep,
|
|
23
|
+
minuteStep,
|
|
24
|
+
secondStep,
|
|
25
|
+
format,
|
|
26
|
+
value,
|
|
27
|
+
defaultValue,
|
|
28
|
+
use12Hours,
|
|
29
|
+
allowClear,
|
|
30
|
+
placeholder,
|
|
31
|
+
placement,
|
|
32
|
+
bordered,
|
|
33
|
+
size,
|
|
34
|
+
status,
|
|
35
|
+
popupContainer,
|
|
36
|
+
readOnly,
|
|
37
|
+
extraFooter,
|
|
38
|
+
showNow,
|
|
39
|
+
persistence,
|
|
40
|
+
persisted_props,
|
|
41
|
+
persistence_type,
|
|
42
|
+
loading_state,
|
|
43
|
+
batchPropsNames
|
|
44
|
+
} = props;
|
|
45
|
+
|
|
46
|
+
// 批属性监听
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (batchPropsNames && batchPropsNames.length !== 0) {
|
|
49
|
+
let _batchPropsValues = {};
|
|
50
|
+
for (let propName of batchPropsNames) {
|
|
51
|
+
_batchPropsValues[propName] = props[propName];
|
|
52
|
+
}
|
|
53
|
+
setProps({
|
|
54
|
+
batchPropsValues: _batchPropsValues
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const context = useContext(PropsContext)
|
|
60
|
+
locale = (context && context.locale) || locale
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
// 初始化value
|
|
64
|
+
if (defaultValue && !value) {
|
|
65
|
+
// 当defaultValue不为空且value为空时,为value初始化defaultValue对应值
|
|
66
|
+
setProps({ value: defaultValue })
|
|
67
|
+
}
|
|
68
|
+
}, [])
|
|
69
|
+
|
|
70
|
+
const onChange = (time, timeString) => {
|
|
71
|
+
if (isString(timeString)) {
|
|
72
|
+
setProps({ value: timeString })
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 返回定制化的前端组件
|
|
77
|
+
return (
|
|
78
|
+
<div>
|
|
79
|
+
<ConfigProvider locale={str2Locale.get(locale)}>
|
|
80
|
+
<TimePicker
|
|
81
|
+
id={id}
|
|
82
|
+
className={
|
|
83
|
+
isString(className) ?
|
|
84
|
+
className :
|
|
85
|
+
(className ? useCss(className) : undefined)
|
|
86
|
+
}
|
|
87
|
+
style={style}
|
|
88
|
+
key={key}
|
|
89
|
+
onChange={onChange}
|
|
90
|
+
placeholder={placeholder}
|
|
91
|
+
placement={placement}
|
|
92
|
+
bordered={bordered}
|
|
93
|
+
size={
|
|
94
|
+
context && !isUndefined(context.componentSize) ?
|
|
95
|
+
context.componentSize :
|
|
96
|
+
size
|
|
97
|
+
}
|
|
98
|
+
disabled={
|
|
99
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
100
|
+
context.componentDisabled :
|
|
101
|
+
disabled
|
|
102
|
+
}
|
|
103
|
+
hourStep={hourStep}
|
|
104
|
+
minuteStep={minuteStep}
|
|
105
|
+
secondStep={secondStep}
|
|
106
|
+
format={format}
|
|
107
|
+
value={value ? moment(value, format) : undefined}
|
|
108
|
+
defaultValue={defaultValue ? moment(defaultValue, format) : undefined}
|
|
109
|
+
use12Hours={use12Hours}
|
|
110
|
+
allowClear={isUndefined(readOnly) ? allowClear : !readOnly}
|
|
111
|
+
status={status}
|
|
112
|
+
renderExtraFooter={() => extraFooter}
|
|
113
|
+
showNow={showNow}
|
|
114
|
+
persistence={persistence}
|
|
115
|
+
persisted_props={persisted_props}
|
|
116
|
+
persistence_type={persistence_type}
|
|
117
|
+
data-dash-is-loading={
|
|
118
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
119
|
+
}
|
|
120
|
+
getPopupContainer={
|
|
121
|
+
popupContainer === 'parent' ?
|
|
122
|
+
(triggerNode) => triggerNode.parentNode :
|
|
123
|
+
undefined
|
|
124
|
+
}
|
|
125
|
+
open={isUndefined(readOnly) || !readOnly ? undefined : false}
|
|
126
|
+
inputReadOnly={readOnly}
|
|
127
|
+
/>
|
|
128
|
+
</ConfigProvider>
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default AntdTimePicker;
|
|
134
|
+
|
|
135
|
+
AntdTimePicker.defaultProps = defaultProps;
|
|
136
|
+
AntdTimePicker.propTypes = propTypes;
|