@pisell/date-picker 1.0.83 → 1.0.85
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/es/PisellDateRangePicker/index.js +47 -22
- package/es/PisellDateRangePicker/index.less +1 -0
- package/es/Toolbar/index.js +24 -2
- package/es/Toolbar/index.less +3 -0
- package/es/internals/utils/date-fields-utils.d.ts +1 -1
- package/es/locales/en-US.d.ts +2 -0
- package/es/locales/en-US.js +3 -1
- package/es/locales/zh-CN.d.ts +2 -0
- package/es/locales/zh-CN.js +3 -1
- package/es/locales/zh-TW.d.ts +2 -0
- package/es/locales/zh-TW.js +3 -1
- package/lib/PisellDateRangePicker/index.js +35 -6
- package/lib/PisellDateRangePicker/index.less +1 -0
- package/lib/Toolbar/index.js +20 -2
- package/lib/Toolbar/index.less +3 -0
- package/lib/internals/utils/date-fields-utils.d.ts +1 -1
- package/lib/locales/en-US.d.ts +2 -0
- package/lib/locales/en-US.js +3 -1
- package/lib/locales/zh-CN.d.ts +2 -0
- package/lib/locales/zh-CN.js +3 -1
- package/lib/locales/zh-TW.d.ts +2 -0
- package/lib/locales/zh-TW.js +3 -1
- package/package.json +1 -1
|
@@ -92,6 +92,10 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
92
92
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
93
93
|
currentShortcut = _useState4[0],
|
|
94
94
|
setCurrentShortcut = _useState4[1];
|
|
95
|
+
var _useState5 = useState('start'),
|
|
96
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
97
|
+
rangePosition = _useState6[0],
|
|
98
|
+
setRangePosition = _useState6[1];
|
|
95
99
|
var lastConfirmShortcut = useRef(isString(propsValue) ? propsValue : null);
|
|
96
100
|
useEffect(function () {
|
|
97
101
|
isBoolean(propsOpen) && setOpen(propsOpen);
|
|
@@ -99,12 +103,12 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
99
103
|
var _presets = useMemo(function () {
|
|
100
104
|
return formatPresets(presets || defaultPresets, locale);
|
|
101
105
|
}, [presets]);
|
|
102
|
-
var
|
|
106
|
+
var _useState7 = useState(function () {
|
|
103
107
|
return transDayjsArr(propsValue, defaultValue, _presets);
|
|
104
108
|
}),
|
|
105
|
-
|
|
106
|
-
_value =
|
|
107
|
-
setValue =
|
|
109
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
110
|
+
_value = _useState8[0],
|
|
111
|
+
setValue = _useState8[1];
|
|
108
112
|
useEffect(function () {
|
|
109
113
|
setValue(transDayjsArr(propsValue, defaultValue, _presets));
|
|
110
114
|
if (isString(propsValue)) {
|
|
@@ -159,11 +163,12 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
159
163
|
return item || null;
|
|
160
164
|
});
|
|
161
165
|
}
|
|
162
|
-
if (!clearEndOnSelection) {
|
|
163
|
-
if (
|
|
164
|
-
newVal
|
|
165
|
-
}
|
|
166
|
-
|
|
166
|
+
if (!clearEndOnSelection && type !== "shortcuts") {
|
|
167
|
+
if (rangePosition === 'start') {
|
|
168
|
+
newVal = [newVal[0], newVal[0]];
|
|
169
|
+
}
|
|
170
|
+
if (!newVal[1]) {
|
|
171
|
+
newVal = [newVal[0], newVal[0]];
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
if (clearEndOnSelection && type !== "set" && _value.filter(Boolean).length === 2) {
|
|
@@ -243,7 +248,12 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
243
248
|
// defaultValue={defaultValue}
|
|
244
249
|
// key={`${_value?.[0]?.valueOf()}-${_value?.[1]?.valueOf()}`}
|
|
245
250
|
, {
|
|
246
|
-
desktopModeMediaQuery: desktopModeMediaQuery
|
|
251
|
+
desktopModeMediaQuery: desktopModeMediaQuery
|
|
252
|
+
// onSelectedSectionsChange={(val) => {
|
|
253
|
+
// console.log(val,'valval');
|
|
254
|
+
// }}
|
|
255
|
+
// selectedSections={null}
|
|
256
|
+
,
|
|
247
257
|
onMonthChange: onMonthChange,
|
|
248
258
|
minDate: minDate,
|
|
249
259
|
maxDate: maxDate,
|
|
@@ -254,18 +264,13 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
254
264
|
onClose: handleClose,
|
|
255
265
|
onChange: handleChange,
|
|
256
266
|
onOpen: handleOpen,
|
|
257
|
-
open: open
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
//
|
|
262
|
-
// // } else {
|
|
263
|
-
// setRangePosition(rp)
|
|
264
|
-
// // }
|
|
265
|
-
// }}
|
|
266
|
-
// // defaultRangePosition="start"
|
|
267
|
-
// rangePosition={_value.every((item) => Boolean(item)) ? "start" : undefined}
|
|
267
|
+
open: open,
|
|
268
|
+
onRangePositionChange: function onRangePositionChange(rp) {
|
|
269
|
+
setRangePosition(rp);
|
|
270
|
+
}
|
|
271
|
+
// defaultRangePosition="start"
|
|
268
272
|
,
|
|
273
|
+
rangePosition: rangePosition,
|
|
269
274
|
defaultCalendarMonth: defaultCalendarMonth,
|
|
270
275
|
shouldDisableDate: function shouldDisableDate(current, position) {
|
|
271
276
|
return disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(current, position, _value);
|
|
@@ -282,6 +287,7 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
282
287
|
dayOfWeekFormatter: function dayOfWeekFormatter(day) {
|
|
283
288
|
return day;
|
|
284
289
|
},
|
|
290
|
+
disableDragEditing: true,
|
|
285
291
|
slotProps: {
|
|
286
292
|
shortcuts: {
|
|
287
293
|
items: [],
|
|
@@ -320,7 +326,26 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
320
326
|
popper: {
|
|
321
327
|
className: popupClassName,
|
|
322
328
|
disablePortal: disablePortal,
|
|
323
|
-
placement: placement
|
|
329
|
+
placement: placement,
|
|
330
|
+
modifiers: [{
|
|
331
|
+
name: 'flip',
|
|
332
|
+
enabled: true,
|
|
333
|
+
options: {
|
|
334
|
+
altBoundary: true,
|
|
335
|
+
rootBoundary: 'viewport',
|
|
336
|
+
padding: 8
|
|
337
|
+
}
|
|
338
|
+
}, {
|
|
339
|
+
name: 'preventOverflow',
|
|
340
|
+
enabled: true,
|
|
341
|
+
options: {
|
|
342
|
+
altAxis: true,
|
|
343
|
+
altBoundary: true,
|
|
344
|
+
tether: true,
|
|
345
|
+
rootBoundary: 'viewport',
|
|
346
|
+
padding: 8
|
|
347
|
+
}
|
|
348
|
+
}]
|
|
324
349
|
},
|
|
325
350
|
dialog: {
|
|
326
351
|
disablePortal: disablePortal
|
package/es/Toolbar/index.js
CHANGED
|
@@ -35,14 +35,24 @@ var Toolbar = function Toolbar(props) {
|
|
|
35
35
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
36
|
endStr = _useState4[0],
|
|
37
37
|
setEndStr = _useState4[1];
|
|
38
|
+
var _useState5 = useState(false),
|
|
39
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
40
|
+
startError = _useState6[0],
|
|
41
|
+
setStartError = _useState6[1];
|
|
42
|
+
var _useState7 = useState(false),
|
|
43
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
44
|
+
endError = _useState8[0],
|
|
45
|
+
setEndError = _useState8[1];
|
|
38
46
|
useEffect(function () {
|
|
39
47
|
if (value !== null && value !== void 0 && value[0]) {
|
|
40
48
|
setStartStr(value[0].format(format));
|
|
49
|
+
setStartError(false);
|
|
41
50
|
} else {
|
|
42
51
|
setStartStr('');
|
|
43
52
|
}
|
|
44
53
|
if (value !== null && value !== void 0 && value[1]) {
|
|
45
54
|
setEndStr(value[1].format(format));
|
|
55
|
+
setEndError(false);
|
|
46
56
|
} else {
|
|
47
57
|
setEndStr('');
|
|
48
58
|
}
|
|
@@ -52,11 +62,14 @@ var Toolbar = function Toolbar(props) {
|
|
|
52
62
|
setStartStr(val);
|
|
53
63
|
if (isValidDate(val, format)) {
|
|
54
64
|
var _start$set, _start$set$set;
|
|
65
|
+
setStartError(false);
|
|
55
66
|
var valDate = dayjs(val, format);
|
|
56
67
|
var newValue = _toConsumableArray(value);
|
|
57
68
|
var start = newValue[0] || dayjs();
|
|
58
69
|
newValue[0] = (start === null || start === void 0 ? void 0 : (_start$set = start.set('year', (valDate === null || valDate === void 0 ? void 0 : valDate.get('year')) || 0)) === null || _start$set === void 0 ? void 0 : (_start$set$set = _start$set.set('month', (valDate === null || valDate === void 0 ? void 0 : valDate.get('month')) || 0)) === null || _start$set$set === void 0 ? void 0 : _start$set$set.set('date', (valDate === null || valDate === void 0 ? void 0 : valDate.get('date')) || 0)) || null;
|
|
59
70
|
onChange(newValue);
|
|
71
|
+
} else {
|
|
72
|
+
setStartError(true);
|
|
60
73
|
}
|
|
61
74
|
};
|
|
62
75
|
var handleEndChange = function handleEndChange(e) {
|
|
@@ -64,11 +77,14 @@ var Toolbar = function Toolbar(props) {
|
|
|
64
77
|
setEndStr(val);
|
|
65
78
|
if (isValidDate(val, format)) {
|
|
66
79
|
var _end$set, _end$set$set;
|
|
80
|
+
setEndError(false);
|
|
67
81
|
var valDate = dayjs(val, format);
|
|
68
82
|
var newValue = _toConsumableArray(value);
|
|
69
83
|
var end = newValue[1] || dayjs();
|
|
70
84
|
newValue[1] = (end === null || end === void 0 ? void 0 : (_end$set = end.set('year', (valDate === null || valDate === void 0 ? void 0 : valDate.get('year')) || 0)) === null || _end$set === void 0 ? void 0 : (_end$set$set = _end$set.set('month', (valDate === null || valDate === void 0 ? void 0 : valDate.get('month')) || 0)) === null || _end$set$set === void 0 ? void 0 : _end$set$set.set('date', (valDate === null || valDate === void 0 ? void 0 : valDate.get('date')) || 0)) || null;
|
|
71
85
|
onChange(newValue);
|
|
86
|
+
} else {
|
|
87
|
+
setEndError(true);
|
|
72
88
|
}
|
|
73
89
|
};
|
|
74
90
|
var handleSelectChange = function handleSelectChange(e) {
|
|
@@ -106,17 +122,23 @@ var Toolbar = function Toolbar(props) {
|
|
|
106
122
|
}, /*#__PURE__*/React.createElement("div", {
|
|
107
123
|
className: "date-picker-toolbar-start-wrap"
|
|
108
124
|
}, /*#__PURE__*/React.createElement("span", null, getText('toolbar-date-range-shortcut-starting', pLocaleMap[locale])), /*#__PURE__*/React.createElement(Input, {
|
|
125
|
+
status: startError ? "error" : "",
|
|
109
126
|
size: "large",
|
|
110
127
|
value: startStr,
|
|
111
128
|
onChange: handleStartChange,
|
|
112
129
|
placeholder: dayjs().format(format)
|
|
113
|
-
})
|
|
130
|
+
}), startError && /*#__PURE__*/React.createElement("span", {
|
|
131
|
+
className: "date-picker-error"
|
|
132
|
+
}, getText('toolbar-date-range-invalid-start-date', pLocaleMap[locale]))), /*#__PURE__*/React.createElement("div", {
|
|
114
133
|
className: "date-picker-toolbar-end-wrap"
|
|
115
134
|
}, /*#__PURE__*/React.createElement("span", null, getText('toolbar-date-range-shortcut-ending', pLocaleMap[locale])), /*#__PURE__*/React.createElement(Input, {
|
|
135
|
+
status: endError ? "error" : "",
|
|
116
136
|
size: "large",
|
|
117
137
|
value: endStr,
|
|
118
138
|
onChange: handleEndChange,
|
|
119
139
|
placeholder: dayjs().format(format)
|
|
120
|
-
})
|
|
140
|
+
}), endError && /*#__PURE__*/React.createElement("span", {
|
|
141
|
+
className: "date-picker-error"
|
|
142
|
+
}, getText('toolbar-date-range-invalid-end-date', pLocaleMap[locale])))));
|
|
121
143
|
};
|
|
122
144
|
export default Toolbar;
|
package/es/Toolbar/index.less
CHANGED
|
@@ -5,7 +5,7 @@ export declare const splitDateRangeSections: (sections: RangeFieldSection[]) =>
|
|
|
5
5
|
};
|
|
6
6
|
export declare const removeLastSeparator: (dateSections: RangeFieldSection[]) => (RangeFieldSection | {
|
|
7
7
|
separator: null;
|
|
8
|
-
dateName: "
|
|
8
|
+
dateName: "start" | "end";
|
|
9
9
|
value: string;
|
|
10
10
|
format: string;
|
|
11
11
|
maxLength: number | null;
|
package/es/locales/en-US.d.ts
CHANGED
|
@@ -20,5 +20,7 @@ declare const _default: {
|
|
|
20
20
|
"toolbar-date-range-shortcut-next-30-days": string;
|
|
21
21
|
"toolbar-date-range-shortcut-next-90-days": string;
|
|
22
22
|
"toolbar-date-range-shortcut-next-180-days": string;
|
|
23
|
+
"toolbar-date-range-invalid-start-date": string;
|
|
24
|
+
"toolbar-date-range-invalid-end-date": string;
|
|
23
25
|
};
|
|
24
26
|
export default _default;
|
package/es/locales/en-US.js
CHANGED
|
@@ -19,5 +19,7 @@ export default {
|
|
|
19
19
|
"toolbar-date-range-shortcut-next-7-days": "Next 7 days",
|
|
20
20
|
"toolbar-date-range-shortcut-next-30-days": "Next 30 days",
|
|
21
21
|
"toolbar-date-range-shortcut-next-90-days": "Next 90 days",
|
|
22
|
-
"toolbar-date-range-shortcut-next-180-days": "Next 180 days"
|
|
22
|
+
"toolbar-date-range-shortcut-next-180-days": "Next 180 days",
|
|
23
|
+
"toolbar-date-range-invalid-start-date": "Invalid start date",
|
|
24
|
+
"toolbar-date-range-invalid-end-date": "Invalid end date"
|
|
23
25
|
};
|
package/es/locales/zh-CN.d.ts
CHANGED
|
@@ -20,5 +20,7 @@ declare const _default: {
|
|
|
20
20
|
"toolbar-date-range-shortcut-next-30-days": string;
|
|
21
21
|
"toolbar-date-range-shortcut-next-90-days": string;
|
|
22
22
|
"toolbar-date-range-shortcut-next-180-days": string;
|
|
23
|
+
"toolbar-date-range-invalid-start-date": string;
|
|
24
|
+
"toolbar-date-range-invalid-end-date": string;
|
|
23
25
|
};
|
|
24
26
|
export default _default;
|
package/es/locales/zh-CN.js
CHANGED
|
@@ -19,5 +19,7 @@ export default {
|
|
|
19
19
|
"toolbar-date-range-shortcut-next-7-days": "未来7天",
|
|
20
20
|
"toolbar-date-range-shortcut-next-30-days": "未来30天",
|
|
21
21
|
"toolbar-date-range-shortcut-next-90-days": "未来90天",
|
|
22
|
-
"toolbar-date-range-shortcut-next-180-days": "未来180天"
|
|
22
|
+
"toolbar-date-range-shortcut-next-180-days": "未来180天",
|
|
23
|
+
"toolbar-date-range-invalid-start-date": "开始日期无效",
|
|
24
|
+
"toolbar-date-range-invalid-end-date": "结束日期无效"
|
|
23
25
|
};
|
package/es/locales/zh-TW.d.ts
CHANGED
|
@@ -20,5 +20,7 @@ declare const _default: {
|
|
|
20
20
|
"toolbar-date-range-shortcut-next-30-days": string;
|
|
21
21
|
"toolbar-date-range-shortcut-next-90-days": string;
|
|
22
22
|
"toolbar-date-range-shortcut-next-180-days": string;
|
|
23
|
+
"toolbar-date-range-invalid-start-date": string;
|
|
24
|
+
"toolbar-date-range-invalid-end-date": string;
|
|
23
25
|
};
|
|
24
26
|
export default _default;
|
package/es/locales/zh-TW.js
CHANGED
|
@@ -19,5 +19,7 @@ export default {
|
|
|
19
19
|
"toolbar-date-range-shortcut-next-7-days": "未來7天",
|
|
20
20
|
"toolbar-date-range-shortcut-next-30-days": "未來30天",
|
|
21
21
|
"toolbar-date-range-shortcut-next-90-days": "未來90天",
|
|
22
|
-
"toolbar-date-range-shortcut-next-180-days": "未來180天"
|
|
22
|
+
"toolbar-date-range-shortcut-next-180-days": "未來180天",
|
|
23
|
+
"toolbar-date-range-invalid-start-date": "開始日期無效",
|
|
24
|
+
"toolbar-date-range-invalid-end-date": "結束日期無效"
|
|
23
25
|
};
|
|
@@ -101,6 +101,7 @@ var PisellDateRangePicker = (props) => {
|
|
|
101
101
|
const [open, setOpen] = (0, import_react.useState)(propsOpen ?? false);
|
|
102
102
|
const { locale } = (0, import_react.useContext)(import_LocaleContext.LocaleContext) || {};
|
|
103
103
|
const [currentShortcut, setCurrentShortcut] = (0, import_react.useState)("");
|
|
104
|
+
const [rangePosition, setRangePosition] = (0, import_react.useState)("start");
|
|
104
105
|
const lastConfirmShortcut = (0, import_react.useRef)((0, import_utils.isString)(propsValue) ? propsValue : null);
|
|
105
106
|
(0, import_react.useEffect)(() => {
|
|
106
107
|
(0, import_utils.isBoolean)(propsOpen) && setOpen(propsOpen);
|
|
@@ -164,11 +165,12 @@ var PisellDateRangePicker = (props) => {
|
|
|
164
165
|
return item || null;
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
|
-
if (!clearEndOnSelection) {
|
|
168
|
-
if (
|
|
169
|
-
newVal
|
|
170
|
-
}
|
|
171
|
-
|
|
168
|
+
if (!clearEndOnSelection && type !== "shortcuts") {
|
|
169
|
+
if (rangePosition === "start") {
|
|
170
|
+
newVal = [newVal[0], newVal[0]];
|
|
171
|
+
}
|
|
172
|
+
if (!newVal[1]) {
|
|
173
|
+
newVal = [newVal[0], newVal[0]];
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
176
|
if (clearEndOnSelection && type !== "set" && _value.filter(Boolean).length === 2) {
|
|
@@ -262,6 +264,10 @@ var PisellDateRangePicker = (props) => {
|
|
|
262
264
|
onChange: handleChange,
|
|
263
265
|
onOpen: handleOpen,
|
|
264
266
|
open,
|
|
267
|
+
onRangePositionChange: (rp) => {
|
|
268
|
+
setRangePosition(rp);
|
|
269
|
+
},
|
|
270
|
+
rangePosition,
|
|
265
271
|
defaultCalendarMonth,
|
|
266
272
|
shouldDisableDate: (current, position) => disabledDate == null ? void 0 : disabledDate(current, position, _value),
|
|
267
273
|
slots: {
|
|
@@ -276,6 +282,7 @@ var PisellDateRangePicker = (props) => {
|
|
|
276
282
|
dayOfWeekFormatter: (day) => {
|
|
277
283
|
return day;
|
|
278
284
|
},
|
|
285
|
+
disableDragEditing: true,
|
|
279
286
|
slotProps: {
|
|
280
287
|
shortcuts: {
|
|
281
288
|
items: [],
|
|
@@ -315,7 +322,29 @@ var PisellDateRangePicker = (props) => {
|
|
|
315
322
|
popper: {
|
|
316
323
|
className: popupClassName,
|
|
317
324
|
disablePortal,
|
|
318
|
-
placement
|
|
325
|
+
placement,
|
|
326
|
+
modifiers: [
|
|
327
|
+
{
|
|
328
|
+
name: "flip",
|
|
329
|
+
enabled: true,
|
|
330
|
+
options: {
|
|
331
|
+
altBoundary: true,
|
|
332
|
+
rootBoundary: "viewport",
|
|
333
|
+
padding: 8
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "preventOverflow",
|
|
338
|
+
enabled: true,
|
|
339
|
+
options: {
|
|
340
|
+
altAxis: true,
|
|
341
|
+
altBoundary: true,
|
|
342
|
+
tether: true,
|
|
343
|
+
rootBoundary: "viewport",
|
|
344
|
+
padding: 8
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
]
|
|
319
348
|
},
|
|
320
349
|
dialog: {
|
|
321
350
|
disablePortal
|
package/lib/Toolbar/index.js
CHANGED
|
@@ -54,14 +54,18 @@ var Toolbar = (props) => {
|
|
|
54
54
|
const format = locale === "en" || locale === "en-US" ? "DD/MM/YYYY" : "YYYY/MM/DD";
|
|
55
55
|
const [startStr, setStartStr] = (0, import_react.useState)("");
|
|
56
56
|
const [endStr, setEndStr] = (0, import_react.useState)("");
|
|
57
|
+
const [startError, setStartError] = (0, import_react.useState)(false);
|
|
58
|
+
const [endError, setEndError] = (0, import_react.useState)(false);
|
|
57
59
|
(0, import_react.useEffect)(() => {
|
|
58
60
|
if (value == null ? void 0 : value[0]) {
|
|
59
61
|
setStartStr(value[0].format(format));
|
|
62
|
+
setStartError(false);
|
|
60
63
|
} else {
|
|
61
64
|
setStartStr("");
|
|
62
65
|
}
|
|
63
66
|
if (value == null ? void 0 : value[1]) {
|
|
64
67
|
setEndStr(value[1].format(format));
|
|
68
|
+
setEndError(false);
|
|
65
69
|
} else {
|
|
66
70
|
setEndStr("");
|
|
67
71
|
}
|
|
@@ -71,11 +75,14 @@ var Toolbar = (props) => {
|
|
|
71
75
|
const val = e.target.value;
|
|
72
76
|
setStartStr(val);
|
|
73
77
|
if (isValidDate(val, format)) {
|
|
78
|
+
setStartError(false);
|
|
74
79
|
const valDate = (0, import_dayjs.default)(val, format);
|
|
75
80
|
const newValue = [...value];
|
|
76
81
|
const start = newValue[0] || (0, import_dayjs.default)();
|
|
77
82
|
newValue[0] = ((_b = (_a = start == null ? void 0 : start.set("year", (valDate == null ? void 0 : valDate.get("year")) || 0)) == null ? void 0 : _a.set("month", (valDate == null ? void 0 : valDate.get("month")) || 0)) == null ? void 0 : _b.set("date", (valDate == null ? void 0 : valDate.get("date")) || 0)) || null;
|
|
78
83
|
onChange(newValue);
|
|
84
|
+
} else {
|
|
85
|
+
setStartError(true);
|
|
79
86
|
}
|
|
80
87
|
};
|
|
81
88
|
const handleEndChange = (e) => {
|
|
@@ -83,11 +90,14 @@ var Toolbar = (props) => {
|
|
|
83
90
|
const val = e.target.value;
|
|
84
91
|
setEndStr(val);
|
|
85
92
|
if (isValidDate(val, format)) {
|
|
93
|
+
setEndError(false);
|
|
86
94
|
const valDate = (0, import_dayjs.default)(val, format);
|
|
87
95
|
const newValue = [...value];
|
|
88
96
|
const end = newValue[1] || (0, import_dayjs.default)();
|
|
89
97
|
newValue[1] = ((_b = (_a = end == null ? void 0 : end.set("year", (valDate == null ? void 0 : valDate.get("year")) || 0)) == null ? void 0 : _a.set("month", (valDate == null ? void 0 : valDate.get("month")) || 0)) == null ? void 0 : _b.set("date", (valDate == null ? void 0 : valDate.get("date")) || 0)) || null;
|
|
90
98
|
onChange(newValue);
|
|
99
|
+
} else {
|
|
100
|
+
setEndError(true);
|
|
91
101
|
}
|
|
92
102
|
};
|
|
93
103
|
const handleSelectChange = (e) => {
|
|
@@ -135,19 +145,27 @@ var Toolbar = (props) => {
|
|
|
135
145
|
)), /* @__PURE__ */ import_react.default.createElement(
|
|
136
146
|
import_antd.Input,
|
|
137
147
|
{
|
|
148
|
+
status: startError ? "error" : "",
|
|
138
149
|
size: "large",
|
|
139
150
|
value: startStr,
|
|
140
151
|
onChange: handleStartChange,
|
|
141
152
|
placeholder: (0, import_dayjs.default)().format(format)
|
|
142
153
|
}
|
|
143
|
-
)
|
|
154
|
+
), startError && /* @__PURE__ */ import_react.default.createElement("span", { className: "date-picker-error" }, (0, import_locales.getText)(
|
|
155
|
+
"toolbar-date-range-invalid-start-date",
|
|
156
|
+
import_locales.pLocaleMap[locale]
|
|
157
|
+
))), /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-toolbar-end-wrap" }, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_locales.getText)("toolbar-date-range-shortcut-ending", import_locales.pLocaleMap[locale])), /* @__PURE__ */ import_react.default.createElement(
|
|
144
158
|
import_antd.Input,
|
|
145
159
|
{
|
|
160
|
+
status: endError ? "error" : "",
|
|
146
161
|
size: "large",
|
|
147
162
|
value: endStr,
|
|
148
163
|
onChange: handleEndChange,
|
|
149
164
|
placeholder: (0, import_dayjs.default)().format(format)
|
|
150
165
|
}
|
|
151
|
-
))
|
|
166
|
+
), endError && /* @__PURE__ */ import_react.default.createElement("span", { className: "date-picker-error" }, (0, import_locales.getText)(
|
|
167
|
+
"toolbar-date-range-invalid-end-date",
|
|
168
|
+
import_locales.pLocaleMap[locale]
|
|
169
|
+
)))));
|
|
152
170
|
};
|
|
153
171
|
var Toolbar_default = Toolbar;
|
package/lib/Toolbar/index.less
CHANGED
|
@@ -5,7 +5,7 @@ export declare const splitDateRangeSections: (sections: RangeFieldSection[]) =>
|
|
|
5
5
|
};
|
|
6
6
|
export declare const removeLastSeparator: (dateSections: RangeFieldSection[]) => (RangeFieldSection | {
|
|
7
7
|
separator: null;
|
|
8
|
-
dateName: "
|
|
8
|
+
dateName: "start" | "end";
|
|
9
9
|
value: string;
|
|
10
10
|
format: string;
|
|
11
11
|
maxLength: number | null;
|
package/lib/locales/en-US.d.ts
CHANGED
|
@@ -20,5 +20,7 @@ declare const _default: {
|
|
|
20
20
|
"toolbar-date-range-shortcut-next-30-days": string;
|
|
21
21
|
"toolbar-date-range-shortcut-next-90-days": string;
|
|
22
22
|
"toolbar-date-range-shortcut-next-180-days": string;
|
|
23
|
+
"toolbar-date-range-invalid-start-date": string;
|
|
24
|
+
"toolbar-date-range-invalid-end-date": string;
|
|
23
25
|
};
|
|
24
26
|
export default _default;
|
package/lib/locales/en-US.js
CHANGED
|
@@ -43,5 +43,7 @@ var en_US_default = {
|
|
|
43
43
|
"toolbar-date-range-shortcut-next-7-days": "Next 7 days",
|
|
44
44
|
"toolbar-date-range-shortcut-next-30-days": "Next 30 days",
|
|
45
45
|
"toolbar-date-range-shortcut-next-90-days": "Next 90 days",
|
|
46
|
-
"toolbar-date-range-shortcut-next-180-days": "Next 180 days"
|
|
46
|
+
"toolbar-date-range-shortcut-next-180-days": "Next 180 days",
|
|
47
|
+
"toolbar-date-range-invalid-start-date": "Invalid start date",
|
|
48
|
+
"toolbar-date-range-invalid-end-date": "Invalid end date"
|
|
47
49
|
};
|
package/lib/locales/zh-CN.d.ts
CHANGED
|
@@ -20,5 +20,7 @@ declare const _default: {
|
|
|
20
20
|
"toolbar-date-range-shortcut-next-30-days": string;
|
|
21
21
|
"toolbar-date-range-shortcut-next-90-days": string;
|
|
22
22
|
"toolbar-date-range-shortcut-next-180-days": string;
|
|
23
|
+
"toolbar-date-range-invalid-start-date": string;
|
|
24
|
+
"toolbar-date-range-invalid-end-date": string;
|
|
23
25
|
};
|
|
24
26
|
export default _default;
|
package/lib/locales/zh-CN.js
CHANGED
|
@@ -43,5 +43,7 @@ var zh_CN_default = {
|
|
|
43
43
|
"toolbar-date-range-shortcut-next-7-days": "未来7天",
|
|
44
44
|
"toolbar-date-range-shortcut-next-30-days": "未来30天",
|
|
45
45
|
"toolbar-date-range-shortcut-next-90-days": "未来90天",
|
|
46
|
-
"toolbar-date-range-shortcut-next-180-days": "未来180天"
|
|
46
|
+
"toolbar-date-range-shortcut-next-180-days": "未来180天",
|
|
47
|
+
"toolbar-date-range-invalid-start-date": "开始日期无效",
|
|
48
|
+
"toolbar-date-range-invalid-end-date": "结束日期无效"
|
|
47
49
|
};
|
package/lib/locales/zh-TW.d.ts
CHANGED
|
@@ -20,5 +20,7 @@ declare const _default: {
|
|
|
20
20
|
"toolbar-date-range-shortcut-next-30-days": string;
|
|
21
21
|
"toolbar-date-range-shortcut-next-90-days": string;
|
|
22
22
|
"toolbar-date-range-shortcut-next-180-days": string;
|
|
23
|
+
"toolbar-date-range-invalid-start-date": string;
|
|
24
|
+
"toolbar-date-range-invalid-end-date": string;
|
|
23
25
|
};
|
|
24
26
|
export default _default;
|
package/lib/locales/zh-TW.js
CHANGED
|
@@ -43,5 +43,7 @@ var zh_TW_default = {
|
|
|
43
43
|
"toolbar-date-range-shortcut-next-7-days": "未來7天",
|
|
44
44
|
"toolbar-date-range-shortcut-next-30-days": "未來30天",
|
|
45
45
|
"toolbar-date-range-shortcut-next-90-days": "未來90天",
|
|
46
|
-
"toolbar-date-range-shortcut-next-180-days": "未來180天"
|
|
46
|
+
"toolbar-date-range-shortcut-next-180-days": "未來180天",
|
|
47
|
+
"toolbar-date-range-invalid-start-date": "開始日期無效",
|
|
48
|
+
"toolbar-date-range-invalid-end-date": "結束日期無效"
|
|
47
49
|
};
|