@rotki/ui-library 2.10.0 → 2.11.1

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 (52) hide show
  1. package/dist/components/accordions/accordion/RuiAccordion.vue.d.ts +2 -2
  2. package/dist/components/alerts/RuiAlert.vue.d.ts +3 -3
  3. package/dist/components/buttons/button/RuiButton.vue.d.ts +9 -5
  4. package/dist/components/buttons/button-group/RuiButtonGroup.vue.d.ts +9 -5
  5. package/dist/components/calendar/state.js +1 -1
  6. package/dist/components/calendar/state.js.map +1 -1
  7. package/dist/components/cards/RuiCard.vue.d.ts +6 -6
  8. package/dist/components/date-time-picker/RuiDateTimePicker.vue.d.ts +3 -4
  9. package/dist/components/date-time-picker/RuiDateTimePicker.vue2.js +66 -249
  10. package/dist/components/date-time-picker/RuiDateTimePicker.vue2.js.map +1 -1
  11. package/dist/components/date-time-picker/use-date-time-selection.d.ts +38 -0
  12. package/dist/components/date-time-picker/use-date-time-selection.js +286 -0
  13. package/dist/components/date-time-picker/use-date-time-selection.js.map +1 -0
  14. package/dist/components/date-time-picker/use-keyboard-handler.d.ts +2 -0
  15. package/dist/components/date-time-picker/use-keyboard-handler.js +71 -60
  16. package/dist/components/date-time-picker/use-keyboard-handler.js.map +1 -1
  17. package/dist/components/forms/auto-complete/RuiAutoComplete.vue.d.ts +29 -25
  18. package/dist/components/forms/checkbox/RuiCheckbox.vue.d.ts +2 -2
  19. package/dist/components/forms/radio-button/radio/RuiRadio.vue.d.ts +9 -5
  20. package/dist/components/forms/radio-button/radio-group/RuiRadioGroup.vue.d.ts +9 -5
  21. package/dist/components/forms/revealable-text-field/RuiRevealableTextField.vue.d.ts +4 -4
  22. package/dist/components/forms/select/RuiMenuSelect.vue.d.ts +29 -25
  23. package/dist/components/forms/text-area/RuiTextArea.vue.d.ts +3 -3
  24. package/dist/components/forms/text-field/RuiTextField.vue.d.ts +3 -3
  25. package/dist/components/overlays/badge/RuiBadge.vue.d.ts +3 -3
  26. package/dist/components/overlays/bottom-sheet/RuiBottomSheet.vue.d.ts +2 -2
  27. package/dist/components/overlays/dialog/RuiDialog.vue.d.ts +2 -2
  28. package/dist/components/overlays/menu/RuiMenu.vue.d.ts +2 -2
  29. package/dist/components/overlays/navigation-drawer/RuiNavigationDrawer.vue.d.ts +2 -2
  30. package/dist/components/overlays/notification/RuiNotification.vue.d.ts +2 -2
  31. package/dist/components/overlays/tooltip/RuiTooltip.vue.d.ts +2 -2
  32. package/dist/components/tables/RuiDataTable.vue.d.ts +9 -5
  33. package/dist/components/tables/RuiExpandButton.vue.d.ts +2 -2
  34. package/dist/components/tables/RuiTableHead.vue.d.ts +9 -5
  35. package/dist/components/tabs/tab/RuiTab.vue.d.ts +1 -1
  36. package/dist/components/tabs/tab-item/RuiTabItem.vue.d.ts +3 -3
  37. package/dist/components/tabs/tab-items/RuiTabItems.vue.d.ts +9 -5
  38. package/dist/components/time-picker/RuiTimePicker.vue2.js +0 -1
  39. package/dist/components/time-picker/RuiTimePicker.vue2.js.map +1 -1
  40. package/dist/composables/defaults/table.js +1 -1
  41. package/dist/composables/defaults/table.js.map +1 -1
  42. package/dist/composables/icons.js +1 -1
  43. package/dist/composables/icons.js.map +1 -1
  44. package/dist/composables/theme.js +7 -8
  45. package/dist/composables/theme.js.map +1 -1
  46. package/dist/composables/use-rui-i18n.js +1 -1
  47. package/dist/composables/use-rui-i18n.js.map +1 -1
  48. package/dist/style.css +2 -2
  49. package/dist/types/theme.d.ts +7 -7
  50. package/dist/types/theme.js.map +1 -1
  51. package/dist/web-types.json +72 -72
  52. package/package.json +31 -40
@@ -7,11 +7,11 @@ export interface AccordionProps {
7
7
  }
8
8
  declare var __VLS_1: {
9
9
  open: boolean;
10
- }, __VLS_7: {};
10
+ }, __VLS_8: {};
11
11
  type __VLS_Slots = {} & {
12
12
  header?: (props: typeof __VLS_1) => any;
13
13
  } & {
14
- default?: (props: typeof __VLS_7) => any;
14
+ default?: (props: typeof __VLS_8) => any;
15
15
  };
16
16
  declare const __VLS_base: import("vue").DefineComponent<AccordionProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
17
  click: () => any;
@@ -9,11 +9,11 @@ export interface Props {
9
9
  actionText?: string;
10
10
  closeable?: boolean;
11
11
  }
12
- declare var __VLS_5: {}, __VLS_7: {};
12
+ declare var __VLS_6: {}, __VLS_8: {};
13
13
  type __VLS_Slots = {} & {
14
- title?: (props: typeof __VLS_5) => any;
14
+ title?: (props: typeof __VLS_6) => any;
15
15
  } & {
16
- default?: (props: typeof __VLS_7) => any;
16
+ default?: (props: typeof __VLS_8) => any;
17
17
  };
18
18
  declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
19
19
  close: () => any;
@@ -14,10 +14,12 @@ export interface Props<T = undefined> {
14
14
  modelValue?: T;
15
15
  hideFocusIndicator?: boolean;
16
16
  }
17
- declare const __VLS_export: <T = undefined>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
18
- props: __VLS_PrettifyLocal<Props<T> & {
17
+ declare const __VLS_export: <T = undefined>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
18
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<Props<T> & {
19
19
  "onUpdate:model-value"?: ((value?: T | undefined) => any) | undefined;
20
- }> & import("vue").PublicProps;
20
+ }> & (typeof globalThis extends {
21
+ __VLS_PROPS_FALLBACK: infer P;
22
+ } ? P : {});
21
23
  expose: (exposed: {}) => void;
22
24
  attrs: any;
23
25
  slots: {
@@ -33,6 +35,8 @@ declare const __VLS_export: <T = undefined>(__VLS_props: NonNullable<Awaited<typ
33
35
  };
34
36
  declare const _default: typeof __VLS_export;
35
37
  export default _default;
36
- type __VLS_PrettifyLocal<T> = {
38
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
39
+ [K in keyof T]: T[K];
40
+ } : {
37
41
  [K in keyof T as K]: T[K];
38
- } & {};
42
+ }) & {};
@@ -10,10 +10,12 @@ export interface Props<T = undefined> {
10
10
  modelValue?: T | T[];
11
11
  disabled?: boolean;
12
12
  }
13
- declare const __VLS_export: <T = undefined>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
14
- props: __VLS_PrettifyLocal<Props<T> & {
13
+ declare const __VLS_export: <T = undefined>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
14
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<Props<T> & {
15
15
  "onUpdate:modelValue"?: ((modelValue?: T | T[] | undefined) => any) | undefined;
16
- }> & import("vue").PublicProps;
16
+ }> & (typeof globalThis extends {
17
+ __VLS_PROPS_FALLBACK: infer P;
18
+ } ? P : {});
17
19
  expose: (exposed: {}) => void;
18
20
  attrs: any;
19
21
  slots: {};
@@ -23,6 +25,8 @@ declare const __VLS_export: <T = undefined>(__VLS_props: NonNullable<Awaited<typ
23
25
  };
24
26
  declare const _default: typeof __VLS_export;
25
27
  export default _default;
26
- type __VLS_PrettifyLocal<T> = {
28
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
29
+ [K in keyof T]: T[K];
30
+ } : {
27
31
  [K in keyof T as K]: T[K];
28
- } & {};
32
+ }) & {};
@@ -1,4 +1,4 @@
1
- const CalendarStateSymbol = Symbol.for("rui:calendar");
1
+ const CalendarStateSymbol = /* @__PURE__ */ Symbol.for("rui:calendar");
2
2
  function getDaysOfWeek(locale = "en-US", format = "narrow") {
3
3
  const daysOfWeek = [];
4
4
  for (let i = 0; i < 7; i++) {
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sources":["../../../src/components/calendar/state.ts"],"sourcesContent":["import type { ComputedRef, InjectionKey, Ref } from 'vue';\n\nexport const CalendarStateSymbol: InjectionKey<RuiCalendarState> = Symbol.for('rui:calendar');\n\nexport interface RuiCalendarState {\n viewMonth: Ref<number>;\n viewYear: Ref<number>;\n selectedDate: Ref<Date | undefined>;\n maxDate: ComputedRef<Date | undefined>;\n minDate: ComputedRef<Date | undefined>;\n isDark: ComputedRef<boolean>;\n allowEmpty: boolean;\n}\n\nexport interface MonthYearSelection {\n month: number;\n year: number;\n}\n\nexport function getDaysOfWeek(locale: Intl.LocalesArgument = 'en-US', format: 'narrow' | 'short' = 'narrow'): string[] {\n const daysOfWeek: string[] = [];\n for (let i = 0; i < 7; i++) {\n const date = new Date(2021, 0, 3 + i); // Jan 3, 2021 was a Sunday\n const dayName = new Intl.DateTimeFormat(locale, { weekday: format }).format(date);\n daysOfWeek.push(format === 'narrow' ? dayName : dayName.charAt(0));\n }\n return daysOfWeek;\n}\n\nexport function getShortMonthNames(locale: Intl.LocalesArgument = 'en-US'): string[] {\n const monthNames: string[] = [];\n for (let month = 0; month < 12; month++) {\n const date = new Date(2021, month, 1);\n const monthName = new Intl.DateTimeFormat(locale, { month: 'short' }).format(date);\n monthNames.push(monthName);\n }\n return monthNames;\n}\n"],"names":[],"mappings":"AAEO,MAAM,sBAAsD,OAAO,IAAI,cAAc;AAiBrF,SAAS,cAAc,SAA+B,SAAS,SAA6B,UAAoB;AACrH,QAAM,aAAuB,CAAA;AAC7B,WAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,UAAM,OAAO,IAAI,KAAK,MAAM,GAAG,IAAI,CAAC;AACpC,UAAM,UAAU,IAAI,KAAK,eAAe,QAAQ,EAAE,SAAS,OAAA,CAAQ,EAAE,OAAO,IAAI;AAChF,eAAW,KAAK,WAAW,WAAW,UAAU,QAAQ,OAAO,CAAC,CAAC;AAAA,EACnE;AACA,SAAO;AACT;AAEO,SAAS,mBAAmB,SAA+B,SAAmB;AACnF,QAAM,aAAuB,CAAA;AAC7B,WAAS,QAAQ,GAAG,QAAQ,IAAI,SAAS;AACvC,UAAM,OAAO,IAAI,KAAK,MAAM,OAAO,CAAC;AACpC,UAAM,YAAY,IAAI,KAAK,eAAe,QAAQ,EAAE,OAAO,QAAA,CAAS,EAAE,OAAO,IAAI;AACjF,eAAW,KAAK,SAAS;AAAA,EAC3B;AACA,SAAO;AACT;"}
1
+ {"version":3,"file":"state.js","sources":["../../../src/components/calendar/state.ts"],"sourcesContent":["import type { ComputedRef, InjectionKey, Ref } from 'vue';\n\nexport const CalendarStateSymbol: InjectionKey<RuiCalendarState> = Symbol.for('rui:calendar');\n\nexport interface RuiCalendarState {\n viewMonth: Ref<number>;\n viewYear: Ref<number>;\n selectedDate: Ref<Date | undefined>;\n maxDate: ComputedRef<Date | undefined>;\n minDate: ComputedRef<Date | undefined>;\n isDark: ComputedRef<boolean>;\n allowEmpty: boolean;\n}\n\nexport interface MonthYearSelection {\n month: number;\n year: number;\n}\n\nexport function getDaysOfWeek(locale: Intl.LocalesArgument = 'en-US', format: 'narrow' | 'short' = 'narrow'): string[] {\n const daysOfWeek: string[] = [];\n for (let i = 0; i < 7; i++) {\n const date = new Date(2021, 0, 3 + i); // Jan 3, 2021 was a Sunday\n const dayName = new Intl.DateTimeFormat(locale, { weekday: format }).format(date);\n daysOfWeek.push(format === 'narrow' ? dayName : dayName.charAt(0));\n }\n return daysOfWeek;\n}\n\nexport function getShortMonthNames(locale: Intl.LocalesArgument = 'en-US'): string[] {\n const monthNames: string[] = [];\n for (let month = 0; month < 12; month++) {\n const date = new Date(2021, month, 1);\n const monthName = new Intl.DateTimeFormat(locale, { month: 'short' }).format(date);\n monthNames.push(monthName);\n }\n return monthNames;\n}\n"],"names":[],"mappings":"AAEO,MAAM,sBAAsD,uBAAO,IAAI,cAAc;AAiBrF,SAAS,cAAc,SAA+B,SAAS,SAA6B,UAAoB;AACrH,QAAM,aAAuB,CAAA;AAC7B,WAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,UAAM,OAAO,IAAI,KAAK,MAAM,GAAG,IAAI,CAAC;AACpC,UAAM,UAAU,IAAI,KAAK,eAAe,QAAQ,EAAE,SAAS,OAAA,CAAQ,EAAE,OAAO,IAAI;AAChF,eAAW,KAAK,WAAW,WAAW,UAAU,QAAQ,OAAO,CAAC,CAAC;AAAA,EACnE;AACA,SAAO;AACT;AAEO,SAAS,mBAAmB,SAA+B,SAAmB;AACnF,QAAM,aAAuB,CAAA;AAC7B,WAAS,QAAQ,GAAG,QAAQ,IAAI,SAAS;AACvC,UAAM,OAAO,IAAI,KAAK,MAAM,OAAO,CAAC;AACpC,UAAM,YAAY,IAAI,KAAK,eAAe,QAAQ,EAAE,OAAO,QAAA,CAAS,EAAE,OAAO,IAAI;AACjF,eAAW,KAAK,SAAS;AAAA,EAC3B;AACA,SAAO;AACT;"}
@@ -7,21 +7,21 @@ export interface Props {
7
7
  noPadding?: boolean;
8
8
  contentClass?: string;
9
9
  }
10
- declare var __VLS_1: {}, __VLS_3: {}, __VLS_10: {}, __VLS_13: {}, __VLS_16: {}, __VLS_18: {}, __VLS_20: {};
10
+ declare var __VLS_1: {}, __VLS_3: {}, __VLS_12: {}, __VLS_15: {}, __VLS_18: {}, __VLS_20: {}, __VLS_22: {};
11
11
  type __VLS_Slots = {} & {
12
12
  image?: (props: typeof __VLS_1) => any;
13
13
  } & {
14
14
  'custom-header'?: (props: typeof __VLS_3) => any;
15
15
  } & {
16
- prepend?: (props: typeof __VLS_10) => any;
16
+ prepend?: (props: typeof __VLS_12) => any;
17
17
  } & {
18
- header?: (props: typeof __VLS_13) => any;
18
+ header?: (props: typeof __VLS_15) => any;
19
19
  } & {
20
- subheader?: (props: typeof __VLS_16) => any;
20
+ subheader?: (props: typeof __VLS_18) => any;
21
21
  } & {
22
- default?: (props: typeof __VLS_18) => any;
22
+ default?: (props: typeof __VLS_20) => any;
23
23
  } & {
24
- footer?: (props: typeof __VLS_20) => any;
24
+ footer?: (props: typeof __VLS_22) => any;
25
25
  };
26
26
  declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
27
27
  dense: boolean;
@@ -1,4 +1,3 @@
1
- import type { TimeAccuracy } from '../../consts/time-accuracy.js';
2
1
  type DateFormat = 'year-first' | 'month-first' | 'day-first';
3
2
  type DateTimeModelType = 'date' | 'epoch-ms' | 'epoch';
4
3
  type ModelValueType<T extends DateTimeModelType> = T extends 'date' ? Date | undefined : T extends 'epoch-ms' ? number | undefined : T extends 'epoch' ? number | undefined : Date | number | undefined;
@@ -7,7 +6,7 @@ export interface RuiDateTimePickerProps {
7
6
  maxDate?: Date | number | 'now';
8
7
  format?: DateFormat;
9
8
  type?: DateTimeModelType;
10
- accuracy?: TimeAccuracy;
9
+ accuracy?: 'minute' | 'second' | 'millisecond';
11
10
  disabled?: boolean;
12
11
  allowEmpty?: boolean;
13
12
  readonly?: boolean;
@@ -34,7 +33,7 @@ declare const props: Readonly<{}> & {
34
33
  readonly maxDate: number | Date | "now" | undefined;
35
34
  readonly minDate: number | Date | undefined;
36
35
  readonly format: DateFormat;
37
- readonly accuracy: TimeAccuracy;
36
+ readonly accuracy: "minute" | "second" | "millisecond";
38
37
  readonly errorMessages: string | string[];
39
38
  readonly successMessages: string | string[];
40
39
  readonly required: boolean;
@@ -72,7 +71,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
72
71
  maxDate: Date | number | "now";
73
72
  minDate: Date | number;
74
73
  allowEmpty: boolean;
75
- accuracy: TimeAccuracy;
74
+ accuracy: "minute" | "second" | "millisecond";
76
75
  format: DateFormat;
77
76
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
78
77
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -1,25 +1,22 @@
1
1
  import { getRootAttrs, getNonRootAttrs } from "../../utils/helpers.js";
2
- import { defineComponent, mergeModels, useCssVars, unref, computed, useModel, ref, watch, onMounted, createBlock, openBlock, mergeProps, isRef, withCtx, createVNode, renderSlot, createElementVNode, createElementBlock, createCommentVNode, normalizeClass, createTextVNode, toDisplayString, withModifiers, nextTick } from "vue";
2
+ import { defineComponent, mergeModels, useCssVars, unref, computed, useModel, ref, createBlock, openBlock, mergeProps, isRef, withCtx, createVNode, renderSlot, createElementVNode, createElementBlock, createCommentVNode, normalizeClass, createTextVNode, toDisplayString, withModifiers, nextTick } from "vue";
3
3
  import { logicOr, logicAnd } from "@vueuse/math";
4
- import dayjs from "dayjs";
5
4
  import RuiButton from "../buttons/button/RuiButton.vue.js";
6
5
  import _sfc_main$1 from "./RuiDateTimePickerMenu.vue.js";
6
+ import { useDateTimeSelection } from "./use-date-time-selection.js";
7
7
  import { useInputHandler } from "./use-input-handler.js";
8
8
  import { useKeyboardHandler } from "./use-keyboard-handler.js";
9
- import { guessTimezone, includeSeconds, includeMilliseconds } from "./utils.js";
10
9
  import RuiIcon from "../icons/RuiIcon.vue.js";
11
10
  import RuiMenu from "../overlays/menu/RuiMenu.vue.js";
12
- import { useRuiI8n } from "../../composables/use-rui-i18n.js";
13
- import { RUI_I18N_KEYS } from "../../i18n/keys.js";
14
- import { useFocusWithin, useFocus, isDefined, watchIgnorable } from "@vueuse/core";
11
+ import { useFocusWithin, useFocus, isDefined } from "@vueuse/core";
15
12
  import { get, set } from "@vueuse/shared";
16
13
  const _hoisted_1 = ["data-error", "tabindex"];
17
14
  const _hoisted_2 = {
18
15
  key: 0,
16
+ "data-id": "required-indicator",
19
17
  class: "text-rui-error"
20
18
  };
21
19
  const _hoisted_3 = ["disabled", "value", "placeholder", "readonly", "aria-invalid"];
22
- const MILLISECONDS = 1e3;
23
20
  const _sfc_main = /* @__PURE__ */ defineComponent({
24
21
  ...{
25
22
  name: "RuiDateTimePicker",
@@ -50,7 +47,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
50
47
  emits: ["update:modelValue"],
51
48
  setup(__props) {
52
49
  useCssVars((_ctx) => ({
53
- "a9f07354": unref(labelWithQuote)
50
+ "a01b5b3e": unref(labelWithQuote)
54
51
  }));
55
52
  const modelValue = useModel(__props, "modelValue");
56
53
  const props = __props;
@@ -61,17 +58,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
61
58
  };
62
59
  const isOpen = ref(false);
63
60
  const cursorPosition = ref(0);
64
- const internalErrorMessages = ref([]);
65
- const selectedYear = ref();
66
- const selectedMonth = ref();
67
- const selectedDay = ref();
68
- const selectedHour = ref();
69
- const selectedMinute = ref();
70
- const selectedSecond = ref();
71
- const selectedMillisecond = ref();
72
- const selectedTimezone = ref(guessTimezone());
73
61
  const currentValue = ref();
74
- const now = ref(dayjs.tz(void 0, guessTimezone()));
75
62
  const textInput = ref();
76
63
  const activator = ref();
77
64
  const menuWrapperRef = ref();
@@ -79,36 +66,34 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
79
66
  const { focused: activatorFocusedWithin } = useFocusWithin(activator);
80
67
  const { focused: menuWrapperFocusedWithin } = useFocusWithin(menuWrapperRef);
81
68
  const { focused: searchInputFocused } = useFocus(textInput);
82
- const { setValue, update, getCurrent } = useInputHandler({
83
- DD: selectedDay,
84
- MM: selectedMonth,
85
- YYYY: selectedYear,
86
- HH: selectedHour,
87
- mm: selectedMinute,
88
- ss: selectedSecond,
89
- SSS: selectedMillisecond
90
- }, currentValue);
91
- const minAllowedDate = computed(() => {
92
- if (props.minDate === void 0) {
93
- return new Date(1970, 0, 1);
94
- }
95
- if (props.type === "epoch" && typeof props.minDate === "number") {
96
- return new Date(props.minDate * MILLISECONDS);
97
- }
98
- return new Date(props.minDate);
99
- });
100
- const maxAllowedDate = computed(() => {
101
- if (props.maxDate === void 0) {
102
- return void 0;
103
- }
104
- if (props.maxDate === "now") {
105
- return get(now).toDate();
106
- }
107
- if (props.type === "epoch" && typeof props.maxDate === "number") {
108
- return new Date(props.maxDate * MILLISECONDS);
109
- }
110
- return new Date(props.maxDate);
69
+ const {
70
+ clear: clearSelection,
71
+ getDateTime,
72
+ internalErrorMessages,
73
+ maxAllowedDate,
74
+ minAllowedDate,
75
+ segmentData,
76
+ selectedDate,
77
+ selectedDay,
78
+ selectedHour,
79
+ selectedMillisecond,
80
+ selectedMinute,
81
+ selectedMonth,
82
+ selectedSecond,
83
+ selectedTime,
84
+ selectedTimezone,
85
+ selectedYear,
86
+ setNow,
87
+ valueSet
88
+ } = useDateTimeSelection({
89
+ accuracy: props.accuracy,
90
+ allowEmpty: props.allowEmpty,
91
+ maxDate: props.maxDate,
92
+ minDate: props.minDate,
93
+ modelValue,
94
+ type: props.type
111
95
  });
96
+ const { setValue, getCurrent } = useInputHandler(segmentData, currentValue);
112
97
  const dateFormat = computed(() => {
113
98
  const dateFormat2 = props.format;
114
99
  const format = baseFormats[dateFormat2];
@@ -121,72 +106,34 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
121
106
  });
122
107
  const {
123
108
  getCurrentSegment,
109
+ handleBlur,
124
110
  handleClick,
125
111
  handleFocus,
126
112
  handleInput,
127
113
  handleInputSelection,
128
114
  handleKeyDown,
115
+ handleMouseDown,
129
116
  handlePaste,
130
117
  setSegment
131
118
  } = useKeyboardHandler({
119
+ accuracy: props.accuracy,
132
120
  currentValue,
133
121
  cursorPosition,
122
+ dateFormat,
134
123
  disabled: props.disabled,
135
- getDateTime,
136
124
  getCurrent,
125
+ getDateTime,
137
126
  readonly: props.readonly,
138
- dateFormat,
139
127
  setValue,
140
- textInput,
141
- accuracy: props.accuracy
128
+ textInput
142
129
  });
143
- const { t } = useRuiI8n();
144
130
  function handleInputClick(event) {
131
+ handleClick(event);
145
132
  if (!get(isOpen)) {
146
133
  set(isOpen, true);
147
134
  }
148
- handleClick(event);
149
135
  }
150
136
  const anyFocused = logicOr(activatorFocusedWithin, menuWrapperFocusedWithin);
151
- const selectedDate = computed({
152
- set(value) {
153
- set(selectedYear, value?.getFullYear());
154
- set(selectedMonth, value ? value.getMonth() + 1 : void 0);
155
- set(selectedDay, value?.getDate());
156
- },
157
- get() {
158
- if (!(isDefined(selectedYear) && isDefined(selectedMonth) && isDefined(selectedDay))) {
159
- return void 0;
160
- }
161
- const date = /* @__PURE__ */ new Date();
162
- date.setFullYear(get(selectedYear));
163
- date.setMonth(get(selectedMonth) - 1);
164
- date.setDate(get(selectedDay));
165
- return date;
166
- }
167
- });
168
- const selectedTime = computed({
169
- set(value) {
170
- set(selectedHour, value?.getHours());
171
- set(selectedMinute, value?.getMinutes());
172
- set(selectedSecond, value?.getSeconds());
173
- set(selectedMillisecond, value?.getMilliseconds());
174
- },
175
- get() {
176
- if (!(isDefined(selectedHour) && isDefined(selectedMinute))) {
177
- return void 0;
178
- }
179
- const date = /* @__PURE__ */ new Date();
180
- date.setHours(
181
- get(selectedHour),
182
- get(selectedMinute),
183
- get(selectedSecond) ?? 0,
184
- get(selectedMillisecond) ?? 0
185
- );
186
- return date;
187
- }
188
- });
189
- const valueSet = computed(() => isDefined(selectedDate) && isDefined(selectedTime));
190
137
  const labelWithQuote = computed(() => {
191
138
  if (!props.label)
192
139
  return '"\\200B"';
@@ -255,17 +202,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
255
202
  });
256
203
  }
257
204
  function clear(segmentType) {
258
- set(internalErrorMessages, []);
259
205
  {
260
- set(selectedYear, void 0);
261
- set(selectedMonth, void 0);
262
- set(selectedDay, void 0);
263
- set(selectedHour, void 0);
264
- set(selectedMinute, void 0);
265
- set(selectedSecond, void 0);
266
- set(selectedMillisecond, void 0);
206
+ clearSelection();
267
207
  set(currentValue, void 0);
268
- set(modelValue, void 0);
269
208
  return;
270
209
  }
271
210
  }
@@ -275,137 +214,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
275
214
  event.stopPropagation();
276
215
  }
277
216
  }
278
- function getDateTime() {
279
- let dateTime = dayjs();
280
- if (isDefined(selectedYear)) {
281
- dateTime = dateTime.year(get(selectedYear));
282
- }
283
- if (isDefined(selectedMonth)) {
284
- dateTime = dateTime.month(get(selectedMonth) - 1);
285
- }
286
- if (isDefined(selectedDay)) {
287
- const daysInMonth = dateTime.daysInMonth();
288
- const day = Math.min(get(selectedDay), daysInMonth);
289
- dateTime = dateTime.date(day);
290
- }
291
- if (isDefined(selectedHour)) {
292
- dateTime = dateTime.hour(get(selectedHour));
293
- }
294
- if (isDefined(selectedMinute)) {
295
- dateTime = dateTime.minute(get(selectedMinute));
296
- }
297
- if (isDefined(selectedSecond)) {
298
- dateTime = dateTime.second(get(selectedSecond));
299
- }
300
- if (isDefined(selectedMillisecond)) {
301
- dateTime = dateTime.millisecond(get(selectedMillisecond));
302
- }
303
- return dateTime;
304
- }
305
- function setNow() {
306
- set(internalErrorMessages, []);
307
- const date = dayjs();
308
- set(now, date);
309
- set(selectedYear, date.year());
310
- set(selectedMonth, date.month() + 1);
311
- set(selectedDay, date.date());
312
- set(selectedHour, date.hour());
313
- set(selectedMinute, date.minute());
314
- set(selectedSecond, includeSeconds(props.accuracy) ? date.second() : 0);
315
- set(selectedMillisecond, includeMilliseconds(props.accuracy) ? date.millisecond() : 0);
316
- nextTick(() => {
317
- updateModelValue();
318
- });
319
- }
320
- function isDateValid(date) {
321
- const min = get(minAllowedDate);
322
- const max = get(maxAllowedDate);
323
- set(internalErrorMessages, []);
324
- if (min && date.isBefore(min)) {
325
- const errorMessage = t(RUI_I18N_KEYS.dateTimePicker.dateBeforeMin, {
326
- date: min.toLocaleDateString()
327
- }, `Date cannot be before ${min.toLocaleDateString()}`);
328
- set(internalErrorMessages, [...get(internalErrorMessages), errorMessage]);
329
- return false;
330
- }
331
- if (max && date.isAfter(max)) {
332
- const nowError = t(RUI_I18N_KEYS.dateTimePicker.dateInFuture, "The selected date cannot be in the future");
333
- const maxError = t(RUI_I18N_KEYS.dateTimePicker.dateAfterMax, { date: max.toLocaleDateString() }, `Date cannot be after ${max.toLocaleDateString()}`);
334
- const errorMessage = props.maxDate === "now" ? nowError : maxError;
335
- set(internalErrorMessages, [...get(internalErrorMessages), errorMessage]);
336
- return false;
337
- }
338
- return true;
339
- }
340
- function emitUpdate(updatedModel) {
341
- const typeMap = {
342
- "date": () => updatedModel.toDate(),
343
- "epoch-ms": () => updatedModel.valueOf(),
344
- "epoch": () => updatedModel.valueOf() / MILLISECONDS
345
- };
346
- set(modelValue, typeMap[props.type]());
347
- }
348
- function updateModelValue() {
349
- if (!isDefined(selectedDate) || !isDefined(selectedTime)) {
350
- return;
351
- }
352
- if (!(isDefined(selectedDate) && isDefined(selectedTime))) {
353
- set(modelValue, void 0);
354
- } else {
355
- const date = get(selectedDate);
356
- const time = get(selectedTime);
357
- const updatedModel = dayjs.tz(isDefined(modelValue) ? get(modelValue) : void 0, get(selectedTimezone)).year(date.getFullYear()).month(date.getMonth()).date(date.getDate()).hour(time.getHours()).minute(time.getMinutes()).second(includeSeconds(props.accuracy) ? time.getSeconds() : 0).millisecond(includeMilliseconds(props.accuracy) ? time.getMilliseconds() : 0);
358
- if (!isDateValid(updatedModel)) {
359
- return;
360
- }
361
- emitUpdate(updatedModel);
362
- }
363
- }
364
- const { ignoreUpdates } = watchIgnorable([selectedDate, selectedTime], ([selectedDate2, selectedTime2], [prevSelectedDate, prevSelectedTime]) => {
365
- const currentTimezone = get(selectedTimezone);
366
- const newSelectedDate = dayjs.tz(selectedDate2, currentTimezone);
367
- const oldSelectedDate = dayjs.tz(prevSelectedDate, currentTimezone);
368
- const newSelectedTime = dayjs.tz(selectedTime2, currentTimezone);
369
- const oldSelectedTime = dayjs.tz(prevSelectedTime, currentTimezone);
370
- if (newSelectedDate.isSame(oldSelectedDate) && newSelectedTime.isSame(oldSelectedTime)) {
371
- return;
372
- }
373
- set(now, dayjs());
374
- updateModelValue();
375
- });
376
- function updateInternalModel(value) {
377
- ignoreUpdates(() => {
378
- const updatedValue = props.type === "epoch" && typeof value === "number" ? value * MILLISECONDS : value;
379
- const date = dayjs.tz(updatedValue, get(selectedTimezone));
380
- isDateValid(date);
381
- update(date, props.accuracy);
382
- });
383
- }
384
- watch(selectedTimezone, (newTimezone) => {
385
- if (newTimezone && isDefined(selectedDate) && isDefined(selectedTime)) {
386
- set(now, dayjs());
387
- updateModelValue();
388
- }
389
- });
390
- watch(modelValue, (value) => {
391
- set(now, dayjs());
392
- if (value === void 0) {
393
- clear();
394
- } else {
395
- updateInternalModel(value);
396
- }
397
- });
398
- onMounted(() => {
399
- if (isDefined(modelValue)) {
400
- updateInternalModel(get(modelValue));
401
- } else if (!props.allowEmpty) {
402
- setNow();
403
- }
404
- });
405
217
  return (_ctx, _cache) => {
406
218
  return openBlock(), createBlock(RuiMenu, mergeProps({
407
219
  modelValue: unref(isOpen),
408
- "onUpdate:modelValue": _cache[19] || (_cache[19] = ($event) => isRef(isOpen) ? isOpen.value = $event : null),
220
+ "onUpdate:modelValue": _cache[21] || (_cache[21] = ($event) => isRef(isOpen) ? isOpen.value = $event : null),
409
221
  class: _ctx.$style.wrapper,
410
222
  dense: __props.dense,
411
223
  hint: __props.hint,
@@ -418,7 +230,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
418
230
  popper: {
419
231
  placement: "bottom-start"
420
232
  },
421
- "full-width": ""
233
+ "full-width": "",
234
+ "disable-auto-focus": ""
422
235
  }, {
423
236
  ...("getRootAttrs" in _ctx ? _ctx.getRootAttrs : unref(getRootAttrs))(_ctx.$attrs)
424
237
  }), {
@@ -450,11 +263,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
450
263
  "data-id": "activator",
451
264
  "data-error": hasError ? "" : void 0,
452
265
  tabindex: __props.disabled || props.readonly ? -1 : 0,
453
- onClick: _cache[8] || (_cache[8] = ($event) => setInputFocus())
266
+ onClick: _cache[10] || (_cache[10] = ($event) => setInputFocus())
454
267
  }
455
268
  ), [
456
269
  unref(isOutlined) && (unref(searchInputFocused) || open || unref(valueSet)) ? (openBlock(), createElementBlock("span", {
457
270
  key: 0,
271
+ "data-id": "label",
458
272
  class: normalizeClass([
459
273
  _ctx.$style.label,
460
274
  {
@@ -488,12 +302,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
488
302
  placeholder: unref(dateFormat),
489
303
  readonly: __props.readonly,
490
304
  "aria-invalid": hasError,
491
- onFocus: _cache[0] || (_cache[0] = ($event) => unref(handleFocus)()),
492
- onSelect: _cache[1] || (_cache[1] = ($event) => unref(handleInputSelection)($event)),
493
- onClick: _cache[2] || (_cache[2] = withModifiers(($event) => handleInputClick($event), ["stop"])),
494
- onKeydown: _cache[3] || (_cache[3] = ($event) => unref(handleKeyDown)($event)),
495
- onPaste: _cache[4] || (_cache[4] = ($event) => unref(handlePaste)($event)),
496
- onInput: _cache[5] || (_cache[5] = ($event) => unref(handleInput)($event))
305
+ onMousedown: _cache[0] || (_cache[0] = ($event) => unref(handleMouseDown)($event)),
306
+ onFocus: _cache[1] || (_cache[1] = ($event) => unref(handleFocus)()),
307
+ onBlur: _cache[2] || (_cache[2] = ($event) => unref(handleBlur)()),
308
+ onSelect: _cache[3] || (_cache[3] = ($event) => unref(handleInputSelection)($event)),
309
+ onClick: _cache[4] || (_cache[4] = withModifiers(($event) => handleInputClick($event), ["stop"])),
310
+ onKeydown: _cache[5] || (_cache[5] = ($event) => unref(handleKeyDown)($event)),
311
+ onPaste: _cache[6] || (_cache[6] = ($event) => unref(handlePaste)($event)),
312
+ onInput: _cache[7] || (_cache[7] = ($event) => unref(handleInput)($event))
497
313
  }, null, 40, _hoisted_3)
498
314
  ], 2),
499
315
  __props.allowEmpty && unref(valueSet) && !__props.disabled ? (openBlock(), createBlock(RuiButton, {
@@ -507,7 +323,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
507
323
  class: normalizeClass(["group-hover:!visible", [_ctx.$style.clear, unref(anyFocused) && "!visible", {
508
324
  "mr-2": !__props.dense
509
325
  }]]),
510
- onClick: _cache[6] || (_cache[6] = withModifiers(($event) => clear(), ["stop", "prevent"]))
326
+ onClick: _cache[8] || (_cache[8] = withModifiers(($event) => clear(), ["stop", "prevent"]))
511
327
  }, {
512
328
  default: withCtx(() => [
513
329
  createVNode(RuiIcon, {
@@ -519,7 +335,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
519
335
  }, 8, ["class"])) : createCommentVNode("", true),
520
336
  createElementVNode("span", {
521
337
  class: normalizeClass([_ctx.$style.icon__wrapper, _ctx.$style.icon__append]),
522
- onClick: _cache[7] || (_cache[7] = ($event) => arrowClicked($event))
338
+ "data-id": "append",
339
+ onClick: _cache[9] || (_cache[9] = ($event) => arrowClicked($event))
523
340
  }, [
524
341
  createVNode(RuiIcon, {
525
342
  class: normalizeClass([_ctx.$style.icon, { "rotate-180": open }]),
@@ -542,27 +359,27 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
542
359
  ref_key: "menuWrapperRef",
543
360
  ref: menuWrapperRef,
544
361
  "selected-date": unref(selectedDate),
545
- "onUpdate:selectedDate": _cache[9] || (_cache[9] = ($event) => isRef(selectedDate) ? selectedDate.value = $event : null),
362
+ "onUpdate:selectedDate": _cache[11] || (_cache[11] = ($event) => isRef(selectedDate) ? selectedDate.value = $event : null),
546
363
  "selected-time": unref(selectedTime),
547
- "onUpdate:selectedTime": _cache[10] || (_cache[10] = ($event) => isRef(selectedTime) ? selectedTime.value = $event : null),
364
+ "onUpdate:selectedTime": _cache[12] || (_cache[12] = ($event) => isRef(selectedTime) ? selectedTime.value = $event : null),
548
365
  "selected-hour": unref(selectedHour),
549
- "onUpdate:selectedHour": _cache[11] || (_cache[11] = ($event) => isRef(selectedHour) ? selectedHour.value = $event : null),
366
+ "onUpdate:selectedHour": _cache[13] || (_cache[13] = ($event) => isRef(selectedHour) ? selectedHour.value = $event : null),
550
367
  "selected-minute": unref(selectedMinute),
551
- "onUpdate:selectedMinute": _cache[12] || (_cache[12] = ($event) => isRef(selectedMinute) ? selectedMinute.value = $event : null),
368
+ "onUpdate:selectedMinute": _cache[14] || (_cache[14] = ($event) => isRef(selectedMinute) ? selectedMinute.value = $event : null),
552
369
  "selected-second": unref(selectedSecond),
553
- "onUpdate:selectedSecond": _cache[13] || (_cache[13] = ($event) => isRef(selectedSecond) ? selectedSecond.value = $event : null),
370
+ "onUpdate:selectedSecond": _cache[15] || (_cache[15] = ($event) => isRef(selectedSecond) ? selectedSecond.value = $event : null),
554
371
  "selected-millisecond": unref(selectedMillisecond),
555
- "onUpdate:selectedMillisecond": _cache[14] || (_cache[14] = ($event) => isRef(selectedMillisecond) ? selectedMillisecond.value = $event : null),
372
+ "onUpdate:selectedMillisecond": _cache[16] || (_cache[16] = ($event) => isRef(selectedMillisecond) ? selectedMillisecond.value = $event : null),
556
373
  "time-selection": unref(timeSelection),
557
- "onUpdate:timeSelection": _cache[15] || (_cache[15] = ($event) => isRef(timeSelection) ? timeSelection.value = $event : null),
374
+ "onUpdate:timeSelection": _cache[17] || (_cache[17] = ($event) => isRef(timeSelection) ? timeSelection.value = $event : null),
558
375
  "selected-timezone": unref(selectedTimezone),
559
- "onUpdate:selectedTimezone": _cache[16] || (_cache[16] = ($event) => isRef(selectedTimezone) ? selectedTimezone.value = $event : null),
376
+ "onUpdate:selectedTimezone": _cache[18] || (_cache[18] = ($event) => isRef(selectedTimezone) ? selectedTimezone.value = $event : null),
560
377
  "calendar-menu-open": unref(calendarMenuOpen),
561
- "onUpdate:calendarMenuOpen": _cache[17] || (_cache[17] = ($event) => isRef(calendarMenuOpen) ? calendarMenuOpen.value = $event : null),
378
+ "onUpdate:calendarMenuOpen": _cache[19] || (_cache[19] = ($event) => isRef(calendarMenuOpen) ? calendarMenuOpen.value = $event : null),
562
379
  accuracy: __props.accuracy,
563
380
  "max-date": unref(maxAllowedDate),
564
381
  "min-date": unref(minAllowedDate),
565
- onSetNow: _cache[18] || (_cache[18] = ($event) => setNow())
382
+ onSetNow: _cache[20] || (_cache[20] = ($event) => unref(setNow)())
566
383
  }, {
567
384
  default: withCtx(() => [
568
385
  renderSlot(_ctx.$slots, "menu-content")