@base-framework/ui 1.0.1727 → 1.0.2000

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 (79) hide show
  1. package/copilot.md +80 -0
  2. package/dist/aside-template-sUm-F2f0.js +44 -0
  3. package/dist/atoms.es.js +31 -30
  4. package/dist/{bside-template-Du2m3rsE.js → bside-template-do_hXebn.js} +1 -1
  5. package/dist/{buttons-Cm9etaEG.js → buttons-CHEs54Wl.js} +23 -24
  6. package/dist/{confirmation-BxmDhBjv.js → empty-state-BfT4MKkN.js} +721 -335
  7. package/dist/form-group-CJzpq9Us.js +29 -0
  8. package/dist/format-BLolnx9j.js +122 -0
  9. package/dist/icons.es.js +4 -1
  10. package/dist/image-scaler-1G-JzJVG.js +530 -0
  11. package/dist/index.es.js +170 -151
  12. package/dist/inputs-9udyzkHR.js +210 -0
  13. package/dist/{mobile-nav-wrapper-Dj67Pb8l.js → mobile-nav-wrapper-Dm9DinRD.js} +2 -2
  14. package/dist/molecules.es.js +46 -39
  15. package/dist/organisms.es.js +55 -49
  16. package/dist/pages.es.js +1 -1
  17. package/dist/range-calendar-BMWSJTE0.js +833 -0
  18. package/dist/{sidebar-menu-page-BVryQj2Z.js → sidebar-menu-page-D4WMgz5U.js} +6 -6
  19. package/dist/{signature-panel-xXbYWejE.js → signature-panel-CcRmukPe.js} +598 -252
  20. package/dist/templates.es.js +2 -2
  21. package/dist/{tooltip-CESEqMCU.js → tooltip-PupzYM1r.js} +27 -34
  22. package/dist/types/components/atoms/atoms.d.ts +1 -0
  23. package/dist/types/components/atoms/form/form-group.d.ts +12 -0
  24. package/dist/types/components/atoms/form/inputs/input-classes.d.ts +2 -2
  25. package/dist/types/components/atoms/form/inputs/inputs.d.ts +0 -7
  26. package/dist/types/components/molecules/date-time/date-range-picker.d.ts +10 -0
  27. package/dist/types/components/molecules/empty/empty-state.d.ts +9 -0
  28. package/dist/types/components/molecules/files/attachment/attachment-input.d.ts +9 -0
  29. package/dist/types/components/molecules/files/attachment/attachment.d.ts +10 -0
  30. package/dist/types/components/molecules/files/attachment/orientation.d.ts +1 -0
  31. package/dist/types/components/molecules/files/attachment/type.d.ts +1 -0
  32. package/dist/types/components/molecules/form/form-card.d.ts +31 -0
  33. package/dist/types/components/molecules/image/image-uploader.d.ts +9 -0
  34. package/dist/types/components/molecules/image/logo-uploader.d.ts +9 -0
  35. package/dist/types/components/molecules/molecules.d.ts +5 -0
  36. package/dist/types/components/molecules/notifications/notification.d.ts +3 -3
  37. package/dist/types/components/organisms/calendar/calendar.d.ts +6 -0
  38. package/dist/types/components/organisms/calendar/month/calendar-header.d.ts +7 -0
  39. package/dist/types/components/organisms/calendar/month-selector.d.ts +5 -0
  40. package/dist/types/components/organisms/calendar/range/calendar-header.d.ts +7 -0
  41. package/dist/types/components/organisms/calendar/range/day-header.d.ts +1 -0
  42. package/dist/types/components/organisms/calendar/range/days-of-week-header.d.ts +1 -0
  43. package/dist/types/components/organisms/calendar/range/month-calendar.d.ts +17 -0
  44. package/dist/types/components/organisms/calendar/range/month-selector.d.ts +5 -0
  45. package/dist/types/components/organisms/calendar/range/navigation-button.d.ts +1 -0
  46. package/dist/types/components/organisms/calendar/range/range-calendar.d.ts +72 -0
  47. package/dist/types/components/organisms/calendar/range/range-day-cell.d.ts +10 -0
  48. package/dist/types/components/organisms/calendar/range/range-days-grid.d.ts +6 -0
  49. package/dist/types/components/organisms/calendar/range/range-toggle.d.ts +7 -0
  50. package/dist/types/components/organisms/calendar/range/year-selector.d.ts +4 -0
  51. package/dist/types/components/organisms/calendar/year-selector.d.ts +5 -0
  52. package/dist/types/components/organisms/lists/data-table-body.d.ts +1 -1
  53. package/dist/types/components/organisms/lists/data-table.d.ts +7 -0
  54. package/dist/types/components/organisms/lists/dynamic-data-table.d.ts +2 -0
  55. package/dist/types/components/organisms/lists/dynamic-table.d.ts +2 -0
  56. package/dist/types/components/organisms/lists/scrollable-data-table.d.ts +2 -0
  57. package/dist/types/components/organisms/lists/scrollable-table.d.ts +2 -0
  58. package/dist/types/components/organisms/lists/skeleton-examples.d.ts +12 -0
  59. package/dist/types/components/organisms/lists/skeleton-table-row.d.ts +6 -0
  60. package/dist/types/components/organisms/organisms.d.ts +6 -0
  61. package/dist/types/components/organisms/tabs/button-tab.d.ts +2 -2
  62. package/dist/types/components/organisms/tabs/tab-group.d.ts +3 -3
  63. package/dist/types/components/organisms/tabs/tab-navigation.d.ts +2 -2
  64. package/dist/types/components/organisms/tabs/tab.d.ts +2 -2
  65. package/dist/types/components/organisms/tabs/underlined-button-tab.d.ts +60 -0
  66. package/dist/types/components/organisms/tabs/underlined-tab-group.d.ts +48 -0
  67. package/dist/types/components/organisms/tabs/underlined-tab-navigation.d.ts +63 -0
  68. package/dist/types/components/organisms/tabs/underlined-tab.d.ts +36 -0
  69. package/dist/types/demo.d.ts +0 -0
  70. package/dist/types/ui.d.ts +1 -0
  71. package/dist/types/utils/format/format.d.ts +78 -0
  72. package/dist/types/utils/utils.d.ts +2 -0
  73. package/dist/utils.es.js +7 -1
  74. package/dist/veil-CqnAmj-D.js +20 -0
  75. package/package.json +85 -85
  76. package/dist/aside-template-McEj_Gxc.js +0 -35
  77. package/dist/calendar-DQXME-2u.js +0 -440
  78. package/dist/inputs-Dmu4Z-7-.js +0 -209
  79. package/dist/veil-D4dRxILB.js +0 -21
@@ -0,0 +1,833 @@
1
+ import { Div as h, Img as _, Span as H, Button as L, OnState as J, On as z } from "@base-framework/atoms";
2
+ import { Component as Y, Data as B, Atom as j, DateTime as T } from "@base-framework/base";
3
+ import { B as m } from "./buttons-CHEs54Wl.js";
4
+ import { Icons as P } from "./icons.es.js";
5
+ const U = (e, t) => {
6
+ const n = e ? e.getBoundingClientRect() : { top: 0, bottom: 0, left: 0 }, a = t.getBoundingClientRect(), s = 10, r = globalThis.scrollX, l = globalThis.scrollY;
7
+ let i = n.left + r, d = n.bottom + l;
8
+ const g = globalThis.innerHeight - n.bottom, f = n.top;
9
+ return i + a.width > globalThis.innerWidth && (i = globalThis.innerWidth - a.width - s), g < a.height && f > g ? d = n.top + l - a.height - s : g < a.height && (d = n.bottom + l - (a.height - g) - s), { x: i, y: d };
10
+ };
11
+ class Pt extends Y {
12
+ /**
13
+ * This will set up the data.
14
+ *
15
+ * @returns {object}
16
+ */
17
+ setData() {
18
+ const t = this.parent.data || new B();
19
+ return t.set({
20
+ position: { x: 0, y: 0 }
21
+ }), t;
22
+ }
23
+ /**
24
+ * This will get the class size.
25
+ *
26
+ * @returns {string}
27
+ */
28
+ getSize() {
29
+ switch (this.size || "lg") {
30
+ // @ts-ignore
31
+ case "sm":
32
+ return "w-48";
33
+ // @ts-ignore
34
+ case "md":
35
+ return "w-64";
36
+ case "lg":
37
+ return "w-[250px]";
38
+ // @ts-ignore
39
+ case "xl":
40
+ return "w-96";
41
+ // @ts-ignore
42
+ case "2xl":
43
+ return "w-[400px]";
44
+ // @ts-ignore
45
+ case "fit":
46
+ return "w-fit";
47
+ // @ts-ignore
48
+ case "full":
49
+ return "w-full";
50
+ }
51
+ }
52
+ /**
53
+ * This will render the modal component.
54
+ *
55
+ * @returns {object}
56
+ */
57
+ render() {
58
+ const t = this.getSize();
59
+ return h({
60
+ class: `absolute inset-auto fadeIn mt-2 rounded-md p-0 shadow-lg bg-popover min-h-12 backdrop:bg-transparent text-inherit r z-30 ${t}`,
61
+ popover: "manual",
62
+ toggle: (n, { state: a }) => n.newState === "closed" ? a.open = !1 : null,
63
+ style: "top: [[position.y]]px; left: [[position.x]]px"
64
+ }, this.children);
65
+ }
66
+ /**
67
+ * This will setup the states.
68
+ *
69
+ * @returns {object}
70
+ */
71
+ setupStates() {
72
+ return {
73
+ open: {
74
+ id: this.parent.getId(),
75
+ callBack: (a) => {
76
+ this.state.open === !1 && this.destroy();
77
+ }
78
+ }
79
+ };
80
+ }
81
+ /**
82
+ * Updates the dropdown position.
83
+ *
84
+ * @returns {void}
85
+ */
86
+ updatePosition() {
87
+ const t = this.button ?? null, n = this.panel, a = U(t, n);
88
+ this.data.position = a;
89
+ }
90
+ /**
91
+ * This will run after the setup.
92
+ *
93
+ * @returns {void}
94
+ */
95
+ afterSetup() {
96
+ this.panel.showPopover(), this.updatePosition();
97
+ }
98
+ /**
99
+ * This will check if the element clicked was in the
100
+ * component of the button.
101
+ *
102
+ * @param {object} element
103
+ * @returns {boolean}
104
+ */
105
+ isOutsideClick(t) {
106
+ return !this.panel.contains(t) && this.button && !this.button.contains(t);
107
+ }
108
+ /**
109
+ * This will set up the events.
110
+ *
111
+ * @returns {array}
112
+ */
113
+ setupEvents() {
114
+ return [
115
+ ["click", document, (t) => {
116
+ this.isOutsideClick(t.target) && (this.state.open = !1);
117
+ }],
118
+ ["resize", globalThis, (t) => this.updatePosition()],
119
+ ["scroll", document, (t) => this.updatePosition()]
120
+ ];
121
+ }
122
+ /**
123
+ * This will override the set up to use the app shell.
124
+ *
125
+ * @param {object} container
126
+ */
127
+ setContainer(t) {
128
+ this.container = app.root;
129
+ }
130
+ /**
131
+ * This will hide the popover before destroying.
132
+ *
133
+ * @returns {void}
134
+ */
135
+ beforeDestroy() {
136
+ this.panel.hidePopover();
137
+ }
138
+ }
139
+ const q = j(({ src: e, alt: t }) => !e || e.indexOf(".") === -1 && e.indexOf("[[") === -1 ? null : _({
140
+ class: "absolute w-full h-full rounded-full object-cover fadeIn",
141
+ src: e,
142
+ alt: t,
143
+ /**
144
+ * If there's an error loading the image, hide it.
145
+ */
146
+ error: (n) => n.target.style.display = "none"
147
+ })), K = (e) => e && (Array.isArray(e) && (e = e.join(" ")), typeof e != "string" && (e = String(e)), e.split(" ").map((t) => t.charAt(0)).join("").toUpperCase()), G = (e) => !e || e.length < 2 ? e : K(e), Q = (e) => H([e, (t, n) => {
148
+ n.textContent = G(t);
149
+ }]), A = {
150
+ xs: "h-6 w-6",
151
+ sm: "h-8 w-8",
152
+ md: "h-12 w-12",
153
+ lg: "h-16 w-16",
154
+ xl: "h-24 w-24",
155
+ "2xl": "h-32 w-32",
156
+ "3xl": "h-48 w-48",
157
+ "4xl": "h-64 w-64",
158
+ default: "h-12 w-12"
159
+ }, I = {
160
+ xs: "text-[7px]",
161
+ sm: "text-xs",
162
+ md: "text-base",
163
+ lg: "text-xl",
164
+ xl: "text-2xl",
165
+ "2xl": "text-3xl",
166
+ "3xl": "text-4xl",
167
+ "4xl": "text-5xl",
168
+ default: "text-base"
169
+ }, V = (e) => A[e] || A.default, Z = (e) => I[e] || I.default, tt = (e, t = null, n = "md") => {
170
+ const a = G(e), s = Z(n);
171
+ return h(
172
+ {
173
+ class: `
174
+ flex items-center justify-center w-full h-full rounded-full
175
+ bg-muted text-muted-foreground font-medium
176
+ ${s}
177
+ `
178
+ },
179
+ [
180
+ t ? Q(t) : H({ class: "uppercase" }, a)
181
+ ]
182
+ );
183
+ }, Tt = j(({ src: e, alt: t, fallbackText: n, watcherFallback: a, size: s }) => {
184
+ const r = V(s);
185
+ return h(
186
+ {
187
+ class: `relative flex items-center justify-center ${r}`
188
+ },
189
+ [
190
+ q({ src: e, alt: t }),
191
+ tt(n, a, s)
192
+ ]
193
+ );
194
+ }), et = ({ currentMonth: e, currentYear: t, onSelect: n }) => h(
195
+ { class: "grid grid-cols-3 gap-2" },
196
+ T.monthNames.map(
197
+ (a, s) => m(
198
+ {
199
+ click: (r) => {
200
+ r.preventDefault(), r.stopPropagation(), n(s);
201
+ },
202
+ variant: e === s ? "primary" : "ghost",
203
+ "aria-label": `Select ${a} ${t}`
204
+ },
205
+ a.substring(0, 3)
206
+ )
207
+ )
208
+ ), D = (e) => (e *= 1, e < 10 ? `0${e}` : String(e)), nt = (e) => (e.indexOf("T") === -1 && e.indexOf(" ") === -1 && (e += "T00:00:01"), e.replace(" ", "T"), e), w = (e, t, n) => `${e}-${D(t + 1)}-${D(n)}`, at = (e) => e ? "bg-accent text-primary" : "", st = (e) => e ? "text-muted-foreground opacity-50" : "", rt = (e, t) => e === t, ot = (e, t) => rt(e, t) ? "bg-primary text-primary-foreground" : "", it = (e, t, n, a) => {
209
+ const s = ot(t, a);
210
+ return s || (e ? at(e) : n ? st(n) : "text-foreground");
211
+ }, N = (e) => {
212
+ const {
213
+ day: t,
214
+ currentDate: n,
215
+ date: a,
216
+ isToday: s,
217
+ isOutsideMonth: r,
218
+ select: l,
219
+ disabled: i
220
+ } = e;
221
+ return L(
222
+ {
223
+ class: `
224
+ flex items-center justify-center h-9 w-auto p-0 font-normal text-sm rounded-md
225
+ ${it(s, n, r, a)}
226
+ hover:bg-muted/50 hover:text-muted-foreground focus:z-10
227
+ disabled:pointer-events-none disabled:opacity-50
228
+ `,
229
+ disabled: i || t === null,
230
+ "aria-label": t ? `Day ${t}` : null,
231
+ // Only call select if it's not disabled.
232
+ click: () => !i && l(a)
233
+ },
234
+ t.toString()
235
+ );
236
+ }, O = (e, t, n, a) => e === a.date && t === a.month && n === a.year, lt = (e, t, n, a = !1) => {
237
+ const { year: s, month: r } = e, l = w(s, r, e.date), i = new Date(s, r, 1).getDay(), d = new Date(s, r + 1, 0).getDate(), g = new Date(s, r, 0).getDate(), f = [], C = r === 0 ? 11 : r - 1, v = r === 0 ? s - 1 : s;
238
+ for (let o = i - 1; o >= 0; o--) {
239
+ const u = g - o, p = O(u, C, v, t), y = new Date(v, C, u) < new Date(t.year, t.month, t.date), x = a && y;
240
+ f.push(
241
+ N({
242
+ day: u,
243
+ currentDate: l,
244
+ date: w(v, C, u),
245
+ isToday: p,
246
+ isOutsideMonth: !0,
247
+ select: n,
248
+ disabled: x
249
+ })
250
+ );
251
+ }
252
+ for (let o = 1; o <= d; o++) {
253
+ const u = O(o, r, s, t), p = new Date(s, r, o) < new Date(t.year, t.month, t.date), y = a && p;
254
+ f.push(
255
+ N({
256
+ day: o,
257
+ currentDate: l,
258
+ date: w(s, r, o),
259
+ isToday: u,
260
+ isOutsideMonth: !1,
261
+ select: n,
262
+ disabled: y
263
+ })
264
+ );
265
+ }
266
+ const b = r === 11 ? 0 : r + 1, $ = r === 11 ? s + 1 : s, c = (7 - f.length % 7) % 7;
267
+ for (let o = 1; o <= c; o++) {
268
+ const u = O(o, b, $, t), p = new Date($, b, o) < new Date(t.year, t.month, t.date), y = a && p;
269
+ f.push(
270
+ N({
271
+ day: o,
272
+ currentDate: l,
273
+ date: w($, b, o),
274
+ isToday: u,
275
+ isOutsideMonth: !0,
276
+ select: n,
277
+ disabled: y
278
+ })
279
+ );
280
+ }
281
+ return f;
282
+ }, R = ({ label: e, click: t }) => m(
283
+ {
284
+ class: `
285
+ inline-flex items-center justify-center h-7 w-7 bg-transparent p-0
286
+ opacity-50 hover:opacity-100 text-muted-foreground absolute
287
+ ${e === "Previous" ? "left-1" : "right-1"}
288
+ focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2
289
+ `,
290
+ click: t,
291
+ "aria-label": `${e} month`,
292
+ variant: "icon",
293
+ icon: e === "Previous" ? P.chevron.single.left : P.chevron.single.right
294
+ }
295
+ ), ct = ({ onMonthClick: e, onYearClick: t, next: n, previous: a }) => h({ class: "flex items-center justify-center gap-x-2 relative min-h-12 text-sm font-medium" }, [
296
+ m({ click: e, variant: "ghost", "aria-label": "Select month" }, "[[monthName]]"),
297
+ m({ click: t, variant: "ghost", "aria-label": "Select year" }, "[[current.year]]"),
298
+ R({ label: "Previous", click: a }),
299
+ R({ label: "Next", click: n })
300
+ ]), ht = (e) => h(
301
+ { class: "flex items-center justify-center h-9 w-auto text-[0.8rem] font-normal text-muted-foreground" },
302
+ e
303
+ ), ut = () => ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map(ht), dt = (e) => h({ class: "rdp flex flex-auto flex-col w-full gap-y-1" }, [
304
+ ct({
305
+ onMonthClick: e.onMonthClick,
306
+ onYearClick: e.onYearClick,
307
+ next: e.next,
308
+ previous: e.previous
309
+ }),
310
+ h({
311
+ class: "flex flex-auto flex-col w-full",
312
+ onSet: [
313
+ "currentDate",
314
+ () => [
315
+ h({ class: "grid grid-cols-7" }, ut()),
316
+ h(
317
+ { class: "grid grid-cols-7" },
318
+ lt(
319
+ e.current,
320
+ e.today,
321
+ e.select,
322
+ e.blockPriorDates
323
+ )
324
+ )
325
+ ]
326
+ ]
327
+ })
328
+ ]), gt = ({ currentMonth: e, currentYear: t, onSelect: n }) => {
329
+ const a = t - 50, s = Array.from({ length: 101 }, (r, l) => a + l);
330
+ return h(
331
+ { class: "grid grid-cols-4 gap-2 overflow-y-auto max-h-72" },
332
+ s.map(
333
+ (r) => m(
334
+ {
335
+ click: (l) => {
336
+ l.preventDefault(), l.stopPropagation(), n(r);
337
+ },
338
+ variant: r === t ? "primary" : "ghost",
339
+ "aria-label": `Select ${r}`
340
+ },
341
+ r.toString()
342
+ )
343
+ )
344
+ );
345
+ };
346
+ class Nt extends Y {
347
+ /**
348
+ * This will declare the props for the compiler.
349
+ *
350
+ * @returns {void}
351
+ */
352
+ declareProps() {
353
+ this.selectedDate = null, this.selectedCallBack = null, this.blockPriorDates = !1;
354
+ }
355
+ /**
356
+ * This will get the selected data.
357
+ *
358
+ * @param {object} today
359
+ * @returns {Date}
360
+ */
361
+ getSelectedDate(t) {
362
+ const n = this.selectedDate ? new Date(nt(this.selectedDate)) : t;
363
+ return new Date(n.getFullYear(), n.getMonth(), n.getDate());
364
+ }
365
+ /**
366
+ * This will set up the data for the calendar.
367
+ *
368
+ * @returns {Data}
369
+ */
370
+ setData() {
371
+ const t = /* @__PURE__ */ new Date(), n = this.getSelectedDate(t), a = n.getMonth();
372
+ return new B({
373
+ monthName: this.getMonthName(a),
374
+ currentDate: `${n.getFullYear()}-${a + 1}-${n.getDate()}`,
375
+ current: {
376
+ date: n.getDate(),
377
+ year: n.getFullYear(),
378
+ month: a
379
+ },
380
+ today: {
381
+ date: t.getDate(),
382
+ month: t.getMonth(),
383
+ year: t.getFullYear()
384
+ }
385
+ });
386
+ }
387
+ /**
388
+ * This will set up the states for the calendar.
389
+ *
390
+ * @return {object}
391
+ */
392
+ setupStates() {
393
+ return {
394
+ view: "calendar"
395
+ // 'calendar' | 'months' | 'years'
396
+ };
397
+ }
398
+ /**
399
+ * This will get the name of the month.
400
+ *
401
+ * @param {number} month
402
+ * @returns {string}
403
+ */
404
+ getMonthName(t) {
405
+ return T.monthNames[t];
406
+ }
407
+ /**
408
+ * This will go to the previous month.
409
+ *
410
+ * @returns {void}
411
+ */
412
+ goToPreviousMonth() {
413
+ const t = this.data;
414
+ let n = t.current.month, a = t.current.year;
415
+ n === 0 ? (n = 11, a--) : n--, this.setCurrentDate(n, a);
416
+ }
417
+ /**
418
+ * This will go to the next month.
419
+ *
420
+ * @returns {void}
421
+ */
422
+ goToNextMonth() {
423
+ const t = this.data;
424
+ let n = t.current.month, a = t.current.year;
425
+ n === 11 ? (n = 0, a++) : n++, this.setCurrentDate(n, a);
426
+ }
427
+ /**
428
+ * This will set the current month and year.
429
+ *
430
+ * @param {number} month
431
+ * @param {number} year
432
+ * @param {number} [date=null]
433
+ * @returns {void}
434
+ */
435
+ setCurrentDate(t, n, a = null) {
436
+ const s = this.data;
437
+ s.current.month = t, s.current.year = n, typeof a == "number" && (s.current.date = D(a)), s.currentDate = `${n}-${D(t + 1)}-${s.current.date}`, s.monthName = this.getMonthName(t);
438
+ }
439
+ /**
440
+ * This will select a date.
441
+ *
442
+ * @param {string} date
443
+ * @returns {void}
444
+ */
445
+ selectDate(t) {
446
+ const n = /* @__PURE__ */ new Date(t + "T00:00:00");
447
+ this.setCurrentDate(n.getMonth(), n.getFullYear(), n.getDate()), typeof this.selectedCallBack == "function" && this.selectedCallBack(this.data.currentDate);
448
+ }
449
+ /**
450
+ * This will render the calendar.
451
+ *
452
+ * @returns {object}
453
+ */
454
+ render() {
455
+ return h({ class: "calendar-container p-3 rounded-md border min-w-80" }, [
456
+ J("view", (t) => {
457
+ switch (t) {
458
+ case "months":
459
+ return et(
460
+ {
461
+ currentMonth: this.data.current.month,
462
+ currentYear: this.data.current.year,
463
+ onSelect: (n) => {
464
+ this.setCurrentDate(n, this.data.current.year), this.state.view = "calendar";
465
+ }
466
+ }
467
+ );
468
+ case "years":
469
+ return gt(
470
+ {
471
+ currentMonth: this.data.current.month,
472
+ currentYear: this.data.current.year,
473
+ onSelect: (n) => {
474
+ this.setCurrentDate(this.data.current.month, n), this.state.view = "calendar";
475
+ }
476
+ }
477
+ );
478
+ default:
479
+ return dt({
480
+ current: this.data.current,
481
+ today: this.data.today,
482
+ select: (n) => this.selectDate(n),
483
+ next: () => this.goToNextMonth(),
484
+ previous: () => this.goToPreviousMonth(),
485
+ blockPriorDates: this.blockPriorDates || !1,
486
+ onMonthClick: (n) => {
487
+ n.preventDefault(), n.stopPropagation(), this.state.view = "months";
488
+ },
489
+ onYearClick: (n) => {
490
+ n.preventDefault(), n.stopPropagation(), this.state.view = "years";
491
+ }
492
+ });
493
+ }
494
+ })
495
+ ]);
496
+ }
497
+ }
498
+ const W = ({ label: e, click: t }) => m(
499
+ {
500
+ class: `
501
+ inline-flex items-center justify-center h-7 w-7 bg-transparent p-0
502
+ opacity-50 hover:opacity-100 text-muted-foreground absolute
503
+ ${e === "Previous" ? "left-1" : "right-1"}
504
+ focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2
505
+ `,
506
+ click: t,
507
+ "aria-label": `${e} month`,
508
+ variant: "icon",
509
+ icon: e === "Previous" ? P.chevron.single.left : P.chevron.single.right
510
+ }
511
+ ), ft = ({ onMonthClick: e, onYearClick: t, next: n, previous: a }) => h({ class: "flex items-center justify-center gap-x-2 relative min-h-12 text-sm font-medium" }, [
512
+ m({ click: e, variant: "ghost", "aria-label": "Select month" }, "[[monthName]]"),
513
+ m({ click: t, variant: "ghost", "aria-label": "Select year" }, "[[current.year]]"),
514
+ W({ label: "Previous", click: a }),
515
+ W({ label: "Next", click: n })
516
+ ]), mt = (e) => h({ class: "h-9 flex items-center justify-center font-medium" }, e), pt = () => h(
517
+ { class: "grid grid-cols-7 gap-1 text-center text-xs font-medium text-muted-foreground mb-2" },
518
+ ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map(mt)
519
+ ), yt = ({ day: e, iso: t, disabled: n, isStart: a, isEnd: s, isBetween: r, isOtherMonth: l, click: i }) => {
520
+ let d = "ghost", g = "";
521
+ return a || s ? (d = "default", g = "bg-primary text-primary-foreground hover:bg-primary/90") : r && (g = "bg-accent text-accent-foreground hover:bg-accent/80"), n && (g += " opacity-50 cursor-not-allowed"), l && (g += " text-muted-foreground opacity-50"), m(
522
+ {
523
+ class: `flex items-center justify-center p-0 text-sm font-medium rounded-md transition-colors ${g}`,
524
+ variant: d,
525
+ disabled: n,
526
+ click: (f) => {
527
+ f.preventDefault(), f.stopPropagation(), n || i();
528
+ }
529
+ },
530
+ e.toString()
531
+ );
532
+ }, Dt = ({ today: e, current: t, blockPriorDates: n, onDateClick: a }) => {
533
+ const { start: s, end: r } = t, l = new Date(t.year, t.month, 1).getDay(), i = new Date(t.year, t.month + 1, 0).getDate(), d = [], g = t.month === 0 ? 11 : t.month - 1, f = t.month === 0 ? t.year - 1 : t.year, C = new Date(f, g + 1, 0).getDate(), v = t.month === 11 ? 0 : t.month + 1, b = t.month === 11 ? t.year + 1 : t.year;
534
+ for (let c = l - 1; c >= 0; c--) {
535
+ const o = C - c, u = w(f, g, o), p = new Date(f, g, o), y = new Date(e.year, e.month, e.date), x = p < y, M = n && x, S = s === u, k = r === u, X = s && r && u > s && u < r;
536
+ d.push({
537
+ day: o,
538
+ iso: u,
539
+ disabled: M,
540
+ isStart: S,
541
+ isEnd: k,
542
+ isBetween: X,
543
+ isOtherMonth: !0,
544
+ click: () => a(u)
545
+ });
546
+ }
547
+ for (let c = 1; c <= i; c++) {
548
+ const o = w(t.year, t.month, c), u = new Date(t.year, t.month, c), p = new Date(e.year, e.month, e.date), y = u < p, x = n && y, M = s === o, S = r === o, k = s && r && o > s && o < r;
549
+ d.push({
550
+ day: c,
551
+ iso: o,
552
+ disabled: x,
553
+ isStart: M,
554
+ isEnd: S,
555
+ isBetween: k,
556
+ isOtherMonth: !1,
557
+ click: () => {
558
+ a(o);
559
+ }
560
+ });
561
+ }
562
+ const F = (7 - d.length % 7) % 7;
563
+ for (let c = 1; c <= F; c++) {
564
+ const o = w(b, v, c), u = new Date(b, v, c), p = new Date(e.year, e.month, e.date), y = u < p, x = n && y, M = s === o, S = r === o, k = s && r && o > s && o < r;
565
+ d.push({
566
+ day: c,
567
+ iso: o,
568
+ disabled: x,
569
+ isStart: M,
570
+ isEnd: S,
571
+ isBetween: k,
572
+ isOtherMonth: !0,
573
+ click: () => a(o)
574
+ });
575
+ }
576
+ return h(
577
+ { class: "grid grid-cols-7 gap-1" },
578
+ d.map(
579
+ (c, o) => yt({
580
+ day: c.day,
581
+ iso: c.iso,
582
+ disabled: c.disabled,
583
+ isStart: c.isStart,
584
+ isEnd: c.isEnd,
585
+ isBetween: c.isBetween,
586
+ isOtherMonth: c.isOtherMonth,
587
+ click: c.click
588
+ })
589
+ )
590
+ );
591
+ }, xt = j((e, t) => h({ class: "flex flex-auto flex-col" }, [
592
+ ft({
593
+ onMonthClick: e.onMonthClick,
594
+ onYearClick: e.onYearClick,
595
+ next: e.next,
596
+ previous: e.previous
597
+ }),
598
+ h({
599
+ class: "flex flex-auto flex-col w-full",
600
+ onSet: [
601
+ "currentDate",
602
+ () => [
603
+ pt(),
604
+ Dt({
605
+ today: e.today,
606
+ current: e.current,
607
+ blockPriorDates: e.blockPriorDates,
608
+ onDateClick: e.onDateClick
609
+ })
610
+ ]
611
+ ]
612
+ })
613
+ ])), wt = ({ currentMonth: e, currentYear: t, onSelect: n }) => h(
614
+ { class: "grid grid-cols-3 gap-2" },
615
+ T.monthNames.map(
616
+ (a, s) => m(
617
+ {
618
+ click: (r) => {
619
+ r.preventDefault(), r.stopPropagation(), n(s);
620
+ },
621
+ variant: e === s ? "primary" : "ghost",
622
+ "aria-label": `Select ${a} ${t}`
623
+ },
624
+ a.substring(0, 3)
625
+ )
626
+ )
627
+ ), vt = ({ start: e, end: t, selecting: n, onSelectStart: a, onSelectEnd: s }) => h({ class: "flex gap-x-2 mb-4" }, [
628
+ z("selecting", (r) => m({
629
+ click: a,
630
+ variant: r === "start" ? "primary" : "outline",
631
+ class: "flex-1"
632
+ }, [
633
+ h({ class: "font-medium" }, E("current.start", "Start Date"))
634
+ ])),
635
+ z("selecting", (r) => m({
636
+ click: s,
637
+ variant: r === "end" ? "primary" : "outline",
638
+ class: "flex-1"
639
+ }, [
640
+ h({ class: "font-medium" }, E("current.end", "End Date"))
641
+ ]))
642
+ ]), E = (e, t) => [`[[${e}]]`, (n) => n == null ? t : bt(n)], bt = (e) => {
643
+ const t = /* @__PURE__ */ new Date(e + "T00:00:00"), n = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], a = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
644
+ return `${n[t.getDay()]}, ${t.getDate()} ${a[t.getMonth()]}`;
645
+ }, Ct = ({ currentYear: e, onSelect: t }) => {
646
+ const n = e - 50, a = Array.from({ length: 101 }, (s, r) => n + r);
647
+ return h(
648
+ { class: "grid grid-cols-4 gap-2 overflow-y-auto max-h-72" },
649
+ a.map(
650
+ (s) => m(
651
+ {
652
+ click: (r) => {
653
+ r.preventDefault(), r.stopPropagation(), t(s);
654
+ },
655
+ variant: s === e ? "primary" : "ghost",
656
+ "aria-label": `Select ${s}`
657
+ },
658
+ s.toString()
659
+ )
660
+ )
661
+ );
662
+ };
663
+ class Ot extends Y {
664
+ /**
665
+ * Declare compiler props.
666
+ *
667
+ * @returns {void}
668
+ */
669
+ declareProps() {
670
+ this.startDate = null, this.endDate = null, this.onRangeSelect = null, this.blockPriorDates = !1;
671
+ }
672
+ /**
673
+ * Initialize reactive data for today and current view.
674
+ *
675
+ * @returns {Data}
676
+ */
677
+ setData() {
678
+ const t = /* @__PURE__ */ new Date(), n = this.startDate ? /* @__PURE__ */ new Date(this.startDate + "T00:00:00") : t, a = n.getMonth(), s = n.getFullYear();
679
+ return new B({
680
+ today: {
681
+ date: t.getDate(),
682
+ month: t.getMonth(),
683
+ year: t.getFullYear()
684
+ },
685
+ monthName: this.getMonthName(a),
686
+ currentData: `${n.getFullYear()}-${D(n.getMonth() + 1)}-${D(n.getDate())}`,
687
+ current: {
688
+ date: t.getDate(),
689
+ month: a,
690
+ year: s,
691
+ start: this.startDate,
692
+ end: this.endDate
693
+ },
694
+ selecting: "start"
695
+ });
696
+ }
697
+ /**
698
+ * This will get the name of the month.
699
+ *
700
+ * @param {number} month
701
+ * @returns {string}
702
+ */
703
+ getMonthName(t) {
704
+ return T.monthNames[t];
705
+ }
706
+ /**
707
+ * Initialize component state.
708
+ *
709
+ * @returns {{view:string}}
710
+ */
711
+ setupStates() {
712
+ return {
713
+ view: "calendar"
714
+ // 'calendar', 'months', or 'years'
715
+ };
716
+ }
717
+ /**
718
+ * Handle a date cell click.
719
+ *
720
+ * @param {string} isoDate
721
+ * @returns {void}
722
+ */
723
+ handleClick(t) {
724
+ if (this.data.selecting === "start") {
725
+ this.data.current.start = t, this.data.current.end = null, this.data.selecting = "end";
726
+ const n = /* @__PURE__ */ new Date(t + "T00:00:00");
727
+ this.setCurrent({
728
+ month: n.getMonth(),
729
+ year: n.getFullYear(),
730
+ date: n.getDate()
731
+ });
732
+ } else {
733
+ this.data.current.start && t < this.data.current.start ? (this.data.current.end = this.data.current.start, this.data.current.start = t) : this.data.current.end = t, this.data.selecting = "start";
734
+ const n = /* @__PURE__ */ new Date(t + "T00:00:00");
735
+ this.setCurrent({
736
+ month: n.getMonth(),
737
+ year: n.getFullYear(),
738
+ date: n.getDate()
739
+ }), typeof this.onRangeSelect == "function" && this.onRangeSelect(this.data.current.start, this.data.current.end);
740
+ }
741
+ }
742
+ /**
743
+ * Update current month/year in data.
744
+ *
745
+ * @param {object} obj
746
+ * @returns {void}
747
+ */
748
+ setCurrent({ month: t, year: n, date: a = null }) {
749
+ const s = this.data.current;
750
+ s.month = (t + 12) % 12, s.year = n + (t < 0 ? -1 : t > 11 ? 1 : 0), a !== null && (s.date = a), this.data.monthName = this.getMonthName(s.month), this.data.currentDate = `${n}-${D(t + 1)}-${D(s.date)}`;
751
+ }
752
+ /**
753
+ * Render the range calendar.
754
+ *
755
+ * @returns {object}
756
+ */
757
+ render() {
758
+ const { today: t, current: n, selecting: a } = this.data, { start: s, end: r } = n;
759
+ return h({ class: "range-calendar border border-border rounded-lg shadow-md p-4 w-full max-w-sm min-w-80" }, [
760
+ vt({
761
+ start: s,
762
+ end: r,
763
+ selecting: a,
764
+ onSelectStart: (l) => {
765
+ l.preventDefault(), l.stopPropagation(), this.data.selecting = "start";
766
+ },
767
+ onSelectEnd: (l) => {
768
+ l.preventDefault(), l.stopPropagation(), this.data.selecting = "end";
769
+ }
770
+ }),
771
+ J("view", (l) => {
772
+ switch (l) {
773
+ case "months":
774
+ return wt(
775
+ {
776
+ currentMonth: n.month,
777
+ currentYear: n.year,
778
+ onSelect: (i) => {
779
+ this.setCurrent({ month: i, year: n.year }), this.state.view = "calendar";
780
+ }
781
+ }
782
+ );
783
+ case "years":
784
+ return Ct(
785
+ {
786
+ currentYear: n.year,
787
+ onSelect: (i) => {
788
+ this.setCurrent({ month: n.month, year: i }), this.state.view = "calendar";
789
+ }
790
+ }
791
+ );
792
+ default:
793
+ return xt({
794
+ monthName: this.data.monthName,
795
+ year: n.year,
796
+ today: t,
797
+ current: n,
798
+ blockPriorDates: this.blockPriorDates,
799
+ onDateClick: (i) => this.handleClick(i),
800
+ onMonthClick: (i) => {
801
+ i.preventDefault(), i.stopPropagation(), this.state.view = "months";
802
+ },
803
+ onYearClick: (i) => {
804
+ i.preventDefault(), i.stopPropagation(), this.state.view = "years";
805
+ },
806
+ next: () => {
807
+ const i = this.data.current, d = i.month === 11 ? { month: 0, year: i.year + 1 } : { month: i.month + 1, year: i.year };
808
+ this.setCurrent(d);
809
+ },
810
+ previous: () => {
811
+ const i = this.data.current, d = i.month === 0 ? { month: 11, year: i.year - 1 } : { month: i.month - 1, year: i.year };
812
+ this.setCurrent(d);
813
+ }
814
+ });
815
+ }
816
+ })
817
+ ]);
818
+ }
819
+ }
820
+ export {
821
+ Tt as A,
822
+ lt as C,
823
+ N as D,
824
+ w as F,
825
+ dt as M,
826
+ Pt as P,
827
+ Ot as R,
828
+ ht as a,
829
+ Nt as b,
830
+ nt as c,
831
+ U as g,
832
+ D as p
833
+ };