naive-ui 2.19.7 → 2.19.11

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 (208) hide show
  1. package/es/_internal/icons/Add.js +2 -3
  2. package/es/_internal/selection/src/Selection.d.ts +4 -1
  3. package/es/_internal/selection/src/Selection.js +3 -3
  4. package/es/anchor/src/AnchorAdapter.d.ts +5 -0
  5. package/es/anchor/src/BaseAnchor.d.ts +6 -1
  6. package/es/anchor/src/BaseAnchor.js +8 -3
  7. package/es/auto-complete/src/AutoComplete.d.ts +4 -0
  8. package/es/auto-complete/src/AutoComplete.js +9 -2
  9. package/es/calendar/src/Calendar.d.ts +1 -0
  10. package/es/cascader/src/Cascader.js +1 -1
  11. package/es/cascader/src/CascaderSelectMenu.d.ts +16 -7
  12. package/es/cascader/src/CascaderSelectMenu.js +23 -10
  13. package/es/cascader/src/utils.d.ts +2 -1
  14. package/es/cascader/src/utils.js +5 -2
  15. package/es/collapse/src/Collapse.d.ts +0 -1
  16. package/es/collapse/src/Collapse.js +2 -5
  17. package/es/collapse/src/CollapseItem.js +0 -2
  18. package/es/color-picker/src/ColorPicker.d.ts +4 -0
  19. package/es/color-picker/src/ColorPicker.js +5 -2
  20. package/es/color-picker/src/ColorPickerSwatches.d.ts +39 -0
  21. package/es/color-picker/src/ColorPickerSwatches.js +142 -0
  22. package/es/color-picker/src/styles/index.cssr.js +20 -0
  23. package/es/config-provider/src/ConfigProvider.d.ts +8 -1
  24. package/es/config-provider/src/ConfigProvider.js +8 -2
  25. package/es/config-provider/src/config.d.ts +8 -0
  26. package/es/config-provider/src/config.js +8 -0
  27. package/es/config-provider/src/internal-interface.d.ts +4 -0
  28. package/es/data-table/src/TableParts/Body.d.ts +8 -2
  29. package/es/data-table/src/TableParts/Body.js +4 -4
  30. package/es/data-table/src/TableParts/Header.d.ts +8 -2
  31. package/es/data-table/src/TableParts/Header.js +7 -4
  32. package/es/data-table/src/interface.d.ts +8 -2
  33. package/es/data-table/src/use-group-header.js +12 -8
  34. package/es/data-table/src/use-scroll.d.ts +11 -5
  35. package/es/data-table/src/use-scroll.js +37 -10
  36. package/es/date-picker/src/DatePicker.js +3 -0
  37. package/es/date-picker/src/panel/date.d.ts +1 -0
  38. package/es/date-picker/src/panel/daterange.d.ts +1 -0
  39. package/es/date-picker/src/panel/datetime.d.ts +1 -0
  40. package/es/date-picker/src/panel/datetimerange.d.ts +1 -0
  41. package/es/date-picker/src/panel/month.d.ts +1 -0
  42. package/es/date-picker/src/panel/use-calendar.d.ts +1 -0
  43. package/es/date-picker/src/panel/use-dual-calendar.d.ts +1 -0
  44. package/es/date-picker/src/panel/use-panel-common.d.ts +1 -0
  45. package/es/dialog/src/styles/index.cssr.js +1 -0
  46. package/es/ellipsis/src/Ellipsis.js +3 -1
  47. package/es/grid/src/Grid.d.ts +1 -1
  48. package/es/grid/src/Grid.js +4 -3
  49. package/es/input/src/Input.d.ts +1 -1
  50. package/es/input/src/Input.js +3 -8
  51. package/es/input/src/WordCount.js +22 -7
  52. package/es/input/src/interface.d.ts +1 -1
  53. package/es/input-number/index.d.ts +1 -0
  54. package/es/input-number/src/InputNumber.d.ts +2 -0
  55. package/es/input-number/src/InputNumber.js +10 -22
  56. package/es/input-number/src/interface.d.ts +4 -0
  57. package/es/locales/common/enUS.d.ts +1 -0
  58. package/es/locales/common/enUS.js +1 -0
  59. package/es/locales/common/jaJP.d.ts +3 -0
  60. package/es/locales/common/jaJP.js +93 -0
  61. package/es/locales/common/ruRU.js +1 -0
  62. package/es/locales/common/ukUA.js +1 -0
  63. package/es/locales/common/zhCN.js +1 -0
  64. package/es/locales/date/jaJP.d.ts +3 -0
  65. package/es/locales/date/jaJP.js +6 -0
  66. package/es/locales/index.d.ts +2 -0
  67. package/es/locales/index.js +2 -0
  68. package/es/menu/src/Menu.d.ts +8 -1
  69. package/es/menu/src/Menu.js +4 -2
  70. package/es/menu/src/MenuOption.d.ts +2 -0
  71. package/es/menu/src/MenuOptionContent.d.ts +2 -0
  72. package/es/menu/src/Submenu.d.ts +2 -0
  73. package/es/menu/src/Submenu.js +3 -2
  74. package/es/rate/src/Rate.d.ts +2 -2
  75. package/es/scrollbar/src/ScrollBar.d.ts +14 -4
  76. package/es/scrollbar/src/ScrollBar.js +13 -3
  77. package/es/select/src/Select.d.ts +5 -1
  78. package/es/select/src/Select.js +2 -2
  79. package/es/table/src/Table.d.ts +2 -8
  80. package/es/table/src/Table.js +1 -4
  81. package/es/tabs/src/Tab.js +18 -2
  82. package/es/tabs/src/Tabs.d.ts +5 -1
  83. package/es/tabs/src/Tabs.js +4 -1
  84. package/es/tabs/src/interface.d.ts +6 -0
  85. package/es/time-picker/src/Panel.d.ts +30 -8
  86. package/es/time-picker/src/Panel.js +101 -33
  87. package/es/time-picker/src/PanelCol.d.ts +6 -9
  88. package/es/time-picker/src/PanelCol.js +7 -9
  89. package/es/time-picker/src/TimePicker.d.ts +21 -16
  90. package/es/time-picker/src/TimePicker.js +63 -36
  91. package/es/time-picker/src/interface.d.ts +7 -0
  92. package/es/time-picker/src/utils.d.ts +4 -1
  93. package/es/time-picker/src/utils.js +67 -4
  94. package/es/tree/src/Tree.d.ts +2 -2
  95. package/es/upload/src/Upload.d.ts +15 -11
  96. package/es/upload/src/Upload.js +16 -7
  97. package/es/upload/src/UploadFile.js +1 -1
  98. package/es/upload/src/UploadFileList.js +1 -3
  99. package/es/upload/src/UploadTrigger.js +13 -5
  100. package/es/upload/src/interface.d.ts +1 -1
  101. package/es/upload/src/styles/index.cssr.js +3 -1
  102. package/es/version.d.ts +1 -1
  103. package/es/version.js +1 -1
  104. package/lib/_internal/icons/Add.js +2 -3
  105. package/lib/_internal/selection/src/Selection.d.ts +4 -1
  106. package/lib/_internal/selection/src/Selection.js +3 -3
  107. package/lib/anchor/src/AnchorAdapter.d.ts +5 -0
  108. package/lib/anchor/src/BaseAnchor.d.ts +6 -1
  109. package/lib/anchor/src/BaseAnchor.js +7 -2
  110. package/lib/auto-complete/src/AutoComplete.d.ts +4 -0
  111. package/lib/auto-complete/src/AutoComplete.js +9 -2
  112. package/lib/calendar/src/Calendar.d.ts +1 -0
  113. package/lib/cascader/src/Cascader.js +1 -1
  114. package/lib/cascader/src/CascaderSelectMenu.d.ts +16 -7
  115. package/lib/cascader/src/CascaderSelectMenu.js +23 -10
  116. package/lib/cascader/src/utils.d.ts +2 -1
  117. package/lib/cascader/src/utils.js +5 -2
  118. package/lib/collapse/src/Collapse.d.ts +0 -1
  119. package/lib/collapse/src/Collapse.js +2 -5
  120. package/lib/collapse/src/CollapseItem.js +0 -2
  121. package/lib/color-picker/src/ColorPicker.d.ts +4 -0
  122. package/lib/color-picker/src/ColorPicker.js +5 -2
  123. package/lib/color-picker/src/ColorPickerSwatches.d.ts +39 -0
  124. package/lib/color-picker/src/ColorPickerSwatches.js +144 -0
  125. package/lib/color-picker/src/styles/index.cssr.js +20 -0
  126. package/lib/config-provider/src/ConfigProvider.d.ts +8 -1
  127. package/lib/config-provider/src/ConfigProvider.js +8 -2
  128. package/lib/config-provider/src/config.d.ts +8 -0
  129. package/lib/config-provider/src/config.js +11 -0
  130. package/lib/config-provider/src/internal-interface.d.ts +4 -0
  131. package/lib/data-table/src/TableParts/Body.d.ts +8 -2
  132. package/lib/data-table/src/TableParts/Body.js +4 -4
  133. package/lib/data-table/src/TableParts/Header.d.ts +8 -2
  134. package/lib/data-table/src/TableParts/Header.js +7 -4
  135. package/lib/data-table/src/interface.d.ts +8 -2
  136. package/lib/data-table/src/use-group-header.js +12 -8
  137. package/lib/data-table/src/use-scroll.d.ts +11 -5
  138. package/lib/data-table/src/use-scroll.js +37 -10
  139. package/lib/date-picker/src/DatePicker.js +3 -0
  140. package/lib/date-picker/src/panel/date.d.ts +1 -0
  141. package/lib/date-picker/src/panel/daterange.d.ts +1 -0
  142. package/lib/date-picker/src/panel/datetime.d.ts +1 -0
  143. package/lib/date-picker/src/panel/datetimerange.d.ts +1 -0
  144. package/lib/date-picker/src/panel/month.d.ts +1 -0
  145. package/lib/date-picker/src/panel/use-calendar.d.ts +1 -0
  146. package/lib/date-picker/src/panel/use-dual-calendar.d.ts +1 -0
  147. package/lib/date-picker/src/panel/use-panel-common.d.ts +1 -0
  148. package/lib/dialog/src/styles/index.cssr.js +1 -0
  149. package/lib/ellipsis/src/Ellipsis.js +3 -1
  150. package/lib/grid/src/Grid.d.ts +1 -1
  151. package/lib/grid/src/Grid.js +4 -3
  152. package/lib/input/src/Input.d.ts +1 -1
  153. package/lib/input/src/Input.js +2 -7
  154. package/lib/input/src/WordCount.js +21 -6
  155. package/lib/input/src/interface.d.ts +1 -1
  156. package/lib/input-number/index.d.ts +1 -0
  157. package/lib/input-number/src/InputNumber.d.ts +2 -0
  158. package/lib/input-number/src/InputNumber.js +10 -22
  159. package/lib/input-number/src/interface.d.ts +4 -0
  160. package/lib/locales/common/enUS.d.ts +1 -0
  161. package/lib/locales/common/enUS.js +1 -0
  162. package/lib/locales/common/jaJP.d.ts +3 -0
  163. package/lib/locales/common/jaJP.js +95 -0
  164. package/lib/locales/common/ruRU.js +1 -0
  165. package/lib/locales/common/ukUA.js +1 -0
  166. package/lib/locales/common/zhCN.js +1 -0
  167. package/lib/locales/date/jaJP.d.ts +3 -0
  168. package/lib/locales/date/jaJP.js +8 -0
  169. package/lib/locales/index.d.ts +2 -0
  170. package/lib/locales/index.js +5 -1
  171. package/lib/menu/src/Menu.d.ts +8 -1
  172. package/lib/menu/src/Menu.js +4 -2
  173. package/lib/menu/src/MenuOption.d.ts +2 -0
  174. package/lib/menu/src/MenuOptionContent.d.ts +2 -0
  175. package/lib/menu/src/Submenu.d.ts +2 -0
  176. package/lib/menu/src/Submenu.js +3 -2
  177. package/lib/rate/src/Rate.d.ts +2 -2
  178. package/lib/scrollbar/src/ScrollBar.d.ts +14 -4
  179. package/lib/scrollbar/src/ScrollBar.js +12 -2
  180. package/lib/select/src/Select.d.ts +5 -1
  181. package/lib/select/src/Select.js +2 -2
  182. package/lib/table/src/Table.d.ts +2 -8
  183. package/lib/table/src/Table.js +1 -4
  184. package/lib/tabs/src/Tab.js +18 -2
  185. package/lib/tabs/src/Tabs.d.ts +5 -1
  186. package/lib/tabs/src/Tabs.js +4 -1
  187. package/lib/tabs/src/interface.d.ts +6 -0
  188. package/lib/time-picker/src/Panel.d.ts +30 -8
  189. package/lib/time-picker/src/Panel.js +100 -32
  190. package/lib/time-picker/src/PanelCol.d.ts +6 -9
  191. package/lib/time-picker/src/PanelCol.js +7 -9
  192. package/lib/time-picker/src/TimePicker.d.ts +21 -16
  193. package/lib/time-picker/src/TimePicker.js +61 -34
  194. package/lib/time-picker/src/interface.d.ts +7 -0
  195. package/lib/time-picker/src/utils.d.ts +4 -1
  196. package/lib/time-picker/src/utils.js +69 -5
  197. package/lib/tree/src/Tree.d.ts +2 -2
  198. package/lib/upload/src/Upload.d.ts +15 -11
  199. package/lib/upload/src/Upload.js +16 -7
  200. package/lib/upload/src/UploadFile.js +1 -1
  201. package/lib/upload/src/UploadFileList.js +1 -3
  202. package/lib/upload/src/UploadTrigger.js +13 -5
  203. package/lib/upload/src/interface.d.ts +1 -1
  204. package/lib/upload/src/styles/index.cssr.js +3 -1
  205. package/lib/version.d.ts +1 -1
  206. package/lib/version.js +1 -1
  207. package/package.json +7 -4
  208. package/web-types.json +68 -1
@@ -14,21 +14,19 @@ export default defineComponent({
14
14
  type: Number,
15
15
  default: null
16
16
  },
17
+ // It should be required but vue's type seems to have bugs
17
18
  onItemClick: Function
18
19
  },
19
20
  render() {
20
21
  const { activeValue, onItemClick, clsPrefix } = this;
21
22
  return this.data.map((item) => {
22
- const { value, disabled } = item;
23
- const numValue = Number(value);
24
- const active = activeValue === numValue;
25
- return (h("div", { key: value, "data-active": active ? '' : null, class: [
23
+ const { label, disabled, value } = item;
24
+ const active = activeValue === value;
25
+ return (h("div", { key: label, "data-active": active ? '' : null, class: [
26
26
  `${clsPrefix}-time-picker-col__item`,
27
- {
28
- [`${clsPrefix}-time-picker-col__item--active`]: active,
29
- [`${clsPrefix}-time-picker-col__item--disabled`]: disabled
30
- }
31
- ], onClick: onItemClick && !disabled ? () => onItemClick(numValue) : undefined }, value));
27
+ active && `${clsPrefix}-time-picker-col__item--active`,
28
+ disabled && `${clsPrefix}-time-picker-col__item--disabled`
29
+ ], onClick: onItemClick && !disabled ? () => onItemClick(value) : undefined }, label));
32
30
  });
33
31
  }
34
32
  });
@@ -1,6 +1,6 @@
1
1
  import { PropType } from 'vue';
2
2
  import { MaybeArray, ExtractPublicPropTypes } from '../../_utils';
3
- import { IsHourDisabled, IsMinuteDisabled, IsSecondDisabled, OnUpdateValue, Size } from './interface';
3
+ import { IsHourDisabled, IsMinuteDisabled, IsSecondDisabled, ItemValue, OnUpdateValue, Size } from './interface';
4
4
  declare const timePickerProps: {
5
5
  to: {
6
6
  type: PropType<string | boolean | HTMLElement>;
@@ -51,11 +51,6 @@ declare const timePickerProps: {
51
51
  type: PropType<boolean | undefined>;
52
52
  default: undefined;
53
53
  };
54
- onChange: {
55
- type: PropType<MaybeArray<OnUpdateValue> | undefined>;
56
- validator: () => boolean;
57
- default: undefined;
58
- };
59
54
  hours: {
60
55
  type: PropType<MaybeArray<number>>;
61
56
  validator: (value: MaybeArray<number>) => boolean;
@@ -68,6 +63,8 @@ declare const timePickerProps: {
68
63
  type: PropType<MaybeArray<number>>;
69
64
  validator: (value: MaybeArray<number>) => boolean;
70
65
  };
66
+ use12Hours: BooleanConstructor;
67
+ onChange: PropType<MaybeArray<OnUpdateValue> | undefined>;
71
68
  theme: PropType<import("../../_mixins").Theme<"TimePicker", {
72
69
  panelColor: string;
73
70
  panelBoxShadow: string;
@@ -951,11 +948,6 @@ declare const _default: import("vue").DefineComponent<{
951
948
  type: PropType<boolean | undefined>;
952
949
  default: undefined;
953
950
  };
954
- onChange: {
955
- type: PropType<MaybeArray<OnUpdateValue> | undefined>;
956
- validator: () => boolean;
957
- default: undefined;
958
- };
959
951
  hours: {
960
952
  type: PropType<MaybeArray<number>>;
961
953
  validator: (value: MaybeArray<number>) => boolean;
@@ -968,6 +960,8 @@ declare const _default: import("vue").DefineComponent<{
968
960
  type: PropType<MaybeArray<number>>;
969
961
  validator: (value: MaybeArray<number>) => boolean;
970
962
  };
963
+ use12Hours: BooleanConstructor;
964
+ onChange: PropType<MaybeArray<OnUpdateValue> | undefined>;
971
965
  theme: PropType<import("../../_mixins").Theme<"TimePicker", {
972
966
  panelColor: string;
973
967
  panelBoxShadow: string;
@@ -1839,6 +1833,13 @@ declare const _default: import("vue").DefineComponent<{
1839
1833
  contentRef: HTMLElement | null;
1840
1834
  containerScrollTop: number;
1841
1835
  } | undefined;
1836
+ amPmScrollRef?: {
1837
+ scrollTo: import("../../_internal/scrollbar/src/ScrollBar").ScrollTo;
1838
+ sync: () => void;
1839
+ containerRef: HTMLElement | null;
1840
+ contentRef: HTMLElement | null;
1841
+ containerScrollTop: number;
1842
+ } | undefined;
1842
1843
  } | null>;
1843
1844
  adjustedTo: import("vue").ComputedRef<string | HTMLElement>;
1844
1845
  mergedShow: import("vue").ComputedRef<boolean>;
@@ -1861,6 +1862,7 @@ declare const _default: import("vue").DefineComponent<{
1861
1862
  hourValue: import("vue").ComputedRef<number | null>;
1862
1863
  minuteValue: import("vue").ComputedRef<number | null>;
1863
1864
  secondValue: import("vue").ComputedRef<number | null>;
1865
+ amPmValue: import("vue").ComputedRef<"am" | "pm" | null>;
1864
1866
  handleTimeInputFocus: (e: FocusEvent) => void;
1865
1867
  handleTimeInputBlur: (e: FocusEvent) => void;
1866
1868
  handleNowClick: () => void;
@@ -1871,9 +1873,10 @@ declare const _default: import("vue").DefineComponent<{
1871
1873
  handleClickOutside: (e: MouseEvent) => void;
1872
1874
  handleTimeInputActivate: () => void;
1873
1875
  handleTimeInputDeactivate: () => void;
1874
- handleHourClick: (hour: number) => void;
1875
- handleMinuteClick: (minute: number) => void;
1876
- handleSecondClick: (second: number) => void;
1876
+ handleHourClick: (hour: ItemValue) => void;
1877
+ handleMinuteClick: (minute: ItemValue) => void;
1878
+ handleSecondClick: (second: ItemValue) => void;
1879
+ handleAmPmClick: (amPm: ItemValue) => void;
1877
1880
  handleTimeInputClear: (e: MouseEvent) => void;
1878
1881
  handleFocusDetectorFocus: () => void;
1879
1882
  handleMenuKeyDown: (e: KeyboardEvent) => void;
@@ -2318,10 +2321,11 @@ declare const _default: import("vue").DefineComponent<{
2318
2321
  showIcon?: unknown;
2319
2322
  disabled?: unknown;
2320
2323
  show?: unknown;
2321
- onChange?: unknown;
2322
2324
  hours?: unknown;
2323
2325
  minutes?: unknown;
2324
2326
  seconds?: unknown;
2327
+ use12Hours?: unknown;
2328
+ onChange?: unknown;
2325
2329
  theme?: unknown;
2326
2330
  themeOverrides?: unknown;
2327
2331
  builtinThemeOverrides?: unknown;
@@ -2333,6 +2337,7 @@ declare const _default: import("vue").DefineComponent<{
2333
2337
  stateful: boolean;
2334
2338
  showIcon: boolean;
2335
2339
  inputReadonly: boolean;
2340
+ use12Hours: boolean;
2336
2341
  } & {
2337
2342
  value?: number | null | undefined;
2338
2343
  size?: Size | undefined;
@@ -3187,7 +3192,6 @@ declare const _default: import("vue").DefineComponent<{
3187
3192
  }>, {
3188
3193
  show: boolean | undefined;
3189
3194
  disabled: boolean | undefined;
3190
- onChange: MaybeArray<OnUpdateValue> | undefined;
3191
3195
  format: string;
3192
3196
  to: string | boolean | HTMLElement;
3193
3197
  placement: string;
@@ -3197,5 +3201,6 @@ declare const _default: import("vue").DefineComponent<{
3197
3201
  stateful: boolean;
3198
3202
  showIcon: boolean;
3199
3203
  inputReadonly: boolean;
3204
+ use12Hours: boolean;
3200
3205
  }>;
3201
3206
  export default _default;
@@ -1,20 +1,20 @@
1
- import { h, ref, toRef, defineComponent, computed, withDirectives, Transition, provide, nextTick, watch } from 'vue';
1
+ import { h, ref, toRef, defineComponent, computed, withDirectives, Transition, provide, nextTick, watch, watchEffect } from 'vue';
2
2
  import { useIsMounted, useKeyboard, useMergedState } from 'vooks';
3
3
  import { VBinder, VTarget, VFollower } from 'vueuc';
4
4
  import { clickoutside } from 'vdirs';
5
+ import { happensIn } from 'seemly';
5
6
  import { isValid, startOfSecond, startOfMinute, startOfHour, format, set, setHours, setMinutes, setSeconds, getTime, getMinutes, getHours, getSeconds } from 'date-fns';
6
7
  import { strictParse } from '../../date-picker/src/utils';
7
8
  import { TimeIcon } from '../../_internal/icons';
8
9
  import { NInput } from '../../input';
9
10
  import { NBaseIcon } from '../../_internal';
10
11
  import { useConfig, useTheme, useLocale, useFormItem } from '../../_mixins';
11
- import { warn, call, useAdjustedTo } from '../../_utils';
12
+ import { call, useAdjustedTo, warnOnce } from '../../_utils';
12
13
  import { timePickerLight } from '../styles';
13
14
  import Panel from './Panel';
14
- import style from './styles/index.cssr';
15
15
  import { timePickerInjectionKey } from './interface';
16
- import { happensIn } from 'seemly';
17
16
  import { findSimilarTime, isTimeInStep } from './utils';
17
+ import style from './styles/index.cssr';
18
18
  // validate hours, minutes, seconds prop
19
19
  function validateUnits(value, max) {
20
20
  if (value === undefined) {
@@ -53,17 +53,6 @@ const timePickerProps = Object.assign(Object.assign({}, useTheme.props), { to: u
53
53
  }, show: {
54
54
  type: Boolean,
55
55
  default: undefined
56
- },
57
- // deprecated
58
- onChange: {
59
- type: [Function, Array],
60
- validator: () => {
61
- if (process.env.NODE_ENV !== 'production') {
62
- warn('time-picker', '`on-change` is deprecated, please use `on-update:value` instead.');
63
- }
64
- return true;
65
- },
66
- default: undefined
67
56
  }, hours: {
68
57
  type: [Number, Array],
69
58
  validator: (value) => validateUnits(value, 23)
@@ -73,11 +62,20 @@ const timePickerProps = Object.assign(Object.assign({}, useTheme.props), { to: u
73
62
  }, seconds: {
74
63
  type: [Number, Array],
75
64
  validator: (value) => validateUnits(value, 59)
76
- } });
65
+ }, use12Hours: Boolean,
66
+ // deprecated
67
+ onChange: [Function, Array] });
77
68
  export default defineComponent({
78
69
  name: 'TimePicker',
79
70
  props: timePickerProps,
80
71
  setup(props) {
72
+ if (process.env.NODE_ENV !== 'production') {
73
+ watchEffect(() => {
74
+ if (props.onChange !== undefined) {
75
+ warnOnce('time-picker', '`on-change` is deprecated, please use `on-update:value` instead.');
76
+ }
77
+ });
78
+ }
81
79
  const { mergedBorderedRef, mergedClsPrefixRef, namespaceRef } = useConfig(props);
82
80
  const { localeRef, dateLocaleRef } = useLocale('TimePicker');
83
81
  const formItem = useFormItem(props);
@@ -170,6 +168,12 @@ export default defineComponent({
170
168
  const mergedAttrSizeRef = computed(() => {
171
169
  return props.format.length + 4;
172
170
  });
171
+ const amPmValueRef = computed(() => {
172
+ const { value } = mergedValueRef;
173
+ if (value === null)
174
+ return null;
175
+ return getHours(value) < 12 ? 'am' : 'pm';
176
+ });
173
177
  const hourValueRef = computed(() => {
174
178
  const { value } = mergedValueRef;
175
179
  if (value === null)
@@ -257,6 +261,8 @@ export default defineComponent({
257
261
  }
258
262
  }
259
263
  function handleHourClick(hour) {
264
+ if (typeof hour === 'string')
265
+ return;
260
266
  if (mergedValueRef.value === null) {
261
267
  doChange(getTime(setHours(startOfHour(new Date()), hour)));
262
268
  }
@@ -265,6 +271,8 @@ export default defineComponent({
265
271
  }
266
272
  }
267
273
  function handleMinuteClick(minute) {
274
+ if (typeof minute === 'string')
275
+ return;
268
276
  if (mergedValueRef.value === null) {
269
277
  doChange(getTime(setMinutes(startOfMinute(new Date()), minute)));
270
278
  }
@@ -273,6 +281,8 @@ export default defineComponent({
273
281
  }
274
282
  }
275
283
  function handleSecondClick(second) {
284
+ if (typeof second === 'string')
285
+ return;
276
286
  if (mergedValueRef.value === null) {
277
287
  doChange(getTime(setSeconds(startOfSecond(new Date()), second)));
278
288
  }
@@ -280,6 +290,29 @@ export default defineComponent({
280
290
  doChange(getTime(setSeconds(mergedValueRef.value, second)));
281
291
  }
282
292
  }
293
+ function handleAmPmClick(amPm) {
294
+ const { value: mergedValue } = mergedValueRef;
295
+ if (mergedValue === null) {
296
+ const now = new Date();
297
+ const hours = getHours(now);
298
+ if (amPm === 'pm' && hours < 12) {
299
+ doChange(getTime(setHours(now, hours + 12)));
300
+ }
301
+ else if (amPm === 'am' && hours >= 12) {
302
+ doChange(getTime(setHours(now, hours - 12)));
303
+ }
304
+ doChange(getTime(now));
305
+ }
306
+ else {
307
+ const hours = getHours(mergedValue);
308
+ if (amPm === 'pm' && hours < 12) {
309
+ doChange(getTime(setHours(mergedValue, hours + 12)));
310
+ }
311
+ else if (amPm === 'am' && hours >= 12) {
312
+ doChange(getTime(setHours(mergedValue, hours - 12)));
313
+ }
314
+ }
315
+ }
283
316
  function deriveInputValue(time) {
284
317
  if (time === undefined)
285
318
  time = mergedValueRef.value;
@@ -324,28 +357,20 @@ export default defineComponent({
324
357
  });
325
358
  }
326
359
  function scrollTimer() {
327
- var _a, _b, _c;
328
360
  if (!panelInstRef.value)
329
361
  return;
330
- const { hourScrollRef, minuteScrollRef, secondScrollRef } = panelInstRef.value;
331
- if (hourScrollRef) {
332
- const hour = (_a = hourScrollRef.contentRef) === null || _a === void 0 ? void 0 : _a.querySelector('[data-active]');
333
- if (hour) {
334
- hourScrollRef.scrollTo({ top: hour.offsetTop });
335
- }
336
- }
337
- if (minuteScrollRef) {
338
- const minute = (_b = minuteScrollRef.contentRef) === null || _b === void 0 ? void 0 : _b.querySelector('[data-active]');
339
- if (minute) {
340
- minuteScrollRef.scrollTo({ top: minute.offsetTop });
341
- }
342
- }
343
- if (secondScrollRef) {
344
- const second = (_c = secondScrollRef.contentRef) === null || _c === void 0 ? void 0 : _c.querySelector('[data-active]');
345
- if (second) {
346
- secondScrollRef.scrollTo({ top: second.offsetTop });
362
+ const { hourScrollRef, minuteScrollRef, secondScrollRef, amPmScrollRef } = panelInstRef.value;
363
+ [hourScrollRef, minuteScrollRef, secondScrollRef, amPmScrollRef].forEach((itemScrollRef) => {
364
+ var _a;
365
+ if (!itemScrollRef)
366
+ return;
367
+ const activeItemEl = (_a = itemScrollRef.contentRef) === null || _a === void 0 ? void 0 : _a.querySelector('[data-active]');
368
+ if (activeItemEl) {
369
+ itemScrollRef.scrollTo({
370
+ top: activeItemEl.offsetTop
371
+ });
347
372
  }
348
- }
373
+ });
349
374
  }
350
375
  function doUpdateShow(value) {
351
376
  uncontrolledShowRef.value = value;
@@ -475,6 +500,7 @@ export default defineComponent({
475
500
  hourValue: hourValueRef,
476
501
  minuteValue: minuteValueRef,
477
502
  secondValue: secondValueRef,
503
+ amPmValue: amPmValueRef,
478
504
  handleTimeInputFocus,
479
505
  handleTimeInputBlur,
480
506
  handleNowClick,
@@ -488,6 +514,7 @@ export default defineComponent({
488
514
  handleHourClick,
489
515
  handleMinuteClick,
490
516
  handleSecondClick,
517
+ handleAmPmClick,
491
518
  handleTimeInputClear,
492
519
  handleFocusDetectorFocus,
493
520
  handleMenuKeyDown,
@@ -539,7 +566,7 @@ export default defineComponent({
539
566
  h(VFollower, { teleportDisabled: this.adjustedTo === useAdjustedTo.tdkey, show: this.mergedShow, to: this.adjustedTo, containerClass: this.namespace, placement: "bottom-start" }, {
540
567
  default: () => (h(Transition, { name: "fade-in-scale-up-transition", appear: this.isMounted }, {
541
568
  default: () => this.mergedShow
542
- ? withDirectives(h(Panel, { ref: "panelInstRef", actions: this.actions, style: this.cssVars, seconds: this.seconds, minutes: this.minutes, hours: this.hours, transitionDisabled: this.transitionDisabled, hourValue: this.hourValue, showHour: this.hourInFormat, isHourInvalid: this.isHourInvalid, isHourDisabled: this.isHourDisabled, minuteValue: this.minuteValue, showMinute: this.minuteInFormat, isMinuteInvalid: this.isMinuteInvalid, isMinuteDisabled: this.isMinuteDisabled, secondValue: this.secondValue, showSecond: this.secondInFormat, isSecondInvalid: this.isSecondInvalid, isSecondDisabled: this.isSecondDisabled, isValueInvalid: this.isValueInvalid, nowText: this.localizedNow, confirmText: this.localizedPositiveText, onFocusout: this.handleMenuFocusOut, onKeydown: this.handleMenuKeyDown, onHourClick: this.handleHourClick, onMinuteClick: this.handleMinuteClick, onSecondClick: this.handleSecondClick, onNowClick: this.handleNowClick, onConfirmClick: this.handleConfirmClick, onFocusDetectorFocus: this.handleFocusDetectorFocus }), [[clickoutside, this.handleClickOutside]])
569
+ ? withDirectives(h(Panel, { ref: "panelInstRef", actions: this.actions, style: this.cssVars, seconds: this.seconds, minutes: this.minutes, hours: this.hours, transitionDisabled: this.transitionDisabled, hourValue: this.hourValue, showHour: this.hourInFormat, isHourInvalid: this.isHourInvalid, isHourDisabled: this.isHourDisabled, minuteValue: this.minuteValue, showMinute: this.minuteInFormat, isMinuteInvalid: this.isMinuteInvalid, isMinuteDisabled: this.isMinuteDisabled, secondValue: this.secondValue, amPmValue: this.amPmValue, showSecond: this.secondInFormat, isSecondInvalid: this.isSecondInvalid, isSecondDisabled: this.isSecondDisabled, isValueInvalid: this.isValueInvalid, nowText: this.localizedNow, confirmText: this.localizedPositiveText, use12Hours: this.use12Hours, onFocusout: this.handleMenuFocusOut, onKeydown: this.handleMenuKeyDown, onHourClick: this.handleHourClick, onMinuteClick: this.handleMinuteClick, onSecondClick: this.handleSecondClick, onAmPmClick: this.handleAmPmClick, onNowClick: this.handleNowClick, onConfirmClick: this.handleConfirmClick, onFocusDetectorFocus: this.handleFocusDetectorFocus }), [[clickoutside, this.handleClickOutside]])
543
570
  : null
544
571
  }))
545
572
  })
@@ -2,6 +2,12 @@ import { InjectionKey, Ref } from 'vue';
2
2
  import { ScrollbarInst } from '../../_internal';
3
3
  import type { MergedTheme } from '../../_mixins';
4
4
  import type { TimePickerTheme } from '../styles';
5
+ export declare type ItemValue = number | 'am' | 'pm';
6
+ export interface Item {
7
+ label: string;
8
+ value: ItemValue;
9
+ disabled: boolean;
10
+ }
5
11
  export interface TimePickerInjection {
6
12
  mergedThemeRef: Ref<MergedTheme<TimePickerTheme>>;
7
13
  mergedClsPrefixRef: Ref<string>;
@@ -12,6 +18,7 @@ export interface PanelRef {
12
18
  hourScrollRef?: ScrollbarInst;
13
19
  minuteScrollRef?: ScrollbarInst;
14
20
  secondScrollRef?: ScrollbarInst;
21
+ amPmScrollRef?: ScrollbarInst;
15
22
  }
16
23
  export declare type OnUpdateValue = <T extends number & (number | null)>(value: T) => void;
17
24
  export declare type OnUpdateValueImpl = (value: number | null) => void;
@@ -1,11 +1,14 @@
1
1
  import { MaybeArray } from '../../_utils';
2
2
  export declare const time: {
3
+ amHours: string[];
4
+ pmHours: string[];
3
5
  hours: string[];
4
6
  minutes: string[];
5
7
  seconds: string[];
6
8
  period: string[];
7
9
  };
8
10
  export declare function getFixValue(value: number): string;
9
- export declare function getTimeUnits(defaultValue: string[], stepOrList: MaybeArray<number> | undefined): string[];
11
+ export declare function getTimeUnits(defaultValue: string[], stepOrList: MaybeArray<number> | undefined, isHourWithAmPm?: 'am' | 'pm'): string[];
10
12
  export declare function isTimeInStep(value: number, type: 'hours' | 'minutes' | 'seconds', stepOrList: MaybeArray<number> | undefined): boolean;
11
13
  export declare function findSimilarTime(value: number, type: 'hours' | 'minutes' | 'seconds', stepOrList: MaybeArray<number> | undefined): number;
14
+ export declare function getAmPm(value: number): 'am' | 'pm';
@@ -1,5 +1,34 @@
1
+ import { getHours } from 'date-fns';
1
2
  import { throwError } from '../../_utils';
2
3
  export const time = {
4
+ amHours: [
5
+ '00',
6
+ '01',
7
+ '02',
8
+ '03',
9
+ '04',
10
+ '05',
11
+ '06',
12
+ '07',
13
+ '08',
14
+ '09',
15
+ '10',
16
+ '11'
17
+ ],
18
+ pmHours: [
19
+ '12',
20
+ '01',
21
+ '02',
22
+ '03',
23
+ '04',
24
+ '05',
25
+ '06',
26
+ '07',
27
+ '08',
28
+ '09',
29
+ '10',
30
+ '11'
31
+ ],
3
32
  hours: [
4
33
  '00',
5
34
  '01',
@@ -155,15 +184,46 @@ export const time = {
155
184
  export function getFixValue(value) {
156
185
  return `00${value}`.slice(-2);
157
186
  }
158
- export function getTimeUnits(defaultValue, stepOrList) {
187
+ // TODO: refactor the logic, it's somehow a patch logic
188
+ export function getTimeUnits(defaultValue, stepOrList, isHourWithAmPm) {
159
189
  if (Array.isArray(stepOrList)) {
160
- return stepOrList.map((v) => Math.floor(v)).map((v) => getFixValue(v));
190
+ return (isHourWithAmPm === 'am'
191
+ ? stepOrList.filter((v) => v < 12)
192
+ : isHourWithAmPm === 'pm'
193
+ ? stepOrList.filter((v) => v >= 12).map((v) => (v === 12 ? 12 : v - 12))
194
+ : stepOrList).map((v) => getFixValue(v));
161
195
  }
162
196
  else if (typeof stepOrList === 'number') {
163
- return defaultValue.filter((hour) => Number(hour) % stepOrList === 0);
197
+ if (isHourWithAmPm === 'am') {
198
+ return defaultValue.filter((hour) => {
199
+ const hourAsNumber = Number(hour);
200
+ return hourAsNumber < 12 && hourAsNumber % stepOrList === 0;
201
+ });
202
+ }
203
+ else if (isHourWithAmPm === 'pm') {
204
+ return defaultValue
205
+ .filter((hour) => {
206
+ const hourAsNumber = Number(hour);
207
+ return hourAsNumber >= 12 && hourAsNumber % stepOrList === 0;
208
+ })
209
+ .map((hour) => {
210
+ const hourAsNumber = Number(hour);
211
+ return getFixValue(hourAsNumber === 12 ? 12 : hourAsNumber - 12);
212
+ });
213
+ }
214
+ return defaultValue.filter((hour) => {
215
+ return Number(hour) % stepOrList === 0;
216
+ });
164
217
  }
165
218
  else {
166
- return defaultValue;
219
+ return isHourWithAmPm === 'am'
220
+ ? defaultValue.filter((hour) => Number(hour) < 12)
221
+ : isHourWithAmPm === 'pm'
222
+ ? defaultValue
223
+ .map((hour) => Number(hour))
224
+ .filter((hour) => Number(hour) >= 12)
225
+ .map((v) => getFixValue(v === 12 ? 12 : v - 12))
226
+ : defaultValue;
167
227
  }
168
228
  }
169
229
  export function isTimeInStep(value, type, stepOrList) {
@@ -201,3 +261,6 @@ export function findSimilarTime(value, type, stepOrList) {
201
261
  }
202
262
  return upperBound - value > value - lowerBound ? lowerBound : upperBound;
203
263
  }
264
+ export function getAmPm(value) {
265
+ return getHours(value) < 12 ? 'am' : 'pm';
266
+ }
@@ -1043,12 +1043,12 @@ declare const _default: import("vue").DefineComponent<{
1043
1043
  indent: number;
1044
1044
  labelField: string;
1045
1045
  childrenField: string;
1046
+ internalScrollable: boolean;
1046
1047
  checkStrategy: CheckStrategy;
1047
1048
  leafOnly: boolean;
1048
1049
  defaultExpandAll: boolean;
1049
1050
  defaultExpandedKeys: Key[];
1050
1051
  cancelable: boolean;
1051
- internalScrollable: boolean;
1052
1052
  blockLine: boolean;
1053
1053
  selectable: boolean;
1054
1054
  internalUnifySelectCheck: boolean;
@@ -1238,12 +1238,12 @@ declare const _default: import("vue").DefineComponent<{
1238
1238
  indent: number;
1239
1239
  labelField: string;
1240
1240
  childrenField: string;
1241
+ internalScrollable: boolean;
1241
1242
  checkStrategy: CheckStrategy;
1242
1243
  leafOnly: boolean;
1243
1244
  defaultExpandAll: boolean;
1244
1245
  defaultExpandedKeys: Key[];
1245
1246
  cancelable: boolean;
1246
- internalScrollable: boolean;
1247
1247
  blockLine: boolean;
1248
1248
  selectable: boolean;
1249
1249
  internalUnifySelectCheck: boolean;
@@ -69,6 +69,7 @@ declare const uploadProps: {
69
69
  readonly onPreview: PropType<OnPreview>;
70
70
  readonly createThumbnailUrl: PropType<CreateThumbnailUrl>;
71
71
  readonly abstract: BooleanConstructor;
72
+ readonly max: NumberConstructor;
72
73
  readonly theme: PropType<import("../../_mixins").Theme<"Upload", {
73
74
  fontSize: string;
74
75
  lineHeight: string;
@@ -192,7 +193,7 @@ declare const uploadProps: {
192
193
  textColorFocusSuccess: string;
193
194
  textColorDisabledSuccess: string;
194
195
  textColorTextSuccess: string;
195
- textColorTextHoverSuccess: string; /** currently of no usage */
196
+ textColorTextHoverSuccess: string;
196
197
  textColorTextPressedSuccess: string;
197
198
  textColorTextFocusSuccess: string;
198
199
  textColorTextDisabledSuccess: string;
@@ -428,7 +429,7 @@ declare const uploadProps: {
428
429
  textColorFocusSuccess: string;
429
430
  textColorDisabledSuccess: string;
430
431
  textColorTextSuccess: string;
431
- textColorTextHoverSuccess: string; /** currently of no usage */
432
+ textColorTextHoverSuccess: string;
432
433
  textColorTextPressedSuccess: string;
433
434
  textColorTextFocusSuccess: string;
434
435
  textColorTextDisabledSuccess: string;
@@ -664,7 +665,7 @@ declare const uploadProps: {
664
665
  textColorFocusSuccess: string;
665
666
  textColorDisabledSuccess: string;
666
667
  textColorTextSuccess: string;
667
- textColorTextHoverSuccess: string; /** currently of no usage */
668
+ textColorTextHoverSuccess: string;
668
669
  textColorTextPressedSuccess: string;
669
670
  textColorTextFocusSuccess: string;
670
671
  textColorTextDisabledSuccess: string;
@@ -847,6 +848,7 @@ declare const _default: import("vue").DefineComponent<{
847
848
  readonly onPreview: PropType<OnPreview>;
848
849
  readonly createThumbnailUrl: PropType<CreateThumbnailUrl>;
849
850
  readonly abstract: BooleanConstructor;
851
+ readonly max: NumberConstructor;
850
852
  readonly theme: PropType<import("../../_mixins").Theme<"Upload", {
851
853
  fontSize: string;
852
854
  lineHeight: string;
@@ -970,7 +972,7 @@ declare const _default: import("vue").DefineComponent<{
970
972
  textColorFocusSuccess: string;
971
973
  textColorDisabledSuccess: string;
972
974
  textColorTextSuccess: string;
973
- textColorTextHoverSuccess: string; /** currently of no usage */
975
+ textColorTextHoverSuccess: string;
974
976
  textColorTextPressedSuccess: string;
975
977
  textColorTextFocusSuccess: string;
976
978
  textColorTextDisabledSuccess: string;
@@ -1206,7 +1208,7 @@ declare const _default: import("vue").DefineComponent<{
1206
1208
  textColorFocusSuccess: string;
1207
1209
  textColorDisabledSuccess: string;
1208
1210
  textColorTextSuccess: string;
1209
- textColorTextHoverSuccess: string; /** currently of no usage */
1211
+ textColorTextHoverSuccess: string;
1210
1212
  textColorTextPressedSuccess: string;
1211
1213
  textColorTextFocusSuccess: string;
1212
1214
  textColorTextDisabledSuccess: string;
@@ -1442,7 +1444,7 @@ declare const _default: import("vue").DefineComponent<{
1442
1444
  textColorFocusSuccess: string;
1443
1445
  textColorDisabledSuccess: string;
1444
1446
  textColorTextSuccess: string;
1445
- textColorTextHoverSuccess: string; /** currently of no usage */
1447
+ textColorTextHoverSuccess: string;
1446
1448
  textColorTextPressedSuccess: string;
1447
1449
  textColorTextFocusSuccess: string;
1448
1450
  textColorTextDisabledSuccess: string;
@@ -1631,7 +1633,7 @@ declare const _default: import("vue").DefineComponent<{
1631
1633
  tableHeaderColor: string;
1632
1634
  hoverColor: string;
1633
1635
  tableColorHover: string;
1634
- pressedColor: string;
1636
+ pressedColor: string; /** currently of no usage */
1635
1637
  opacityDisabled: string;
1636
1638
  inputColorDisabled: string;
1637
1639
  boxShadow1: string;
@@ -1785,7 +1787,7 @@ declare const _default: import("vue").DefineComponent<{
1785
1787
  textColorFocusSuccess: string;
1786
1788
  textColorDisabledSuccess: string;
1787
1789
  textColorTextSuccess: string;
1788
- textColorTextHoverSuccess: string; /** currently of no usage */
1790
+ textColorTextHoverSuccess: string;
1789
1791
  textColorTextPressedSuccess: string;
1790
1792
  textColorTextFocusSuccess: string;
1791
1793
  textColorTextDisabledSuccess: string;
@@ -1946,6 +1948,7 @@ declare const _default: import("vue").DefineComponent<{
1946
1948
  readonly onPreview?: unknown;
1947
1949
  readonly createThumbnailUrl?: unknown;
1948
1950
  readonly abstract?: unknown;
1951
+ readonly max?: unknown;
1949
1952
  readonly theme?: unknown;
1950
1953
  readonly themeOverrides?: unknown;
1951
1954
  readonly builtinThemeOverrides?: unknown;
@@ -1970,6 +1973,7 @@ declare const _default: import("vue").DefineComponent<{
1970
1973
  onChange?: OnChange | undefined;
1971
1974
  action?: string | undefined;
1972
1975
  accept?: string | undefined;
1976
+ max?: number | undefined;
1973
1977
  headers?: FuncOrRecordOrUndef;
1974
1978
  theme?: import("../../_mixins").Theme<"Upload", {
1975
1979
  fontSize: string;
@@ -2094,7 +2098,7 @@ declare const _default: import("vue").DefineComponent<{
2094
2098
  textColorFocusSuccess: string;
2095
2099
  textColorDisabledSuccess: string;
2096
2100
  textColorTextSuccess: string;
2097
- textColorTextHoverSuccess: string; /** currently of no usage */
2101
+ textColorTextHoverSuccess: string;
2098
2102
  textColorTextPressedSuccess: string;
2099
2103
  textColorTextFocusSuccess: string;
2100
2104
  textColorTextDisabledSuccess: string;
@@ -2330,7 +2334,7 @@ declare const _default: import("vue").DefineComponent<{
2330
2334
  textColorFocusSuccess: string;
2331
2335
  textColorDisabledSuccess: string;
2332
2336
  textColorTextSuccess: string;
2333
- textColorTextHoverSuccess: string; /** currently of no usage */
2337
+ textColorTextHoverSuccess: string;
2334
2338
  textColorTextPressedSuccess: string;
2335
2339
  textColorTextFocusSuccess: string;
2336
2340
  textColorTextDisabledSuccess: string;
@@ -2566,7 +2570,7 @@ declare const _default: import("vue").DefineComponent<{
2566
2570
  textColorFocusSuccess: string;
2567
2571
  textColorDisabledSuccess: string;
2568
2572
  textColorTextSuccess: string;
2569
- textColorTextHoverSuccess: string; /** currently of no usage */
2573
+ textColorTextHoverSuccess: string;
2570
2574
  textColorTextPressedSuccess: string;
2571
2575
  textColorTextFocusSuccess: string;
2572
2576
  textColorTextDisabledSuccess: string;