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,85 @@
|
|
|
1
|
+
import React, { useContext, useEffect } from 'react';
|
|
2
|
+
import { Checkbox } 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/AntdCheckbox.react';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// 定义选择框组件AntdCheckbox,api参数参考https://ant.design/components/checkbox-cn/
|
|
10
|
+
const AntdCheckbox = (props) => {
|
|
11
|
+
// 取得必要属性或参数
|
|
12
|
+
let {
|
|
13
|
+
id,
|
|
14
|
+
style,
|
|
15
|
+
className,
|
|
16
|
+
key,
|
|
17
|
+
label,
|
|
18
|
+
disabled,
|
|
19
|
+
checked,
|
|
20
|
+
indeterminate,
|
|
21
|
+
readOnly,
|
|
22
|
+
setProps,
|
|
23
|
+
persistence,
|
|
24
|
+
persisted_props,
|
|
25
|
+
persistence_type,
|
|
26
|
+
loading_state,
|
|
27
|
+
batchPropsNames
|
|
28
|
+
} = props;
|
|
29
|
+
|
|
30
|
+
// 批属性监听
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (batchPropsNames && batchPropsNames.length !== 0) {
|
|
33
|
+
let _batchPropsValues = {};
|
|
34
|
+
for (let propName of batchPropsNames) {
|
|
35
|
+
_batchPropsValues[propName] = props[propName];
|
|
36
|
+
}
|
|
37
|
+
setProps({
|
|
38
|
+
batchPropsValues: _batchPropsValues
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const context = useContext(PropsContext)
|
|
44
|
+
|
|
45
|
+
const onChange = e => {
|
|
46
|
+
if (!readOnly) {
|
|
47
|
+
setProps({ checked: e.target.checked })
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 返回定制化的前端组件
|
|
52
|
+
return (
|
|
53
|
+
<Checkbox
|
|
54
|
+
id={id}
|
|
55
|
+
className={
|
|
56
|
+
isString(className) ?
|
|
57
|
+
className :
|
|
58
|
+
(className ? useCss(className) : undefined)
|
|
59
|
+
}
|
|
60
|
+
style={style}
|
|
61
|
+
key={key}
|
|
62
|
+
onChange={onChange}
|
|
63
|
+
disabled={
|
|
64
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
65
|
+
context.componentDisabled :
|
|
66
|
+
disabled
|
|
67
|
+
}
|
|
68
|
+
checked={checked}
|
|
69
|
+
indeterminate={indeterminate}
|
|
70
|
+
persistence={persistence}
|
|
71
|
+
persisted_props={persisted_props}
|
|
72
|
+
persistence_type={persistence_type}
|
|
73
|
+
data-dash-is-loading={
|
|
74
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
75
|
+
}
|
|
76
|
+
>
|
|
77
|
+
{label}
|
|
78
|
+
</Checkbox>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default AntdCheckbox;
|
|
83
|
+
|
|
84
|
+
AntdCheckbox.defaultProps = defaultProps;
|
|
85
|
+
AntdCheckbox.propTypes = propTypes;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useContext, useEffect } from 'react';
|
|
2
|
+
import { Checkbox } 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/AntdCheckboxGroup.react';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// 定义组合选择框组件AntdCheckboxGroup,api参数参考https://ant.design/components/checkbox-cn/
|
|
10
|
+
const AntdCheckboxGroup = (props) => {
|
|
11
|
+
// 取得必要属性或参数
|
|
12
|
+
let {
|
|
13
|
+
id,
|
|
14
|
+
style,
|
|
15
|
+
className,
|
|
16
|
+
key,
|
|
17
|
+
options,
|
|
18
|
+
value,
|
|
19
|
+
disabled,
|
|
20
|
+
readOnly,
|
|
21
|
+
setProps,
|
|
22
|
+
persistence,
|
|
23
|
+
persisted_props,
|
|
24
|
+
persistence_type,
|
|
25
|
+
loading_state,
|
|
26
|
+
batchPropsNames
|
|
27
|
+
} = props;
|
|
28
|
+
|
|
29
|
+
// 批属性监听
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (batchPropsNames && batchPropsNames.length !== 0) {
|
|
32
|
+
let _batchPropsValues = {};
|
|
33
|
+
for (let propName of batchPropsNames) {
|
|
34
|
+
_batchPropsValues[propName] = props[propName];
|
|
35
|
+
}
|
|
36
|
+
setProps({
|
|
37
|
+
batchPropsValues: _batchPropsValues
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const context = useContext(PropsContext)
|
|
43
|
+
|
|
44
|
+
const onChange = e => {
|
|
45
|
+
if (!readOnly) {
|
|
46
|
+
setProps({ value: e })
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 返回定制化的前端组件
|
|
51
|
+
return (
|
|
52
|
+
<Checkbox.Group
|
|
53
|
+
id={id}
|
|
54
|
+
className={
|
|
55
|
+
isString(className) ?
|
|
56
|
+
className :
|
|
57
|
+
(className ? useCss(className) : undefined)
|
|
58
|
+
}
|
|
59
|
+
style={style}
|
|
60
|
+
key={key}
|
|
61
|
+
options={options}
|
|
62
|
+
value={value}
|
|
63
|
+
disabled={
|
|
64
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
65
|
+
context.componentDisabled :
|
|
66
|
+
disabled
|
|
67
|
+
}
|
|
68
|
+
onChange={onChange}
|
|
69
|
+
persistence={persistence}
|
|
70
|
+
persisted_props={persisted_props}
|
|
71
|
+
persistence_type={persistence_type}
|
|
72
|
+
data-dash-is-loading={
|
|
73
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
74
|
+
}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default AntdCheckboxGroup;
|
|
80
|
+
|
|
81
|
+
AntdCheckboxGroup.defaultProps = defaultProps;
|
|
82
|
+
AntdCheckboxGroup.propTypes = propTypes;
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import React, { useEffect, useContext } from 'react';
|
|
2
|
+
import { DatePicker, ConfigProvider } from 'antd';
|
|
3
|
+
import moment from 'moment';
|
|
4
|
+
import { isString, isUndefined, isObject } from 'lodash';
|
|
5
|
+
import "moment/locale/zh-cn";
|
|
6
|
+
import { str2Locale } from '../../components/locales.react';
|
|
7
|
+
import useCss from '../../hooks/useCss';
|
|
8
|
+
import PropsContext from '../../contexts/PropsContext';
|
|
9
|
+
import { propTypes, defaultProps } from '../../components/dataEntry/AntdDatePicker.react';
|
|
10
|
+
|
|
11
|
+
// 定义日期选择组件AntdDatePicker,api参数参考https://ant.design/components/date-picker-cn/
|
|
12
|
+
const AntdDatePicker = (props) => {
|
|
13
|
+
// 取得必要属性或参数
|
|
14
|
+
let {
|
|
15
|
+
id,
|
|
16
|
+
className,
|
|
17
|
+
style,
|
|
18
|
+
key,
|
|
19
|
+
locale,
|
|
20
|
+
setProps,
|
|
21
|
+
picker,
|
|
22
|
+
format,
|
|
23
|
+
firstDayOfWeek,
|
|
24
|
+
disabled,
|
|
25
|
+
showTime,
|
|
26
|
+
allowClear,
|
|
27
|
+
placeholder,
|
|
28
|
+
disabledDatesStrategy,
|
|
29
|
+
defaultPickerValue,
|
|
30
|
+
value,
|
|
31
|
+
defaultValue,
|
|
32
|
+
bordered,
|
|
33
|
+
size,
|
|
34
|
+
status,
|
|
35
|
+
popupContainer,
|
|
36
|
+
readOnly,
|
|
37
|
+
placement,
|
|
38
|
+
extraFooter,
|
|
39
|
+
showToday,
|
|
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
|
+
// 调整不同showTime下的format缺省参数
|
|
71
|
+
if (showTime && !format) {
|
|
72
|
+
setProps({
|
|
73
|
+
format: 'YYYY-MM-DD HH:mm:ss'
|
|
74
|
+
})
|
|
75
|
+
} else if (!showTime && !format) {
|
|
76
|
+
setProps({
|
|
77
|
+
format: 'YYYY-MM-DD'
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// defaultPickerValue为空时默认定位到今日对应面板位置
|
|
82
|
+
if (!defaultPickerValue) {
|
|
83
|
+
setProps({
|
|
84
|
+
defaultPickerValue: moment(new Date()).format(format || 'YYYY-MM-DD')
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}, [])
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (!isUndefined(firstDayOfWeek)) {
|
|
91
|
+
moment.locale(
|
|
92
|
+
locale === 'en-us' ? 'en' : locale,
|
|
93
|
+
{
|
|
94
|
+
week: {
|
|
95
|
+
dow: firstDayOfWeek
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
}, [firstDayOfWeek])
|
|
101
|
+
|
|
102
|
+
const onChange = (date, dateString) => {
|
|
103
|
+
if (isString(dateString)) {
|
|
104
|
+
setProps({ value: dateString })
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const checkDisabledDate = current => {
|
|
109
|
+
|
|
110
|
+
// 根据disabledDatesStrategy设定的各个子条件进行是否禁用判断
|
|
111
|
+
for (let i = 0; i < disabledDatesStrategy.length; i++) {
|
|
112
|
+
let strategy = disabledDatesStrategy[i];
|
|
113
|
+
// 判断当前子策略方式
|
|
114
|
+
if (strategy.mode === 'eq') {
|
|
115
|
+
// 判断当前子策略约束目标
|
|
116
|
+
if (strategy.target === 'day') {
|
|
117
|
+
if (current.date() === strategy.value) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
} else if (strategy.target === 'month') {
|
|
121
|
+
if (current.month() === strategy.value) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
} else if (strategy.target === 'quarter') {
|
|
125
|
+
if (current.quarter() === strategy.value) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
} else if (strategy.target === 'year') {
|
|
129
|
+
if (current.year() === strategy.value) {
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
} else if (strategy.target === 'dayOfYear') {
|
|
133
|
+
if (current.dayOfYear() === strategy.value) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
} else if (strategy.target === 'dayOfWeek') {
|
|
137
|
+
if (current.isoWeekday() === strategy.value) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
} else if (strategy.target === 'specific-date') {
|
|
141
|
+
if (current.isSame(moment(strategy.value, 'YYYY-MM-DD'))) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
} else if (strategy.mode === 'ne') {
|
|
146
|
+
// 判断当前子策略约束目标
|
|
147
|
+
if (strategy.target === 'day') {
|
|
148
|
+
if (current.date() !== strategy.value) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
} else if (strategy.target === 'month') {
|
|
152
|
+
if (current.month() !== strategy.value) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
} else if (strategy.target === 'quarter') {
|
|
156
|
+
if (current.quarter() !== strategy.value) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
} else if (strategy.target === 'year') {
|
|
160
|
+
if (current.year() !== strategy.value) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
} else if (strategy.target === 'dayOfYear') {
|
|
164
|
+
if (current.dayOfYear() !== strategy.value) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
} else if (strategy.target === 'dayOfWeek') {
|
|
168
|
+
if (current.isoWeekday() !== strategy.value) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
} else if (strategy.target === 'specific-date') {
|
|
172
|
+
if (!current.isSame(moment(strategy.value, 'YYYY-MM-DD'))) {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
} else if (strategy.mode === 'le') {
|
|
177
|
+
// 判断当前子策略约束目标
|
|
178
|
+
if (strategy.target === 'day') {
|
|
179
|
+
if (current.date() <= strategy.value) {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
} else if (strategy.target === 'month') {
|
|
183
|
+
if (current.month() <= strategy.value) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
} else if (strategy.target === 'quarter') {
|
|
187
|
+
if (current.quarter() <= strategy.value) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
} else if (strategy.target === 'year') {
|
|
191
|
+
if (current.year() <= strategy.value) {
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
} else if (strategy.target === 'dayOfYear') {
|
|
195
|
+
if (current.dayOfYear() <= strategy.value) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
} else if (strategy.target === 'dayOfWeek') {
|
|
199
|
+
if (current.isoWeekday() <= strategy.value) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
} else if (strategy.target === 'specific-date') {
|
|
203
|
+
if (current.isSameOrBefore(moment(strategy.value, 'YYYY-MM-DD'))) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
} else if (strategy.mode === 'lt') {
|
|
208
|
+
// 判断当前子策略约束目标
|
|
209
|
+
if (strategy.target === 'day') {
|
|
210
|
+
if (current.date() < strategy.value) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
} else if (strategy.target === 'month') {
|
|
214
|
+
if (current.month() < strategy.value) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
} else if (strategy.target === 'quarter') {
|
|
218
|
+
if (current.quarter() < strategy.value) {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
} else if (strategy.target === 'year') {
|
|
222
|
+
if (current.year() < strategy.value) {
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
} else if (strategy.target === 'dayOfYear') {
|
|
226
|
+
if (current.dayOfYear() < strategy.value) {
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
} else if (strategy.target === 'dayOfWeek') {
|
|
230
|
+
if (current.isoWeekday() < strategy.value) {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
} else if (strategy.target === 'specific-date') {
|
|
234
|
+
if (current.isBefore(moment(strategy.value, 'YYYY-MM-DD'))) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
} else if (strategy.mode === 'ge') {
|
|
239
|
+
// 判断当前子策略约束目标
|
|
240
|
+
if (strategy.target === 'day') {
|
|
241
|
+
if (current.date() >= strategy.value) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
} else if (strategy.target === 'month') {
|
|
245
|
+
if (current.month() >= strategy.value) {
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
} else if (strategy.target === 'quarter') {
|
|
249
|
+
if (current.quarter() >= strategy.value) {
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
} else if (strategy.target === 'year') {
|
|
253
|
+
if (current.year() >= strategy.value) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
} else if (strategy.target === 'dayOfYear') {
|
|
257
|
+
if (current.dayOfYear() >= strategy.value) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
} else if (strategy.target === 'dayOfWeek') {
|
|
261
|
+
if (current.isoWeekday() >= strategy.value) {
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
} else if (strategy.target === 'specific-date') {
|
|
265
|
+
if (current.isSameOrAfter(moment(strategy.value, 'YYYY-MM-DD'))) {
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
} else if (strategy.mode === 'gt') {
|
|
270
|
+
// 判断当前子策略约束目标
|
|
271
|
+
if (strategy.target === 'day') {
|
|
272
|
+
if (current.date() > strategy.value) {
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
} else if (strategy.target === 'month') {
|
|
276
|
+
if (current.month() > strategy.value) {
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
} else if (strategy.target === 'quarter') {
|
|
280
|
+
if (current.quarter() > strategy.value) {
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
} else if (strategy.target === 'year') {
|
|
284
|
+
if (current.year() > strategy.value) {
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
} else if (strategy.target === 'dayOfYear') {
|
|
288
|
+
if (current.dayOfYear() > strategy.value) {
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
} else if (strategy.target === 'dayOfWeek') {
|
|
292
|
+
if (current.isoWeekday() > strategy.value) {
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
} else if (strategy.target === 'specific-date') {
|
|
296
|
+
if (current.isAfter(moment(strategy.value, 'YYYY-MM-DD'))) {
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
} else if (strategy.mode === 'in') {
|
|
301
|
+
// 判断当前子策略约束目标
|
|
302
|
+
if (strategy.target === 'day') {
|
|
303
|
+
if (strategy.value.includes(current.date())) {
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
} else if (strategy.target === 'month') {
|
|
307
|
+
if (strategy.value.includes(current.month())) {
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
} else if (strategy.target === 'quarter') {
|
|
311
|
+
if (strategy.value.includes(current.quarter())) {
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
} else if (strategy.target === 'year') {
|
|
315
|
+
if (strategy.value.includes(current.year())) {
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
} else if (strategy.target === 'dayOfYear') {
|
|
319
|
+
if (strategy.value.includes(current.dayOfYear())) {
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
} else if (strategy.target === 'dayOfWeek') {
|
|
323
|
+
if (strategy.value.includes(current.isoWeekday())) {
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
} else if (strategy.mode === 'not-in') {
|
|
328
|
+
// 判断当前子策略约束目标
|
|
329
|
+
if (strategy.target === 'day') {
|
|
330
|
+
if (!strategy.value.includes(current.date())) {
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
} else if (strategy.target === 'month') {
|
|
334
|
+
if (!strategy.value.includes(current.month())) {
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
} else if (strategy.target === 'quarter') {
|
|
338
|
+
if (!strategy.value.includes(current.quarter())) {
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
} else if (strategy.target === 'year') {
|
|
342
|
+
if (!strategy.value.includes(current.year())) {
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
} else if (strategy.target === 'dayOfYear') {
|
|
346
|
+
if (!strategy.value.includes(current.dayOfYear())) {
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
} else if (strategy.target === 'dayOfWeek') {
|
|
350
|
+
if (!strategy.value.includes(current.isoWeekday())) {
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
} else if (strategy.mode === 'in-enumerate-dates') {
|
|
355
|
+
if (strategy.value.includes(current.format(format))) {
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
} else if (strategy.mode === 'not-in-enumerate-dates') {
|
|
359
|
+
if (!strategy.value.includes(current.format(format))) {
|
|
360
|
+
return true;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// 返回定制化的前端组件
|
|
367
|
+
return (
|
|
368
|
+
<div>
|
|
369
|
+
<ConfigProvider
|
|
370
|
+
locale={str2Locale.get(locale)}
|
|
371
|
+
>
|
|
372
|
+
<DatePicker
|
|
373
|
+
id={id}
|
|
374
|
+
className={
|
|
375
|
+
isString(className) ?
|
|
376
|
+
className :
|
|
377
|
+
(className ? useCss(className) : undefined)
|
|
378
|
+
}
|
|
379
|
+
style={style}
|
|
380
|
+
key={key}
|
|
381
|
+
format={format}
|
|
382
|
+
onChange={onChange}
|
|
383
|
+
picker={picker}
|
|
384
|
+
calendarStartDay={firstDayOfWeek}
|
|
385
|
+
disabled={
|
|
386
|
+
context && !isUndefined(context.componentDisabled) ?
|
|
387
|
+
context.componentDisabled :
|
|
388
|
+
disabled
|
|
389
|
+
}
|
|
390
|
+
placeholder={placeholder}
|
|
391
|
+
bordered={bordered}
|
|
392
|
+
size={
|
|
393
|
+
context && !isUndefined(context.componentSize) ?
|
|
394
|
+
context.componentSize :
|
|
395
|
+
size
|
|
396
|
+
}
|
|
397
|
+
disabledDate={disabledDatesStrategy ? checkDisabledDate : undefined}
|
|
398
|
+
defaultPickerValue={moment(defaultPickerValue, format)}
|
|
399
|
+
value={value ? moment(value, format) : undefined}
|
|
400
|
+
defaultValue={defaultValue ? moment(defaultValue, format) : undefined}
|
|
401
|
+
showTime={
|
|
402
|
+
// 处理时间选择面板在日期选定后的默认选中值
|
|
403
|
+
isObject(showTime) && showTime.defaultValue ?
|
|
404
|
+
{
|
|
405
|
+
defaultValue: moment(showTime.defaultValue, showTime.format || 'HH:mm:ss')
|
|
406
|
+
} :
|
|
407
|
+
showTime
|
|
408
|
+
}
|
|
409
|
+
allowClear={isUndefined(readOnly) ? allowClear : !readOnly}
|
|
410
|
+
status={status}
|
|
411
|
+
placement={placement}
|
|
412
|
+
open={isUndefined(readOnly) || !readOnly ? undefined : false}
|
|
413
|
+
inputReadOnly={readOnly}
|
|
414
|
+
renderExtraFooter={() => extraFooter}
|
|
415
|
+
showToday={showToday}
|
|
416
|
+
persistence={persistence}
|
|
417
|
+
persisted_props={persisted_props}
|
|
418
|
+
persistence_type={persistence_type}
|
|
419
|
+
data-dash-is-loading={
|
|
420
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
421
|
+
}
|
|
422
|
+
getPopupContainer={
|
|
423
|
+
popupContainer === 'parent' ?
|
|
424
|
+
(triggerNode) => triggerNode.parentNode :
|
|
425
|
+
undefined
|
|
426
|
+
}
|
|
427
|
+
/>
|
|
428
|
+
</ConfigProvider>
|
|
429
|
+
</div>
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
export default AntdDatePicker;
|
|
434
|
+
|
|
435
|
+
AntdDatePicker.defaultProps = defaultProps;
|
|
436
|
+
AntdDatePicker.propTypes = propTypes;
|