@rockshin/tao-ui 0.0.58 → 0.0.60
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 +38 -4
- package/dist/components/app/app-modals.js +11 -6
- package/dist/components/app/app-notices.js +105 -47
- package/dist/components/auto-complete/auto-complete.js +9 -2
- package/dist/components/calendar/calendar.js +22 -18
- package/dist/components/carousel/carousel.js +27 -14
- package/dist/components/cascader/cascader.js +18 -12
- package/dist/components/checkbox/checkbox.d.ts +3 -1
- package/dist/components/checkbox/checkbox.js +65 -58
- package/dist/components/color-picker/color-picker.css +1 -1
- package/dist/components/color-picker/color-picker.js +386 -362
- package/dist/components/context-menu/context-menu.d.ts +3 -1
- package/dist/components/context-menu/context-menu.js +48 -43
- package/dist/components/date-picker/calendar/calendar-grid.d.ts +5 -3
- package/dist/components/date-picker/calendar/calendar-grid.js +9 -4
- package/dist/components/date-picker/calendar/month-grid.d.ts +2 -1
- package/dist/components/date-picker/calendar/month-grid.js +61 -45
- package/dist/components/date-picker/calendar/time-panel.d.ts +8 -1
- package/dist/components/date-picker/calendar/time-panel.js +93 -88
- package/dist/components/date-picker/calendar/year-grid.d.ts +2 -1
- package/dist/components/date-picker/calendar/year-grid.js +60 -44
- package/dist/components/date-picker/date-picker.css +9 -0
- package/dist/components/date-picker/date-picker.js +25 -14
- package/dist/components/date-picker/range-picker.d.ts +2 -0
- package/dist/components/date-picker/range-picker.js +132 -73
- package/dist/components/date-picker/types.js +1 -1
- package/dist/components/drawer/drawer.d.ts +1 -1
- package/dist/components/drawer/drawer.js +4 -3
- package/dist/components/dropdown/dropdown.d.ts +1 -0
- package/dist/components/dropdown/dropdown.js +29 -21
- package/dist/components/float-button/float-button.js +6 -5
- package/dist/components/form/form-item.d.ts +1 -1
- package/dist/components/form/form-item.js +160 -120
- package/dist/components/form/use-form.js +2 -1
- package/dist/components/form-field/form-field-view.d.ts +2 -1
- package/dist/components/form-field/form-field-view.js +173 -108
- package/dist/components/input/input-shared.js +3 -2
- package/dist/components/input/otp.js +114 -110
- package/dist/components/input/password.js +55 -61
- package/dist/components/input/search.js +8 -4
- package/dist/components/input-number/input-number.d.ts +2 -1
- package/dist/components/input-number/input-number.js +67 -52
- package/dist/components/mentions/mentions.js +4 -2
- package/dist/components/menu/menu-render.d.ts +6 -0
- package/dist/components/menu/menu-render.js +39 -26
- package/dist/components/modal/confirm-dialog.js +22 -10
- package/dist/components/modal/modal.js +320 -315
- package/dist/components/modal/use-modal.js +1 -1
- package/dist/components/pagination/pagination.d.ts +4 -2
- package/dist/components/pagination/pagination.js +128 -117
- package/dist/components/popover/popover.js +214 -351
- package/dist/components/qr-code/qr-code.js +157 -150
- package/dist/components/radio/radio.d.ts +3 -1
- package/dist/components/radio/radio.js +73 -64
- package/dist/components/select/mobile-select.js +7 -4
- package/dist/components/select/select-model.js +3 -3
- package/dist/components/select/select.js +78 -39
- package/dist/components/select/use-select-selection.js +100 -92
- package/dist/components/slider/slider.d.ts +2 -2
- package/dist/components/slider/slider.js +13 -2
- package/dist/components/sonner/sonner.js +2 -2
- package/dist/components/splitter/splitter.css +1 -0
- package/dist/components/splitter/splitter.js +152 -126
- package/dist/components/statistic/statistic.js +38 -31
- package/dist/components/switch/switch.js +45 -39
- package/dist/components/table/table-filter.d.ts +3 -1
- package/dist/components/table/table-filter.js +100 -74
- package/dist/components/table/table.js +2 -0
- package/dist/components/table/use-table-data.js +2 -2
- package/dist/components/tabs/tabs.d.ts +3 -2
- package/dist/components/tabs/tabs.js +122 -112
- package/dist/components/time-picker/time-picker.js +35 -3
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/tooltip/tooltip.js +220 -124
- package/dist/components/tree/tree.js +31 -3
- package/dist/components/tree-select/tree-select.js +2 -1
- package/dist/components/upload/upload.js +67 -40
- package/dist/locales/ar-EG.js +2 -0
- package/dist/locales/de-DE.js +2 -0
- package/dist/locales/en-US.js +2 -0
- package/dist/locales/es-ES.js +2 -0
- package/dist/locales/fr-FR.js +2 -0
- package/dist/locales/hi-IN.js +2 -0
- package/dist/locales/id-ID.js +2 -0
- package/dist/locales/it-IT.js +2 -0
- package/dist/locales/ja-JP.js +2 -0
- package/dist/locales/ko-KR.js +2 -0
- package/dist/locales/pt-BR.js +2 -0
- package/dist/locales/ru-RU.js +2 -0
- package/dist/locales/th-TH.js +2 -0
- package/dist/locales/tr-TR.js +2 -0
- package/dist/locales/types.d.ts +2 -0
- package/dist/locales/vi-VN.js +2 -0
- package/dist/locales/zh-CN.js +2 -0
- package/dist/locales/zh-TW.js +2 -0
- package/dist/number-input/format.js +1 -1
- package/dist/number-input/use-number-input.d.ts +1 -0
- package/dist/number-input/use-number-input.js +170 -321
- package/dist/number-input/validate.d.ts +1 -0
- package/dist/number-input/validate.js +1 -1
- package/dist/provider/tao-provider.d.ts +2 -2
- package/dist/provider/tao-provider.js +66 -52
- package/dist/theme/control.css +5 -1
- package/dist/theme/theme.css +2 -2
- package/dist/utils/composed-parent.d.ts +1 -0
- package/dist/utils/composed-parent.js +7 -0
- package/dist/utils/portal.d.ts +5 -0
- package/dist/utils/portal.js +7 -1
- package/dist/utils/refs.d.ts +3 -1
- package/dist/utils/refs.js +25 -1
- package/package.json +1 -1
|
@@ -7,19 +7,19 @@ import { useIsMobile } from "../../utils/breakpoint.js";
|
|
|
7
7
|
import { useMobileTitle } from "../../utils/field-label.js";
|
|
8
8
|
import { mergeRefs } from "../../utils/refs.js";
|
|
9
9
|
import { cx } from "../../utils/semantic.js";
|
|
10
|
-
import { Drawer } from "../drawer/drawer.js";
|
|
11
10
|
import { Button } from "../button/button.js";
|
|
11
|
+
import { Drawer } from "../drawer/drawer.js";
|
|
12
12
|
import { CalendarGrid } from "./calendar/calendar-grid.js";
|
|
13
13
|
import { MonthGrid } from "./calendar/month-grid.js";
|
|
14
|
-
import { YearGrid } from "./calendar/year-grid.js";
|
|
15
14
|
import { TimePanel } from "./calendar/time-panel.js";
|
|
15
|
+
import { YearGrid } from "./calendar/year-grid.js";
|
|
16
16
|
import "./date-picker.css";
|
|
17
|
-
import { Presets } from "./presets.js";
|
|
18
17
|
import { formatPickerDate, parsePickerDate } from "./date-localization.js";
|
|
18
|
+
import { Presets } from "./presets.js";
|
|
19
19
|
import { getDefaultFormat } from "./types.js";
|
|
20
20
|
import * as __rspack_external__radix_ui_react_popover_c8444160 from "@radix-ui/react-popover";
|
|
21
21
|
const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
22
|
-
const { value, defaultValue, onChange, picker = 'date', showTime, format: formatProp, disabledDate, minDate, maxDate, presets, placeholder: placeholderProp, separator = '~', size, variant, disabled, allowClear = true, status, mobile, open: controlledOpen, onOpenChange, className, style, classNames, styles } = props;
|
|
22
|
+
const { value, defaultValue, onChange, picker = 'date', showTime, format: formatProp, disabledDate, minDate, maxDate, presets, placeholder: placeholderProp, separator = '~', size, variant, disabled, allowEmpty, allowClear = true, status, mobile, open: controlledOpen, onOpenChange, className, style, classNames, styles } = props;
|
|
23
23
|
const popupId = useId();
|
|
24
24
|
const popupRef = useRef(null);
|
|
25
25
|
const [keyboardFocusRequested, setKeyboardFocusRequested] = useState(false);
|
|
@@ -35,6 +35,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
35
35
|
const startDisabled = (Array.isArray(disabled) ? disabled[0] : disabled) ?? ctx.disabled;
|
|
36
36
|
const endDisabled = (Array.isArray(disabled) ? disabled[1] : disabled) ?? ctx.disabled;
|
|
37
37
|
const resolvedDisabled = startDisabled && endDisabled;
|
|
38
|
+
const [allowEmptyStart = false, allowEmptyEnd = false] = allowEmpty ?? [];
|
|
38
39
|
const defaultActiveInput = startDisabled && !endDisabled ? 'end' : 'start';
|
|
39
40
|
const autoMobile = useIsMobile();
|
|
40
41
|
const isMobile = mobile ?? autoMobile;
|
|
@@ -88,7 +89,10 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
88
89
|
end
|
|
89
90
|
] : null;
|
|
90
91
|
if (!isValueControlled) setInternalValue(nextValue);
|
|
91
|
-
onChange?.(nextValue
|
|
92
|
+
onChange?.(nextValue && [
|
|
93
|
+
start,
|
|
94
|
+
end
|
|
95
|
+
], [
|
|
92
96
|
formatValue(start),
|
|
93
97
|
formatValue(end)
|
|
94
98
|
]);
|
|
@@ -104,7 +108,8 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
104
108
|
orderUnit
|
|
105
109
|
]);
|
|
106
110
|
const [internalOpen, setInternalOpen] = useState(false);
|
|
107
|
-
|
|
111
|
+
if (resolvedDisabled && internalOpen) setInternalOpen(false);
|
|
112
|
+
const isOpen = controlledOpen ?? (!resolvedDisabled && internalOpen);
|
|
108
113
|
const workingValue = withTime && isOpen && void 0 !== timeDraft ? timeDraft : resolvedValue;
|
|
109
114
|
const changeRange = useCallback((dates_0)=>{
|
|
110
115
|
if (withTime) setTimeDraft(dates_0);
|
|
@@ -117,6 +122,13 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
117
122
|
phase: 'idle',
|
|
118
123
|
activeInput: defaultActiveInput
|
|
119
124
|
});
|
|
125
|
+
if ('idle' !== interaction.phase && (startDisabled || endDisabled)) {
|
|
126
|
+
setInteraction({
|
|
127
|
+
phase: 'idle',
|
|
128
|
+
activeInput: defaultActiveInput
|
|
129
|
+
});
|
|
130
|
+
setTimeDraft(void 0);
|
|
131
|
+
}
|
|
120
132
|
const controlledValueKey = isValueControlled ? `${resolvedValue?.[0]?.valueOf() ?? 'null'}:${resolvedValue?.[1]?.valueOf() ?? 'null'}` : void 0;
|
|
121
133
|
const setOpen = useCallback((v)=>{
|
|
122
134
|
if (v === isOpen || v && resolvedDisabled) return;
|
|
@@ -144,7 +156,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
144
156
|
setTimeDraft(void 0);
|
|
145
157
|
setInteraction((current)=>({
|
|
146
158
|
phase: 'idle',
|
|
147
|
-
activeInput: '
|
|
159
|
+
activeInput: 'idle' === current.phase ? current.activeInput : 'start'
|
|
148
160
|
}));
|
|
149
161
|
}
|
|
150
162
|
}, [
|
|
@@ -168,8 +180,8 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
168
180
|
const panelStep = 'year' === picker ? 10 : 1;
|
|
169
181
|
const panelUnit = 'date' === picker ? 'month' : 'year';
|
|
170
182
|
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;
|
|
183
|
+
const rangeStart = startDisabled ? resolvedValue?.[0] ?? null : 'pickingStart' === interaction.phase ? null : 'pickingEnd' === interaction.phase ? interaction.start : workingValue?.[0] ?? null;
|
|
184
|
+
const rangeEnd = endDisabled ? resolvedValue?.[1] ?? null : 'pickingEnd' === interaction.phase ? null : 'pickingStart' === interaction.phase ? interaction.end : workingValue?.[1] ?? null;
|
|
173
185
|
const hoverDate = 'pickingEnd' === interaction.phase ? interaction.hover : null;
|
|
174
186
|
const setHoverDate = useCallback((hover)=>{
|
|
175
187
|
setInteraction((current_0)=>'pickingEnd' === current_0.phase ? {
|
|
@@ -177,16 +189,30 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
177
189
|
hover
|
|
178
190
|
} : current_0);
|
|
179
191
|
}, []);
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
192
|
+
const pickOtherEndpoint = useCallback((position_0, date_1)=>{
|
|
193
|
+
setInteraction('start' === position_0 ? {
|
|
194
|
+
phase: 'pickingEnd',
|
|
195
|
+
activeInput: 'end',
|
|
196
|
+
start: date_1,
|
|
197
|
+
hover: null
|
|
198
|
+
} : {
|
|
199
|
+
phase: 'pickingStart',
|
|
200
|
+
activeInput: 'start',
|
|
201
|
+
end: date_1
|
|
202
|
+
});
|
|
203
|
+
}, []);
|
|
204
|
+
const handleDateSelect = useCallback((date_2)=>{
|
|
205
|
+
const startsRange = !startDisabled && !endDisabled && 'pickingStart' !== interaction.phase && ('pickingEnd' === interaction.phase ? isDateBlocked(interaction.start) : 'start' === interaction.activeInput);
|
|
206
|
+
const selectsEnd = startDisabled || !endDisabled && ('pickingStart' === interaction.phase ? isDateBlocked(interaction.end) : !startsRange && 'end' === interaction.activeInput);
|
|
207
|
+
const position_1 = selectsEnd ? 1 : 0;
|
|
208
|
+
const previous = workingValue?.[position_1] ?? resolvedValue?.[position_1];
|
|
209
|
+
if (withTime && previous) date_2 = date_2.hour(previous.hour()).minute(previous.minute()).second(previous.second()).millisecond(previous.millisecond());
|
|
184
210
|
if (startDisabled || endDisabled) {
|
|
185
211
|
const next = startDisabled ? [
|
|
186
212
|
rangeStart,
|
|
187
|
-
|
|
213
|
+
date_2
|
|
188
214
|
] : [
|
|
189
|
-
|
|
215
|
+
date_2,
|
|
190
216
|
rangeEnd
|
|
191
217
|
];
|
|
192
218
|
if (next[0] && next[1] && next[0].isAfter(next[1], granularity)) return;
|
|
@@ -198,36 +224,29 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
198
224
|
if (!withTime) setOpen(false);
|
|
199
225
|
return;
|
|
200
226
|
}
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
];
|
|
219
|
-
changeRange([
|
|
220
|
-
start_0,
|
|
221
|
-
end_0
|
|
222
|
-
]);
|
|
223
|
-
setInteraction({
|
|
224
|
-
phase: 'idle',
|
|
225
|
-
activeInput: 'start'
|
|
226
|
-
});
|
|
227
|
-
if (!withTime) setOpen(false);
|
|
228
|
-
}
|
|
227
|
+
if (startsRange && (!allowEmptyEnd || rangeEnd)) return void pickOtherEndpoint('start', date_2);
|
|
228
|
+
if (1 === position_1 && !rangeStart && !allowEmptyStart) return void pickOtherEndpoint('end', date_2);
|
|
229
|
+
let start_0 = 0 === position_1 ? date_2 : rangeStart;
|
|
230
|
+
let end_0 = startsRange ? null : 1 === position_1 ? date_2 : rangeEnd;
|
|
231
|
+
if (start_0 && end_0?.isBefore(start_0, orderUnit)) [start_0, end_0] = [
|
|
232
|
+
end_0,
|
|
233
|
+
start_0
|
|
234
|
+
];
|
|
235
|
+
changeRange([
|
|
236
|
+
start_0,
|
|
237
|
+
end_0
|
|
238
|
+
]);
|
|
239
|
+
setInteraction({
|
|
240
|
+
phase: 'idle',
|
|
241
|
+
activeInput: 'start'
|
|
242
|
+
});
|
|
243
|
+
if (!withTime) setOpen(false);
|
|
229
244
|
}, [
|
|
230
245
|
interaction,
|
|
246
|
+
isDateBlocked,
|
|
247
|
+
allowEmptyStart,
|
|
248
|
+
allowEmptyEnd,
|
|
249
|
+
pickOtherEndpoint,
|
|
231
250
|
rangeStart,
|
|
232
251
|
rangeEnd,
|
|
233
252
|
changeRange,
|
|
@@ -313,19 +332,31 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
313
332
|
}, [
|
|
314
333
|
typedValue
|
|
315
334
|
]);
|
|
316
|
-
const commitInputValue = useCallback((
|
|
317
|
-
if ('start' ===
|
|
318
|
-
const text = ('start' ===
|
|
319
|
-
const currentValue = 'start' ===
|
|
335
|
+
const commitInputValue = useCallback((position_2, { keepPopupOpen = false, openIncomplete = false } = {})=>{
|
|
336
|
+
if ('start' === position_2 ? startDisabled : endDisabled) return;
|
|
337
|
+
const text = ('start' === position_2 ? inputStart : inputEnd).trim();
|
|
338
|
+
const currentValue = 'start' === position_2 ? displayStart : displayEnd;
|
|
339
|
+
if (text === currentValue) return;
|
|
320
340
|
const parsed_0 = text ? parsePickerDate(text, fmt, dayjsLocale, numberLocale) : null;
|
|
321
|
-
const isBlocked = null != parsed_0 && (isDateBlocked(parsed_0) || 'start' ===
|
|
341
|
+
const isBlocked = null != parsed_0 && (isDateBlocked(parsed_0) || 'start' === position_2 && null != rangeEnd && parsed_0.isAfter(rangeEnd, orderUnit) || 'end' === position_2 && null != rangeStart && parsed_0.isBefore(rangeStart, orderUnit));
|
|
322
342
|
if (isBlocked) {
|
|
323
|
-
if ('start' ===
|
|
343
|
+
if ('start' === position_2) setInputStart(currentValue);
|
|
344
|
+
else setInputEnd(currentValue);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const nextStart = 'start' === position_2 ? parsed_0 : rangeStart;
|
|
348
|
+
const nextEnd = 'end' === position_2 ? parsed_0 : rangeEnd;
|
|
349
|
+
const needsStart = nextEnd && !nextStart && !startDisabled && !allowEmptyStart;
|
|
350
|
+
const needsEnd = nextStart && !nextEnd && !endDisabled && !allowEmptyEnd;
|
|
351
|
+
if (needsStart || needsEnd) {
|
|
352
|
+
if (parsed_0) {
|
|
353
|
+
pickOtherEndpoint(position_2, parsed_0);
|
|
354
|
+
setViewDateStart(parsed_0);
|
|
355
|
+
if (!isOpen && openIncomplete) setOpen(true);
|
|
356
|
+
} else if ('start' === position_2) setInputStart(currentValue);
|
|
324
357
|
else setInputEnd(currentValue);
|
|
325
358
|
return;
|
|
326
359
|
}
|
|
327
|
-
const nextStart = 'start' === position_1 ? parsed_0 : rangeStart;
|
|
328
|
-
const nextEnd = 'end' === position_1 ? parsed_0 : rangeEnd;
|
|
329
360
|
const nextStrings = [
|
|
330
361
|
formatValue(nextStart),
|
|
331
362
|
formatValue(nextEnd)
|
|
@@ -339,16 +370,19 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
339
370
|
}
|
|
340
371
|
setInteraction({
|
|
341
372
|
phase: 'idle',
|
|
342
|
-
activeInput:
|
|
373
|
+
activeInput: position_2
|
|
343
374
|
});
|
|
344
375
|
if (parsed_0 && !keepPopupOpen) setViewDateStart(parsed_0);
|
|
345
|
-
if ('start' ===
|
|
376
|
+
if ('start' === position_2) setInputStart(isValueControlled && !withTime ? displayStart : nextStrings[0]);
|
|
346
377
|
else setInputEnd(isValueControlled && !withTime ? displayEnd : nextStrings[1]);
|
|
347
378
|
if (nextStart && nextEnd && !keepPopupOpen && !withTime) setOpen(false);
|
|
348
379
|
}, [
|
|
349
380
|
isDateBlocked,
|
|
350
381
|
startDisabled,
|
|
351
382
|
endDisabled,
|
|
383
|
+
allowEmptyStart,
|
|
384
|
+
allowEmptyEnd,
|
|
385
|
+
pickOtherEndpoint,
|
|
352
386
|
displayEnd,
|
|
353
387
|
displayStart,
|
|
354
388
|
changeRange,
|
|
@@ -367,9 +401,9 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
367
401
|
orderUnit
|
|
368
402
|
]);
|
|
369
403
|
const showClearBtn = allowClear && (!startDisabled && rangeStart || !endDisabled && rangeEnd);
|
|
370
|
-
const isDateDisabled = (
|
|
371
|
-
const periodTitle = (
|
|
372
|
-
const canConfirm = !resolvedDisabled && (!hasTypedEdit || null !== typedValue) && (startDisabled ||
|
|
404
|
+
const isDateDisabled = (date_3)=>Boolean(resolvedDisabled || disabledDate?.(date_3) || startDisabled && rangeStart && date_3.isBefore(rangeStart, granularity) || endDisabled && rangeEnd && date_3.isAfter(rangeEnd, granularity));
|
|
405
|
+
const periodTitle = (date_4)=>'date' === picker ? ctx.locale.monthTitle(date_4.month(), date_4.year()) : 'month' === picker ? date_4.format('YYYY') : `${10 * Math.floor(date_4.year() / 10)} – ${10 * Math.floor(date_4.year() / 10) + 9}`;
|
|
406
|
+
const canConfirm = !resolvedDisabled && !!(panelStart || panelEnd) && (!hasTypedEdit || null !== typedValue) && (startDisabled || (panelStart ? !isDateBlocked(panelStart) : allowEmptyStart)) && (endDisabled || (panelEnd ? !isDateBlocked(panelEnd) : allowEmptyEnd)) && !(panelStart && panelEnd && panelStart.isAfter(panelEnd, orderUnit));
|
|
373
407
|
const confirmTimeRange = ()=>{
|
|
374
408
|
if (!canConfirm || !emitChange([
|
|
375
409
|
panelStart,
|
|
@@ -386,11 +420,17 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
386
420
|
});
|
|
387
421
|
setOpen(false);
|
|
388
422
|
};
|
|
423
|
+
const announcement = /*#__PURE__*/ jsx("span", {
|
|
424
|
+
role: "status",
|
|
425
|
+
"data-tao-range-announcement": "",
|
|
426
|
+
children: isOpen && 'pickingEnd' === interaction.phase ? `${ctx.locale.startDate}: ${formatValue(interaction.start)}. ${ctx.locale.selectEndDate ?? 'Select an end date.'}` : isOpen && 'pickingStart' === interaction.phase ? `${ctx.locale.endDate}: ${formatValue(interaction.end)}. ${ctx.locale.selectStartDate ?? 'Select a start date.'}` : ''
|
|
427
|
+
});
|
|
389
428
|
const panelContent = /*#__PURE__*/ jsxs("div", {
|
|
390
429
|
"data-tao-range-panel": "",
|
|
391
430
|
className: isMobile ? classNames?.popup : void 0,
|
|
392
431
|
style: isMobile ? styles?.popup : void 0,
|
|
393
432
|
children: [
|
|
433
|
+
isMobile && announcement,
|
|
394
434
|
/*#__PURE__*/ jsxs("div", {
|
|
395
435
|
"data-tao-range-header": "",
|
|
396
436
|
children: [
|
|
@@ -452,11 +492,12 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
452
492
|
children: [
|
|
453
493
|
viewDateStart,
|
|
454
494
|
viewDateEnd
|
|
455
|
-
].map((
|
|
495
|
+
].map((date_5, index)=>{
|
|
456
496
|
const shared = {
|
|
457
|
-
viewDate:
|
|
497
|
+
viewDate: date_5,
|
|
458
498
|
rangeStart: panelStart,
|
|
459
499
|
rangeEnd: panelEnd,
|
|
500
|
+
committedRange: resolvedValue,
|
|
460
501
|
onSelect: handleDateSelect,
|
|
461
502
|
disabledDate: isDateDisabled,
|
|
462
503
|
minDate,
|
|
@@ -495,6 +536,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
495
536
|
hour: endpoint?.hour() ?? 0,
|
|
496
537
|
minute: endpoint?.minute() ?? 0,
|
|
497
538
|
second: endpoint?.second() ?? 0,
|
|
539
|
+
format: fmt,
|
|
498
540
|
onChange: (hour, minute, second)=>{
|
|
499
541
|
if (!endpoint || disabledEndpoint) return;
|
|
500
542
|
const next_2 = endpoint.hour(hour).minute(minute).second(second);
|
|
@@ -511,6 +553,10 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
511
553
|
...interaction,
|
|
512
554
|
start: next_2
|
|
513
555
|
});
|
|
556
|
+
if (1 === index && 'pickingStart' === interaction.phase) setInteraction({
|
|
557
|
+
...interaction,
|
|
558
|
+
end: next_2
|
|
559
|
+
});
|
|
514
560
|
}
|
|
515
561
|
})
|
|
516
562
|
]
|
|
@@ -578,11 +624,11 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
578
624
|
const popup = popupRef.current;
|
|
579
625
|
if (!popup) return;
|
|
580
626
|
const selectedDate = activeDate && !isDateBlocked(activeDate) ? activeDate : null;
|
|
581
|
-
const periodKey = (
|
|
627
|
+
const periodKey = (date_6)=>'year' === picker ? Math.floor(date_6.year() / 10) : date_6.startOf(panelUnit).valueOf();
|
|
582
628
|
if (selectedDate && periodKey(selectedDate) !== periodKey(viewDateStart) && periodKey(selectedDate) !== periodKey(viewDateStart.add(panelStep, panelUnit))) return void setViewDateStart(selectedDate);
|
|
583
629
|
const cellFormat = 'month' === picker ? 'YYYY-MM' : 'year' === picker ? 'YYYY' : 'YYYY-MM-DD';
|
|
584
630
|
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][
|
|
631
|
+
target ??= popup.querySelector('[data-tao-calendar-date][tabindex="0"]:not(:disabled)') ?? popup.querySelector('[data-tao-calendar-date][data-tao-selected]:not(:disabled)') ?? popup.querySelector('[data-tao-calendar-date]:not(:disabled)') ?? popup.querySelector('button:not(:disabled)');
|
|
586
632
|
target?.focus();
|
|
587
633
|
setKeyboardFocusRequested(false);
|
|
588
634
|
}, [
|
|
@@ -601,7 +647,9 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
601
647
|
focusCalendar
|
|
602
648
|
]);
|
|
603
649
|
const openFromKeyboard = ()=>{
|
|
604
|
-
commitInputValue(interaction.activeInput,
|
|
650
|
+
commitInputValue(interaction.activeInput, {
|
|
651
|
+
keepPopupOpen: true
|
|
652
|
+
});
|
|
605
653
|
setKeyboardFocusRequested(true);
|
|
606
654
|
if (!isOpen) setOpen(true);
|
|
607
655
|
};
|
|
@@ -616,6 +664,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
616
664
|
"data-tao-size": resolvedSize,
|
|
617
665
|
"data-tao-variant": resolvedVariant,
|
|
618
666
|
"data-tao-error": 'error' === status || void 0,
|
|
667
|
+
"data-tao-warning": 'warning' === status || void 0,
|
|
619
668
|
disabled: resolvedDisabled,
|
|
620
669
|
onClick: ()=>setOpen(true),
|
|
621
670
|
className: cx(classNames?.root, className),
|
|
@@ -665,6 +714,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
665
714
|
"data-tao-size": resolvedSize,
|
|
666
715
|
"data-tao-variant": resolvedVariant,
|
|
667
716
|
"data-tao-error": 'error' === status || void 0,
|
|
717
|
+
"data-tao-warning": 'warning' === status || void 0,
|
|
668
718
|
"data-disabled": resolvedDisabled || void 0,
|
|
669
719
|
className: cx(classNames?.root, className),
|
|
670
720
|
style: {
|
|
@@ -702,17 +752,19 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
702
752
|
disabled: startDisabled,
|
|
703
753
|
onFocus: ()=>{
|
|
704
754
|
returnFocusRef.current = startInputRef.current;
|
|
705
|
-
setInteraction({
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
755
|
+
setInteraction((current_1)=>'pickingStart' === current_1.phase ? current_1 : {
|
|
756
|
+
phase: 'idle',
|
|
757
|
+
activeInput: 'start'
|
|
758
|
+
});
|
|
709
759
|
},
|
|
710
760
|
onChange: (event_3)=>setInputStart(event_3.target.value),
|
|
711
761
|
onBlur: (event_4)=>{
|
|
712
762
|
const enteringCalendar = event_4.relatedTarget instanceof HTMLElement && !!popupRef.current?.contains(event_4.relatedTarget);
|
|
713
763
|
if (enteringCalendar && keyboardFocusRequested) return;
|
|
714
764
|
setKeyboardFocusRequested(false);
|
|
715
|
-
commitInputValue('start',
|
|
765
|
+
commitInputValue('start', {
|
|
766
|
+
keepPopupOpen: enteringCalendar || event_4.relatedTarget === endInputRef.current
|
|
767
|
+
});
|
|
716
768
|
},
|
|
717
769
|
onKeyDown: (event_5)=>{
|
|
718
770
|
if (event_5.nativeEvent.isComposing || 229 === event_5.keyCode) return;
|
|
@@ -721,7 +773,9 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
721
773
|
openFromKeyboard();
|
|
722
774
|
} else if ('Enter' === event_5.key) {
|
|
723
775
|
event_5.preventDefault();
|
|
724
|
-
commitInputValue('start'
|
|
776
|
+
commitInputValue('start', {
|
|
777
|
+
openIncomplete: true
|
|
778
|
+
});
|
|
725
779
|
} else if ('Escape' === event_5.key) {
|
|
726
780
|
setInputStart(displayStart);
|
|
727
781
|
setOpen(false);
|
|
@@ -754,17 +808,19 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
754
808
|
disabled: endDisabled,
|
|
755
809
|
onFocus: ()=>{
|
|
756
810
|
returnFocusRef.current = endInputRef.current;
|
|
757
|
-
setInteraction({
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
811
|
+
setInteraction((current_2)=>'pickingEnd' === current_2.phase ? current_2 : {
|
|
812
|
+
phase: 'idle',
|
|
813
|
+
activeInput: 'end'
|
|
814
|
+
});
|
|
761
815
|
},
|
|
762
816
|
onChange: (event_6)=>setInputEnd(event_6.target.value),
|
|
763
817
|
onBlur: (event_7)=>{
|
|
764
818
|
const enteringCalendar_0 = event_7.relatedTarget instanceof HTMLElement && !!popupRef.current?.contains(event_7.relatedTarget);
|
|
765
819
|
if (enteringCalendar_0 && keyboardFocusRequested) return;
|
|
766
820
|
setKeyboardFocusRequested(false);
|
|
767
|
-
commitInputValue('end',
|
|
821
|
+
commitInputValue('end', {
|
|
822
|
+
keepPopupOpen: enteringCalendar_0 || event_7.relatedTarget === startInputRef.current
|
|
823
|
+
});
|
|
768
824
|
},
|
|
769
825
|
onKeyDown: (event_8)=>{
|
|
770
826
|
if (event_8.nativeEvent.isComposing || 229 === event_8.keyCode) return;
|
|
@@ -773,7 +829,9 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
773
829
|
openFromKeyboard();
|
|
774
830
|
} else if ('Enter' === event_8.key) {
|
|
775
831
|
event_8.preventDefault();
|
|
776
|
-
commitInputValue('end'
|
|
832
|
+
commitInputValue('end', {
|
|
833
|
+
openIncomplete: true
|
|
834
|
+
});
|
|
777
835
|
} else if ('Escape' === event_8.key) {
|
|
778
836
|
setInputEnd(displayEnd);
|
|
779
837
|
setOpen(false);
|
|
@@ -805,6 +863,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
805
863
|
asChild: true,
|
|
806
864
|
children: desktopTrigger
|
|
807
865
|
}),
|
|
866
|
+
announcement,
|
|
808
867
|
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_c8444160.Portal, {
|
|
809
868
|
children: /*#__PURE__*/ jsx(TaoPortalScope, {
|
|
810
869
|
asChild: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function getDefaultFormat(picker, showTime) {
|
|
2
2
|
if ('year' === picker) return 'YYYY';
|
|
3
3
|
if ('month' === picker) return 'YYYY-MM';
|
|
4
|
-
if (showTime) return
|
|
4
|
+
if (showTime) return `YYYY-MM-DD ${'object' == typeof showTime && showTime.format || 'HH:mm:ss'}`;
|
|
5
5
|
return 'YYYY-MM-DD';
|
|
6
6
|
}
|
|
7
7
|
export { getDefaultFormat };
|
|
@@ -25,7 +25,7 @@ export interface DrawerProps extends Pick<AriaAttributes, 'aria-label' | 'aria-l
|
|
|
25
25
|
height?: number | string;
|
|
26
26
|
/** Show the close (×) button. Defaults to true. */
|
|
27
27
|
closable?: boolean;
|
|
28
|
-
/** Custom close icon. */
|
|
28
|
+
/** Custom close icon. `null` or `false` hides the close button. */
|
|
29
29
|
closeIcon?: ReactNode;
|
|
30
30
|
/** Close when clicking the mask. Defaults to true. */
|
|
31
31
|
maskClosable?: boolean;
|
|
@@ -3,7 +3,7 @@ import { c } from "react-compiler-runtime";
|
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { TaoPortalScope, TaoProvider, useTaoConfig } from "../../provider/tao-provider.js";
|
|
5
5
|
import { DialogContent } from "../../utils/dialog-content.js";
|
|
6
|
-
import { preventParentOutsideDismiss } from "../../utils/portal.js";
|
|
6
|
+
import { isEscapeForOpenCombobox, preventParentOutsideDismiss } from "../../utils/portal.js";
|
|
7
7
|
import { cx } from "../../utils/semantic.js";
|
|
8
8
|
import "./drawer.css";
|
|
9
9
|
import { useWatermarkPanelRef } from "../watermark/watermark-context.js";
|
|
@@ -108,12 +108,13 @@ function Drawer({ direction, open, onClose, title, extra, footer, placement = 'r
|
|
|
108
108
|
}
|
|
109
109
|
const keepAlive = !destroyOnHidden;
|
|
110
110
|
const forceMount = keepAlive ? true : void 0;
|
|
111
|
-
const showClose = closable && false !== closeIcon;
|
|
111
|
+
const showClose = closable && false !== closeIcon && null !== closeIcon;
|
|
112
112
|
const showHeader = null != title || null != extra || showClose;
|
|
113
113
|
return /*#__PURE__*/ jsx(TaoProvider, {
|
|
114
114
|
direction: direction,
|
|
115
115
|
children: /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dialog_dabd8325.Root, {
|
|
116
116
|
open: open,
|
|
117
|
+
modal: mask,
|
|
117
118
|
onOpenChange: (v)=>{
|
|
118
119
|
if (!v) onClose?.();
|
|
119
120
|
},
|
|
@@ -154,7 +155,7 @@ function Drawer({ direction, open, onClose, title, extra, footer, placement = 'r
|
|
|
154
155
|
if (target?.isConnected && (!prevOpen.current || !contentRef.current)) target.focus();
|
|
155
156
|
},
|
|
156
157
|
onEscapeKeyDown: (e_2)=>{
|
|
157
|
-
if (!keyboard) e_2.preventDefault();
|
|
158
|
+
if (!keyboard || isEscapeForOpenCombobox(e_2)) e_2.preventDefault();
|
|
158
159
|
},
|
|
159
160
|
onPointerDownOutside: preventParentOutsideDismiss,
|
|
160
161
|
onInteractOutside: preventParentOutsideDismiss,
|
|
@@ -3,6 +3,7 @@ import { c } from "react-compiler-runtime";
|
|
|
3
3
|
import { useCallback, useEffect, useRef } from "react";
|
|
4
4
|
import { TaoPortalScope, useTaoConfig, useTaoDirection } from "../../provider/tao-provider.js";
|
|
5
5
|
import { asTriggerChild, useControlledOpen } from "../../utils/overlay.js";
|
|
6
|
+
import { useCommittedRef } from "../../utils/refs.js";
|
|
6
7
|
import { cx } from "../../utils/semantic.js";
|
|
7
8
|
import { Button } from "../button/button.js";
|
|
8
9
|
import { ContextMenu } from "../context-menu/context-menu.js";
|
|
@@ -68,8 +69,9 @@ function Dropdown(props) {
|
|
|
68
69
|
const [direction, directionRef] = useTaoDirection(props.direction, 'self');
|
|
69
70
|
const { menu, children, trigger = [
|
|
70
71
|
'click'
|
|
71
|
-
], placement, open, defaultOpen, onOpenChange, disabled, arrow = false, className, style, classNames, styles } = props;
|
|
72
|
-
const { size, disabled: ctxDisabled } = useTaoConfig();
|
|
72
|
+
], placement, open, defaultOpen, onOpenChange, size: sizeProp, disabled, arrow = false, className, style, classNames, styles } = props;
|
|
73
|
+
const { size: ctxSize, disabled: ctxDisabled } = useTaoConfig();
|
|
74
|
+
const size = sizeProp ?? ctxSize;
|
|
73
75
|
const resolvedDisabled = disabled ?? ctxDisabled;
|
|
74
76
|
const isContext = trigger.includes('contextMenu');
|
|
75
77
|
const hoverMode = !isContext && trigger.includes('hover');
|
|
@@ -97,8 +99,7 @@ function Dropdown(props) {
|
|
|
97
99
|
}, [
|
|
98
100
|
updateOpen
|
|
99
101
|
]);
|
|
100
|
-
const latestSetOpen =
|
|
101
|
-
latestSetOpen.current = setOpen;
|
|
102
|
+
const latestSetOpen = useCommittedRef(setOpen);
|
|
102
103
|
useEffect(()=>{
|
|
103
104
|
if (resolvedDisabled && realOpen && null == open) setOpen(false);
|
|
104
105
|
}, [
|
|
@@ -107,21 +108,25 @@ function Dropdown(props) {
|
|
|
107
108
|
resolvedDisabled,
|
|
108
109
|
setOpen
|
|
109
110
|
]);
|
|
110
|
-
const openOnHover = useCallback(()=>{
|
|
111
|
+
const openOnHover = useCallback((event)=>{
|
|
112
|
+
if ('touch' === event.pointerType) return;
|
|
111
113
|
clearTimeout(closeTimer.current);
|
|
112
114
|
if (!realOpen) setOpen(true);
|
|
113
115
|
}, [
|
|
114
116
|
realOpen,
|
|
115
117
|
setOpen
|
|
116
118
|
]);
|
|
117
|
-
const closeOnHover = useCallback(()=>{
|
|
118
|
-
if (!realOpen) return;
|
|
119
|
+
const closeOnHover = useCallback((event_0)=>{
|
|
120
|
+
if (!realOpen || 'touch' === event_0.pointerType) return;
|
|
119
121
|
clearTimeout(closeTimer.current);
|
|
120
122
|
closeTimer.current = setTimeout(()=>latestSetOpen.current(false), 120);
|
|
121
123
|
}, [
|
|
124
|
+
latestSetOpen,
|
|
122
125
|
realOpen
|
|
123
126
|
]);
|
|
124
127
|
const { content, selectedKeys, commitSelection } = useMenuController(menu, DD, {
|
|
128
|
+
size,
|
|
129
|
+
direction,
|
|
125
130
|
classNames,
|
|
126
131
|
styles
|
|
127
132
|
});
|
|
@@ -135,6 +140,7 @@ function Dropdown(props) {
|
|
|
135
140
|
},
|
|
136
141
|
open: realOpen && !resolvedDisabled,
|
|
137
142
|
onOpenChange: setOpen,
|
|
143
|
+
size: sizeProp,
|
|
138
144
|
disabled: disabled,
|
|
139
145
|
className: className,
|
|
140
146
|
style: style,
|
|
@@ -160,8 +166,8 @@ function Dropdown(props) {
|
|
|
160
166
|
disabled: resolvedDisabled,
|
|
161
167
|
"data-tao-dropdown-trigger": "",
|
|
162
168
|
...hoverProps,
|
|
163
|
-
onPointerDown: (
|
|
164
|
-
if (!clickMode)
|
|
169
|
+
onPointerDown: (event_1)=>{
|
|
170
|
+
if (!clickMode && 'touch' !== event_1.pointerType) event_1.preventDefault();
|
|
165
171
|
},
|
|
166
172
|
children: triggerChild
|
|
167
173
|
}),
|
|
@@ -181,8 +187,8 @@ function Dropdown(props) {
|
|
|
181
187
|
side: side,
|
|
182
188
|
align: align,
|
|
183
189
|
sideOffset: 4,
|
|
184
|
-
onCloseAutoFocus: (
|
|
185
|
-
if (latestVisible.current)
|
|
190
|
+
onCloseAutoFocus: (event_2)=>{
|
|
191
|
+
if (latestVisible.current) event_2.preventDefault();
|
|
186
192
|
},
|
|
187
193
|
...hoverProps,
|
|
188
194
|
children: [
|
|
@@ -201,7 +207,7 @@ function Dropdown(props) {
|
|
|
201
207
|
});
|
|
202
208
|
}
|
|
203
209
|
function DropdownButton(t0) {
|
|
204
|
-
const $ = c(
|
|
210
|
+
const $ = c(32);
|
|
205
211
|
let children;
|
|
206
212
|
let disabled;
|
|
207
213
|
let dropdownRest;
|
|
@@ -275,9 +281,10 @@ function DropdownButton(t0) {
|
|
|
275
281
|
$[22] = t4;
|
|
276
282
|
} else t4 = $[22];
|
|
277
283
|
let t5;
|
|
278
|
-
if ($[23] !== disabled || $[24] !== dropdownRest || $[25] !== menu || $[26] !== t4) {
|
|
284
|
+
if ($[23] !== disabled || $[24] !== dropdownRest || $[25] !== menu || $[26] !== resolvedSize || $[27] !== t4) {
|
|
279
285
|
t5 = /*#__PURE__*/ jsx(Dropdown, {
|
|
280
286
|
menu: menu,
|
|
287
|
+
size: resolvedSize,
|
|
281
288
|
disabled: disabled,
|
|
282
289
|
...dropdownRest,
|
|
283
290
|
children: t4
|
|
@@ -285,11 +292,12 @@ function DropdownButton(t0) {
|
|
|
285
292
|
$[23] = disabled;
|
|
286
293
|
$[24] = dropdownRest;
|
|
287
294
|
$[25] = menu;
|
|
288
|
-
$[26] =
|
|
289
|
-
$[27] =
|
|
290
|
-
|
|
295
|
+
$[26] = resolvedSize;
|
|
296
|
+
$[27] = t4;
|
|
297
|
+
$[28] = t5;
|
|
298
|
+
} else t5 = $[28];
|
|
291
299
|
let t6;
|
|
292
|
-
if ($[
|
|
300
|
+
if ($[29] !== t2 || $[30] !== t5) {
|
|
293
301
|
t6 = /*#__PURE__*/ jsxs("span", {
|
|
294
302
|
"data-tao-dropdown-button-group": "",
|
|
295
303
|
children: [
|
|
@@ -297,10 +305,10 @@ function DropdownButton(t0) {
|
|
|
297
305
|
t5
|
|
298
306
|
]
|
|
299
307
|
});
|
|
300
|
-
$[
|
|
301
|
-
$[
|
|
302
|
-
$[
|
|
303
|
-
} else t6 = $[
|
|
308
|
+
$[29] = t2;
|
|
309
|
+
$[30] = t5;
|
|
310
|
+
$[31] = t6;
|
|
311
|
+
} else t6 = $[31];
|
|
304
312
|
return t6;
|
|
305
313
|
}
|
|
306
314
|
Dropdown.Button = DropdownButton;
|