@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
@@ -16,10 +16,10 @@ var locale = {
16
16
  monthSelect: "Ay Seç",
17
17
  yearSelect: "Yıl Seç",
18
18
  decadeSelect: "On Yıl Seç",
19
- previousMonth: "Önceki Ay (PageUp)",
20
- nextMonth: "Sonraki Ay (PageDown)",
21
- previousYear: "Önceki Yıl (Control + Sol)",
22
- nextYear: "Sonraki Yıl (Control + Sağ)",
19
+ previousMonth: "Önceki Ay",
20
+ nextMonth: "Sonraki Ay",
21
+ previousYear: "Önceki Yıl",
22
+ nextYear: "Sonraki Yıl",
23
23
  previousDecade: "Önceki On Yıl",
24
24
  nextDecade: "Sonraki On Yıl",
25
25
  previousCentury: "Önceki Yüzyıl",
@@ -13,15 +13,15 @@ var locale = {
13
13
  week: "ھەپتە",
14
14
  month: "ئاي",
15
15
  year: "يىل",
16
- previousMonth: "ئالدىنقى ئاي(ئالدىنقى بەت )",
17
- nextMonth: "كېلەركى ئاي (كېلەركى بەت)",
16
+ previousMonth: "ئالدىنقى ئاي",
17
+ nextMonth: "كېلەر ئاي",
18
18
  monthSelect: "ئاي تاللاش",
19
19
  yearSelect: "يىل تاللاش",
20
20
  decadeSelect: "يىللارنى تاللاش",
21
21
  yearFormat: "YYYY-يىلى",
22
22
  dayFormat: "D-كۈنى",
23
- previousYear: "ئالدىنقى يىلى (Controlبىلەن يۆنىلىش كونۇپكىسى)",
24
- nextYear: "كېلەركى يىلى (Controlبىلەن يۆنىلىش كونۇپكىسى)",
23
+ previousYear: "ئالدىنقى يىلى",
24
+ nextYear: "كېلەركى يىلى",
25
25
  previousDecade: "ئالدىنقى يىللار",
26
26
  nextDecade: "كېيىنكى يىللار",
27
27
  previousCentury: "ئالدىنقى ئەسىر",
@@ -16,10 +16,10 @@ var locale = {
16
16
  monthSelect: "Обрати місяць",
17
17
  yearSelect: "Обрати рік",
18
18
  decadeSelect: "Обрати десятиріччя",
19
- previousMonth: "Попередній місяць (PageUp)",
20
- nextMonth: "Наступний місяць (PageDown)",
21
- previousYear: "Попередній рік (Control + left)",
22
- nextYear: "Наступний рік (Control + right)",
19
+ previousMonth: "Попередній місяць",
20
+ nextMonth: "Наступний місяць",
21
+ previousYear: "Попередній рік",
22
+ nextYear: "Наступний рік",
23
23
  previousDecade: "Попереднє десятиріччя",
24
24
  nextDecade: "Наступне десятиріччя",
25
25
  previousCentury: "Попереднє століття",
@@ -17,10 +17,10 @@ var locale = {
17
17
  monthSelect: "ایک مہینہ کا انتخاب کریں",
18
18
  yearSelect: "ایک سال کا انتخاب کریں",
19
19
  decadeSelect: "ایک دہائی کا انتخاب کریں",
20
- previousMonth: "پچھلے مہینے (PageUp)",
21
- nextMonth: "اگلے مہینے (PageDown)",
22
- previousYear: "گزشتہ سال (Control + left)",
23
- nextYear: "اگلے سال (Control + right)",
20
+ previousMonth: "پچھلے مہینے",
21
+ nextMonth: "اگلے مہینے",
22
+ previousYear: "گزشتہ سال",
23
+ nextYear: "اگلے سال",
24
24
  previousDecade: "پچھلی دہائی",
25
25
  nextDecade: "اگلی دہائی",
26
26
  previousCentury: "پچھلی صدی",
@@ -17,10 +17,10 @@ var locale = {
17
17
  monthSelect: "Oyni tanlang",
18
18
  yearSelect: "Yilni tanlang",
19
19
  decadeSelect: "O'n yilni tanlang",
20
- previousMonth: "Oldingi oy (PageUp)",
21
- nextMonth: "Keyingi oy (PageDown)",
22
- previousYear: "O'tgan yili (Control + left)",
23
- nextYear: "Keyingi yil (Control + right)",
20
+ previousMonth: "Oldingi oy",
21
+ nextMonth: "Keyingi oy",
22
+ previousYear: "O'tgan yili",
23
+ nextYear: "Keyingi yil",
24
24
  previousDecade: "Oxirgi o'n yil",
25
25
  nextDecade: "Keyingi o'n yil",
26
26
  previousCentury: "O'tgan asr",
@@ -17,10 +17,10 @@ var locale = {
17
17
  monthSelect: "Chọn tháng",
18
18
  yearSelect: "Chọn năm",
19
19
  decadeSelect: "Chọn thập kỷ",
20
- previousMonth: "Tháng trước (PageUp)",
21
- nextMonth: "Tháng sau (PageDown)",
22
- previousYear: "Năm trước (Control + left)",
23
- nextYear: "Năm sau (Control + right)",
20
+ previousMonth: "Tháng trước",
21
+ nextMonth: "Tháng sau",
22
+ previousYear: "Năm trước",
23
+ nextYear: "Năm sau",
24
24
  previousDecade: "Thập kỷ trước",
25
25
  nextDecade: "Thập kỷ sau",
26
26
  previousCentury: "Thế kỷ trước",
@@ -14,13 +14,13 @@ var locale = {
14
14
  week: "周",
15
15
  month: "月",
16
16
  year: "年",
17
- previousMonth: "上个月 (翻页上键)",
18
- nextMonth: "下个月 (翻页下键)",
17
+ previousMonth: "上个月",
18
+ nextMonth: "下个月",
19
19
  monthSelect: "选择月份",
20
20
  yearSelect: "选择年份",
21
21
  decadeSelect: "选择年代",
22
- previousYear: "上一年 (Control键加左方向键)",
23
- nextYear: "下一年 (Control键加右方向键)",
22
+ previousYear: "上一年",
23
+ nextYear: "下一年",
24
24
  previousDecade: "上一年代",
25
25
  nextDecade: "下一年代",
26
26
  previousCentury: "上一世纪",
@@ -14,14 +14,14 @@ var locale = {
14
14
  week: "週",
15
15
  month: "月",
16
16
  year: "年",
17
- previousMonth: "上個月 (翻頁上鍵)",
18
- nextMonth: "下個月 (翻頁下鍵)",
17
+ previousMonth: "上個月",
18
+ nextMonth: "下個月",
19
19
  monthSelect: "選擇月份",
20
20
  yearSelect: "選擇年份",
21
21
  decadeSelect: "選擇年代",
22
22
  yearFormat: "YYYY年",
23
- previousYear: "上一年 (Control鍵加左方向鍵)",
24
- nextYear: "下一年 (Control鍵加右方向鍵)",
23
+ previousYear: "上一年",
24
+ nextYear: "下一年",
25
25
  previousDecade: "上一年代",
26
26
  nextDecade: "下一年代",
27
27
  previousCentury: "上一世紀",
@@ -11,4 +11,4 @@ export declare function getRowFormat(picker: InternalMode, locale: Locale, forma
11
11
  format: string;
12
12
  type?: "mask";
13
13
  } | import('../interface').FormatType<any> | import('../interface').FormatType<any>[] | undefined;
14
- export declare function getFromDate<DateType>(calendarValues: DateType[], activeIndexList: number[], activeIndex?: number): DateType | undefined;
14
+ export declare function getFromDate<DateType>(calendarValues: DateType[], triggeredFields: number[], activeIndex: number): DateType | undefined;
@@ -37,10 +37,9 @@ function getRowFormat(picker, locale, format) {
37
37
  default: return locale.fieldDateFormat;
38
38
  }
39
39
  }
40
- function getFromDate(calendarValues, activeIndexList, activeIndex) {
41
- const mergedActiveIndex = activeIndex !== void 0 ? activeIndex : activeIndexList[activeIndexList.length - 1];
42
- const firstValuedIndex = activeIndexList.find((index) => calendarValues[index]);
43
- return mergedActiveIndex !== firstValuedIndex ? calendarValues[firstValuedIndex] : void 0;
40
+ function getFromDate(calendarValues, triggeredFields, activeIndex) {
41
+ const firstValuedIndex = triggeredFields.find((index) => calendarValues[index]);
42
+ return activeIndex !== firstValuedIndex ? calendarValues[firstValuedIndex] : void 0;
44
43
  }
45
44
  //#endregion
46
45
  export { fillIndex, getFromDate, getRowFormat, leftPad, pickProps, toArray };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/picker",
3
3
  "type": "module",
4
- "version": "1.2.2",
4
+ "version": "1.3.0",
5
5
  "description": "picker ui component for vue",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -77,10 +77,10 @@
77
77
  }
78
78
  },
79
79
  "dependencies": {
80
- "@v-c/util": "^1.0.21",
80
+ "@v-c/overflow": "^1.1.1",
81
81
  "@v-c/resize-observer": "^1.1.3",
82
- "@v-c/trigger": "^1.0.18",
83
- "@v-c/overflow": "^1.1.1"
82
+ "@v-c/trigger": "^1.1.0",
83
+ "@v-c/util": "^1.1.0"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@types/luxon": "^3.7.2"
@@ -1,9 +0,0 @@
1
- import { ComputedRef, Ref } from 'vue';
2
- export type OperationType = 'input' | 'panel';
3
- export type NextActive<DateType> = (nextValue: [DateType | null | undefined, DateType | null | undefined]) => number | null;
4
- /**
5
- * When user first focus one input, any submit will trigger focus another one.
6
- * When second time focus one input, submit will not trigger focus again.
7
- * When click outside to close the panel, trigger event if it can trigger onChange.
8
- */
9
- export default function useRangeActive<DateType>(disabled: Ref<(boolean | undefined)[]> | ComputedRef<(boolean | undefined)[]>, empty?: Ref<boolean[]>, mergedOpen?: Ref<boolean | undefined>): readonly [Ref<boolean, boolean>, (nextFocus: boolean) => void, (type?: OperationType) => OperationType, Ref<number, number>, (index: number) => void, NextActive<DateType>, Ref<number[], number[]>, (index: number | null) => void, (index: number) => boolean];
@@ -1,59 +0,0 @@
1
- import useLockEffect from "./useLockEffect.js";
2
- import { computed, ref, watch } from "vue";
3
- //#region src/PickerInput/hooks/useRangeActive.ts
4
- /**
5
- * When user first focus one input, any submit will trigger focus another one.
6
- * When second time focus one input, submit will not trigger focus again.
7
- * When click outside to close the panel, trigger event if it can trigger onChange.
8
- */
9
- function useRangeActive(disabled, empty = ref([]), mergedOpen = ref(false)) {
10
- const activeIndex = ref(0);
11
- const focused = ref(false);
12
- const activeListRef = ref([]);
13
- const submitIndexRef = ref(null);
14
- const lastOperationRef = ref(null);
15
- const updateSubmitIndex = (index) => {
16
- submitIndexRef.value = index;
17
- };
18
- const hasActiveSubmitValue = (index) => {
19
- return submitIndexRef.value === index;
20
- };
21
- const triggerFocus = (nextFocus) => {
22
- focused.value = nextFocus;
23
- };
24
- const lastOperation = (type) => {
25
- if (type) lastOperationRef.value = type;
26
- return lastOperationRef.value;
27
- };
28
- const nextActiveIndex = (nextValue) => {
29
- const list = activeListRef.value;
30
- const filledActiveSet = new Set(list.filter((index) => nextValue?.[index] || empty.value[index]));
31
- const nextIndex = list[list.length - 1] === 0 ? 1 : 0;
32
- if (filledActiveSet.size >= 2 || disabled.value[nextIndex]) return null;
33
- return nextIndex;
34
- };
35
- useLockEffect(computed(() => focused.value || mergedOpen.value), () => {
36
- if (!focused.value) {
37
- activeListRef.value = [];
38
- updateSubmitIndex(null);
39
- }
40
- });
41
- watch([focused, activeIndex], () => {
42
- if (focused.value) activeListRef.value.push(activeIndex.value);
43
- });
44
- return [
45
- focused,
46
- triggerFocus,
47
- lastOperation,
48
- activeIndex,
49
- (index) => {
50
- activeIndex.value = index;
51
- },
52
- nextActiveIndex,
53
- activeListRef,
54
- updateSubmitIndex,
55
- hasActiveSubmitValue
56
- ];
57
- }
58
- //#endregion
59
- export { useRangeActive as default };