@rockshin/tao-ui 0.0.48 → 0.0.49
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/dist/components/affix/affix.js +20 -16
- package/dist/components/alert/alert.js +114 -99
- package/dist/components/app/app-modals.js +134 -96
- package/dist/components/app/app-notices.js +39 -23
- package/dist/components/auto-complete/auto-complete.js +21 -7
- package/dist/components/avatar/avatar.js +31 -11
- package/dist/components/badge/badge.css +1 -1
- package/dist/components/badge/badge.js +72 -257
- package/dist/components/border-beam/border-beam.js +21 -17
- package/dist/components/breadcrumb/breadcrumb.js +178 -159
- package/dist/components/button/button.js +61 -53
- package/dist/components/calendar/calendar.js +6 -4
- package/dist/components/card/card.js +24 -8
- package/dist/components/carousel/carousel.d.ts +1 -1
- package/dist/components/carousel/carousel.js +105 -68
- package/dist/components/cascader/cascader.js +54 -19
- package/dist/components/checkbox/checkbox.css +13 -2
- package/dist/components/checkbox/checkbox.d.ts +2 -0
- package/dist/components/checkbox/checkbox.js +320 -229
- package/dist/components/collapse/collapse-panels.d.ts +1 -1
- package/dist/components/collapse/collapse-panels.js +122 -113
- package/dist/components/collapse/collapse.js +98 -63
- package/dist/components/color-picker/color-picker.js +539 -441
- package/dist/components/color-picker/color.js +1 -1
- package/dist/components/context-menu/context-menu.d.ts +1 -1
- package/dist/components/context-menu/context-menu.js +108 -68
- package/dist/components/date-picker/calendar/calendar-grid.js +42 -39
- package/dist/components/date-picker/calendar/month-grid.d.ts +8 -1
- package/dist/components/date-picker/calendar/month-grid.js +79 -37
- package/dist/components/date-picker/calendar/time-panel.d.ts +2 -1
- package/dist/components/date-picker/calendar/time-panel.js +94 -89
- package/dist/components/date-picker/calendar/year-grid.d.ts +8 -1
- package/dist/components/date-picker/calendar/year-grid.js +66 -35
- package/dist/components/date-picker/date-picker.css +24 -1
- package/dist/components/date-picker/date-picker.js +99 -53
- package/dist/components/date-picker/presets.d.ts +2 -1
- package/dist/components/date-picker/presets.js +27 -24
- package/dist/components/date-picker/range-picker.js +308 -153
- package/dist/components/descriptions/descriptions.js +7 -3
- package/dist/components/divider/divider.css +1 -1
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/drawer/drawer.js +201 -369
- package/dist/components/dropdown/dropdown.d.ts +1 -1
- package/dist/components/dropdown/dropdown.js +183 -279
- package/dist/components/empty/empty.js +57 -78
- package/dist/components/float-button/float-button.d.ts +1 -0
- package/dist/components/float-button/float-button.js +47 -30
- package/dist/components/form/field-control.d.ts +4 -2
- package/dist/components/form/field-control.js +17 -9
- package/dist/components/form/form-context.d.ts +8 -2
- package/dist/components/form/form-context.js +2 -1
- package/dist/components/form/form-item.js +85 -63
- package/dist/components/form/use-form.d.ts +2 -1
- package/dist/components/form/use-form.js +2 -1
- package/dist/components/form-field/form-field-view.d.ts +3 -1
- package/dist/components/form-field/form-field-view.js +194 -141
- package/dist/components/form-section/form-section.d.ts +1 -1
- package/dist/components/form-section/form-section.js +52 -45
- package/dist/components/image/image.js +585 -477
- package/dist/components/input/base-input.js +8 -9
- package/dist/components/input/input-shared.d.ts +5 -2
- package/dist/components/input/input-shared.js +42 -18
- package/dist/components/input/otp.js +236 -217
- package/dist/components/input/password.js +2 -1
- package/dist/components/input/search.js +8 -7
- package/dist/components/list/list-pagination.js +41 -36
- package/dist/components/list/list.js +141 -125
- package/dist/components/listy/listy.js +175 -106
- package/dist/components/masonry/masonry.js +108 -85
- package/dist/components/mentions/mentions.js +12 -3
- package/dist/components/menu/menu-render.d.ts +9 -3
- package/dist/components/menu/menu-render.js +99 -36
- package/dist/components/modal/confirm-dialog.js +10 -4
- package/dist/components/modal/confirm.js +3 -7
- package/dist/components/modal/index.js +9 -3
- package/dist/components/modal/modal.js +390 -365
- package/dist/components/pagination/pagination.js +105 -96
- package/dist/components/popconfirm/popconfirm.d.ts +1 -1
- package/dist/components/popconfirm/popconfirm.js +219 -168
- package/dist/components/popover/popover.js +330 -243
- package/dist/components/progress/progress.css +2 -2
- package/dist/components/progress/progress.js +232 -458
- package/dist/components/qr-code/qr-code.js +72 -66
- package/dist/components/radio/radio.css +15 -4
- package/dist/components/radio/radio.d.ts +2 -1
- package/dist/components/radio/radio.js +260 -198
- package/dist/components/rate/rate.js +173 -113
- package/dist/components/scroll-area/scroll-area.js +241 -211
- package/dist/components/segmented/segmented.js +73 -41
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +24 -13
- package/dist/components/select/select-searchable-list.d.ts +2 -1
- package/dist/components/select/select-searchable-list.js +2 -3
- package/dist/components/select/select.js +49 -25
- package/dist/components/select/use-select-selection.d.ts +1 -1
- package/dist/components/select/use-select-selection.js +7 -4
- package/dist/components/skeleton/skeleton.js +56 -48
- package/dist/components/slider/slider.js +87 -212
- package/dist/components/sonner/sonner.js +109 -93
- package/dist/components/spinner/spinner.js +147 -138
- package/dist/components/splitter/splitter.js +222 -159
- package/dist/components/statistic/statistic.js +7 -6
- package/dist/components/steps/steps.js +88 -81
- package/dist/components/steps/use-display-steps.js +1 -1
- package/dist/components/switch/switch.js +89 -89
- package/dist/components/table/table-filter.js +66 -56
- package/dist/components/table/table-icons.d.ts +2 -1
- package/dist/components/table/table-icons.js +11 -9
- package/dist/components/table/table-model.js +1 -1
- package/dist/components/table/table.js +107 -83
- package/dist/components/table/use-table-data.d.ts +6 -3
- package/dist/components/table/use-table-data.js +166 -130
- package/dist/components/tabs/tabs.css +1 -1
- package/dist/components/tabs/tabs.js +236 -179
- package/dist/components/tag/tag.d.ts +2 -2
- package/dist/components/tag/tag.js +111 -108
- package/dist/components/textarea/textarea.js +22 -17
- package/dist/components/time-picker/time-picker.js +5 -3
- package/dist/components/timeline/timeline.css +6 -1
- package/dist/components/timeline/timeline.js +21 -11
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/components/tooltip/tooltip.js +123 -233
- package/dist/components/tour/tour.css +4 -0
- package/dist/components/tour/tour.js +400 -331
- package/dist/components/transfer/transfer-list.js +29 -11
- package/dist/components/transfer/transfer-parts.js +1 -1
- package/dist/components/transfer/transfer-types.d.ts +1 -0
- package/dist/components/transfer/transfer.js +29 -14
- package/dist/components/tree/tree-keyboard.d.ts +1 -1
- package/dist/components/tree/tree-keyboard.js +5 -3
- package/dist/components/tree/tree.js +74 -59
- package/dist/components/tree-select/select-engine.d.ts +3 -2
- package/dist/components/tree-select/select-engine.js +18 -16
- package/dist/components/tree-select/tree-select.js +21 -5
- package/dist/components/upload/upload.css +8 -0
- package/dist/components/upload/upload.js +160 -72
- package/dist/components/watermark/watermark.js +36 -29
- package/dist/number-input/use-number-input.js +129 -90
- package/dist/number-input/validate.js +32 -5
- package/dist/provider/merge-locale.js +12 -9
- package/dist/provider/tao-provider.d.ts +3 -1
- package/dist/provider/tao-provider.js +123 -86
- package/package.json +1 -1
|
@@ -8,7 +8,11 @@ import { useMobileTitle } from "../../utils/field-label.js";
|
|
|
8
8
|
import { mergeRefs } from "../../utils/refs.js";
|
|
9
9
|
import { cx } from "../../utils/semantic.js";
|
|
10
10
|
import { Drawer } from "../drawer/drawer.js";
|
|
11
|
+
import { Button } from "../button/button.js";
|
|
11
12
|
import { CalendarGrid } from "./calendar/calendar-grid.js";
|
|
13
|
+
import { MonthGrid } from "./calendar/month-grid.js";
|
|
14
|
+
import { YearGrid } from "./calendar/year-grid.js";
|
|
15
|
+
import { TimePanel } from "./calendar/time-panel.js";
|
|
12
16
|
import "./date-picker.css";
|
|
13
17
|
import { Presets } from "./presets.js";
|
|
14
18
|
import { formatPickerDate, parsePickerDate } from "./date-localization.js";
|
|
@@ -31,6 +35,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
31
35
|
const startDisabled = (Array.isArray(disabled) ? disabled[0] : disabled) ?? ctx.disabled;
|
|
32
36
|
const endDisabled = (Array.isArray(disabled) ? disabled[1] : disabled) ?? ctx.disabled;
|
|
33
37
|
const resolvedDisabled = startDisabled && endDisabled;
|
|
38
|
+
const defaultActiveInput = startDisabled && !endDisabled ? 'end' : 'start';
|
|
34
39
|
const autoMobile = useIsMobile();
|
|
35
40
|
const isMobile = mobile ?? autoMobile;
|
|
36
41
|
const mobileTriggerRef = useRef(null);
|
|
@@ -54,25 +59,30 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
54
59
|
isMobile
|
|
55
60
|
]);
|
|
56
61
|
const fmt = formatProp ?? getDefaultFormat(picker, showTime);
|
|
62
|
+
const withTime = 'date' === picker && !!showTime;
|
|
63
|
+
const granularity = 'date' === picker ? 'day' : picker;
|
|
64
|
+
const orderUnit = withTime ? void 0 : granularity;
|
|
57
65
|
const dayjsLocale = ctx.locale.dayjsLocale;
|
|
58
66
|
const numberLocale = ctx.locale.numberLocale;
|
|
59
67
|
const formatValue = useCallback((date)=>formatPickerDate(date, fmt, dayjsLocale), [
|
|
60
68
|
fmt,
|
|
61
69
|
dayjsLocale
|
|
62
70
|
]);
|
|
63
|
-
const isDateBlocked = useCallback((date_0)=>!date_0.isValid() || Boolean(disabledDate?.(date_0)) || null != minDate && date_0.isBefore(minDate,
|
|
71
|
+
const isDateBlocked = useCallback((date_0)=>!date_0.isValid() || Boolean(disabledDate?.(date_0)) || null != minDate && date_0.isBefore(minDate, granularity) || null != maxDate && date_0.isAfter(maxDate, granularity), [
|
|
64
72
|
disabledDate,
|
|
65
73
|
minDate,
|
|
66
|
-
maxDate
|
|
74
|
+
maxDate,
|
|
75
|
+
granularity
|
|
67
76
|
]);
|
|
68
77
|
const isValueControlled = 'value' in props;
|
|
69
78
|
const [internalValue, setInternalValue] = useState(defaultValue ?? null);
|
|
70
79
|
const resolvedValue = isValueControlled ? value ?? null : internalValue;
|
|
80
|
+
const [timeDraft, setTimeDraft] = useState();
|
|
71
81
|
const emitChange = useCallback((dates)=>{
|
|
72
82
|
if (resolvedDisabled) return false;
|
|
73
83
|
const start = (startDisabled ? resolvedValue?.[0] : dates?.[0]) ?? null;
|
|
74
84
|
const end = (endDisabled ? resolvedValue?.[1] : dates?.[1]) ?? null;
|
|
75
|
-
if ((startDisabled || endDisabled) && start && end && start.isAfter(end)) return false;
|
|
85
|
+
if ((startDisabled || endDisabled) && start && end && start.isAfter(end, orderUnit)) return false;
|
|
76
86
|
const nextValue = start || end ? [
|
|
77
87
|
start,
|
|
78
88
|
end
|
|
@@ -90,52 +100,76 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
90
100
|
endDisabled,
|
|
91
101
|
resolvedDisabled,
|
|
92
102
|
resolvedValue,
|
|
93
|
-
formatValue
|
|
103
|
+
formatValue,
|
|
104
|
+
orderUnit
|
|
94
105
|
]);
|
|
95
106
|
const [internalOpen, setInternalOpen] = useState(false);
|
|
96
107
|
const isOpen = controlledOpen ?? internalOpen;
|
|
108
|
+
const workingValue = withTime && isOpen && void 0 !== timeDraft ? timeDraft : resolvedValue;
|
|
109
|
+
const changeRange = useCallback((dates_0)=>{
|
|
110
|
+
if (withTime) setTimeDraft(dates_0);
|
|
111
|
+
else emitChange(dates_0);
|
|
112
|
+
}, [
|
|
113
|
+
withTime,
|
|
114
|
+
emitChange
|
|
115
|
+
]);
|
|
97
116
|
const [interaction, setInteraction] = useState({
|
|
98
117
|
phase: 'idle',
|
|
99
|
-
activeInput:
|
|
118
|
+
activeInput: defaultActiveInput
|
|
100
119
|
});
|
|
101
120
|
const controlledValueKey = isValueControlled ? `${resolvedValue?.[0]?.valueOf() ?? 'null'}:${resolvedValue?.[1]?.valueOf() ?? 'null'}` : void 0;
|
|
102
121
|
const setOpen = useCallback((v)=>{
|
|
103
|
-
if (v && resolvedDisabled) return;
|
|
122
|
+
if (v === isOpen || v && resolvedDisabled) return;
|
|
104
123
|
setInternalOpen(v);
|
|
105
124
|
onOpenChange?.(v);
|
|
106
125
|
}, [
|
|
126
|
+
isOpen,
|
|
107
127
|
onOpenChange,
|
|
108
128
|
resolvedDisabled
|
|
109
129
|
]);
|
|
110
130
|
useEffect(()=>{
|
|
111
|
-
if (!isOpen)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
if (!isOpen) {
|
|
132
|
+
setInteraction({
|
|
133
|
+
phase: 'idle',
|
|
134
|
+
activeInput: defaultActiveInput
|
|
135
|
+
});
|
|
136
|
+
setTimeDraft(void 0);
|
|
137
|
+
}
|
|
115
138
|
}, [
|
|
116
|
-
isOpen
|
|
139
|
+
isOpen,
|
|
140
|
+
defaultActiveInput
|
|
117
141
|
]);
|
|
118
142
|
useEffect(()=>{
|
|
119
|
-
if (void 0 !== controlledValueKey)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
143
|
+
if (void 0 !== controlledValueKey) {
|
|
144
|
+
setTimeDraft(void 0);
|
|
145
|
+
setInteraction((current)=>({
|
|
146
|
+
phase: 'idle',
|
|
147
|
+
activeInput: 'pickingEnd' === current.phase ? 'start' : current.activeInput
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
123
150
|
}, [
|
|
124
151
|
controlledValueKey
|
|
125
152
|
]);
|
|
126
153
|
const [viewDateStart, setViewDateStart] = useState(()=>resolvedValue?.[0] ?? resolvedValue?.[1] ?? dayjs());
|
|
127
154
|
const wasOpenRef = useRef(false);
|
|
128
155
|
useEffect(()=>{
|
|
129
|
-
if (isOpen && !wasOpenRef.current)
|
|
156
|
+
if (isOpen && !wasOpenRef.current) {
|
|
157
|
+
const openAtEnd = !endDisabled && (startDisabled || 'end' === interaction.activeInput);
|
|
158
|
+
setViewDateStart(resolvedValue?.[openAtEnd ? 1 : 0] ?? resolvedValue?.[0] ?? resolvedValue?.[1] ?? dayjs());
|
|
159
|
+
}
|
|
130
160
|
wasOpenRef.current = isOpen;
|
|
131
161
|
}, [
|
|
132
162
|
isOpen,
|
|
133
163
|
resolvedValue,
|
|
134
|
-
interaction.activeInput
|
|
164
|
+
interaction.activeInput,
|
|
165
|
+
startDisabled,
|
|
166
|
+
endDisabled
|
|
135
167
|
]);
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
const
|
|
168
|
+
const panelStep = 'year' === picker ? 10 : 1;
|
|
169
|
+
const panelUnit = 'date' === picker ? 'month' : 'year';
|
|
170
|
+
const viewDateEnd = viewDateStart.add(panelStep, panelUnit);
|
|
171
|
+
const rangeStart = 'pickingEnd' === interaction.phase ? interaction.start : workingValue?.[0] ?? null;
|
|
172
|
+
const rangeEnd = 'pickingEnd' === interaction.phase ? null : workingValue?.[1] ?? null;
|
|
139
173
|
const hoverDate = 'pickingEnd' === interaction.phase ? interaction.hover : null;
|
|
140
174
|
const setHoverDate = useCallback((hover)=>{
|
|
141
175
|
setInteraction((current_0)=>'pickingEnd' === current_0.phase ? {
|
|
@@ -144,35 +178,45 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
144
178
|
} : current_0);
|
|
145
179
|
}, []);
|
|
146
180
|
const handleDateSelect = useCallback((date_1)=>{
|
|
181
|
+
const position_0 = startDisabled || !endDisabled && 'end' === interaction.activeInput ? 1 : 0;
|
|
182
|
+
const previous = workingValue?.[position_0] ?? resolvedValue?.[position_0];
|
|
183
|
+
if (withTime && previous) date_1 = date_1.hour(previous.hour()).minute(previous.minute()).second(previous.second()).millisecond(previous.millisecond());
|
|
147
184
|
if (startDisabled || endDisabled) {
|
|
148
|
-
|
|
185
|
+
const next = startDisabled ? [
|
|
149
186
|
rangeStart,
|
|
150
187
|
date_1
|
|
151
188
|
] : [
|
|
152
189
|
date_1,
|
|
153
190
|
rangeEnd
|
|
154
|
-
]
|
|
191
|
+
];
|
|
192
|
+
if (next[0] && next[1] && next[0].isAfter(next[1], granularity)) return;
|
|
193
|
+
changeRange(next);
|
|
155
194
|
setInteraction({
|
|
156
195
|
phase: 'idle',
|
|
157
196
|
activeInput: startDisabled ? 'end' : 'start'
|
|
158
197
|
});
|
|
159
|
-
if (!
|
|
198
|
+
if (!withTime) setOpen(false);
|
|
160
199
|
return;
|
|
161
200
|
}
|
|
162
|
-
if ('idle' === interaction.phase && 'start' === interaction.activeInput)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
201
|
+
if ('idle' === interaction.phase && 'start' === interaction.activeInput) {
|
|
202
|
+
if (withTime) setTimeDraft([
|
|
203
|
+
date_1,
|
|
204
|
+
workingValue?.[1] ?? null
|
|
205
|
+
]);
|
|
206
|
+
setInteraction({
|
|
207
|
+
phase: 'pickingEnd',
|
|
208
|
+
activeInput: 'end',
|
|
209
|
+
start: date_1,
|
|
210
|
+
hover: null
|
|
211
|
+
});
|
|
212
|
+
} else {
|
|
169
213
|
let start_0 = 'pickingEnd' === interaction.phase ? interaction.start : rangeStart;
|
|
170
214
|
let end_0 = date_1;
|
|
171
|
-
if (start_0 && date_1.isBefore(start_0)) [start_0, end_0] = [
|
|
215
|
+
if (start_0 && date_1.isBefore(start_0, orderUnit)) [start_0, end_0] = [
|
|
172
216
|
date_1,
|
|
173
217
|
start_0
|
|
174
218
|
];
|
|
175
|
-
|
|
219
|
+
changeRange([
|
|
176
220
|
start_0,
|
|
177
221
|
end_0
|
|
178
222
|
]);
|
|
@@ -180,21 +224,26 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
180
224
|
phase: 'idle',
|
|
181
225
|
activeInput: 'start'
|
|
182
226
|
});
|
|
183
|
-
if (!
|
|
227
|
+
if (!withTime) setOpen(false);
|
|
184
228
|
}
|
|
185
229
|
}, [
|
|
186
230
|
interaction,
|
|
187
231
|
rangeStart,
|
|
188
232
|
rangeEnd,
|
|
189
|
-
|
|
233
|
+
changeRange,
|
|
190
234
|
startDisabled,
|
|
191
235
|
endDisabled,
|
|
192
|
-
|
|
193
|
-
|
|
236
|
+
withTime,
|
|
237
|
+
workingValue,
|
|
238
|
+
resolvedValue,
|
|
239
|
+
setOpen,
|
|
240
|
+
granularity,
|
|
241
|
+
orderUnit
|
|
194
242
|
]);
|
|
195
243
|
const handleClear = useCallback((e)=>{
|
|
196
244
|
e.stopPropagation();
|
|
197
245
|
emitChange(null);
|
|
246
|
+
setTimeDraft(void 0);
|
|
198
247
|
setInteraction({
|
|
199
248
|
phase: 'idle',
|
|
200
249
|
activeInput: 'start'
|
|
@@ -204,22 +253,28 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
204
253
|
]);
|
|
205
254
|
const handlePresetSelect = useCallback((val)=>{
|
|
206
255
|
const [s, e_0] = val;
|
|
207
|
-
if (!startDisabled && isDateBlocked(s) || !endDisabled && isDateBlocked(e_0) || !startDisabled && !endDisabled && s.isAfter(e_0)) return;
|
|
208
|
-
|
|
209
|
-
s,
|
|
210
|
-
e_0
|
|
211
|
-
]
|
|
256
|
+
if (!startDisabled && isDateBlocked(s) || !endDisabled && isDateBlocked(e_0) || !startDisabled && !endDisabled && s.isAfter(e_0, orderUnit)) return;
|
|
257
|
+
const next_0 = [
|
|
258
|
+
startDisabled ? resolvedValue?.[0] ?? null : s,
|
|
259
|
+
endDisabled ? resolvedValue?.[1] ?? null : e_0
|
|
260
|
+
];
|
|
261
|
+
if (resolvedDisabled || next_0[0] && next_0[1] && next_0[0].isAfter(next_0[1], orderUnit)) return;
|
|
262
|
+
changeRange(next_0);
|
|
212
263
|
setInteraction({
|
|
213
264
|
phase: 'idle',
|
|
214
265
|
activeInput: 'start'
|
|
215
266
|
});
|
|
216
|
-
setOpen(false);
|
|
267
|
+
if (!withTime) setOpen(false);
|
|
217
268
|
}, [
|
|
218
|
-
|
|
269
|
+
changeRange,
|
|
219
270
|
setOpen,
|
|
220
271
|
isDateBlocked,
|
|
221
272
|
startDisabled,
|
|
222
|
-
endDisabled
|
|
273
|
+
endDisabled,
|
|
274
|
+
resolvedValue,
|
|
275
|
+
resolvedDisabled,
|
|
276
|
+
withTime,
|
|
277
|
+
orderUnit
|
|
223
278
|
]);
|
|
224
279
|
const displayStart = formatValue(rangeStart);
|
|
225
280
|
const displayEnd = formatValue(rangeEnd);
|
|
@@ -231,42 +286,74 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
231
286
|
useEffect(()=>setInputEnd(displayEnd), [
|
|
232
287
|
displayEnd
|
|
233
288
|
]);
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const
|
|
289
|
+
const editingStart = 'start' === interaction.activeInput;
|
|
290
|
+
const typedText = (editingStart ? inputStart : inputEnd).trim();
|
|
291
|
+
const hasTypedEdit = typedText !== (editingStart ? displayStart : displayEnd);
|
|
292
|
+
const typedValue = useMemo(()=>{
|
|
293
|
+
if (!typedText || !hasTypedEdit) return null;
|
|
294
|
+
const parsed = parsePickerDate(typedText, fmt, dayjsLocale, numberLocale);
|
|
295
|
+
if (isDateBlocked(parsed) || editingStart && rangeEnd && parsed.isAfter(rangeEnd, orderUnit) || !editingStart && rangeStart && parsed.isBefore(rangeStart, orderUnit)) return null;
|
|
296
|
+
return parsed;
|
|
297
|
+
}, [
|
|
298
|
+
editingStart,
|
|
299
|
+
typedText,
|
|
300
|
+
hasTypedEdit,
|
|
301
|
+
fmt,
|
|
302
|
+
dayjsLocale,
|
|
303
|
+
numberLocale,
|
|
304
|
+
isDateBlocked,
|
|
305
|
+
rangeStart,
|
|
306
|
+
rangeEnd,
|
|
307
|
+
orderUnit
|
|
308
|
+
]);
|
|
309
|
+
const panelStart = editingStart ? typedValue ?? rangeStart : rangeStart;
|
|
310
|
+
const panelEnd = editingStart ? rangeEnd : typedValue ?? rangeEnd;
|
|
311
|
+
useEffect(()=>{
|
|
312
|
+
if (typedValue) setViewDateStart(typedValue);
|
|
313
|
+
}, [
|
|
314
|
+
typedValue
|
|
315
|
+
]);
|
|
316
|
+
const commitInputValue = useCallback((position_1, keepPopupOpen = false)=>{
|
|
317
|
+
if ('start' === position_1 ? startDisabled : endDisabled) return;
|
|
318
|
+
const text = ('start' === position_1 ? inputStart : inputEnd).trim();
|
|
319
|
+
const currentValue = 'start' === position_1 ? displayStart : displayEnd;
|
|
320
|
+
const parsed_0 = text ? parsePickerDate(text, fmt, dayjsLocale, numberLocale) : null;
|
|
321
|
+
const isBlocked = null != parsed_0 && (isDateBlocked(parsed_0) || 'start' === position_1 && null != rangeEnd && parsed_0.isAfter(rangeEnd, orderUnit) || 'end' === position_1 && null != rangeStart && parsed_0.isBefore(rangeStart, orderUnit));
|
|
240
322
|
if (isBlocked) {
|
|
241
|
-
if ('start' ===
|
|
323
|
+
if ('start' === position_1) setInputStart(currentValue);
|
|
242
324
|
else setInputEnd(currentValue);
|
|
243
325
|
return;
|
|
244
326
|
}
|
|
245
|
-
const nextStart = 'start' ===
|
|
246
|
-
const nextEnd = 'end' ===
|
|
327
|
+
const nextStart = 'start' === position_1 ? parsed_0 : rangeStart;
|
|
328
|
+
const nextEnd = 'end' === position_1 ? parsed_0 : rangeEnd;
|
|
247
329
|
const nextStrings = [
|
|
248
330
|
formatValue(nextStart),
|
|
249
331
|
formatValue(nextEnd)
|
|
250
332
|
];
|
|
251
|
-
if (nextStrings[0] !== displayStart || nextStrings[1] !== displayEnd)
|
|
252
|
-
nextStart
|
|
253
|
-
|
|
254
|
-
|
|
333
|
+
if (nextStrings[0] !== displayStart || nextStrings[1] !== displayEnd) {
|
|
334
|
+
changeRange(nextStart || nextEnd ? [
|
|
335
|
+
nextStart,
|
|
336
|
+
nextEnd
|
|
337
|
+
] : null);
|
|
338
|
+
if (withTime && !isOpen) setOpen(true);
|
|
339
|
+
}
|
|
255
340
|
setInteraction({
|
|
256
341
|
phase: 'idle',
|
|
257
|
-
activeInput:
|
|
342
|
+
activeInput: position_1
|
|
258
343
|
});
|
|
259
|
-
if (
|
|
260
|
-
if ('start' ===
|
|
261
|
-
else setInputEnd(isValueControlled ? displayEnd : nextStrings[1]);
|
|
262
|
-
if (nextStart && nextEnd && !keepPopupOpen) setOpen(false);
|
|
344
|
+
if (parsed_0 && !keepPopupOpen) setViewDateStart(parsed_0);
|
|
345
|
+
if ('start' === position_1) setInputStart(isValueControlled && !withTime ? displayStart : nextStrings[0]);
|
|
346
|
+
else setInputEnd(isValueControlled && !withTime ? displayEnd : nextStrings[1]);
|
|
347
|
+
if (nextStart && nextEnd && !keepPopupOpen && !withTime) setOpen(false);
|
|
263
348
|
}, [
|
|
264
349
|
isDateBlocked,
|
|
265
350
|
startDisabled,
|
|
266
351
|
endDisabled,
|
|
267
352
|
displayEnd,
|
|
268
353
|
displayStart,
|
|
269
|
-
|
|
354
|
+
changeRange,
|
|
355
|
+
withTime,
|
|
356
|
+
isOpen,
|
|
270
357
|
fmt,
|
|
271
358
|
dayjsLocale,
|
|
272
359
|
numberLocale,
|
|
@@ -276,10 +363,29 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
276
363
|
isValueControlled,
|
|
277
364
|
rangeEnd,
|
|
278
365
|
rangeStart,
|
|
279
|
-
setOpen
|
|
366
|
+
setOpen,
|
|
367
|
+
orderUnit
|
|
280
368
|
]);
|
|
281
369
|
const showClearBtn = allowClear && (!startDisabled && rangeStart || !endDisabled && rangeEnd);
|
|
282
|
-
const isDateDisabled = (date_2)=>Boolean(resolvedDisabled || disabledDate?.(date_2) || startDisabled && rangeStart && date_2.isBefore(rangeStart,
|
|
370
|
+
const isDateDisabled = (date_2)=>Boolean(resolvedDisabled || disabledDate?.(date_2) || startDisabled && rangeStart && date_2.isBefore(rangeStart, granularity) || endDisabled && rangeEnd && date_2.isAfter(rangeEnd, granularity));
|
|
371
|
+
const periodTitle = (date_3)=>'date' === picker ? ctx.locale.monthTitle(date_3.month(), date_3.year()) : 'month' === picker ? date_3.format('YYYY') : `${10 * Math.floor(date_3.year() / 10)} – ${10 * Math.floor(date_3.year() / 10) + 9}`;
|
|
372
|
+
const canConfirm = !resolvedDisabled && (!hasTypedEdit || null !== typedValue) && (startDisabled || null != panelStart && !isDateBlocked(panelStart)) && (endDisabled || null != panelEnd && !isDateBlocked(panelEnd)) && !(panelStart && panelEnd && panelStart.isAfter(panelEnd, orderUnit));
|
|
373
|
+
const confirmTimeRange = ()=>{
|
|
374
|
+
if (!canConfirm || !emitChange([
|
|
375
|
+
panelStart,
|
|
376
|
+
panelEnd
|
|
377
|
+
])) return;
|
|
378
|
+
const committedStart = isValueControlled ? resolvedValue?.[0] : panelStart;
|
|
379
|
+
const committedEnd = isValueControlled ? resolvedValue?.[1] : panelEnd;
|
|
380
|
+
setInputStart(formatValue(committedStart));
|
|
381
|
+
setInputEnd(formatValue(committedEnd));
|
|
382
|
+
setTimeDraft(void 0);
|
|
383
|
+
setInteraction({
|
|
384
|
+
phase: 'idle',
|
|
385
|
+
activeInput: 'start'
|
|
386
|
+
});
|
|
387
|
+
setOpen(false);
|
|
388
|
+
};
|
|
283
389
|
const panelContent = /*#__PURE__*/ jsxs("div", {
|
|
284
390
|
"data-tao-range-panel": "",
|
|
285
391
|
className: isMobile ? classNames?.popup : void 0,
|
|
@@ -291,7 +397,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
291
397
|
/*#__PURE__*/ jsxs("div", {
|
|
292
398
|
"data-tao-calendar-nav": "",
|
|
293
399
|
children: [
|
|
294
|
-
/*#__PURE__*/ jsx("button", {
|
|
400
|
+
'date' === picker && /*#__PURE__*/ jsx("button", {
|
|
295
401
|
type: "button",
|
|
296
402
|
"data-tao-calendar-nav-btn": "",
|
|
297
403
|
onClick: ()=>setViewDateStart(viewDateStart.subtract(1, 'year')),
|
|
@@ -301,8 +407,8 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
301
407
|
/*#__PURE__*/ jsx("button", {
|
|
302
408
|
type: "button",
|
|
303
409
|
"data-tao-calendar-nav-btn": "",
|
|
304
|
-
onClick: ()=>setViewDateStart(viewDateStart.subtract(
|
|
305
|
-
"aria-label": ctx.locale.previousMonth,
|
|
410
|
+
onClick: ()=>setViewDateStart(viewDateStart.subtract(panelStep, panelUnit)),
|
|
411
|
+
"aria-label": 'date' === picker ? ctx.locale.previousMonth : 'month' === picker ? ctx.locale.previousYear : ctx.locale.previous,
|
|
306
412
|
children: /*#__PURE__*/ jsx(LeftIcon, {})
|
|
307
413
|
})
|
|
308
414
|
]
|
|
@@ -312,11 +418,11 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
312
418
|
children: [
|
|
313
419
|
/*#__PURE__*/ jsx("span", {
|
|
314
420
|
"data-tao-range-title": "",
|
|
315
|
-
children:
|
|
421
|
+
children: periodTitle(viewDateStart)
|
|
316
422
|
}),
|
|
317
423
|
/*#__PURE__*/ jsx("span", {
|
|
318
424
|
"data-tao-range-title": "",
|
|
319
|
-
children:
|
|
425
|
+
children: periodTitle(viewDateEnd)
|
|
320
426
|
})
|
|
321
427
|
]
|
|
322
428
|
}),
|
|
@@ -326,11 +432,11 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
326
432
|
/*#__PURE__*/ jsx("button", {
|
|
327
433
|
type: "button",
|
|
328
434
|
"data-tao-calendar-nav-btn": "",
|
|
329
|
-
onClick: ()=>setViewDateStart(viewDateStart.add(
|
|
330
|
-
"aria-label": ctx.locale.nextMonth,
|
|
435
|
+
onClick: ()=>setViewDateStart(viewDateStart.add(panelStep, panelUnit)),
|
|
436
|
+
"aria-label": 'date' === picker ? ctx.locale.nextMonth : 'month' === picker ? ctx.locale.nextYear : ctx.locale.next,
|
|
331
437
|
children: /*#__PURE__*/ jsx(RightIcon, {})
|
|
332
438
|
}),
|
|
333
|
-
/*#__PURE__*/ jsx("button", {
|
|
439
|
+
'date' === picker && /*#__PURE__*/ jsx("button", {
|
|
334
440
|
type: "button",
|
|
335
441
|
"data-tao-calendar-nav-btn": "",
|
|
336
442
|
onClick: ()=>setViewDateStart(viewDateStart.add(1, 'year')),
|
|
@@ -341,58 +447,91 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
341
447
|
})
|
|
342
448
|
]
|
|
343
449
|
}),
|
|
344
|
-
/*#__PURE__*/
|
|
450
|
+
/*#__PURE__*/ jsx("div", {
|
|
345
451
|
"data-tao-range-panels": "",
|
|
346
452
|
children: [
|
|
347
|
-
|
|
453
|
+
viewDateStart,
|
|
454
|
+
viewDateEnd
|
|
455
|
+
].map((date_4, index)=>{
|
|
456
|
+
const shared = {
|
|
457
|
+
viewDate: date_4,
|
|
458
|
+
rangeStart: panelStart,
|
|
459
|
+
rangeEnd: panelEnd,
|
|
460
|
+
onSelect: handleDateSelect,
|
|
461
|
+
disabledDate: isDateDisabled,
|
|
462
|
+
minDate,
|
|
463
|
+
maxDate,
|
|
464
|
+
className: classNames?.calendar,
|
|
465
|
+
style: styles?.calendar,
|
|
466
|
+
cellClassName: classNames?.cell,
|
|
467
|
+
cellStyle: styles?.cell
|
|
468
|
+
};
|
|
469
|
+
const endpoint = 0 === index ? panelStart : panelEnd;
|
|
470
|
+
const disabledEndpoint = 0 === index ? startDisabled : endDisabled;
|
|
471
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
348
472
|
"data-tao-picker-panel": "",
|
|
349
|
-
children:
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
473
|
+
children: [
|
|
474
|
+
/*#__PURE__*/ jsx("div", {
|
|
475
|
+
"data-tao-picker-body": "",
|
|
476
|
+
children: 'month' === picker ? /*#__PURE__*/ jsx(MonthGrid, {
|
|
477
|
+
...shared
|
|
478
|
+
}) : 'year' === picker ? /*#__PURE__*/ jsx(YearGrid, {
|
|
479
|
+
...shared
|
|
480
|
+
}) : /*#__PURE__*/ jsx(CalendarGrid, {
|
|
481
|
+
...shared,
|
|
482
|
+
hoverDate: hoverDate,
|
|
483
|
+
onViewDateChange: (next_1)=>setViewDateStart(0 === index ? next_1 : next_1.subtract(panelStep, panelUnit)),
|
|
484
|
+
onHover: setHoverDate
|
|
485
|
+
})
|
|
486
|
+
}),
|
|
487
|
+
withTime && /*#__PURE__*/ jsxs("fieldset", {
|
|
488
|
+
"data-tao-range-time": "",
|
|
489
|
+
disabled: disabledEndpoint || !endpoint,
|
|
490
|
+
children: [
|
|
491
|
+
/*#__PURE__*/ jsx("legend", {
|
|
492
|
+
children: placeholder[index]
|
|
493
|
+
}),
|
|
494
|
+
/*#__PURE__*/ jsx(TimePanel, {
|
|
495
|
+
hour: endpoint?.hour() ?? 0,
|
|
496
|
+
minute: endpoint?.minute() ?? 0,
|
|
497
|
+
second: endpoint?.second() ?? 0,
|
|
498
|
+
onChange: (hour, minute, second)=>{
|
|
499
|
+
if (!endpoint || disabledEndpoint) return;
|
|
500
|
+
const next_2 = endpoint.hour(hour).minute(minute).second(second);
|
|
501
|
+
setTimeDraft(0 === index ? [
|
|
502
|
+
next_2,
|
|
503
|
+
panelEnd
|
|
504
|
+
] : [
|
|
505
|
+
panelStart,
|
|
506
|
+
next_2
|
|
507
|
+
]);
|
|
508
|
+
if (0 === index) setInputStart(formatValue(next_2));
|
|
509
|
+
else setInputEnd(formatValue(next_2));
|
|
510
|
+
if (0 === index && 'pickingEnd' === interaction.phase) setInteraction({
|
|
511
|
+
...interaction,
|
|
512
|
+
start: next_2
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
})
|
|
516
|
+
]
|
|
388
517
|
})
|
|
389
|
-
|
|
390
|
-
})
|
|
391
|
-
|
|
518
|
+
]
|
|
519
|
+
}, 0 === index ? 'start' : 'end');
|
|
520
|
+
})
|
|
392
521
|
}),
|
|
393
522
|
presets && presets.length > 0 && /*#__PURE__*/ jsx(Presets, {
|
|
394
523
|
items: presets,
|
|
524
|
+
disabled: resolvedDisabled,
|
|
395
525
|
onSelect: handlePresetSelect
|
|
526
|
+
}),
|
|
527
|
+
withTime && /*#__PURE__*/ jsx("div", {
|
|
528
|
+
"data-tao-picker-footer": "",
|
|
529
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
530
|
+
size: "small",
|
|
531
|
+
disabled: !canConfirm,
|
|
532
|
+
onClick: confirmTimeRange,
|
|
533
|
+
children: ctx.locale.ok
|
|
534
|
+
})
|
|
396
535
|
})
|
|
397
536
|
]
|
|
398
537
|
});
|
|
@@ -402,18 +541,19 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
402
541
|
children: [
|
|
403
542
|
showClearBtn && /*#__PURE__*/ jsx("span", {
|
|
404
543
|
"data-tao-picker-clear": "",
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
544
|
+
onMouseDown: (event)=>event.preventDefault(),
|
|
545
|
+
onClick: (event_0)=>{
|
|
546
|
+
event_0.stopPropagation();
|
|
547
|
+
handleClear(event_0);
|
|
408
548
|
},
|
|
409
549
|
"aria-label": ctx.locale.clear,
|
|
410
550
|
role: "button",
|
|
411
551
|
tabIndex: 0,
|
|
412
|
-
onKeyDown: (
|
|
413
|
-
if ('Enter' ===
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
handleClear(
|
|
552
|
+
onKeyDown: (event_1)=>{
|
|
553
|
+
if ('Enter' === event_1.key || ' ' === event_1.key) {
|
|
554
|
+
event_1.preventDefault();
|
|
555
|
+
event_1.stopPropagation();
|
|
556
|
+
handleClear(event_1);
|
|
417
557
|
}
|
|
418
558
|
},
|
|
419
559
|
children: /*#__PURE__*/ jsx(CloseIcon, {})
|
|
@@ -438,14 +578,19 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
438
578
|
const popup = popupRef.current;
|
|
439
579
|
if (!popup) return;
|
|
440
580
|
const selectedDate = activeDate && !isDateBlocked(activeDate) ? activeDate : null;
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
581
|
+
const periodKey = (date_5)=>'year' === picker ? Math.floor(date_5.year() / 10) : date_5.startOf(panelUnit).valueOf();
|
|
582
|
+
if (selectedDate && periodKey(selectedDate) !== periodKey(viewDateStart) && periodKey(selectedDate) !== periodKey(viewDateStart.add(panelStep, panelUnit))) return void setViewDateStart(selectedDate);
|
|
583
|
+
const cellFormat = 'month' === picker ? 'YYYY-MM' : 'year' === picker ? 'YYYY' : 'YYYY-MM-DD';
|
|
584
|
+
let target = selectedDate ? popup.querySelector(`[data-tao-calendar-date="${selectedDate.format(cellFormat)}"]:not([data-tao-other-month]):not(:disabled)`) : null;
|
|
585
|
+
target ??= popup.querySelector('[data-tao-calendar-date][tabindex="0"]:not(:disabled)') ?? popup.querySelector('[data-tao-calendar-date][aria-pressed="true"]:not(:disabled)') ?? popup.querySelector('[data-tao-calendar-date]:not(:disabled)') ?? popup.querySelector('button:not(:disabled)');
|
|
444
586
|
target?.focus();
|
|
445
587
|
setKeyboardFocusRequested(false);
|
|
446
588
|
}, [
|
|
447
589
|
activeDate,
|
|
448
590
|
isDateBlocked,
|
|
591
|
+
panelStep,
|
|
592
|
+
panelUnit,
|
|
593
|
+
picker,
|
|
449
594
|
viewDateStart
|
|
450
595
|
]);
|
|
451
596
|
useEffect(()=>{
|
|
@@ -513,7 +658,10 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
513
658
|
dir: direction,
|
|
514
659
|
"data-tao-control": "",
|
|
515
660
|
"data-tao-range-trigger": "",
|
|
516
|
-
onClick: ()
|
|
661
|
+
onClick: (event_2)=>{
|
|
662
|
+
const clickedInput = event_2.target === startInputRef.current || event_2.target === endInputRef.current;
|
|
663
|
+
if (!resolvedDisabled) setOpen(clickedInput || !isOpen);
|
|
664
|
+
},
|
|
517
665
|
"data-tao-size": resolvedSize,
|
|
518
666
|
"data-tao-variant": resolvedVariant,
|
|
519
667
|
"data-tao-error": 'error' === status || void 0,
|
|
@@ -559,20 +707,22 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
559
707
|
activeInput: 'start'
|
|
560
708
|
});
|
|
561
709
|
},
|
|
562
|
-
onChange: (
|
|
563
|
-
onBlur: (
|
|
564
|
-
const enteringCalendar =
|
|
710
|
+
onChange: (event_3)=>setInputStart(event_3.target.value),
|
|
711
|
+
onBlur: (event_4)=>{
|
|
712
|
+
const enteringCalendar = event_4.relatedTarget instanceof HTMLElement && !!popupRef.current?.contains(event_4.relatedTarget);
|
|
565
713
|
if (enteringCalendar && keyboardFocusRequested) return;
|
|
566
|
-
|
|
714
|
+
setKeyboardFocusRequested(false);
|
|
715
|
+
commitInputValue('start', enteringCalendar || event_4.relatedTarget === endInputRef.current);
|
|
567
716
|
},
|
|
568
|
-
onKeyDown: (
|
|
569
|
-
if (
|
|
570
|
-
|
|
717
|
+
onKeyDown: (event_5)=>{
|
|
718
|
+
if (event_5.nativeEvent.isComposing || 229 === event_5.keyCode) return;
|
|
719
|
+
if ('ArrowDown' === event_5.key) {
|
|
720
|
+
event_5.preventDefault();
|
|
571
721
|
openFromKeyboard();
|
|
572
|
-
} else if ('Enter' ===
|
|
573
|
-
|
|
722
|
+
} else if ('Enter' === event_5.key) {
|
|
723
|
+
event_5.preventDefault();
|
|
574
724
|
commitInputValue('start');
|
|
575
|
-
} else if ('Escape' ===
|
|
725
|
+
} else if ('Escape' === event_5.key) {
|
|
576
726
|
setInputStart(displayStart);
|
|
577
727
|
setOpen(false);
|
|
578
728
|
}
|
|
@@ -609,20 +759,22 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
609
759
|
activeInput: 'end'
|
|
610
760
|
});
|
|
611
761
|
},
|
|
612
|
-
onChange: (
|
|
613
|
-
onBlur: (
|
|
614
|
-
const enteringCalendar_0 =
|
|
762
|
+
onChange: (event_6)=>setInputEnd(event_6.target.value),
|
|
763
|
+
onBlur: (event_7)=>{
|
|
764
|
+
const enteringCalendar_0 = event_7.relatedTarget instanceof HTMLElement && !!popupRef.current?.contains(event_7.relatedTarget);
|
|
615
765
|
if (enteringCalendar_0 && keyboardFocusRequested) return;
|
|
616
|
-
|
|
766
|
+
setKeyboardFocusRequested(false);
|
|
767
|
+
commitInputValue('end', enteringCalendar_0 || event_7.relatedTarget === startInputRef.current);
|
|
617
768
|
},
|
|
618
|
-
onKeyDown: (
|
|
619
|
-
if (
|
|
620
|
-
|
|
769
|
+
onKeyDown: (event_8)=>{
|
|
770
|
+
if (event_8.nativeEvent.isComposing || 229 === event_8.keyCode) return;
|
|
771
|
+
if ('ArrowDown' === event_8.key) {
|
|
772
|
+
event_8.preventDefault();
|
|
621
773
|
openFromKeyboard();
|
|
622
|
-
} else if ('Enter' ===
|
|
623
|
-
|
|
774
|
+
} else if ('Enter' === event_8.key) {
|
|
775
|
+
event_8.preventDefault();
|
|
624
776
|
commitInputValue('end');
|
|
625
|
-
} else if ('Escape' ===
|
|
777
|
+
} else if ('Escape' === event_8.key) {
|
|
626
778
|
setInputEnd(displayEnd);
|
|
627
779
|
setOpen(false);
|
|
628
780
|
}
|
|
@@ -666,12 +818,15 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
666
818
|
align: "start",
|
|
667
819
|
className: classNames?.popup,
|
|
668
820
|
style: styles?.popup,
|
|
669
|
-
|
|
670
|
-
|
|
821
|
+
onInteractOutside: (event_9)=>{
|
|
822
|
+
if (startInputRef.current?.parentElement?.contains(event_9.target)) event_9.preventDefault();
|
|
823
|
+
},
|
|
824
|
+
onOpenAutoFocus: (event_10)=>{
|
|
825
|
+
event_10.preventDefault();
|
|
671
826
|
if (keyboardFocusRequested) focusCalendar();
|
|
672
827
|
},
|
|
673
|
-
onCloseAutoFocus: (
|
|
674
|
-
|
|
828
|
+
onCloseAutoFocus: (event_11)=>{
|
|
829
|
+
event_11.preventDefault();
|
|
675
830
|
if (document.activeElement === document.body || popupRef.current?.contains(document.activeElement)) (returnFocusRef.current ?? startInputRef.current)?.focus();
|
|
676
831
|
},
|
|
677
832
|
children: panelContent
|