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,152 @@
|
|
|
1
|
+
import React, { useEffect, useContext } from 'react';
|
|
2
|
+
import { TimePicker, ConfigProvider } from 'antd';
|
|
3
|
+
import moment from 'moment';
|
|
4
|
+
import { isUndefined, isString } 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/AntdTimeRangePicker.react';
|
|
9
|
+
|
|
10
|
+
const { RangePicker } = TimePicker
|
|
11
|
+
|
|
12
|
+
// 定义时间范围选择组件AntdTimeRangePicker,api参数参考https://ant.design/components/time-picker-cn/
|
|
13
|
+
const AntdTimeRangePicker = (props) => {
|
|
14
|
+
// 取得必要属性或参数
|
|
15
|
+
let {
|
|
16
|
+
id,
|
|
17
|
+
className,
|
|
18
|
+
style,
|
|
19
|
+
key,
|
|
20
|
+
locale,
|
|
21
|
+
setProps,
|
|
22
|
+
value,
|
|
23
|
+
defaultValue,
|
|
24
|
+
placeholder,
|
|
25
|
+
placement,
|
|
26
|
+
disabled,
|
|
27
|
+
hourStep,
|
|
28
|
+
minuteStep,
|
|
29
|
+
secondStep,
|
|
30
|
+
format,
|
|
31
|
+
use12Hours,
|
|
32
|
+
allowClear,
|
|
33
|
+
bordered,
|
|
34
|
+
size,
|
|
35
|
+
open,
|
|
36
|
+
status,
|
|
37
|
+
popupContainer,
|
|
38
|
+
readOnly,
|
|
39
|
+
extraFooter,
|
|
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
|
+
locale = (context && context.locale) || locale
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
// 初始化value
|
|
65
|
+
if (defaultValue && !value) {
|
|
66
|
+
// 当defaultValue不为空且value为空时,为value初始化defaultValue对应值
|
|
67
|
+
setProps({ value: defaultValue })
|
|
68
|
+
}
|
|
69
|
+
}, [])
|
|
70
|
+
|
|
71
|
+
const onChange = (time, timeString) => {
|
|
72
|
+
if (Array.isArray(timeString)) {
|
|
73
|
+
setProps({ value: [timeString[0], timeString[1]] })
|
|
74
|
+
} else {
|
|
75
|
+
setProps({ value: null })
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 返回定制化的前端组件
|
|
80
|
+
return (
|
|
81
|
+
<div>
|
|
82
|
+
<ConfigProvider locale={str2Locale.get(locale)}>
|
|
83
|
+
<RangePicker
|
|
84
|
+
id={id}
|
|
85
|
+
className={
|
|
86
|
+
isString(className) ?
|
|
87
|
+
className :
|
|
88
|
+
(className ? useCss(className) : undefined)
|
|
89
|
+
}
|
|
90
|
+
style={style}
|
|
91
|
+
key={key}
|
|
92
|
+
onChange={onChange}
|
|
93
|
+
disabled={
|
|
94
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
95
|
+
[context.componentDisabled, context.componentDisabled] :
|
|
96
|
+
(
|
|
97
|
+
(disabled && disabled.length === 2) ? disabled : undefined
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
allowEmpty={(disabled && disabled.length === 2) ? disabled : undefined}
|
|
101
|
+
placeholder={(placeholder && placeholder.length === 2) ? placeholder : undefined}
|
|
102
|
+
placement={placement}
|
|
103
|
+
bordered={bordered}
|
|
104
|
+
size={
|
|
105
|
+
context && !isUndefined(context.componentSize) ?
|
|
106
|
+
context.componentSize :
|
|
107
|
+
size
|
|
108
|
+
}
|
|
109
|
+
hourStep={hourStep}
|
|
110
|
+
minuteStep={minuteStep}
|
|
111
|
+
secondStep={secondStep}
|
|
112
|
+
format={format}
|
|
113
|
+
use12Hours={use12Hours}
|
|
114
|
+
allowClear={isUndefined(readOnly) ? allowClear : !readOnly}
|
|
115
|
+
defaultValue={
|
|
116
|
+
(defaultValue && defaultValue.length === 2) ?
|
|
117
|
+
[defaultValue[0] !== '' ? moment(defaultValue[0], format) : undefined,
|
|
118
|
+
defaultValue[1] !== '' ? moment(defaultValue[1], format) : undefined] :
|
|
119
|
+
undefined
|
|
120
|
+
}
|
|
121
|
+
value={
|
|
122
|
+
(value && value.length === 2) ?
|
|
123
|
+
[value[0] !== '' ? moment(value[0], format) : undefined,
|
|
124
|
+
value[1] !== '' ? moment(value[1], format) : undefined] :
|
|
125
|
+
undefined
|
|
126
|
+
}
|
|
127
|
+
status={status}
|
|
128
|
+
renderExtraFooter={() => extraFooter}
|
|
129
|
+
persistence={persistence}
|
|
130
|
+
persisted_props={persisted_props}
|
|
131
|
+
persistence_type={persistence_type}
|
|
132
|
+
data-dash-is-loading={
|
|
133
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
134
|
+
}
|
|
135
|
+
getPopupContainer={
|
|
136
|
+
popupContainer === 'parent' ?
|
|
137
|
+
(triggerNode) => triggerNode.parentNode :
|
|
138
|
+
undefined
|
|
139
|
+
}
|
|
140
|
+
open={isUndefined(readOnly) || !readOnly ? open : false}
|
|
141
|
+
onOpenChange={(e) => setProps({ open: e })}
|
|
142
|
+
inputReadOnly={readOnly}
|
|
143
|
+
/>
|
|
144
|
+
</ConfigProvider>
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export default AntdTimeRangePicker;
|
|
150
|
+
|
|
151
|
+
AntdTimeRangePicker.defaultProps = defaultProps;
|
|
152
|
+
AntdTimeRangePicker.propTypes = propTypes;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React, { useContext, useEffect } from 'react';
|
|
2
|
+
import { Transfer, ConfigProvider } from 'antd';
|
|
3
|
+
import { str2Locale, locale2text } from '../../components/locales.react';
|
|
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/AntdTransfer.react';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
// 定义穿梭框组件AntdTransfer,api参数参考https://ant.design/components/transfer-cn/
|
|
11
|
+
const AntdTransfer = (props) => {
|
|
12
|
+
// 取得必要属性或参数
|
|
13
|
+
let {
|
|
14
|
+
id,
|
|
15
|
+
className,
|
|
16
|
+
style,
|
|
17
|
+
key,
|
|
18
|
+
locale,
|
|
19
|
+
setProps,
|
|
20
|
+
dataSource,
|
|
21
|
+
height,
|
|
22
|
+
pagination,
|
|
23
|
+
operations,
|
|
24
|
+
showSearch,
|
|
25
|
+
optionFilterMode,
|
|
26
|
+
showSelectAll,
|
|
27
|
+
titles,
|
|
28
|
+
disabled,
|
|
29
|
+
targetKeys,
|
|
30
|
+
status,
|
|
31
|
+
readOnly,
|
|
32
|
+
persistence,
|
|
33
|
+
persisted_props,
|
|
34
|
+
persistence_type,
|
|
35
|
+
loading_state,
|
|
36
|
+
batchPropsNames
|
|
37
|
+
} = props;
|
|
38
|
+
|
|
39
|
+
// 批属性监听
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (batchPropsNames && batchPropsNames.length !== 0) {
|
|
42
|
+
let _batchPropsValues = {};
|
|
43
|
+
for (let propName of batchPropsNames) {
|
|
44
|
+
_batchPropsValues[propName] = props[propName];
|
|
45
|
+
}
|
|
46
|
+
setProps({
|
|
47
|
+
batchPropsValues: _batchPropsValues
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const context = useContext(PropsContext)
|
|
53
|
+
locale = (context && context.locale) || locale
|
|
54
|
+
|
|
55
|
+
if (!titles) {
|
|
56
|
+
titles = locale2text.AntdTransfer[locale].titles
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 监听选项移动事件
|
|
60
|
+
const listenMove = (nextTargetKeys, moveDirection, moveKeys) => {
|
|
61
|
+
if (!readOnly) {
|
|
62
|
+
setProps({
|
|
63
|
+
targetKeys: nextTargetKeys,
|
|
64
|
+
moveDirection: moveDirection,
|
|
65
|
+
moveKeys: moveKeys
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 返回定制化的前端组件
|
|
71
|
+
return (
|
|
72
|
+
<ConfigProvider locale={str2Locale.get(locale)}>
|
|
73
|
+
<Transfer
|
|
74
|
+
id={id}
|
|
75
|
+
style={style}
|
|
76
|
+
className={
|
|
77
|
+
isString(className) ?
|
|
78
|
+
className :
|
|
79
|
+
(className ? useCss(className) : undefined)
|
|
80
|
+
}
|
|
81
|
+
key={key}
|
|
82
|
+
dataSource={dataSource}
|
|
83
|
+
targetKeys={targetKeys}
|
|
84
|
+
onChange={listenMove}
|
|
85
|
+
render={item => item.title}
|
|
86
|
+
pagination={pagination}
|
|
87
|
+
operations={operations}
|
|
88
|
+
showSearch={showSearch}
|
|
89
|
+
filterOption={
|
|
90
|
+
showSearch ?
|
|
91
|
+
(inputValue, option) => {
|
|
92
|
+
// 处理''特殊情况
|
|
93
|
+
inputValue = inputValue || ''
|
|
94
|
+
if (inputValue !== '') {
|
|
95
|
+
if (optionFilterMode === 'case-insensitive') {
|
|
96
|
+
// 进行大小写不敏感筛选
|
|
97
|
+
return (option.title || '').toLowerCase()
|
|
98
|
+
.includes(inputValue.toLowerCase())
|
|
99
|
+
} else if (optionFilterMode === 'case-sensitive') {
|
|
100
|
+
// 判断输入的内容是否是当前选项筛选依据字段值的子串
|
|
101
|
+
return option.title.includes(inputValue)
|
|
102
|
+
} else if (optionFilterMode === 'regex') {
|
|
103
|
+
// 判断输入的正则规则是否匹配当前选项筛选依据字段值
|
|
104
|
+
try {
|
|
105
|
+
// 尝试进行正则匹配
|
|
106
|
+
return eval(`/${inputValue}/`).test(option.title)
|
|
107
|
+
} catch {
|
|
108
|
+
// 忽略非法的正则表达式
|
|
109
|
+
return false
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return false
|
|
114
|
+
} : undefined
|
|
115
|
+
}
|
|
116
|
+
showSelectAll={showSelectAll}
|
|
117
|
+
titles={titles}
|
|
118
|
+
disabled={
|
|
119
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
120
|
+
context.componentDisabled :
|
|
121
|
+
disabled
|
|
122
|
+
}
|
|
123
|
+
status={status}
|
|
124
|
+
persistence={persistence}
|
|
125
|
+
persisted_props={persisted_props}
|
|
126
|
+
persistence_type={persistence_type}
|
|
127
|
+
listStyle={{
|
|
128
|
+
overflowX: 'auto',
|
|
129
|
+
height: height,
|
|
130
|
+
width: '100%'
|
|
131
|
+
}}
|
|
132
|
+
data-dash-is-loading={
|
|
133
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
134
|
+
}
|
|
135
|
+
/>
|
|
136
|
+
</ConfigProvider>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default AntdTransfer;
|
|
141
|
+
|
|
142
|
+
AntdTransfer.defaultProps = defaultProps;
|
|
143
|
+
AntdTransfer.propTypes = propTypes;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useContext } from 'react';
|
|
2
|
+
import { TreeSelect, ConfigProvider } from 'antd';
|
|
3
|
+
import { str2Locale } from '../../components/locales.react';
|
|
4
|
+
import { isUndefined, isString } from 'lodash';
|
|
5
|
+
import { flatToTree } from '../../components/utils';
|
|
6
|
+
import useCss from '../../hooks/useCss';
|
|
7
|
+
import PropsContext from '../../contexts/PropsContext';
|
|
8
|
+
import { propTypes, defaultProps } from '../../components/dataEntry/AntdTreeSelect.react';
|
|
9
|
+
|
|
10
|
+
const { SHOW_ALL, SHOW_CHILD, SHOW_PARENT } = TreeSelect;
|
|
11
|
+
|
|
12
|
+
// 定义勾选项回填策略映射字典
|
|
13
|
+
const str2ShowCheckedStrategy = new Map(
|
|
14
|
+
[
|
|
15
|
+
['show-all', SHOW_ALL],
|
|
16
|
+
['show-child', SHOW_CHILD],
|
|
17
|
+
['show-parent', SHOW_PARENT]
|
|
18
|
+
]
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
// 定义树选择组件AntdTreeSelect,api参数参考https://ant.design/components/tree-select-cn/
|
|
22
|
+
const AntdTreeSelect = (props) => {
|
|
23
|
+
// 取得必要属性或参数
|
|
24
|
+
let {
|
|
25
|
+
id,
|
|
26
|
+
style,
|
|
27
|
+
className,
|
|
28
|
+
key,
|
|
29
|
+
locale,
|
|
30
|
+
treeData,
|
|
31
|
+
treeDataMode,
|
|
32
|
+
allowClear,
|
|
33
|
+
bordered,
|
|
34
|
+
treeLine,
|
|
35
|
+
listHeight,
|
|
36
|
+
placeholder,
|
|
37
|
+
value,
|
|
38
|
+
defaultValue,
|
|
39
|
+
maxTagCount,
|
|
40
|
+
multiple,
|
|
41
|
+
size,
|
|
42
|
+
treeCheckable,
|
|
43
|
+
treeCheckStrictly,
|
|
44
|
+
treeDefaultExpandAll,
|
|
45
|
+
treeDefaultExpandedKeys,
|
|
46
|
+
treeExpandedKeys,
|
|
47
|
+
virtual,
|
|
48
|
+
disabled,
|
|
49
|
+
placement,
|
|
50
|
+
status,
|
|
51
|
+
treeNodeFilterProp,
|
|
52
|
+
treeNodeFilterMode,
|
|
53
|
+
autoClearSearchValue,
|
|
54
|
+
popupContainer,
|
|
55
|
+
setProps,
|
|
56
|
+
readOnly,
|
|
57
|
+
showCheckedStrategy,
|
|
58
|
+
dropdownBefore,
|
|
59
|
+
dropdownAfter,
|
|
60
|
+
persistence,
|
|
61
|
+
persisted_props,
|
|
62
|
+
persistence_type,
|
|
63
|
+
loading_state,
|
|
64
|
+
batchPropsNames
|
|
65
|
+
} = props;
|
|
66
|
+
|
|
67
|
+
// 批属性监听
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (batchPropsNames && batchPropsNames.length !== 0) {
|
|
70
|
+
let _batchPropsValues = {};
|
|
71
|
+
for (let propName of batchPropsNames) {
|
|
72
|
+
_batchPropsValues[propName] = props[propName];
|
|
73
|
+
}
|
|
74
|
+
setProps({
|
|
75
|
+
batchPropsValues: _batchPropsValues
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
const context = useContext(PropsContext)
|
|
81
|
+
locale = (context && context.locale) || locale
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!value && defaultValue) {
|
|
85
|
+
setProps({ value: defaultValue })
|
|
86
|
+
}
|
|
87
|
+
if (!treeExpandedKeys && treeDefaultExpandedKeys) {
|
|
88
|
+
setProps({ treeExpandedKeys: treeDefaultExpandedKeys })
|
|
89
|
+
}
|
|
90
|
+
}, [])
|
|
91
|
+
|
|
92
|
+
const flatToTreeData = useMemo(() => {
|
|
93
|
+
return flatToTree(treeData);
|
|
94
|
+
}, [treeData])
|
|
95
|
+
|
|
96
|
+
// 用于获取用户已选择值的回调函数
|
|
97
|
+
const updateSelectedValue = (e) => {
|
|
98
|
+
|
|
99
|
+
if (treeCheckStrictly) {
|
|
100
|
+
setProps({ value: e.map(item => item.value) })
|
|
101
|
+
} else {
|
|
102
|
+
setProps({ value: e })
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 返回定制化的前端组件
|
|
108
|
+
return (
|
|
109
|
+
<ConfigProvider locale={str2Locale.get(locale)}>
|
|
110
|
+
<TreeSelect
|
|
111
|
+
id={id}
|
|
112
|
+
className={
|
|
113
|
+
isString(className) ?
|
|
114
|
+
className :
|
|
115
|
+
(className ? useCss(className) : undefined)
|
|
116
|
+
}
|
|
117
|
+
style={{
|
|
118
|
+
width: '100%',
|
|
119
|
+
...style
|
|
120
|
+
}}
|
|
121
|
+
key={key}
|
|
122
|
+
treeData={treeDataMode === 'flat' ? flatToTreeData : treeData}
|
|
123
|
+
allowClear={isUndefined(readOnly) ? allowClear : !readOnly}
|
|
124
|
+
bordered={bordered}
|
|
125
|
+
treeLine={treeLine}
|
|
126
|
+
listHeight={listHeight}
|
|
127
|
+
placeholder={placeholder}
|
|
128
|
+
value={value}
|
|
129
|
+
defaultValue={defaultValue}
|
|
130
|
+
maxTagCount={maxTagCount}
|
|
131
|
+
multiple={multiple}
|
|
132
|
+
size={
|
|
133
|
+
context && !isUndefined(context.componentSize) ?
|
|
134
|
+
context.componentSize :
|
|
135
|
+
size
|
|
136
|
+
}
|
|
137
|
+
treeCheckable={treeCheckable}
|
|
138
|
+
showCheckedStrategy={str2ShowCheckedStrategy.get(showCheckedStrategy)}
|
|
139
|
+
treeCheckStrictly={treeCheckStrictly}
|
|
140
|
+
treeDefaultExpandAll={treeDefaultExpandAll}
|
|
141
|
+
treeDefaultExpandedKeys={treeDefaultExpandedKeys}
|
|
142
|
+
treeExpandedKeys={treeExpandedKeys}
|
|
143
|
+
onChange={updateSelectedValue}
|
|
144
|
+
showSearch={true}
|
|
145
|
+
virtual={virtual}
|
|
146
|
+
disabled={
|
|
147
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
148
|
+
context.componentDisabled :
|
|
149
|
+
disabled
|
|
150
|
+
}
|
|
151
|
+
placement={placement}
|
|
152
|
+
status={status}
|
|
153
|
+
treeNodeFilterProp={treeNodeFilterProp}
|
|
154
|
+
filterTreeNode={
|
|
155
|
+
(inputValue, treeNode) => {
|
|
156
|
+
// 处理''特殊情况
|
|
157
|
+
inputValue = inputValue || ''
|
|
158
|
+
if (inputValue !== '') {
|
|
159
|
+
if (treeNodeFilterMode === 'case-insensitive') {
|
|
160
|
+
// 进行大小写不敏感筛选
|
|
161
|
+
return (treeNode[treeNodeFilterProp] || '').toLowerCase()
|
|
162
|
+
.includes(inputValue.toLowerCase())
|
|
163
|
+
} else if (treeNodeFilterMode === 'case-sensitive') {
|
|
164
|
+
// 判断输入的内容是否是当前选项筛选依据字段值的子串
|
|
165
|
+
return treeNode[treeNodeFilterProp].includes(inputValue)
|
|
166
|
+
} else if (treeNodeFilterMode === 'regex') {
|
|
167
|
+
// 判断输入的正则规则是否匹配当前选项筛选依据字段值
|
|
168
|
+
try {
|
|
169
|
+
// 尝试进行正则匹配
|
|
170
|
+
return eval(`/${inputValue}/`).test(treeNode[treeNodeFilterProp])
|
|
171
|
+
} catch {
|
|
172
|
+
// 忽略非法的正则表达式
|
|
173
|
+
return false
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return false
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
autoClearSearchValue={autoClearSearchValue}
|
|
181
|
+
dropdownRender={
|
|
182
|
+
(dropdownBefore || dropdownAfter) ?
|
|
183
|
+
(menu) => {
|
|
184
|
+
return (
|
|
185
|
+
<>
|
|
186
|
+
{dropdownBefore}
|
|
187
|
+
{menu}
|
|
188
|
+
{dropdownAfter}
|
|
189
|
+
</>
|
|
190
|
+
);
|
|
191
|
+
} : undefined
|
|
192
|
+
}
|
|
193
|
+
onTreeExpand={(e) => {
|
|
194
|
+
setProps({ treeExpandedKeys: e })
|
|
195
|
+
}}
|
|
196
|
+
persistence={persistence}
|
|
197
|
+
persisted_props={persisted_props}
|
|
198
|
+
persistence_type={persistence_type}
|
|
199
|
+
data-dash-is-loading={
|
|
200
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
201
|
+
}
|
|
202
|
+
getPopupContainer={
|
|
203
|
+
popupContainer === 'parent' ?
|
|
204
|
+
(triggerNode) => triggerNode.parentNode :
|
|
205
|
+
undefined
|
|
206
|
+
}
|
|
207
|
+
open={isUndefined(readOnly) || !readOnly ? undefined : false}
|
|
208
|
+
/>
|
|
209
|
+
</ConfigProvider>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export default AntdTreeSelect;
|
|
214
|
+
|
|
215
|
+
AntdTreeSelect.defaultProps = defaultProps;
|
|
216
|
+
AntdTreeSelect.propTypes = propTypes;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { useEffect, useContext } from 'react';
|
|
2
|
+
import { CheckCard } from '@ant-design/pro-card';
|
|
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/check-card/AntdCheckCard.react';
|
|
7
|
+
|
|
8
|
+
// 定义选择卡片组件AntdCheckCard,api参数参考https://procomponents.ant.design/components/check-card
|
|
9
|
+
const AntdCheckCard = (props) => {
|
|
10
|
+
// 取得必要属性或参数
|
|
11
|
+
let {
|
|
12
|
+
id,
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
style,
|
|
16
|
+
key,
|
|
17
|
+
checked,
|
|
18
|
+
bordered,
|
|
19
|
+
value,
|
|
20
|
+
defaultChecked,
|
|
21
|
+
disabled,
|
|
22
|
+
size,
|
|
23
|
+
readOnly,
|
|
24
|
+
setProps,
|
|
25
|
+
loading_state,
|
|
26
|
+
persistence,
|
|
27
|
+
persisted_props,
|
|
28
|
+
persistence_type
|
|
29
|
+
} = props;
|
|
30
|
+
|
|
31
|
+
const context = useContext(PropsContext)
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!isUndefined(defaultChecked) && isUndefined(checked)) {
|
|
35
|
+
setProps({ checked: defaultChecked })
|
|
36
|
+
}
|
|
37
|
+
}, [])
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<CheckCard id={id}
|
|
41
|
+
className={
|
|
42
|
+
isString(className) ?
|
|
43
|
+
className :
|
|
44
|
+
(className ? useCss(className) : undefined)
|
|
45
|
+
}
|
|
46
|
+
style={style}
|
|
47
|
+
key={key}
|
|
48
|
+
description={children}
|
|
49
|
+
checked={checked}
|
|
50
|
+
bordered={bordered}
|
|
51
|
+
value={value}
|
|
52
|
+
defaultChecked={defaultChecked}
|
|
53
|
+
disabled={
|
|
54
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
55
|
+
context.componentDisabled :
|
|
56
|
+
disabled
|
|
57
|
+
}
|
|
58
|
+
size={size}
|
|
59
|
+
onChange={e => {
|
|
60
|
+
if (!readOnly) {
|
|
61
|
+
setProps({ checked: e })
|
|
62
|
+
}
|
|
63
|
+
}}
|
|
64
|
+
persistence={persistence}
|
|
65
|
+
persisted_props={persisted_props}
|
|
66
|
+
persistence_type={persistence_type}
|
|
67
|
+
data-dash-is-loading={
|
|
68
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
69
|
+
} />
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
export default AntdCheckCard;
|
|
75
|
+
|
|
76
|
+
AntdCheckCard.defaultProps = defaultProps;
|
|
77
|
+
AntdCheckCard.propTypes = propTypes;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React, { useEffect, useContext } from 'react';
|
|
2
|
+
import { CheckCard } from '@ant-design/pro-card';
|
|
3
|
+
import { parseChildrenToArray } from '../../../components/utils';
|
|
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/check-card/AntdCheckCardGroup.react';
|
|
8
|
+
|
|
9
|
+
// 定义组合选择卡片组件AntdCheckCardGroup,api参数参考https://procomponents.ant.design/components/check-card
|
|
10
|
+
const AntdCheckCardGroup = (props) => {
|
|
11
|
+
|
|
12
|
+
// 取得必要属性或参数
|
|
13
|
+
let {
|
|
14
|
+
id,
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
|
+
style,
|
|
18
|
+
key,
|
|
19
|
+
multiple,
|
|
20
|
+
allowNoValue,
|
|
21
|
+
bordered,
|
|
22
|
+
value,
|
|
23
|
+
defaultValue,
|
|
24
|
+
disabled,
|
|
25
|
+
size,
|
|
26
|
+
readOnly,
|
|
27
|
+
setProps,
|
|
28
|
+
loading_state,
|
|
29
|
+
persistence,
|
|
30
|
+
persisted_props,
|
|
31
|
+
persistence_type
|
|
32
|
+
} = props;
|
|
33
|
+
|
|
34
|
+
const context = useContext(PropsContext)
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (defaultValue && !value) {
|
|
38
|
+
setProps({ value: defaultValue })
|
|
39
|
+
}
|
|
40
|
+
}, [])
|
|
41
|
+
|
|
42
|
+
children = parseChildrenToArray(children)
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<CheckCard.Group id={id}
|
|
46
|
+
className={
|
|
47
|
+
isString(className) ?
|
|
48
|
+
className :
|
|
49
|
+
(className ? useCss(className) : undefined)
|
|
50
|
+
}
|
|
51
|
+
style={style}
|
|
52
|
+
key={key}
|
|
53
|
+
multiple={multiple}
|
|
54
|
+
bordered={bordered}
|
|
55
|
+
value={value}
|
|
56
|
+
defaultValue={defaultValue}
|
|
57
|
+
disabled={
|
|
58
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
59
|
+
context.componentDisabled :
|
|
60
|
+
disabled
|
|
61
|
+
}
|
|
62
|
+
size={size}
|
|
63
|
+
onChange={(e) => {
|
|
64
|
+
// 只读模式下不进行值更新
|
|
65
|
+
if (!readOnly) {
|
|
66
|
+
if (allowNoValue) {
|
|
67
|
+
setProps({ value: e })
|
|
68
|
+
} else {
|
|
69
|
+
if (e && e.length !== 0) {
|
|
70
|
+
setProps({ value: e })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}}
|
|
75
|
+
persistence={persistence}
|
|
76
|
+
persisted_props={persisted_props}
|
|
77
|
+
persistence_type={persistence_type}
|
|
78
|
+
data-dash-is-loading={
|
|
79
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
80
|
+
} >
|
|
81
|
+
{children}
|
|
82
|
+
</ CheckCard.Group>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default AntdCheckCardGroup;
|
|
87
|
+
|
|
88
|
+
AntdCheckCardGroup.defaultProps = defaultProps;
|
|
89
|
+
AntdCheckCardGroup.propTypes = propTypes;
|