@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
@@ -0,0 +1,851 @@
1
+ "use client";
2
+ import { jsxs as M, jsx as t } from "react/jsx-runtime";
3
+ import * as d from "react";
4
+ import { format as U, setMonth as ae, setYear as oe, endOfDay as B, startOfYear as be, subMonths as me, endOfMonth as ce, startOfMonth as le, startOfDay as _, subDays as ne, addMonths as ie, isBefore as pe, isAfter as xe, setHours as K, setMinutes as q, setSeconds as de } from "date-fns";
5
+ import { IconCalendarEvent as fe, IconClock as Me, IconCalendarClock as ye } from "@tabler/icons-react";
6
+ import { Icon as W } from "../ui/icon.js";
7
+ import { cn as N } from "../ui/lib/utils.js";
8
+ import { Popover as X, PopoverTrigger as Z, PopoverContent as ee } from "../ui/popover.js";
9
+ import { C as Q } from "./use-calendar.js";
10
+ const te = d.forwardRef(
11
+ function({
12
+ currentYear: e,
13
+ selectedYear: f,
14
+ onYearSelect: u,
15
+ minDate: h,
16
+ maxDate: S,
17
+ className: b,
18
+ ...y
19
+ }, C) {
20
+ const w = Math.floor(e / 10) * 10, H = Array.from({ length: 12 }, (i, s) => w + s), [k, R] = d.useState(() => {
21
+ const i = H.indexOf(f ?? e);
22
+ return i >= 0 ? i : 0;
23
+ }), m = d.useRef([]), g = (i) => h != null && i < h.getFullYear() || S != null && i > S.getFullYear(), o = (i) => {
24
+ let s = k;
25
+ switch (i.key) {
26
+ case "ArrowRight":
27
+ s = Math.min(11, k + 1);
28
+ break;
29
+ case "ArrowLeft":
30
+ s = Math.max(0, k - 1);
31
+ break;
32
+ case "ArrowDown":
33
+ s = Math.min(11, k + 3);
34
+ break;
35
+ case "ArrowUp":
36
+ s = Math.max(0, k - 3);
37
+ break;
38
+ case "Home":
39
+ s = 0;
40
+ break;
41
+ case "End":
42
+ s = 11;
43
+ break;
44
+ default:
45
+ return;
46
+ }
47
+ for (i.preventDefault(); s !== k && g(H[s]); )
48
+ if (s += i.key === "ArrowLeft" || i.key === "ArrowUp" ? -1 : 1, s < 0 || s > 11) return;
49
+ R(s), m.current[s]?.focus();
50
+ };
51
+ return /* @__PURE__ */ M("div", { ref: C, ...y, className: N("w-[252px]", b), children: [
52
+ /* @__PURE__ */ M("div", { className: "text-center pb-ds-04 text-ds-md font-semibold text-surface-fg", children: [
53
+ w,
54
+ " – ",
55
+ w + 11
56
+ ] }),
57
+ /* @__PURE__ */ t("div", { role: "grid", "aria-label": "Year picker", tabIndex: -1, onKeyDown: o, children: [0, 1, 2, 3].map((i) => /* @__PURE__ */ t("div", { role: "row", className: "grid grid-cols-3 gap-ds-02 mb-ds-02 last:mb-0", children: H.slice(i * 3, i * 3 + 3).map((s) => {
58
+ const P = H.indexOf(s), x = s === f, A = g(s);
59
+ return /* @__PURE__ */ t(
60
+ "button",
61
+ {
62
+ ref: (v) => {
63
+ m.current[P] = v;
64
+ },
65
+ type: "button",
66
+ role: "gridcell",
67
+ tabIndex: P === k ? 0 : -1,
68
+ disabled: A || !1,
69
+ onClick: () => !A && u(s),
70
+ className: N(
71
+ "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",
72
+ A && "opacity-action-disabled pointer-events-none cursor-not-allowed",
73
+ x && "bg-accent-9 text-accent-fg",
74
+ !x && !A && "hover:bg-surface-raised-hover text-surface-fg"
75
+ ),
76
+ children: s
77
+ },
78
+ s
79
+ );
80
+ }) }, i)) })
81
+ ] });
82
+ }
83
+ );
84
+ te.displayName = "YearPicker";
85
+ const we = [
86
+ "Jan",
87
+ "Feb",
88
+ "Mar",
89
+ "Apr",
90
+ "May",
91
+ "Jun",
92
+ "Jul",
93
+ "Aug",
94
+ "Sep",
95
+ "Oct",
96
+ "Nov",
97
+ "Dec"
98
+ ], se = d.forwardRef(
99
+ function({
100
+ currentYear: e,
101
+ selectedMonth: f,
102
+ onMonthSelect: u,
103
+ minDate: h,
104
+ maxDate: S,
105
+ className: b,
106
+ ...y
107
+ }, C) {
108
+ const [w, H] = d.useState(f ?? 0), k = d.useRef([]), R = (g) => h != null && (e < h.getFullYear() || e === h.getFullYear() && g < h.getMonth()) || S != null && (e > S.getFullYear() || e === S.getFullYear() && g > S.getMonth()), m = (g) => {
109
+ let o = w;
110
+ switch (g.key) {
111
+ case "ArrowRight":
112
+ o = Math.min(11, w + 1);
113
+ break;
114
+ case "ArrowLeft":
115
+ o = Math.max(0, w - 1);
116
+ break;
117
+ case "ArrowDown":
118
+ o = Math.min(11, w + 4);
119
+ break;
120
+ case "ArrowUp":
121
+ o = Math.max(0, w - 4);
122
+ break;
123
+ case "Home":
124
+ o = 0;
125
+ break;
126
+ case "End":
127
+ o = 11;
128
+ break;
129
+ default:
130
+ return;
131
+ }
132
+ for (g.preventDefault(); o !== w && R(o); )
133
+ if (o += g.key === "ArrowLeft" || g.key === "ArrowUp" ? -1 : 1, o < 0 || o > 11) return;
134
+ H(o), k.current[o]?.focus();
135
+ };
136
+ return /* @__PURE__ */ M("div", { ref: C, ...y, className: N("w-[252px]", b), children: [
137
+ /* @__PURE__ */ t("div", { className: "text-center pb-ds-04 text-ds-md font-semibold text-surface-fg", children: e }),
138
+ /* @__PURE__ */ t("div", { role: "grid", "aria-label": "Month picker", tabIndex: -1, onKeyDown: m, children: [0, 1, 2].map((g) => /* @__PURE__ */ t("div", { role: "row", className: "grid grid-cols-4 gap-ds-02 mb-ds-02 last:mb-0", children: we.slice(g * 4, g * 4 + 4).map((o, i) => {
139
+ const s = g * 4 + i, P = s === f, x = R(s);
140
+ return /* @__PURE__ */ t(
141
+ "button",
142
+ {
143
+ ref: (A) => {
144
+ k.current[s] = A;
145
+ },
146
+ type: "button",
147
+ role: "gridcell",
148
+ tabIndex: s === w ? 0 : -1,
149
+ disabled: x || !1,
150
+ onClick: () => !x && u(s),
151
+ className: N(
152
+ "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",
153
+ x && "opacity-action-disabled pointer-events-none cursor-not-allowed",
154
+ P && "bg-accent-9 text-accent-fg",
155
+ !P && !x && "hover:bg-surface-raised-hover text-surface-fg"
156
+ ),
157
+ children: o
158
+ },
159
+ o
160
+ );
161
+ }) }, g)) })
162
+ ] });
163
+ }
164
+ );
165
+ se.displayName = "MonthPicker";
166
+ const ke = d.forwardRef(
167
+ function({
168
+ value: e,
169
+ onChange: f,
170
+ placeholder: u = "Pick a date",
171
+ className: h,
172
+ formatStr: S = "MMM d, yyyy",
173
+ minDate: b,
174
+ maxDate: y,
175
+ disabledDates: C,
176
+ ...Y
177
+ }, w) {
178
+ const [H, k] = d.useState(!1), [R, m] = d.useState(
179
+ e ?? /* @__PURE__ */ new Date()
180
+ ), [g, o] = d.useState("days");
181
+ d.useEffect(() => {
182
+ H || o("days");
183
+ }, [H]);
184
+ const i = (v) => {
185
+ f?.(v), k(!1);
186
+ }, s = () => {
187
+ o((v) => v === "days" ? "months" : "years");
188
+ }, P = (v) => {
189
+ m((T) => ae(T, v)), o("days");
190
+ }, x = (v) => {
191
+ m((T) => oe(T, v)), o("months");
192
+ }, A = () => {
193
+ switch (g) {
194
+ case "years":
195
+ return /* @__PURE__ */ t(
196
+ te,
197
+ {
198
+ currentYear: R.getFullYear(),
199
+ selectedYear: e?.getFullYear(),
200
+ onYearSelect: x,
201
+ minDate: b,
202
+ maxDate: y
203
+ }
204
+ );
205
+ case "months":
206
+ return /* @__PURE__ */ t(
207
+ se,
208
+ {
209
+ currentYear: R.getFullYear(),
210
+ selectedMonth: e?.getMonth(),
211
+ onMonthSelect: P,
212
+ minDate: b,
213
+ maxDate: y
214
+ }
215
+ );
216
+ default:
217
+ return /* @__PURE__ */ t(
218
+ Q,
219
+ {
220
+ currentMonth: R,
221
+ selected: e,
222
+ onSelect: i,
223
+ onMonthChange: m,
224
+ onHeaderClick: s,
225
+ disabledDates: C,
226
+ minDate: b,
227
+ maxDate: y
228
+ }
229
+ );
230
+ }
231
+ };
232
+ return /* @__PURE__ */ M(X, { open: H, onOpenChange: k, children: [
233
+ /* @__PURE__ */ t(Z, { asChild: !0, children: /* @__PURE__ */ M(
234
+ "button",
235
+ {
236
+ ref: w,
237
+ type: "button",
238
+ "aria-label": e ? `Change date, ${U(e, S)}` : u,
239
+ ...Y,
240
+ className: N(
241
+ "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",
242
+ "hover:border-surface-border-strong",
243
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
244
+ h
245
+ ),
246
+ children: [
247
+ /* @__PURE__ */ t(W, { icon: fe, size: "sm", stroke: "light", className: "text-surface-fg-subtle" }),
248
+ /* @__PURE__ */ t(
249
+ "span",
250
+ {
251
+ className: N(
252
+ "text-ds-md",
253
+ e ? "text-surface-fg" : "text-surface-fg-subtle"
254
+ ),
255
+ children: e ? U(e, S) : u
256
+ }
257
+ )
258
+ ]
259
+ }
260
+ ) }),
261
+ /* @__PURE__ */ t(
262
+ ee,
263
+ {
264
+ className: "w-auto border-surface-border-strong bg-surface-overlay p-ds-04",
265
+ align: "start",
266
+ sideOffset: 4,
267
+ children: A()
268
+ }
269
+ )
270
+ ] });
271
+ }
272
+ );
273
+ ke.displayName = "DatePicker";
274
+ const Ne = {
275
+ today: {
276
+ label: "Today",
277
+ getRange: () => {
278
+ const l = /* @__PURE__ */ new Date();
279
+ return { start: _(l), end: B(l) };
280
+ }
281
+ },
282
+ yesterday: {
283
+ label: "Yesterday",
284
+ getRange: () => {
285
+ const l = ne(/* @__PURE__ */ new Date(), 1);
286
+ return { start: _(l), end: B(l) };
287
+ }
288
+ },
289
+ last7days: {
290
+ label: "Last 7 days",
291
+ getRange: () => {
292
+ const l = /* @__PURE__ */ new Date();
293
+ return { start: _(ne(l, 6)), end: B(l) };
294
+ }
295
+ },
296
+ last30days: {
297
+ label: "Last 30 days",
298
+ getRange: () => {
299
+ const l = /* @__PURE__ */ new Date();
300
+ return { start: _(ne(l, 29)), end: B(l) };
301
+ }
302
+ },
303
+ thisMonth: {
304
+ label: "This month",
305
+ getRange: () => {
306
+ const l = /* @__PURE__ */ new Date();
307
+ return { start: le(l), end: ce(l) };
308
+ }
309
+ },
310
+ lastMonth: {
311
+ label: "Last month",
312
+ getRange: () => {
313
+ const e = me(/* @__PURE__ */ new Date(), 1);
314
+ return { start: le(e), end: ce(e) };
315
+ }
316
+ },
317
+ thisYear: {
318
+ label: "This year",
319
+ getRange: () => {
320
+ const l = /* @__PURE__ */ new Date();
321
+ return { start: be(l), end: B(l) };
322
+ }
323
+ }
324
+ }, he = d.forwardRef(
325
+ function({ presets: e, onSelect: f, className: u, ...h }, S) {
326
+ return /* @__PURE__ */ t("div", { ref: S, ...h, className: N("flex flex-col gap-ds-01", u), children: e.map((b) => {
327
+ const y = Ne[b];
328
+ return y ? /* @__PURE__ */ t(
329
+ "button",
330
+ {
331
+ type: "button",
332
+ onClick: () => {
333
+ const { start: C, end: Y } = y.getRange();
334
+ f(C, Y);
335
+ },
336
+ className: N(
337
+ "h-ds-sm w-full rounded-ds-md px-ds-03 text-left text-ds-sm",
338
+ "text-surface-fg transition-colors",
339
+ "hover:bg-surface-raised-hover",
340
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9"
341
+ ),
342
+ children: y.label
343
+ },
344
+ b
345
+ ) : null;
346
+ }) });
347
+ }
348
+ );
349
+ he.displayName = "Presets";
350
+ const Se = d.forwardRef(
351
+ function({
352
+ startDate: e,
353
+ endDate: f,
354
+ onChange: u,
355
+ placeholder: h = "Pick a date range",
356
+ className: S,
357
+ formatStr: b = "MMM d, yyyy",
358
+ minDate: y,
359
+ maxDate: C,
360
+ disabledDates: Y,
361
+ presets: w,
362
+ numberOfMonths: H = 1,
363
+ ...k
364
+ }, R) {
365
+ const [m, g] = d.useState(!1), [o, i] = d.useState(
366
+ e ?? /* @__PURE__ */ new Date()
367
+ ), [s, P] = d.useState(
368
+ e ?? null
369
+ ), [x, A] = d.useState(
370
+ f ?? null
371
+ ), [v, T] = d.useState(null), [j, E] = d.useState("days"), V = Math.max(1, H);
372
+ d.useEffect(() => {
373
+ P(e ?? null), A(f ?? null);
374
+ }, [e, f]), d.useEffect(() => {
375
+ m || E("days");
376
+ }, [m]);
377
+ const L = (c) => {
378
+ if (!s || s && x)
379
+ P(c), A(null);
380
+ else {
381
+ const a = pe(c, s) ? c : s, O = xe(c, s) ? c : s;
382
+ P(a), A(O), u?.({ start: a, end: O }), g(!1);
383
+ }
384
+ }, z = (c, a) => {
385
+ P(c), A(a), u?.({ start: c, end: a }), g(!1);
386
+ }, $ = () => {
387
+ E((c) => c === "days" ? "months" : "years");
388
+ }, I = (c) => {
389
+ i((a) => ae(a, c)), E("days");
390
+ }, F = (c) => {
391
+ i((a) => oe(a, c)), E("months");
392
+ }, D = () => s && x ? `${U(s, b)} - ${U(x, b)}` : h, n = () => V === 1 ? /* @__PURE__ */ t(
393
+ Q,
394
+ {
395
+ currentMonth: o,
396
+ rangeStart: s,
397
+ rangeEnd: x,
398
+ hoverDate: v,
399
+ onSelect: L,
400
+ onHover: T,
401
+ onMonthChange: i,
402
+ onHeaderClick: $,
403
+ disabledDates: Y,
404
+ minDate: y,
405
+ maxDate: C
406
+ }
407
+ ) : /* @__PURE__ */ t("div", { className: "flex flex-row gap-ds-04", children: Array.from({ length: V }, (c, a) => /* @__PURE__ */ t(
408
+ Q,
409
+ {
410
+ currentMonth: ie(o, a),
411
+ rangeStart: s,
412
+ rangeEnd: x,
413
+ hoverDate: v,
414
+ onSelect: L,
415
+ onHover: T,
416
+ onMonthChange: (O) => {
417
+ i(ie(O, -a));
418
+ },
419
+ onHeaderClick: $,
420
+ disabledDates: Y,
421
+ minDate: y,
422
+ maxDate: C,
423
+ hidePrevNav: a > 0,
424
+ hideNextNav: a < V - 1
425
+ },
426
+ a
427
+ )) }), p = () => {
428
+ switch (j) {
429
+ case "years":
430
+ return /* @__PURE__ */ t(
431
+ te,
432
+ {
433
+ currentYear: o.getFullYear(),
434
+ selectedYear: s?.getFullYear(),
435
+ onYearSelect: F,
436
+ minDate: y,
437
+ maxDate: C
438
+ }
439
+ );
440
+ case "months":
441
+ return /* @__PURE__ */ t(
442
+ se,
443
+ {
444
+ currentYear: o.getFullYear(),
445
+ selectedMonth: s?.getMonth(),
446
+ onMonthSelect: I,
447
+ minDate: y,
448
+ maxDate: C
449
+ }
450
+ );
451
+ default:
452
+ return n();
453
+ }
454
+ }, r = w && w.length > 0;
455
+ return /* @__PURE__ */ M(X, { open: m, onOpenChange: g, children: [
456
+ /* @__PURE__ */ t(Z, { asChild: !0, children: /* @__PURE__ */ M(
457
+ "button",
458
+ {
459
+ ref: R,
460
+ type: "button",
461
+ "aria-label": s && x ? `Change date range, ${D()}` : h,
462
+ ...k,
463
+ className: N(
464
+ "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",
465
+ "hover:border-surface-border-strong",
466
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
467
+ S
468
+ ),
469
+ children: [
470
+ /* @__PURE__ */ t(W, { icon: fe, size: "sm", stroke: "light", className: "text-surface-fg-subtle" }),
471
+ /* @__PURE__ */ t(
472
+ "span",
473
+ {
474
+ className: N(
475
+ "text-ds-md",
476
+ s && x ? "text-surface-fg" : "text-surface-fg-subtle"
477
+ ),
478
+ children: D()
479
+ }
480
+ )
481
+ ]
482
+ }
483
+ ) }),
484
+ /* @__PURE__ */ t(
485
+ ee,
486
+ {
487
+ className: "w-auto border-surface-border-strong bg-surface-overlay p-ds-04",
488
+ align: "start",
489
+ sideOffset: 4,
490
+ children: r ? /* @__PURE__ */ M("div", { className: "flex flex-row gap-ds-04", children: [
491
+ /* @__PURE__ */ t("div", { className: "min-w-[140px] border-r border-surface-border-strong pr-ds-04", children: /* @__PURE__ */ t(he, { presets: w, onSelect: z }) }),
492
+ /* @__PURE__ */ t("div", { children: p() })
493
+ ] }) : p()
494
+ }
495
+ )
496
+ ] });
497
+ }
498
+ );
499
+ Se.displayName = "DateRangePicker";
500
+ function G(l, e, f) {
501
+ const u = [];
502
+ for (let h = l; h <= e; h += f)
503
+ u.push(h);
504
+ return u;
505
+ }
506
+ function J(l) {
507
+ return l.toString().padStart(2, "0");
508
+ }
509
+ const ve = d.forwardRef(
510
+ function({
511
+ value: e,
512
+ onChange: f,
513
+ format: u = "12h",
514
+ minuteStep: h = 1,
515
+ secondStep: S = 1,
516
+ showSeconds: b = !1,
517
+ placeholder: y = "Pick a time",
518
+ className: C,
519
+ disabled: Y = !1,
520
+ ...w
521
+ }, H) {
522
+ const [k, R] = d.useState(!1), m = e ? e.getHours() : null, g = e ? e.getMinutes() : null, o = e ? e.getSeconds() : null, i = m !== null ? m >= 12 ? "PM" : "AM" : null, s = m !== null ? m === 0 ? 12 : m > 12 ? m - 12 : m : null, P = u === "12h" ? G(1, 12, 1) : G(0, 23, 1), x = G(0, 59, h), A = G(0, 59, S), v = (n) => {
523
+ const p = e ? new Date(e) : /* @__PURE__ */ new Date();
524
+ let r = n.hours ?? p.getHours();
525
+ const c = n.minutes ?? p.getMinutes(), a = n.seconds ?? p.getSeconds();
526
+ u === "12h" && n.hours !== void 0 && ((n.ampm ?? i ?? "AM") === "AM" ? r = n.hours === 12 ? 0 : n.hours : r = n.hours === 12 ? 12 : n.hours + 12);
527
+ let O = K(p, r);
528
+ return O = q(O, c), O = de(O, a), O;
529
+ }, T = (n) => {
530
+ const p = v({ hours: n });
531
+ f?.(p);
532
+ }, j = (n) => {
533
+ const p = v({ minutes: n });
534
+ f?.(p);
535
+ }, E = (n) => {
536
+ const p = v({ seconds: n });
537
+ f?.(p);
538
+ }, V = (n) => {
539
+ if (!e) {
540
+ const c = n === "AM" ? 0 : 12;
541
+ let a = /* @__PURE__ */ new Date();
542
+ a = K(a, c), a = q(a, 0), a = de(a, 0), f?.(a);
543
+ return;
544
+ }
545
+ const p = e.getHours();
546
+ let r;
547
+ n === "AM" ? r = p >= 12 ? p - 12 : p : r = p < 12 ? p + 12 : p, f?.(K(new Date(e), r));
548
+ }, L = d.useMemo(() => e ? u === "12h" ? U(e, b ? "h:mm:ss a" : "h:mm a") : U(e, b ? "HH:mm:ss" : "HH:mm") : null, [e, u, b]), z = u === "12h" ? s : m, $ = "flex flex-col gap-ds-01 overflow-y-auto max-h-[200px] px-ds-01", I = "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", D = "text-surface-fg hover:bg-surface-raised-hover";
549
+ return /* @__PURE__ */ M(X, { open: k, onOpenChange: R, children: [
550
+ /* @__PURE__ */ t(Z, { asChild: !0, children: /* @__PURE__ */ M(
551
+ "button",
552
+ {
553
+ ref: H,
554
+ type: "button",
555
+ disabled: Y,
556
+ ...w,
557
+ className: N(
558
+ "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",
559
+ "hover:border-surface-border-strong",
560
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
561
+ Y && "opacity-action-disabled pointer-events-none",
562
+ C
563
+ ),
564
+ "aria-label": L ? `Selected time: ${L}` : y,
565
+ children: [
566
+ /* @__PURE__ */ t(W, { icon: Me, size: "sm", stroke: "light", className: "text-surface-fg-subtle" }),
567
+ /* @__PURE__ */ t(
568
+ "span",
569
+ {
570
+ className: N(
571
+ "text-ds-md",
572
+ L ? "text-surface-fg" : "text-surface-fg-subtle"
573
+ ),
574
+ children: L ?? y
575
+ }
576
+ )
577
+ ]
578
+ }
579
+ ) }),
580
+ /* @__PURE__ */ t(
581
+ ee,
582
+ {
583
+ className: "w-auto border-surface-border-strong bg-surface-overlay p-ds-04",
584
+ align: "start",
585
+ sideOffset: 4,
586
+ children: /* @__PURE__ */ M("div", { className: "flex gap-ds-03", role: "group", "aria-label": "Time picker", children: [
587
+ /* @__PURE__ */ M("div", { className: "flex flex-col items-center gap-ds-02", children: [
588
+ /* @__PURE__ */ t("span", { className: "text-ds-xs font-semibold uppercase tracking-wider text-surface-fg-subtle", children: "Hr" }),
589
+ /* @__PURE__ */ t("div", { className: N($, "min-w-[48px]"), children: P.map((n) => /* @__PURE__ */ t(
590
+ "button",
591
+ {
592
+ type: "button",
593
+ onClick: () => T(n),
594
+ className: N(
595
+ I,
596
+ z === n ? F : D
597
+ ),
598
+ "aria-label": `${n} hours`,
599
+ "aria-selected": z === n || void 0,
600
+ children: u === "24h" ? J(n) : n
601
+ },
602
+ n
603
+ )) })
604
+ ] }),
605
+ /* @__PURE__ */ M("div", { className: "flex flex-col items-center gap-ds-02", children: [
606
+ /* @__PURE__ */ t("span", { className: "text-ds-xs font-semibold uppercase tracking-wider text-surface-fg-subtle", children: "Min" }),
607
+ /* @__PURE__ */ t("div", { className: N($, "min-w-[48px]"), children: x.map((n) => /* @__PURE__ */ t(
608
+ "button",
609
+ {
610
+ type: "button",
611
+ onClick: () => j(n),
612
+ className: N(
613
+ I,
614
+ g === n ? F : D
615
+ ),
616
+ "aria-label": `${J(n)} minutes`,
617
+ "aria-selected": g === n || void 0,
618
+ children: J(n)
619
+ },
620
+ n
621
+ )) })
622
+ ] }),
623
+ b && /* @__PURE__ */ M("div", { className: "flex flex-col items-center gap-ds-02", children: [
624
+ /* @__PURE__ */ t("span", { className: "text-ds-xs font-semibold uppercase tracking-wider text-surface-fg-subtle", children: "Sec" }),
625
+ /* @__PURE__ */ t("div", { className: N($, "min-w-[48px]"), children: A.map((n) => /* @__PURE__ */ t(
626
+ "button",
627
+ {
628
+ type: "button",
629
+ onClick: () => E(n),
630
+ className: N(
631
+ I,
632
+ o === n ? F : D
633
+ ),
634
+ "aria-label": `${J(n)} seconds`,
635
+ "aria-selected": o === n || void 0,
636
+ children: J(n)
637
+ },
638
+ n
639
+ )) })
640
+ ] }),
641
+ u === "12h" && /* @__PURE__ */ M("div", { className: "flex flex-col items-center gap-ds-02", children: [
642
+ /* @__PURE__ */ t("span", { className: "text-ds-xs font-semibold uppercase tracking-wider text-surface-fg-subtle", children: " " }),
643
+ /* @__PURE__ */ t("div", { className: "flex flex-col gap-ds-01 px-ds-01", children: ["AM", "PM"].map((n) => /* @__PURE__ */ t(
644
+ "button",
645
+ {
646
+ type: "button",
647
+ onClick: () => V(n),
648
+ className: N(
649
+ I,
650
+ "min-w-[44px] font-semibold",
651
+ i === n ? F : D
652
+ ),
653
+ "aria-label": n,
654
+ "aria-selected": i === n || void 0,
655
+ children: n
656
+ },
657
+ n
658
+ )) })
659
+ ] })
660
+ ] })
661
+ }
662
+ )
663
+ ] });
664
+ }
665
+ );
666
+ ve.displayName = "TimePicker";
667
+ function ue(l) {
668
+ return l.toString().padStart(2, "0");
669
+ }
670
+ function re(l, e, f) {
671
+ const u = [];
672
+ for (let h = l; h <= e; h += f)
673
+ u.push(h);
674
+ return u;
675
+ }
676
+ const Ce = d.forwardRef(
677
+ function({
678
+ value: e,
679
+ onChange: f,
680
+ minDate: u,
681
+ maxDate: h,
682
+ disabledDates: S,
683
+ timeFormat: b = "12h",
684
+ minuteStep: y = 1,
685
+ placeholder: C = "Pick date & time",
686
+ className: Y,
687
+ ...w
688
+ }, H) {
689
+ const [k, R] = d.useState(!1), [m, g] = d.useState(e ?? /* @__PURE__ */ new Date()), [o, i] = d.useState("days");
690
+ d.useEffect(() => {
691
+ k || i("days");
692
+ }, [k]);
693
+ const s = e ? e.getHours() : 0, P = e ? e.getMinutes() : 0, x = s >= 12 ? "PM" : "AM", A = s === 0 ? 12 : s > 12 ? s - 12 : s, v = b === "12h" ? re(1, 12, 1) : re(0, 23, 1), T = re(0, 59, y), j = b === "12h" ? A : s, E = (r) => {
694
+ let c = K(r, e ? e.getHours() : s);
695
+ c = q(c, e ? e.getMinutes() : P), f?.(c);
696
+ }, V = () => {
697
+ i((r) => r === "days" ? "months" : "years");
698
+ }, L = (r) => {
699
+ g((c) => ae(c, r)), i("days");
700
+ }, z = (r) => {
701
+ g((c) => oe(c, r)), i("months");
702
+ }, $ = (r) => {
703
+ const c = e ? new Date(e) : /* @__PURE__ */ new Date();
704
+ let a = r;
705
+ b === "12h" && ((e ? x : "AM") === "AM" ? a = r === 12 ? 0 : r : a = r === 12 ? 12 : r + 12);
706
+ const O = K(c, a);
707
+ f?.(O);
708
+ }, I = (r) => {
709
+ const c = e ? new Date(e) : /* @__PURE__ */ new Date(), a = q(c, r);
710
+ f?.(a);
711
+ }, F = (r) => {
712
+ const c = e ? new Date(e) : /* @__PURE__ */ new Date(), a = c.getHours();
713
+ let O;
714
+ r === "AM" ? O = a >= 12 ? a - 12 : a : O = a < 12 ? a + 12 : a, f?.(K(c, O));
715
+ }, D = d.useMemo(() => e ? U(e, b === "12h" ? "MMM d, yyyy h:mm a" : "MMM d, yyyy HH:mm") : null, [e, b]), n = () => {
716
+ switch (o) {
717
+ case "years":
718
+ return /* @__PURE__ */ t(
719
+ te,
720
+ {
721
+ currentYear: m.getFullYear(),
722
+ selectedYear: e?.getFullYear(),
723
+ onYearSelect: z,
724
+ minDate: u,
725
+ maxDate: h
726
+ }
727
+ );
728
+ case "months":
729
+ return /* @__PURE__ */ t(
730
+ se,
731
+ {
732
+ currentYear: m.getFullYear(),
733
+ selectedMonth: e?.getMonth(),
734
+ onMonthSelect: L,
735
+ minDate: u,
736
+ maxDate: h
737
+ }
738
+ );
739
+ default:
740
+ return /* @__PURE__ */ t(
741
+ Q,
742
+ {
743
+ currentMonth: m,
744
+ selected: e,
745
+ onSelect: E,
746
+ onMonthChange: g,
747
+ onHeaderClick: V,
748
+ disabledDates: S,
749
+ minDate: u,
750
+ maxDate: h
751
+ }
752
+ );
753
+ }
754
+ }, p = "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";
755
+ return /* @__PURE__ */ M(X, { open: k, onOpenChange: R, children: [
756
+ /* @__PURE__ */ t(Z, { asChild: !0, children: /* @__PURE__ */ M(
757
+ "button",
758
+ {
759
+ ref: H,
760
+ type: "button",
761
+ ...w,
762
+ className: N(
763
+ "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",
764
+ "hover:border-surface-border-strong",
765
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
766
+ Y
767
+ ),
768
+ "aria-label": D ? `Selected: ${D}` : C,
769
+ children: [
770
+ /* @__PURE__ */ t(W, { icon: ye, size: "sm", stroke: "light", className: "text-surface-fg-subtle" }),
771
+ /* @__PURE__ */ t(
772
+ "span",
773
+ {
774
+ className: N(
775
+ "text-ds-md",
776
+ D ? "text-surface-fg" : "text-surface-fg-subtle"
777
+ ),
778
+ children: D ?? C
779
+ }
780
+ )
781
+ ]
782
+ }
783
+ ) }),
784
+ /* @__PURE__ */ t(
785
+ ee,
786
+ {
787
+ className: "w-auto border-surface-border-strong bg-surface-overlay p-ds-04",
788
+ align: "start",
789
+ sideOffset: 4,
790
+ children: /* @__PURE__ */ M("div", { className: "flex flex-col gap-ds-04", children: [
791
+ n(),
792
+ o === "days" && /* @__PURE__ */ M("div", { className: "flex items-center gap-ds-02 border-t border-surface-border-strong pt-ds-04", children: [
793
+ /* @__PURE__ */ t("span", { className: "text-ds-xs font-semibold uppercase tracking-wider text-surface-fg-subtle", children: "Time" }),
794
+ /* @__PURE__ */ M(
795
+ "select",
796
+ {
797
+ value: j ?? "",
798
+ onChange: (r) => $(Number(r.target.value)),
799
+ className: p,
800
+ "aria-label": "Hour",
801
+ children: [
802
+ !e && /* @__PURE__ */ t("option", { value: "", children: "--" }),
803
+ v.map((r) => /* @__PURE__ */ t("option", { value: r, children: b === "24h" ? ue(r) : r }, r))
804
+ ]
805
+ }
806
+ ),
807
+ /* @__PURE__ */ t("span", { className: "text-ds-md font-semibold text-surface-fg-subtle", children: ":" }),
808
+ /* @__PURE__ */ M(
809
+ "select",
810
+ {
811
+ value: e ? P : "",
812
+ onChange: (r) => I(Number(r.target.value)),
813
+ className: p,
814
+ "aria-label": "Minute",
815
+ children: [
816
+ !e && /* @__PURE__ */ t("option", { value: "", children: "--" }),
817
+ T.map((r) => /* @__PURE__ */ t("option", { value: r, children: ue(r) }, r))
818
+ ]
819
+ }
820
+ ),
821
+ b === "12h" && /* @__PURE__ */ M(
822
+ "select",
823
+ {
824
+ value: e ? x : "",
825
+ onChange: (r) => F(r.target.value),
826
+ className: p,
827
+ "aria-label": "AM or PM",
828
+ children: [
829
+ !e && /* @__PURE__ */ t("option", { value: "", children: "--" }),
830
+ /* @__PURE__ */ t("option", { value: "AM", children: "AM" }),
831
+ /* @__PURE__ */ t("option", { value: "PM", children: "PM" })
832
+ ]
833
+ }
834
+ )
835
+ ] })
836
+ ] })
837
+ }
838
+ )
839
+ ] });
840
+ }
841
+ );
842
+ Ce.displayName = "DateTimePicker";
843
+ export {
844
+ ke as D,
845
+ se as M,
846
+ he as P,
847
+ ve as T,
848
+ te as Y,
849
+ Se as a,
850
+ Ce as b
851
+ };