@rockshin/tao-ui 0.0.58 → 0.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/components/affix/affix.js +38 -4
  2. package/dist/components/app/app-modals.js +11 -6
  3. package/dist/components/app/app-notices.js +105 -47
  4. package/dist/components/auto-complete/auto-complete.js +9 -2
  5. package/dist/components/calendar/calendar.js +22 -18
  6. package/dist/components/carousel/carousel.js +27 -14
  7. package/dist/components/cascader/cascader.js +17 -12
  8. package/dist/components/checkbox/checkbox.d.ts +3 -1
  9. package/dist/components/checkbox/checkbox.js +65 -58
  10. package/dist/components/color-picker/color-picker.js +383 -360
  11. package/dist/components/date-picker/calendar/calendar-grid.d.ts +5 -3
  12. package/dist/components/date-picker/calendar/calendar-grid.js +9 -4
  13. package/dist/components/date-picker/calendar/month-grid.d.ts +2 -1
  14. package/dist/components/date-picker/calendar/month-grid.js +61 -45
  15. package/dist/components/date-picker/calendar/time-panel.d.ts +8 -1
  16. package/dist/components/date-picker/calendar/time-panel.js +89 -88
  17. package/dist/components/date-picker/calendar/year-grid.d.ts +2 -1
  18. package/dist/components/date-picker/calendar/year-grid.js +60 -44
  19. package/dist/components/date-picker/date-picker.css +9 -0
  20. package/dist/components/date-picker/date-picker.js +22 -13
  21. package/dist/components/date-picker/range-picker.d.ts +2 -0
  22. package/dist/components/date-picker/range-picker.js +127 -70
  23. package/dist/components/date-picker/types.js +1 -1
  24. package/dist/components/drawer/drawer.d.ts +1 -1
  25. package/dist/components/drawer/drawer.js +4 -3
  26. package/dist/components/dropdown/dropdown.js +11 -9
  27. package/dist/components/float-button/float-button.js +4 -4
  28. package/dist/components/form/form-item.d.ts +1 -1
  29. package/dist/components/form/form-item.js +160 -120
  30. package/dist/components/form-field/form-field-view.d.ts +2 -1
  31. package/dist/components/form-field/form-field-view.js +173 -108
  32. package/dist/components/input/input-shared.js +3 -2
  33. package/dist/components/input/otp.js +114 -110
  34. package/dist/components/input/password.js +55 -61
  35. package/dist/components/input/search.js +8 -4
  36. package/dist/components/mentions/mentions.js +1 -0
  37. package/dist/components/menu/menu-render.js +1 -0
  38. package/dist/components/modal/confirm-dialog.js +11 -4
  39. package/dist/components/modal/modal.js +320 -315
  40. package/dist/components/pagination/pagination.d.ts +1 -0
  41. package/dist/components/pagination/pagination.js +1 -0
  42. package/dist/components/popover/popover.js +325 -289
  43. package/dist/components/qr-code/qr-code.js +157 -150
  44. package/dist/components/radio/radio.d.ts +3 -1
  45. package/dist/components/radio/radio.js +73 -64
  46. package/dist/components/select/mobile-select.js +6 -3
  47. package/dist/components/select/select-model.js +2 -2
  48. package/dist/components/select/select.js +78 -39
  49. package/dist/components/select/use-select-selection.js +58 -58
  50. package/dist/components/slider/slider.d.ts +2 -2
  51. package/dist/components/slider/slider.js +13 -2
  52. package/dist/components/sonner/sonner.js +2 -2
  53. package/dist/components/splitter/splitter.css +1 -0
  54. package/dist/components/splitter/splitter.js +152 -126
  55. package/dist/components/switch/switch.js +45 -39
  56. package/dist/components/table/table.js +1 -0
  57. package/dist/components/table/use-table-data.js +2 -2
  58. package/dist/components/time-picker/time-picker.js +31 -1
  59. package/dist/components/tooltip/tooltip.js +237 -99
  60. package/dist/components/tree/tree.js +31 -3
  61. package/dist/components/tree-select/tree-select.js +1 -1
  62. package/dist/components/upload/upload.js +67 -40
  63. package/dist/locales/ar-EG.js +2 -0
  64. package/dist/locales/de-DE.js +2 -0
  65. package/dist/locales/en-US.js +2 -0
  66. package/dist/locales/es-ES.js +2 -0
  67. package/dist/locales/fr-FR.js +2 -0
  68. package/dist/locales/hi-IN.js +2 -0
  69. package/dist/locales/id-ID.js +2 -0
  70. package/dist/locales/it-IT.js +2 -0
  71. package/dist/locales/ja-JP.js +2 -0
  72. package/dist/locales/ko-KR.js +2 -0
  73. package/dist/locales/pt-BR.js +2 -0
  74. package/dist/locales/ru-RU.js +2 -0
  75. package/dist/locales/th-TH.js +2 -0
  76. package/dist/locales/tr-TR.js +2 -0
  77. package/dist/locales/types.d.ts +2 -0
  78. package/dist/locales/vi-VN.js +2 -0
  79. package/dist/locales/zh-CN.js +2 -0
  80. package/dist/locales/zh-TW.js +2 -0
  81. package/dist/number-input/format.js +1 -1
  82. package/dist/number-input/use-number-input.js +166 -321
  83. package/dist/number-input/validate.d.ts +1 -0
  84. package/dist/number-input/validate.js +1 -1
  85. package/dist/provider/tao-provider.d.ts +2 -2
  86. package/dist/provider/tao-provider.js +49 -49
  87. package/dist/utils/composed-parent.d.ts +1 -0
  88. package/dist/utils/composed-parent.js +7 -0
  89. package/dist/utils/portal.d.ts +5 -0
  90. package/dist/utils/portal.js +7 -1
  91. package/dist/utils/refs.d.ts +3 -1
  92. package/dist/utils/refs.js +25 -1
  93. package/package.json +1 -1
@@ -12,7 +12,7 @@ import { Drawer } from "../drawer/drawer.js";
12
12
  import { CalendarGrid } from "./calendar/calendar-grid.js";
13
13
  import { CalendarHeader } from "./calendar/calendar-header.js";
14
14
  import { MonthGrid } from "./calendar/month-grid.js";
15
- import { TimePanel } from "./calendar/time-panel.js";
15
+ import { TimePanel, getTimeUnits } from "./calendar/time-panel.js";
16
16
  import { YearGrid } from "./calendar/year-grid.js";
17
17
  import "./date-picker.css";
18
18
  import { Presets } from "./presets.js";
@@ -83,7 +83,8 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
83
83
  resolvedDisabled
84
84
  ]);
85
85
  const [internalOpen, setInternalOpen] = useState(false);
86
- const isOpen = controlledOpen ?? internalOpen;
86
+ if (resolvedDisabled && internalOpen) setInternalOpen(false);
87
+ const isOpen = controlledOpen ?? (!resolvedDisabled && internalOpen);
87
88
  const setOpen = useCallback((v)=>{
88
89
  if (v === isOpen) return;
89
90
  setInternalOpen(v);
@@ -113,12 +114,14 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
113
114
  isDateBlocked
114
115
  ]);
115
116
  const panelValue = typedValue ?? resolvedValue;
117
+ const wasOpenRef = useRef(false);
116
118
  useEffect(()=>{
117
- if (isOpen) {
119
+ if (isOpen && !wasOpenRef.current) {
118
120
  setViewDate(resolvedValue ?? dayjs());
119
121
  setPanelMode('year' === picker ? 'year' : 'month' === picker ? 'month' : 'date');
120
122
  setTimeScrollKey((k)=>k + 1);
121
123
  }
124
+ wasOpenRef.current = isOpen;
122
125
  }, [
123
126
  isOpen,
124
127
  picker,
@@ -176,7 +179,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
176
179
  emitChange(date_3, formatValue(date_3));
177
180
  setOpen(false);
178
181
  } else {
179
- setViewDate(date_3);
182
+ setViewDate((current)=>current.year(date_3.year()));
180
183
  setPanelMode('month' === picker ? 'month' : 'date');
181
184
  }
182
185
  }, [
@@ -260,10 +263,17 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
260
263
  setOpen
261
264
  ]);
262
265
  const showTimePanel = !!(showTime && 'date' === panelMode);
266
+ const timeUnits = getTimeUnits(fmt);
263
267
  const today = isOpen && showTimePanel ? dayjs() : null;
264
268
  const nowBlocked = null != today && isDateBlocked(today);
265
269
  const timeBlocked = null != today && (panelValue ? isDateBlocked(panelValue) : nowBlocked);
266
270
  const isPanelDateDisabled = (date_4)=>resolvedDisabled || Boolean(disabledDate?.(date_4));
271
+ const isPeriodDisabled = (period, unit)=>{
272
+ if (resolvedDisabled) return true;
273
+ const step = 'date' === picker ? 'day' : 'month';
274
+ for(let d_0 = period.startOf(unit); d_0.isSame(period, unit); d_0 = d_0.add(1, step))if (!isDateBlocked(d_0)) return false;
275
+ return true;
276
+ };
267
277
  const datePanel = /*#__PURE__*/ jsxs(Fragment, {
268
278
  children: [
269
279
  /*#__PURE__*/ jsx(CalendarHeader, {
@@ -292,7 +302,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
292
302
  viewDate: viewDate,
293
303
  value: panelValue,
294
304
  onSelect: handleMonthSelect,
295
- disabledDate: isPanelDateDisabled,
305
+ disabledDate: 'month' === picker ? isPanelDateDisabled : (date_5)=>isPeriodDisabled(date_5, 'month'),
296
306
  minDate: minDate,
297
307
  maxDate: maxDate
298
308
  }),
@@ -300,7 +310,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
300
310
  viewDate: viewDate,
301
311
  value: panelValue,
302
312
  onSelect: handleYearSelect,
303
- disabledDate: isPanelDateDisabled,
313
+ disabledDate: 'year' === picker ? isPanelDateDisabled : (date_6)=>isPeriodDisabled(date_6, 'year'),
304
314
  minDate: minDate,
305
315
  maxDate: maxDate
306
316
  })
@@ -324,15 +334,13 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
324
334
  /*#__PURE__*/ jsxs("div", {
325
335
  "data-tao-picker-time": "",
326
336
  children: [
327
- /*#__PURE__*/ jsxs("div", {
337
+ /*#__PURE__*/ jsx("div", {
328
338
  "data-tao-time-header": "",
329
339
  children: [
330
- String(timeValue.hour).padStart(2, '0'),
331
- ":",
332
- String(timeValue.minute).padStart(2, '0'),
333
- ":",
334
- String(timeValue.second).padStart(2, '0')
335
- ]
340
+ 'hour',
341
+ 'minute',
342
+ 'second'
343
+ ].filter((unit_0)=>timeUnits[unit_0]).map((unit_1)=>String(timeValue[unit_1]).padStart(2, '0')).join(':')
336
344
  }),
337
345
  /*#__PURE__*/ jsx(TimePanel, {
338
346
  hour: timeValue.hour,
@@ -341,6 +349,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
341
349
  disabled: resolvedDisabled || timeBlocked,
342
350
  onChange: handleTimeChange,
343
351
  config: 'object' == typeof showTime ? showTime : void 0,
352
+ format: fmt,
344
353
  scrollKey: timeScrollKey
345
354
  })
346
355
  ]
@@ -24,6 +24,8 @@ export interface RangePickerProps extends Pick<AriaAttributes, 'aria-label' | 'a
24
24
  size?: TaoSize;
25
25
  variant?: TaoVariant;
26
26
  disabled?: boolean | [boolean, boolean];
27
+ /** Permit an open start or end when both endpoints are editable. */
28
+ allowEmpty?: [boolean, boolean];
27
29
  allowClear?: boolean;
28
30
  status?: TaoStatus;
29
31
  ref?: Ref<PickerRef>;
@@ -19,7 +19,7 @@ import { formatPickerDate, parsePickerDate } from "./date-localization.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
- const isOpen = controlledOpen ?? internalOpen;
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: 'pickingEnd' === current.phase ? 'start' : current.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 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());
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
- date_1
213
+ date_2
188
214
  ] : [
189
- date_1,
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 ('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 {
213
- let start_0 = 'pickingEnd' === interaction.phase ? interaction.start : rangeStart;
214
- let end_0 = date_1;
215
- if (start_0 && date_1.isBefore(start_0, orderUnit)) [start_0, end_0] = [
216
- date_1,
217
- start_0
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((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;
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' === position_1 && null != rangeEnd && parsed_0.isAfter(rangeEnd, orderUnit) || 'end' === position_1 && null != rangeStart && parsed_0.isBefore(rangeStart, orderUnit));
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' === position_1) setInputStart(currentValue);
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: position_1
373
+ activeInput: position_2
343
374
  });
344
375
  if (parsed_0 && !keepPopupOpen) setViewDateStart(parsed_0);
345
- if ('start' === position_1) setInputStart(isValueControlled && !withTime ? displayStart : nextStrings[0]);
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 = (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));
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((date_4, index)=>{
495
+ ].map((date_5, index)=>{
456
496
  const shared = {
457
- viewDate: date_4,
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 = (date_5)=>'year' === picker ? Math.floor(date_5.year() / 10) : date_5.startOf(panelUnit).valueOf();
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][aria-pressed="true"]:not(:disabled)') ?? popup.querySelector('[data-tao-calendar-date]:not(:disabled)') ?? popup.querySelector('button:not(:disabled)');
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, true);
650
+ commitInputValue(interaction.activeInput, {
651
+ keepPopupOpen: true
652
+ });
605
653
  setKeyboardFocusRequested(true);
606
654
  if (!isOpen) setOpen(true);
607
655
  };
@@ -702,17 +750,19 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
702
750
  disabled: startDisabled,
703
751
  onFocus: ()=>{
704
752
  returnFocusRef.current = startInputRef.current;
705
- setInteraction({
706
- phase: 'idle',
707
- activeInput: 'start'
708
- });
753
+ setInteraction((current_1)=>'pickingStart' === current_1.phase ? current_1 : {
754
+ phase: 'idle',
755
+ activeInput: 'start'
756
+ });
709
757
  },
710
758
  onChange: (event_3)=>setInputStart(event_3.target.value),
711
759
  onBlur: (event_4)=>{
712
760
  const enteringCalendar = event_4.relatedTarget instanceof HTMLElement && !!popupRef.current?.contains(event_4.relatedTarget);
713
761
  if (enteringCalendar && keyboardFocusRequested) return;
714
762
  setKeyboardFocusRequested(false);
715
- commitInputValue('start', enteringCalendar || event_4.relatedTarget === endInputRef.current);
763
+ commitInputValue('start', {
764
+ keepPopupOpen: enteringCalendar || event_4.relatedTarget === endInputRef.current
765
+ });
716
766
  },
717
767
  onKeyDown: (event_5)=>{
718
768
  if (event_5.nativeEvent.isComposing || 229 === event_5.keyCode) return;
@@ -721,7 +771,9 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
721
771
  openFromKeyboard();
722
772
  } else if ('Enter' === event_5.key) {
723
773
  event_5.preventDefault();
724
- commitInputValue('start');
774
+ commitInputValue('start', {
775
+ openIncomplete: true
776
+ });
725
777
  } else if ('Escape' === event_5.key) {
726
778
  setInputStart(displayStart);
727
779
  setOpen(false);
@@ -754,17 +806,19 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
754
806
  disabled: endDisabled,
755
807
  onFocus: ()=>{
756
808
  returnFocusRef.current = endInputRef.current;
757
- setInteraction({
758
- phase: 'idle',
759
- activeInput: 'end'
760
- });
809
+ setInteraction((current_2)=>'pickingEnd' === current_2.phase ? current_2 : {
810
+ phase: 'idle',
811
+ activeInput: 'end'
812
+ });
761
813
  },
762
814
  onChange: (event_6)=>setInputEnd(event_6.target.value),
763
815
  onBlur: (event_7)=>{
764
816
  const enteringCalendar_0 = event_7.relatedTarget instanceof HTMLElement && !!popupRef.current?.contains(event_7.relatedTarget);
765
817
  if (enteringCalendar_0 && keyboardFocusRequested) return;
766
818
  setKeyboardFocusRequested(false);
767
- commitInputValue('end', enteringCalendar_0 || event_7.relatedTarget === startInputRef.current);
819
+ commitInputValue('end', {
820
+ keepPopupOpen: enteringCalendar_0 || event_7.relatedTarget === startInputRef.current
821
+ });
768
822
  },
769
823
  onKeyDown: (event_8)=>{
770
824
  if (event_8.nativeEvent.isComposing || 229 === event_8.keyCode) return;
@@ -773,7 +827,9 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
773
827
  openFromKeyboard();
774
828
  } else if ('Enter' === event_8.key) {
775
829
  event_8.preventDefault();
776
- commitInputValue('end');
830
+ commitInputValue('end', {
831
+ openIncomplete: true
832
+ });
777
833
  } else if ('Escape' === event_8.key) {
778
834
  setInputEnd(displayEnd);
779
835
  setOpen(false);
@@ -805,6 +861,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
805
861
  asChild: true,
806
862
  children: desktopTrigger
807
863
  }),
864
+ announcement,
808
865
  /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_c8444160.Portal, {
809
866
  children: /*#__PURE__*/ jsx(TaoPortalScope, {
810
867
  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 'YYYY-MM-DD HH:mm:ss';
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";
@@ -97,8 +98,7 @@ function Dropdown(props) {
97
98
  }, [
98
99
  updateOpen
99
100
  ]);
100
- const latestSetOpen = useRef(setOpen);
101
- latestSetOpen.current = setOpen;
101
+ const latestSetOpen = useCommittedRef(setOpen);
102
102
  useEffect(()=>{
103
103
  if (resolvedDisabled && realOpen && null == open) setOpen(false);
104
104
  }, [
@@ -107,18 +107,20 @@ function Dropdown(props) {
107
107
  resolvedDisabled,
108
108
  setOpen
109
109
  ]);
110
- const openOnHover = useCallback(()=>{
110
+ const openOnHover = useCallback((event)=>{
111
+ if ('touch' === event.pointerType) return;
111
112
  clearTimeout(closeTimer.current);
112
113
  if (!realOpen) setOpen(true);
113
114
  }, [
114
115
  realOpen,
115
116
  setOpen
116
117
  ]);
117
- const closeOnHover = useCallback(()=>{
118
- if (!realOpen) return;
118
+ const closeOnHover = useCallback((event_0)=>{
119
+ if (!realOpen || 'touch' === event_0.pointerType) return;
119
120
  clearTimeout(closeTimer.current);
120
121
  closeTimer.current = setTimeout(()=>latestSetOpen.current(false), 120);
121
122
  }, [
123
+ latestSetOpen,
122
124
  realOpen
123
125
  ]);
124
126
  const { content, selectedKeys, commitSelection } = useMenuController(menu, DD, {
@@ -160,8 +162,8 @@ function Dropdown(props) {
160
162
  disabled: resolvedDisabled,
161
163
  "data-tao-dropdown-trigger": "",
162
164
  ...hoverProps,
163
- onPointerDown: (event)=>{
164
- if (!clickMode) event.preventDefault();
165
+ onPointerDown: (event_1)=>{
166
+ if (!clickMode && 'touch' !== event_1.pointerType) event_1.preventDefault();
165
167
  },
166
168
  children: triggerChild
167
169
  }),
@@ -181,8 +183,8 @@ function Dropdown(props) {
181
183
  side: side,
182
184
  align: align,
183
185
  sideOffset: 4,
184
- onCloseAutoFocus: (event_0)=>{
185
- if (latestVisible.current) event_0.preventDefault();
186
+ onCloseAutoFocus: (event_2)=>{
187
+ if (latestVisible.current) event_2.preventDefault();
186
188
  },
187
189
  ...hoverProps,
188
190
  children: [