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,333 @@
|
|
|
1
|
+
import React, { useEffect, useContext } from 'react';
|
|
2
|
+
import { Input } from 'antd';
|
|
3
|
+
import md5 from 'md5';
|
|
4
|
+
import { useRequest } from 'ahooks';
|
|
5
|
+
import { isString, isUndefined } from 'lodash';
|
|
6
|
+
import useCss from '../../hooks/useCss';
|
|
7
|
+
import PropsContext from '../../contexts/PropsContext';
|
|
8
|
+
import { propTypes, defaultProps } from '../../components/dataEntry/AntdInput.react';
|
|
9
|
+
|
|
10
|
+
const { Search, TextArea } = Input;
|
|
11
|
+
|
|
12
|
+
// 定义输入框组件AntdInput,api参数参考https://ant.design/components/input-cn/
|
|
13
|
+
const AntdInput = (props) => {
|
|
14
|
+
// 取得必要属性或参数
|
|
15
|
+
let {
|
|
16
|
+
id,
|
|
17
|
+
className,
|
|
18
|
+
style,
|
|
19
|
+
key,
|
|
20
|
+
mode,
|
|
21
|
+
passwordUseMd5,
|
|
22
|
+
autoComplete,
|
|
23
|
+
placeholder,
|
|
24
|
+
value,
|
|
25
|
+
size,
|
|
26
|
+
addonBefore,
|
|
27
|
+
addonAfter,
|
|
28
|
+
prefix,
|
|
29
|
+
suffix,
|
|
30
|
+
allowClear,
|
|
31
|
+
bordered,
|
|
32
|
+
defaultValue,
|
|
33
|
+
disabled,
|
|
34
|
+
maxLength,
|
|
35
|
+
showCount,
|
|
36
|
+
countFormat,
|
|
37
|
+
nClicksSearch,
|
|
38
|
+
nSubmit,
|
|
39
|
+
status,
|
|
40
|
+
autoSize,
|
|
41
|
+
debounceWait,
|
|
42
|
+
readOnly,
|
|
43
|
+
emptyAsNone,
|
|
44
|
+
setProps,
|
|
45
|
+
loading_state,
|
|
46
|
+
persistence,
|
|
47
|
+
persisted_props,
|
|
48
|
+
persistence_type,
|
|
49
|
+
batchPropsNames
|
|
50
|
+
} = props;
|
|
51
|
+
|
|
52
|
+
// 批属性监听
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (batchPropsNames && batchPropsNames.length !== 0) {
|
|
55
|
+
let _batchPropsValues = {};
|
|
56
|
+
for (let propName of batchPropsNames) {
|
|
57
|
+
_batchPropsValues[propName] = props[propName];
|
|
58
|
+
}
|
|
59
|
+
setProps({
|
|
60
|
+
batchPropsValues: _batchPropsValues
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const context = useContext(PropsContext)
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
// 初始化value
|
|
69
|
+
if (defaultValue && !value) {
|
|
70
|
+
// 当defaultValue不为空且value为空时,为value初始化defaultValue对应的value值
|
|
71
|
+
setProps({
|
|
72
|
+
value: defaultValue,
|
|
73
|
+
md5Value: md5(defaultValue)
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
// 在value存在时,初始化md5Value
|
|
77
|
+
if (value) {
|
|
78
|
+
setProps({
|
|
79
|
+
md5Value: md5(value)
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
}, [])
|
|
83
|
+
|
|
84
|
+
// 监听输入内容变化事件
|
|
85
|
+
const onChange = e => {
|
|
86
|
+
// 若启用md5加密且为密码模式
|
|
87
|
+
if (passwordUseMd5 && mode === 'password') {
|
|
88
|
+
setProps({
|
|
89
|
+
md5Value: md5(e.target.value),
|
|
90
|
+
value: (
|
|
91
|
+
emptyAsNone ?
|
|
92
|
+
(
|
|
93
|
+
e.target.value === '' ?
|
|
94
|
+
null :
|
|
95
|
+
e.target.value
|
|
96
|
+
) :
|
|
97
|
+
e.target.value
|
|
98
|
+
)
|
|
99
|
+
})
|
|
100
|
+
} else {
|
|
101
|
+
setProps({
|
|
102
|
+
value: (
|
|
103
|
+
emptyAsNone ?
|
|
104
|
+
(
|
|
105
|
+
e.target.value === '' ?
|
|
106
|
+
null :
|
|
107
|
+
e.target.value
|
|
108
|
+
) :
|
|
109
|
+
e.target.value
|
|
110
|
+
)
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const { run: onDebounceChange } = useRequest(
|
|
116
|
+
(e) => {
|
|
117
|
+
setProps({
|
|
118
|
+
debounceValue: (
|
|
119
|
+
emptyAsNone ?
|
|
120
|
+
(
|
|
121
|
+
e === '' ?
|
|
122
|
+
null :
|
|
123
|
+
e
|
|
124
|
+
) :
|
|
125
|
+
e
|
|
126
|
+
)
|
|
127
|
+
})
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
debounceWait: Math.max(debounceWait, 200),
|
|
131
|
+
manual: true
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
// 监听聚焦到输入框时enter键点按次数
|
|
136
|
+
const onPressEnter = e => {
|
|
137
|
+
setProps({ nSubmit: nSubmit + 1 })
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 监听搜索按钮点按事件
|
|
141
|
+
const onSearch = e => {
|
|
142
|
+
setProps({ nClicksSearch: nClicksSearch + 1 })
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// 不同的mode模式下渲染不同的组件
|
|
146
|
+
if (mode === 'default') {
|
|
147
|
+
return (
|
|
148
|
+
<Input id={id}
|
|
149
|
+
className={
|
|
150
|
+
isString(className) ?
|
|
151
|
+
className :
|
|
152
|
+
(className ? useCss(className) : undefined)
|
|
153
|
+
}
|
|
154
|
+
style={style}
|
|
155
|
+
key={key}
|
|
156
|
+
placeholder={placeholder}
|
|
157
|
+
autoComplete={autoComplete}
|
|
158
|
+
value={value}
|
|
159
|
+
size={
|
|
160
|
+
context && !isUndefined(context.componentSize) ?
|
|
161
|
+
context.componentSize :
|
|
162
|
+
size
|
|
163
|
+
}
|
|
164
|
+
addonBefore={addonBefore}
|
|
165
|
+
addonAfter={addonAfter}
|
|
166
|
+
prefix={prefix}
|
|
167
|
+
suffix={suffix}
|
|
168
|
+
allowClear={allowClear}
|
|
169
|
+
bordered={bordered}
|
|
170
|
+
defaultValue={defaultValue}
|
|
171
|
+
disabled={
|
|
172
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
173
|
+
context.componentDisabled :
|
|
174
|
+
disabled
|
|
175
|
+
}
|
|
176
|
+
maxLength={maxLength}
|
|
177
|
+
status={status}
|
|
178
|
+
readOnly={readOnly}
|
|
179
|
+
onChange={(e) => {
|
|
180
|
+
onChange(e)
|
|
181
|
+
onDebounceChange(e.target.value)
|
|
182
|
+
}}
|
|
183
|
+
onPressEnter={onPressEnter}
|
|
184
|
+
persistence={persistence}
|
|
185
|
+
persisted_props={persisted_props}
|
|
186
|
+
persistence_type={persistence_type}
|
|
187
|
+
data-dash-is-loading={
|
|
188
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
189
|
+
} />
|
|
190
|
+
);
|
|
191
|
+
} else if (mode === 'search') {
|
|
192
|
+
return (
|
|
193
|
+
<Search id={id}
|
|
194
|
+
className={
|
|
195
|
+
isString(className) ?
|
|
196
|
+
className :
|
|
197
|
+
(className ? useCss(className) : undefined)
|
|
198
|
+
}
|
|
199
|
+
style={style}
|
|
200
|
+
key={key}
|
|
201
|
+
placeholder={placeholder}
|
|
202
|
+
autoComplete={autoComplete}
|
|
203
|
+
size={
|
|
204
|
+
context && !isUndefined(context.componentSize) ?
|
|
205
|
+
context.componentSize :
|
|
206
|
+
size
|
|
207
|
+
}
|
|
208
|
+
allowClear={allowClear}
|
|
209
|
+
bordered={bordered}
|
|
210
|
+
value={value}
|
|
211
|
+
defaultValue={defaultValue}
|
|
212
|
+
disabled={
|
|
213
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
214
|
+
context.componentDisabled :
|
|
215
|
+
disabled
|
|
216
|
+
}
|
|
217
|
+
maxLength={maxLength}
|
|
218
|
+
status={status}
|
|
219
|
+
readOnly={readOnly}
|
|
220
|
+
onSearch={onSearch}
|
|
221
|
+
onChange={(e) => {
|
|
222
|
+
onChange(e)
|
|
223
|
+
onDebounceChange(e.target.value)
|
|
224
|
+
}}
|
|
225
|
+
onPressEnter={onPressEnter}
|
|
226
|
+
persistence={persistence}
|
|
227
|
+
persisted_props={persisted_props}
|
|
228
|
+
persistence_type={persistence_type}
|
|
229
|
+
data-dash-is-loading={
|
|
230
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
231
|
+
} />
|
|
232
|
+
);
|
|
233
|
+
} else if (mode === 'text-area') {
|
|
234
|
+
return (
|
|
235
|
+
<TextArea id={id}
|
|
236
|
+
className={
|
|
237
|
+
isString(className) ?
|
|
238
|
+
className :
|
|
239
|
+
(className ? useCss(className) : undefined)
|
|
240
|
+
}
|
|
241
|
+
style={style}
|
|
242
|
+
key={key}
|
|
243
|
+
placeholder={placeholder}
|
|
244
|
+
autoComplete={autoComplete}
|
|
245
|
+
size={
|
|
246
|
+
context && !isUndefined(context.componentSize) ?
|
|
247
|
+
context.componentSize :
|
|
248
|
+
size
|
|
249
|
+
}
|
|
250
|
+
allowClear={allowClear}
|
|
251
|
+
bordered={bordered}
|
|
252
|
+
value={value}
|
|
253
|
+
defaultValue={defaultValue}
|
|
254
|
+
disabled={
|
|
255
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
256
|
+
context.componentDisabled :
|
|
257
|
+
disabled
|
|
258
|
+
}
|
|
259
|
+
maxLength={maxLength}
|
|
260
|
+
showCount={
|
|
261
|
+
showCount && countFormat && !maxLength ?
|
|
262
|
+
{
|
|
263
|
+
// 基于countFormat所定义的正则规则来自定义计算字符数
|
|
264
|
+
formatter: ({ value }) => {
|
|
265
|
+
return value.match(eval(`/${countFormat}/g`))?.length || 0;
|
|
266
|
+
}
|
|
267
|
+
} :
|
|
268
|
+
showCount
|
|
269
|
+
}
|
|
270
|
+
status={status}
|
|
271
|
+
autoSize={autoSize}
|
|
272
|
+
readOnly={readOnly}
|
|
273
|
+
onChange={(e) => {
|
|
274
|
+
onChange(e)
|
|
275
|
+
onDebounceChange(e.target.value)
|
|
276
|
+
}}
|
|
277
|
+
onPressEnter={onPressEnter}
|
|
278
|
+
persistence={persistence}
|
|
279
|
+
persisted_props={persisted_props}
|
|
280
|
+
persistence_type={persistence_type}
|
|
281
|
+
data-dash-is-loading={
|
|
282
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
283
|
+
} />
|
|
284
|
+
);
|
|
285
|
+
} else if (mode === 'password') {
|
|
286
|
+
return (
|
|
287
|
+
<Input.Password id={id}
|
|
288
|
+
className={
|
|
289
|
+
isString(className) ?
|
|
290
|
+
className :
|
|
291
|
+
(className ? useCss(className) : undefined)
|
|
292
|
+
}
|
|
293
|
+
style={style}
|
|
294
|
+
key={key}
|
|
295
|
+
placeholder={placeholder}
|
|
296
|
+
autoComplete={autoComplete}
|
|
297
|
+
size={
|
|
298
|
+
context && !isUndefined(context.componentSize) ?
|
|
299
|
+
context.componentSize :
|
|
300
|
+
size
|
|
301
|
+
}
|
|
302
|
+
bordered={bordered}
|
|
303
|
+
disabled={
|
|
304
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
305
|
+
context.componentDisabled :
|
|
306
|
+
disabled
|
|
307
|
+
}
|
|
308
|
+
value={value}
|
|
309
|
+
defaultValue={defaultValue}
|
|
310
|
+
maxLength={maxLength}
|
|
311
|
+
status={status}
|
|
312
|
+
prefix={prefix}
|
|
313
|
+
suffix={suffix}
|
|
314
|
+
readOnly={readOnly}
|
|
315
|
+
onChange={(e) => {
|
|
316
|
+
onChange(e)
|
|
317
|
+
onDebounceChange(e.target.value)
|
|
318
|
+
}}
|
|
319
|
+
onPressEnter={onPressEnter}
|
|
320
|
+
persistence={persistence}
|
|
321
|
+
persisted_props={persisted_props}
|
|
322
|
+
persistence_type={persistence_type}
|
|
323
|
+
data-dash-is-loading={
|
|
324
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
325
|
+
} />
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export default AntdInput;
|
|
331
|
+
|
|
332
|
+
AntdInput.defaultProps = defaultProps;
|
|
333
|
+
AntdInput.propTypes = propTypes;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React, { useEffect, useContext } from 'react';
|
|
2
|
+
import { InputNumber } from 'antd';
|
|
3
|
+
import { useRequest } from 'ahooks';
|
|
4
|
+
import { isString, isUndefined } from 'lodash';
|
|
5
|
+
import useCss from '../../hooks/useCss';
|
|
6
|
+
import PropsContext from '../../contexts/PropsContext';
|
|
7
|
+
import { propTypes, defaultProps } from '../../components/dataEntry/AntdInputNumber.react';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
// 定义数字输入框组件AntdInputNumber,api参数参考https://ant.design/components/input-number-cn/
|
|
11
|
+
const AntdInputNumber = (props) => {
|
|
12
|
+
|
|
13
|
+
// 取得必要属性或参数
|
|
14
|
+
let {
|
|
15
|
+
id,
|
|
16
|
+
className,
|
|
17
|
+
style,
|
|
18
|
+
key,
|
|
19
|
+
size,
|
|
20
|
+
addonBefore,
|
|
21
|
+
addonAfter,
|
|
22
|
+
prefix,
|
|
23
|
+
bordered,
|
|
24
|
+
controls,
|
|
25
|
+
value,
|
|
26
|
+
defaultValue,
|
|
27
|
+
disabled,
|
|
28
|
+
placeholder,
|
|
29
|
+
keyboard,
|
|
30
|
+
min,
|
|
31
|
+
max,
|
|
32
|
+
step,
|
|
33
|
+
precision,
|
|
34
|
+
readOnly,
|
|
35
|
+
stringMode,
|
|
36
|
+
nSubmit,
|
|
37
|
+
status,
|
|
38
|
+
debounceWait,
|
|
39
|
+
setProps,
|
|
40
|
+
persistence,
|
|
41
|
+
persisted_props,
|
|
42
|
+
persistence_type,
|
|
43
|
+
loading_state,
|
|
44
|
+
batchPropsNames
|
|
45
|
+
} = props;
|
|
46
|
+
|
|
47
|
+
// 批属性监听
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (batchPropsNames && batchPropsNames.length !== 0) {
|
|
50
|
+
let _batchPropsValues = {};
|
|
51
|
+
for (let propName of batchPropsNames) {
|
|
52
|
+
_batchPropsValues[propName] = props[propName];
|
|
53
|
+
}
|
|
54
|
+
setProps({
|
|
55
|
+
batchPropsValues: _batchPropsValues
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const context = useContext(PropsContext)
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
// 初始化value
|
|
64
|
+
if (defaultValue && !value) {
|
|
65
|
+
// 当defaultValue不为空且value为空时,为value初始化defaultValue对应的value值
|
|
66
|
+
setProps({
|
|
67
|
+
value: defaultValue,
|
|
68
|
+
debounceValue: defaultValue
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
}, [])
|
|
72
|
+
|
|
73
|
+
// 监听输入内容变化事件
|
|
74
|
+
const onChange = e => {
|
|
75
|
+
setProps({ value: e })
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const { run: onDebounceChange } = useRequest(
|
|
79
|
+
(e) => {
|
|
80
|
+
setProps({ debounceValue: e })
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
debounceWait: Math.max(debounceWait, 200),
|
|
84
|
+
manual: true
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
// 监听聚焦到输入框时enter键点按次数
|
|
89
|
+
const onPressEnter = e => {
|
|
90
|
+
setProps({ nSubmit: nSubmit + 1 })
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<InputNumber id={id}
|
|
95
|
+
className={
|
|
96
|
+
isString(className) ?
|
|
97
|
+
className :
|
|
98
|
+
(className ? useCss(className) : undefined)
|
|
99
|
+
}
|
|
100
|
+
style={style}
|
|
101
|
+
key={key}
|
|
102
|
+
size={
|
|
103
|
+
context && !isUndefined(context.componentSize) ?
|
|
104
|
+
context.componentSize :
|
|
105
|
+
size
|
|
106
|
+
}
|
|
107
|
+
addonBefore={addonBefore}
|
|
108
|
+
addonAfter={addonAfter}
|
|
109
|
+
prefix={prefix}
|
|
110
|
+
placeholder={placeholder}
|
|
111
|
+
bordered={bordered}
|
|
112
|
+
controls={controls}
|
|
113
|
+
value={value}
|
|
114
|
+
defaultValue={defaultValue}
|
|
115
|
+
disabled={
|
|
116
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
117
|
+
context.componentDisabled :
|
|
118
|
+
disabled
|
|
119
|
+
}
|
|
120
|
+
keyboard={keyboard}
|
|
121
|
+
min={min}
|
|
122
|
+
max={max}
|
|
123
|
+
step={step}
|
|
124
|
+
precision={precision}
|
|
125
|
+
readOnly={readOnly}
|
|
126
|
+
stringMode={stringMode}
|
|
127
|
+
status={status}
|
|
128
|
+
onChange={(e) => {
|
|
129
|
+
onChange(e)
|
|
130
|
+
onDebounceChange(e)
|
|
131
|
+
}}
|
|
132
|
+
onPressEnter={onPressEnter}
|
|
133
|
+
persistence={persistence}
|
|
134
|
+
persisted_props={persisted_props}
|
|
135
|
+
persistence_type={persistence_type}
|
|
136
|
+
data-dash-is-loading={
|
|
137
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
138
|
+
} />
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export default AntdInputNumber;
|
|
143
|
+
|
|
144
|
+
AntdInputNumber.defaultProps = defaultProps;
|
|
145
|
+
AntdInputNumber.propTypes = propTypes;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import React, { useContext, useEffect } from 'react';
|
|
2
|
+
import { Mentions } 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/AntdMentions.react';
|
|
7
|
+
|
|
8
|
+
const { Option } = Mentions;
|
|
9
|
+
|
|
10
|
+
// 定义提及组件AntdMentions,api参数参考https://ant.design/components/mentions-cn/
|
|
11
|
+
const AntdMentions = (props) => {
|
|
12
|
+
// 取得必要属性或参数
|
|
13
|
+
let {
|
|
14
|
+
id,
|
|
15
|
+
className,
|
|
16
|
+
style,
|
|
17
|
+
key,
|
|
18
|
+
autoSize,
|
|
19
|
+
prefix,
|
|
20
|
+
value,
|
|
21
|
+
defaultValue,
|
|
22
|
+
placement,
|
|
23
|
+
options,
|
|
24
|
+
disabled,
|
|
25
|
+
status,
|
|
26
|
+
popupContainer,
|
|
27
|
+
readOnly,
|
|
28
|
+
setProps,
|
|
29
|
+
loading_state,
|
|
30
|
+
batchPropsNames
|
|
31
|
+
} = props;
|
|
32
|
+
|
|
33
|
+
// 批属性监听
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (batchPropsNames && batchPropsNames.length !== 0) {
|
|
36
|
+
let _batchPropsValues = {};
|
|
37
|
+
for (let propName of batchPropsNames) {
|
|
38
|
+
_batchPropsValues[propName] = props[propName];
|
|
39
|
+
}
|
|
40
|
+
setProps({
|
|
41
|
+
batchPropsValues: _batchPropsValues
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const context = useContext(PropsContext)
|
|
47
|
+
|
|
48
|
+
const onChange = (e) => {
|
|
49
|
+
if (!readOnly) {
|
|
50
|
+
setProps({ value: e })
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const onSelect = (e) => {
|
|
55
|
+
// 获取最新一次被选中的子项value值
|
|
56
|
+
let latestSelectedOption = e.value
|
|
57
|
+
|
|
58
|
+
// 计算当前options中value值数组
|
|
59
|
+
let optionValues = options.map(item => item.value)
|
|
60
|
+
|
|
61
|
+
// 抽取已输入内容中的已选择子项内容
|
|
62
|
+
let presentSelectedOptions = (
|
|
63
|
+
(
|
|
64
|
+
(value || '')
|
|
65
|
+
.match(eval(`/${prefix || '@'}\\S{1,}\\s/g`))
|
|
66
|
+
|| []
|
|
67
|
+
)
|
|
68
|
+
.map(
|
|
69
|
+
s => s.slice(1, s.length).trim()
|
|
70
|
+
)
|
|
71
|
+
.concat([latestSelectedOption])
|
|
72
|
+
// 处理latestSelectedOption与options中value值的存在性问题
|
|
73
|
+
.filter(s => optionValues.indexOf(s) !== -1)
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
// 更新输入框中已标记子项value值列表
|
|
77
|
+
setProps({
|
|
78
|
+
selectedOptions: presentSelectedOptions
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Mentions id={id}
|
|
84
|
+
className={
|
|
85
|
+
isString(className) ?
|
|
86
|
+
className :
|
|
87
|
+
(className ? useCss(className) : undefined)
|
|
88
|
+
}
|
|
89
|
+
style={style}
|
|
90
|
+
key={key}
|
|
91
|
+
autoSize={autoSize}
|
|
92
|
+
prefix={prefix}
|
|
93
|
+
defaultValue={defaultValue}
|
|
94
|
+
placement={placement}
|
|
95
|
+
disabled={
|
|
96
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
97
|
+
context.componentDisabled :
|
|
98
|
+
disabled
|
|
99
|
+
}
|
|
100
|
+
status={status}
|
|
101
|
+
onChange={onChange}
|
|
102
|
+
onSelect={onSelect}
|
|
103
|
+
getPopupContainer={
|
|
104
|
+
popupContainer === 'parent' ?
|
|
105
|
+
(triggerNode) => triggerNode.parentNode :
|
|
106
|
+
undefined
|
|
107
|
+
}
|
|
108
|
+
data-dash-is-loading={
|
|
109
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
110
|
+
}
|
|
111
|
+
>
|
|
112
|
+
{
|
|
113
|
+
options.map(
|
|
114
|
+
(item, idx) => <Option value={item.value} key={idx}>{item.label}</Option>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
</Mentions>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default AntdMentions;
|
|
122
|
+
|
|
123
|
+
AntdMentions.defaultProps = defaultProps;
|
|
124
|
+
AntdMentions.propTypes = propTypes;
|