@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.
- package/README.md +44 -0
- package/dist/atoms.es.js +37 -34
- package/dist/buttons-HW55zbqy.js +127 -0
- package/dist/{empty-state-CuciIYY7.js → empty-state-5g6Pdeeg.js} +324 -321
- package/dist/full-page-DccgwWsM.js +69 -0
- package/dist/icons.es.js +127 -1
- package/dist/image-BhZbKYDj.js +237 -0
- package/dist/index.es.js +179 -173
- package/dist/{mobile-nav-wrapper-C3Lvz7CH.js → mobile-nav-wrapper-DmrkMxyd.js} +77 -84
- package/dist/molecules.es.js +5 -5
- package/dist/organisms.es.js +52 -51
- package/dist/pages.es.js +10 -9
- package/dist/sidebar-menu-C5s4Cogh.js +13 -0
- package/dist/sidebar-menu-page-DwqCqwzG.js +153 -0
- package/dist/signature-panel-CDQgFxuo.js +1364 -0
- package/dist/simple-search-input-mCUOwYbp.js +1654 -0
- package/dist/skeleton-BlY3opxG.js +7 -0
- package/dist/{tooltip-BlFbB8yL.js → tooltip-BmvjA9XQ.js} +104 -84
- package/dist/types/components/atoms/atoms.d.ts +2 -0
- package/dist/types/components/atoms/material-icon.d.ts +17 -0
- package/dist/types/components/atoms/universal-icon.d.ts +3 -0
- package/dist/types/components/icons/icons.d.ts +1 -0
- package/dist/types/components/icons/material-symbols.d.ts +19 -0
- package/dist/types/components/molecules/breadcrumb/breadcrumb.d.ts +2 -2
- package/dist/types/components/molecules/image/image-uploader.d.ts +2 -2
- package/dist/types/components/molecules/image/logo-uploader.d.ts +2 -2
- package/dist/types/components/organisms/navigation/mobile/nav-wrapper/title-header.d.ts +1 -1
- package/package.json +1 -1
- package/dist/buttons-Dr-bViom.js +0 -77
- package/dist/form-group-BB7dLJir.js +0 -29
- package/dist/image-BB__4s0g.js +0 -31
- package/dist/inputs-CcimrM1k.js +0 -210
- package/dist/range-calendar-CzKIBhgb.js +0 -831
- package/dist/sidebar-menu-page-BtuUB_XB.js +0 -217
- package/dist/signature-panel-DmyPbuRi.js +0 -2186
|
@@ -0,0 +1,1364 @@
|
|
|
1
|
+
import { Div as l, Button as b, On as j, Span as T, Nav as f, Ul as p, Section as y, Li as w, Canvas as z } from "@base-framework/atoms";
|
|
2
|
+
import { Component as k, Data as I, DateTime as U, router as v, NavLink as S, base as L, Dom as B } from "@base-framework/base";
|
|
3
|
+
import { B as C } from "./buttons-HW55zbqy.js";
|
|
4
|
+
import { Icons as D } from "./icons.es.js";
|
|
5
|
+
import { O as A } from "./simple-search-input-mCUOwYbp.js";
|
|
6
|
+
import { V as u, H as F } from "./image-BhZbKYDj.js";
|
|
7
|
+
import { IntervalTimer as O } from "@base-framework/organisms";
|
|
8
|
+
class Pt extends k {
|
|
9
|
+
/**
|
|
10
|
+
* This will declare the props for the compiler.
|
|
11
|
+
*
|
|
12
|
+
* @returns {void}
|
|
13
|
+
*/
|
|
14
|
+
declareProps() {
|
|
15
|
+
this.class = "";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* This will render the component.
|
|
19
|
+
*
|
|
20
|
+
* @returns {object}
|
|
21
|
+
*/
|
|
22
|
+
render() {
|
|
23
|
+
return l({ class: this.class || "" }, this.children);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const Y = (s) => {
|
|
27
|
+
const t = new Date(s, 11, 31), e = new Date(s, 0, 1);
|
|
28
|
+
return t.getDay() === 4 || // December 31 is a Thursday
|
|
29
|
+
e.getDay() === 4;
|
|
30
|
+
}, R = (s) => {
|
|
31
|
+
const t = new Date(s.valueOf()), e = (t.getDay() + 6) % 7;
|
|
32
|
+
t.setDate(t.getDate() - e + 3);
|
|
33
|
+
const i = t.getFullYear(), a = new Date(i, 0, 4);
|
|
34
|
+
a.setDate(a.getDate() - (a.getDay() + 6) % 7);
|
|
35
|
+
const n = Math.ceil((t - a) / 6048e5) + 1;
|
|
36
|
+
return n > 52 && !Y(i) ? {
|
|
37
|
+
weekNumber: 1,
|
|
38
|
+
year: i + 1
|
|
39
|
+
} : {
|
|
40
|
+
weekNumber: n,
|
|
41
|
+
year: i
|
|
42
|
+
};
|
|
43
|
+
}, E = (s, t, e) => {
|
|
44
|
+
if (e === 0) return [];
|
|
45
|
+
const i = new Date(s, t, 0).getDate();
|
|
46
|
+
return Array.from(
|
|
47
|
+
{ length: e },
|
|
48
|
+
(a, n) => new Date(s, t - 1, i - e + n + 1)
|
|
49
|
+
);
|
|
50
|
+
}, G = (s, t, e) => Array.from({ length: e }, (i, a) => new Date(s, t + 1, a + 1)), P = (s, t) => {
|
|
51
|
+
const e = new Date(t, 0, 4), i = (e.getDay() + 6) % 7, a = new Date(e);
|
|
52
|
+
a.setDate(e.getDate() - i);
|
|
53
|
+
const n = new Date(a);
|
|
54
|
+
return n.setDate(a.getDate() + (s - 1) * 7), n;
|
|
55
|
+
}, Wt = (s, t) => {
|
|
56
|
+
const e = new Date(s, t, 1).getDay(), i = new Date(s, t + 1, 0).getDate(), a = [];
|
|
57
|
+
let n = [];
|
|
58
|
+
for (let o = 1 - e; o <= i; o++) {
|
|
59
|
+
const h = new Date(s, t, o);
|
|
60
|
+
n.push(o > 0 ? h : null), (n.length === 7 || o === i) && (a.push([...n]), n = []);
|
|
61
|
+
}
|
|
62
|
+
return a;
|
|
63
|
+
}, Tt = (s, t) => {
|
|
64
|
+
const e = new Date(s, t + 1, 0).getDate(), i = [];
|
|
65
|
+
let a = [];
|
|
66
|
+
for (let n = 1; n <= e; n++)
|
|
67
|
+
a.push(new Date(s, t, n)), a.length === 7 && (i.push(a), a = []);
|
|
68
|
+
return a.length > 0 && i.push(a), i;
|
|
69
|
+
}, V = (s, t, e) => {
|
|
70
|
+
const i = /* @__PURE__ */ new Date();
|
|
71
|
+
return i.getDate() === s && i.getMonth() === t && i.getFullYear() === e;
|
|
72
|
+
}, X = ({ day: s, month: t, year: e, weekNumber: i, selectWeek: a }) => {
|
|
73
|
+
const n = V(s, t, e);
|
|
74
|
+
return b({
|
|
75
|
+
text: s || "",
|
|
76
|
+
disabled: !s,
|
|
77
|
+
class: `
|
|
78
|
+
px-2 py-1 text-center rounded-md
|
|
79
|
+
${n ? "bg-accent text-accent-foreground" : ""}
|
|
80
|
+
hover:bg-primary hover:text-primary-foreground
|
|
81
|
+
`,
|
|
82
|
+
click: () => a(i, e)
|
|
83
|
+
});
|
|
84
|
+
}, H = (s, t) => {
|
|
85
|
+
const e = new Date(s, t, 1).getDay(), i = new Date(s, t + 1, 0).getDate(), a = E(s, t, e), n = Array.from({ length: i }, (c, m) => new Date(s, t, m + 1)), o = (a.length + n.length) % 7, h = o === 0 ? 0 : 7 - o, r = G(s, t, h), d = [...a, ...n, ...r], g = [];
|
|
86
|
+
for (let c = 0; c < d.length; c += 7) {
|
|
87
|
+
const m = d.slice(c, c + 7), x = m.find((N) => N) || new Date(s, t, 1), { weekNumber: M, year: $ } = R(x);
|
|
88
|
+
g.push({
|
|
89
|
+
weekNumber: M,
|
|
90
|
+
year: $,
|
|
91
|
+
days: m
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return g;
|
|
95
|
+
}, q = ({ selectWeek: s }) => j("month", (t, e, { data: i }) => {
|
|
96
|
+
const { year: a, month: n, currentDate: o } = i, h = H(a, n);
|
|
97
|
+
return l(
|
|
98
|
+
{ class: "grid grid-cols-8 gap-1 text-sm px-4 py-2" },
|
|
99
|
+
[
|
|
100
|
+
// Header row: "Week" label + day-of-week labels
|
|
101
|
+
l({ class: "text-xs text-center col-span-1 text-muted-foreground flex items-center" }, "Week"),
|
|
102
|
+
l(
|
|
103
|
+
{
|
|
104
|
+
class: "grid grid-cols-7 col-span-7 text-center text-muted-foreground items-center"
|
|
105
|
+
},
|
|
106
|
+
["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map(
|
|
107
|
+
(r) => T({ class: "px-1 py-1", text: r })
|
|
108
|
+
)
|
|
109
|
+
),
|
|
110
|
+
// Render each "week" row
|
|
111
|
+
...h.map(
|
|
112
|
+
({ weekNumber: r, days: d, year: g }) => l({
|
|
113
|
+
class: "grid grid-cols-8 col-span-8 items-center ring-primary rounded-sm px-1",
|
|
114
|
+
onSet: ["currentWeek", {
|
|
115
|
+
ring: r
|
|
116
|
+
}]
|
|
117
|
+
}, [
|
|
118
|
+
// Left column: ISO week number
|
|
119
|
+
l({
|
|
120
|
+
class: "font-medium text-center col-span-1 rounded-sm cursor-pointer",
|
|
121
|
+
click: () => s(r, g),
|
|
122
|
+
// If you have a 'currentWeek' state, you can highlight it with 'onSet'
|
|
123
|
+
onSet: ["currentWeek", {
|
|
124
|
+
"text-primary-foreground": r,
|
|
125
|
+
"bg-primary": r
|
|
126
|
+
}],
|
|
127
|
+
text: r ? `W${r}` : ""
|
|
128
|
+
}),
|
|
129
|
+
// The 7 cells for each day in the row
|
|
130
|
+
l(
|
|
131
|
+
{ class: "grid grid-cols-7 col-span-7 text-center" },
|
|
132
|
+
d.map(
|
|
133
|
+
(c) => X({
|
|
134
|
+
year: c?.getFullYear() || null,
|
|
135
|
+
month: c?.getMonth() || null,
|
|
136
|
+
day: c?.getDate() || null,
|
|
137
|
+
weekNumber: r,
|
|
138
|
+
selectWeek: s
|
|
139
|
+
})
|
|
140
|
+
)
|
|
141
|
+
)
|
|
142
|
+
])
|
|
143
|
+
)
|
|
144
|
+
]
|
|
145
|
+
);
|
|
146
|
+
}), W = ({ label: s, click: t }) => C(
|
|
147
|
+
{
|
|
148
|
+
class: `
|
|
149
|
+
inline-flex items-center justify-center h-7 w-7 bg-transparent p-0
|
|
150
|
+
opacity-50 hover:opacity-100 text-muted-foreground absolute
|
|
151
|
+
${s === "Previous" ? "left-1" : "right-1"}
|
|
152
|
+
focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2
|
|
153
|
+
`,
|
|
154
|
+
click: t,
|
|
155
|
+
"aria-label": `${s} month`,
|
|
156
|
+
variant: "icon",
|
|
157
|
+
icon: s === "Previous" ? D.chevron.single.left : D.chevron.single.right
|
|
158
|
+
}
|
|
159
|
+
), _ = ({ next: s, previous: t }) => l({ class: "flex flex-auto min-h-12 text-sm font-medium relative justify-center items-center" }, [
|
|
160
|
+
T("[[monthName]] [[year]]"),
|
|
161
|
+
W({
|
|
162
|
+
label: "Previous",
|
|
163
|
+
click: t
|
|
164
|
+
}),
|
|
165
|
+
W({
|
|
166
|
+
label: "Next",
|
|
167
|
+
click: s
|
|
168
|
+
})
|
|
169
|
+
]);
|
|
170
|
+
class Ct extends k {
|
|
171
|
+
/**
|
|
172
|
+
* This will declare the props for the compiler.
|
|
173
|
+
*
|
|
174
|
+
* @returns {void}
|
|
175
|
+
*/
|
|
176
|
+
declareProps() {
|
|
177
|
+
this.selectedDate = null, this.selectedWeek = null, this.selectedCallBack = null;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Initializes the calendar data.
|
|
181
|
+
*
|
|
182
|
+
* @returns {Data}
|
|
183
|
+
*/
|
|
184
|
+
setData() {
|
|
185
|
+
const t = /* @__PURE__ */ new Date(), e = this.selectedWeek || this.calculateCurrentWeek(t), i = P(e, t.getFullYear());
|
|
186
|
+
return new I({
|
|
187
|
+
monthName: this.getMonthName(i.getMonth()),
|
|
188
|
+
year: i.getFullYear(),
|
|
189
|
+
month: i.getMonth(),
|
|
190
|
+
currentDate: i.getDate(),
|
|
191
|
+
currentWeek: e
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Determines the current selected date.
|
|
196
|
+
*
|
|
197
|
+
* @param {Date} today
|
|
198
|
+
* @returns {Date}
|
|
199
|
+
*/
|
|
200
|
+
getSelectedDate(t) {
|
|
201
|
+
const e = this.selectedDate ? new Date(this.selectedDate) : t;
|
|
202
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate());
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Calculates the ISO week number for a given date.
|
|
206
|
+
*
|
|
207
|
+
* @param {Date} date
|
|
208
|
+
* @returns {number}
|
|
209
|
+
*/
|
|
210
|
+
calculateCurrentWeek(t) {
|
|
211
|
+
const e = new Date(t.valueOf()), i = (t.getDay() + 6) % 7;
|
|
212
|
+
e.setDate(e.getDate() - i + 3);
|
|
213
|
+
const a = e.valueOf();
|
|
214
|
+
return e.setMonth(0, 1), e.getDay() !== 4 && e.setMonth(0, 1 + (4 - e.getDay() + 7) % 7), 1 + Math.ceil((a - e) / 6048e5);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Gets the name of the month.
|
|
218
|
+
*
|
|
219
|
+
* @param {number} month
|
|
220
|
+
* @returns {string}
|
|
221
|
+
*/
|
|
222
|
+
getMonthName(t) {
|
|
223
|
+
return U.monthNames[t];
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Updates the calendar to show the previous month.
|
|
227
|
+
*
|
|
228
|
+
* @returns {void}
|
|
229
|
+
*/
|
|
230
|
+
goToPreviousMonth() {
|
|
231
|
+
const t = this.data;
|
|
232
|
+
let { year: e, month: i } = t;
|
|
233
|
+
i === 0 ? (i = 11, e--) : i--, this.setDate(i, e);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Updates the calendar to show the next month.
|
|
237
|
+
*
|
|
238
|
+
* @returns {void}
|
|
239
|
+
*/
|
|
240
|
+
goToNextMonth() {
|
|
241
|
+
const t = this.data;
|
|
242
|
+
let { year: e, month: i } = t;
|
|
243
|
+
i === 11 ? (i = 0, e++) : i++, this.setDate(i, e);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Sets the selected date.
|
|
247
|
+
*
|
|
248
|
+
* @param {number} month
|
|
249
|
+
* @param {number} year
|
|
250
|
+
* @param {number|null} [date=null]
|
|
251
|
+
* @returns {void}
|
|
252
|
+
*/
|
|
253
|
+
setDate(t, e, i) {
|
|
254
|
+
this.data.set({
|
|
255
|
+
year: e,
|
|
256
|
+
month: t,
|
|
257
|
+
monthName: this.getMonthName(t)
|
|
258
|
+
}), i && (this.data.currentDate = i);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Handles week selection.
|
|
262
|
+
*
|
|
263
|
+
* @param {number} weekNumber
|
|
264
|
+
* @returns {void}
|
|
265
|
+
*/
|
|
266
|
+
selectWeek(t, e) {
|
|
267
|
+
this.data.currentWeek = t;
|
|
268
|
+
const i = P(t, e);
|
|
269
|
+
this.setDate(i.getMonth(), i.getFullYear(), i.getDate()), typeof this.selectedCallBack == "function" && this.selectedCallBack(t);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Renders the WeekCalendar component.
|
|
273
|
+
*
|
|
274
|
+
* @returns {object}
|
|
275
|
+
*/
|
|
276
|
+
render() {
|
|
277
|
+
return l({ class: "week-calendar-container border rounded-md p-3" }, [
|
|
278
|
+
_({
|
|
279
|
+
next: () => this.goToNextMonth(),
|
|
280
|
+
previous: () => this.goToPreviousMonth()
|
|
281
|
+
}),
|
|
282
|
+
q({
|
|
283
|
+
selectWeek: (t, e) => this.selectWeek(t, e)
|
|
284
|
+
})
|
|
285
|
+
]);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const J = (s, t) => t.includes(s), K = (s, t, e) => s.exact ? e === t : J(t, e), Q = ({ text: s, href: t, exact: e, hidden: i }) => new S({
|
|
289
|
+
text: s,
|
|
290
|
+
href: t,
|
|
291
|
+
exact: e,
|
|
292
|
+
dataSet: ["selected", ["state", !0, "active"]],
|
|
293
|
+
class: `${i ? "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`
|
|
294
|
+
});
|
|
295
|
+
class Mt extends k {
|
|
296
|
+
/**
|
|
297
|
+
* This will declare the props for the compiler.
|
|
298
|
+
*
|
|
299
|
+
* @returns {void}
|
|
300
|
+
*/
|
|
301
|
+
declareProps() {
|
|
302
|
+
this.options = [], this.class = "";
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* This will configure the links.
|
|
306
|
+
*/
|
|
307
|
+
beforeSetup() {
|
|
308
|
+
this.links = [];
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* This will render the component.
|
|
312
|
+
*
|
|
313
|
+
* @returns {object}
|
|
314
|
+
*/
|
|
315
|
+
render() {
|
|
316
|
+
return f(
|
|
317
|
+
{ class: `flex items-center justify-center p-2 text-muted-foreground rounded-md ${this.class || ""}` },
|
|
318
|
+
[
|
|
319
|
+
p({
|
|
320
|
+
class: "flex gap-x-4",
|
|
321
|
+
map: [this.options, (t) => this.addLink(t)],
|
|
322
|
+
watch: {
|
|
323
|
+
value: ["[[path]]", v.data],
|
|
324
|
+
callBack: this.updateLinks.bind(this)
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
]
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* This will update the links.
|
|
332
|
+
*
|
|
333
|
+
* @returns {void}
|
|
334
|
+
*/
|
|
335
|
+
afterSetup() {
|
|
336
|
+
const t = v.data.path;
|
|
337
|
+
this.updateLinks(t);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* This will update the links based on the current path.
|
|
341
|
+
*
|
|
342
|
+
* @param {string} path
|
|
343
|
+
* @returns {void}
|
|
344
|
+
*/
|
|
345
|
+
updateLinks(t) {
|
|
346
|
+
let e = !1;
|
|
347
|
+
this.deactivateAllLinks();
|
|
348
|
+
for (const i of this.links) {
|
|
349
|
+
if (!i.rendered)
|
|
350
|
+
continue;
|
|
351
|
+
K(i, i.getLinkPath(), t) ? (this.updateLink(i, !0), e = !0) : this.updateLink(i, !1);
|
|
352
|
+
}
|
|
353
|
+
!e && this.links[0] && this.updateLink(this.links[0], !0);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* This will deactivate all links.
|
|
357
|
+
*
|
|
358
|
+
* @returns {void}
|
|
359
|
+
*/
|
|
360
|
+
deactivateAllLinks() {
|
|
361
|
+
for (const t of this.links)
|
|
362
|
+
this.updateLink(t, !1);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* This will update the link's active state.
|
|
366
|
+
*
|
|
367
|
+
* @param {object} link
|
|
368
|
+
* @param {boolean} selected
|
|
369
|
+
* @returns {void}
|
|
370
|
+
*/
|
|
371
|
+
updateLink(t, e) {
|
|
372
|
+
t.update(e);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* This will add a link to the navigation.
|
|
376
|
+
*
|
|
377
|
+
* @param {object} option
|
|
378
|
+
* @returns {object}
|
|
379
|
+
*/
|
|
380
|
+
addLink({ label: t, href: e, exact: i, hidden: a }) {
|
|
381
|
+
const n = Q({ text: t, href: e, exact: i, hidden: a });
|
|
382
|
+
return this.links.push(n), n;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* This will clear the links.
|
|
386
|
+
*
|
|
387
|
+
* @returns {void}
|
|
388
|
+
*/
|
|
389
|
+
beforeDestroy() {
|
|
390
|
+
this.links = [];
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
class $t extends A {
|
|
394
|
+
/**
|
|
395
|
+
* This will get the overlay type.
|
|
396
|
+
*
|
|
397
|
+
* @returns {string}
|
|
398
|
+
*/
|
|
399
|
+
getClassName() {
|
|
400
|
+
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 || "");
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* This will setup and render the component.
|
|
404
|
+
*
|
|
405
|
+
* @param {object} container
|
|
406
|
+
* @returns {void}
|
|
407
|
+
*/
|
|
408
|
+
setup(t) {
|
|
409
|
+
this.container = t, this.initialize();
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const Z = (s) => w(
|
|
413
|
+
{
|
|
414
|
+
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",
|
|
415
|
+
dataStateSet: ["selected", ["state", s.value, "active"]]
|
|
416
|
+
},
|
|
417
|
+
[
|
|
418
|
+
b({
|
|
419
|
+
class: "flex flex-auto justify-center items-center px-3 py-1.5 rounded-md",
|
|
420
|
+
onState: ["selected", { selected: s.value }],
|
|
421
|
+
click: (t) => s.callBack(s.value)
|
|
422
|
+
}, s.label)
|
|
423
|
+
]
|
|
424
|
+
), tt = (s, t) => (s.callBack = t, Z(s)), et = (s) => f({ class: `tab items-center justify-center rounded-md bg-muted p-1 text-muted-foreground ${s.class}` }, [
|
|
425
|
+
p({ class: "flex flex-auto flex-row", map: [s.options, (t) => tt(t, s.callBack)] })
|
|
426
|
+
]);
|
|
427
|
+
class Nt extends u {
|
|
428
|
+
/**
|
|
429
|
+
* This will declare the props for the compiler.
|
|
430
|
+
*
|
|
431
|
+
* @returns {void}
|
|
432
|
+
*/
|
|
433
|
+
declareProps() {
|
|
434
|
+
this.options = [], this.class = "", this.callBack = null;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* This will render the component.
|
|
438
|
+
*
|
|
439
|
+
* @returns {object}
|
|
440
|
+
*/
|
|
441
|
+
render() {
|
|
442
|
+
const t = this.select.bind(this);
|
|
443
|
+
return l({ class: "" }, [
|
|
444
|
+
et({
|
|
445
|
+
class: this.class,
|
|
446
|
+
options: this.options,
|
|
447
|
+
callBack: t
|
|
448
|
+
}),
|
|
449
|
+
y({
|
|
450
|
+
class: "tab-content",
|
|
451
|
+
onState: ["selected", this.updateContent.bind(this)]
|
|
452
|
+
})
|
|
453
|
+
]);
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* This will get the first value.
|
|
457
|
+
*
|
|
458
|
+
* @returns {*}
|
|
459
|
+
*/
|
|
460
|
+
getFirstValue() {
|
|
461
|
+
return this.options[0]?.value;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* This will update the component.
|
|
465
|
+
*
|
|
466
|
+
* @returns {void}
|
|
467
|
+
*/
|
|
468
|
+
update() {
|
|
469
|
+
const t = this.state.get("selected");
|
|
470
|
+
this.select(null), this.select(t);
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* This will select a value.
|
|
474
|
+
*
|
|
475
|
+
* @param {*} value
|
|
476
|
+
* @returns {void}
|
|
477
|
+
*/
|
|
478
|
+
select(t) {
|
|
479
|
+
this.state.selected = t;
|
|
480
|
+
const e = this.onSelect;
|
|
481
|
+
typeof e == "function" && e(t, this.parent);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* This will update the content.
|
|
485
|
+
*
|
|
486
|
+
* @param {*} value
|
|
487
|
+
* @returns {object}
|
|
488
|
+
*/
|
|
489
|
+
updateContent(t) {
|
|
490
|
+
const e = this.options;
|
|
491
|
+
if (!e || e.length < 1)
|
|
492
|
+
return;
|
|
493
|
+
const i = e[0];
|
|
494
|
+
for (const a of e)
|
|
495
|
+
if (a.value === t)
|
|
496
|
+
return a.layout;
|
|
497
|
+
return i.layout;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* This will setup the states.
|
|
501
|
+
*
|
|
502
|
+
* @returns {object}
|
|
503
|
+
*/
|
|
504
|
+
setupStates() {
|
|
505
|
+
const t = this.callBack, e = typeof t;
|
|
506
|
+
return {
|
|
507
|
+
selected: {
|
|
508
|
+
state: this.getFirstValue(),
|
|
509
|
+
callBack(i) {
|
|
510
|
+
e === "function" && t(i);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
const st = (s) => w(
|
|
517
|
+
{
|
|
518
|
+
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",
|
|
519
|
+
dataStateSet: ["selected", ["state", s.value, "active"]]
|
|
520
|
+
},
|
|
521
|
+
[
|
|
522
|
+
b({
|
|
523
|
+
class: "flex flex-auto justify-center items-center px-3 py-1.5 rounded-md disabled:opacity-50 disabled:cursor-not-allowed",
|
|
524
|
+
onState: ["selected", { selected: s.value }],
|
|
525
|
+
click: (t) => s.callBack(s.value),
|
|
526
|
+
disabled: s.disabled
|
|
527
|
+
}, s.label)
|
|
528
|
+
]
|
|
529
|
+
), it = (s, t) => (s.callBack = t, st(s)), at = (s) => f({ class: `tab items-center justify-center rounded-md bg-muted p-1 text-muted-foreground ${s.class}` }, [
|
|
530
|
+
p({ class: "flex flex-auto flex-row", map: [s.options, (t) => it(t, s.callBack)] })
|
|
531
|
+
]);
|
|
532
|
+
class jt extends u {
|
|
533
|
+
/**
|
|
534
|
+
* This will declare the props for the compiler.
|
|
535
|
+
*
|
|
536
|
+
* @returns {void}
|
|
537
|
+
*/
|
|
538
|
+
declareProps() {
|
|
539
|
+
this.options = [], this.class = "", this.onSelect = null;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* This will render the component.
|
|
543
|
+
*
|
|
544
|
+
* @returns {object}
|
|
545
|
+
*/
|
|
546
|
+
render() {
|
|
547
|
+
const t = this.select.bind(this);
|
|
548
|
+
return at({
|
|
549
|
+
class: this.class,
|
|
550
|
+
options: this.options,
|
|
551
|
+
callBack: t
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* This will select a value.
|
|
556
|
+
*
|
|
557
|
+
* @param {*} value
|
|
558
|
+
* @returns {void}
|
|
559
|
+
*/
|
|
560
|
+
select(t) {
|
|
561
|
+
this.state.selected = t, typeof this.onSelect == "function" && this.onSelect(t, this.parent);
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* This will setup the states.
|
|
565
|
+
*
|
|
566
|
+
* @returns {object}
|
|
567
|
+
*/
|
|
568
|
+
setupStates() {
|
|
569
|
+
return {
|
|
570
|
+
selected: this.options[0]?.value || null
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
const nt = (s, t) => new RegExp(`${s}($|/|\\.).*`).test(t), ot = (s, t) => {
|
|
575
|
+
const e = s.getLinkPath();
|
|
576
|
+
return s.exact ? t === e : nt(e, t);
|
|
577
|
+
}, rt = ({ text: s, href: t, exact: e }) => new S({
|
|
578
|
+
text: s,
|
|
579
|
+
href: t,
|
|
580
|
+
exact: e,
|
|
581
|
+
dataSet: ["selected", ["state", !0, "active"]],
|
|
582
|
+
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"
|
|
583
|
+
});
|
|
584
|
+
class lt extends u {
|
|
585
|
+
/**
|
|
586
|
+
* This will declare the props for the compiler.
|
|
587
|
+
*
|
|
588
|
+
* @returns {void}
|
|
589
|
+
*/
|
|
590
|
+
declareProps() {
|
|
591
|
+
this.options = [], this.class = "", this.onSelect = null;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* This will configure the links.
|
|
595
|
+
*/
|
|
596
|
+
beforeSetup() {
|
|
597
|
+
this.links = [];
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* This will render the component.
|
|
601
|
+
*
|
|
602
|
+
* @returns {object}
|
|
603
|
+
*/
|
|
604
|
+
render() {
|
|
605
|
+
return f({ class: `tab items-center justify-center rounded-md bg-muted p-1 text-muted-foreground ${this.class}` }, [
|
|
606
|
+
p({
|
|
607
|
+
class: "flex flex-auto flex-row",
|
|
608
|
+
map: [this.options, (t) => this.addLink(t)],
|
|
609
|
+
watch: {
|
|
610
|
+
value: ["[[path]]", v.data],
|
|
611
|
+
callBack: this.updateLinks.bind(this)
|
|
612
|
+
}
|
|
613
|
+
})
|
|
614
|
+
]);
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* This will update the links.
|
|
618
|
+
*
|
|
619
|
+
* @returns {void}
|
|
620
|
+
*/
|
|
621
|
+
afterSetup() {
|
|
622
|
+
const t = v.data.path;
|
|
623
|
+
this.updateLinks(t);
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* This will update the links.
|
|
627
|
+
*
|
|
628
|
+
* @param {string} value
|
|
629
|
+
* @returns {void}
|
|
630
|
+
*/
|
|
631
|
+
updateLinks(t) {
|
|
632
|
+
let e = !1, i = this.links[0];
|
|
633
|
+
this.deactivateAllLinks();
|
|
634
|
+
for (const a of this.links)
|
|
635
|
+
if (a.rendered !== !1 && (e = ot(a, t), e === !0)) {
|
|
636
|
+
this.updateLink(a, !0);
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
e !== !0 && i && this.updateLink(i, !0);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* This will deactivate all links.
|
|
643
|
+
*
|
|
644
|
+
* @returns {void}
|
|
645
|
+
*/
|
|
646
|
+
deactivateAllLinks() {
|
|
647
|
+
for (const t of this.links)
|
|
648
|
+
this.updateLink(t, !1);
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* This will update the link.
|
|
652
|
+
*
|
|
653
|
+
* @param {object} link
|
|
654
|
+
* @param {boolean} selected
|
|
655
|
+
* @returns {void}
|
|
656
|
+
*/
|
|
657
|
+
updateLink(t, e) {
|
|
658
|
+
t.update(e);
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* This will add a link.
|
|
662
|
+
*
|
|
663
|
+
* @param {object} option
|
|
664
|
+
* @returns {object}
|
|
665
|
+
*/
|
|
666
|
+
addLink({ label: t, href: e, exact: i }) {
|
|
667
|
+
const a = rt({ text: t, href: e, exact: i });
|
|
668
|
+
return this.links.push(a), a;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* This will remove all the links.
|
|
672
|
+
*
|
|
673
|
+
* @returns {void}
|
|
674
|
+
*/
|
|
675
|
+
beforeDestroy() {
|
|
676
|
+
this.links = [];
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
class zt extends u {
|
|
680
|
+
/**
|
|
681
|
+
* This will declare the props for the compiler.
|
|
682
|
+
*
|
|
683
|
+
* @returns {void}
|
|
684
|
+
*/
|
|
685
|
+
declareProps() {
|
|
686
|
+
this.options = [], this.class = "";
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* This will render the component.
|
|
690
|
+
*
|
|
691
|
+
* @returns {object}
|
|
692
|
+
*/
|
|
693
|
+
render() {
|
|
694
|
+
return l({ class: "tab-panel" }, [
|
|
695
|
+
new lt({
|
|
696
|
+
class: this.class,
|
|
697
|
+
options: this.options
|
|
698
|
+
}),
|
|
699
|
+
y({
|
|
700
|
+
class: "tab-content",
|
|
701
|
+
switch: this.addGroup()
|
|
702
|
+
})
|
|
703
|
+
]);
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* This will add the group.
|
|
707
|
+
*
|
|
708
|
+
* @returns {array}
|
|
709
|
+
*/
|
|
710
|
+
addGroup() {
|
|
711
|
+
let t;
|
|
712
|
+
const e = [], i = this.options;
|
|
713
|
+
for (let a = 0, n = i.length; a < n; a++)
|
|
714
|
+
t = i[a], e.push(
|
|
715
|
+
{
|
|
716
|
+
uri: t.uri || t.href,
|
|
717
|
+
component: t.component,
|
|
718
|
+
title: t.title || null,
|
|
719
|
+
persist: !0
|
|
720
|
+
}
|
|
721
|
+
);
|
|
722
|
+
return e;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
const ct = (s) => w(
|
|
726
|
+
{
|
|
727
|
+
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",
|
|
728
|
+
dataStateSet: ["selected", ["state", s.value, "active"]]
|
|
729
|
+
},
|
|
730
|
+
[
|
|
731
|
+
b({
|
|
732
|
+
class: "flex flex-auto justify-center items-center px-4 py-3 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",
|
|
733
|
+
onState: ["selected", { selected: s.value }],
|
|
734
|
+
click: (t) => s.callBack(s.value)
|
|
735
|
+
}, s.label)
|
|
736
|
+
]
|
|
737
|
+
), ht = (s, t) => (s.callBack = t, ct(s)), dt = (s) => f({ class: `border-b border-border ${s.class}` }, [
|
|
738
|
+
p({ class: "flex flex-row items-center", map: [s.options, (t) => ht(t, s.callBack)] })
|
|
739
|
+
]);
|
|
740
|
+
class It extends u {
|
|
741
|
+
/**
|
|
742
|
+
* This will declare the props for the compiler.
|
|
743
|
+
*
|
|
744
|
+
* @returns {void}
|
|
745
|
+
*/
|
|
746
|
+
declareProps() {
|
|
747
|
+
this.options = [], this.class = "", this.onSelect = null;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* This will render the component.
|
|
751
|
+
*
|
|
752
|
+
* @returns {object}
|
|
753
|
+
*/
|
|
754
|
+
render() {
|
|
755
|
+
const t = this.select.bind(this);
|
|
756
|
+
return l({ class: "underlined-button-tab-panel flex flex-auto flex-col" }, [
|
|
757
|
+
dt({
|
|
758
|
+
class: this.class,
|
|
759
|
+
options: this.options,
|
|
760
|
+
callBack: t
|
|
761
|
+
}),
|
|
762
|
+
y({
|
|
763
|
+
class: "tab-content pt-6 flex flex-auto flex-col",
|
|
764
|
+
onState: ["selected", this.updateContent.bind(this)]
|
|
765
|
+
})
|
|
766
|
+
]);
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* This will get the first value.
|
|
770
|
+
*
|
|
771
|
+
* @returns {*}
|
|
772
|
+
*/
|
|
773
|
+
getFirstValue() {
|
|
774
|
+
return this.options[0]?.value;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* This will select an option.
|
|
778
|
+
*
|
|
779
|
+
* @param {*} value
|
|
780
|
+
* @returns {void}
|
|
781
|
+
*/
|
|
782
|
+
select(t) {
|
|
783
|
+
this.state.selected = t;
|
|
784
|
+
const e = this.onSelect;
|
|
785
|
+
typeof e == "function" && e(t, this.parent);
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* This will update the content.
|
|
789
|
+
*
|
|
790
|
+
* @param {*} value
|
|
791
|
+
* @returns {object}
|
|
792
|
+
*/
|
|
793
|
+
updateContent(t) {
|
|
794
|
+
const e = this.options;
|
|
795
|
+
if (!e || e.length < 1)
|
|
796
|
+
return;
|
|
797
|
+
const i = e[0];
|
|
798
|
+
for (const a of e)
|
|
799
|
+
if (a.value === t)
|
|
800
|
+
return a.component;
|
|
801
|
+
return i.component;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* This will setup the states.
|
|
805
|
+
*
|
|
806
|
+
* @returns {object}
|
|
807
|
+
*/
|
|
808
|
+
setupStates() {
|
|
809
|
+
const t = this.onSelect, e = typeof t;
|
|
810
|
+
return {
|
|
811
|
+
selected: {
|
|
812
|
+
state: this.getFirstValue(),
|
|
813
|
+
callBack(i) {
|
|
814
|
+
e === "function" && t(i);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
const ut = (s) => w(
|
|
821
|
+
{
|
|
822
|
+
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",
|
|
823
|
+
dataStateSet: ["selected", ["state", s.value, "active"]]
|
|
824
|
+
},
|
|
825
|
+
[
|
|
826
|
+
b({
|
|
827
|
+
class: "flex flex-auto justify-center items-center px-4 py-3 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",
|
|
828
|
+
onState: ["selected", { selected: s.value }],
|
|
829
|
+
click: (t) => s.callBack(s.value),
|
|
830
|
+
disabled: s.disabled
|
|
831
|
+
}, s.label)
|
|
832
|
+
]
|
|
833
|
+
), ft = (s, t) => (s.callBack = t, ut(s)), pt = (s) => f({ class: `border-b border-border ${s.class}` }, [
|
|
834
|
+
p({ class: "flex flex-row items-center", map: [s.options, (t) => ft(t, s.callBack)] })
|
|
835
|
+
]);
|
|
836
|
+
class Ut extends u {
|
|
837
|
+
/**
|
|
838
|
+
* This will declare the props for the compiler.
|
|
839
|
+
*
|
|
840
|
+
* @returns {void}
|
|
841
|
+
*/
|
|
842
|
+
declareProps() {
|
|
843
|
+
this.options = [], this.class = "", this.onSelect = null;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* This will render the component.
|
|
847
|
+
*
|
|
848
|
+
* @returns {object}
|
|
849
|
+
*/
|
|
850
|
+
render() {
|
|
851
|
+
const t = this.select.bind(this);
|
|
852
|
+
return pt({
|
|
853
|
+
class: this.class,
|
|
854
|
+
options: this.options,
|
|
855
|
+
callBack: t
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* This will select an option.
|
|
860
|
+
*
|
|
861
|
+
* @param {*} value
|
|
862
|
+
* @returns {void}
|
|
863
|
+
*/
|
|
864
|
+
select(t) {
|
|
865
|
+
this.state.selected = t, typeof this.onSelect == "function" && this.onSelect(t, this.parent);
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* This will setup the states.
|
|
869
|
+
*
|
|
870
|
+
* @returns {object}
|
|
871
|
+
*/
|
|
872
|
+
setupStates() {
|
|
873
|
+
return {
|
|
874
|
+
selected: this.options[0]?.value || null
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
const gt = (s, t) => new RegExp(`${s}($|/|\\.).*`).test(t), mt = (s, t) => {
|
|
879
|
+
const e = s.getLinkPath();
|
|
880
|
+
return s.exact ? t === e : gt(e, t);
|
|
881
|
+
}, vt = ({ text: s, href: t, exact: e }) => new S({
|
|
882
|
+
text: s,
|
|
883
|
+
href: t,
|
|
884
|
+
exact: e,
|
|
885
|
+
dataSet: ["selected", ["state", !0, "active"]],
|
|
886
|
+
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"
|
|
887
|
+
});
|
|
888
|
+
class bt extends u {
|
|
889
|
+
/**
|
|
890
|
+
* This will declare the props for the compiler.
|
|
891
|
+
*
|
|
892
|
+
* @returns {void}
|
|
893
|
+
*/
|
|
894
|
+
declareProps() {
|
|
895
|
+
this.options = [], this.class = "", this.onSelect = null;
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* This will configure the links.
|
|
899
|
+
*/
|
|
900
|
+
beforeSetup() {
|
|
901
|
+
this.links = [];
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* This will render the component.
|
|
905
|
+
*
|
|
906
|
+
* @returns {object}
|
|
907
|
+
*/
|
|
908
|
+
render() {
|
|
909
|
+
return f({ class: `border-b border-border ${this.class}` }, [
|
|
910
|
+
p({
|
|
911
|
+
class: "flex flex-row items-center",
|
|
912
|
+
map: [this.options, (t) => this.addLink(t)],
|
|
913
|
+
watch: {
|
|
914
|
+
value: ["[[path]]", v.data],
|
|
915
|
+
callBack: this.updateLinks.bind(this)
|
|
916
|
+
}
|
|
917
|
+
})
|
|
918
|
+
]);
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* This will update the links.
|
|
922
|
+
*
|
|
923
|
+
* @returns {void}
|
|
924
|
+
*/
|
|
925
|
+
afterSetup() {
|
|
926
|
+
const t = v.data.path;
|
|
927
|
+
this.updateLinks(t);
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* This will update the links.
|
|
931
|
+
*
|
|
932
|
+
* @param {string} value
|
|
933
|
+
* @returns {void}
|
|
934
|
+
*/
|
|
935
|
+
updateLinks(t) {
|
|
936
|
+
let e = !1, i = this.links[0];
|
|
937
|
+
this.deactivateAllLinks();
|
|
938
|
+
for (const a of this.links)
|
|
939
|
+
if (a.rendered !== !1 && (e = mt(a, t), e === !0)) {
|
|
940
|
+
this.updateLink(a, !0);
|
|
941
|
+
break;
|
|
942
|
+
}
|
|
943
|
+
e !== !0 && i && this.updateLink(i, !0);
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* This will deactivate all links.
|
|
947
|
+
*
|
|
948
|
+
* @returns {void}
|
|
949
|
+
*/
|
|
950
|
+
deactivateAllLinks() {
|
|
951
|
+
for (const t of this.links)
|
|
952
|
+
this.updateLink(t, !1);
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* This will update the link.
|
|
956
|
+
*
|
|
957
|
+
* @param {object} link
|
|
958
|
+
* @param {boolean} selected
|
|
959
|
+
* @returns {void}
|
|
960
|
+
*/
|
|
961
|
+
updateLink(t, e) {
|
|
962
|
+
t.update(e);
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* This will add a link.
|
|
966
|
+
*
|
|
967
|
+
* @param {object} option
|
|
968
|
+
* @returns {object}
|
|
969
|
+
*/
|
|
970
|
+
addLink({ label: t, href: e, exact: i }) {
|
|
971
|
+
const a = vt({ text: t, href: e, exact: i });
|
|
972
|
+
return this.links.push(a), a;
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* This will remove all the links.
|
|
976
|
+
*
|
|
977
|
+
* @returns {void}
|
|
978
|
+
*/
|
|
979
|
+
beforeDestroy() {
|
|
980
|
+
this.links = [];
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
class At extends u {
|
|
984
|
+
/**
|
|
985
|
+
* This will declare the props for the compiler.
|
|
986
|
+
*
|
|
987
|
+
* @returns {void}
|
|
988
|
+
*/
|
|
989
|
+
declareProps() {
|
|
990
|
+
this.options = [], this.class = "";
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* This will render the component.
|
|
994
|
+
*
|
|
995
|
+
* @returns {object}
|
|
996
|
+
*/
|
|
997
|
+
render() {
|
|
998
|
+
return l({ class: "underlined-tab-panel flex flex-auto flex-col" }, [
|
|
999
|
+
new bt({
|
|
1000
|
+
class: this.class,
|
|
1001
|
+
options: this.options
|
|
1002
|
+
}),
|
|
1003
|
+
y({
|
|
1004
|
+
class: "tab-content pt-6 flex flex-auto flex-col",
|
|
1005
|
+
switch: this.addGroup()
|
|
1006
|
+
})
|
|
1007
|
+
]);
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* This will add the group.
|
|
1011
|
+
*
|
|
1012
|
+
* @returns {array}
|
|
1013
|
+
*/
|
|
1014
|
+
addGroup() {
|
|
1015
|
+
let t;
|
|
1016
|
+
const e = [], i = this.options;
|
|
1017
|
+
for (let a = 0, n = i.length; a < n; a++)
|
|
1018
|
+
t = i[a], e.push(
|
|
1019
|
+
{
|
|
1020
|
+
uri: t.uri || t.href,
|
|
1021
|
+
component: t.component,
|
|
1022
|
+
title: t.title || null,
|
|
1023
|
+
persist: !0
|
|
1024
|
+
}
|
|
1025
|
+
);
|
|
1026
|
+
return e;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
class kt extends k {
|
|
1030
|
+
/**
|
|
1031
|
+
* Runs before rendering, sets up defaults, a timer for drawing,
|
|
1032
|
+
* and basic canvas properties.
|
|
1033
|
+
*
|
|
1034
|
+
* @returns {void}
|
|
1035
|
+
*/
|
|
1036
|
+
onCreated() {
|
|
1037
|
+
this.lineWidth = this.lineWidth || 3, this.lineColor = this.lineColor || "#000000", this.canvas = null, this.ctx = null, this.status = "stopped";
|
|
1038
|
+
const t = 1e3 / 60;
|
|
1039
|
+
this.timer = new O(t, 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";
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Renders a <canvas> element.
|
|
1043
|
+
*
|
|
1044
|
+
* @returns {object} Layout definition for the canvas.
|
|
1045
|
+
*/
|
|
1046
|
+
render() {
|
|
1047
|
+
return z({
|
|
1048
|
+
style: "touch-action: none; -webkit-user-select: none; -webkit-touch-callout: none;"
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Called before the component is destroyed. Stops the timer
|
|
1053
|
+
* to prevent memory leaks or ongoing animation.
|
|
1054
|
+
*
|
|
1055
|
+
* @returns {void}
|
|
1056
|
+
*/
|
|
1057
|
+
beforeDestroy() {
|
|
1058
|
+
this.stopTimer();
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Called after component setup. Initializes canvas context,
|
|
1062
|
+
* schedules a resize, and draws the initial content.
|
|
1063
|
+
*
|
|
1064
|
+
* @returns {void}
|
|
1065
|
+
*/
|
|
1066
|
+
afterSetup() {
|
|
1067
|
+
this.canvas = this.panel, this.ctx = this.canvas.getContext("2d"), globalThis.setTimeout(() => {
|
|
1068
|
+
this.resize(), this.draw();
|
|
1069
|
+
}, 1);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Defines the DOM events to set up for this canvas component.
|
|
1073
|
+
*
|
|
1074
|
+
* @returns {Array} An array of [eventName, element, callback] definitions.
|
|
1075
|
+
*/
|
|
1076
|
+
setupEvents() {
|
|
1077
|
+
const t = this.panel, e = this.pointerPosition.bind(this), i = this.pointerUp.bind(this), a = this.pointerDown.bind(this), n = this.resize.bind(this), o = { passive: !1 };
|
|
1078
|
+
return [
|
|
1079
|
+
["pointermove", t, e, o],
|
|
1080
|
+
["pointerup", t, i],
|
|
1081
|
+
["pointerdown", t, a, o],
|
|
1082
|
+
["pointerout", t, i],
|
|
1083
|
+
["resize", globalThis, n]
|
|
1084
|
+
];
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Calculates and saves the current pointer position in canvas coordinates.
|
|
1088
|
+
*
|
|
1089
|
+
* @param {Event} e The event object (mouse or touch).
|
|
1090
|
+
* @returns {void}
|
|
1091
|
+
*/
|
|
1092
|
+
getEventPosition(t) {
|
|
1093
|
+
let e, i;
|
|
1094
|
+
const a = this.canvas, n = a.width / parseInt(a.style.width), o = a.getBoundingClientRect();
|
|
1095
|
+
if (t.touches && t.touches.length) {
|
|
1096
|
+
const d = t.touches[0];
|
|
1097
|
+
e = d.clientX, i = d.clientY;
|
|
1098
|
+
} else
|
|
1099
|
+
e = t.x || t.clientX, i = t.y || t.clientY;
|
|
1100
|
+
const h = parseInt((e - o.left) * n), r = parseInt((i - o.top) * n);
|
|
1101
|
+
this.mouse.x = h, this.mouse.y = r;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Called when the pointer goes down on the canvas.
|
|
1105
|
+
* Begins a new path, sets the mouse status, and starts the timer.
|
|
1106
|
+
*
|
|
1107
|
+
* @param {Event} e The event object.
|
|
1108
|
+
* @returns {void}
|
|
1109
|
+
*/
|
|
1110
|
+
pointerDown(t) {
|
|
1111
|
+
t.preventDefault(), t.stopPropagation(), this.getEventPosition(t);
|
|
1112
|
+
const { ctx: e, mouse: i } = this;
|
|
1113
|
+
e.beginPath(), e.moveTo(i.x, i.y), i.status = "down", this.startTimer();
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Called when the pointer goes up or leaves the canvas area.
|
|
1117
|
+
* Closes the path and stops the drawing timer.
|
|
1118
|
+
*
|
|
1119
|
+
* @param {Event} e The event object.
|
|
1120
|
+
* @returns {void}
|
|
1121
|
+
*/
|
|
1122
|
+
pointerUp(t) {
|
|
1123
|
+
t.preventDefault(), t.stopPropagation(), this.ctx.closePath(), this.mouse.status = "up", this.stopTimer();
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Tracks pointer movement, updates position in real time.
|
|
1127
|
+
*
|
|
1128
|
+
* @param {Event} e The event object.
|
|
1129
|
+
* @returns {void}
|
|
1130
|
+
*/
|
|
1131
|
+
pointerPosition(t) {
|
|
1132
|
+
this.getEventPosition(t), this.mouse.status === "down" && (t.preventDefault(), t.stopPropagation());
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Resizes the canvas, preserves existing drawing by converting
|
|
1136
|
+
* it to a data URL, then re-drawing.
|
|
1137
|
+
*
|
|
1138
|
+
* @returns {void}
|
|
1139
|
+
*/
|
|
1140
|
+
resize() {
|
|
1141
|
+
const { canvas: t, ctx: e } = this, i = t.toDataURL();
|
|
1142
|
+
if (this.scale(), this.setupBackground(e), i !== "data:,") {
|
|
1143
|
+
const a = new globalThis.Image();
|
|
1144
|
+
L.on("load", a, function n() {
|
|
1145
|
+
e.drawImage(a, 0, 0), L.off("load", a, n);
|
|
1146
|
+
}), a.src = i;
|
|
1147
|
+
}
|
|
1148
|
+
this.draw();
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Returns a JPEG data URL of the current canvas content.
|
|
1152
|
+
*
|
|
1153
|
+
* @returns {string} The signature image as a data URL.
|
|
1154
|
+
*/
|
|
1155
|
+
getImage() {
|
|
1156
|
+
return this.canvas.toDataURL("image/jpeg", 0.7);
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* (Deprecated approach) Resize the canvas to the container size
|
|
1160
|
+
* without scaling logic.
|
|
1161
|
+
*
|
|
1162
|
+
* @returns {void}
|
|
1163
|
+
*/
|
|
1164
|
+
noScaleResize() {
|
|
1165
|
+
const t = B.getSize(container);
|
|
1166
|
+
this.width = canvas.width = t.width, this.height = canvas.height = t.height;
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Scales the canvas to fit within its container, preserving aspect ratio
|
|
1170
|
+
* relative to this.targetSize.
|
|
1171
|
+
*
|
|
1172
|
+
* @returns {void}
|
|
1173
|
+
*/
|
|
1174
|
+
scale() {
|
|
1175
|
+
const t = this.canvas, e = this.container, i = B.getSize(e), a = this.targetSize, n = a.width, o = a.height;
|
|
1176
|
+
let h = n + "px", r = o + "px";
|
|
1177
|
+
if (this.width = t.width = n, this.height = t.height = o, i.width !== 0 && i.height !== 0) {
|
|
1178
|
+
const d = i.width, g = i.height, c = d / n, m = g / o, x = Math.min(c, m);
|
|
1179
|
+
h = n * x + "px", r = o * x + "px";
|
|
1180
|
+
}
|
|
1181
|
+
t.style.width = h, t.style.height = r;
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Main drawing loop. If the mouse is down, adds a line
|
|
1185
|
+
* from the last point to the current pointer position.
|
|
1186
|
+
*
|
|
1187
|
+
* @returns {void}
|
|
1188
|
+
*/
|
|
1189
|
+
draw() {
|
|
1190
|
+
this.mouse.status === "down" && this.addLine(this.ctx, this.mouse.x, this.mouse.y, this.lineColor);
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Draws the baseline at the bottom of the canvas.
|
|
1194
|
+
*
|
|
1195
|
+
* @param {CanvasRenderingContext2D} ctx The canvas 2D context.
|
|
1196
|
+
* @returns {void}
|
|
1197
|
+
*/
|
|
1198
|
+
drawBottomLine(t) {
|
|
1199
|
+
const e = this.canvas;
|
|
1200
|
+
t.globalAlpha = 1, t.shadowBlur = 0;
|
|
1201
|
+
const i = this.margin.x, a = this.height - this.margin.y;
|
|
1202
|
+
t.beginPath(), t.moveTo(i, a), t.lineTo(e.width - this.margin.x, a), t.lineWidth = this.baseLineWidth, t.strokeStyle = this.baseStrokeColor, t.stroke(), t.closePath();
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Adds a line to the current path, updating the 'signed' status.
|
|
1206
|
+
*
|
|
1207
|
+
* @param {CanvasRenderingContext2D} ctx The canvas context.
|
|
1208
|
+
* @param {number} px The x-coordinate.
|
|
1209
|
+
* @param {number} py The y-coordinate.
|
|
1210
|
+
* @param {string} color The stroke color.
|
|
1211
|
+
* @returns {void}
|
|
1212
|
+
*/
|
|
1213
|
+
addLine(t, e, i, a) {
|
|
1214
|
+
this.signed || (this.signed = !0);
|
|
1215
|
+
const n = Math.round(e), o = Math.round(i);
|
|
1216
|
+
t.lineWidth = this.lineWidth, t.strokeStyle = a, t.lineTo(n, o), t.stroke();
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Clears the canvas, sets signed to false, and re-initializes
|
|
1220
|
+
* the background for a fresh signature.
|
|
1221
|
+
*
|
|
1222
|
+
* @returns {void}
|
|
1223
|
+
*/
|
|
1224
|
+
reset() {
|
|
1225
|
+
this.signed = !1;
|
|
1226
|
+
const { ctx: t } = this;
|
|
1227
|
+
t.clearRect(0, 0, this.width, this.height), this.setupBackground(t);
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Fills the canvas background with white and draws the baseline.
|
|
1231
|
+
*
|
|
1232
|
+
* @param {CanvasRenderingContext2D} ctx The canvas context.
|
|
1233
|
+
* @returns {void}
|
|
1234
|
+
*/
|
|
1235
|
+
setupBackground(t) {
|
|
1236
|
+
t.fillStyle = "transparent", t.fillRect(0, 0, this.width, this.height), this.drawBottomLine(t);
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Starts the drawing timer so new lines can be added as pointer moves.
|
|
1240
|
+
*
|
|
1241
|
+
* @returns {void}
|
|
1242
|
+
*/
|
|
1243
|
+
startTimer() {
|
|
1244
|
+
this.stopTimer(), this.draw(), this.timer.start(), this.status = "started";
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Stops the drawing timer.
|
|
1248
|
+
*
|
|
1249
|
+
* @returns {void}
|
|
1250
|
+
*/
|
|
1251
|
+
stopTimer() {
|
|
1252
|
+
this.timer.stop(), this.status = "stopped";
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
class Ft extends k {
|
|
1256
|
+
/**
|
|
1257
|
+
* Sets up default properties for the signature panel.
|
|
1258
|
+
*
|
|
1259
|
+
* @returns {void}
|
|
1260
|
+
*/
|
|
1261
|
+
declareProps() {
|
|
1262
|
+
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;
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Renders the main layout for the signature panel,
|
|
1266
|
+
* including a hidden input and a reset button.
|
|
1267
|
+
*
|
|
1268
|
+
* @returns {object} The layout object for the component.
|
|
1269
|
+
*/
|
|
1270
|
+
render() {
|
|
1271
|
+
return l({ class: "signature-panel relative flex flex-auto overflow-hidden select-none" }, [
|
|
1272
|
+
F({
|
|
1273
|
+
cache: "hiddenInput",
|
|
1274
|
+
required: !0,
|
|
1275
|
+
bind: this.path + ".data"
|
|
1276
|
+
}),
|
|
1277
|
+
l({ class: "absolute top-2 right-2" }, [
|
|
1278
|
+
C({
|
|
1279
|
+
variant: "icon",
|
|
1280
|
+
icon: D.circleX,
|
|
1281
|
+
click: this.reset.bind(this)
|
|
1282
|
+
})
|
|
1283
|
+
]),
|
|
1284
|
+
new kt({
|
|
1285
|
+
cache: "canvasLayer",
|
|
1286
|
+
margin: this.margin,
|
|
1287
|
+
targetSize: this.targetSize,
|
|
1288
|
+
lineColor: this.lineColor,
|
|
1289
|
+
lineWidth: this.lineWidth,
|
|
1290
|
+
baseLineWidth: this.baseLineWidth,
|
|
1291
|
+
baseStrokeColor: this.baseStrokeColor,
|
|
1292
|
+
pointerUpCallBack: this.pointerUp,
|
|
1293
|
+
callBackData: this.callBackData
|
|
1294
|
+
})
|
|
1295
|
+
]);
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Called after component setup. Resizes the signature canvas once
|
|
1299
|
+
* everything is ready.
|
|
1300
|
+
*
|
|
1301
|
+
* @returns {void}
|
|
1302
|
+
*/
|
|
1303
|
+
afterSetup() {
|
|
1304
|
+
this.canvasLayer.resize();
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Gets the signature image from the canvas layer, as a data URL.
|
|
1308
|
+
*
|
|
1309
|
+
* @returns {string} The signature image data URL.
|
|
1310
|
+
*/
|
|
1311
|
+
getImage() {
|
|
1312
|
+
return this.canvasLayer.getImage();
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Checks if the user has drawn anything on the signature canvas.
|
|
1316
|
+
*
|
|
1317
|
+
* @returns {boolean} True if the canvas has been signed, otherwise false.
|
|
1318
|
+
*/
|
|
1319
|
+
isSigned() {
|
|
1320
|
+
return this.canvasLayer ? this.canvasLayer.signed : !1;
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Resets the signature canvas to a blank state.
|
|
1324
|
+
*
|
|
1325
|
+
* @param {Event} [e] The event object (if called by a click event).
|
|
1326
|
+
* @returns {void}
|
|
1327
|
+
*/
|
|
1328
|
+
reset(t) {
|
|
1329
|
+
if (this.canvasLayer)
|
|
1330
|
+
return this.canvasLayer.reset();
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Cleans up references before destroying the component.
|
|
1334
|
+
*
|
|
1335
|
+
* @returns {void}
|
|
1336
|
+
*/
|
|
1337
|
+
beforeDestroy() {
|
|
1338
|
+
this.canvasLayer = null, this.hiddenInput = null;
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
export {
|
|
1342
|
+
Nt as B,
|
|
1343
|
+
$t as I,
|
|
1344
|
+
Mt as N,
|
|
1345
|
+
Pt as P,
|
|
1346
|
+
Ft as S,
|
|
1347
|
+
zt as T,
|
|
1348
|
+
It as U,
|
|
1349
|
+
Ct as W,
|
|
1350
|
+
jt as a,
|
|
1351
|
+
lt as b,
|
|
1352
|
+
At as c,
|
|
1353
|
+
Ut as d,
|
|
1354
|
+
bt as e,
|
|
1355
|
+
X as f,
|
|
1356
|
+
q as g,
|
|
1357
|
+
_ as h,
|
|
1358
|
+
R as i,
|
|
1359
|
+
Wt as j,
|
|
1360
|
+
P as k,
|
|
1361
|
+
Tt as l,
|
|
1362
|
+
G as m,
|
|
1363
|
+
E as n
|
|
1364
|
+
};
|