@devalok/shilp-sutra 0.32.0 → 0.33.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 (66) hide show
  1. package/LICENSE +21 -0
  2. package/dist/_chunks/date-time-picker.js +851 -0
  3. package/dist/_chunks/framer.js +1777 -1728
  4. package/dist/_chunks/mention-suggestion.js +362 -0
  5. package/dist/_chunks/tiptap.js +11595 -7731
  6. package/dist/_chunks/use-calendar.js +115 -956
  7. package/dist/_chunks/vendor-client.js +1062 -878
  8. package/dist/composed/date-picker/index.js +9 -8
  9. package/dist/composed/emoji-picker.d.ts +8 -2
  10. package/dist/composed/emoji-picker.d.ts.map +1 -1
  11. package/dist/composed/emoji-picker.js +65 -56
  12. package/dist/composed/extensions/emoji-data.d.ts +35 -0
  13. package/dist/composed/extensions/emoji-data.d.ts.map +1 -0
  14. package/dist/composed/extensions/emoji-node.d.ts +11 -0
  15. package/dist/composed/extensions/emoji-node.d.ts.map +1 -0
  16. package/dist/composed/extensions/emoji-suggestion.d.ts +4 -6
  17. package/dist/composed/extensions/emoji-suggestion.d.ts.map +1 -1
  18. package/dist/composed/extensions/slash-command.d.ts +35 -0
  19. package/dist/composed/extensions/slash-command.d.ts.map +1 -0
  20. package/dist/composed/index.d.ts +7 -1
  21. package/dist/composed/index.d.ts.map +1 -1
  22. package/dist/composed/index.js +79 -70
  23. package/dist/composed/rich-chat-input/attachment-strip.d.ts +15 -0
  24. package/dist/composed/rich-chat-input/attachment-strip.d.ts.map +1 -0
  25. package/dist/composed/rich-chat-input/audio-player.d.ts +11 -0
  26. package/dist/composed/rich-chat-input/audio-player.d.ts.map +1 -0
  27. package/dist/composed/rich-chat-input/audio-waveform.d.ts +24 -0
  28. package/dist/composed/rich-chat-input/audio-waveform.d.ts.map +1 -0
  29. package/dist/composed/rich-chat-input/chat-toolbar.d.ts +51 -0
  30. package/dist/composed/rich-chat-input/chat-toolbar.d.ts.map +1 -0
  31. package/dist/composed/rich-chat-input/recording-overlay.d.ts +15 -0
  32. package/dist/composed/rich-chat-input/recording-overlay.d.ts.map +1 -0
  33. package/dist/composed/rich-chat-input/reply-banner.d.ts +8 -0
  34. package/dist/composed/rich-chat-input/reply-banner.d.ts.map +1 -0
  35. package/dist/composed/rich-chat-input/schedule-send.d.ts +22 -0
  36. package/dist/composed/rich-chat-input/schedule-send.d.ts.map +1 -0
  37. package/dist/composed/rich-chat-input/use-voice-recorder.d.ts +18 -0
  38. package/dist/composed/rich-chat-input/use-voice-recorder.d.ts.map +1 -0
  39. package/dist/composed/rich-chat-input.d.ts +91 -0
  40. package/dist/composed/rich-chat-input.d.ts.map +1 -0
  41. package/dist/composed/rich-chat-input.js +1861 -0
  42. package/dist/composed/rich-text-editor.d.ts +3 -0
  43. package/dist/composed/rich-text-editor.d.ts.map +1 -1
  44. package/dist/composed/rich-text-editor.js +278 -448
  45. package/dist/ui/button-group.d.ts +27 -37
  46. package/dist/ui/button-group.d.ts.map +1 -1
  47. package/dist/ui/button-group.js +95 -29
  48. package/dist/ui/button.d.ts.map +1 -1
  49. package/dist/ui/button.js +110 -106
  50. package/dist/ui/index.d.ts +1 -0
  51. package/dist/ui/index.d.ts.map +1 -1
  52. package/dist/ui/index.js +335 -333
  53. package/dist/ui/lib/index.d.ts +1 -0
  54. package/dist/ui/lib/index.d.ts.map +1 -1
  55. package/dist/ui/split-button.d.ts +45 -0
  56. package/dist/ui/split-button.d.ts.map +1 -0
  57. package/dist/ui/split-button.js +282 -0
  58. package/docs/components/composed/emoji-picker.md +9 -0
  59. package/docs/components/composed/rich-chat-input.md +88 -0
  60. package/docs/components/composed/rich-text-editor.md +5 -0
  61. package/docs/components/ui/button-group.md +9 -0
  62. package/docs/components/ui/button.md +4 -0
  63. package/docs/components/ui/split-button.md +41 -0
  64. package/llms-full.txt +157 -1
  65. package/llms.txt +22 -2
  66. package/package.json +38 -34
@@ -1,190 +1,189 @@
1
1
  "use client";
2
- import { jsxs as M, jsx as t } from "react/jsx-runtime";
3
- import * as b from "react";
4
- import { useState as Ce } from "react";
5
- import { format as D, startOfMonth as q, endOfMonth as ge, startOfWeek as Pe, endOfWeek as Ae, addDays as G, subMonths as be, addMonths as se, isSameMonth as xe, isSameDay as X, lastDayOfMonth as Re, isBefore as ee, startOfDay as V, isAfter as te, isWithinInterval as ye, setMonth as re, setYear as ae, endOfDay as J, startOfYear as Oe, subDays as fe, setHours as W, setMinutes as ne, setSeconds as Me } from "date-fns";
6
- import { IconChevronLeft as Ye, IconChevronRight as He, IconCalendarEvent as ve, IconClock as Te, IconCalendarClock as De } from "@tabler/icons-react";
7
- import { Icon as B } from "../ui/icon.js";
8
- import { cn as S } from "../ui/lib/utils.js";
9
- import { Popover as oe, PopoverTrigger as ce, PopoverContent as le } from "../ui/popover.js";
10
- const Le = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], Q = b.forwardRef(
2
+ import { jsxs as y, jsx as i } from "react/jsx-runtime";
3
+ import * as w from "react";
4
+ import { useState as ae } from "react";
5
+ import { format as m, startOfMonth as k, endOfMonth as ie, startOfWeek as ce, endOfWeek as de, addDays as b, subMonths as z, addMonths as B, isSameMonth as Y, isSameDay as x, lastDayOfMonth as le, isBefore as N, startOfDay as G, isAfter as T, isWithinInterval as L, setYear as ue, setMonth as fe } from "date-fns";
6
+ import { IconChevronLeft as me, IconChevronRight as pe } from "@tabler/icons-react";
7
+ import { Icon as P } from "../ui/icon.js";
8
+ import { cn as C } from "../ui/lib/utils.js";
9
+ const be = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], he = w.forwardRef(
11
10
  function({
12
- currentMonth: e,
11
+ currentMonth: c,
13
12
  selected: d,
14
- rangeStart: l,
15
- rangeEnd: u,
16
- hoverDate: w,
17
- onSelect: x,
18
- onHover: m,
19
- onMonthChange: v,
20
- onHeaderClick: H,
21
- disabledDates: C,
22
- minDate: O,
23
- maxDate: k,
24
- hidePrevNav: T,
25
- hideNextNav: y,
26
- events: p,
27
- className: h,
28
- ...g
29
- }, r) {
30
- const A = b.useRef(null), N = b.useMemo(() => {
31
- const a = /* @__PURE__ */ new Map();
32
- if (!p) return a;
33
- for (const s of p) {
34
- const c = D(s.date, "yyyy-MM-dd"), n = a.get(c) ?? [];
35
- n.push(s), a.set(c, n);
13
+ rangeStart: o,
14
+ rangeEnd: l,
15
+ hoverDate: f,
16
+ onSelect: v,
17
+ onHover: a,
18
+ onMonthChange: u,
19
+ onHeaderClick: R,
20
+ disabledDates: q,
21
+ minDate: j,
22
+ maxDate: A,
23
+ hidePrevNav: F,
24
+ hideNextNav: S,
25
+ events: g,
26
+ className: U,
27
+ ...$
28
+ }, J) {
29
+ const M = w.useRef(null), Q = w.useMemo(() => {
30
+ const e = /* @__PURE__ */ new Map();
31
+ if (!g) return e;
32
+ for (const n of g) {
33
+ const t = m(n.date, "yyyy-MM-dd"), s = e.get(t) ?? [];
34
+ s.push(n), e.set(t, s);
36
35
  }
37
- return a;
38
- }, [p]), Y = q(e), R = ge(e), L = Pe(Y), U = Ae(R), $ = [];
39
- let E = L;
40
- for (; E <= U; )
41
- $.push(E), E = G(E, 1);
42
- const I = (a) => !!(C?.(a) || O && ee(a, V(O)) || k && te(a, V(k))), z = (a) => {
43
- if (l && u) {
44
- const s = ee(l, u) ? l : u, c = te(u, l) ? u : l;
45
- return ye(a, { start: s, end: c });
36
+ return e;
37
+ }, [g]), V = k(c), X = ie(c), Z = ce(V), _ = de(X), E = [];
38
+ let h = Z;
39
+ for (; h <= _; )
40
+ E.push(h), h = b(h, 1);
41
+ const I = (e) => !!(q?.(e) || j && N(e, G(j)) || A && T(e, G(A))), H = (e) => {
42
+ if (o && l) {
43
+ const n = N(o, l) ? o : l, t = T(l, o) ? l : o;
44
+ return L(e, { start: n, end: t });
46
45
  }
47
- if (l && w) {
48
- const s = ee(l, w) ? l : w, c = te(w, l) ? w : l;
49
- return ye(a, { start: s, end: c });
46
+ if (o && f) {
47
+ const n = N(o, f) ? o : f, t = T(f, o) ? f : o;
48
+ return L(e, { start: n, end: t });
50
49
  }
51
50
  return !1;
52
- }, j = (a) => !!(l && X(a, l) || u && X(a, u)), K = (a) => {
53
- if (!A.current) return;
54
- const s = D(a, "yyyy-MM-dd"), c = A.current.querySelector(
55
- `[data-date="${s}"]`
51
+ }, ee = (e) => !!(o && x(e, o) || l && x(e, l)), te = (e) => {
52
+ if (!M.current) return;
53
+ const n = m(e, "yyyy-MM-dd"), t = M.current.querySelector(
54
+ `[data-date="${n}"]`
56
55
  );
57
- c ? c.focus() : v(q(a));
58
- }, F = (a) => {
59
- const c = a.target.getAttribute("data-date");
60
- if (!c) return;
61
- const n = /* @__PURE__ */ new Date(c + "T00:00:00");
62
- let o = null;
63
- switch (a.key) {
56
+ t ? t.focus() : u(k(e));
57
+ }, se = (e) => {
58
+ const t = e.target.getAttribute("data-date");
59
+ if (!t) return;
60
+ const s = /* @__PURE__ */ new Date(t + "T00:00:00");
61
+ let r = null;
62
+ switch (e.key) {
64
63
  case "ArrowLeft":
65
- o = G(n, -1);
64
+ r = b(s, -1);
66
65
  break;
67
66
  case "ArrowRight":
68
- o = G(n, 1);
67
+ r = b(s, 1);
69
68
  break;
70
69
  case "ArrowUp":
71
- o = G(n, -7);
70
+ r = b(s, -7);
72
71
  break;
73
72
  case "ArrowDown":
74
- o = G(n, 7);
73
+ r = b(s, 7);
75
74
  break;
76
75
  case "Home":
77
- o = q(n);
76
+ r = k(s);
78
77
  break;
79
78
  case "End":
80
- o = Re(n);
79
+ r = le(s);
81
80
  break;
82
81
  case "Enter":
83
82
  case " ": {
84
- a.preventDefault(), !I(n) && xe(n, e) && x(n);
83
+ e.preventDefault(), !I(s) && Y(s, c) && v(s);
85
84
  return;
86
85
  }
87
86
  default:
88
87
  return;
89
88
  }
90
- o && (a.preventDefault(), K(o));
89
+ r && (e.preventDefault(), te(r));
91
90
  };
92
- return /* @__PURE__ */ M("div", { ref: r, ...g, className: S("w-[252px]", h), children: [
93
- /* @__PURE__ */ M("div", { className: "flex items-center justify-between px-ds-02 pb-ds-04", children: [
94
- T ? /* @__PURE__ */ t("span", { className: "h-ds-xs-plus w-ds-xs-plus" }) : /* @__PURE__ */ t(
91
+ return /* @__PURE__ */ y("div", { ref: J, ...$, className: C("w-[252px]", U), children: [
92
+ /* @__PURE__ */ y("div", { className: "flex items-center justify-between px-ds-02 pb-ds-04", children: [
93
+ F ? /* @__PURE__ */ i("span", { className: "h-ds-xs-plus w-ds-xs-plus" }) : /* @__PURE__ */ i(
95
94
  "button",
96
95
  {
97
96
  type: "button",
98
- onClick: () => v(be(e, 1)),
97
+ onClick: () => u(z(c, 1)),
99
98
  className: "inline-flex h-ds-xs-plus w-ds-xs-plus items-center justify-center rounded-ds-md text-surface-fg-subtle transition-colors duration-fast-01 ease-productive-standard hover:bg-surface-raised-hover hover:text-surface-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9",
100
99
  "aria-label": "Previous month",
101
- children: /* @__PURE__ */ t(B, { icon: Ye, size: "sm", stroke: "light" })
100
+ children: /* @__PURE__ */ i(P, { icon: me, size: "sm", stroke: "light" })
102
101
  }
103
102
  ),
104
- /* @__PURE__ */ t(
103
+ /* @__PURE__ */ i(
105
104
  "button",
106
105
  {
107
106
  type: "button",
108
- onClick: H,
109
- className: S(
107
+ onClick: R,
108
+ className: C(
110
109
  "text-ds-md font-semibold text-surface-fg",
111
- H && "cursor-pointer rounded-ds-md px-ds-02 transition-colors duration-fast-01 ease-productive-standard hover:bg-surface-raised-hover"
110
+ R && "cursor-pointer rounded-ds-md px-ds-02 transition-colors duration-fast-01 ease-productive-standard hover:bg-surface-raised-hover"
112
111
  ),
113
112
  "aria-label": "Switch to month/year view",
114
- children: D(e, "MMMM yyyy")
113
+ children: m(c, "MMMM yyyy")
115
114
  }
116
115
  ),
117
- y ? /* @__PURE__ */ t("span", { className: "h-ds-xs-plus w-ds-xs-plus" }) : /* @__PURE__ */ t(
116
+ S ? /* @__PURE__ */ i("span", { className: "h-ds-xs-plus w-ds-xs-plus" }) : /* @__PURE__ */ i(
118
117
  "button",
119
118
  {
120
119
  type: "button",
121
- onClick: () => v(se(e, 1)),
120
+ onClick: () => u(B(c, 1)),
122
121
  className: "inline-flex h-ds-xs-plus w-ds-xs-plus items-center justify-center rounded-ds-md text-surface-fg-subtle transition-colors duration-fast-01 ease-productive-standard hover:bg-surface-raised-hover hover:text-surface-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9",
123
122
  "aria-label": "Next month",
124
- children: /* @__PURE__ */ t(B, { icon: He, size: "sm", stroke: "light" })
123
+ children: /* @__PURE__ */ i(P, { icon: pe, size: "sm", stroke: "light" })
125
124
  }
126
125
  )
127
126
  ] }),
128
- /* @__PURE__ */ M(
127
+ /* @__PURE__ */ y(
129
128
  "div",
130
129
  {
131
- ref: A,
130
+ ref: M,
132
131
  className: "grid grid-cols-7 gap-0",
133
132
  role: "grid",
134
133
  tabIndex: 0,
135
134
  "aria-label": "Calendar",
136
- onKeyDown: F,
135
+ onKeyDown: se,
137
136
  children: [
138
- Le.map((a) => /* @__PURE__ */ t(
137
+ be.map((e) => /* @__PURE__ */ i(
139
138
  "div",
140
139
  {
141
140
  role: "columnheader",
142
141
  className: "flex h-ds-sm items-center justify-center text-ds-xs font-semibold uppercase tracking-wider text-surface-fg-subtle",
143
- children: a
142
+ children: e
144
143
  },
145
- a
144
+ e
146
145
  )),
147
- $.map((a, s) => {
148
- const c = xe(a, e), n = I(a), o = d && X(a, d), i = z(a), P = j(a), ue = X(a, /* @__PURE__ */ new Date()), me = D(a, "yyyy-MM-dd"), pe = N.get(me) ?? [];
149
- return /* @__PURE__ */ M(
146
+ E.map((e, n) => {
147
+ const t = Y(e, c), s = I(e), r = d && x(e, d), O = H(e), p = ee(e), oe = x(e, /* @__PURE__ */ new Date()), W = m(e, "yyyy-MM-dd"), K = Q.get(W) ?? [];
148
+ return /* @__PURE__ */ y(
150
149
  "button",
151
150
  {
152
151
  type: "button",
153
152
  role: "gridcell",
154
- "data-date": me,
155
- tabIndex: c && !n ? 0 : -1,
156
- disabled: !c || n,
153
+ "data-date": W,
154
+ tabIndex: t && !s ? 0 : -1,
155
+ disabled: !t || s,
157
156
  onClick: () => {
158
- c && !n && x(a);
157
+ t && !s && v(e);
159
158
  },
160
- onMouseEnter: () => m?.(a),
161
- onMouseLeave: () => m?.(null),
162
- "aria-label": D(a, "EEEE, MMMM d, yyyy"),
163
- "aria-selected": o || P || void 0,
164
- "aria-disabled": !c || n || void 0,
165
- className: S(
159
+ onMouseEnter: () => a?.(e),
160
+ onMouseLeave: () => a?.(null),
161
+ "aria-label": m(e, "EEEE, MMMM d, yyyy"),
162
+ "aria-selected": r || p || void 0,
163
+ "aria-disabled": !t || s || void 0,
164
+ className: C(
166
165
  "relative flex h-ds-sm w-ds-sm-plus items-center justify-center rounded-ds-md text-ds-md font-body transition-colors duration-fast-01 ease-productive-standard",
167
- !c && "pointer-events-none opacity-0",
168
- c && n && "opacity-action-disabled pointer-events-none cursor-not-allowed",
169
- c && !n && !o && !P && !i && "text-surface-fg hover:bg-surface-raised-hover",
170
- i && !P && "rounded-ds-none bg-surface-raised-hover text-surface-fg",
171
- (o || P) && "bg-accent-9 text-accent-fg hover:bg-accent-10",
172
- ue && !o && !P && !n && "font-semibold text-accent-11"
166
+ !t && "pointer-events-none opacity-0",
167
+ t && s && "opacity-action-disabled pointer-events-none cursor-not-allowed",
168
+ t && !s && !r && !p && !O && "text-surface-fg hover:bg-surface-raised-hover",
169
+ O && !p && "rounded-ds-none bg-surface-raised-hover text-surface-fg",
170
+ (r || p) && "bg-accent-9 text-accent-fg hover:bg-accent-10",
171
+ oe && !r && !p && !s && "font-semibold text-accent-11"
173
172
  ),
174
173
  children: [
175
- D(a, "d"),
176
- pe.length > 0 && /* @__PURE__ */ t("span", { className: "flex gap-px justify-center absolute bottom-[2px] left-0 right-0", children: pe.slice(0, 3).map((Ne, Se) => /* @__PURE__ */ t(
174
+ m(e, "d"),
175
+ K.length > 0 && /* @__PURE__ */ i("span", { className: "flex gap-px justify-center absolute bottom-[2px] left-0 right-0", children: K.slice(0, 3).map((re, ne) => /* @__PURE__ */ i(
177
176
  "span",
178
177
  {
179
178
  "data-event-dot": !0,
180
179
  className: "h-[4px] w-[4px] rounded-ds-full",
181
- style: { backgroundColor: Ne.color ?? "var(--color-accent-9)" }
180
+ style: { backgroundColor: re.color ?? "var(--color-accent-9)" }
182
181
  },
183
- Se
182
+ ne
184
183
  )) })
185
184
  ]
186
185
  },
187
- s
186
+ n
188
187
  );
189
188
  })
190
189
  ]
@@ -193,859 +192,19 @@ const Le = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], Q = b.forwardRef(
193
192
  ] });
194
193
  }
195
194
  );
196
- Q.displayName = "CalendarGrid";
197
- const ie = b.forwardRef(
198
- function({
199
- currentYear: e,
200
- selectedYear: d,
201
- onYearSelect: l,
202
- minDate: u,
203
- maxDate: w,
204
- className: x,
205
- ...m
206
- }, v) {
207
- const C = Math.floor(e / 10) * 10, O = Array.from({ length: 12 }, (g, r) => C + r), [k, T] = b.useState(() => {
208
- const g = O.indexOf(d ?? e);
209
- return g >= 0 ? g : 0;
210
- }), y = b.useRef([]), p = (g) => u != null && g < u.getFullYear() || w != null && g > w.getFullYear(), h = (g) => {
211
- let r = k;
212
- switch (g.key) {
213
- case "ArrowRight":
214
- r = Math.min(11, k + 1);
215
- break;
216
- case "ArrowLeft":
217
- r = Math.max(0, k - 1);
218
- break;
219
- case "ArrowDown":
220
- r = Math.min(11, k + 3);
221
- break;
222
- case "ArrowUp":
223
- r = Math.max(0, k - 3);
224
- break;
225
- case "Home":
226
- r = 0;
227
- break;
228
- case "End":
229
- r = 11;
230
- break;
231
- default:
232
- return;
233
- }
234
- for (g.preventDefault(); r !== k && p(O[r]); )
235
- if (r += g.key === "ArrowLeft" || g.key === "ArrowUp" ? -1 : 1, r < 0 || r > 11) return;
236
- T(r), y.current[r]?.focus();
237
- };
238
- return /* @__PURE__ */ M("div", { ref: v, ...m, className: S("w-[252px]", x), children: [
239
- /* @__PURE__ */ M("div", { className: "text-center pb-ds-04 text-ds-md font-semibold text-surface-fg", children: [
240
- C,
241
- " – ",
242
- C + 11
243
- ] }),
244
- /* @__PURE__ */ t("div", { role: "grid", "aria-label": "Year picker", tabIndex: -1, onKeyDown: h, children: [0, 1, 2, 3].map((g) => /* @__PURE__ */ t("div", { role: "row", className: "grid grid-cols-3 gap-ds-02 mb-ds-02 last:mb-0", children: O.slice(g * 3, g * 3 + 3).map((r) => {
245
- const A = O.indexOf(r), N = r === d, Y = p(r);
246
- return /* @__PURE__ */ t(
247
- "button",
248
- {
249
- ref: (R) => {
250
- y.current[A] = R;
251
- },
252
- type: "button",
253
- role: "gridcell",
254
- tabIndex: A === k ? 0 : -1,
255
- disabled: Y || !1,
256
- onClick: () => !Y && l(r),
257
- className: S(
258
- "h-ds-sm-plus rounded-ds-md text-ds-md transition-colors focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
259
- Y && "opacity-action-disabled pointer-events-none cursor-not-allowed",
260
- N && "bg-accent-9 text-accent-fg",
261
- !N && !Y && "hover:bg-surface-raised-hover text-surface-fg"
262
- ),
263
- children: r
264
- },
265
- r
266
- );
267
- }) }, g)) })
268
- ] });
269
- }
270
- );
271
- ie.displayName = "YearPicker";
272
- const Ee = [
273
- "Jan",
274
- "Feb",
275
- "Mar",
276
- "Apr",
277
- "May",
278
- "Jun",
279
- "Jul",
280
- "Aug",
281
- "Sep",
282
- "Oct",
283
- "Nov",
284
- "Dec"
285
- ], de = b.forwardRef(
286
- function({
287
- currentYear: e,
288
- selectedMonth: d,
289
- onMonthSelect: l,
290
- minDate: u,
291
- maxDate: w,
292
- className: x,
293
- ...m
294
- }, v) {
295
- const [C, O] = b.useState(d ?? 0), k = b.useRef([]), T = (p) => u != null && (e < u.getFullYear() || e === u.getFullYear() && p < u.getMonth()) || w != null && (e > w.getFullYear() || e === w.getFullYear() && p > w.getMonth()), y = (p) => {
296
- let h = C;
297
- switch (p.key) {
298
- case "ArrowRight":
299
- h = Math.min(11, C + 1);
300
- break;
301
- case "ArrowLeft":
302
- h = Math.max(0, C - 1);
303
- break;
304
- case "ArrowDown":
305
- h = Math.min(11, C + 4);
306
- break;
307
- case "ArrowUp":
308
- h = Math.max(0, C - 4);
309
- break;
310
- case "Home":
311
- h = 0;
312
- break;
313
- case "End":
314
- h = 11;
315
- break;
316
- default:
317
- return;
318
- }
319
- for (p.preventDefault(); h !== C && T(h); )
320
- if (h += p.key === "ArrowLeft" || p.key === "ArrowUp" ? -1 : 1, h < 0 || h > 11) return;
321
- O(h), k.current[h]?.focus();
322
- };
323
- return /* @__PURE__ */ M("div", { ref: v, ...m, className: S("w-[252px]", x), children: [
324
- /* @__PURE__ */ t("div", { className: "text-center pb-ds-04 text-ds-md font-semibold text-surface-fg", children: e }),
325
- /* @__PURE__ */ t("div", { role: "grid", "aria-label": "Month picker", tabIndex: -1, onKeyDown: y, children: [0, 1, 2].map((p) => /* @__PURE__ */ t("div", { role: "row", className: "grid grid-cols-4 gap-ds-02 mb-ds-02 last:mb-0", children: Ee.slice(p * 4, p * 4 + 4).map((h, g) => {
326
- const r = p * 4 + g, A = r === d, N = T(r);
327
- return /* @__PURE__ */ t(
328
- "button",
329
- {
330
- ref: (Y) => {
331
- k.current[r] = Y;
332
- },
333
- type: "button",
334
- role: "gridcell",
335
- tabIndex: r === C ? 0 : -1,
336
- disabled: N || !1,
337
- onClick: () => !N && l(r),
338
- className: S(
339
- "h-ds-sm-plus rounded-ds-md text-ds-md transition-colors focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
340
- N && "opacity-action-disabled pointer-events-none cursor-not-allowed",
341
- A && "bg-accent-9 text-accent-fg",
342
- !A && !N && "hover:bg-surface-raised-hover text-surface-fg"
343
- ),
344
- children: h
345
- },
346
- h
347
- );
348
- }) }, p)) })
349
- ] });
350
- }
351
- );
352
- de.displayName = "MonthPicker";
353
- const Ie = b.forwardRef(
354
- function({
355
- value: e,
356
- onChange: d,
357
- placeholder: l = "Pick a date",
358
- className: u,
359
- formatStr: w = "MMM d, yyyy",
360
- minDate: x,
361
- maxDate: m,
362
- disabledDates: v,
363
- ...H
364
- }, C) {
365
- const [O, k] = b.useState(!1), [T, y] = b.useState(
366
- e ?? /* @__PURE__ */ new Date()
367
- ), [p, h] = b.useState("days");
368
- b.useEffect(() => {
369
- O || h("days");
370
- }, [O]);
371
- const g = (R) => {
372
- d?.(R), k(!1);
373
- }, r = () => {
374
- h((R) => R === "days" ? "months" : "years");
375
- }, A = (R) => {
376
- y((L) => re(L, R)), h("days");
377
- }, N = (R) => {
378
- y((L) => ae(L, R)), h("months");
379
- }, Y = () => {
380
- switch (p) {
381
- case "years":
382
- return /* @__PURE__ */ t(
383
- ie,
384
- {
385
- currentYear: T.getFullYear(),
386
- selectedYear: e?.getFullYear(),
387
- onYearSelect: N,
388
- minDate: x,
389
- maxDate: m
390
- }
391
- );
392
- case "months":
393
- return /* @__PURE__ */ t(
394
- de,
395
- {
396
- currentYear: T.getFullYear(),
397
- selectedMonth: e?.getMonth(),
398
- onMonthSelect: A,
399
- minDate: x,
400
- maxDate: m
401
- }
402
- );
403
- default:
404
- return /* @__PURE__ */ t(
405
- Q,
406
- {
407
- currentMonth: T,
408
- selected: e,
409
- onSelect: g,
410
- onMonthChange: y,
411
- onHeaderClick: r,
412
- disabledDates: v,
413
- minDate: x,
414
- maxDate: m
415
- }
416
- );
417
- }
418
- };
419
- return /* @__PURE__ */ M(oe, { open: O, onOpenChange: k, children: [
420
- /* @__PURE__ */ t(ce, { asChild: !0, children: /* @__PURE__ */ M(
421
- "button",
422
- {
423
- ref: C,
424
- type: "button",
425
- "aria-label": e ? `Change date, ${D(e, w)}` : l,
426
- ...H,
427
- className: S(
428
- "inline-flex h-ds-sm-plus items-center gap-ds-03 rounded-ds-lg border border-surface-border-strong bg-surface-overlay px-ds-04 text-left transition-colors duration-fast-01 ease-productive-standard",
429
- "hover:border-surface-border-strong",
430
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
431
- u
432
- ),
433
- children: [
434
- /* @__PURE__ */ t(B, { icon: ve, size: "sm", stroke: "light", className: "text-surface-fg-subtle" }),
435
- /* @__PURE__ */ t(
436
- "span",
437
- {
438
- className: S(
439
- "text-ds-md",
440
- e ? "text-surface-fg" : "text-surface-fg-subtle"
441
- ),
442
- children: e ? D(e, w) : l
443
- }
444
- )
445
- ]
446
- }
447
- ) }),
448
- /* @__PURE__ */ t(
449
- le,
450
- {
451
- className: "w-auto border-surface-border-strong bg-surface-overlay p-ds-04",
452
- align: "start",
453
- sideOffset: 4,
454
- children: Y()
455
- }
456
- )
457
- ] });
458
- }
459
- );
460
- Ie.displayName = "DatePicker";
461
- const $e = {
462
- today: {
463
- label: "Today",
464
- getRange: () => {
465
- const f = /* @__PURE__ */ new Date();
466
- return { start: V(f), end: J(f) };
467
- }
468
- },
469
- yesterday: {
470
- label: "Yesterday",
471
- getRange: () => {
472
- const f = fe(/* @__PURE__ */ new Date(), 1);
473
- return { start: V(f), end: J(f) };
474
- }
475
- },
476
- last7days: {
477
- label: "Last 7 days",
478
- getRange: () => {
479
- const f = /* @__PURE__ */ new Date();
480
- return { start: V(fe(f, 6)), end: J(f) };
481
- }
482
- },
483
- last30days: {
484
- label: "Last 30 days",
485
- getRange: () => {
486
- const f = /* @__PURE__ */ new Date();
487
- return { start: V(fe(f, 29)), end: J(f) };
488
- }
489
- },
490
- thisMonth: {
491
- label: "This month",
492
- getRange: () => {
493
- const f = /* @__PURE__ */ new Date();
494
- return { start: q(f), end: ge(f) };
495
- }
496
- },
497
- lastMonth: {
498
- label: "Last month",
499
- getRange: () => {
500
- const e = be(/* @__PURE__ */ new Date(), 1);
501
- return { start: q(e), end: ge(e) };
502
- }
503
- },
504
- thisYear: {
505
- label: "This year",
506
- getRange: () => {
507
- const f = /* @__PURE__ */ new Date();
508
- return { start: Oe(f), end: J(f) };
509
- }
510
- }
511
- }, ke = b.forwardRef(
512
- function({ presets: e, onSelect: d, className: l, ...u }, w) {
513
- return /* @__PURE__ */ t("div", { ref: w, ...u, className: S("flex flex-col gap-ds-01", l), children: e.map((x) => {
514
- const m = $e[x];
515
- return m ? /* @__PURE__ */ t(
516
- "button",
517
- {
518
- type: "button",
519
- onClick: () => {
520
- const { start: v, end: H } = m.getRange();
521
- d(v, H);
522
- },
523
- className: S(
524
- "h-ds-sm w-full rounded-ds-md px-ds-03 text-left text-ds-sm",
525
- "text-surface-fg transition-colors",
526
- "hover:bg-surface-raised-hover",
527
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9"
528
- ),
529
- children: m.label
530
- },
531
- x
532
- ) : null;
533
- }) });
534
- }
535
- );
536
- ke.displayName = "Presets";
537
- const je = b.forwardRef(
538
- function({
539
- startDate: e,
540
- endDate: d,
541
- onChange: l,
542
- placeholder: u = "Pick a date range",
543
- className: w,
544
- formatStr: x = "MMM d, yyyy",
545
- minDate: m,
546
- maxDate: v,
547
- disabledDates: H,
548
- presets: C,
549
- numberOfMonths: O = 1,
550
- ...k
551
- }, T) {
552
- const [y, p] = b.useState(!1), [h, g] = b.useState(
553
- e ?? /* @__PURE__ */ new Date()
554
- ), [r, A] = b.useState(
555
- e ?? null
556
- ), [N, Y] = b.useState(
557
- d ?? null
558
- ), [R, L] = b.useState(null), [U, $] = b.useState("days"), E = Math.max(1, O);
559
- b.useEffect(() => {
560
- A(e ?? null), Y(d ?? null);
561
- }, [e, d]), b.useEffect(() => {
562
- y || $("days");
563
- }, [y]);
564
- const I = (o) => {
565
- if (!r || r && N)
566
- A(o), Y(null);
567
- else {
568
- const i = ee(o, r) ? o : r, P = te(o, r) ? o : r;
569
- A(i), Y(P), l?.({ start: i, end: P }), p(!1);
570
- }
571
- }, z = (o, i) => {
572
- A(o), Y(i), l?.({ start: o, end: i }), p(!1);
573
- }, j = () => {
574
- $((o) => o === "days" ? "months" : "years");
575
- }, K = (o) => {
576
- g((i) => re(i, o)), $("days");
577
- }, F = (o) => {
578
- g((i) => ae(i, o)), $("months");
579
- }, a = () => r && N ? `${D(r, x)} - ${D(N, x)}` : u, s = () => E === 1 ? /* @__PURE__ */ t(
580
- Q,
581
- {
582
- currentMonth: h,
583
- rangeStart: r,
584
- rangeEnd: N,
585
- hoverDate: R,
586
- onSelect: I,
587
- onHover: L,
588
- onMonthChange: g,
589
- onHeaderClick: j,
590
- disabledDates: H,
591
- minDate: m,
592
- maxDate: v
593
- }
594
- ) : /* @__PURE__ */ t("div", { className: "flex flex-row gap-ds-04", children: Array.from({ length: E }, (o, i) => /* @__PURE__ */ t(
595
- Q,
596
- {
597
- currentMonth: se(h, i),
598
- rangeStart: r,
599
- rangeEnd: N,
600
- hoverDate: R,
601
- onSelect: I,
602
- onHover: L,
603
- onMonthChange: (P) => {
604
- g(se(P, -i));
605
- },
606
- onHeaderClick: j,
607
- disabledDates: H,
608
- minDate: m,
609
- maxDate: v,
610
- hidePrevNav: i > 0,
611
- hideNextNav: i < E - 1
612
- },
613
- i
614
- )) }), c = () => {
615
- switch (U) {
616
- case "years":
617
- return /* @__PURE__ */ t(
618
- ie,
619
- {
620
- currentYear: h.getFullYear(),
621
- selectedYear: r?.getFullYear(),
622
- onYearSelect: F,
623
- minDate: m,
624
- maxDate: v
625
- }
626
- );
627
- case "months":
628
- return /* @__PURE__ */ t(
629
- de,
630
- {
631
- currentYear: h.getFullYear(),
632
- selectedMonth: r?.getMonth(),
633
- onMonthSelect: K,
634
- minDate: m,
635
- maxDate: v
636
- }
637
- );
638
- default:
639
- return s();
640
- }
641
- }, n = C && C.length > 0;
642
- return /* @__PURE__ */ M(oe, { open: y, onOpenChange: p, children: [
643
- /* @__PURE__ */ t(ce, { asChild: !0, children: /* @__PURE__ */ M(
644
- "button",
645
- {
646
- ref: T,
647
- type: "button",
648
- "aria-label": r && N ? `Change date range, ${a()}` : u,
649
- ...k,
650
- className: S(
651
- "inline-flex h-ds-sm-plus items-center gap-ds-03 rounded-ds-lg border border-surface-border-strong bg-surface-overlay px-ds-04 text-left transition-colors duration-fast-01 ease-productive-standard",
652
- "hover:border-surface-border-strong",
653
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
654
- w
655
- ),
656
- children: [
657
- /* @__PURE__ */ t(B, { icon: ve, size: "sm", stroke: "light", className: "text-surface-fg-subtle" }),
658
- /* @__PURE__ */ t(
659
- "span",
660
- {
661
- className: S(
662
- "text-ds-md",
663
- r && N ? "text-surface-fg" : "text-surface-fg-subtle"
664
- ),
665
- children: a()
666
- }
667
- )
668
- ]
669
- }
670
- ) }),
671
- /* @__PURE__ */ t(
672
- le,
673
- {
674
- className: "w-auto border-surface-border-strong bg-surface-overlay p-ds-04",
675
- align: "start",
676
- sideOffset: 4,
677
- children: n ? /* @__PURE__ */ M("div", { className: "flex flex-row gap-ds-04", children: [
678
- /* @__PURE__ */ t("div", { className: "min-w-[140px] border-r border-surface-border-strong pr-ds-04", children: /* @__PURE__ */ t(ke, { presets: C, onSelect: z }) }),
679
- /* @__PURE__ */ t("div", { children: c() })
680
- ] }) : c()
681
- }
682
- )
683
- ] });
684
- }
685
- );
686
- je.displayName = "DateRangePicker";
687
- function Z(f, e, d) {
688
- const l = [];
689
- for (let u = f; u <= e; u += d)
690
- l.push(u);
691
- return l;
692
- }
693
- function _(f) {
694
- return f.toString().padStart(2, "0");
695
- }
696
- const Ke = b.forwardRef(
697
- function({
698
- value: e,
699
- onChange: d,
700
- format: l = "12h",
701
- minuteStep: u = 1,
702
- secondStep: w = 1,
703
- showSeconds: x = !1,
704
- placeholder: m = "Pick a time",
705
- className: v,
706
- disabled: H = !1,
707
- ...C
708
- }, O) {
709
- const [k, T] = b.useState(!1), y = e ? e.getHours() : null, p = e ? e.getMinutes() : null, h = e ? e.getSeconds() : null, g = y !== null ? y >= 12 ? "PM" : "AM" : null, r = y !== null ? y === 0 ? 12 : y > 12 ? y - 12 : y : null, A = l === "12h" ? Z(1, 12, 1) : Z(0, 23, 1), N = Z(0, 59, u), Y = Z(0, 59, w), R = (s) => {
710
- const c = e ? new Date(e) : /* @__PURE__ */ new Date();
711
- let n = s.hours ?? c.getHours();
712
- const o = s.minutes ?? c.getMinutes(), i = s.seconds ?? c.getSeconds();
713
- l === "12h" && s.hours !== void 0 && ((s.ampm ?? g ?? "AM") === "AM" ? n = s.hours === 12 ? 0 : s.hours : n = s.hours === 12 ? 12 : s.hours + 12);
714
- let P = W(c, n);
715
- return P = ne(P, o), P = Me(P, i), P;
716
- }, L = (s) => {
717
- const c = R({ hours: s });
718
- d?.(c);
719
- }, U = (s) => {
720
- const c = R({ minutes: s });
721
- d?.(c);
722
- }, $ = (s) => {
723
- const c = R({ seconds: s });
724
- d?.(c);
725
- }, E = (s) => {
726
- if (!e) {
727
- const o = s === "AM" ? 0 : 12;
728
- let i = /* @__PURE__ */ new Date();
729
- i = W(i, o), i = ne(i, 0), i = Me(i, 0), d?.(i);
730
- return;
731
- }
732
- const c = e.getHours();
733
- let n;
734
- s === "AM" ? n = c >= 12 ? c - 12 : c : n = c < 12 ? c + 12 : c, d?.(W(new Date(e), n));
735
- }, I = b.useMemo(() => e ? l === "12h" ? D(e, x ? "h:mm:ss a" : "h:mm a") : D(e, x ? "HH:mm:ss" : "HH:mm") : null, [e, l, x]), z = l === "12h" ? r : y, j = "flex flex-col gap-ds-01 overflow-y-auto max-h-[200px] px-ds-01", K = "flex h-ds-sm w-full items-center justify-center rounded-ds-md text-ds-md transition-colors duration-fast-01 ease-productive-standard cursor-pointer", F = "bg-accent-9 text-accent-fg", a = "text-surface-fg hover:bg-surface-raised-hover";
736
- return /* @__PURE__ */ M(oe, { open: k, onOpenChange: T, children: [
737
- /* @__PURE__ */ t(ce, { asChild: !0, children: /* @__PURE__ */ M(
738
- "button",
739
- {
740
- ref: O,
741
- type: "button",
742
- disabled: H,
743
- ...C,
744
- className: S(
745
- "inline-flex h-ds-sm-plus items-center gap-ds-03 rounded-ds-lg border border-surface-border-strong bg-surface-overlay px-ds-04 text-left transition-colors duration-fast-01 ease-productive-standard",
746
- "hover:border-surface-border-strong",
747
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
748
- H && "opacity-action-disabled pointer-events-none",
749
- v
750
- ),
751
- "aria-label": I ? `Selected time: ${I}` : m,
752
- children: [
753
- /* @__PURE__ */ t(B, { icon: Te, size: "sm", stroke: "light", className: "text-surface-fg-subtle" }),
754
- /* @__PURE__ */ t(
755
- "span",
756
- {
757
- className: S(
758
- "text-ds-md",
759
- I ? "text-surface-fg" : "text-surface-fg-subtle"
760
- ),
761
- children: I ?? m
762
- }
763
- )
764
- ]
765
- }
766
- ) }),
767
- /* @__PURE__ */ t(
768
- le,
769
- {
770
- className: "w-auto border-surface-border-strong bg-surface-overlay p-ds-04",
771
- align: "start",
772
- sideOffset: 4,
773
- children: /* @__PURE__ */ M("div", { className: "flex gap-ds-03", role: "group", "aria-label": "Time picker", children: [
774
- /* @__PURE__ */ M("div", { className: "flex flex-col items-center gap-ds-02", children: [
775
- /* @__PURE__ */ t("span", { className: "text-ds-xs font-semibold uppercase tracking-wider text-surface-fg-subtle", children: "Hr" }),
776
- /* @__PURE__ */ t("div", { className: S(j, "min-w-[48px]"), children: A.map((s) => /* @__PURE__ */ t(
777
- "button",
778
- {
779
- type: "button",
780
- onClick: () => L(s),
781
- className: S(
782
- K,
783
- z === s ? F : a
784
- ),
785
- "aria-label": `${s} hours`,
786
- "aria-selected": z === s || void 0,
787
- children: l === "24h" ? _(s) : s
788
- },
789
- s
790
- )) })
791
- ] }),
792
- /* @__PURE__ */ M("div", { className: "flex flex-col items-center gap-ds-02", children: [
793
- /* @__PURE__ */ t("span", { className: "text-ds-xs font-semibold uppercase tracking-wider text-surface-fg-subtle", children: "Min" }),
794
- /* @__PURE__ */ t("div", { className: S(j, "min-w-[48px]"), children: N.map((s) => /* @__PURE__ */ t(
795
- "button",
796
- {
797
- type: "button",
798
- onClick: () => U(s),
799
- className: S(
800
- K,
801
- p === s ? F : a
802
- ),
803
- "aria-label": `${_(s)} minutes`,
804
- "aria-selected": p === s || void 0,
805
- children: _(s)
806
- },
807
- s
808
- )) })
809
- ] }),
810
- x && /* @__PURE__ */ M("div", { className: "flex flex-col items-center gap-ds-02", children: [
811
- /* @__PURE__ */ t("span", { className: "text-ds-xs font-semibold uppercase tracking-wider text-surface-fg-subtle", children: "Sec" }),
812
- /* @__PURE__ */ t("div", { className: S(j, "min-w-[48px]"), children: Y.map((s) => /* @__PURE__ */ t(
813
- "button",
814
- {
815
- type: "button",
816
- onClick: () => $(s),
817
- className: S(
818
- K,
819
- h === s ? F : a
820
- ),
821
- "aria-label": `${_(s)} seconds`,
822
- "aria-selected": h === s || void 0,
823
- children: _(s)
824
- },
825
- s
826
- )) })
827
- ] }),
828
- l === "12h" && /* @__PURE__ */ M("div", { className: "flex flex-col items-center gap-ds-02", children: [
829
- /* @__PURE__ */ t("span", { className: "text-ds-xs font-semibold uppercase tracking-wider text-surface-fg-subtle", children: " " }),
830
- /* @__PURE__ */ t("div", { className: "flex flex-col gap-ds-01 px-ds-01", children: ["AM", "PM"].map((s) => /* @__PURE__ */ t(
831
- "button",
832
- {
833
- type: "button",
834
- onClick: () => E(s),
835
- className: S(
836
- K,
837
- "min-w-[44px] font-semibold",
838
- g === s ? F : a
839
- ),
840
- "aria-label": s,
841
- "aria-selected": g === s || void 0,
842
- children: s
843
- },
844
- s
845
- )) })
846
- ] })
847
- ] })
848
- }
849
- )
850
- ] });
851
- }
852
- );
853
- Ke.displayName = "TimePicker";
854
- function we(f) {
855
- return f.toString().padStart(2, "0");
856
- }
857
- function he(f, e, d) {
858
- const l = [];
859
- for (let u = f; u <= e; u += d)
860
- l.push(u);
861
- return l;
862
- }
863
- const Fe = b.forwardRef(
864
- function({
865
- value: e,
866
- onChange: d,
867
- minDate: l,
868
- maxDate: u,
869
- disabledDates: w,
870
- timeFormat: x = "12h",
871
- minuteStep: m = 1,
872
- placeholder: v = "Pick date & time",
873
- className: H,
874
- ...C
875
- }, O) {
876
- const [k, T] = b.useState(!1), [y, p] = b.useState(e ?? /* @__PURE__ */ new Date()), [h, g] = b.useState("days");
877
- b.useEffect(() => {
878
- k || g("days");
879
- }, [k]);
880
- const r = e ? e.getHours() : 0, A = e ? e.getMinutes() : 0, N = r >= 12 ? "PM" : "AM", Y = r === 0 ? 12 : r > 12 ? r - 12 : r, R = x === "12h" ? he(1, 12, 1) : he(0, 23, 1), L = he(0, 59, m), U = x === "12h" ? Y : r, $ = (n) => {
881
- let o = W(n, e ? e.getHours() : r);
882
- o = ne(o, e ? e.getMinutes() : A), d?.(o);
883
- }, E = () => {
884
- g((n) => n === "days" ? "months" : "years");
885
- }, I = (n) => {
886
- p((o) => re(o, n)), g("days");
887
- }, z = (n) => {
888
- p((o) => ae(o, n)), g("months");
889
- }, j = (n) => {
890
- const o = e ? new Date(e) : /* @__PURE__ */ new Date();
891
- let i = n;
892
- x === "12h" && ((e ? N : "AM") === "AM" ? i = n === 12 ? 0 : n : i = n === 12 ? 12 : n + 12);
893
- const P = W(o, i);
894
- d?.(P);
895
- }, K = (n) => {
896
- const o = e ? new Date(e) : /* @__PURE__ */ new Date(), i = ne(o, n);
897
- d?.(i);
898
- }, F = (n) => {
899
- const o = e ? new Date(e) : /* @__PURE__ */ new Date(), i = o.getHours();
900
- let P;
901
- n === "AM" ? P = i >= 12 ? i - 12 : i : P = i < 12 ? i + 12 : i, d?.(W(o, P));
902
- }, a = b.useMemo(() => e ? D(e, x === "12h" ? "MMM d, yyyy h:mm a" : "MMM d, yyyy HH:mm") : null, [e, x]), s = () => {
903
- switch (h) {
904
- case "years":
905
- return /* @__PURE__ */ t(
906
- ie,
907
- {
908
- currentYear: y.getFullYear(),
909
- selectedYear: e?.getFullYear(),
910
- onYearSelect: z,
911
- minDate: l,
912
- maxDate: u
913
- }
914
- );
915
- case "months":
916
- return /* @__PURE__ */ t(
917
- de,
918
- {
919
- currentYear: y.getFullYear(),
920
- selectedMonth: e?.getMonth(),
921
- onMonthSelect: I,
922
- minDate: l,
923
- maxDate: u
924
- }
925
- );
926
- default:
927
- return /* @__PURE__ */ t(
928
- Q,
929
- {
930
- currentMonth: y,
931
- selected: e,
932
- onSelect: $,
933
- onMonthChange: p,
934
- onHeaderClick: E,
935
- disabledDates: w,
936
- minDate: l,
937
- maxDate: u
938
- }
939
- );
940
- }
941
- }, c = "h-ds-sm rounded-ds-md border border-surface-border-strong bg-surface-overlay px-ds-02 text-ds-md text-surface-fg transition-colors duration-fast-01 ease-productive-standard hover:border-surface-border-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9 cursor-pointer appearance-none";
942
- return /* @__PURE__ */ M(oe, { open: k, onOpenChange: T, children: [
943
- /* @__PURE__ */ t(ce, { asChild: !0, children: /* @__PURE__ */ M(
944
- "button",
945
- {
946
- ref: O,
947
- type: "button",
948
- ...C,
949
- className: S(
950
- "inline-flex h-ds-sm-plus items-center gap-ds-03 rounded-ds-lg border border-surface-border-strong bg-surface-overlay px-ds-04 text-left transition-colors duration-fast-01 ease-productive-standard",
951
- "hover:border-surface-border-strong",
952
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
953
- H
954
- ),
955
- "aria-label": a ? `Selected: ${a}` : v,
956
- children: [
957
- /* @__PURE__ */ t(B, { icon: De, size: "sm", stroke: "light", className: "text-surface-fg-subtle" }),
958
- /* @__PURE__ */ t(
959
- "span",
960
- {
961
- className: S(
962
- "text-ds-md",
963
- a ? "text-surface-fg" : "text-surface-fg-subtle"
964
- ),
965
- children: a ?? v
966
- }
967
- )
968
- ]
969
- }
970
- ) }),
971
- /* @__PURE__ */ t(
972
- le,
973
- {
974
- className: "w-auto border-surface-border-strong bg-surface-overlay p-ds-04",
975
- align: "start",
976
- sideOffset: 4,
977
- children: /* @__PURE__ */ M("div", { className: "flex flex-col gap-ds-04", children: [
978
- s(),
979
- h === "days" && /* @__PURE__ */ M("div", { className: "flex items-center gap-ds-02 border-t border-surface-border-strong pt-ds-04", children: [
980
- /* @__PURE__ */ t("span", { className: "text-ds-xs font-semibold uppercase tracking-wider text-surface-fg-subtle", children: "Time" }),
981
- /* @__PURE__ */ M(
982
- "select",
983
- {
984
- value: U ?? "",
985
- onChange: (n) => j(Number(n.target.value)),
986
- className: c,
987
- "aria-label": "Hour",
988
- children: [
989
- !e && /* @__PURE__ */ t("option", { value: "", children: "--" }),
990
- R.map((n) => /* @__PURE__ */ t("option", { value: n, children: x === "24h" ? we(n) : n }, n))
991
- ]
992
- }
993
- ),
994
- /* @__PURE__ */ t("span", { className: "text-ds-md font-semibold text-surface-fg-subtle", children: ":" }),
995
- /* @__PURE__ */ M(
996
- "select",
997
- {
998
- value: e ? A : "",
999
- onChange: (n) => K(Number(n.target.value)),
1000
- className: c,
1001
- "aria-label": "Minute",
1002
- children: [
1003
- !e && /* @__PURE__ */ t("option", { value: "", children: "--" }),
1004
- L.map((n) => /* @__PURE__ */ t("option", { value: n, children: we(n) }, n))
1005
- ]
1006
- }
1007
- ),
1008
- x === "12h" && /* @__PURE__ */ M(
1009
- "select",
1010
- {
1011
- value: e ? N : "",
1012
- onChange: (n) => F(n.target.value),
1013
- className: c,
1014
- "aria-label": "AM or PM",
1015
- children: [
1016
- !e && /* @__PURE__ */ t("option", { value: "", children: "--" }),
1017
- /* @__PURE__ */ t("option", { value: "AM", children: "AM" }),
1018
- /* @__PURE__ */ t("option", { value: "PM", children: "PM" })
1019
- ]
1020
- }
1021
- )
1022
- ] })
1023
- ] })
1024
- }
1025
- )
1026
- ] });
1027
- }
1028
- );
1029
- Fe.displayName = "DateTimePicker";
1030
- function _e(f) {
1031
- const [e, d] = Ce(f ?? /* @__PURE__ */ new Date());
195
+ he.displayName = "CalendarGrid";
196
+ function ke(D) {
197
+ const [c, d] = ae(D ?? /* @__PURE__ */ new Date());
1032
198
  return {
1033
- currentMonth: e,
199
+ currentMonth: c,
1034
200
  setCurrentMonth: d,
1035
- goToPreviousMonth: () => d((m) => be(m, 1)),
1036
- goToNextMonth: () => d((m) => se(m, 1)),
1037
- goToMonth: (m) => d((v) => re(v, m)),
1038
- goToYear: (m) => d((v) => ae(v, m))
201
+ goToPreviousMonth: () => d((a) => z(a, 1)),
202
+ goToNextMonth: () => d((a) => B(a, 1)),
203
+ goToMonth: (a) => d((u) => fe(u, a)),
204
+ goToYear: (a) => d((u) => ue(u, a))
1039
205
  };
1040
206
  }
1041
207
  export {
1042
- Q as C,
1043
- Ie as D,
1044
- de as M,
1045
- ke as P,
1046
- Ke as T,
1047
- ie as Y,
1048
- je as a,
1049
- Fe as b,
1050
- _e as u
208
+ he as C,
209
+ ke as u
1051
210
  };