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.
Files changed (61) hide show
  1. package/DESCRIPTION +1 -1
  2. package/Project.toml +1 -1
  3. package/build/lib/feffery_antd_components/__init__.py +1 -1
  4. package/build/lib/feffery_antd_components/async-antd_table.js +1 -1
  5. package/build/lib/feffery_antd_components/async-antd_upload.js +1 -1
  6. package/build/lib/feffery_antd_components/async-data_entry.js +1 -0
  7. package/build/lib/feffery_antd_components/feffery_antd_components.min.js +1 -1
  8. package/build/lib/feffery_antd_components/package-info.json +1 -1
  9. package/feffery_antd_components/__init__.py +1 -1
  10. package/feffery_antd_components/async-antd_table.js +1 -1
  11. package/feffery_antd_components/async-antd_upload.js +1 -1
  12. package/feffery_antd_components/async-data_entry.js +1 -0
  13. package/feffery_antd_components/feffery_antd_components.min.js +1 -1
  14. package/feffery_antd_components/package-info.json +1 -1
  15. package/package.json +1 -1
  16. package/src/lib/components/dataEntry/AntdCascader.react.js +9 -147
  17. package/src/lib/components/dataEntry/AntdCheckbox.react.js +9 -74
  18. package/src/lib/components/dataEntry/AntdCheckboxGroup.react.js +9 -71
  19. package/src/lib/components/dataEntry/AntdDatePicker.react.js +10 -425
  20. package/src/lib/components/dataEntry/AntdDateRangePicker.react.js +9 -446
  21. package/src/lib/components/dataEntry/AntdInput.react.js +11 -325
  22. package/src/lib/components/dataEntry/AntdInputNumber.react.js +9 -134
  23. package/src/lib/components/dataEntry/AntdMentions.react.js +9 -113
  24. package/src/lib/components/dataEntry/AntdRadioGroup.react.js +9 -135
  25. package/src/lib/components/dataEntry/AntdRate.react.js +9 -76
  26. package/src/lib/components/dataEntry/AntdSegmentedColoring.react.js +9 -206
  27. package/src/lib/components/dataEntry/AntdSelect.react.js +10 -288
  28. package/src/lib/components/dataEntry/AntdSlider.react.js +9 -123
  29. package/src/lib/components/dataEntry/AntdSwitch.react.js +9 -84
  30. package/src/lib/components/dataEntry/AntdTimePicker.react.js +9 -125
  31. package/src/lib/components/dataEntry/AntdTimeRangePicker.react.js +9 -141
  32. package/src/lib/components/dataEntry/AntdTransfer.react.js +9 -132
  33. package/src/lib/components/dataEntry/AntdTreeSelect.react.js +11 -207
  34. package/src/lib/components/dataEntry/check-card/AntdCheckCard.react.js +10 -66
  35. package/src/lib/components/dataEntry/check-card/AntdCheckCardGroup.react.js +10 -79
  36. package/src/lib/components/dataEntry/form/AntdForm.react.js +9 -42
  37. package/src/lib/components/dataEntry/form/AntdFormItem.react.js +9 -54
  38. package/src/lib/fragments/AntdTable.react.js +29 -12
  39. package/src/lib/fragments/dataEntry/AntdCascader.react.js +157 -0
  40. package/src/lib/fragments/dataEntry/AntdCheckbox.react.js +85 -0
  41. package/src/lib/fragments/dataEntry/AntdCheckboxGroup.react.js +82 -0
  42. package/src/lib/fragments/dataEntry/AntdDatePicker.react.js +436 -0
  43. package/src/lib/fragments/dataEntry/AntdDateRangePicker.react.js +458 -0
  44. package/src/lib/fragments/dataEntry/AntdInput.react.js +333 -0
  45. package/src/lib/fragments/dataEntry/AntdInputNumber.react.js +145 -0
  46. package/src/lib/fragments/dataEntry/AntdMentions.react.js +124 -0
  47. package/src/lib/fragments/dataEntry/AntdRadioGroup.react.js +146 -0
  48. package/src/lib/fragments/dataEntry/AntdRate.react.js +87 -0
  49. package/src/lib/fragments/dataEntry/AntdSegmentedColoring.react.js +219 -0
  50. package/src/lib/fragments/dataEntry/AntdSelect.react.js +298 -0
  51. package/src/lib/fragments/dataEntry/AntdSlider.react.js +134 -0
  52. package/src/lib/fragments/dataEntry/AntdSwitch.react.js +95 -0
  53. package/src/lib/fragments/dataEntry/AntdTimePicker.react.js +136 -0
  54. package/src/lib/fragments/dataEntry/AntdTimeRangePicker.react.js +152 -0
  55. package/src/lib/fragments/dataEntry/AntdTransfer.react.js +143 -0
  56. package/src/lib/fragments/dataEntry/AntdTreeSelect.react.js +216 -0
  57. package/src/lib/fragments/dataEntry/check-card/AntdCheckCard.react.js +77 -0
  58. package/src/lib/fragments/dataEntry/check-card/AntdCheckCardGroup.react.js +89 -0
  59. package/src/lib/fragments/dataEntry/form/AntdForm.react.js +53 -0
  60. package/src/lib/fragments/dataEntry/form/AntdFormItem.react.js +65 -0
  61. package/usage.py +94 -51
@@ -0,0 +1,146 @@
1
+ import React, { useEffect, useContext } from 'react';
2
+ import { Radio, Space } 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/AntdRadioGroup.react';
7
+
8
+
9
+ // 定义单选框组件AntdRadioGroup,api参数参考https://ant.design/components/radio-cn/
10
+ const AntdRadioGroup = (props) => {
11
+ // 取得必要属性或参数
12
+ let {
13
+ id,
14
+ style,
15
+ className,
16
+ key,
17
+ options,
18
+ defaultValue,
19
+ value,
20
+ direction,
21
+ optionType,
22
+ buttonStyle,
23
+ disabled,
24
+ size,
25
+ readOnly,
26
+ setProps,
27
+ persistence,
28
+ persisted_props,
29
+ persistence_type,
30
+ loading_state,
31
+ batchPropsNames
32
+ } = props;
33
+
34
+ // 批属性监听
35
+ useEffect(() => {
36
+ if (batchPropsNames && batchPropsNames.length !== 0) {
37
+ let _batchPropsValues = {};
38
+ for (let propName of batchPropsNames) {
39
+ _batchPropsValues[propName] = props[propName];
40
+ }
41
+ setProps({
42
+ batchPropsValues: _batchPropsValues
43
+ })
44
+ }
45
+ })
46
+
47
+ const context = useContext(PropsContext)
48
+
49
+ useEffect(() => {
50
+ if (defaultValue && !value) {
51
+ setProps({ value: defaultValue })
52
+ }
53
+ }, [])
54
+
55
+ const onSelect = (e) => {
56
+ if (!readOnly) {
57
+ setProps({ value: e.target.value })
58
+ }
59
+ }
60
+
61
+ if (direction === 'vertical') {
62
+
63
+ // 返回定制化的前端组件
64
+ return (
65
+ <Radio.Group
66
+ id={id}
67
+ className={
68
+ isString(className) ?
69
+ className :
70
+ (className ? useCss(className) : undefined)
71
+ }
72
+ style={style}
73
+ key={key}
74
+ defaultValue={defaultValue}
75
+ value={value}
76
+ buttonStyle={buttonStyle}
77
+ disabled={
78
+ context && !isUndefined(context.componentDisabled) ?
79
+ context.componentDisabled :
80
+ disabled
81
+ }
82
+ size={
83
+ context && !isUndefined(context.componentSize) ?
84
+ context.componentSize :
85
+ size
86
+ }
87
+ persistence={persistence}
88
+ persisted_props={persisted_props}
89
+ persistence_type={persistence_type}
90
+ onChange={onSelect}
91
+ data-dash-is-loading={
92
+ (loading_state && loading_state.is_loading) || undefined
93
+ }
94
+ >
95
+ <Space direction='vertical'>
96
+ {options.map(item => {
97
+ return optionType !== 'button' ?
98
+ <Radio value={item.value} disabled={item.disabled}>{item.label}</Radio> :
99
+ <Radio.Button value={item.value} disabled={item.disabled}>{item.label}</Radio.Button>
100
+ })}
101
+ </Space>
102
+ </Radio.Group>
103
+ );
104
+ }
105
+
106
+ // 返回定制化的前端组件
107
+ return (
108
+ <Radio.Group
109
+ id={id}
110
+ className={
111
+ isString(className) ?
112
+ className :
113
+ (className ? useCss(className) : undefined)
114
+ }
115
+ style={style}
116
+ key={key}
117
+ options={options}
118
+ defaultValue={defaultValue}
119
+ value={value}
120
+ optionType={optionType}
121
+ buttonStyle={buttonStyle}
122
+ disabled={
123
+ context && !isUndefined(context.componentDisabled) ?
124
+ context.componentDisabled :
125
+ disabled
126
+ }
127
+ size={
128
+ context && !isUndefined(context.componentSize) ?
129
+ context.componentSize :
130
+ size
131
+ }
132
+ persistence={persistence}
133
+ persisted_props={persisted_props}
134
+ persistence_type={persistence_type}
135
+ onChange={onSelect}
136
+ data-dash-is-loading={
137
+ (loading_state && loading_state.is_loading) || undefined
138
+ }
139
+ />
140
+ );
141
+ }
142
+
143
+ export default AntdRadioGroup;
144
+
145
+ AntdRadioGroup.defaultProps = defaultProps;
146
+ AntdRadioGroup.propTypes = propTypes;
@@ -0,0 +1,87 @@
1
+ import React, { useEffect, useContext } from 'react';
2
+ import { Rate } 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/AntdRate.react';
7
+
8
+
9
+ // 定义评分组件AntdRate,api参数参考https://ant.design/components/rate-cn/
10
+ const AntdRate = (props) => {
11
+ // 取得必要属性或参数
12
+ let {
13
+ id,
14
+ className,
15
+ style,
16
+ key,
17
+ allowClear,
18
+ allowHalf,
19
+ count,
20
+ disabled,
21
+ tooltips,
22
+ defaultValue,
23
+ value,
24
+ setProps,
25
+ loading_state,
26
+ persistence,
27
+ persisted_props,
28
+ persistence_type,
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
+ // 初始化value
49
+ if (defaultValue && !value) {
50
+ // 当defaultValue不为空时,为value初始化defaultValue对应的value值
51
+ setProps({ value: defaultValue })
52
+ }
53
+ }, [])
54
+
55
+ return (
56
+ <Rate id={id}
57
+ className={
58
+ isString(className) ?
59
+ className :
60
+ (className ? useCss(className) : undefined)
61
+ }
62
+ style={style}
63
+ key={key}
64
+ allowClear={allowClear}
65
+ allowHalf={allowHalf}
66
+ count={count}
67
+ disabled={
68
+ context && !isUndefined(context.componentDisabled) ?
69
+ context.componentDisabled :
70
+ disabled
71
+ }
72
+ tooltips={tooltips}
73
+ value={value}
74
+ onChange={v => setProps({ value: v })}
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
+ );
82
+ }
83
+
84
+ export default AntdRate;
85
+
86
+ AntdRate.defaultProps = defaultProps;
87
+ AntdRate.propTypes = propTypes;
@@ -0,0 +1,219 @@
1
+ /* eslint-disable no-undefined */
2
+ /* eslint-disable no-unused-vars */
3
+ import React, { useContext, useEffect } from 'react';
4
+ import { InputNumber, Space, message, Typography } from 'antd';
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/AntdSegmentedColoring.react';
9
+
10
+
11
+ const { Text } = Typography;
12
+
13
+ const size2size = new Map([
14
+ ["small", "24px"],
15
+ ["middle", "32px"],
16
+ ["large", "40px"]
17
+ ]);
18
+
19
+ // 定义分段着色组件AntdSegmentedColoring
20
+ const AntdSegmentedColoring = (props) => {
21
+
22
+ // 取得必要属性或参数
23
+ let {
24
+ id,
25
+ key,
26
+ className,
27
+ style,
28
+ size,
29
+ bordered,
30
+ controls,
31
+ disabled,
32
+ keyboard,
33
+ placeholder,
34
+ min,
35
+ max,
36
+ step,
37
+ precision,
38
+ readOnly,
39
+ pureLegend,
40
+ breakpoints,
41
+ colors,
42
+ inputNumberStyle,
43
+ colorBlockPosition,
44
+ colorBlockStyle,
45
+ pureLegendLabelStyle,
46
+ loading_state,
47
+ setProps,
48
+ batchPropsNames
49
+ } = props;
50
+
51
+ // 批属性监听
52
+ useEffect(() => {
53
+ if (batchPropsNames && batchPropsNames.length !== 0) {
54
+ let _batchPropsValues = {};
55
+ for (let propName of batchPropsNames) {
56
+ _batchPropsValues[propName] = props[propName];
57
+ }
58
+ setProps({
59
+ batchPropsValues: _batchPropsValues
60
+ })
61
+ }
62
+ })
63
+
64
+ const context = useContext(PropsContext)
65
+
66
+ disabled = (
67
+ context && !isUndefined(context.componentDisabled) ?
68
+ context.componentDisabled :
69
+ disabled
70
+ )
71
+
72
+ size = (
73
+ context && !isUndefined(context.componentSize) ?
74
+ context.componentSize :
75
+ size
76
+ )
77
+
78
+ return (
79
+ <Space
80
+ id={id}
81
+ key={key}
82
+ style={{
83
+ borderRadius: "2px",
84
+ padding: "12px 20px",
85
+ ...style
86
+ }}
87
+ className={
88
+ isString(className) ?
89
+ className :
90
+ (className ? useCss(className) : undefined)
91
+ }
92
+ direction={"vertical"}
93
+ data-dash-is-loading={
94
+ (loading_state && loading_state.is_loading) || undefined
95
+ }
96
+ >
97
+ {breakpoints.slice(0, breakpoints.length - 1).map((v, i) => {
98
+ return (
99
+ <Space style={{ display: 'flex' }} size={"small"}>
100
+ {colorBlockPosition === 'left' ?
101
+ (<div
102
+ style={{
103
+ height: size2size.get(size),
104
+ backgroundColor: colors[i],
105
+ width: size2size.get(size),
106
+ ...colorBlockStyle
107
+ }}
108
+ />) : null
109
+ }
110
+ {
111
+ pureLegend ?
112
+ (
113
+ <>
114
+ <Text style={pureLegendLabelStyle}>{breakpoints[i].toFixed(precision)}</Text>
115
+ <Text style={pureLegendLabelStyle}>~</Text>
116
+ <Text style={pureLegendLabelStyle}>{breakpoints[i + 1].toFixed(precision)}</Text>
117
+ </>
118
+ ) : (
119
+ <>
120
+ <InputNumber
121
+ style={inputNumberStyle}
122
+ size={size}
123
+ bordered={bordered}
124
+ controls={controls}
125
+ disabled={disabled}
126
+ keyboard={keyboard}
127
+ placeholder={placeholder}
128
+ min={min}
129
+ max={max}
130
+ step={step}
131
+ precision={precision}
132
+ readOnly={readOnly}
133
+ value={breakpoints[i]}
134
+ onChange={(e) => {
135
+ if (e !== null && i === 0 && e < breakpoints[i + 1]) {
136
+ let _breakpoints = [...breakpoints];
137
+ _breakpoints[i] = e;
138
+ setProps({ breakpoints: _breakpoints });
139
+ } else if (
140
+ e !== null &&
141
+ i > 0 &&
142
+ e > breakpoints[i - 1] &&
143
+ e < breakpoints[i + 1]
144
+ ) {
145
+ let _breakpoints = [...breakpoints];
146
+ _breakpoints[i] = e;
147
+ setProps({ breakpoints: _breakpoints });
148
+ } else if (e !== null) {
149
+ message.warning({
150
+ content: "数值超出相邻断点,请调整后再输入!",
151
+ duration: 1.5
152
+ });
153
+ }
154
+ }}
155
+ />
156
+ <span>~</span>
157
+ <InputNumber
158
+ style={inputNumberStyle}
159
+ size={size}
160
+ bordered={bordered}
161
+ controls={controls}
162
+ disabled={disabled}
163
+ keyboard={keyboard}
164
+ placeholder={placeholder}
165
+ min={min}
166
+ max={max}
167
+ step={step}
168
+ precision={precision}
169
+ readOnly={readOnly}
170
+ value={breakpoints[i + 1]}
171
+ onChange={(e) => {
172
+ if (
173
+ e !== null &&
174
+ i === breakpoints.length - 2 &&
175
+ e > breakpoints[i]
176
+ ) {
177
+ let _breakpoints = [...breakpoints];
178
+ _breakpoints[i + 1] = e;
179
+ setProps({ breakpoints: _breakpoints });
180
+ } else if (
181
+ e !== null &&
182
+ e > breakpoints[i] &&
183
+ e < breakpoints[i + 2]
184
+ ) {
185
+ let _breakpoints = [...breakpoints];
186
+ _breakpoints[i + 1] = e;
187
+ setProps({ breakpoints: _breakpoints });
188
+ } else if (e !== null) {
189
+ message.warning({
190
+ content: "数值超出相邻断点,请调整后再输入!",
191
+ duration: 1.5
192
+ });
193
+ }
194
+ }}
195
+ />
196
+ </>
197
+ )
198
+ }
199
+ {colorBlockPosition === 'right' ?
200
+ (<div
201
+ style={{
202
+ height: size2size.get(size),
203
+ backgroundColor: colors[i],
204
+ width: size2size.get(size),
205
+ ...colorBlockStyle
206
+ }}
207
+ />) : null
208
+ }
209
+ </Space>
210
+ );
211
+ })}
212
+ </Space>
213
+ );
214
+ }
215
+
216
+ export default AntdSegmentedColoring;
217
+
218
+ AntdSegmentedColoring.defaultProps = defaultProps;
219
+ AntdSegmentedColoring.propTypes = propTypes;