iryx-ui 0.25.0 → 0.26.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.
@@ -15,6 +15,16 @@ export interface CommandPaletteProps {
15
15
  hotkey?: string | null;
16
16
  /** Close once a command is chosen. */
17
17
  closeOnSelect?: boolean;
18
+ /**
19
+ * Remember recently chosen commands under this `localStorage` key and list
20
+ * them first while the search is empty. Unset (the default) remembers
21
+ * nothing. Use a different key per palette.
22
+ */
23
+ recentKey?: string;
24
+ /** How many recent commands to keep. */
25
+ recentLimit?: number;
26
+ /** Heading over the recent commands. Override for non-English apps. */
27
+ recentLabel?: string;
18
28
  /** Hint row along the bottom. Set `false` to drop it. */
19
29
  footer?: boolean;
20
30
  /** Skip built-in classes; you take over styling entirely. */
@@ -53,6 +63,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
53
63
  emptyText: string;
54
64
  hotkey: string | null;
55
65
  closeOnSelect: boolean;
66
+ recentLimit: number;
67
+ recentLabel: string;
56
68
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
57
69
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
58
70
  declare const _default: typeof __VLS_export;
@@ -1,15 +1,15 @@
1
1
  import { useIryxUiConfig as e } from "../config.js";
2
2
  import t from "./Icon.js";
3
- import { commandHaystack as n, matchesHotkey as r, toCommandGroups as i } from "../composables/command-palette.js";
4
- import { commandPaletteTheme as a } from "../theme/command-palette.js";
5
- import o from "./Kbd.js";
6
- import { Fragment as s, computed as c, createBlock as l, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createTextVNode as p, createVNode as m, defineComponent as h, mergeModels as g, normalizeClass as _, onBeforeUnmount as v, onMounted as y, openBlock as b, ref as x, renderList as S, renderSlot as C, toDisplayString as w, unref as T, useModel as E, watch as D, withCtx as O } from "vue";
7
- import { Search01Icon as k } from "@hugeicons/core-free-icons";
8
- import { DialogContent as ee, DialogOverlay as te, DialogPortal as ne, DialogRoot as A, DialogTitle as j, ListboxContent as M, ListboxFilter as N, ListboxGroup as P, ListboxGroupLabel as F, ListboxItem as I, ListboxRoot as L, VisuallyHidden as R, useFilter as z } from "reka-ui";
3
+ import { commandHaystack as n, commandId as r, matchesHotkey as i, pushRecent as a, toCommandGroups as o } from "../composables/command-palette.js";
4
+ import { commandPaletteTheme as s } from "../theme/command-palette.js";
5
+ import c from "./Kbd.js";
6
+ import { Fragment as l, computed as u, createBlock as d, createCommentVNode as f, createElementBlock as p, createElementVNode as m, createTextVNode as h, createVNode as g, defineComponent as _, mergeModels as v, normalizeClass as y, onBeforeUnmount as b, onMounted as x, openBlock as S, ref as C, renderList as w, renderSlot as T, toDisplayString as E, unref as D, useModel as O, watch as k, withCtx as A } from "vue";
7
+ import { Search01Icon as j } from "@hugeicons/core-free-icons";
8
+ import { DialogContent as M, DialogOverlay as ee, DialogPortal as te, DialogRoot as ne, DialogTitle as re, ListboxContent as ie, ListboxFilter as ae, ListboxGroup as oe, ListboxGroupLabel as se, ListboxItem as N, ListboxRoot as P, VisuallyHidden as F, useFilter as I } from "reka-ui";
9
9
  //#region src/components/CommandPalette.vue?vue&type=script&setup=true&lang.ts
10
- var B = /*@__PURE__*/ h({
10
+ var L = /*@__PURE__*/ _({
11
11
  __name: "CommandPalette",
12
- props: /*@__PURE__*/ g({
12
+ props: /*@__PURE__*/ v({
13
13
  items: {},
14
14
  placeholder: { default: "Search commands…" },
15
15
  emptyText: { default: "No matching commands." },
@@ -19,6 +19,9 @@ var B = /*@__PURE__*/ h({
19
19
  type: Boolean,
20
20
  default: !0
21
21
  },
22
+ recentKey: {},
23
+ recentLimit: { default: 5 },
24
+ recentLabel: { default: "Recent" },
22
25
  footer: {
23
26
  type: Boolean,
24
27
  default: !0
@@ -41,109 +44,143 @@ var B = /*@__PURE__*/ h({
41
44
  },
42
45
  openModifiers: {}
43
46
  }),
44
- emits: /*@__PURE__*/ g(["select"], ["update:open"]),
45
- setup(h, { emit: g }) {
46
- let B = h, V = g, H = E(h, "open"), U = x("");
47
- D(H, (e) => {
48
- e || (U.value = "");
47
+ emits: /*@__PURE__*/ v(["select"], ["update:open"]),
48
+ setup(_, { emit: v }) {
49
+ let L = _, R = v, z = O(_, "open"), B = C("");
50
+ k(z, (e) => {
51
+ e || (B.value = "");
49
52
  });
50
- let { contains: W } = z({ sensitivity: "base" }), G = c(() => i(B.items)), K = c(() => {
51
- let e = U.value.trim();
52
- return G.value.map((t) => ({
53
+ let { contains: V } = I({ sensitivity: "base" }), H = u(() => o(L.items)), U = C([]);
54
+ function W() {
55
+ if (L.recentKey) try {
56
+ let e = JSON.parse(window.localStorage.getItem(L.recentKey) ?? "[]");
57
+ U.value = Array.isArray(e) ? e.filter((e) => typeof e == "string") : [];
58
+ } catch {
59
+ U.value = [];
60
+ }
61
+ }
62
+ function G(e, t) {
63
+ if (L.recentKey) {
64
+ U.value = a(U.value, r(e, t), L.recentLimit);
65
+ try {
66
+ window.localStorage.setItem(L.recentKey, JSON.stringify(U.value));
67
+ } catch {}
68
+ }
69
+ }
70
+ x(W), k(() => L.recentKey, W);
71
+ let K = u(() => {
72
+ if (!L.recentKey || !U.value.length) return;
73
+ let e = /* @__PURE__ */ new Map();
74
+ for (let t of H.value) for (let n of t.items) e.set(r(n, t.label), {
75
+ item: n,
76
+ group: t.label
77
+ });
78
+ let t = U.value.slice(0, L.recentLimit).map((t) => e.get(t)).filter((e) => !!e && !e.item.disabled);
79
+ return t.length ? {
80
+ label: L.recentLabel,
81
+ items: t.map((e) => e.item),
82
+ sources: t.map((e) => e.group)
83
+ } : void 0;
84
+ }), q = u(() => {
85
+ let e = B.value.trim(), t = H.value.map((t) => ({
53
86
  ...t,
54
- items: e ? t.items.filter((r) => W(n(r, t.label), e)) : t.items
87
+ items: e ? t.items.filter((r) => V(n(r, t.label), e)) : t.items
88
+ })).map((e) => ({
89
+ ...e,
90
+ sources: e.items.map(() => e.label)
55
91
  })).filter((e) => e.items.length > 0);
56
- }), q = c(() => K.value.length === 0);
92
+ return !e && K.value ? [K.value, ...t] : t;
93
+ }), ce = u(() => q.value.length === 0);
57
94
  function J(e, t) {
58
95
  return `${e}:${t}`;
59
96
  }
60
- function Y(e) {
61
- e.disabled || (V("select", e), e.onSelect?.(), B.closeOnSelect && (H.value = !1));
97
+ function le(e, t) {
98
+ e.disabled || (G(e, t), R("select", e), e.onSelect?.(), L.closeOnSelect && (z.value = !1));
62
99
  }
63
- function X(e) {
64
- B.hotkey && r(e, B.hotkey) && (e.preventDefault(), H.value = !H.value);
100
+ function Y(e) {
101
+ L.hotkey && i(e, L.hotkey) && (e.preventDefault(), z.value = !z.value);
65
102
  }
66
- y(() => window.addEventListener("keydown", X)), v(() => window.removeEventListener("keydown", X));
67
- let re = e(), Z = c(() => B.unstyled ?? re.unstyled), Q = c(() => a());
103
+ x(() => window.addEventListener("keydown", Y)), b(() => window.removeEventListener("keydown", Y));
104
+ let X = e(), Z = u(() => L.unstyled ?? X.unstyled), Q = u(() => s());
68
105
  function $(e, t) {
69
- let n = B.ui?.[e];
106
+ let n = L.ui?.[e];
70
107
  return Z.value ? [n, t].filter(Boolean).join(" ") : Q.value[e]({ class: [n, t] });
71
108
  }
72
- function ie(e) {
109
+ function ue(e) {
73
110
  return e.split(" ").filter(Boolean);
74
111
  }
75
- return (e, n) => (b(), l(T(A), {
76
- open: H.value,
77
- "onUpdate:open": n[1] ||= (e) => H.value = e
112
+ return (e, n) => (S(), d(D(ne), {
113
+ open: z.value,
114
+ "onUpdate:open": n[1] ||= (e) => z.value = e
78
115
  }, {
79
- default: O(() => [m(T(ne), null, {
80
- default: O(() => [m(T(te), { class: _($("overlay")) }, null, 8, ["class"]), m(T(ee), {
81
- class: _(Z.value ? [B.ui?.content, B.class] : Q.value.content({ class: [B.ui?.content, B.class] })),
82
- "aria-label": B.label,
116
+ default: A(() => [g(D(te), null, {
117
+ default: A(() => [g(D(ee), { class: y($("overlay")) }, null, 8, ["class"]), g(D(M), {
118
+ class: y(Z.value ? [L.ui?.content, L.class] : Q.value.content({ class: [L.ui?.content, L.class] })),
119
+ "aria-label": L.label,
83
120
  "aria-describedby": void 0
84
121
  }, {
85
- default: O(() => [
86
- m(T(R), null, {
87
- default: O(() => [m(T(j), null, {
88
- default: O(() => [p(w(B.label), 1)]),
122
+ default: A(() => [
123
+ g(D(F), null, {
124
+ default: A(() => [g(D(re), null, {
125
+ default: A(() => [h(E(L.label), 1)]),
89
126
  _: 1
90
127
  })]),
91
128
  _: 1
92
129
  }),
93
- m(T(L), {
130
+ g(D(P), {
94
131
  "highlight-on-hover": "",
95
- class: _($("list"))
132
+ class: y($("list"))
96
133
  }, {
97
- default: O(() => [f("div", { class: _($("header")) }, [f("span", { class: _($("icon")) }, [m(t, { icon: T(k) }, null, 8, ["icon"])], 2), m(T(N), {
98
- modelValue: U.value,
99
- "onUpdate:modelValue": n[0] ||= (e) => U.value = e,
134
+ default: A(() => [m("div", { class: y($("header")) }, [m("span", { class: y($("icon")) }, [g(t, { icon: D(j) }, null, 8, ["icon"])], 2), g(D(ae), {
135
+ modelValue: B.value,
136
+ "onUpdate:modelValue": n[0] ||= (e) => B.value = e,
100
137
  "auto-focus": "",
101
- placeholder: B.placeholder,
102
- class: _($("input"))
138
+ placeholder: L.placeholder,
139
+ class: y($("input"))
103
140
  }, null, 8, [
104
141
  "modelValue",
105
142
  "placeholder",
106
143
  "class"
107
- ])], 2), m(T(M), { class: _($("viewport")) }, {
108
- default: O(() => [q.value ? (b(), d("p", {
144
+ ])], 2), g(D(ie), { class: y($("viewport")) }, {
145
+ default: A(() => [ce.value ? (S(), p("p", {
109
146
  key: 0,
110
- class: _($("empty"))
111
- }, [C(e.$slots, "empty", { query: U.value }, () => [p(w(B.emptyText), 1)])], 2)) : u("", !0), (b(!0), d(s, null, S(K.value, (n, r) => (b(), l(T(P), {
147
+ class: y($("empty"))
148
+ }, [T(e.$slots, "empty", { query: B.value }, () => [h(E(L.emptyText), 1)])], 2)) : f("", !0), (S(!0), p(l, null, w(q.value, (n, r) => (S(), d(D(oe), {
112
149
  key: n.label || r,
113
- class: _($("group"))
150
+ class: y($("group"))
114
151
  }, {
115
- default: O(() => [n.label ? (b(), l(T(F), {
152
+ default: A(() => [n.label ? (S(), d(D(se), {
116
153
  key: 0,
117
- class: _($("groupLabel"))
154
+ class: y($("groupLabel"))
118
155
  }, {
119
- default: O(() => [p(w(n.label), 1)]),
156
+ default: A(() => [h(E(n.label), 1)]),
120
157
  _: 2
121
- }, 1032, ["class"])) : u("", !0), (b(!0), d(s, null, S(n.items, (n, i) => (b(), l(T(I), {
122
- key: J(r, i),
123
- value: J(r, i),
124
- disabled: n.disabled,
125
- "aria-disabled": n.disabled || void 0,
126
- as: n.href ? "a" : "div",
127
- href: n.href,
128
- class: _($("item")),
129
- onSelect: (e) => Y(n)
158
+ }, 1032, ["class"])) : f("", !0), (S(!0), p(l, null, w(n.items, (i, a) => (S(), d(D(N), {
159
+ key: J(r, a),
160
+ value: J(r, a),
161
+ disabled: i.disabled,
162
+ "aria-disabled": i.disabled || void 0,
163
+ as: i.href ? "a" : "div",
164
+ href: i.href,
165
+ class: y($("item")),
166
+ onSelect: (e) => le(i, n.sources[a] ?? n.label)
130
167
  }, {
131
- default: O(() => [C(e.$slots, "item", { item: n }, () => [
132
- n.icon ? (b(), d("span", {
168
+ default: A(() => [T(e.$slots, "item", { item: i }, () => [
169
+ i.icon ? (S(), p("span", {
133
170
  key: 0,
134
- class: _($("itemIcon"))
135
- }, [m(t, { icon: n.icon }, null, 8, ["icon"])], 2)) : u("", !0),
136
- f("span", { class: _($("itemLabel")) }, w(n.label), 3),
137
- n.shortcut ? (b(), l(o, {
171
+ class: y($("itemIcon"))
172
+ }, [g(t, { icon: i.icon }, null, 8, ["icon"])], 2)) : f("", !0),
173
+ m("span", { class: y($("itemLabel")) }, E(i.label), 3),
174
+ i.shortcut ? (S(), d(c, {
138
175
  key: 1,
139
- keys: ie(n.shortcut),
140
- class: _($("shortcut")),
141
- ui: { key: B.ui?.key }
176
+ keys: ue(i.shortcut),
177
+ class: y($("shortcut")),
178
+ ui: { key: L.ui?.key }
142
179
  }, null, 8, [
143
180
  "keys",
144
181
  "class",
145
182
  "ui"
146
- ])) : u("", !0)
183
+ ])) : f("", !0)
147
184
  ])]),
148
185
  _: 2
149
186
  }, 1032, [
@@ -161,23 +198,23 @@ var B = /*@__PURE__*/ h({
161
198
  }, 8, ["class"])]),
162
199
  _: 3
163
200
  }, 8, ["class"]),
164
- B.footer ? (b(), d("div", {
201
+ L.footer ? (S(), p("div", {
165
202
  key: 0,
166
- class: _($("footer"))
167
- }, [C(e.$slots, "footer", {}, () => [
168
- f("span", null, [m(o, {
203
+ class: y($("footer"))
204
+ }, [T(e.$slots, "footer", {}, () => [
205
+ m("span", null, [g(c, {
169
206
  keys: ["up", "down"],
170
- ui: { key: B.ui?.key }
171
- }, null, 8, ["ui"]), n[2] ||= p(" to navigate", -1)]),
172
- f("span", null, [m(o, {
207
+ ui: { key: L.ui?.key }
208
+ }, null, 8, ["ui"]), n[2] ||= h(" to navigate", -1)]),
209
+ m("span", null, [g(c, {
173
210
  keys: "enter",
174
- ui: { key: B.ui?.key }
175
- }, null, 8, ["ui"]), n[3] ||= p(" to select", -1)]),
176
- f("span", null, [m(o, {
211
+ ui: { key: L.ui?.key }
212
+ }, null, 8, ["ui"]), n[3] ||= h(" to select", -1)]),
213
+ m("span", null, [g(c, {
177
214
  keys: "escape",
178
- ui: { key: B.ui?.key }
179
- }, null, 8, ["ui"]), n[4] ||= p(" to close", -1)])
180
- ])], 2)) : u("", !0)
215
+ ui: { key: L.ui?.key }
216
+ }, null, 8, ["ui"]), n[4] ||= h(" to close", -1)])
217
+ ])], 2)) : f("", !0)
181
218
  ]),
182
219
  _: 3
183
220
  }, 8, ["class", "aria-label"])]),
@@ -188,4 +225,4 @@ var B = /*@__PURE__*/ h({
188
225
  }
189
226
  });
190
227
  //#endregion
191
- export { B as default };
228
+ export { L as default };
@@ -1,4 +1,5 @@
1
1
  import type { ClassValue } from '../class-value';
2
+ import type { DateRangePreset } from '../composables/date';
2
3
  /** Both ends are ISO `YYYY-MM-DD` strings, and either may be absent. */
3
4
  export interface DateRange {
4
5
  start: string | null;
@@ -21,8 +22,18 @@ export interface DateRangePickerProps {
21
22
  format?: Intl.DateTimeFormatOptions;
22
23
  /** 0 is Sunday. Defaults to the locale's own convention. */
23
24
  weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
24
- /** Months shown side by side. Two makes picking a span across a boundary sane. */
25
+ /**
26
+ * Months shown side by side. Two makes picking a span across a boundary
27
+ * sane. Narrow screens always get one.
28
+ */
25
29
  months?: number;
30
+ /**
31
+ * Shortcuts beside the calendar — "Last 7 days", "This month". Picking one
32
+ * fills the range and closes. `commonDateRangePresets()` builds the usual set.
33
+ */
34
+ presets?: DateRangePreset[];
35
+ /** Accessible name for the preset list — override for non-English apps. */
36
+ presetsLabel?: string;
26
37
  /** Offer a "clear" action in the footer. */
27
38
  clearable?: boolean;
28
39
  /** Separator between the two dates on the trigger. */
@@ -36,7 +47,7 @@ export interface DateRangePickerProps {
36
47
  /** Applied to the trigger, which is the element carrying the field chrome. */
37
48
  class?: ClassValue;
38
49
  /** Override classes per element, e.g. `{ content: 'p-4' }`. */
39
- ui?: Partial<Record<'trigger' | 'placeholder' | 'content' | 'header' | 'heading' | 'nav' | 'months' | 'grid' | 'headCell' | 'cell' | 'cellTrigger' | 'footer' | 'action', string>>;
50
+ ui?: Partial<Record<'trigger' | 'placeholder' | 'content' | 'panel' | 'presets' | 'preset' | 'header' | 'heading' | 'nav' | 'months' | 'grid' | 'headCell' | 'cell' | 'cellTrigger' | 'footer' | 'action', string>>;
40
51
  }
41
52
  type __VLS_Props = DateRangePickerProps;
42
53
  type __VLS_ModelProps = {
@@ -56,6 +67,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
56
67
  nextLabel: string;
57
68
  invalid: boolean;
58
69
  clearLabel: string;
70
+ presetsLabel: string;
59
71
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
60
72
  declare const _default: typeof __VLS_export;
61
73
  export default _default;
@@ -2,18 +2,22 @@ import { useIryxUiConfig as e } from "../config.js";
2
2
  import t from "./Icon.js";
3
3
  import { formatIsoDate as n, toCalendarDate as r, toIsoDate as i } from "../composables/date.js";
4
4
  import { calendarTheme as ee } from "../theme/calendar.js";
5
- import { useFormField as te } from "../composables/form.js";
6
- import { datePickerTheme as a } from "../theme/date-picker.js";
7
- import { Fragment as o, computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createTextVNode as f, createVNode as p, defineComponent as m, mergeModels as h, normalizeClass as g, openBlock as _, ref as v, renderList as y, shallowRef as b, toDisplayString as x, unref as S, useModel as C, watch as w, withCtx as T } from "vue";
8
- import { ArrowLeft01Icon as E, ArrowRight01Icon as ne, Calendar03Icon as re } from "@hugeicons/core-free-icons";
9
- import { PopoverContent as D, PopoverPortal as O, PopoverRoot as k, PopoverTrigger as A, RangeCalendarCell as j, RangeCalendarCellTrigger as M, RangeCalendarGrid as N, RangeCalendarGridBody as P, RangeCalendarGridHead as F, RangeCalendarGridRow as I, RangeCalendarHeadCell as L, RangeCalendarHeader as R, RangeCalendarHeading as z, RangeCalendarNext as B, RangeCalendarPrev as V, RangeCalendarRoot as ie } from "reka-ui";
5
+ import { useFormField as a } from "../composables/form.js";
6
+ import { datePickerTheme as o } from "../theme/date-picker.js";
7
+ import { Fragment as s, computed as c, createBlock as l, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createTextVNode as te, createVNode as p, defineComponent as m, mergeModels as h, normalizeClass as g, onBeforeUnmount as ne, onMounted as re, openBlock as _, ref as v, renderList as y, shallowRef as b, toDisplayString as x, unref as S, useModel as ie, watch as C, withCtx as w } from "vue";
8
+ import { ArrowLeft01Icon as ae, ArrowRight01Icon as oe, Calendar03Icon as se } from "@hugeicons/core-free-icons";
9
+ import { PopoverContent as ce, PopoverPortal as le, PopoverRoot as ue, PopoverTrigger as de, RangeCalendarCell as T, RangeCalendarCellTrigger as E, RangeCalendarGrid as D, RangeCalendarGridBody as O, RangeCalendarGridHead as k, RangeCalendarGridRow as A, RangeCalendarHeadCell as j, RangeCalendarHeader as M, RangeCalendarHeading as N, RangeCalendarNext as P, RangeCalendarPrev as F, RangeCalendarRoot as I } from "reka-ui";
10
10
  //#region src/components/DateRangePicker.vue?vue&type=script&setup=true&lang.ts
11
- var H = [
11
+ var L = [
12
12
  "id",
13
13
  "disabled",
14
14
  "aria-invalid",
15
15
  "aria-describedby"
16
- ], U = { key: 0 }, W = /*@__PURE__*/ m({
16
+ ], R = { key: 0 }, z = ["aria-label"], B = [
17
+ "disabled",
18
+ "aria-pressed",
19
+ "onClick"
20
+ ], V = /*@__PURE__*/ m({
17
21
  __name: "DateRangePicker",
18
22
  props: /*@__PURE__*/ h({
19
23
  size: {},
@@ -30,6 +34,8 @@ var H = [
30
34
  format: {},
31
35
  weekStartsOn: {},
32
36
  months: { default: 2 },
37
+ presets: {},
38
+ presetsLabel: { default: "Presets" },
33
39
  clearable: { type: Boolean },
34
40
  separator: { default: " – " },
35
41
  clearLabel: { default: "Clear" },
@@ -55,127 +61,162 @@ var H = [
55
61
  }),
56
62
  emits: ["update:modelValue"],
57
63
  setup(m) {
58
- let h = m, W = C(m, "modelValue"), G = v(!1), K = te(), q = s(() => h.id ?? K?.id.value);
59
- K && h.id && (K.id.value = h.id);
60
- let J = s(() => h.invalid ?? K?.invalid.value ?? !1), Y = e(), ae = s(() => h.unstyled ?? Y.unstyled), X = b({
61
- start: r(W.value?.start),
62
- end: r(W.value?.end)
64
+ let h = m, V = ie(m, "modelValue"), H = v(!1), U = a(), fe = c(() => h.id ?? U?.id.value);
65
+ U && h.id && (U.id.value = h.id);
66
+ let W = c(() => h.invalid ?? U?.invalid.value ?? !1), pe = e(), me = c(() => h.unstyled ?? pe.unstyled), G = b({
67
+ start: r(V.value?.start),
68
+ end: r(V.value?.end)
63
69
  });
64
- function Z(e) {
65
- return i(e.start) === (W.value?.start ?? null) && i(e.end) === (W.value?.end ?? null);
70
+ function K(e) {
71
+ return i(e.start) === (V.value?.start ?? null) && i(e.end) === (V.value?.end ?? null);
66
72
  }
67
- w(W, () => {
68
- Z(X.value) || (X.value = {
69
- start: r(W.value?.start),
70
- end: r(W.value?.end)
73
+ C(V, () => {
74
+ K(G.value) || (G.value = {
75
+ start: r(V.value?.start),
76
+ end: r(V.value?.end)
71
77
  });
72
- }, { deep: !0 }), w(X, (e) => {
73
- Z(e) || (W.value = {
78
+ }, { deep: !0 }), C(G, (e) => {
79
+ K(e) || (V.value = {
74
80
  start: i(e.start),
75
81
  end: i(e.end)
76
82
  });
77
83
  });
78
- let oe = s(() => r(h.min)), se = s(() => r(h.max)), Q = s(() => {
79
- let e = n(W.value?.start, h.locale, h.format), t = n(W.value?.end, h.locale, h.format);
84
+ let q = v(!1), J;
85
+ function Y(e) {
86
+ q.value = e.matches;
87
+ }
88
+ re(() => {
89
+ typeof window.matchMedia == "function" && (J = window.matchMedia("(max-width: 39.99rem)"), q.value = J.matches, J.addEventListener("change", Y));
90
+ }), ne(() => J?.removeEventListener("change", Y));
91
+ let he = c(() => q.value ? 1 : h.months), ge = c(() => r(h.min)), _e = c(() => r(h.max)), X = c(() => {
92
+ let e = n(V.value?.start, h.locale, h.format), t = n(V.value?.end, h.locale, h.format);
80
93
  return !e && !t ? "" : t ? `${e}${h.separator}${t}` : e;
81
94
  });
82
- w(W, (e) => {
83
- G.value && e?.start && e?.end && (G.value = !1);
95
+ C(V, (e) => {
96
+ H.value && e?.start && e?.end && (H.value = !1);
84
97
  }, { deep: !0 });
85
- function ce() {
86
- W.value = {
98
+ let Z = c(() => (H.value, (h.presets ?? []).map((e) => ({
99
+ label: e.label,
100
+ range: typeof e.range == "function" ? e.range() : e.range
101
+ }))));
102
+ function Q(e) {
103
+ return (!h.min || !e.start || e.start >= h.min) && (!h.max || !e.end || e.end <= h.max);
104
+ }
105
+ function ve(e) {
106
+ return V.value?.start === e.start && V.value?.end === e.end;
107
+ }
108
+ function ye(e) {
109
+ V.value = {
110
+ start: e.start,
111
+ end: e.end
112
+ }, H.value = !1;
113
+ }
114
+ function be() {
115
+ V.value = {
87
116
  start: null,
88
117
  end: null
89
- }, G.value = !1;
118
+ }, H.value = !1;
90
119
  }
91
- let le = s(() => ({
92
- ...a({
120
+ let xe = c(() => ({
121
+ ...o({
93
122
  size: h.size,
94
- invalid: J.value
123
+ invalid: W.value
95
124
  }),
96
125
  ...ee({ range: !0 })
97
126
  }));
98
127
  function $(e, t) {
99
128
  let n = h.ui?.[e];
100
- return ae.value ? [n, t] : le.value[e]({ class: [n, t] });
129
+ return me.value ? [n, t] : xe.value[e]({ class: [n, t] });
101
130
  }
102
- return (e, n) => (_(), c(S(k), {
103
- open: G.value,
104
- "onUpdate:open": n[1] ||= (e) => G.value = e
131
+ return (e, n) => (_(), l(S(ue), {
132
+ open: H.value,
133
+ "onUpdate:open": n[1] ||= (e) => H.value = e
105
134
  }, {
106
- default: T(() => [p(S(A), { "as-child": "" }, {
107
- default: T(() => [d("button", {
108
- id: q.value,
135
+ default: w(() => [p(S(de), { "as-child": "" }, {
136
+ default: w(() => [f("button", {
137
+ id: fe.value,
109
138
  type: "button",
110
139
  disabled: h.disabled,
111
- "aria-invalid": J.value || void 0,
112
- "aria-describedby": S(K)?.describedBy.value,
140
+ "aria-invalid": W.value || void 0,
141
+ "aria-describedby": S(U)?.describedBy.value,
113
142
  class: g($("trigger", h.class))
114
- }, [Q.value ? (_(), u("span", U, x(Q.value), 1)) : (_(), u("span", {
143
+ }, [X.value ? (_(), d("span", R, x(X.value), 1)) : (_(), d("span", {
115
144
  key: 1,
116
145
  class: g($("placeholder"))
117
- }, x(h.placeholder), 3)), p(t, { icon: S(re) }, null, 8, ["icon"])], 10, H)]),
146
+ }, x(h.placeholder), 3)), p(t, { icon: S(se) }, null, 8, ["icon"])], 10, L)]),
118
147
  _: 1
119
- }), p(S(O), null, {
120
- default: T(() => [p(S(D), {
148
+ }), p(S(le), null, {
149
+ default: w(() => [p(S(ce), {
121
150
  class: g($("content")),
122
151
  "side-offset": 4,
123
152
  align: "start"
124
153
  }, {
125
- default: T(() => [p(S(ie), {
126
- modelValue: X.value,
127
- "onUpdate:modelValue": n[0] ||= (e) => X.value = e,
128
- "min-value": oe.value,
129
- "max-value": se.value,
154
+ default: w(() => [f("div", { class: g($("panel")) }, [Z.value.length ? (_(), d("div", {
155
+ key: 0,
156
+ role: "group",
157
+ "aria-label": h.presetsLabel,
158
+ class: g($("presets"))
159
+ }, [(_(!0), d(s, null, y(Z.value, (e) => (_(), d("button", {
160
+ key: e.label,
161
+ type: "button",
162
+ disabled: !Q(e.range),
163
+ "aria-pressed": ve(e.range),
164
+ class: g($("preset")),
165
+ onClick: (t) => ye(e.range)
166
+ }, x(e.label), 11, B))), 128))], 10, z)) : u("", !0), p(S(I), {
167
+ modelValue: G.value,
168
+ "onUpdate:modelValue": n[0] ||= (e) => G.value = e,
169
+ "min-value": ge.value,
170
+ "max-value": _e.value,
130
171
  locale: h.locale,
131
172
  "week-starts-on": h.weekStartsOn,
132
- "number-of-months": h.months,
173
+ "number-of-months": he.value,
133
174
  "fixed-weeks": "",
134
175
  "initial-focus": ""
135
176
  }, {
136
- default: T(({ grid: e, weekDays: n }) => [p(S(R), { class: g($("header")) }, {
137
- default: T(() => [
138
- p(S(V), {
177
+ default: w(({ grid: e, weekDays: n }) => [p(S(M), { class: g($("header")) }, {
178
+ default: w(() => [
179
+ p(S(F), {
139
180
  "aria-label": h.previousLabel,
140
181
  class: g($("nav"))
141
182
  }, {
142
- default: T(() => [p(t, { icon: S(E) }, null, 8, ["icon"])]),
183
+ default: w(() => [p(t, { icon: S(ae) }, null, 8, ["icon"])]),
143
184
  _: 1
144
185
  }, 8, ["aria-label", "class"]),
145
- p(S(z), { class: g($("heading")) }, null, 8, ["class"]),
146
- p(S(B), {
186
+ p(S(N), { class: g($("heading")) }, null, 8, ["class"]),
187
+ p(S(P), {
147
188
  "aria-label": h.nextLabel,
148
189
  class: g($("nav"))
149
190
  }, {
150
- default: T(() => [p(t, { icon: S(ne) }, null, 8, ["icon"])]),
191
+ default: w(() => [p(t, { icon: S(oe) }, null, 8, ["icon"])]),
151
192
  _: 1
152
193
  }, 8, ["aria-label", "class"])
153
194
  ]),
154
195
  _: 1
155
- }, 8, ["class"]), d("div", { class: g($("months")) }, [(_(!0), u(o, null, y(e, (e) => (_(), c(S(N), {
196
+ }, 8, ["class"]), f("div", { class: g($("months")) }, [(_(!0), d(s, null, y(e, (e) => (_(), l(S(D), {
156
197
  key: e.value.toString(),
157
198
  class: g($("grid"))
158
199
  }, {
159
- default: T(() => [p(S(F), null, {
160
- default: T(() => [p(S(I), null, {
161
- default: T(() => [(_(!0), u(o, null, y(n, (e) => (_(), c(S(L), {
200
+ default: w(() => [p(S(k), null, {
201
+ default: w(() => [p(S(A), null, {
202
+ default: w(() => [(_(!0), d(s, null, y(n, (e) => (_(), l(S(j), {
162
203
  key: e,
163
204
  class: g($("headCell"))
164
205
  }, {
165
- default: T(() => [f(x(e), 1)]),
206
+ default: w(() => [te(x(e), 1)]),
166
207
  _: 2
167
208
  }, 1032, ["class"]))), 128))]),
168
209
  _: 2
169
210
  }, 1024)]),
170
211
  _: 2
171
- }, 1024), p(S(P), null, {
172
- default: T(() => [(_(!0), u(o, null, y(e.rows, (t, n) => (_(), c(S(I), { key: `week-${n}` }, {
173
- default: T(() => [(_(!0), u(o, null, y(t, (t) => (_(), c(S(j), {
212
+ }, 1024), p(S(O), null, {
213
+ default: w(() => [(_(!0), d(s, null, y(e.rows, (t, n) => (_(), l(S(A), { key: `week-${n}` }, {
214
+ default: w(() => [(_(!0), d(s, null, y(t, (t) => (_(), l(S(T), {
174
215
  key: t.toString(),
175
216
  date: t,
176
217
  class: g($("cell"))
177
218
  }, {
178
- default: T(() => [p(S(M), {
219
+ default: w(() => [p(S(E), {
179
220
  day: t,
180
221
  month: e.value,
181
222
  class: g($("cellTrigger"))
@@ -200,14 +241,14 @@ var H = [
200
241
  "locale",
201
242
  "week-starts-on",
202
243
  "number-of-months"
203
- ]), h.clearable ? (_(), u("div", {
244
+ ])], 2), h.clearable ? (_(), d("div", {
204
245
  key: 0,
205
246
  class: g($("footer"))
206
- }, [d("button", {
247
+ }, [f("button", {
207
248
  type: "button",
208
249
  class: g($("action")),
209
- onClick: ce
210
- }, x(h.clearLabel), 3)], 2)) : l("", !0)]),
250
+ onClick: be
251
+ }, x(h.clearLabel), 3)], 2)) : u("", !0)]),
211
252
  _: 1
212
253
  }, 8, ["class"])]),
213
254
  _: 1
@@ -217,4 +258,4 @@ var H = [
217
258
  }
218
259
  });
219
260
  //#endregion
220
- export { W as default };
261
+ export { V as default };