@hemerson/design-system 0.7.0 → 0.8.0
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/dist/index.js
CHANGED
|
@@ -111,14 +111,14 @@ var O = l(function({ variant: e = "primary", size: t = "md", icon: n, iconOnly:
|
|
|
111
111
|
});
|
|
112
112
|
//#endregion
|
|
113
113
|
//#region src/components/NavBar/NavBar.tsx
|
|
114
|
-
function
|
|
114
|
+
function ee({ active: e = !1, className: t, ...n }) {
|
|
115
115
|
return /* @__PURE__ */ b("a", {
|
|
116
116
|
...n,
|
|
117
117
|
"aria-current": e ? "page" : void 0,
|
|
118
118
|
className: C("hds-navbar-link", t)
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function k({ title: e, actions: t, navLabel: n = "Principal", className: r, children: i, ...a }) {
|
|
122
122
|
return /* @__PURE__ */ x(w, {
|
|
123
123
|
...a,
|
|
124
124
|
as: "header",
|
|
@@ -140,10 +140,10 @@ function A({ title: e, actions: t, navLabel: n = "Principal", className: r, chil
|
|
|
140
140
|
]
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
var
|
|
143
|
+
var A = Object.assign(k, { Link: ee });
|
|
144
144
|
//#endregion
|
|
145
145
|
//#region src/components/Sidebar/Sidebar.tsx
|
|
146
|
-
function
|
|
146
|
+
function j({ items: e, footer: t, floating: n = !1, label: r = "Navegação", className: i }) {
|
|
147
147
|
return /* @__PURE__ */ x(w, {
|
|
148
148
|
as: "nav",
|
|
149
149
|
"aria-label": r,
|
|
@@ -177,13 +177,13 @@ function M({ items: e, footer: t, floating: n = !1, label: r = "Navegação", cl
|
|
|
177
177
|
}
|
|
178
178
|
//#endregion
|
|
179
179
|
//#region src/components/SegmentedControl/SegmentedControl.tsx
|
|
180
|
-
var
|
|
180
|
+
var M = {
|
|
181
181
|
ArrowRight: 1,
|
|
182
182
|
ArrowDown: 1,
|
|
183
183
|
ArrowLeft: -1,
|
|
184
184
|
ArrowUp: -1
|
|
185
185
|
};
|
|
186
|
-
function
|
|
186
|
+
function N({ options: e, value: t, defaultValue: n, onChange: r, label: i, className: a }) {
|
|
187
187
|
let [o, s] = _(n ?? e[0]?.value), c = t === void 0 ? o : t, l = g([]), u = g(null), d = Math.max(0, e.findIndex((e) => e.value === c));
|
|
188
188
|
m(() => {
|
|
189
189
|
function e() {
|
|
@@ -196,7 +196,7 @@ function P({ options: e, value: t, defaultValue: n, onChange: r, label: i, class
|
|
|
196
196
|
t === void 0 && s(e), r?.(e);
|
|
197
197
|
}
|
|
198
198
|
function p(t) {
|
|
199
|
-
let n =
|
|
199
|
+
let n = M[t.key];
|
|
200
200
|
if (!n) return;
|
|
201
201
|
t.preventDefault();
|
|
202
202
|
let r = (d + n + e.length) % e.length;
|
|
@@ -230,13 +230,13 @@ function P({ options: e, value: t, defaultValue: n, onChange: r, label: i, class
|
|
|
230
230
|
})]
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function te(e, t, n) {
|
|
234
234
|
let r = e.getBoundingClientRect(), i = t.offsetWidth, a = t.offsetHeight, o = document.documentElement.clientWidth || window.innerWidth, s = document.documentElement.clientHeight || window.innerHeight, c = r.bottom + 8 + a <= s - 8, l = r.top - 8 - a >= 8, u = c || !l ? r.bottom + 8 : r.top - 8 - a, d = n === "end" ? r.right - i : r.left, f = Math.min(Math.max(8, d), Math.max(8, o - i - 8));
|
|
235
235
|
t.style.top = `${Math.round(u)}px`, t.style.left = `${Math.round(f)}px`, t.dataset.side = c || !l ? "bottom" : "top";
|
|
236
236
|
}
|
|
237
237
|
//#endregion
|
|
238
238
|
//#region src/components/Menu/Menu.tsx
|
|
239
|
-
function
|
|
239
|
+
function P({ label: e, icon: t, iconOnly: n = !1, items: r, align: i = "end", triggerVariant: a = "glass", header: o, className: s }) {
|
|
240
240
|
let [c, l] = _(!1), u = g(null), d = g(null), h = p(), v = () => Array.from(d.current?.querySelectorAll("[role=\"menuitem\"]") ?? []);
|
|
241
241
|
function T(e) {
|
|
242
242
|
l(!1), e && u.current?.focus();
|
|
@@ -244,7 +244,7 @@ function F({ label: e, icon: t, iconOnly: n = !1, items: r, align: i = "end", tr
|
|
|
244
244
|
m(() => {
|
|
245
245
|
if (!c || !u.current || !d.current) return;
|
|
246
246
|
let e = () => {
|
|
247
|
-
u.current && d.current &&
|
|
247
|
+
u.current && d.current && te(u.current, d.current, i);
|
|
248
248
|
};
|
|
249
249
|
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
250
250
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
@@ -309,7 +309,7 @@ function F({ label: e, icon: t, iconOnly: n = !1, items: r, align: i = "end", tr
|
|
|
309
309
|
}
|
|
310
310
|
//#endregion
|
|
311
311
|
//#region src/components/FloatingButton/FloatingButton.tsx
|
|
312
|
-
var
|
|
312
|
+
var F = l(function({ label: e, position: t = "bottom-right", type: n = "button", className: r, ...i }, a) {
|
|
313
313
|
return /* @__PURE__ */ b("button", {
|
|
314
314
|
...i,
|
|
315
315
|
ref: a,
|
|
@@ -318,8 +318,8 @@ var I = l(function({ label: e, position: t = "bottom-right", type: n = "button",
|
|
|
318
318
|
title: e,
|
|
319
319
|
className: C("hds-glass", "hds-fab", `hds-fab--${t}`, r)
|
|
320
320
|
});
|
|
321
|
-
}),
|
|
322
|
-
function
|
|
321
|
+
}), I = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
322
|
+
function L({ open: e, onClose: t, title: n, description: r, children: i, footer: a, closeLabel: o = "Fechar", initialFocus: s = "first", size: c = "md", className: l }) {
|
|
323
323
|
let u = g(null), d = p(), m = p(), h = g(t);
|
|
324
324
|
return f(() => {
|
|
325
325
|
h.current = t;
|
|
@@ -327,7 +327,7 @@ function R({ open: e, onClose: t, title: n, description: r, children: i, footer:
|
|
|
327
327
|
if (!e) return;
|
|
328
328
|
let t = document.activeElement, n = document.body.style.overflow;
|
|
329
329
|
document.body.style.overflow = "hidden";
|
|
330
|
-
let r = u.current?.querySelectorAll(
|
|
330
|
+
let r = u.current?.querySelectorAll(I) ?? [];
|
|
331
331
|
(s === "panel" || r.length === 0 ? u.current : r[0])?.focus();
|
|
332
332
|
function i(e) {
|
|
333
333
|
if (e.key === "Escape") {
|
|
@@ -336,7 +336,7 @@ function R({ open: e, onClose: t, title: n, description: r, children: i, footer:
|
|
|
336
336
|
return;
|
|
337
337
|
}
|
|
338
338
|
if (e.key !== "Tab" || !u.current) return;
|
|
339
|
-
let t = Array.from(u.current.querySelectorAll(
|
|
339
|
+
let t = Array.from(u.current.querySelectorAll(I));
|
|
340
340
|
if (t.length === 0) return;
|
|
341
341
|
let n = t[0], r = t[t.length - 1];
|
|
342
342
|
e.shiftKey && document.activeElement === n ? (e.preventDefault(), r.focus()) : !e.shiftKey && document.activeElement === r && (e.preventDefault(), n.focus());
|
|
@@ -389,13 +389,13 @@ function R({ open: e, onClose: t, title: n, description: r, children: i, footer:
|
|
|
389
389
|
}
|
|
390
390
|
//#endregion
|
|
391
391
|
//#region src/components/Toast/ToastView.tsx
|
|
392
|
-
var
|
|
392
|
+
var R = {
|
|
393
393
|
neutral: "info",
|
|
394
394
|
success: "circle-check",
|
|
395
395
|
warning: "triangle-alert",
|
|
396
396
|
danger: "circle-x"
|
|
397
397
|
};
|
|
398
|
-
function
|
|
398
|
+
function z({ tone: e, title: t, description: n, duration: r, onClose: i, closeLabel: a, className: o }) {
|
|
399
399
|
let [s, c] = _(!1), l = g(i);
|
|
400
400
|
return f(() => {
|
|
401
401
|
l.current = i;
|
|
@@ -411,7 +411,7 @@ function B({ tone: e, title: t, description: n, duration: r, onClose: i, closeLa
|
|
|
411
411
|
onFocus: () => c(!0),
|
|
412
412
|
onBlur: () => c(!1),
|
|
413
413
|
children: [
|
|
414
|
-
/* @__PURE__ */ b(D, { name:
|
|
414
|
+
/* @__PURE__ */ b(D, { name: R[e] }),
|
|
415
415
|
/* @__PURE__ */ x("div", {
|
|
416
416
|
className: "hds-toast-body",
|
|
417
417
|
children: [/* @__PURE__ */ b("p", {
|
|
@@ -435,10 +435,10 @@ function B({ tone: e, title: t, description: n, duration: r, onClose: i, closeLa
|
|
|
435
435
|
}
|
|
436
436
|
//#endregion
|
|
437
437
|
//#region src/components/Toast/Toast.tsx
|
|
438
|
-
function
|
|
438
|
+
function B({ open: e, onClose: t, tone: n = "neutral", title: r, description: i, duration: a = 5e3, closeLabel: o = "Fechar aviso", className: s }) {
|
|
439
439
|
return e ? S(/* @__PURE__ */ b("div", {
|
|
440
440
|
className: "hds-toast-region",
|
|
441
|
-
children: /* @__PURE__ */ b(
|
|
441
|
+
children: /* @__PURE__ */ b(z, {
|
|
442
442
|
tone: n,
|
|
443
443
|
title: r,
|
|
444
444
|
description: i,
|
|
@@ -451,8 +451,8 @@ function V({ open: e, onClose: t, tone: n = "neutral", title: r, description: i,
|
|
|
451
451
|
}
|
|
452
452
|
//#endregion
|
|
453
453
|
//#region src/components/Toast/ToastProvider.tsx
|
|
454
|
-
var
|
|
455
|
-
function
|
|
454
|
+
var V = c(null);
|
|
455
|
+
function ne({ children: e, max: t = 3, closeLabel: n = "Fechar aviso" }) {
|
|
456
456
|
let [r, i] = _([]), a = g(0), o = u((e) => {
|
|
457
457
|
i((t) => t.filter((t) => t.id !== e));
|
|
458
458
|
}, []), s = u(({ title: e, description: n, tone: r = "neutral", duration: o = 5e3 }) => {
|
|
@@ -488,11 +488,11 @@ function U({ children: e, max: t = 3, closeLabel: n = "Fechar aviso" }) {
|
|
|
488
488
|
tone: "neutral"
|
|
489
489
|
})
|
|
490
490
|
}), [s, o]);
|
|
491
|
-
return /* @__PURE__ */ x(
|
|
491
|
+
return /* @__PURE__ */ x(V.Provider, {
|
|
492
492
|
value: c,
|
|
493
493
|
children: [e, r.length ? S(/* @__PURE__ */ b("div", {
|
|
494
494
|
className: "hds-toast-region",
|
|
495
|
-
children: r.map((e) => /* @__PURE__ */ b(
|
|
495
|
+
children: r.map((e) => /* @__PURE__ */ b(z, {
|
|
496
496
|
tone: e.tone,
|
|
497
497
|
title: e.title,
|
|
498
498
|
description: e.description,
|
|
@@ -503,14 +503,14 @@ function U({ children: e, max: t = 3, closeLabel: n = "Fechar aviso" }) {
|
|
|
503
503
|
}), document.body) : null]
|
|
504
504
|
});
|
|
505
505
|
}
|
|
506
|
-
function
|
|
507
|
-
let e = d(
|
|
506
|
+
function H() {
|
|
507
|
+
let e = d(V);
|
|
508
508
|
if (!e) throw Error("useToast must be used inside a ToastProvider.");
|
|
509
509
|
return e;
|
|
510
510
|
}
|
|
511
511
|
//#endregion
|
|
512
512
|
//#region src/internal/field.tsx
|
|
513
|
-
function
|
|
513
|
+
function U(e) {
|
|
514
514
|
let t = p(), n = e ?? t;
|
|
515
515
|
return {
|
|
516
516
|
id: n,
|
|
@@ -518,7 +518,7 @@ function G(e) {
|
|
|
518
518
|
error: `${n}-error`
|
|
519
519
|
};
|
|
520
520
|
}
|
|
521
|
-
function
|
|
521
|
+
function W(e, t) {
|
|
522
522
|
let n = [
|
|
523
523
|
e.hint && t.hint,
|
|
524
524
|
e.error && t.error,
|
|
@@ -526,7 +526,7 @@ function K(e, t) {
|
|
|
526
526
|
].filter(Boolean);
|
|
527
527
|
return n.length ? n.join(" ") : void 0;
|
|
528
528
|
}
|
|
529
|
-
function
|
|
529
|
+
function re({ hint: e, error: t, ids: n }) {
|
|
530
530
|
return /* @__PURE__ */ x(y, { children: [e ? /* @__PURE__ */ b("p", {
|
|
531
531
|
id: n.hint,
|
|
532
532
|
className: "hds-hint",
|
|
@@ -539,58 +539,58 @@ function q({ hint: e, error: t, ids: n }) {
|
|
|
539
539
|
}
|
|
540
540
|
//#endregion
|
|
541
541
|
//#region src/components/Input/Input.tsx
|
|
542
|
-
var
|
|
543
|
-
let
|
|
542
|
+
var G = l(function({ label: e, hint: t, error: n, numeric: r = !1, hideLabel: i = !1, id: a, className: o, ...s }, c) {
|
|
543
|
+
let l = U(a);
|
|
544
544
|
return /* @__PURE__ */ x("div", {
|
|
545
|
-
className: C("hds-field",
|
|
545
|
+
className: C("hds-field", o),
|
|
546
546
|
children: [
|
|
547
547
|
/* @__PURE__ */ b("label", {
|
|
548
|
-
className: "hds-label",
|
|
549
|
-
htmlFor:
|
|
548
|
+
className: C("hds-label", i && "hds-visually-hidden"),
|
|
549
|
+
htmlFor: l.id,
|
|
550
550
|
children: e
|
|
551
551
|
}),
|
|
552
552
|
/* @__PURE__ */ b("input", {
|
|
553
553
|
inputMode: r ? "decimal" : void 0,
|
|
554
|
-
...
|
|
555
|
-
ref:
|
|
556
|
-
id:
|
|
554
|
+
...s,
|
|
555
|
+
ref: c,
|
|
556
|
+
id: l.id,
|
|
557
557
|
"aria-invalid": n ? !0 : void 0,
|
|
558
|
-
"aria-describedby":
|
|
558
|
+
"aria-describedby": W({
|
|
559
559
|
hint: t,
|
|
560
560
|
error: n,
|
|
561
|
-
"aria-describedby":
|
|
562
|
-
},
|
|
561
|
+
"aria-describedby": s["aria-describedby"]
|
|
562
|
+
}, l),
|
|
563
563
|
className: C("hds-input", r && "hds-input--numeric")
|
|
564
564
|
}),
|
|
565
|
-
/* @__PURE__ */ b(
|
|
565
|
+
/* @__PURE__ */ b(re, {
|
|
566
566
|
hint: t,
|
|
567
567
|
error: n,
|
|
568
|
-
ids:
|
|
568
|
+
ids: l
|
|
569
569
|
})
|
|
570
570
|
]
|
|
571
571
|
});
|
|
572
|
-
}),
|
|
573
|
-
let
|
|
572
|
+
}), ie = l(function({ label: e, options: t, placeholder: n, hint: r, error: i, hideLabel: a = !1, id: o, className: s, ...c }, l) {
|
|
573
|
+
let u = U(o);
|
|
574
574
|
return /* @__PURE__ */ x("div", {
|
|
575
|
-
className: C("hds-field",
|
|
575
|
+
className: C("hds-field", s),
|
|
576
576
|
children: [
|
|
577
577
|
/* @__PURE__ */ b("label", {
|
|
578
|
-
className: "hds-label",
|
|
579
|
-
htmlFor:
|
|
578
|
+
className: C("hds-label", a && "hds-visually-hidden"),
|
|
579
|
+
htmlFor: u.id,
|
|
580
580
|
children: e
|
|
581
581
|
}),
|
|
582
582
|
/* @__PURE__ */ x("div", {
|
|
583
583
|
className: "hds-select-wrap",
|
|
584
584
|
children: [/* @__PURE__ */ x("select", {
|
|
585
|
-
...
|
|
586
|
-
ref:
|
|
587
|
-
id:
|
|
585
|
+
...c,
|
|
586
|
+
ref: l,
|
|
587
|
+
id: u.id,
|
|
588
588
|
"aria-invalid": i ? !0 : void 0,
|
|
589
|
-
"aria-describedby":
|
|
589
|
+
"aria-describedby": W({
|
|
590
590
|
hint: r,
|
|
591
591
|
error: i,
|
|
592
|
-
"aria-describedby":
|
|
593
|
-
},
|
|
592
|
+
"aria-describedby": c["aria-describedby"]
|
|
593
|
+
}, u),
|
|
594
594
|
className: "hds-select",
|
|
595
595
|
children: [n ? /* @__PURE__ */ b("option", {
|
|
596
596
|
value: "",
|
|
@@ -603,33 +603,33 @@ var te = l(function({ label: e, hint: t, error: n, numeric: r = !1, id: i, class
|
|
|
603
603
|
}, e.value))]
|
|
604
604
|
}), /* @__PURE__ */ b(D, { name: "chevron-down" })]
|
|
605
605
|
}),
|
|
606
|
-
/* @__PURE__ */ b(
|
|
606
|
+
/* @__PURE__ */ b(re, {
|
|
607
607
|
hint: r,
|
|
608
608
|
error: i,
|
|
609
|
-
ids:
|
|
609
|
+
ids: u
|
|
610
610
|
})
|
|
611
611
|
]
|
|
612
612
|
});
|
|
613
613
|
});
|
|
614
614
|
//#endregion
|
|
615
615
|
//#region src/components/DateInput/dates.ts
|
|
616
|
-
function
|
|
616
|
+
function K(e) {
|
|
617
617
|
let t = (e) => String(e).padStart(2, "0");
|
|
618
618
|
return `${e.getFullYear()}-${t(e.getMonth() + 1)}-${t(e.getDate())}`;
|
|
619
619
|
}
|
|
620
|
-
function
|
|
620
|
+
function q(e) {
|
|
621
621
|
let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e ?? "");
|
|
622
622
|
if (!t) return null;
|
|
623
623
|
let n = new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3]));
|
|
624
|
-
return
|
|
624
|
+
return K(n) === e ? n : null;
|
|
625
625
|
}
|
|
626
|
-
function
|
|
627
|
-
let t =
|
|
626
|
+
function J(e) {
|
|
627
|
+
let t = q(e);
|
|
628
628
|
if (!t) return "";
|
|
629
629
|
let n = (e) => String(e).padStart(2, "0");
|
|
630
630
|
return `${n(t.getDate())}/${n(t.getMonth() + 1)}/${t.getFullYear()}`;
|
|
631
631
|
}
|
|
632
|
-
function
|
|
632
|
+
function ae(e) {
|
|
633
633
|
let t = e.trim(), n = /^\d{8}$/.test(t) ? [
|
|
634
634
|
t.slice(0, 2),
|
|
635
635
|
t.slice(2, 4),
|
|
@@ -637,98 +637,98 @@ function ie(e) {
|
|
|
637
637
|
] : /^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(t)?.slice(1);
|
|
638
638
|
if (!n) return null;
|
|
639
639
|
let [r, i, a] = n.map(Number), o = new Date(a, i - 1, r);
|
|
640
|
-
return o.getFullYear() === a && o.getMonth() === i - 1 && o.getDate() === r ?
|
|
640
|
+
return o.getFullYear() === a && o.getMonth() === i - 1 && o.getDate() === r ? K(o) : null;
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function Y(e, t) {
|
|
643
643
|
return new Date(e.getFullYear(), e.getMonth(), e.getDate() + t);
|
|
644
644
|
}
|
|
645
|
-
function
|
|
645
|
+
function X(e, t) {
|
|
646
646
|
let n = new Date(e.getFullYear(), e.getMonth() + t, 1), r = new Date(n.getFullYear(), n.getMonth() + 1, 0).getDate();
|
|
647
647
|
return new Date(n.getFullYear(), n.getMonth(), Math.min(e.getDate(), r));
|
|
648
648
|
}
|
|
649
649
|
function oe(e, t) {
|
|
650
|
-
let n = new Date(e.getFullYear(), e.getMonth(), 1), r =
|
|
651
|
-
return Array.from({ length: 6 }, (e, t) => Array.from({ length: 7 }, (e, n) =>
|
|
650
|
+
let n = new Date(e.getFullYear(), e.getMonth(), 1), r = Y(n, -((n.getDay() - t + 7) % 7));
|
|
651
|
+
return Array.from({ length: 6 }, (e, t) => Array.from({ length: 7 }, (e, n) => Y(r, t * 7 + n)));
|
|
652
652
|
}
|
|
653
653
|
function se(e, t, n) {
|
|
654
654
|
return (!t || e >= t) && (!n || e <= n);
|
|
655
655
|
}
|
|
656
656
|
//#endregion
|
|
657
657
|
//#region src/components/DateInput/DateInput.tsx
|
|
658
|
-
var ce = () =>
|
|
659
|
-
function le({ label: e, value: t, defaultValue: n = "", onChange: r, min: i, max: a, hint: o, error: s, locale: c = "pt-BR", weekStartsOn: l = 0, calendarLabel: u = "Abrir calendário", previousMonthLabel: d = "Mês anterior", nextMonthLabel: p = "Próximo mês",
|
|
660
|
-
let j =
|
|
661
|
-
|
|
662
|
-
function
|
|
658
|
+
var ce = () => K(/* @__PURE__ */ new Date());
|
|
659
|
+
function le({ label: e, value: t, defaultValue: n = "", onChange: r, min: i, max: a, hint: o, error: s, locale: c = "pt-BR", weekStartsOn: l = 0, calendarLabel: u = "Abrir calendário", previousMonthLabel: d = "Mês anterior", nextMonthLabel: p = "Próximo mês", hideLabel: h = !1, name: v, id: y, disabled: T, required: E, placeholder: ee = "dd/mm/aaaa", className: k, ...A }) {
|
|
660
|
+
let j = U(y), [M, N] = _(n), P = t === void 0 ? M : t, [F, I] = _(() => J(P)), [L, R] = _(!1), [z, B] = _(() => q(P) ?? /* @__PURE__ */ new Date()), V = g(null), ne = g(null), H = g(null), G = g(!1), [ie, le] = _(P);
|
|
661
|
+
ie !== P && (le(P), I(J(P)));
|
|
662
|
+
function Z(e) {
|
|
663
663
|
t === void 0 && N(e), e !== P && r?.(e);
|
|
664
664
|
}
|
|
665
|
-
function
|
|
665
|
+
function ue(e) {
|
|
666
666
|
if (I(e), e.trim() === "") {
|
|
667
|
-
|
|
667
|
+
Z("");
|
|
668
668
|
return;
|
|
669
669
|
}
|
|
670
|
-
let t =
|
|
671
|
-
t && se(t, i, a) &&
|
|
672
|
-
}
|
|
673
|
-
function ue() {
|
|
674
|
-
B(Y(P) ?? Y(ce()) ?? /* @__PURE__ */ new Date()), W.current = !0, R(!0);
|
|
670
|
+
let t = ae(e);
|
|
671
|
+
t && se(t, i, a) && Z(t);
|
|
675
672
|
}
|
|
676
|
-
function de(
|
|
677
|
-
|
|
673
|
+
function de() {
|
|
674
|
+
B(q(P) ?? q(ce()) ?? /* @__PURE__ */ new Date()), G.current = !0, R(!0);
|
|
678
675
|
}
|
|
679
676
|
function fe(e) {
|
|
680
|
-
|
|
681
|
-
|
|
677
|
+
R(!1), e && ne.current?.focus();
|
|
678
|
+
}
|
|
679
|
+
function pe(e) {
|
|
680
|
+
let t = K(e);
|
|
681
|
+
se(t, i, a) && (Z(t), I(J(t)), fe(!0));
|
|
682
682
|
}
|
|
683
683
|
m(() => {
|
|
684
|
-
if (!L || !V.current || !
|
|
684
|
+
if (!L || !V.current || !H.current) return;
|
|
685
685
|
let e = () => {
|
|
686
|
-
V.current &&
|
|
686
|
+
V.current && H.current && te(V.current, H.current, "start");
|
|
687
687
|
};
|
|
688
688
|
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
689
689
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
690
690
|
};
|
|
691
691
|
}, [L]), f(() => {
|
|
692
|
-
L &&
|
|
692
|
+
L && G.current && (G.current = !1, H.current?.querySelector("[tabindex=\"0\"]")?.focus());
|
|
693
693
|
}), f(() => {
|
|
694
694
|
if (!L) return;
|
|
695
695
|
function e(e) {
|
|
696
696
|
let t = e.target;
|
|
697
|
-
V.current?.contains(t) ||
|
|
697
|
+
V.current?.contains(t) || H.current?.contains(t) || R(!1);
|
|
698
698
|
}
|
|
699
699
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
700
700
|
}, [L]);
|
|
701
|
-
function pe(e) {
|
|
702
|
-
W.current = !0, B(e);
|
|
703
|
-
}
|
|
704
701
|
function me(e) {
|
|
702
|
+
G.current = !0, B(e);
|
|
703
|
+
}
|
|
704
|
+
function he(e) {
|
|
705
705
|
let t = {
|
|
706
|
-
ArrowLeft: () =>
|
|
707
|
-
ArrowRight: () =>
|
|
708
|
-
ArrowUp: () =>
|
|
709
|
-
ArrowDown: () =>
|
|
710
|
-
Home: () =>
|
|
711
|
-
End: () =>
|
|
712
|
-
PageUp: () =>
|
|
713
|
-
PageDown: () =>
|
|
706
|
+
ArrowLeft: () => Y(z, -1),
|
|
707
|
+
ArrowRight: () => Y(z, 1),
|
|
708
|
+
ArrowUp: () => Y(z, -7),
|
|
709
|
+
ArrowDown: () => Y(z, 7),
|
|
710
|
+
Home: () => Y(z, -((z.getDay() - l + 7) % 7)),
|
|
711
|
+
End: () => Y(z, 6 - (z.getDay() - l + 7) % 7),
|
|
712
|
+
PageUp: () => X(z, e.shiftKey ? -12 : -1),
|
|
713
|
+
PageDown: () => X(z, e.shiftKey ? 12 : 1)
|
|
714
714
|
}[e.key];
|
|
715
|
-
t && (e.preventDefault(),
|
|
715
|
+
t && (e.preventDefault(), me(t()));
|
|
716
716
|
}
|
|
717
|
-
function
|
|
718
|
-
(e.key === "Escape" || e.key === "Tab") && (e.preventDefault(),
|
|
717
|
+
function ge(e) {
|
|
718
|
+
(e.key === "Escape" || e.key === "Tab") && (e.preventDefault(), fe(!0));
|
|
719
719
|
}
|
|
720
|
-
let
|
|
720
|
+
let _e = new Intl.DateTimeFormat(c, {
|
|
721
721
|
month: "long",
|
|
722
722
|
year: "numeric"
|
|
723
|
-
}).format(z),
|
|
723
|
+
}).format(z), ve = _e.charAt(0).toLocaleUpperCase(c) + _e.slice(1), ye = new Intl.DateTimeFormat(c, { dateStyle: "full" }), be = oe(z, l)[0].map((e) => ({
|
|
724
724
|
short: new Intl.DateTimeFormat(c, { weekday: "narrow" }).format(e),
|
|
725
725
|
long: new Intl.DateTimeFormat(c, { weekday: "long" }).format(e)
|
|
726
|
-
})),
|
|
726
|
+
})), Q = K(z), xe = ce(), $ = `${j.id}-calendar-title`;
|
|
727
727
|
return /* @__PURE__ */ x("div", {
|
|
728
728
|
className: C("hds-field", k),
|
|
729
729
|
children: [
|
|
730
730
|
/* @__PURE__ */ b("label", {
|
|
731
|
-
className: "hds-label",
|
|
731
|
+
className: C("hds-label", h && "hds-visually-hidden"),
|
|
732
732
|
htmlFor: j.id,
|
|
733
733
|
children: e
|
|
734
734
|
}),
|
|
@@ -742,24 +742,24 @@ function le({ label: e, value: t, defaultValue: n = "", onChange: r, min: i, max
|
|
|
742
742
|
type: "text",
|
|
743
743
|
inputMode: "numeric",
|
|
744
744
|
autoComplete: "off",
|
|
745
|
-
placeholder:
|
|
745
|
+
placeholder: ee,
|
|
746
746
|
value: F,
|
|
747
|
-
disabled:
|
|
748
|
-
required:
|
|
747
|
+
disabled: T,
|
|
748
|
+
required: E,
|
|
749
749
|
"aria-invalid": s ? !0 : void 0,
|
|
750
|
-
"aria-describedby":
|
|
750
|
+
"aria-describedby": W({
|
|
751
751
|
hint: o,
|
|
752
752
|
error: s,
|
|
753
753
|
"aria-describedby": A["aria-describedby"]
|
|
754
754
|
}, j),
|
|
755
755
|
className: "hds-input hds-input--numeric hds-date-input",
|
|
756
|
-
onChange: (e) =>
|
|
756
|
+
onChange: (e) => ue(e.target.value),
|
|
757
757
|
onBlur: (e) => {
|
|
758
|
-
A.onBlur?.(e), F.trim() !== "" &&
|
|
758
|
+
A.onBlur?.(e), F.trim() !== "" && ae(F) !== P && I(J(P));
|
|
759
759
|
}
|
|
760
760
|
}),
|
|
761
761
|
/* @__PURE__ */ b(O, {
|
|
762
|
-
ref:
|
|
762
|
+
ref: ne,
|
|
763
763
|
variant: "ghost",
|
|
764
764
|
size: "sm",
|
|
765
765
|
iconOnly: !0,
|
|
@@ -767,29 +767,29 @@ function le({ label: e, value: t, defaultValue: n = "", onChange: r, min: i, max
|
|
|
767
767
|
"aria-label": u,
|
|
768
768
|
"aria-haspopup": "dialog",
|
|
769
769
|
"aria-expanded": L,
|
|
770
|
-
disabled:
|
|
770
|
+
disabled: T,
|
|
771
771
|
className: "hds-date-button",
|
|
772
|
-
onClick: () => L ?
|
|
772
|
+
onClick: () => L ? fe(!1) : de()
|
|
773
773
|
}),
|
|
774
|
-
|
|
774
|
+
v ? /* @__PURE__ */ b("input", {
|
|
775
775
|
type: "hidden",
|
|
776
|
-
name:
|
|
776
|
+
name: v,
|
|
777
777
|
value: P
|
|
778
778
|
}) : null
|
|
779
779
|
]
|
|
780
780
|
}),
|
|
781
|
-
/* @__PURE__ */ b(
|
|
781
|
+
/* @__PURE__ */ b(re, {
|
|
782
782
|
hint: o,
|
|
783
783
|
error: s,
|
|
784
784
|
ids: j
|
|
785
785
|
}),
|
|
786
786
|
L ? S(/* @__PURE__ */ x(w, {
|
|
787
|
-
ref:
|
|
787
|
+
ref: H,
|
|
788
788
|
role: "dialog",
|
|
789
789
|
tone: "thick",
|
|
790
790
|
"aria-labelledby": $,
|
|
791
791
|
className: "hds-date-panel",
|
|
792
|
-
onKeyDown:
|
|
792
|
+
onKeyDown: ge,
|
|
793
793
|
children: [/* @__PURE__ */ x("div", {
|
|
794
794
|
className: "hds-date-header",
|
|
795
795
|
children: [
|
|
@@ -799,13 +799,13 @@ function le({ label: e, value: t, defaultValue: n = "", onChange: r, min: i, max
|
|
|
799
799
|
iconOnly: !0,
|
|
800
800
|
icon: /* @__PURE__ */ b(D, { name: "chevron-left" }),
|
|
801
801
|
"aria-label": d,
|
|
802
|
-
onClick: () => B(
|
|
802
|
+
onClick: () => B(X(z, -1))
|
|
803
803
|
}),
|
|
804
804
|
/* @__PURE__ */ b("h2", {
|
|
805
805
|
id: $,
|
|
806
806
|
className: "hds-date-title",
|
|
807
807
|
"aria-live": "polite",
|
|
808
|
-
children:
|
|
808
|
+
children: ve
|
|
809
809
|
}),
|
|
810
810
|
/* @__PURE__ */ b(O, {
|
|
811
811
|
variant: "ghost",
|
|
@@ -813,35 +813,35 @@ function le({ label: e, value: t, defaultValue: n = "", onChange: r, min: i, max
|
|
|
813
813
|
iconOnly: !0,
|
|
814
814
|
icon: /* @__PURE__ */ b(D, { name: "chevron-right" }),
|
|
815
815
|
"aria-label": p,
|
|
816
|
-
onClick: () => B(
|
|
816
|
+
onClick: () => B(X(z, 1))
|
|
817
817
|
})
|
|
818
818
|
]
|
|
819
819
|
}), /* @__PURE__ */ x("table", {
|
|
820
820
|
role: "grid",
|
|
821
821
|
"aria-labelledby": $,
|
|
822
822
|
className: "hds-date-grid",
|
|
823
|
-
onKeyDown:
|
|
824
|
-
children: [/* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { children:
|
|
823
|
+
onKeyDown: he,
|
|
824
|
+
children: [/* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { children: be.map((e) => /* @__PURE__ */ b("th", {
|
|
825
825
|
scope: "col",
|
|
826
826
|
abbr: e.long,
|
|
827
827
|
children: e.short
|
|
828
828
|
}, e.long)) }) }), /* @__PURE__ */ b("tbody", { children: oe(z, l).map((e) => /* @__PURE__ */ b("tr", { children: e.map((e) => {
|
|
829
|
-
let t =
|
|
829
|
+
let t = K(e), n = se(t, i, a);
|
|
830
830
|
return /* @__PURE__ */ b("td", {
|
|
831
831
|
role: "gridcell",
|
|
832
832
|
"aria-selected": t === P,
|
|
833
833
|
children: /* @__PURE__ */ b("button", {
|
|
834
834
|
type: "button",
|
|
835
|
-
tabIndex: t ===
|
|
836
|
-
"aria-label":
|
|
837
|
-
"aria-current": t ===
|
|
835
|
+
tabIndex: t === Q ? 0 : -1,
|
|
836
|
+
"aria-label": ye.format(e),
|
|
837
|
+
"aria-current": t === xe ? "date" : void 0,
|
|
838
838
|
"aria-disabled": !n || void 0,
|
|
839
839
|
className: C("hds-date-day", e.getMonth() !== z.getMonth() && "hds-date-day--outside", t === P && "hds-date-day--selected"),
|
|
840
|
-
onClick: () =>
|
|
840
|
+
onClick: () => pe(e),
|
|
841
841
|
children: e.getDate()
|
|
842
842
|
})
|
|
843
843
|
}, t);
|
|
844
|
-
}) },
|
|
844
|
+
}) }, K(e[0]))) })]
|
|
845
845
|
})]
|
|
846
846
|
}), document.body) : null
|
|
847
847
|
]
|
|
@@ -872,10 +872,10 @@ function de({ text: e, query: t, locale: n }) {
|
|
|
872
872
|
e.slice(i)
|
|
873
873
|
] });
|
|
874
874
|
}
|
|
875
|
-
function fe({ label: e, value: t, defaultValue: n = "", onChange: r, suggestions: i, maxSuggestions: a = 8, hint: o, error: s, locale: c = "pt-BR",
|
|
876
|
-
let
|
|
875
|
+
function fe({ label: e, value: t, defaultValue: n = "", onChange: r, suggestions: i, maxSuggestions: a = 8, hint: o, error: s, locale: c = "pt-BR", hideLabel: l = !1, id: u, className: d, disabled: p, ...h }) {
|
|
876
|
+
let v = U(u), y = `${v.id}-list`, T = `${v.id}-label`, [E, D] = _(n), O = t === void 0 ? E : t, [ee, k] = _(!1), [A, j] = _(-1), M = g(null), N = g(null), P = ue(i, O, c, a), F = ee && P.length > 0;
|
|
877
877
|
function I(e) {
|
|
878
|
-
t === void 0 &&
|
|
878
|
+
t === void 0 && D(e), r?.(e);
|
|
879
879
|
}
|
|
880
880
|
function L(e) {
|
|
881
881
|
I(e), k(!1), j(-1);
|
|
@@ -883,20 +883,20 @@ function fe({ label: e, value: t, defaultValue: n = "", onChange: r, suggestions
|
|
|
883
883
|
m(() => {
|
|
884
884
|
if (!F || !M.current || !N.current) return;
|
|
885
885
|
let e = () => {
|
|
886
|
-
M.current && N.current && (N.current.style.width = `${M.current.offsetWidth}px`,
|
|
886
|
+
M.current && N.current && (N.current.style.width = `${M.current.offsetWidth}px`, te(M.current, N.current, "start"));
|
|
887
887
|
};
|
|
888
888
|
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
889
889
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
890
890
|
};
|
|
891
891
|
}, [F, P.length]), f(() => {
|
|
892
|
-
!F || A < 0 || document.getElementById(`${
|
|
892
|
+
!F || A < 0 || document.getElementById(`${y}-${A}`)?.scrollIntoView?.({ block: "nearest" });
|
|
893
893
|
}, [
|
|
894
894
|
F,
|
|
895
895
|
A,
|
|
896
|
-
|
|
896
|
+
y
|
|
897
897
|
]);
|
|
898
898
|
function R(e) {
|
|
899
|
-
if (
|
|
899
|
+
if (h.onKeyDown?.(e), e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
900
900
|
if (e.preventDefault(), !F) {
|
|
901
901
|
k(!0), j(e.key === "ArrowDown" ? 0 : P.length - 1);
|
|
902
902
|
return;
|
|
@@ -905,56 +905,56 @@ function fe({ label: e, value: t, defaultValue: n = "", onChange: r, suggestions
|
|
|
905
905
|
} else e.key === "Enter" && F && A >= 0 ? (e.preventDefault(), L(P[A])) : e.key === "Escape" && F ? (e.preventDefault(), k(!1), j(-1)) : e.key === "Tab" && k(!1);
|
|
906
906
|
}
|
|
907
907
|
return /* @__PURE__ */ x("div", {
|
|
908
|
-
className: C("hds-field",
|
|
908
|
+
className: C("hds-field", d),
|
|
909
909
|
children: [
|
|
910
910
|
/* @__PURE__ */ b("label", {
|
|
911
|
-
id:
|
|
912
|
-
className: "hds-label",
|
|
913
|
-
htmlFor:
|
|
911
|
+
id: T,
|
|
912
|
+
className: C("hds-label", l && "hds-visually-hidden"),
|
|
913
|
+
htmlFor: v.id,
|
|
914
914
|
children: e
|
|
915
915
|
}),
|
|
916
916
|
/* @__PURE__ */ b("input", {
|
|
917
917
|
spellCheck: !1,
|
|
918
|
-
...
|
|
918
|
+
...h,
|
|
919
919
|
ref: M,
|
|
920
|
-
id:
|
|
920
|
+
id: v.id,
|
|
921
921
|
type: "text",
|
|
922
922
|
role: "combobox",
|
|
923
923
|
autoComplete: "off",
|
|
924
924
|
"aria-autocomplete": "list",
|
|
925
925
|
"aria-expanded": F,
|
|
926
|
-
"aria-controls": F ?
|
|
927
|
-
"aria-activedescendant": F && A >= 0 ? `${
|
|
926
|
+
"aria-controls": F ? y : void 0,
|
|
927
|
+
"aria-activedescendant": F && A >= 0 ? `${y}-${A}` : void 0,
|
|
928
928
|
"aria-invalid": s ? !0 : void 0,
|
|
929
|
-
"aria-describedby":
|
|
929
|
+
"aria-describedby": W({
|
|
930
930
|
hint: o,
|
|
931
931
|
error: s,
|
|
932
|
-
"aria-describedby":
|
|
933
|
-
},
|
|
932
|
+
"aria-describedby": h["aria-describedby"]
|
|
933
|
+
}, v),
|
|
934
934
|
className: "hds-input",
|
|
935
|
-
disabled:
|
|
936
|
-
value:
|
|
935
|
+
disabled: p,
|
|
936
|
+
value: O,
|
|
937
937
|
onChange: (e) => {
|
|
938
938
|
I(e.target.value), k(!0), j(-1);
|
|
939
939
|
},
|
|
940
940
|
onKeyDown: R,
|
|
941
941
|
onBlur: (e) => {
|
|
942
|
-
|
|
942
|
+
h.onBlur?.(e), k(!1), j(-1);
|
|
943
943
|
}
|
|
944
944
|
}),
|
|
945
|
-
/* @__PURE__ */ b(
|
|
945
|
+
/* @__PURE__ */ b(re, {
|
|
946
946
|
hint: o,
|
|
947
947
|
error: s,
|
|
948
|
-
ids:
|
|
948
|
+
ids: v
|
|
949
949
|
}),
|
|
950
950
|
F ? S(/* @__PURE__ */ b(w, {
|
|
951
951
|
ref: N,
|
|
952
|
-
id:
|
|
952
|
+
id: y,
|
|
953
953
|
role: "listbox",
|
|
954
|
-
"aria-labelledby":
|
|
954
|
+
"aria-labelledby": T,
|
|
955
955
|
className: "hds-typeahead-panel",
|
|
956
956
|
children: P.map((e, t) => /* @__PURE__ */ b("div", {
|
|
957
|
-
id: `${
|
|
957
|
+
id: `${y}-${t}`,
|
|
958
958
|
role: "option",
|
|
959
959
|
"aria-selected": t === A,
|
|
960
960
|
className: "hds-typeahead-option",
|
|
@@ -963,7 +963,7 @@ function fe({ label: e, value: t, defaultValue: n = "", onChange: r, suggestions
|
|
|
963
963
|
onMouseMove: () => j(t),
|
|
964
964
|
children: /* @__PURE__ */ b(de, {
|
|
965
965
|
text: e,
|
|
966
|
-
query:
|
|
966
|
+
query: O,
|
|
967
967
|
locale: c
|
|
968
968
|
})
|
|
969
969
|
}, e))
|
|
@@ -974,7 +974,7 @@ function fe({ label: e, value: t, defaultValue: n = "", onChange: r, suggestions
|
|
|
974
974
|
//#endregion
|
|
975
975
|
//#region src/components/Checkbox/Checkbox.tsx
|
|
976
976
|
var pe = l(function({ label: e, hint: t, id: n, className: r, ...i }, a) {
|
|
977
|
-
let o =
|
|
977
|
+
let o = U(n);
|
|
978
978
|
return /* @__PURE__ */ x("label", {
|
|
979
979
|
className: C("hds-checkbox", r),
|
|
980
980
|
htmlFor: o.id,
|
|
@@ -1094,15 +1094,15 @@ var ye = !1, be = {
|
|
|
1094
1094
|
theme: "dark",
|
|
1095
1095
|
transparency: "full"
|
|
1096
1096
|
}, Q = be;
|
|
1097
|
-
function
|
|
1097
|
+
function xe() {
|
|
1098
1098
|
let e = a();
|
|
1099
1099
|
return (e.theme !== Q.theme || e.transparency !== Q.transparency) && (Q = e), Q;
|
|
1100
1100
|
}
|
|
1101
|
-
function
|
|
1101
|
+
function $() {
|
|
1102
1102
|
f(() => {
|
|
1103
1103
|
ye || (ye = !0, document.documentElement.hasAttribute("data-theme") || r());
|
|
1104
1104
|
}, []);
|
|
1105
|
-
let e = v(o,
|
|
1105
|
+
let e = v(o, xe, () => be);
|
|
1106
1106
|
return {
|
|
1107
1107
|
...e,
|
|
1108
1108
|
setTheme: t,
|
|
@@ -1114,7 +1114,7 @@ function xe() {
|
|
|
1114
1114
|
//#endregion
|
|
1115
1115
|
//#region src/components/AppearanceToggles/AppearanceToggles.tsx
|
|
1116
1116
|
function Se({ lightLabel: e = "Mudar para o tema claro", darkLabel: t = "Mudar para o tema escuro", variant: n = "ghost", ...r }) {
|
|
1117
|
-
let { theme: i, toggleTheme: a } =
|
|
1117
|
+
let { theme: i, toggleTheme: a } = $(), o = i === "dark" ? e : t;
|
|
1118
1118
|
return /* @__PURE__ */ b(O, {
|
|
1119
1119
|
...r,
|
|
1120
1120
|
variant: n,
|
|
@@ -1126,7 +1126,7 @@ function Se({ lightLabel: e = "Mudar para o tema claro", darkLabel: t = "Mudar p
|
|
|
1126
1126
|
});
|
|
1127
1127
|
}
|
|
1128
1128
|
function Ce({ label: e = "Reduzir transparência", variant: t = "ghost", ...n }) {
|
|
1129
|
-
let { transparency: r, toggleTransparency: i } =
|
|
1129
|
+
let { transparency: r, toggleTransparency: i } = $();
|
|
1130
1130
|
return /* @__PURE__ */ b(O, {
|
|
1131
1131
|
...n,
|
|
1132
1132
|
variant: t,
|
|
@@ -1217,6 +1217,6 @@ function ke({ src: e, alt: t, size: n = 96, className: r }) {
|
|
|
1217
1217
|
});
|
|
1218
1218
|
}
|
|
1219
1219
|
//#endregion
|
|
1220
|
-
export { s as APPEARANCE_STORAGE_KEYS, ge as Badge, O as Button, me as Card, pe as Checkbox, we as Container, le as DateInput,
|
|
1220
|
+
export { s as APPEARANCE_STORAGE_KEYS, ge as Badge, O as Button, me as Card, pe as Checkbox, we as Container, le as DateInput, L as Dialog, F as FloatingButton, w as GlassPanel, ke as GlowAvatar, G as Input, Oe as Loading, P as Menu, A as NavBar, De as ScrollArea, Te as SectionTitle, N as SegmentedControl, ie as Select, Ee as Separator, j as Sidebar, ve as Table, Se as ThemeToggle, B as Toast, ne as ToastProvider, Ce as TransparencyToggle, fe as Typeahead, r as applyStoredAppearance, e as enableGlassRefraction, a as getAppearance, n as readStoredAppearance, t as setTheme, i as setTransparency, o as subscribeToAppearance, $ as useAppearance, H as useToast };
|
|
1221
1221
|
|
|
1222
1222
|
//# sourceMappingURL=index.js.map
|