@base-framework/ui 1.1.14 → 1.1.16

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 (35) hide show
  1. package/README.md +44 -0
  2. package/dist/atoms.es.js +37 -34
  3. package/dist/buttons-HW55zbqy.js +127 -0
  4. package/dist/{empty-state-CuciIYY7.js → empty-state-5g6Pdeeg.js} +324 -321
  5. package/dist/full-page-DccgwWsM.js +69 -0
  6. package/dist/icons.es.js +127 -1
  7. package/dist/image-BhZbKYDj.js +237 -0
  8. package/dist/index.es.js +179 -173
  9. package/dist/{mobile-nav-wrapper-C3Lvz7CH.js → mobile-nav-wrapper-DmrkMxyd.js} +77 -84
  10. package/dist/molecules.es.js +5 -5
  11. package/dist/organisms.es.js +52 -51
  12. package/dist/pages.es.js +10 -9
  13. package/dist/sidebar-menu-C5s4Cogh.js +13 -0
  14. package/dist/sidebar-menu-page-DwqCqwzG.js +153 -0
  15. package/dist/signature-panel-CDQgFxuo.js +1364 -0
  16. package/dist/simple-search-input-mCUOwYbp.js +1654 -0
  17. package/dist/skeleton-BlY3opxG.js +7 -0
  18. package/dist/{tooltip-BlFbB8yL.js → tooltip-BmvjA9XQ.js} +104 -84
  19. package/dist/types/components/atoms/atoms.d.ts +2 -0
  20. package/dist/types/components/atoms/material-icon.d.ts +17 -0
  21. package/dist/types/components/atoms/universal-icon.d.ts +3 -0
  22. package/dist/types/components/icons/icons.d.ts +1 -0
  23. package/dist/types/components/icons/material-symbols.d.ts +19 -0
  24. package/dist/types/components/molecules/breadcrumb/breadcrumb.d.ts +2 -2
  25. package/dist/types/components/molecules/image/image-uploader.d.ts +2 -2
  26. package/dist/types/components/molecules/image/logo-uploader.d.ts +2 -2
  27. package/dist/types/components/organisms/navigation/mobile/nav-wrapper/title-header.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/dist/buttons-Dr-bViom.js +0 -77
  30. package/dist/form-group-BB7dLJir.js +0 -29
  31. package/dist/image-BB__4s0g.js +0 -31
  32. package/dist/inputs-CcimrM1k.js +0 -210
  33. package/dist/range-calendar-CzKIBhgb.js +0 -831
  34. package/dist/sidebar-menu-page-BtuUB_XB.js +0 -217
  35. package/dist/signature-panel-DmyPbuRi.js +0 -2186
@@ -1,2186 +0,0 @@
1
- import { Button as k, Div as o, On as C, Span as I, Th as N, UseParent as Q, I as G, Thead as V, Tr as X, Table as B, P as v, Li as w, Time as q, Nav as m, Ul as f, Input as K, Section as L, Canvas as _ } from "@base-framework/atoms";
2
- import { Atom as c, Component as p, Data as T, DateTime as J, router as y, NavLink as M, DataTracker as U, Jot as Z, base as $, Dom as O } from "@base-framework/base";
3
- import { B as P, I as j } from "./buttons-Dr-bViom.js";
4
- import { Icons as D } from "./icons.es.js";
5
- import { TableBody as ee, DataTableBody as te, ScrollableTableBody as se, List as ae, IntervalTimer as ie } from "@base-framework/organisms";
6
- import { C as ne, I as oe, H as le } from "./inputs-CcimrM1k.js";
7
- import { A as re, P as ce } from "./range-calendar-CzKIBhgb.js";
8
- import { V as g } from "./image-BB__4s0g.js";
9
- c((t, e) => ({
10
- class: "flex items-center px-4 py-2",
11
- ...t,
12
- children: e
13
- }));
14
- c(({ value: t, label: e }) => k({
15
- class: "inline-flex flex-auto items-center justify-center whitespace-nowrap rounded-md px-8 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
16
- onState: ["performance", { active: t }],
17
- dataSet: ["performance", ["state", t, "active"]],
18
- click: (s, { state: a }) => a.performance = t
19
- }, e));
20
- class pt extends p {
21
- /**
22
- * This will declare the props for the compiler.
23
- *
24
- * @returns {void}
25
- */
26
- declareProps() {
27
- this.class = "";
28
- }
29
- /**
30
- * This will render the component.
31
- *
32
- * @returns {object}
33
- */
34
- render() {
35
- return o({ class: this.class || "" }, this.children);
36
- }
37
- }
38
- const de = (t) => {
39
- const e = new Date(t, 11, 31), s = new Date(t, 0, 1);
40
- return e.getDay() === 4 || // December 31 is a Thursday
41
- s.getDay() === 4;
42
- }, he = (t) => {
43
- const e = new Date(t.valueOf()), s = (e.getDay() + 6) % 7;
44
- e.setDate(e.getDate() - s + 3);
45
- const a = e.getFullYear(), i = new Date(a, 0, 4);
46
- i.setDate(i.getDate() - (i.getDay() + 6) % 7);
47
- const n = Math.ceil((e - i) / 6048e5) + 1;
48
- return n > 52 && !de(a) ? {
49
- weekNumber: 1,
50
- year: a + 1
51
- } : {
52
- weekNumber: n,
53
- year: a
54
- };
55
- }, ue = (t, e, s) => {
56
- if (s === 0) return [];
57
- const a = new Date(t, e, 0).getDate();
58
- return Array.from(
59
- { length: s },
60
- (i, n) => new Date(t, e - 1, a - s + n + 1)
61
- );
62
- }, fe = (t, e, s) => Array.from({ length: s }, (a, i) => new Date(t, e + 1, i + 1)), W = (t, e) => {
63
- const s = new Date(e, 0, 4), a = (s.getDay() + 6) % 7, i = new Date(s);
64
- i.setDate(s.getDate() - a);
65
- const n = new Date(i);
66
- return n.setDate(i.getDate() + (t - 1) * 7), n;
67
- }, bt = (t, e) => {
68
- const s = new Date(t, e, 1).getDay(), a = new Date(t, e + 1, 0).getDate(), i = [];
69
- let n = [];
70
- for (let l = 1 - s; l <= a; l++) {
71
- const d = new Date(t, e, l);
72
- n.push(l > 0 ? d : null), (n.length === 7 || l === a) && (i.push([...n]), n = []);
73
- }
74
- return i;
75
- }, xt = (t, e) => {
76
- const s = new Date(t, e + 1, 0).getDate(), a = [];
77
- let i = [];
78
- for (let n = 1; n <= s; n++)
79
- i.push(new Date(t, e, n)), i.length === 7 && (a.push(i), i = []);
80
- return i.length > 0 && a.push(i), a;
81
- }, ge = (t, e, s) => {
82
- const a = /* @__PURE__ */ new Date();
83
- return a.getDate() === t && a.getMonth() === e && a.getFullYear() === s;
84
- }, me = ({ day: t, month: e, year: s, weekNumber: a, selectWeek: i }) => {
85
- const n = ge(t, e, s);
86
- return k({
87
- text: t || "",
88
- disabled: !t,
89
- class: `
90
- px-2 py-1 text-center rounded-md
91
- ${n ? "bg-accent text-accent-foreground" : ""}
92
- hover:bg-primary hover:text-primary-foreground
93
- `,
94
- click: () => i(a, s)
95
- });
96
- }, pe = (t, e) => {
97
- const s = new Date(t, e, 1).getDay(), a = new Date(t, e + 1, 0).getDate(), i = ue(t, e, s), n = Array.from({ length: a }, (h, x) => new Date(t, e, x + 1)), l = (i.length + n.length) % 7, d = l === 0 ? 0 : 7 - l, r = fe(t, e, d), u = [...i, ...n, ...r], b = [];
98
- for (let h = 0; h < u.length; h += 7) {
99
- const x = u.slice(h, h + 7), S = x.find((E) => E) || new Date(t, e, 1), { weekNumber: F, year: Y } = he(S);
100
- b.push({
101
- weekNumber: F,
102
- year: Y,
103
- days: x
104
- });
105
- }
106
- return b;
107
- }, be = ({ selectWeek: t }) => C("month", (e, s, { data: a }) => {
108
- const { year: i, month: n, currentDate: l } = a, d = pe(i, n);
109
- return o(
110
- { class: "grid grid-cols-8 gap-1 text-sm px-4 py-2" },
111
- [
112
- // Header row: "Week" label + day-of-week labels
113
- o({ class: "text-xs text-center col-span-1 text-muted-foreground flex items-center" }, "Week"),
114
- o(
115
- {
116
- class: "grid grid-cols-7 col-span-7 text-center text-muted-foreground items-center"
117
- },
118
- ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map(
119
- (r) => I({ class: "px-1 py-1", text: r })
120
- )
121
- ),
122
- // Render each "week" row
123
- ...d.map(
124
- ({ weekNumber: r, days: u, year: b }) => o({
125
- class: "grid grid-cols-8 col-span-8 items-center ring-primary rounded-sm px-1",
126
- onSet: ["currentWeek", {
127
- ring: r
128
- }]
129
- }, [
130
- // Left column: ISO week number
131
- o({
132
- class: "font-medium text-center col-span-1 rounded-sm cursor-pointer",
133
- click: () => t(r, b),
134
- // If you have a 'currentWeek' state, you can highlight it with 'onSet'
135
- onSet: ["currentWeek", {
136
- "text-primary-foreground": r,
137
- "bg-primary": r
138
- }],
139
- text: r ? `W${r}` : ""
140
- }),
141
- // The 7 cells for each day in the row
142
- o(
143
- { class: "grid grid-cols-7 col-span-7 text-center" },
144
- u.map(
145
- (h) => me({
146
- year: h?.getFullYear() || null,
147
- month: h?.getMonth() || null,
148
- day: h?.getDate() || null,
149
- weekNumber: r,
150
- selectWeek: t
151
- })
152
- )
153
- )
154
- ])
155
- )
156
- ]
157
- );
158
- }), z = ({ label: t, click: e }) => P(
159
- {
160
- class: `
161
- inline-flex items-center justify-center h-7 w-7 bg-transparent p-0
162
- opacity-50 hover:opacity-100 text-muted-foreground absolute
163
- ${t === "Previous" ? "left-1" : "right-1"}
164
- focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2
165
- `,
166
- click: e,
167
- "aria-label": `${t} month`,
168
- variant: "icon",
169
- icon: t === "Previous" ? D.chevron.single.left : D.chevron.single.right
170
- }
171
- ), xe = ({ next: t, previous: e }) => o({ class: "flex flex-auto min-h-12 text-sm font-medium relative justify-center items-center" }, [
172
- I("[[monthName]] [[year]]"),
173
- z({
174
- label: "Previous",
175
- click: e
176
- }),
177
- z({
178
- label: "Next",
179
- click: t
180
- })
181
- ]);
182
- class yt extends p {
183
- /**
184
- * This will declare the props for the compiler.
185
- *
186
- * @returns {void}
187
- */
188
- declareProps() {
189
- this.selectedDate = null, this.selectedWeek = null, this.selectedCallBack = null;
190
- }
191
- /**
192
- * Initializes the calendar data.
193
- *
194
- * @returns {Data}
195
- */
196
- setData() {
197
- const e = /* @__PURE__ */ new Date(), s = this.selectedWeek || this.calculateCurrentWeek(e), a = W(s, e.getFullYear());
198
- return new T({
199
- monthName: this.getMonthName(a.getMonth()),
200
- year: a.getFullYear(),
201
- month: a.getMonth(),
202
- currentDate: a.getDate(),
203
- currentWeek: s
204
- });
205
- }
206
- /**
207
- * Determines the current selected date.
208
- *
209
- * @param {Date} today
210
- * @returns {Date}
211
- */
212
- getSelectedDate(e) {
213
- const s = this.selectedDate ? new Date(this.selectedDate) : e;
214
- return new Date(s.getFullYear(), s.getMonth(), s.getDate());
215
- }
216
- /**
217
- * Calculates the ISO week number for a given date.
218
- *
219
- * @param {Date} date
220
- * @returns {number}
221
- */
222
- calculateCurrentWeek(e) {
223
- const s = new Date(e.valueOf()), a = (e.getDay() + 6) % 7;
224
- s.setDate(s.getDate() - a + 3);
225
- const i = s.valueOf();
226
- return s.setMonth(0, 1), s.getDay() !== 4 && s.setMonth(0, 1 + (4 - s.getDay() + 7) % 7), 1 + Math.ceil((i - s) / 6048e5);
227
- }
228
- /**
229
- * Gets the name of the month.
230
- *
231
- * @param {number} month
232
- * @returns {string}
233
- */
234
- getMonthName(e) {
235
- return J.monthNames[e];
236
- }
237
- /**
238
- * Updates the calendar to show the previous month.
239
- *
240
- * @returns {void}
241
- */
242
- goToPreviousMonth() {
243
- const e = this.data;
244
- let { year: s, month: a } = e;
245
- a === 0 ? (a = 11, s--) : a--, this.setDate(a, s);
246
- }
247
- /**
248
- * Updates the calendar to show the next month.
249
- *
250
- * @returns {void}
251
- */
252
- goToNextMonth() {
253
- const e = this.data;
254
- let { year: s, month: a } = e;
255
- a === 11 ? (a = 0, s++) : a++, this.setDate(a, s);
256
- }
257
- /**
258
- * Sets the selected date.
259
- *
260
- * @param {number} month
261
- * @param {number} year
262
- * @param {number|null} [date=null]
263
- * @returns {void}
264
- */
265
- setDate(e, s, a) {
266
- this.data.set({
267
- year: s,
268
- month: e,
269
- monthName: this.getMonthName(e)
270
- }), a && (this.data.currentDate = a);
271
- }
272
- /**
273
- * Handles week selection.
274
- *
275
- * @param {number} weekNumber
276
- * @returns {void}
277
- */
278
- selectWeek(e, s) {
279
- this.data.currentWeek = e;
280
- const a = W(e, s);
281
- this.setDate(a.getMonth(), a.getFullYear(), a.getDate()), typeof this.selectedCallBack == "function" && this.selectedCallBack(e);
282
- }
283
- /**
284
- * Renders the WeekCalendar component.
285
- *
286
- * @returns {object}
287
- */
288
- render() {
289
- return o({ class: "week-calendar-container border rounded-md p-3" }, [
290
- xe({
291
- next: () => this.goToNextMonth(),
292
- previous: () => this.goToPreviousMonth()
293
- }),
294
- be({
295
- selectWeek: (e, s) => this.selectWeek(e, s)
296
- })
297
- ]);
298
- }
299
- }
300
- const ye = (t, e) => {
301
- const s = t.toggleAllSelectedRows();
302
- e.state.checked = !s;
303
- }, ke = (t) => N({ class: `cursor-pointer py-3 px-4 text-base w-10 ${t.class || ""}` }, [
304
- Q((e) => new ne({ class: "mr-2", onChange: (s, a) => ye(e, a) }))
305
- ]), we = ({ align: t, sortable: e, key: s, label: a, sort: i, class: n }) => {
306
- const l = t || "justify-start";
307
- return N({
308
- class: `cursor-pointer py-3 px-4 text-base ${n || ""}`,
309
- click: e && (() => i(s))
310
- }, [
311
- o({ class: `flex flex-auto w-full items-center ${l}` }, [
312
- I(a),
313
- e && G({ class: "ml-2", html: D.arrows.upDown })
314
- ])
315
- ]);
316
- }, R = (t) => V([
317
- X({
318
- class: "text-muted-foreground border-b",
319
- map: [
320
- t.headers,
321
- (e) => e.label === "checkbox" ? ke({ toggle: t.toggle }) : we({
322
- align: e.align,
323
- sortable: e.sortable,
324
- key: e.key,
325
- label: e.label,
326
- sort: t.sort
327
- })
328
- ]
329
- })
330
- ]), ve = ({ key: t, rows: e, selectRow: s, rowItem: a, emptyState: i, skeleton: n, columnCount: l }) => new ee({
331
- cache: "list",
332
- key: t,
333
- items: e,
334
- rowItem: (d) => a(d, s),
335
- class: "divide-y divide-border",
336
- emptyState: i,
337
- skeleton: n,
338
- columnCount: l
339
- });
340
- class A extends p {
341
- /**
342
- * Initializes component data.
343
- *
344
- * @returns {Data}
345
- */
346
- setData() {
347
- let e = this.rows && this.rows.length > 0;
348
- return (this.loadMoreItems || this.tableData) && !e && (e = null), new T({
349
- selectedRows: [],
350
- // @ts-ignore
351
- hasItems: e,
352
- selected: !1
353
- });
354
- }
355
- /**
356
- * This will toggle all selected rows.
357
- *
358
- * @returns {boolean}
359
- */
360
- toggleAllSelectedRows() {
361
- const e = this.list.getRows(), s = this.data.selectedRows.length === e.length, a = s ? [] : e;
362
- return this.data.selectedRows = a, this.updateSelected(), this.updateTable(!s), s;
363
- }
364
- /**
365
- * This will update the selected state.
366
- *
367
- * @returns {void}
368
- */
369
- updateSelected() {
370
- const e = this.data.get("selectedRows");
371
- this.data.selected = e.length > 0;
372
- }
373
- /**
374
- * This will get the selected rows.
375
- *
376
- * @returns {Array<object>}
377
- */
378
- getSelectedRows() {
379
- return this.data.get("selectedRows");
380
- }
381
- /**
382
- * This will update the table rows.
383
- *
384
- * @protected
385
- * @param {boolean} selected
386
- * @returns {void}
387
- */
388
- updateTable(e) {
389
- const s = this.list.getRows();
390
- s.forEach((a) => a.selected = e), this.list.setRows(s);
391
- }
392
- /**
393
- * Handles row selection.
394
- *
395
- * @param {object} row
396
- */
397
- selectRow(e) {
398
- const s = e.selected ?? !1;
399
- e.selected = !s;
400
- const a = this.data.get("selectedRows"), i = e.selected ? [...a, e] : a.filter((n) => n !== e);
401
- this.data.selectedRows = i, this.updateSelected();
402
- }
403
- /**
404
- * Gets the number of header columns.
405
- *
406
- * @returns {number}
407
- */
408
- getHeaderColCount() {
409
- return this.customHeader ? this.customHeader?.children[0]?.children?.length : this.headers ? this.headers.length : 3;
410
- }
411
- /**
412
- * Renders the DataTable component.
413
- *
414
- * @returns {object}
415
- */
416
- render() {
417
- const e = this.border !== !1 ? "border" : "", s = this.getHeaderColCount();
418
- return o({ class: "w-full flex flex-auto flex-col" }, [
419
- C("hasItems", (a) => a === !1 && this.emptyState ? this.emptyState() : null),
420
- o({ class: `w-full rounded-md ${e} overflow-x-auto`, onSet: ["hasItems", { hidden: !1 }] }, [
421
- B({ class: "w-full" }, [
422
- // @ts-ignore
423
- this.headers && R({ headers: this.headers, sort: (a) => this.sortRows(a) }),
424
- // @ts-ignore
425
- this.customHeader ?? null,
426
- ve({
427
- // @ts-ignore
428
- key: this.key,
429
- // @ts-ignore
430
- rows: this.rows,
431
- // @ts-ignore
432
- selectRow: this.selectRow.bind(this),
433
- // @ts-ignore
434
- rowItem: this.rowItem,
435
- // @ts-ignore
436
- emptyState: this.emptyState,
437
- // @ts-ignore
438
- skeleton: this.skeleton,
439
- columnCount: s
440
- })
441
- ])
442
- ])
443
- ]);
444
- }
445
- /**
446
- * This will remove items from the list.
447
- *
448
- * @public
449
- * @param {array} items
450
- * @returns {void}
451
- */
452
- remove(e) {
453
- this.list.remove(e);
454
- }
455
- /**
456
- * This will set the items in the list.
457
- *
458
- * @public
459
- * @param {array} rows
460
- * @returns {void}
461
- */
462
- setRows(e) {
463
- this.list.setRows(e);
464
- }
465
- /**
466
- * This will append items to the list.
467
- *
468
- * @public
469
- * @param {array|object} items
470
- * @returns {void}
471
- */
472
- append(e) {
473
- this.list.append(e);
474
- }
475
- /**
476
- * This will mingle the new items with the old items.
477
- *
478
- * @public
479
- * @param {Array<Object>} newItems
480
- * @param {boolean} withDelete
481
- * @returns {void}
482
- */
483
- mingle(e, s = !1) {
484
- this.list.mingle(e, s);
485
- }
486
- /**
487
- * This will prepend items to the list.
488
- *
489
- * @public
490
- * @param {array|object} items
491
- * @returns {void}
492
- */
493
- prepend(e) {
494
- this.list.prepend(e);
495
- }
496
- /**
497
- * This will remove the selected rows.
498
- *
499
- * @returns {void}
500
- */
501
- beforeDestroy() {
502
- this.data.selectedRows = [];
503
- }
504
- }
505
- const De = (t) => new te({
506
- cache: "list",
507
- loadMoreItems: t.loadMoreItems,
508
- offset: t.offset,
509
- limit: t.limit,
510
- key: t.key,
511
- tableData: t.tableData,
512
- items: t.items,
513
- rowItem: (e) => t.rowItem(e, t.selectRow),
514
- class: "divide-y divide-border",
515
- skeleton: t.skeleton,
516
- columnCount: t.columnCount
517
- });
518
- class Se extends A {
519
- /**
520
- * Renders the DataTable component.
521
- *
522
- * @returns {object}
523
- */
524
- render() {
525
- const e = this.border !== !1 ? "border" : "", s = this.getHeaderColCount();
526
- return o({ class: "w-full flex flex-auto flex-col" }, [
527
- C("hasItems", (a) => a === !1 && this.emptyState ? this.emptyState() : null),
528
- o({ class: `w-full rounded-md ${e} overflow-x-auto`, onSet: ["hasItems", { hidden: !1 }] }, [
529
- B({ class: "w-full" }, [
530
- // @ts-ignore
531
- this.headers && R({ headers: this.headers, sort: (a) => this.sortRows(a) }),
532
- // @ts-ignore
533
- this.customHeader ?? null,
534
- De({
535
- // @ts-ignore
536
- loadMoreItems: this.loadMoreItems,
537
- // @ts-ignore
538
- offset: this.offset,
539
- // @ts-ignore
540
- limit: this.limit,
541
- // @ts-ignore
542
- class: this.class,
543
- // @ts-ignore
544
- tableData: this.tableData,
545
- // @ts-ignore
546
- key: this.key,
547
- // @ts-ignore
548
- items: this.rows,
549
- // @ts-ignore
550
- selectRow: this.selectRow.bind(this),
551
- // @ts-ignore
552
- rowItem: this.rowItem,
553
- // @ts-ignore
554
- skeleton: this.skeleton,
555
- columnCount: s
556
- })
557
- ])
558
- ])
559
- ]);
560
- }
561
- /**
562
- * Refreshes the list.
563
- *
564
- * @returns {void}
565
- */
566
- refresh() {
567
- this.list.refresh();
568
- }
569
- }
570
- const kt = c((t) => new Se(
571
- {
572
- cache: t.cache ?? "list",
573
- tableData: t.data,
574
- loadMoreItems: t.loadMoreItems,
575
- offset: t.offset,
576
- limit: t.limit,
577
- class: t.class,
578
- key: t.key,
579
- rows: t.rows,
580
- rowItem: t.rowItem,
581
- headers: t.headers,
582
- customHeader: t.customHeader,
583
- border: t.border,
584
- emptyState: t.emptyState,
585
- skeleton: t.skeleton
586
- }
587
- )), Ce = (t) => new se({
588
- cache: "list",
589
- scrollContainer: t.scrollContainer,
590
- loadMoreItems: t.loadMoreItems,
591
- offset: t.offset,
592
- limit: t.limit,
593
- key: t.key,
594
- tableData: t.tableData,
595
- items: t.items,
596
- rowItem: (e) => t.rowItem(e, t.selectRow),
597
- class: "divide-y divide-border",
598
- skeleton: t.skeleton,
599
- columnCount: t.columnCount
600
- });
601
- class Ie extends A {
602
- /**
603
- * Renders the DataTable component.
604
- *
605
- * @returns {object}
606
- */
607
- render() {
608
- const e = this.border !== !1 ? "border" : "", s = this.getHeaderColCount();
609
- return o({ class: "w-full flex flex-auto flex-col" }, [
610
- C("hasItems", (a) => a === !1 && this.emptyState ? this.emptyState() : null),
611
- o({ class: `w-full rounded-md ${e} overflow-x-auto`, onSet: ["hasItems", { hidden: !1 }] }, [
612
- B({ class: "w-full" }, [
613
- // @ts-ignore
614
- this.headers && R({ headers: this.headers, sort: (a) => this.sortRows(a) }),
615
- // @ts-ignore
616
- this.customHeader ?? null,
617
- Ce({
618
- // @ts-ignore
619
- scrollContainer: this.scrollContainer,
620
- // @ts-ignore
621
- loadMoreItems: this.loadMoreItems,
622
- // @ts-ignore
623
- offset: this.offset,
624
- // @ts-ignore
625
- limit: this.limit,
626
- // @ts-ignore
627
- class: this.class,
628
- // @ts-ignore
629
- tableData: this.tableData,
630
- // @ts-ignore
631
- key: this.key,
632
- // @ts-ignore
633
- items: this.rows,
634
- // @ts-ignore
635
- selectRow: this.selectRow.bind(this),
636
- // @ts-ignore
637
- rowItem: this.rowItem,
638
- // @ts-ignore
639
- skeleton: this.skeleton,
640
- columnCount: s
641
- })
642
- ])
643
- ])
644
- ]);
645
- }
646
- /**
647
- * Refreshes the list.
648
- *
649
- * @returns {void}
650
- */
651
- refresh() {
652
- this.list.refresh();
653
- }
654
- }
655
- const wt = c((t) => new Ie(
656
- {
657
- cache: t.cache ?? "list",
658
- tableData: t.data,
659
- scrollContainer: t.scrollContainer,
660
- loadMoreItems: t.loadMoreItems,
661
- offset: t.offset,
662
- limit: t.limit,
663
- class: t.class,
664
- key: t.key,
665
- rows: t.rows,
666
- rowItem: t.rowItem,
667
- headers: t.headers,
668
- customHeader: t.customHeader,
669
- border: t.border,
670
- emptyState: t.emptyState,
671
- skeleton: t.skeleton
672
- }
673
- )), Le = c(({ name: t, email: e }) => o({ class: "min-w-0 flex-auto" }, [
674
- v({ class: "text-base font-semibold leading-6 m-0" }, t),
675
- v({ class: "truncate text-sm leading-5 text-muted-foreground m-0" }, e)
676
- ])), Be = () => o({ class: "flex items-center gap-x-1.5" }, [
677
- o({ class: "flex-none rounded-full bg-emerald-500/20 p-1" }, [
678
- o({ class: "h-1.5 w-1.5 rounded-full bg-emerald-500" })
679
- ]),
680
- v({ class: "text-xs leading-5 text-gray-500" }, "Online")
681
- ]), Te = (t) => v({ class: "text-xs leading-5 text-muted-foreground" }, [
682
- I("Last seen "),
683
- q({ datetime: t }, "3h ago")
684
- ]), Me = (t, e) => t === "online" ? Be() : Te(e), Pe = c(({ role: t, lastSeen: e, status: s }) => o({ class: "hidden shrink-0 sm:flex sm:flex-col sm:items-end" }, [
685
- v({ class: "text-sm leading-6 m-0" }, t),
686
- Me(s, e)
687
- ])), Re = (t) => t.split(" ").map((s) => s[0]).join(""), $e = c((t) => w({ class: "fadeIn flex justify-between gap-x-6 py-4 px-4 rounded-md hover:bg-muted/50" }, [
688
- o({ class: "flex min-w-0 gap-x-4" }, [
689
- re({ src: t.image, alt: t.name, fallbackText: Re(t.name) }),
690
- Le({ name: t.name, email: t.email })
691
- ]),
692
- Pe({
693
- role: t.role,
694
- lastSeen: t.lastSeen,
695
- status: t.status
696
- })
697
- ])), vt = c((t) => new ae({
698
- cache: "list",
699
- key: "name",
700
- items: t.users,
701
- role: "list",
702
- class: "divide-y divide-border",
703
- rowItem: $e
704
- })), Oe = (t, e) => e.includes(t), We = (t, e, s) => t.exact ? s === e : Oe(e, s), ze = ({ text: t, href: e, exact: s, hidden: a }) => new M({
705
- text: t,
706
- href: e,
707
- exact: s,
708
- dataSet: ["selected", ["state", !0, "active"]],
709
- class: `${a ? "hidden" : "inline-flex"} items-center justify-center whitespace-nowrap px-3 py-1.5 text-sm font-medium transition-all rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring focus-visible:ring-offset-background hover:bg-primary hover:text-primary-foreground disabled:opacity-50 disabled:pointer-events-none data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm`
710
- });
711
- class Dt extends p {
712
- /**
713
- * This will declare the props for the compiler.
714
- *
715
- * @returns {void}
716
- */
717
- declareProps() {
718
- this.options = [], this.class = "";
719
- }
720
- /**
721
- * This will configure the links.
722
- */
723
- beforeSetup() {
724
- this.links = [];
725
- }
726
- /**
727
- * This will render the component.
728
- *
729
- * @returns {object}
730
- */
731
- render() {
732
- return m(
733
- { class: `flex items-center justify-center p-2 text-muted-foreground rounded-md ${this.class || ""}` },
734
- [
735
- f({
736
- class: "flex gap-x-4",
737
- map: [this.options, (e) => this.addLink(e)],
738
- watch: {
739
- value: ["[[path]]", y.data],
740
- callBack: this.updateLinks.bind(this)
741
- }
742
- })
743
- ]
744
- );
745
- }
746
- /**
747
- * This will update the links.
748
- *
749
- * @returns {void}
750
- */
751
- afterSetup() {
752
- const e = y.data.path;
753
- this.updateLinks(e);
754
- }
755
- /**
756
- * This will update the links based on the current path.
757
- *
758
- * @param {string} path
759
- * @returns {void}
760
- */
761
- updateLinks(e) {
762
- let s = !1;
763
- this.deactivateAllLinks();
764
- for (const a of this.links) {
765
- if (!a.rendered)
766
- continue;
767
- We(a, a.getLinkPath(), e) ? (this.updateLink(a, !0), s = !0) : this.updateLink(a, !1);
768
- }
769
- !s && this.links[0] && this.updateLink(this.links[0], !0);
770
- }
771
- /**
772
- * This will deactivate all links.
773
- *
774
- * @returns {void}
775
- */
776
- deactivateAllLinks() {
777
- for (const e of this.links)
778
- this.updateLink(e, !1);
779
- }
780
- /**
781
- * This will update the link's active state.
782
- *
783
- * @param {object} link
784
- * @param {boolean} selected
785
- * @returns {void}
786
- */
787
- updateLink(e, s) {
788
- e.update(s);
789
- }
790
- /**
791
- * This will add a link to the navigation.
792
- *
793
- * @param {object} option
794
- * @returns {object}
795
- */
796
- addLink({ label: e, href: s, exact: a, hidden: i }) {
797
- const n = ze({ text: e, href: s, exact: a, hidden: i });
798
- return this.links.push(n), n;
799
- }
800
- /**
801
- * This will clear the links.
802
- *
803
- * @returns {void}
804
- */
805
- beforeDestroy() {
806
- this.links = [];
807
- }
808
- }
809
- const St = c((t) => {
810
- const e = t.margin || "m-4 ml-0";
811
- return t.allowHistory = t.allowHistory === !0, o({ class: `flex-none ${e}` }, [
812
- P({ variant: "back", class: "ghost", ...t })
813
- ]);
814
- });
815
- class H extends p {
816
- /**
817
- * This will declare the props for the compiler.
818
- *
819
- * @returns {void}
820
- */
821
- declareProps() {
822
- this.class = "";
823
- }
824
- /**
825
- * This will render the component.
826
- *
827
- * @returns {object}
828
- */
829
- render() {
830
- return o(
831
- {
832
- class: this.getClassName(),
833
- onSet: ["loading", {
834
- loading: !0
835
- }]
836
- },
837
- [
838
- this.addBody()
839
- ]
840
- );
841
- }
842
- /**
843
- * This will get the overlay className.
844
- *
845
- * @returns {string}
846
- */
847
- getClassName() {
848
- return `absolute flex flex-auto flex-col overlay left-0 top-0 right-0 z-20
849
- h-svh max-h-svh min-h-svh
850
- bg-background pointer-events-auto
851
- lg:left-16
852
- will-change-contents ${this.class || ""}`;
853
- }
854
- /**
855
- * This will setup and render the component.
856
- *
857
- * @param {object} container
858
- * @returns {void}
859
- */
860
- setContainer(e) {
861
- this.container = app.root;
862
- }
863
- /**
864
- * This will setup the overlay states.
865
- *
866
- * @returns {object}
867
- */
868
- setupStates() {
869
- return {
870
- loading: !1
871
- };
872
- }
873
- /**
874
- * This will set the loading state.= to true.
875
- *
876
- * @returns {void}
877
- */
878
- addLoading() {
879
- this.state.loading = !0;
880
- }
881
- /**
882
- * This will set the loading state to false.
883
- *
884
- * @returns {void}
885
- */
886
- removeLoading() {
887
- this.state.loading = !1;
888
- }
889
- /**
890
- * This will add the body of the overlay.
891
- *
892
- * @returns {object}
893
- */
894
- addBody() {
895
- return o({ class: "body fadeIn flex flex-auto flex-col bg-background" }, this.getContents());
896
- }
897
- /**
898
- * This will get the body contents.
899
- *
900
- * @returns {array|null}
901
- */
902
- getContents() {
903
- return this.children;
904
- }
905
- }
906
- U.addType("dockableOverlay", (t) => {
907
- if (!t)
908
- return;
909
- const e = t.component;
910
- e && e.rendered === !0 && e.state.docked === !1 && e.destroy();
911
- });
912
- class Ct extends H {
913
- /**
914
- * This will stop presistence.
915
- *
916
- * @returns {void}
917
- */
918
- onCreated() {
919
- this.dockSize = this.maxSize || 1024;
920
- }
921
- /**
922
- * This will render the component.
923
- *
924
- * @returns {object}
925
- */
926
- render() {
927
- const e = this.container;
928
- return o(
929
- {
930
- onState: [
931
- ["loading", {
932
- loading: !0
933
- }],
934
- ["docked", (s, a) => {
935
- s ? (a.className = this.getDockedClassName(), e.appendChild(a)) : (a.className = this.getClassName(), app.root.appendChild(a));
936
- }]
937
- ]
938
- },
939
- [
940
- this.addBody()
941
- ]
942
- );
943
- }
944
- /**
945
- * This will get the docked className.
946
- *
947
- * @returns {string}
948
- */
949
- getDockedClassName() {
950
- return "flex flex-auto flex-col bg-background flex will-change-contents " + (this.class || "");
951
- }
952
- /**
953
- * This will setup and render the component.
954
- *
955
- * @param {object} container
956
- * @returns {void}
957
- */
958
- setup(e) {
959
- this.container = e, this.initialize();
960
- }
961
- /**
962
- * This will setup the overlay states.
963
- *
964
- * @returns {object}
965
- */
966
- setupStates() {
967
- return {
968
- loading: !1,
969
- docked: this.canDock()
970
- };
971
- }
972
- /**
973
- * This will check the dock size.
974
- *
975
- * @returns {void}
976
- */
977
- afterSetup() {
978
- U.add(
979
- this.container,
980
- "dockableOverlay",
981
- {
982
- component: this
983
- }
984
- ), this.onResize();
985
- }
986
- /**
987
- * This will setup the overlay events.
988
- *
989
- * @returns {Array<object>}
990
- */
991
- setupEvents() {
992
- return [
993
- ["resize", globalThis, () => this.onResize()]
994
- ];
995
- }
996
- /**
997
- * This will check if the overlay can dock.
998
- *
999
- * @returns {boolean}
1000
- */
1001
- canDock() {
1002
- return globalThis.innerWidth >= this.dockSize;
1003
- }
1004
- /**
1005
- * This will handle the overlay resize.
1006
- *
1007
- * @returns {void}
1008
- */
1009
- onResize() {
1010
- this.state.docked = this.canDock();
1011
- }
1012
- }
1013
- class It extends H {
1014
- /**
1015
- * This will get the overlay type.
1016
- *
1017
- * @returns {string}
1018
- */
1019
- getClassName() {
1020
- return "overlay relative inline top-[0px] left-0 bottom-0 right-0 flex-col bg-background z-20 lg:left-[64px] lg:top-0 will-change-contents " + (this.class || "");
1021
- }
1022
- /**
1023
- * This will setup and render the component.
1024
- *
1025
- * @param {object} container
1026
- * @returns {void}
1027
- */
1028
- setup(e) {
1029
- this.container = e, this.initialize();
1030
- }
1031
- }
1032
- const Ne = c(({ index: t, click: e, state: s }, a) => w({
1033
- class: "p-2 cursor-pointer hover:bg-muted/50",
1034
- onState: [
1035
- [s, "selectedIndex", {
1036
- "bg-accent": t,
1037
- "text-white": t
1038
- }]
1039
- ],
1040
- click: () => e(t)
1041
- }, a)), Ue = c(({ selectOption: t, state: e }) => f({
1042
- class: "border rounded-md list-none m-0 p-0 max-h-[400px] overflow-y-auto",
1043
- for: ["filteredOptions", (s, a) => Ne({ index: a, click: t, state: e }, s.label)]
1044
- })), je = c((t) => o({ class: "relative flex flex-auto items-center" }, [
1045
- oe({
1046
- cache: "input",
1047
- class: t.class ?? "",
1048
- placeholder: t.placeholder ?? "Search...",
1049
- bind: t.bind ?? [t.state, "searchQuery"],
1050
- keyup: (e, s) => {
1051
- s.state && (s.state.open = !1), typeof t.filterOptions == "function" && t.filterOptions(), s.dropdown && s.dropdown.updatePosition(), t.keyup && t.keyup(e, s);
1052
- },
1053
- pointerup: (e, s) => {
1054
- typeof s.toggleDropdown == "function" && s.toggleDropdown();
1055
- },
1056
- keydown: (e) => [
1057
- typeof t.handleKeyDown == "function" && t.handleKeyDown(e)
1058
- ]
1059
- }),
1060
- t.icon && o({ class: "absolute flex right-0 mr-2" }, [
1061
- j(t.icon)
1062
- ])
1063
- ])), Ae = (t) => o({
1064
- class: "relative flex fle-auto flex-col",
1065
- onState: ["open", (e, s, a) => {
1066
- if (e)
1067
- return new ce({
1068
- cache: "dropdown",
1069
- parent: a,
1070
- button: a.input,
1071
- size: "xl"
1072
- }, [
1073
- Ue(t)
1074
- ]);
1075
- }]
1076
- }), Lt = Z(
1077
- {
1078
- /**
1079
- * This will set up the data object.
1080
- *
1081
- * @returns {object} - The data object.
1082
- */
1083
- setData() {
1084
- const t = this.options || [];
1085
- return new T({
1086
- options: t,
1087
- filteredOptions: t
1088
- });
1089
- },
1090
- /**
1091
- * This will set up the state object.
1092
- *
1093
- * @returns {object} - The state object.
1094
- */
1095
- state() {
1096
- return {
1097
- searchQuery: "",
1098
- selectedIndex: -1,
1099
- open: !1
1100
- };
1101
- },
1102
- /**
1103
- * This will set the selected index by query.
1104
- *
1105
- * @returns {void}
1106
- */
1107
- setSelectedIndexByQuery() {
1108
- const t = this.data.filteredOptions;
1109
- let { searchQuery: e } = this.state;
1110
- e = e.toLowerCase();
1111
- const s = t.findIndex((a) => a.label.toLowerCase() === e);
1112
- s >= 0 && (this.state.selectedIndex = s);
1113
- },
1114
- /**
1115
- * This will filter the options.
1116
- *
1117
- * @returns {void}
1118
- */
1119
- filterOptions() {
1120
- const t = this.state.searchQuery.toLowerCase();
1121
- if (t === "" || t.length === 0) {
1122
- this.data.filteredOptions = this.data.options;
1123
- return;
1124
- }
1125
- const e = this.data.get("options");
1126
- this.data.filteredOptions = e.filter(
1127
- (s) => s.label.toLowerCase().includes(t)
1128
- );
1129
- },
1130
- /**
1131
- * This will get the selected value.
1132
- *
1133
- * @returns {object}
1134
- */
1135
- getValue() {
1136
- const { selectedIndex: t } = this.state;
1137
- return t < 0 ? null : this.data.get(`filteredOptions[${t}]`);
1138
- },
1139
- /**
1140
- * This will select an option.
1141
- *
1142
- * @param {number} index - The index of the option.
1143
- * @returns {void}
1144
- */
1145
- selectOption(t) {
1146
- this.state.selectedIndex = t;
1147
- const e = this.data.get(`filteredOptions[${t}]`);
1148
- this.state.searchQuery = e.label, this.state.open = !1, typeof this.onSelect == "function" && this.onSelect(e);
1149
- },
1150
- /**
1151
- * Toggles the dropdown open state.
1152
- */
1153
- toggleDropdown() {
1154
- this.state.toggle("open"), this.state.open && this.setSelectedIndexByQuery();
1155
- },
1156
- /**
1157
- * This will handle key down events.
1158
- *
1159
- * @param {object} event - The event object.
1160
- * @returns {void}
1161
- */
1162
- handleKeyDown(t) {
1163
- const e = this.data.filteredOptions, { selectedIndex: s } = this.state;
1164
- t.key === "ArrowDown" ? (t.preventDefault(), this.state.selectedIndex = Math.min(s + 1, e.length - 1)) : t.key === "ArrowUp" ? (t.preventDefault(), this.state.selectedIndex = Math.max(s - 1, 0)) : t.key === "Enter" && s >= 0 && (t.preventDefault(), this.selectOption(s));
1165
- },
1166
- /**
1167
- * This will render the component.
1168
- *
1169
- * @returns {object} - The rendered component.
1170
- */
1171
- render() {
1172
- return o({ class: "relative w-full max-w-md" }, [
1173
- je({
1174
- // @ts-ignore
1175
- state: this.state,
1176
- // @ts-ignore
1177
- icon: this.icon,
1178
- // @ts-ignore
1179
- placeholder: this.placeholder,
1180
- // @ts-ignore
1181
- filterOptions: this.filterOptions.bind(this),
1182
- // @ts-ignore
1183
- handleKeyDown: this.handleKeyDown.bind(this)
1184
- }),
1185
- Ae({
1186
- // @ts-ignore
1187
- state: this.state,
1188
- // @ts-ignore
1189
- setSelected: this.setSelectedIndexByQuery.bind(this),
1190
- // @ts-ignore
1191
- selectOption: this.selectOption.bind(this)
1192
- })
1193
- ]);
1194
- }
1195
- }
1196
- ), Bt = c((t) => {
1197
- const e = t.icon ?? D.magnifyingGlass.default;
1198
- return o({
1199
- class: `relative flex items-center w-full rounded-xl bg-muted/30 focus-within:ring-2 focus-within:ring-ring transition-all ${t.containerClass || ""}`
1200
- }, [
1201
- o({ class: "absolute left-4 flex items-center pointer-events-none text-muted-foreground" }, [
1202
- j({ size: "sm" }, e)
1203
- ]),
1204
- K({
1205
- type: "text",
1206
- cache: t.cache ?? "input",
1207
- class: `w-full bg-transparent border-none outline-none pl-12 pr-4 py-4 text-base text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-0 ${t.class || ""}`,
1208
- placeholder: t.placeholder ?? "Search...",
1209
- bind: t.bind,
1210
- value: t.value,
1211
- keyup: t.keyup,
1212
- keydown: t.keydown,
1213
- input: t.input,
1214
- change: t.change,
1215
- focus: t.focus,
1216
- blur: t.blur
1217
- })
1218
- ]);
1219
- }), He = (t) => w(
1220
- {
1221
- class: "inline-flex flex-auto items-center justify-center whitespace-nowrap rounded-sm text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm",
1222
- dataStateSet: ["selected", ["state", t.value, "active"]]
1223
- },
1224
- [
1225
- k({
1226
- class: "flex flex-auto justify-center items-center px-3 py-1.5 rounded-md",
1227
- onState: ["selected", { selected: t.value }],
1228
- click: (e) => t.callBack(t.value)
1229
- }, t.label)
1230
- ]
1231
- ), Fe = (t, e) => (t.callBack = e, He(t)), Ye = (t) => m({ class: `tab items-center justify-center rounded-md bg-muted p-1 text-muted-foreground ${t.class}` }, [
1232
- f({ class: "flex flex-auto flex-row", map: [t.options, (e) => Fe(e, t.callBack)] })
1233
- ]);
1234
- class Tt extends g {
1235
- /**
1236
- * This will declare the props for the compiler.
1237
- *
1238
- * @returns {void}
1239
- */
1240
- declareProps() {
1241
- this.options = [], this.class = "", this.callBack = null;
1242
- }
1243
- /**
1244
- * This will render the component.
1245
- *
1246
- * @returns {object}
1247
- */
1248
- render() {
1249
- const e = this.select.bind(this);
1250
- return o({ class: "" }, [
1251
- Ye({
1252
- class: this.class,
1253
- options: this.options,
1254
- callBack: e
1255
- }),
1256
- L({
1257
- class: "tab-content",
1258
- onState: ["selected", this.updateContent.bind(this)]
1259
- })
1260
- ]);
1261
- }
1262
- /**
1263
- * This will get the first value.
1264
- *
1265
- * @returns {*}
1266
- */
1267
- getFirstValue() {
1268
- return this.options[0]?.value;
1269
- }
1270
- /**
1271
- * This will update the component.
1272
- *
1273
- * @returns {void}
1274
- */
1275
- update() {
1276
- const e = this.state.get("selected");
1277
- this.select(null), this.select(e);
1278
- }
1279
- /**
1280
- * This will select a value.
1281
- *
1282
- * @param {*} value
1283
- * @returns {void}
1284
- */
1285
- select(e) {
1286
- this.state.selected = e;
1287
- const s = this.onSelect;
1288
- typeof s == "function" && s(e, this.parent);
1289
- }
1290
- /**
1291
- * This will update the content.
1292
- *
1293
- * @param {*} value
1294
- * @returns {object}
1295
- */
1296
- updateContent(e) {
1297
- const s = this.options;
1298
- if (!s || s.length < 1)
1299
- return;
1300
- const a = s[0];
1301
- for (const i of s)
1302
- if (i.value === e)
1303
- return i.layout;
1304
- return a.layout;
1305
- }
1306
- /**
1307
- * This will setup the states.
1308
- *
1309
- * @returns {object}
1310
- */
1311
- setupStates() {
1312
- const e = this.callBack, s = typeof e;
1313
- return {
1314
- selected: {
1315
- state: this.getFirstValue(),
1316
- callBack(a) {
1317
- s === "function" && e(a);
1318
- }
1319
- }
1320
- };
1321
- }
1322
- }
1323
- const Ee = (t) => w(
1324
- {
1325
- class: "inline-flex flex-auto items-center justify-center whitespace-nowrap rounded-sm text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm",
1326
- dataStateSet: ["selected", ["state", t.value, "active"]]
1327
- },
1328
- [
1329
- k({
1330
- class: "flex flex-auto justify-center items-center px-3 py-1.5 rounded-md disabled:opacity-50 disabled:cursor-not-allowed",
1331
- onState: ["selected", { selected: t.value }],
1332
- click: (e) => t.callBack(t.value),
1333
- disabled: t.disabled
1334
- }, t.label)
1335
- ]
1336
- ), Qe = (t, e) => (t.callBack = e, Ee(t)), Ge = (t) => m({ class: `tab items-center justify-center rounded-md bg-muted p-1 text-muted-foreground ${t.class}` }, [
1337
- f({ class: "flex flex-auto flex-row", map: [t.options, (e) => Qe(e, t.callBack)] })
1338
- ]);
1339
- class Mt extends g {
1340
- /**
1341
- * This will declare the props for the compiler.
1342
- *
1343
- * @returns {void}
1344
- */
1345
- declareProps() {
1346
- this.options = [], this.class = "", this.onSelect = null;
1347
- }
1348
- /**
1349
- * This will render the component.
1350
- *
1351
- * @returns {object}
1352
- */
1353
- render() {
1354
- const e = this.select.bind(this);
1355
- return Ge({
1356
- class: this.class,
1357
- options: this.options,
1358
- callBack: e
1359
- });
1360
- }
1361
- /**
1362
- * This will select a value.
1363
- *
1364
- * @param {*} value
1365
- * @returns {void}
1366
- */
1367
- select(e) {
1368
- this.state.selected = e, typeof this.onSelect == "function" && this.onSelect(e, this.parent);
1369
- }
1370
- /**
1371
- * This will setup the states.
1372
- *
1373
- * @returns {object}
1374
- */
1375
- setupStates() {
1376
- return {
1377
- selected: this.options[0]?.value || null
1378
- };
1379
- }
1380
- }
1381
- const Ve = (t, e) => new RegExp(`${t}($|/|\\.).*`).test(e), Xe = (t, e) => {
1382
- const s = t.getLinkPath();
1383
- return t.exact ? e === s : Ve(s, e);
1384
- }, qe = ({ text: t, href: e, exact: s }) => new M({
1385
- text: t,
1386
- href: e,
1387
- exact: s,
1388
- dataSet: ["selected", ["state", !0, "active"]],
1389
- class: "inline-flex flex-auto items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm"
1390
- });
1391
- class Ke extends g {
1392
- /**
1393
- * This will declare the props for the compiler.
1394
- *
1395
- * @returns {void}
1396
- */
1397
- declareProps() {
1398
- this.options = [], this.class = "", this.onSelect = null;
1399
- }
1400
- /**
1401
- * This will configure the links.
1402
- */
1403
- beforeSetup() {
1404
- this.links = [];
1405
- }
1406
- /**
1407
- * This will render the component.
1408
- *
1409
- * @returns {object}
1410
- */
1411
- render() {
1412
- return m({ class: `tab items-center justify-center rounded-md bg-muted p-1 text-muted-foreground ${this.class}` }, [
1413
- f({
1414
- class: "flex flex-auto flex-row",
1415
- map: [this.options, (e) => this.addLink(e)],
1416
- watch: {
1417
- value: ["[[path]]", y.data],
1418
- callBack: this.updateLinks.bind(this)
1419
- }
1420
- })
1421
- ]);
1422
- }
1423
- /**
1424
- * This will update the links.
1425
- *
1426
- * @returns {void}
1427
- */
1428
- afterSetup() {
1429
- const e = y.data.path;
1430
- this.updateLinks(e);
1431
- }
1432
- /**
1433
- * This will update the links.
1434
- *
1435
- * @param {string} value
1436
- * @returns {void}
1437
- */
1438
- updateLinks(e) {
1439
- let s = !1, a = this.links[0];
1440
- this.deactivateAllLinks();
1441
- for (const i of this.links)
1442
- if (i.rendered !== !1 && (s = Xe(i, e), s === !0)) {
1443
- this.updateLink(i, !0);
1444
- break;
1445
- }
1446
- s !== !0 && a && this.updateLink(a, !0);
1447
- }
1448
- /**
1449
- * This will deactivate all links.
1450
- *
1451
- * @returns {void}
1452
- */
1453
- deactivateAllLinks() {
1454
- for (const e of this.links)
1455
- this.updateLink(e, !1);
1456
- }
1457
- /**
1458
- * This will update the link.
1459
- *
1460
- * @param {object} link
1461
- * @param {boolean} selected
1462
- * @returns {void}
1463
- */
1464
- updateLink(e, s) {
1465
- e.update(s);
1466
- }
1467
- /**
1468
- * This will add a link.
1469
- *
1470
- * @param {object} option
1471
- * @returns {object}
1472
- */
1473
- addLink({ label: e, href: s, exact: a }) {
1474
- const i = qe({ text: e, href: s, exact: a });
1475
- return this.links.push(i), i;
1476
- }
1477
- /**
1478
- * This will remove all the links.
1479
- *
1480
- * @returns {void}
1481
- */
1482
- beforeDestroy() {
1483
- this.links = [];
1484
- }
1485
- }
1486
- class Pt extends g {
1487
- /**
1488
- * This will declare the props for the compiler.
1489
- *
1490
- * @returns {void}
1491
- */
1492
- declareProps() {
1493
- this.options = [], this.class = "";
1494
- }
1495
- /**
1496
- * This will render the component.
1497
- *
1498
- * @returns {object}
1499
- */
1500
- render() {
1501
- return o({ class: "tab-panel" }, [
1502
- new Ke({
1503
- class: this.class,
1504
- options: this.options
1505
- }),
1506
- L({
1507
- class: "tab-content",
1508
- switch: this.addGroup()
1509
- })
1510
- ]);
1511
- }
1512
- /**
1513
- * This will add the group.
1514
- *
1515
- * @returns {array}
1516
- */
1517
- addGroup() {
1518
- let e;
1519
- const s = [], a = this.options;
1520
- for (let i = 0, n = a.length; i < n; i++)
1521
- e = a[i], s.push(
1522
- {
1523
- uri: e.uri || e.href,
1524
- component: e.component,
1525
- title: e.title || null,
1526
- persist: !0
1527
- }
1528
- );
1529
- return s;
1530
- }
1531
- }
1532
- const _e = (t) => w(
1533
- {
1534
- class: "relative inline-flex items-center justify-center whitespace-nowrap text-sm font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-foreground after:absolute after:bottom-0 after:left-0 after:right-0 after:h-0.5 after:bg-primary after:transition-all after:duration-200 after:scale-x-0 data-[state=active]:after:scale-x-100",
1535
- dataStateSet: ["selected", ["state", t.value, "active"]]
1536
- },
1537
- [
1538
- k({
1539
- class: "flex flex-auto justify-center items-center px-4 py-3 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",
1540
- onState: ["selected", { selected: t.value }],
1541
- click: (e) => t.callBack(t.value)
1542
- }, t.label)
1543
- ]
1544
- ), Je = (t, e) => (t.callBack = e, _e(t)), Ze = (t) => m({ class: `border-b border-border ${t.class}` }, [
1545
- f({ class: "flex flex-row items-center", map: [t.options, (e) => Je(e, t.callBack)] })
1546
- ]);
1547
- class Rt extends g {
1548
- /**
1549
- * This will declare the props for the compiler.
1550
- *
1551
- * @returns {void}
1552
- */
1553
- declareProps() {
1554
- this.options = [], this.class = "", this.onSelect = null;
1555
- }
1556
- /**
1557
- * This will render the component.
1558
- *
1559
- * @returns {object}
1560
- */
1561
- render() {
1562
- const e = this.select.bind(this);
1563
- return o({ class: "underlined-button-tab-panel flex flex-auto flex-col" }, [
1564
- Ze({
1565
- class: this.class,
1566
- options: this.options,
1567
- callBack: e
1568
- }),
1569
- L({
1570
- class: "tab-content pt-6 flex flex-auto flex-col",
1571
- onState: ["selected", this.updateContent.bind(this)]
1572
- })
1573
- ]);
1574
- }
1575
- /**
1576
- * This will get the first value.
1577
- *
1578
- * @returns {*}
1579
- */
1580
- getFirstValue() {
1581
- return this.options[0]?.value;
1582
- }
1583
- /**
1584
- * This will select an option.
1585
- *
1586
- * @param {*} value
1587
- * @returns {void}
1588
- */
1589
- select(e) {
1590
- this.state.selected = e;
1591
- const s = this.onSelect;
1592
- typeof s == "function" && s(e, this.parent);
1593
- }
1594
- /**
1595
- * This will update the content.
1596
- *
1597
- * @param {*} value
1598
- * @returns {object}
1599
- */
1600
- updateContent(e) {
1601
- const s = this.options;
1602
- if (!s || s.length < 1)
1603
- return;
1604
- const a = s[0];
1605
- for (const i of s)
1606
- if (i.value === e)
1607
- return i.component;
1608
- return a.component;
1609
- }
1610
- /**
1611
- * This will setup the states.
1612
- *
1613
- * @returns {object}
1614
- */
1615
- setupStates() {
1616
- const e = this.onSelect, s = typeof e;
1617
- return {
1618
- selected: {
1619
- state: this.getFirstValue(),
1620
- callBack(a) {
1621
- s === "function" && e(a);
1622
- }
1623
- }
1624
- };
1625
- }
1626
- }
1627
- const et = (t) => w(
1628
- {
1629
- class: "relative inline-flex items-center justify-center whitespace-nowrap text-sm font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-foreground after:absolute after:bottom-0 after:left-0 after:right-0 after:h-0.5 after:bg-primary after:transition-all after:duration-200 after:scale-x-0 data-[state=active]:after:scale-x-100",
1630
- dataStateSet: ["selected", ["state", t.value, "active"]]
1631
- },
1632
- [
1633
- k({
1634
- class: "flex flex-auto justify-center items-center px-4 py-3 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",
1635
- onState: ["selected", { selected: t.value }],
1636
- click: (e) => t.callBack(t.value),
1637
- disabled: t.disabled
1638
- }, t.label)
1639
- ]
1640
- ), tt = (t, e) => (t.callBack = e, et(t)), st = (t) => m({ class: `border-b border-border ${t.class}` }, [
1641
- f({ class: "flex flex-row items-center", map: [t.options, (e) => tt(e, t.callBack)] })
1642
- ]);
1643
- class $t extends g {
1644
- /**
1645
- * This will declare the props for the compiler.
1646
- *
1647
- * @returns {void}
1648
- */
1649
- declareProps() {
1650
- this.options = [], this.class = "", this.onSelect = null;
1651
- }
1652
- /**
1653
- * This will render the component.
1654
- *
1655
- * @returns {object}
1656
- */
1657
- render() {
1658
- const e = this.select.bind(this);
1659
- return st({
1660
- class: this.class,
1661
- options: this.options,
1662
- callBack: e
1663
- });
1664
- }
1665
- /**
1666
- * This will select an option.
1667
- *
1668
- * @param {*} value
1669
- * @returns {void}
1670
- */
1671
- select(e) {
1672
- this.state.selected = e, typeof this.onSelect == "function" && this.onSelect(e, this.parent);
1673
- }
1674
- /**
1675
- * This will setup the states.
1676
- *
1677
- * @returns {object}
1678
- */
1679
- setupStates() {
1680
- return {
1681
- selected: this.options[0]?.value || null
1682
- };
1683
- }
1684
- }
1685
- const at = (t, e) => new RegExp(`${t}($|/|\\.).*`).test(e), it = (t, e) => {
1686
- const s = t.getLinkPath();
1687
- return t.exact ? e === s : at(s, e);
1688
- }, nt = ({ text: t, href: e, exact: s }) => new M({
1689
- text: t,
1690
- href: e,
1691
- exact: s,
1692
- dataSet: ["selected", ["state", !0, "active"]],
1693
- class: "relative inline-flex items-center justify-center whitespace-nowrap px-4 py-3 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-foreground after:absolute after:bottom-0 after:left-0 after:right-0 after:h-0.5 after:bg-primary after:transition-all after:duration-200 after:scale-x-0 data-[state=active]:after:scale-x-100"
1694
- });
1695
- class ot extends g {
1696
- /**
1697
- * This will declare the props for the compiler.
1698
- *
1699
- * @returns {void}
1700
- */
1701
- declareProps() {
1702
- this.options = [], this.class = "", this.onSelect = null;
1703
- }
1704
- /**
1705
- * This will configure the links.
1706
- */
1707
- beforeSetup() {
1708
- this.links = [];
1709
- }
1710
- /**
1711
- * This will render the component.
1712
- *
1713
- * @returns {object}
1714
- */
1715
- render() {
1716
- return m({ class: `border-b border-border ${this.class}` }, [
1717
- f({
1718
- class: "flex flex-row items-center",
1719
- map: [this.options, (e) => this.addLink(e)],
1720
- watch: {
1721
- value: ["[[path]]", y.data],
1722
- callBack: this.updateLinks.bind(this)
1723
- }
1724
- })
1725
- ]);
1726
- }
1727
- /**
1728
- * This will update the links.
1729
- *
1730
- * @returns {void}
1731
- */
1732
- afterSetup() {
1733
- const e = y.data.path;
1734
- this.updateLinks(e);
1735
- }
1736
- /**
1737
- * This will update the links.
1738
- *
1739
- * @param {string} value
1740
- * @returns {void}
1741
- */
1742
- updateLinks(e) {
1743
- let s = !1, a = this.links[0];
1744
- this.deactivateAllLinks();
1745
- for (const i of this.links)
1746
- if (i.rendered !== !1 && (s = it(i, e), s === !0)) {
1747
- this.updateLink(i, !0);
1748
- break;
1749
- }
1750
- s !== !0 && a && this.updateLink(a, !0);
1751
- }
1752
- /**
1753
- * This will deactivate all links.
1754
- *
1755
- * @returns {void}
1756
- */
1757
- deactivateAllLinks() {
1758
- for (const e of this.links)
1759
- this.updateLink(e, !1);
1760
- }
1761
- /**
1762
- * This will update the link.
1763
- *
1764
- * @param {object} link
1765
- * @param {boolean} selected
1766
- * @returns {void}
1767
- */
1768
- updateLink(e, s) {
1769
- e.update(s);
1770
- }
1771
- /**
1772
- * This will add a link.
1773
- *
1774
- * @param {object} option
1775
- * @returns {object}
1776
- */
1777
- addLink({ label: e, href: s, exact: a }) {
1778
- const i = nt({ text: e, href: s, exact: a });
1779
- return this.links.push(i), i;
1780
- }
1781
- /**
1782
- * This will remove all the links.
1783
- *
1784
- * @returns {void}
1785
- */
1786
- beforeDestroy() {
1787
- this.links = [];
1788
- }
1789
- }
1790
- class Ot extends g {
1791
- /**
1792
- * This will declare the props for the compiler.
1793
- *
1794
- * @returns {void}
1795
- */
1796
- declareProps() {
1797
- this.options = [], this.class = "";
1798
- }
1799
- /**
1800
- * This will render the component.
1801
- *
1802
- * @returns {object}
1803
- */
1804
- render() {
1805
- return o({ class: "underlined-tab-panel flex flex-auto flex-col" }, [
1806
- new ot({
1807
- class: this.class,
1808
- options: this.options
1809
- }),
1810
- L({
1811
- class: "tab-content pt-6 flex flex-auto flex-col",
1812
- switch: this.addGroup()
1813
- })
1814
- ]);
1815
- }
1816
- /**
1817
- * This will add the group.
1818
- *
1819
- * @returns {array}
1820
- */
1821
- addGroup() {
1822
- let e;
1823
- const s = [], a = this.options;
1824
- for (let i = 0, n = a.length; i < n; i++)
1825
- e = a[i], s.push(
1826
- {
1827
- uri: e.uri || e.href,
1828
- component: e.component,
1829
- title: e.title || null,
1830
- persist: !0
1831
- }
1832
- );
1833
- return s;
1834
- }
1835
- }
1836
- class lt extends p {
1837
- /**
1838
- * Runs before rendering, sets up defaults, a timer for drawing,
1839
- * and basic canvas properties.
1840
- *
1841
- * @returns {void}
1842
- */
1843
- onCreated() {
1844
- this.lineWidth = this.lineWidth || 3, this.lineColor = this.lineColor || "#000000", this.canvas = null, this.ctx = null, this.status = "stopped";
1845
- const e = 1e3 / 60;
1846
- this.timer = new ie(e, this.draw.bind(this)), this.width = 0, this.height = 0, this.signed = !1, this.mouse = { x: 0, y: 0, status: "up" }, this.margin = this.margin || { x: 40, y: 60 }, this.targetSize = this.targetSize || { width: 740, height: 345 }, this.baseLineWidth = this.baseLineWidth || 2, this.baseStrokeColor = this.baseStrokeColor || "#000000";
1847
- }
1848
- /**
1849
- * Renders a <canvas> element.
1850
- *
1851
- * @returns {object} Layout definition for the canvas.
1852
- */
1853
- render() {
1854
- return _({
1855
- style: "touch-action: none; -webkit-user-select: none; -webkit-touch-callout: none;"
1856
- });
1857
- }
1858
- /**
1859
- * Called before the component is destroyed. Stops the timer
1860
- * to prevent memory leaks or ongoing animation.
1861
- *
1862
- * @returns {void}
1863
- */
1864
- beforeDestroy() {
1865
- this.stopTimer();
1866
- }
1867
- /**
1868
- * Called after component setup. Initializes canvas context,
1869
- * schedules a resize, and draws the initial content.
1870
- *
1871
- * @returns {void}
1872
- */
1873
- afterSetup() {
1874
- this.canvas = this.panel, this.ctx = this.canvas.getContext("2d"), globalThis.setTimeout(() => {
1875
- this.resize(), this.draw();
1876
- }, 1);
1877
- }
1878
- /**
1879
- * Defines the DOM events to set up for this canvas component.
1880
- *
1881
- * @returns {Array} An array of [eventName, element, callback] definitions.
1882
- */
1883
- setupEvents() {
1884
- const e = this.panel, s = this.pointerPosition.bind(this), a = this.pointerUp.bind(this), i = this.pointerDown.bind(this), n = this.resize.bind(this), l = { passive: !1 };
1885
- return [
1886
- ["pointermove", e, s, l],
1887
- ["pointerup", e, a],
1888
- ["pointerdown", e, i, l],
1889
- ["pointerout", e, a],
1890
- ["resize", globalThis, n]
1891
- ];
1892
- }
1893
- /**
1894
- * Calculates and saves the current pointer position in canvas coordinates.
1895
- *
1896
- * @param {Event} e The event object (mouse or touch).
1897
- * @returns {void}
1898
- */
1899
- getEventPosition(e) {
1900
- let s, a;
1901
- const i = this.canvas, n = i.width / parseInt(i.style.width), l = i.getBoundingClientRect();
1902
- if (e.touches && e.touches.length) {
1903
- const u = e.touches[0];
1904
- s = u.clientX, a = u.clientY;
1905
- } else
1906
- s = e.x || e.clientX, a = e.y || e.clientY;
1907
- const d = parseInt((s - l.left) * n), r = parseInt((a - l.top) * n);
1908
- this.mouse.x = d, this.mouse.y = r;
1909
- }
1910
- /**
1911
- * Called when the pointer goes down on the canvas.
1912
- * Begins a new path, sets the mouse status, and starts the timer.
1913
- *
1914
- * @param {Event} e The event object.
1915
- * @returns {void}
1916
- */
1917
- pointerDown(e) {
1918
- e.preventDefault(), e.stopPropagation(), this.getEventPosition(e);
1919
- const { ctx: s, mouse: a } = this;
1920
- s.beginPath(), s.moveTo(a.x, a.y), a.status = "down", this.startTimer();
1921
- }
1922
- /**
1923
- * Called when the pointer goes up or leaves the canvas area.
1924
- * Closes the path and stops the drawing timer.
1925
- *
1926
- * @param {Event} e The event object.
1927
- * @returns {void}
1928
- */
1929
- pointerUp(e) {
1930
- e.preventDefault(), e.stopPropagation(), this.ctx.closePath(), this.mouse.status = "up", this.stopTimer();
1931
- }
1932
- /**
1933
- * Tracks pointer movement, updates position in real time.
1934
- *
1935
- * @param {Event} e The event object.
1936
- * @returns {void}
1937
- */
1938
- pointerPosition(e) {
1939
- this.getEventPosition(e), this.mouse.status === "down" && (e.preventDefault(), e.stopPropagation());
1940
- }
1941
- /**
1942
- * Resizes the canvas, preserves existing drawing by converting
1943
- * it to a data URL, then re-drawing.
1944
- *
1945
- * @returns {void}
1946
- */
1947
- resize() {
1948
- const { canvas: e, ctx: s } = this, a = e.toDataURL();
1949
- if (this.scale(), this.setupBackground(s), a !== "data:,") {
1950
- const i = new globalThis.Image();
1951
- $.on("load", i, function n() {
1952
- s.drawImage(i, 0, 0), $.off("load", i, n);
1953
- }), i.src = a;
1954
- }
1955
- this.draw();
1956
- }
1957
- /**
1958
- * Returns a JPEG data URL of the current canvas content.
1959
- *
1960
- * @returns {string} The signature image as a data URL.
1961
- */
1962
- getImage() {
1963
- return this.canvas.toDataURL("image/jpeg", 0.7);
1964
- }
1965
- /**
1966
- * (Deprecated approach) Resize the canvas to the container size
1967
- * without scaling logic.
1968
- *
1969
- * @returns {void}
1970
- */
1971
- noScaleResize() {
1972
- const e = O.getSize(container);
1973
- this.width = canvas.width = e.width, this.height = canvas.height = e.height;
1974
- }
1975
- /**
1976
- * Scales the canvas to fit within its container, preserving aspect ratio
1977
- * relative to this.targetSize.
1978
- *
1979
- * @returns {void}
1980
- */
1981
- scale() {
1982
- const e = this.canvas, s = this.container, a = O.getSize(s), i = this.targetSize, n = i.width, l = i.height;
1983
- let d = n + "px", r = l + "px";
1984
- if (this.width = e.width = n, this.height = e.height = l, a.width !== 0 && a.height !== 0) {
1985
- const u = a.width, b = a.height, h = u / n, x = b / l, S = Math.min(h, x);
1986
- d = n * S + "px", r = l * S + "px";
1987
- }
1988
- e.style.width = d, e.style.height = r;
1989
- }
1990
- /**
1991
- * Main drawing loop. If the mouse is down, adds a line
1992
- * from the last point to the current pointer position.
1993
- *
1994
- * @returns {void}
1995
- */
1996
- draw() {
1997
- this.mouse.status === "down" && this.addLine(this.ctx, this.mouse.x, this.mouse.y, this.lineColor);
1998
- }
1999
- /**
2000
- * Draws the baseline at the bottom of the canvas.
2001
- *
2002
- * @param {CanvasRenderingContext2D} ctx The canvas 2D context.
2003
- * @returns {void}
2004
- */
2005
- drawBottomLine(e) {
2006
- const s = this.canvas;
2007
- e.globalAlpha = 1, e.shadowBlur = 0;
2008
- const a = this.margin.x, i = this.height - this.margin.y;
2009
- e.beginPath(), e.moveTo(a, i), e.lineTo(s.width - this.margin.x, i), e.lineWidth = this.baseLineWidth, e.strokeStyle = this.baseStrokeColor, e.stroke(), e.closePath();
2010
- }
2011
- /**
2012
- * Adds a line to the current path, updating the 'signed' status.
2013
- *
2014
- * @param {CanvasRenderingContext2D} ctx The canvas context.
2015
- * @param {number} px The x-coordinate.
2016
- * @param {number} py The y-coordinate.
2017
- * @param {string} color The stroke color.
2018
- * @returns {void}
2019
- */
2020
- addLine(e, s, a, i) {
2021
- this.signed || (this.signed = !0);
2022
- const n = Math.round(s), l = Math.round(a);
2023
- e.lineWidth = this.lineWidth, e.strokeStyle = i, e.lineTo(n, l), e.stroke();
2024
- }
2025
- /**
2026
- * Clears the canvas, sets signed to false, and re-initializes
2027
- * the background for a fresh signature.
2028
- *
2029
- * @returns {void}
2030
- */
2031
- reset() {
2032
- this.signed = !1;
2033
- const { ctx: e } = this;
2034
- e.clearRect(0, 0, this.width, this.height), this.setupBackground(e);
2035
- }
2036
- /**
2037
- * Fills the canvas background with white and draws the baseline.
2038
- *
2039
- * @param {CanvasRenderingContext2D} ctx The canvas context.
2040
- * @returns {void}
2041
- */
2042
- setupBackground(e) {
2043
- e.fillStyle = "transparent", e.fillRect(0, 0, this.width, this.height), this.drawBottomLine(e);
2044
- }
2045
- /**
2046
- * Starts the drawing timer so new lines can be added as pointer moves.
2047
- *
2048
- * @returns {void}
2049
- */
2050
- startTimer() {
2051
- this.stopTimer(), this.draw(), this.timer.start(), this.status = "started";
2052
- }
2053
- /**
2054
- * Stops the drawing timer.
2055
- *
2056
- * @returns {void}
2057
- */
2058
- stopTimer() {
2059
- this.timer.stop(), this.status = "stopped";
2060
- }
2061
- }
2062
- class Wt extends p {
2063
- /**
2064
- * Sets up default properties for the signature panel.
2065
- *
2066
- * @returns {void}
2067
- */
2068
- declareProps() {
2069
- this.data = null, this.lineColor = null, this.lineWidth = null, this.baseLineWidth = null, this.baseStrokeColor = null, this.margin = null, this.targetSize = null, this.callBackData = null, this.pointerUp = null, this.path = null, this.canvasLayer = null;
2070
- }
2071
- /**
2072
- * Renders the main layout for the signature panel,
2073
- * including a hidden input and a reset button.
2074
- *
2075
- * @returns {object} The layout object for the component.
2076
- */
2077
- render() {
2078
- return o({ class: "signature-panel relative flex flex-auto overflow-hidden select-none" }, [
2079
- le({
2080
- cache: "hiddenInput",
2081
- required: !0,
2082
- bind: this.path + ".data"
2083
- }),
2084
- o({ class: "absolute top-2 right-2" }, [
2085
- P({
2086
- variant: "icon",
2087
- icon: D.circleX,
2088
- click: this.reset.bind(this)
2089
- })
2090
- ]),
2091
- new lt({
2092
- cache: "canvasLayer",
2093
- margin: this.margin,
2094
- targetSize: this.targetSize,
2095
- lineColor: this.lineColor,
2096
- lineWidth: this.lineWidth,
2097
- baseLineWidth: this.baseLineWidth,
2098
- baseStrokeColor: this.baseStrokeColor,
2099
- pointerUpCallBack: this.pointerUp,
2100
- callBackData: this.callBackData
2101
- })
2102
- ]);
2103
- }
2104
- /**
2105
- * Called after component setup. Resizes the signature canvas once
2106
- * everything is ready.
2107
- *
2108
- * @returns {void}
2109
- */
2110
- afterSetup() {
2111
- this.canvasLayer.resize();
2112
- }
2113
- /**
2114
- * Gets the signature image from the canvas layer, as a data URL.
2115
- *
2116
- * @returns {string} The signature image data URL.
2117
- */
2118
- getImage() {
2119
- return this.canvasLayer.getImage();
2120
- }
2121
- /**
2122
- * Checks if the user has drawn anything on the signature canvas.
2123
- *
2124
- * @returns {boolean} True if the canvas has been signed, otherwise false.
2125
- */
2126
- isSigned() {
2127
- return this.canvasLayer ? this.canvasLayer.signed : !1;
2128
- }
2129
- /**
2130
- * Resets the signature canvas to a blank state.
2131
- *
2132
- * @param {Event} [e] The event object (if called by a click event).
2133
- * @returns {void}
2134
- */
2135
- reset(e) {
2136
- if (this.canvasLayer)
2137
- return this.canvasLayer.reset();
2138
- }
2139
- /**
2140
- * Cleans up references before destroying the component.
2141
- *
2142
- * @returns {void}
2143
- */
2144
- beforeDestroy() {
2145
- this.canvasLayer = null, this.hiddenInput = null;
2146
- }
2147
- }
2148
- export {
2149
- St as B,
2150
- ke as C,
2151
- A as D,
2152
- we as H,
2153
- It as I,
2154
- Dt as N,
2155
- H as O,
2156
- pt as P,
2157
- wt as S,
2158
- Pt as T,
2159
- Rt as U,
2160
- yt as W,
2161
- Tt as a,
2162
- ve as b,
2163
- Ct as c,
2164
- kt as d,
2165
- Lt as e,
2166
- je as f,
2167
- Wt as g,
2168
- Bt as h,
2169
- Mt as i,
2170
- Ke as j,
2171
- R as k,
2172
- Ot as l,
2173
- $t as m,
2174
- ot as n,
2175
- vt as o,
2176
- $e as p,
2177
- me as q,
2178
- be as r,
2179
- xe as s,
2180
- he as t,
2181
- bt as u,
2182
- W as v,
2183
- xt as w,
2184
- fe as x,
2185
- ue as y
2186
- };