@v-c/picker 1.2.2 → 1.3.0

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 (101) hide show
  1. package/dist/PickerInput/Popup/index.d.ts +13 -1
  2. package/dist/PickerInput/Popup/index.js +10 -1
  3. package/dist/PickerInput/RangePicker.js +55 -72
  4. package/dist/PickerInput/Selector/ClearIcon.d.ts +11 -0
  5. package/dist/PickerInput/Selector/ClearIcon.js +53 -0
  6. package/dist/PickerInput/Selector/Icon.d.ts +0 -5
  7. package/dist/PickerInput/Selector/Icon.js +16 -57
  8. package/dist/PickerInput/Selector/Input.js +2 -5
  9. package/dist/PickerInput/Selector/RangeSelector.js +9 -5
  10. package/dist/PickerInput/Selector/SingleSelector/index.d.ts +1 -1
  11. package/dist/PickerInput/Selector/SingleSelector/index.js +5 -8
  12. package/dist/PickerInput/SinglePicker.js +54 -39
  13. package/dist/PickerInput/hooks/useFocusEvents.d.ts +28 -0
  14. package/dist/PickerInput/hooks/useFocusEvents.js +36 -0
  15. package/dist/PickerInput/hooks/useFocusLock.d.ts +14 -0
  16. package/dist/PickerInput/hooks/useFocusLock.js +25 -0
  17. package/dist/PickerInput/hooks/useRangeDisabledDate.d.ts +1 -1
  18. package/dist/PickerInput/hooks/useRangeDisabledDate.js +3 -3
  19. package/dist/PickerInput/hooks/useRangePickerValue.d.ts +7 -1
  20. package/dist/PickerInput/hooks/useRangePickerValue.js +10 -16
  21. package/dist/PickerInput/hooks/useRangeValue.d.ts +3 -3
  22. package/dist/PickerInput/hooks/useRangeValue.js +15 -13
  23. package/dist/PickerInput/hooks/useRangeValueChange.d.ts +109 -0
  24. package/dist/PickerInput/hooks/useRangeValueChange.js +226 -0
  25. package/dist/locale/am_ET.js +4 -4
  26. package/dist/locale/ar_EG.js +4 -4
  27. package/dist/locale/az_AZ.js +4 -4
  28. package/dist/locale/bg_BG.js +4 -4
  29. package/dist/locale/bn_BD.js +4 -4
  30. package/dist/locale/by_BY.js +4 -4
  31. package/dist/locale/ca_ES.js +4 -4
  32. package/dist/locale/cs_CZ.js +4 -4
  33. package/dist/locale/da_DK.js +4 -4
  34. package/dist/locale/de_DE.js +4 -4
  35. package/dist/locale/el_GR.js +4 -4
  36. package/dist/locale/en_GB.js +4 -4
  37. package/dist/locale/en_US.js +4 -4
  38. package/dist/locale/es_ES.js +4 -4
  39. package/dist/locale/es_MX.js +4 -4
  40. package/dist/locale/et_EE.js +4 -4
  41. package/dist/locale/eu_ES.js +4 -4
  42. package/dist/locale/fa_IR.js +4 -4
  43. package/dist/locale/fi_FI.js +4 -4
  44. package/dist/locale/fr_BE.js +4 -4
  45. package/dist/locale/fr_CA.js +4 -4
  46. package/dist/locale/fr_FR.js +4 -4
  47. package/dist/locale/ga_IE.js +4 -4
  48. package/dist/locale/gl_ES.js +4 -4
  49. package/dist/locale/he_IL.js +4 -4
  50. package/dist/locale/hi_IN.js +4 -4
  51. package/dist/locale/hr_HR.js +4 -4
  52. package/dist/locale/hu_HU.js +4 -4
  53. package/dist/locale/id_ID.js +4 -4
  54. package/dist/locale/is_IS.js +4 -4
  55. package/dist/locale/it_IT.js +4 -4
  56. package/dist/locale/ja_JP.js +4 -4
  57. package/dist/locale/ka_GE.js +4 -4
  58. package/dist/locale/kk_KZ.js +4 -4
  59. package/dist/locale/km_KH.js +4 -4
  60. package/dist/locale/kmr_IQ.js +4 -4
  61. package/dist/locale/kn_IN.js +4 -4
  62. package/dist/locale/ko_KR.js +4 -4
  63. package/dist/locale/lt_LT.js +4 -4
  64. package/dist/locale/lv_LV.js +4 -4
  65. package/dist/locale/mk_MK.js +4 -4
  66. package/dist/locale/ml_IN.js +4 -4
  67. package/dist/locale/mn_MN.js +4 -4
  68. package/dist/locale/mr_IN.js +4 -4
  69. package/dist/locale/ms_MY.js +2 -2
  70. package/dist/locale/my_MM.js +4 -4
  71. package/dist/locale/nb_NO.js +4 -4
  72. package/dist/locale/ne_NP.js +4 -4
  73. package/dist/locale/nl_BE.js +4 -4
  74. package/dist/locale/nl_NL.js +4 -4
  75. package/dist/locale/pl_PL.js +4 -4
  76. package/dist/locale/pt_BR.js +4 -4
  77. package/dist/locale/pt_PT.js +4 -4
  78. package/dist/locale/ro_RO.js +4 -4
  79. package/dist/locale/ru_RU.js +4 -4
  80. package/dist/locale/si_LK.js +4 -4
  81. package/dist/locale/sk_SK.js +4 -4
  82. package/dist/locale/sl_SI.js +4 -4
  83. package/dist/locale/sr_Cyrl_RS.js +4 -4
  84. package/dist/locale/sr_RS.js +4 -4
  85. package/dist/locale/sv_SE.js +4 -4
  86. package/dist/locale/ta_IN.js +4 -4
  87. package/dist/locale/th_TH.js +4 -4
  88. package/dist/locale/tk_TK.js +4 -4
  89. package/dist/locale/tr_TR.js +4 -4
  90. package/dist/locale/ug_CN.js +4 -4
  91. package/dist/locale/uk_UA.js +4 -4
  92. package/dist/locale/ur_PK.js +4 -4
  93. package/dist/locale/uz_UZ.js +4 -4
  94. package/dist/locale/vi_VN.js +4 -4
  95. package/dist/locale/zh_CN.js +4 -4
  96. package/dist/locale/zh_TW.js +4 -4
  97. package/dist/utils/miscUtil.d.ts +1 -1
  98. package/dist/utils/miscUtil.js +3 -4
  99. package/package.json +4 -4
  100. package/dist/PickerInput/hooks/useRangeActive.d.ts +0 -9
  101. package/dist/PickerInput/hooks/useRangeActive.js +0 -59
@@ -1,5 +1,5 @@
1
1
  import { MouseEventHandler } from '@v-c/util/dist/EventInterface';
2
- import { InputHTMLAttributes } from 'vue';
2
+ import { InputHTMLAttributes, Ref } from 'vue';
3
3
  import { RangeTimeProps, SharedPickerProps, SharedTimeProps, ValueDate } from '../../interface';
4
4
  import { FooterProps } from './Footer';
5
5
  import { PopupPanelProps } from './PopupPanel';
@@ -16,6 +16,12 @@ export type PopupProps<DateType extends object = any, PresetValue = DateType> =
16
16
  isInvalid: (date: DateType | DateType[]) => boolean;
17
17
  onOk: VoidFunction;
18
18
  onPanelMouseDown?: MouseEventHandler;
19
+ /**
20
+ * Expose the popup container element so the Picker can tell whether focus
21
+ * is still inside the popup.
22
+ * 暴露 popup 容器元素,供 Picker 判断焦点是否仍在 popup 内。
23
+ */
24
+ popupContainerRef?: Ref<HTMLDivElement | undefined>;
19
25
  classNames?: SharedPickerProps['classNames'];
20
26
  styles?: SharedPickerProps['styles'];
21
27
  };
@@ -31,6 +37,12 @@ declare const Popup: import('vue').DefineSetupFnComponent<PopupProps<any, any>,
31
37
  isInvalid: (date: any) => boolean;
32
38
  onOk: VoidFunction;
33
39
  onPanelMouseDown?: MouseEventHandler;
40
+ /**
41
+ * Expose the popup container element so the Picker can tell whether focus
42
+ * is still inside the popup.
43
+ * 暴露 popup 容器元素,供 Picker 判断焦点是否仍在 popup 内。
44
+ */
45
+ popupContainerRef?: Ref<HTMLDivElement | undefined>;
34
46
  classNames?: SharedPickerProps["classNames"];
35
47
  styles?: SharedPickerProps["styles"];
36
48
  } & {}, import('vue').PublicProps>;
@@ -109,7 +109,11 @@ var Popup = /* @__PURE__ */ defineComponent((props) => {
109
109
  const marginLeft = "marginLeft";
110
110
  const marginRight = "marginRight";
111
111
  let renderNode = createVNode("div", {
112
- "ref": range ? containerRef : void 0,
112
+ "ref": (el) => {
113
+ const node = el ?? void 0;
114
+ if (range) containerRef.value = node;
115
+ if (props.popupContainerRef) props.popupContainerRef.value = node;
116
+ },
113
117
  "onMousedown": onPanelMouseDown,
114
118
  "tabindex": -1,
115
119
  "class": clsx(containerPrefixCls, `${ctx.value.prefixCls}-${internalMode}-panel-container`, classNames?.popup?.container),
@@ -502,6 +506,11 @@ var Popup = /* @__PURE__ */ defineComponent((props) => {
502
506
  type: Function,
503
507
  required: false,
504
508
  default: void 0
509
+ },
510
+ popupContainerRef: {
511
+ type: Object,
512
+ required: false,
513
+ default: void 0
505
514
  }
506
515
  },
507
516
  name: "Popup",
@@ -7,12 +7,14 @@ import { formatValues } from "../utils/valueUtil.js";
7
7
  import useCellRender from "./hooks/useCellRender.js";
8
8
  import useFieldsInvalidate from "./hooks/useFieldsInvalidate.js";
9
9
  import useFilledProps from "./hooks/useFilledProps.js";
10
+ import useFocusEvents, { isTargetInContainers } from "./hooks/useFocusEvents.js";
11
+ import useFocusLock from "./hooks/useFocusLock.js";
10
12
  import useOpen from "./hooks/useOpen.js";
11
13
  import usePresets from "./hooks/usePresets.js";
12
- import useRangeActive from "./hooks/useRangeActive.js";
13
14
  import useRangeDisabledDate from "./hooks/useRangeDisabledDate.js";
14
15
  import useRangePickerValue from "./hooks/useRangePickerValue.js";
15
16
  import useRangeValue, { useInnerValue } from "./hooks/useRangeValue.js";
17
+ import useRangeValueChange from "./hooks/useRangeValueChange.js";
16
18
  import useShowNow from "./hooks/useShowNow.js";
17
19
  import Popup from "./Popup/index.js";
18
20
  import RangeSelector from "./Selector/RangeSelector.js";
@@ -114,22 +116,44 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
114
116
  };
115
117
  const [mergedValue, setInnerValue, getCalendarValue, triggerCalendarChange, triggerOk] = useInnerValue(generateConfig, locale, formatList, ref(true), ref(false), defaultValue, value, onInternalCalendarChange, onInternalOk);
116
118
  const calendarValue = computed(() => getCalendarValue.value);
117
- const [focused, triggerFocus, lastOperation, activeIndex, setActiveIndex, nextActiveIndex, activeIndexList, updateSubmitIndex, hasActiveSubmitValue] = useRangeActive(disabled, allowEmpty, mergedOpen);
118
- const onSharedFocus = (event, index) => {
119
- triggerFocus(true);
120
- onFocus.value?.(event, { range: getActiveRange(index ?? activeIndex.value) });
119
+ const popupRef = ref();
120
+ const isInternalPickerElement = (element) => isTargetInContainers(element, [selectorRef.value?.nativeElement, popupRef.value]);
121
+ const [focused, onFieldFocus, onFieldBlur] = useFocusEvents(isInternalPickerElement, (index, event) => {
122
+ onFocus.value?.(event, { range: getActiveRange(index) });
123
+ }, (index, event) => {
124
+ onBlur.value?.(event, { range: getActiveRange(index) });
125
+ }, () => {
126
+ triggerOpen(false);
127
+ });
128
+ const [flushSubmit, triggerSubmitChange, resetValue] = useRangeValue(computed(() => ({
129
+ ...fp.value,
130
+ onChange: (dates, dateStrings) => {
131
+ fp.value.onChange?.(formatValues(dates, {
132
+ generateConfig: generateConfig.value,
133
+ locale: locale.value,
134
+ valueFormat: valueFormat.value
135
+ }), dateStrings);
136
+ }
137
+ })), mergedValue, setInnerValue, () => getCalendarValue.value, triggerCalendarChange, disabled, formatList, isInvalidateDate);
138
+ const triggerFieldCalendarChange = (index, date) => {
139
+ triggerCalendarChange(fillIndex(getCalendarValue.value, index, date));
121
140
  };
122
- const onSharedBlur = (event, index) => {
123
- triggerFocus(false);
124
- onBlur.value?.(event, { range: getActiveRange(index ?? activeIndex.value) });
141
+ const flushFieldSubmit = (index, needTriggerChange) => {
142
+ flushSubmit(index, needTriggerChange);
143
+ if (needTriggerChange) triggerOpen(false, { force: true });
125
144
  };
145
+ const [rangeValueIndex, activeIndex, forceFocus, triggeredFields, triggerRangeValueChange, resetRangeValueChange] = useRangeValueChange(computed(() => disabled.value.filter((fieldDisabled) => !fieldDisabled).length), needConfirm, allowEmpty, () => getCalendarValue.value, triggerFieldCalendarChange, flushFieldSubmit, resetValue);
146
+ useFocusLock(rangeValueIndex, forceFocus, selectorRef, popupRef, triggerOpen);
147
+ watch(mergedOpen, (open) => {
148
+ if (!open) triggerRangeValueChange(rangeValueIndex.value ?? activeIndex.value, "popupClose");
149
+ });
126
150
  /** Used for Popup panel */
127
151
  const mergedShowTime = computed(() => {
128
152
  if (!showTime.value) return null;
129
153
  const { disabledTime } = showTime.value;
130
154
  const proxyDisabledTime = disabledTime ? (date) => {
131
155
  const range = getActiveRange(activeIndex.value);
132
- const fromDate = getFromDate(calendarValue.value, activeIndexList.value, activeIndex.value);
156
+ const fromDate = getFromDate(calendarValue.value, triggeredFields.value, activeIndex.value);
133
157
  return disabledTime(date, range, { from: fromDate });
134
158
  } : void 0;
135
159
  return {
@@ -147,19 +171,9 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
147
171
  const internalMode = computed(() => mergedMode.value === "date" && mergedShowTime.value ? "datetime" : mergedMode.value);
148
172
  const multiplePanel = computed(() => internalMode.value === picker.value && internalMode.value !== "time");
149
173
  const mergedShowNow = useShowNow(picker, mergedMode, showNow, showToday, ref(true));
150
- const [flushSubmit, triggerSubmitChange] = useRangeValue(computed(() => ({
151
- ...fp.value,
152
- onChange: (dates, dateStrings) => {
153
- fp.value.onChange?.(formatValues(dates, {
154
- generateConfig: generateConfig.value,
155
- locale: locale.value,
156
- valueFormat: valueFormat.value
157
- }), dateStrings);
158
- }
159
- })), mergedValue, setInnerValue, () => getCalendarValue.value, triggerCalendarChange, disabled, formatList, focused, mergedOpen, isInvalidateDate);
160
- const mergedDisabledDate = useRangeDisabledDate(calendarValue, disabled, activeIndexList, generateConfig, locale, disabledDate);
174
+ const mergedDisabledDate = useRangeDisabledDate(calendarValue, disabled, activeIndex, triggeredFields, generateConfig, locale, disabledDate);
161
175
  const [submitInvalidates, onSelectorInvalid] = useFieldsInvalidate(calendarValue, isInvalidateDate, allowEmpty);
162
- const [currentPickerValue, setCurrentPickerValue] = useRangePickerValue(generateConfig, locale, calendarValue, modes, mergedOpen, activeIndex, internalPicker, multiplePanel, defaultPickerValue, pickerValue, computed(() => mergedShowTime.value?.defaultOpenValue), onPickerValueChange, minDate, maxDate);
176
+ const [currentPickerValue, setCurrentPickerValue] = useRangePickerValue(generateConfig, locale, calendarValue, modes, mergedOpen, focused, activeIndex, internalPicker, multiplePanel, defaultPickerValue, pickerValue, computed(() => mergedShowTime.value?.defaultOpenValue), onPickerValueChange, minDate, maxDate);
163
177
  const triggerModeChange = (nextPickerValue, nextMode, triggerEvent) => {
164
178
  const clone = fillIndex(modes.value, activeIndex.value, nextMode);
165
179
  if (clone[0] !== modes.value[0] || clone[1] !== modes.value[1]) setModes(clone);
@@ -176,15 +190,8 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
176
190
  * - Selector: enter key
177
191
  * - Panel: OK button
178
192
  */
179
- const triggerPartConfirm = (date, skipFocus) => {
180
- let nextValue = calendarValue.value;
181
- if (date) nextValue = fillCalendarValue(date, activeIndex.value);
182
- updateSubmitIndex(activeIndex.value);
183
- const nextIndex = nextActiveIndex(nextValue);
184
- triggerCalendarChange(nextValue);
185
- flushSubmit(activeIndex.value, nextIndex === null);
186
- if (nextIndex === null) triggerOpen(false, { force: true });
187
- else if (!skipFocus) selectorRef.value?.focus({ index: nextIndex });
193
+ const triggerPartConfirm = (date, source = "confirm") => {
194
+ triggerRangeValueChange(activeIndex.value, source, date ?? void 0);
188
195
  };
189
196
  const onSelectorClick = (event) => {
190
197
  const rootNode = event.target.getRootNode();
@@ -198,6 +205,7 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
198
205
  });
199
206
  };
200
207
  const onSelectorClear = () => {
208
+ resetRangeValueChange();
201
209
  triggerSubmitChange(null);
202
210
  triggerOpen(false, { force: true });
203
211
  fp.value.onClear?.();
@@ -235,34 +243,28 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
235
243
  };
236
244
  const onPanelFocus = (event) => {
237
245
  triggerOpen(true);
238
- onSharedFocus(event);
239
- };
240
- const onPanelMouseDown = () => {
241
- lastOperation("panel");
246
+ onFieldFocus(activeIndex.value, "panel", event);
242
247
  };
243
248
  const onSelectorChange = (date, index) => {
244
- const clone = fillCalendarValue(date, index);
245
- triggerCalendarChange(clone);
249
+ triggerRangeValueChange(index, "input", date);
246
250
  };
247
251
  const onSelectorInputChange = () => {
248
- lastOperation("input");
252
+ triggerRangeValueChange(activeIndex.value, "input");
249
253
  };
250
254
  const onSelectorBlur = (event, index) => {
251
- triggerOpen(false);
252
- if (!needConfirm.value && lastOperation() === "input") {
253
- const nextIndex = nextActiveIndex(calendarValue.value);
254
- flushSubmit(activeIndex.value, nextIndex === null);
255
- }
256
- onSharedBlur(event, index);
255
+ onFieldBlur(index, "input", event);
257
256
  };
258
257
  const onSelectorKeyDown = (event, preventDefault) => {
259
- if (event.key === "Tab") triggerPartConfirm(null, true);
258
+ if (event.key === "Tab") triggerPartConfirm(null, "keyboard-submit-weak");
259
+ else if (event.key === "Escape") {
260
+ triggerRangeValueChange(activeIndex.value, "esc");
261
+ triggerOpen(false);
262
+ }
260
263
  onKeyDown.value?.(event, preventDefault);
261
264
  };
262
265
  const onPanelSelect = (date) => {
263
- const clone = fillIndex(calendarValue.value, activeIndex.value, date);
264
- triggerCalendarChange(clone);
265
- if (!needConfirm.value && !complexPicker.value && internalPicker.value === internalMode.value) triggerPartConfirm(date);
266
+ const panelFinished = !complexPicker.value && internalPicker.value === internalMode.value;
267
+ triggerRangeValueChange(activeIndex.value, panelFinished ? "panel-final" : "panel-intermediate", date);
266
268
  };
267
269
  const onPopupClose = () => {
268
270
  triggerOpen(false);
@@ -306,29 +308,10 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
306
308
  ], () => {
307
309
  if (mergedOpen.value && activeIndex.value !== void 0) triggerModeChange(null, picker.value, false);
308
310
  }, { flush: "post" });
309
- watch(mergedOpen, () => {
310
- const lastOp = lastOperation();
311
- if (!mergedOpen.value && lastOp === "input") {
312
- triggerOpen(false);
313
- triggerPartConfirm(null, true);
314
- }
315
- if (!mergedOpen.value && complexPicker.value && !needConfirm.value && lastOp === "panel") {
316
- triggerOpen(true);
317
- triggerPartConfirm();
318
- }
319
- }, { flush: "post" });
320
311
  const onSelectorFocus = (event, index) => {
321
- const activeListLen = activeIndexList.value.length;
322
- const lastActiveIndex = activeIndexList.value[activeListLen - 1];
323
- if (activeListLen && lastActiveIndex !== index && needConfirm.value && !allowEmpty.value[lastActiveIndex] && !hasActiveSubmitValue(lastActiveIndex) && calendarValue.value[lastActiveIndex]) {
324
- selectorRef.value?.focus({ index: lastActiveIndex });
325
- return;
326
- }
327
- lastOperation("input");
312
+ triggerRangeValueChange(index, "field-switch");
328
313
  triggerOpen(true, { inherit: true });
329
- if (activeIndex.value !== index && mergedOpen.value && !needConfirm.value && complexPicker.value) triggerPartConfirm(null, true);
330
- setActiveIndex(index);
331
- onSharedFocus(event, index);
314
+ onFieldFocus(index, "input", event);
332
315
  };
333
316
  if (process.env.NODE_ENV !== "production") {
334
317
  const isIndexEmpty = (index) => {
@@ -353,7 +336,7 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
353
336
  onFocus: onSelectorFocus,
354
337
  onBlur: onSelectorBlur,
355
338
  onKeyDown: onSelectorKeyDown,
356
- onSubmit: triggerPartConfirm,
339
+ onSubmit: () => triggerPartConfirm(null, "keyboard-submit"),
357
340
  value: hoverValues.value,
358
341
  maskFormat: maskFormat.value,
359
342
  onChange: onSelectorChange,
@@ -373,6 +356,7 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
373
356
  };
374
357
  const panel = createVNode(Popup, {
375
358
  ...panelProps.value,
359
+ popupContainerRef: popupRef,
376
360
  showNow: mergedShowNow.value,
377
361
  showTime: mergedShowTime.value,
378
362
  range: true,
@@ -380,8 +364,7 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
380
364
  activeInfo: activeInfo.value,
381
365
  disabledDate: mergedDisabledDate,
382
366
  onFocus: onPanelFocus,
383
- onBlur: onSharedBlur,
384
- onPanelMouseDown,
367
+ onBlur: (event) => onFieldBlur(activeIndex.value, "panel", event),
385
368
  picker: picker.value,
386
369
  mode: mergedMode.value,
387
370
  internalMode: internalMode.value,
@@ -397,7 +380,7 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
397
380
  hoverValue: hoverValues.value,
398
381
  onHover: onPanelHover,
399
382
  needConfirm: needConfirm.value,
400
- onSubmit: triggerPartConfirm,
383
+ onSubmit: (date) => triggerPartConfirm(date, "confirm"),
401
384
  onOk: triggerOk,
402
385
  presets: presetList.value,
403
386
  onPresetHover,
@@ -0,0 +1,11 @@
1
+ import { VueNode } from '@v-c/util/dist/type';
2
+ export interface ClearIconProps {
3
+ icon?: VueNode;
4
+ onClear: VoidFunction;
5
+ }
6
+ /**
7
+ * Rendered as a real `<button>` rather than a `<span role="button">` so it is
8
+ * focusable and activatable by keyboard, and announced with a label.
9
+ */
10
+ declare const ClearIcon: import('vue').DefineSetupFnComponent<ClearIconProps, {}, {}, ClearIconProps & {}, import('vue').PublicProps>;
11
+ export default ClearIcon;
@@ -0,0 +1,53 @@
1
+ import { usePickerContext } from "../context.js";
2
+ import { createVNode, defineComponent, mergeProps } from "vue";
3
+ import { clsx } from "@v-c/util";
4
+ //#region src/PickerInput/Selector/ClearIcon.tsx
5
+ /**
6
+ * Rendered as a real `<button>` rather than a `<span role="button">` so it is
7
+ * focusable and activatable by keyboard, and announced with a label.
8
+ */
9
+ var ClearIcon = /* @__PURE__ */ defineComponent((props, { attrs }) => {
10
+ const ctx = usePickerContext();
11
+ return () => {
12
+ const { prefixCls, classNames, styles, locale } = ctx.value;
13
+ const { class: attrClass, style: attrStyle, ...restAttrs } = attrs;
14
+ const mergedAttrStyle = attrStyle && typeof attrStyle === "object" ? attrStyle : {};
15
+ return createVNode("button", mergeProps(restAttrs, {
16
+ "type": "button",
17
+ "aria-label": locale.clear,
18
+ "class": clsx(`${prefixCls}-clear`, classNames.suffix, attrClass),
19
+ "style": {
20
+ ...styles.suffix || {},
21
+ ...mergedAttrStyle
22
+ },
23
+ "onMousedown": (e) => {
24
+ e.preventDefault();
25
+ },
26
+ "onClick": (e) => {
27
+ e.stopPropagation();
28
+ props.onClear();
29
+ }
30
+ }), [props.icon]);
31
+ };
32
+ }, {
33
+ props: {
34
+ icon: {
35
+ type: [
36
+ Object,
37
+ Function,
38
+ String,
39
+ Number,
40
+ null,
41
+ Boolean,
42
+ Array
43
+ ],
44
+ required: false,
45
+ default: void 0
46
+ },
47
+ onClear: { required: true }
48
+ },
49
+ name: "ClearIcon",
50
+ inheritAttrs: false
51
+ });
52
+ //#endregion
53
+ export { ClearIcon as default };
@@ -1,11 +1,6 @@
1
1
  import { VueNode } from '@v-c/util/dist/type';
2
2
  export interface IconProps {
3
3
  icon?: VueNode;
4
- type: 'suffix' | 'clear';
5
4
  }
6
5
  declare const Icon: import('vue').DefineSetupFnComponent<IconProps, {}, {}, IconProps & {}, import('vue').PublicProps>;
7
6
  export default Icon;
8
- export interface ClearIconProps extends Omit<IconProps, 'type'> {
9
- onClear: VoidFunction;
10
- }
11
- export declare const ClearIcon: import('vue').DefineSetupFnComponent<ClearIconProps, {}, {}, ClearIconProps & {}, import('vue').PublicProps>;
@@ -5,13 +5,13 @@ import { clsx } from "@v-c/util";
5
5
  var Icon = /* @__PURE__ */ defineComponent((props, { attrs }) => {
6
6
  const ctx = usePickerContext();
7
7
  return () => {
8
- const { icon, type } = props;
8
+ const { icon } = props;
9
9
  if (!icon) return null;
10
10
  const { prefixCls, classNames, styles } = ctx.value;
11
11
  const { class: attrClass, style: attrStyle, ...restAttrs } = attrs;
12
12
  const mergedAttrStyle = attrStyle && typeof attrStyle === "object" ? attrStyle : {};
13
13
  return createVNode("span", mergeProps(restAttrs, {
14
- "class": clsx(`${prefixCls}-${type}`, classNames.suffix, attrClass),
14
+ "class": clsx(`${prefixCls}-suffix`, classNames.suffix, attrClass),
15
15
  "style": {
16
16
  ...styles.suffix || {},
17
17
  ...mergedAttrStyle
@@ -19,62 +19,21 @@ var Icon = /* @__PURE__ */ defineComponent((props, { attrs }) => {
19
19
  }), [icon]);
20
20
  };
21
21
  }, {
22
- props: {
23
- icon: {
24
- type: [
25
- Object,
26
- Function,
27
- String,
28
- Number,
29
- null,
30
- Boolean,
31
- Array
32
- ],
33
- required: false,
34
- default: void 0
35
- },
36
- type: {
37
- type: String,
38
- required: true
39
- }
40
- },
22
+ props: { icon: {
23
+ type: [
24
+ Object,
25
+ Function,
26
+ String,
27
+ Number,
28
+ null,
29
+ Boolean,
30
+ Array
31
+ ],
32
+ required: false,
33
+ default: void 0
34
+ } },
41
35
  name: "Icon",
42
36
  inheritAttrs: false
43
37
  });
44
- var ClearIcon = /* @__PURE__ */ defineComponent((props, { attrs }) => {
45
- return () => {
46
- return createVNode(Icon, mergeProps(attrs, {
47
- "icon": props.icon,
48
- "type": "clear",
49
- "role": "button",
50
- "onMousedown": (e) => {
51
- e.preventDefault();
52
- },
53
- "onClick": (e) => {
54
- e.stopPropagation();
55
- props.onClear();
56
- }
57
- }), null);
58
- };
59
- }, {
60
- props: {
61
- onClear: { required: true },
62
- icon: {
63
- type: [
64
- Object,
65
- Function,
66
- String,
67
- Number,
68
- null,
69
- Boolean,
70
- Array
71
- ],
72
- required: false,
73
- default: void 0
74
- }
75
- },
76
- name: "ClearIcon",
77
- inheritAttrs: false
78
- });
79
38
  //#endregion
80
- export { ClearIcon, Icon as default };
39
+ export { Icon as default };
@@ -1,8 +1,8 @@
1
1
  import { usePickerContext } from "../context.js";
2
2
  import { leftPad } from "../../utils/miscUtil.js";
3
+ import Icon from "./Icon.js";
3
4
  import { getMaskRange, raf } from "./util.js";
4
5
  import useLockEffect from "../hooks/useLockEffect.js";
5
- import Icon from "./Icon.js";
6
6
  import MaskFormat from "./MaskFormat.js";
7
7
  import { computed, createVNode, defineComponent, mergeProps, onBeforeUnmount, ref, toRef, watch } from "vue";
8
8
  import { clsx } from "@v-c/util";
@@ -221,10 +221,7 @@ var Input = /* @__PURE__ */ defineComponent((props, { attrs, expose }) => {
221
221
  "class": classNames.value.input,
222
222
  "style": styles.value.input
223
223
  }), null),
224
- createVNode(Icon, {
225
- "type": "suffix",
226
- "icon": props.suffixIcon
227
- }, null),
224
+ createVNode(Icon, { "icon": props.suffixIcon }, null),
228
225
  props.clearIcon
229
226
  ]);
230
227
  };
@@ -1,7 +1,8 @@
1
1
  import { usePickerContext } from "../context.js";
2
+ import ClearIcon from "./ClearIcon.js";
2
3
  import useInputProps from "./hooks/useInputHooks.js";
3
4
  import useRootProps from "./hooks/useRootProps.js";
4
- import Icon, { ClearIcon } from "./Icon.js";
5
+ import Icon from "./Icon.js";
5
6
  import Input from "./Input.js";
6
7
  import { computed, createVNode, defineComponent, mergeProps, ref, watch } from "vue";
7
8
  import { clsx } from "@v-c/util";
@@ -24,6 +25,12 @@ var RangeSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose }) =
24
25
  const getInput = (index) => [inputStartRef, inputEndRef][index]?.value;
25
26
  expose({
26
27
  nativeElement: rootRef,
28
+ get startInput() {
29
+ return inputStartRef.value?.inputElement;
30
+ },
31
+ get endInput() {
32
+ return inputEndRef.value?.inputElement;
33
+ },
27
34
  focus: (options) => {
28
35
  if (typeof options === "object") {
29
36
  const { index = 0, ...rest } = options || {};
@@ -118,10 +125,7 @@ var RangeSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose }) =
118
125
  "class": `${prefixCls.value}-active-bar`,
119
126
  "style": activeBarStyle.value
120
127
  }, null),
121
- createVNode(Icon, {
122
- "type": "suffix",
123
- "icon": suffixIcon
124
- }, null),
128
+ createVNode(Icon, { "icon": suffixIcon }, null),
125
129
  showClear.value && createVNode(ClearIcon, {
126
130
  "icon": clearIcon,
127
131
  "onClear": onClear
@@ -2,7 +2,7 @@ import { InternalMode, SelectorProps } from '../../../interface';
2
2
  export interface SingleSelectorProps<DateType extends object = any> extends SelectorProps<DateType> {
3
3
  id?: string;
4
4
  value?: DateType[];
5
- onChange: (date: DateType[]) => void;
5
+ onChange: (date: DateType[], source?: 'input' | 'remove') => void;
6
6
  internalPicker: InternalMode;
7
7
  disabled?: boolean;
8
8
  /** All the field show as `placeholder` */
@@ -1,8 +1,9 @@
1
1
  import { usePickerContext } from "../../context.js";
2
2
  import { isSame } from "../../../utils/dateUtil.js";
3
+ import ClearIcon from "../ClearIcon.js";
3
4
  import useInputProps from "../hooks/useInputHooks.js";
4
5
  import useRootProps from "../hooks/useRootProps.js";
5
- import Icon, { ClearIcon } from "../Icon.js";
6
+ import Icon from "../Icon.js";
6
7
  import Input from "../Input.js";
7
8
  import MultipleDates from "./MultipleDates.js";
8
9
  import { Fragment, computed, createVNode, defineComponent, mergeProps, ref } from "vue";
@@ -27,12 +28,11 @@ var SingleSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose })
27
28
  });
28
29
  const rootProps = useRootProps(props);
29
30
  const onSingleChange = (date) => {
30
- props.onChange?.([date]);
31
+ props.onChange?.([date], "input");
31
32
  };
32
33
  const onMultipleRemove = (date) => {
33
34
  const nextValues = (props.value || []).filter((oriDate) => oriDate && !isSame(props.generateConfig, props.locale, oriDate, date, props.internalPicker));
34
- props.onChange?.(nextValues);
35
- if (!props.open) props.onSubmit?.();
35
+ props.onChange?.(nextValues, props.open ? "input" : "remove");
36
36
  };
37
37
  const [getInputProps, getText] = useInputProps(computed(() => ({
38
38
  ...props,
@@ -65,10 +65,7 @@ var SingleSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose })
65
65
  "autofocus": autoFocus,
66
66
  "tabindex": tabIndex
67
67
  }, null),
68
- createVNode(Icon, {
69
- "type": "suffix",
70
- "icon": suffixIcon
71
- }, null),
68
+ createVNode(Icon, { "icon": suffixIcon }, null),
72
69
  showClear && createVNode(ClearIcon, {
73
70
  "icon": clearIcon,
74
71
  "onClear": onClear