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