@hemerson/design-system 0.5.0 → 0.7.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/components/Menu/Menu.d.ts +6 -1
- package/dist/components/Typeahead/Typeahead.d.ts +20 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +335 -202
- package/dist/index.js.map +1 -1
- package/dist/styles.css +53 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var w = l(function({ as: e = "div", tone: t = "regular", className: n, ...r }, i
|
|
|
19
19
|
cx: 12,
|
|
20
20
|
cy: 12,
|
|
21
21
|
r: 10
|
|
22
|
-
},
|
|
22
|
+
}, E = {
|
|
23
23
|
check: ["M20 6 9 17l-5-5"],
|
|
24
24
|
x: ["M18 6 6 18", "m6 6 12 12"],
|
|
25
25
|
"chevron-down": ["m6 9 6 6 6-6"],
|
|
@@ -74,8 +74,8 @@ var w = l(function({ as: e = "div", tone: t = "regular", className: n, ...r }, i
|
|
|
74
74
|
r: 7
|
|
75
75
|
}]
|
|
76
76
|
};
|
|
77
|
-
function
|
|
78
|
-
let n =
|
|
77
|
+
function D({ name: e, className: t }) {
|
|
78
|
+
let n = E[e];
|
|
79
79
|
return /* @__PURE__ */ b("svg", {
|
|
80
80
|
className: C("hds-icon", t),
|
|
81
81
|
viewBox: "0 0 24 24",
|
|
@@ -95,7 +95,7 @@ function E({ name: e, className: t }) {
|
|
|
95
95
|
}
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/components/Button/Button.tsx
|
|
98
|
-
var
|
|
98
|
+
var O = l(function({ variant: e = "primary", size: t = "md", icon: n, iconOnly: r = !1, loading: i = !1, disabled: a, type: o = "button", className: s, children: c, ...l }, u) {
|
|
99
99
|
return r && !l["aria-label"] && !l["aria-labelledby"] && console.warn("Button: an icon-only button needs an aria-label."), /* @__PURE__ */ x("button", {
|
|
100
100
|
...l,
|
|
101
101
|
ref: u,
|
|
@@ -103,7 +103,7 @@ var D = l(function({ variant: e = "primary", size: t = "md", icon: n, iconOnly:
|
|
|
103
103
|
disabled: a || i,
|
|
104
104
|
"aria-busy": i || void 0,
|
|
105
105
|
className: C("hds-btn", `hds-btn--${e}`, t !== "md" && `hds-btn--${t}`, r && "hds-btn--icon", e === "glass" && "hds-glass", s),
|
|
106
|
-
children: [i ? /* @__PURE__ */ b(
|
|
106
|
+
children: [i ? /* @__PURE__ */ b(D, {
|
|
107
107
|
name: "loader",
|
|
108
108
|
className: "hds-spin"
|
|
109
109
|
}) : n, r ? null : c]
|
|
@@ -111,14 +111,14 @@ var D = 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 k({ 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 A({ 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 O({ title: e, actions: t, navLabel: n = "Principal", className: r, chil
|
|
|
140
140
|
]
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
var
|
|
143
|
+
var j = Object.assign(A, { Link: k });
|
|
144
144
|
//#endregion
|
|
145
145
|
//#region src/components/Sidebar/Sidebar.tsx
|
|
146
|
-
function
|
|
146
|
+
function M({ 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 ne({ items: e, footer: t, floating: n = !1, label: r = "Navegação", c
|
|
|
177
177
|
}
|
|
178
178
|
//#endregion
|
|
179
179
|
//#region src/components/SegmentedControl/SegmentedControl.tsx
|
|
180
|
-
var
|
|
180
|
+
var N = {
|
|
181
181
|
ArrowRight: 1,
|
|
182
182
|
ArrowDown: 1,
|
|
183
183
|
ArrowLeft: -1,
|
|
184
184
|
ArrowUp: -1
|
|
185
185
|
};
|
|
186
|
-
function
|
|
186
|
+
function P({ 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 A({ 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 = N[t.key];
|
|
200
200
|
if (!n) return;
|
|
201
201
|
t.preventDefault();
|
|
202
202
|
let r = (d + n + e.length) % e.length;
|
|
@@ -230,59 +230,68 @@ function A({ options: e, value: t, defaultValue: n, onChange: r, label: i, class
|
|
|
230
230
|
})]
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function ee(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
|
|
240
|
-
let [
|
|
241
|
-
function
|
|
242
|
-
|
|
239
|
+
function F({ label: e, icon: t, iconOnly: n = !1, items: r, align: i = "end", triggerVariant: a = "glass", header: o, className: s }) {
|
|
240
|
+
let [c, l] = _(!1), u = g(null), d = g(null), h = p(), v = () => Array.from(d.current?.querySelectorAll("[role=\"menuitem\"]") ?? []);
|
|
241
|
+
function T(e) {
|
|
242
|
+
l(!1), e && u.current?.focus();
|
|
243
243
|
}
|
|
244
244
|
m(() => {
|
|
245
|
-
if (!
|
|
245
|
+
if (!c || !u.current || !d.current) return;
|
|
246
246
|
let e = () => {
|
|
247
|
-
|
|
247
|
+
u.current && d.current && ee(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);
|
|
251
251
|
};
|
|
252
|
-
}, [
|
|
253
|
-
if (!
|
|
254
|
-
|
|
252
|
+
}, [c, i]), f(() => {
|
|
253
|
+
if (!c) return;
|
|
254
|
+
v()[0]?.focus();
|
|
255
255
|
function e(e) {
|
|
256
256
|
let t = e.target;
|
|
257
|
-
|
|
257
|
+
u.current?.contains(t) || d.current?.contains(t) || l(!1);
|
|
258
258
|
}
|
|
259
259
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
260
|
-
}, [
|
|
261
|
-
function
|
|
262
|
-
let t =
|
|
263
|
-
e.key === "Escape" || e.key === "Tab" ? (e.preventDefault(),
|
|
260
|
+
}, [c]);
|
|
261
|
+
function E(e) {
|
|
262
|
+
let t = v(), n = t.indexOf(document.activeElement);
|
|
263
|
+
e.key === "Escape" || e.key === "Tab" ? (e.preventDefault(), T(!0)) : e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), t[(n + (e.key === "ArrowDown" ? 1 : -1) + t.length) % t.length]?.focus()) : (e.key === "Home" || e.key === "End") && (e.preventDefault(), (e.key === "Home" ? t[0] : t[t.length - 1])?.focus());
|
|
264
264
|
}
|
|
265
265
|
return /* @__PURE__ */ x("div", {
|
|
266
|
-
className: C("hds-menu",
|
|
267
|
-
children: [/* @__PURE__ */ b(
|
|
268
|
-
ref:
|
|
266
|
+
className: C("hds-menu", s),
|
|
267
|
+
children: [/* @__PURE__ */ b(O, {
|
|
268
|
+
ref: u,
|
|
269
269
|
variant: a,
|
|
270
270
|
icon: t,
|
|
271
271
|
iconOnly: n,
|
|
272
272
|
"aria-label": n ? e : void 0,
|
|
273
273
|
"aria-haspopup": "menu",
|
|
274
|
-
"aria-expanded":
|
|
275
|
-
"aria-controls":
|
|
276
|
-
onClick: () =>
|
|
274
|
+
"aria-expanded": c,
|
|
275
|
+
"aria-controls": c ? h : void 0,
|
|
276
|
+
onClick: () => l(!c),
|
|
277
277
|
children: e
|
|
278
|
-
}),
|
|
279
|
-
ref:
|
|
280
|
-
id:
|
|
278
|
+
}), c ? S(/* @__PURE__ */ x(w, {
|
|
279
|
+
ref: d,
|
|
280
|
+
id: h,
|
|
281
281
|
role: "menu",
|
|
282
282
|
"aria-label": e,
|
|
283
|
+
"aria-describedby": o ? `${h}-header` : void 0,
|
|
283
284
|
className: "hds-menu-panel",
|
|
284
|
-
onKeyDown:
|
|
285
|
-
children:
|
|
285
|
+
onKeyDown: E,
|
|
286
|
+
children: [o ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("div", {
|
|
287
|
+
id: `${h}-header`,
|
|
288
|
+
role: "none",
|
|
289
|
+
className: "hds-menu-header",
|
|
290
|
+
children: o
|
|
291
|
+
}), /* @__PURE__ */ b("div", {
|
|
292
|
+
role: "separator",
|
|
293
|
+
className: "hds-menu-separator"
|
|
294
|
+
})] }) : null, r.map((e, t) => e.separator ? /* @__PURE__ */ b("div", {
|
|
286
295
|
role: "separator",
|
|
287
296
|
className: "hds-menu-separator"
|
|
288
297
|
}, `separator-${t}`) : /* @__PURE__ */ x("button", {
|
|
@@ -291,16 +300,16 @@ function j({ label: e, icon: t, iconOnly: n = !1, items: r, align: i = "end", tr
|
|
|
291
300
|
tabIndex: -1,
|
|
292
301
|
className: C("hds-menu-item", e.danger && "hds-menu-item--danger"),
|
|
293
302
|
onClick: () => {
|
|
294
|
-
|
|
303
|
+
T(!0), e.onSelect?.();
|
|
295
304
|
},
|
|
296
305
|
children: [e.icon, e.label]
|
|
297
|
-
}, e.label))
|
|
306
|
+
}, e.label))]
|
|
298
307
|
}), document.body) : null]
|
|
299
308
|
});
|
|
300
309
|
}
|
|
301
310
|
//#endregion
|
|
302
311
|
//#region src/components/FloatingButton/FloatingButton.tsx
|
|
303
|
-
var
|
|
312
|
+
var I = l(function({ label: e, position: t = "bottom-right", type: n = "button", className: r, ...i }, a) {
|
|
304
313
|
return /* @__PURE__ */ b("button", {
|
|
305
314
|
...i,
|
|
306
315
|
ref: a,
|
|
@@ -309,8 +318,8 @@ var M = l(function({ label: e, position: t = "bottom-right", type: n = "button",
|
|
|
309
318
|
title: e,
|
|
310
319
|
className: C("hds-glass", "hds-fab", `hds-fab--${t}`, r)
|
|
311
320
|
});
|
|
312
|
-
}),
|
|
313
|
-
function
|
|
321
|
+
}), L = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
322
|
+
function R({ open: e, onClose: t, title: n, description: r, children: i, footer: a, closeLabel: o = "Fechar", initialFocus: s = "first", size: c = "md", className: l }) {
|
|
314
323
|
let u = g(null), d = p(), m = p(), h = g(t);
|
|
315
324
|
return f(() => {
|
|
316
325
|
h.current = t;
|
|
@@ -318,7 +327,7 @@ function P({ open: e, onClose: t, title: n, description: r, children: i, footer:
|
|
|
318
327
|
if (!e) return;
|
|
319
328
|
let t = document.activeElement, n = document.body.style.overflow;
|
|
320
329
|
document.body.style.overflow = "hidden";
|
|
321
|
-
let r = u.current?.querySelectorAll(
|
|
330
|
+
let r = u.current?.querySelectorAll(L) ?? [];
|
|
322
331
|
(s === "panel" || r.length === 0 ? u.current : r[0])?.focus();
|
|
323
332
|
function i(e) {
|
|
324
333
|
if (e.key === "Escape") {
|
|
@@ -327,7 +336,7 @@ function P({ open: e, onClose: t, title: n, description: r, children: i, footer:
|
|
|
327
336
|
return;
|
|
328
337
|
}
|
|
329
338
|
if (e.key !== "Tab" || !u.current) return;
|
|
330
|
-
let t = Array.from(u.current.querySelectorAll(
|
|
339
|
+
let t = Array.from(u.current.querySelectorAll(L));
|
|
331
340
|
if (t.length === 0) return;
|
|
332
341
|
let n = t[0], r = t[t.length - 1];
|
|
333
342
|
e.shiftKey && document.activeElement === n ? (e.preventDefault(), r.focus()) : !e.shiftKey && document.activeElement === r && (e.preventDefault(), n.focus());
|
|
@@ -360,11 +369,11 @@ function P({ open: e, onClose: t, title: n, description: r, children: i, footer:
|
|
|
360
369
|
id: m,
|
|
361
370
|
className: "hds-dialog-description",
|
|
362
371
|
children: r
|
|
363
|
-
}) : null] }), /* @__PURE__ */ b(
|
|
372
|
+
}) : null] }), /* @__PURE__ */ b(O, {
|
|
364
373
|
variant: "ghost",
|
|
365
374
|
size: "sm",
|
|
366
375
|
iconOnly: !0,
|
|
367
|
-
icon: /* @__PURE__ */ b(
|
|
376
|
+
icon: /* @__PURE__ */ b(D, { name: "x" }),
|
|
368
377
|
"aria-label": o,
|
|
369
378
|
onClick: t
|
|
370
379
|
})]
|
|
@@ -380,13 +389,13 @@ function P({ open: e, onClose: t, title: n, description: r, children: i, footer:
|
|
|
380
389
|
}
|
|
381
390
|
//#endregion
|
|
382
391
|
//#region src/components/Toast/ToastView.tsx
|
|
383
|
-
var
|
|
392
|
+
var z = {
|
|
384
393
|
neutral: "info",
|
|
385
394
|
success: "circle-check",
|
|
386
395
|
warning: "triangle-alert",
|
|
387
396
|
danger: "circle-x"
|
|
388
397
|
};
|
|
389
|
-
function
|
|
398
|
+
function B({ tone: e, title: t, description: n, duration: r, onClose: i, closeLabel: a, className: o }) {
|
|
390
399
|
let [s, c] = _(!1), l = g(i);
|
|
391
400
|
return f(() => {
|
|
392
401
|
l.current = i;
|
|
@@ -402,7 +411,7 @@ function I({ tone: e, title: t, description: n, duration: r, onClose: i, closeLa
|
|
|
402
411
|
onFocus: () => c(!0),
|
|
403
412
|
onBlur: () => c(!1),
|
|
404
413
|
children: [
|
|
405
|
-
/* @__PURE__ */ b(
|
|
414
|
+
/* @__PURE__ */ b(D, { name: z[e] }),
|
|
406
415
|
/* @__PURE__ */ x("div", {
|
|
407
416
|
className: "hds-toast-body",
|
|
408
417
|
children: [/* @__PURE__ */ b("p", {
|
|
@@ -413,11 +422,11 @@ function I({ tone: e, title: t, description: n, duration: r, onClose: i, closeLa
|
|
|
413
422
|
children: n
|
|
414
423
|
}) : null]
|
|
415
424
|
}),
|
|
416
|
-
i ? /* @__PURE__ */ b(
|
|
425
|
+
i ? /* @__PURE__ */ b(O, {
|
|
417
426
|
variant: "ghost",
|
|
418
427
|
size: "sm",
|
|
419
428
|
iconOnly: !0,
|
|
420
|
-
icon: /* @__PURE__ */ b(
|
|
429
|
+
icon: /* @__PURE__ */ b(D, { name: "x" }),
|
|
421
430
|
"aria-label": a,
|
|
422
431
|
onClick: i
|
|
423
432
|
}) : null
|
|
@@ -426,10 +435,10 @@ function I({ tone: e, title: t, description: n, duration: r, onClose: i, closeLa
|
|
|
426
435
|
}
|
|
427
436
|
//#endregion
|
|
428
437
|
//#region src/components/Toast/Toast.tsx
|
|
429
|
-
function
|
|
438
|
+
function V({ open: e, onClose: t, tone: n = "neutral", title: r, description: i, duration: a = 5e3, closeLabel: o = "Fechar aviso", className: s }) {
|
|
430
439
|
return e ? S(/* @__PURE__ */ b("div", {
|
|
431
440
|
className: "hds-toast-region",
|
|
432
|
-
children: /* @__PURE__ */ b(
|
|
441
|
+
children: /* @__PURE__ */ b(B, {
|
|
433
442
|
tone: n,
|
|
434
443
|
title: r,
|
|
435
444
|
description: i,
|
|
@@ -442,8 +451,8 @@ function L({ open: e, onClose: t, tone: n = "neutral", title: r, description: i,
|
|
|
442
451
|
}
|
|
443
452
|
//#endregion
|
|
444
453
|
//#region src/components/Toast/ToastProvider.tsx
|
|
445
|
-
var
|
|
446
|
-
function
|
|
454
|
+
var H = c(null);
|
|
455
|
+
function U({ children: e, max: t = 3, closeLabel: n = "Fechar aviso" }) {
|
|
447
456
|
let [r, i] = _([]), a = g(0), o = u((e) => {
|
|
448
457
|
i((t) => t.filter((t) => t.id !== e));
|
|
449
458
|
}, []), s = u(({ title: e, description: n, tone: r = "neutral", duration: o = 5e3 }) => {
|
|
@@ -479,11 +488,11 @@ function z({ children: e, max: t = 3, closeLabel: n = "Fechar aviso" }) {
|
|
|
479
488
|
tone: "neutral"
|
|
480
489
|
})
|
|
481
490
|
}), [s, o]);
|
|
482
|
-
return /* @__PURE__ */ x(
|
|
491
|
+
return /* @__PURE__ */ x(H.Provider, {
|
|
483
492
|
value: c,
|
|
484
493
|
children: [e, r.length ? S(/* @__PURE__ */ b("div", {
|
|
485
494
|
className: "hds-toast-region",
|
|
486
|
-
children: r.map((e) => /* @__PURE__ */ b(
|
|
495
|
+
children: r.map((e) => /* @__PURE__ */ b(B, {
|
|
487
496
|
tone: e.tone,
|
|
488
497
|
title: e.title,
|
|
489
498
|
description: e.description,
|
|
@@ -494,14 +503,14 @@ function z({ children: e, max: t = 3, closeLabel: n = "Fechar aviso" }) {
|
|
|
494
503
|
}), document.body) : null]
|
|
495
504
|
});
|
|
496
505
|
}
|
|
497
|
-
function
|
|
498
|
-
let e = d(
|
|
506
|
+
function W() {
|
|
507
|
+
let e = d(H);
|
|
499
508
|
if (!e) throw Error("useToast must be used inside a ToastProvider.");
|
|
500
509
|
return e;
|
|
501
510
|
}
|
|
502
511
|
//#endregion
|
|
503
512
|
//#region src/internal/field.tsx
|
|
504
|
-
function
|
|
513
|
+
function G(e) {
|
|
505
514
|
let t = p(), n = e ?? t;
|
|
506
515
|
return {
|
|
507
516
|
id: n,
|
|
@@ -509,7 +518,7 @@ function V(e) {
|
|
|
509
518
|
error: `${n}-error`
|
|
510
519
|
};
|
|
511
520
|
}
|
|
512
|
-
function
|
|
521
|
+
function K(e, t) {
|
|
513
522
|
let n = [
|
|
514
523
|
e.hint && t.hint,
|
|
515
524
|
e.error && t.error,
|
|
@@ -517,7 +526,7 @@ function H(e, t) {
|
|
|
517
526
|
].filter(Boolean);
|
|
518
527
|
return n.length ? n.join(" ") : void 0;
|
|
519
528
|
}
|
|
520
|
-
function
|
|
529
|
+
function q({ hint: e, error: t, ids: n }) {
|
|
521
530
|
return /* @__PURE__ */ x(y, { children: [e ? /* @__PURE__ */ b("p", {
|
|
522
531
|
id: n.hint,
|
|
523
532
|
className: "hds-hint",
|
|
@@ -525,13 +534,13 @@ function ae({ hint: e, error: t, ids: n }) {
|
|
|
525
534
|
}) : null, t ? /* @__PURE__ */ x("p", {
|
|
526
535
|
id: n.error,
|
|
527
536
|
className: "hds-error",
|
|
528
|
-
children: [/* @__PURE__ */ b(
|
|
537
|
+
children: [/* @__PURE__ */ b(D, { name: "circle-x" }), t]
|
|
529
538
|
}) : null] });
|
|
530
539
|
}
|
|
531
540
|
//#endregion
|
|
532
541
|
//#region src/components/Input/Input.tsx
|
|
533
|
-
var
|
|
534
|
-
let c =
|
|
542
|
+
var te = l(function({ label: e, hint: t, error: n, numeric: r = !1, id: i, className: a, ...o }, s) {
|
|
543
|
+
let c = G(i);
|
|
535
544
|
return /* @__PURE__ */ x("div", {
|
|
536
545
|
className: C("hds-field", a),
|
|
537
546
|
children: [
|
|
@@ -546,22 +555,22 @@ var oe = l(function({ label: e, hint: t, error: n, numeric: r = !1, id: i, class
|
|
|
546
555
|
ref: s,
|
|
547
556
|
id: c.id,
|
|
548
557
|
"aria-invalid": n ? !0 : void 0,
|
|
549
|
-
"aria-describedby":
|
|
558
|
+
"aria-describedby": K({
|
|
550
559
|
hint: t,
|
|
551
560
|
error: n,
|
|
552
561
|
"aria-describedby": o["aria-describedby"]
|
|
553
562
|
}, c),
|
|
554
563
|
className: C("hds-input", r && "hds-input--numeric")
|
|
555
564
|
}),
|
|
556
|
-
/* @__PURE__ */ b(
|
|
565
|
+
/* @__PURE__ */ b(q, {
|
|
557
566
|
hint: t,
|
|
558
567
|
error: n,
|
|
559
568
|
ids: c
|
|
560
569
|
})
|
|
561
570
|
]
|
|
562
571
|
});
|
|
563
|
-
}),
|
|
564
|
-
let l =
|
|
572
|
+
}), ne = l(function({ label: e, options: t, placeholder: n, hint: r, error: i, id: a, className: o, ...s }, c) {
|
|
573
|
+
let l = G(a);
|
|
565
574
|
return /* @__PURE__ */ x("div", {
|
|
566
575
|
className: C("hds-field", o),
|
|
567
576
|
children: [
|
|
@@ -577,7 +586,7 @@ var oe = l(function({ label: e, hint: t, error: n, numeric: r = !1, id: i, class
|
|
|
577
586
|
ref: c,
|
|
578
587
|
id: l.id,
|
|
579
588
|
"aria-invalid": i ? !0 : void 0,
|
|
580
|
-
"aria-describedby":
|
|
589
|
+
"aria-describedby": K({
|
|
581
590
|
hint: r,
|
|
582
591
|
error: i,
|
|
583
592
|
"aria-describedby": s["aria-describedby"]
|
|
@@ -592,9 +601,9 @@ var oe = l(function({ label: e, hint: t, error: n, numeric: r = !1, id: i, class
|
|
|
592
601
|
disabled: e.disabled,
|
|
593
602
|
children: e.label
|
|
594
603
|
}, e.value))]
|
|
595
|
-
}), /* @__PURE__ */ b(
|
|
604
|
+
}), /* @__PURE__ */ b(D, { name: "chevron-down" })]
|
|
596
605
|
}),
|
|
597
|
-
/* @__PURE__ */ b(
|
|
606
|
+
/* @__PURE__ */ b(q, {
|
|
598
607
|
hint: r,
|
|
599
608
|
error: i,
|
|
600
609
|
ids: l
|
|
@@ -604,23 +613,23 @@ var oe = l(function({ label: e, hint: t, error: n, numeric: r = !1, id: i, class
|
|
|
604
613
|
});
|
|
605
614
|
//#endregion
|
|
606
615
|
//#region src/components/DateInput/dates.ts
|
|
607
|
-
function
|
|
616
|
+
function J(e) {
|
|
608
617
|
let t = (e) => String(e).padStart(2, "0");
|
|
609
618
|
return `${e.getFullYear()}-${t(e.getMonth() + 1)}-${t(e.getDate())}`;
|
|
610
619
|
}
|
|
611
|
-
function
|
|
620
|
+
function Y(e) {
|
|
612
621
|
let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e ?? "");
|
|
613
622
|
if (!t) return null;
|
|
614
623
|
let n = new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3]));
|
|
615
|
-
return
|
|
624
|
+
return J(n) === e ? n : null;
|
|
616
625
|
}
|
|
617
|
-
function
|
|
618
|
-
let t =
|
|
626
|
+
function re(e) {
|
|
627
|
+
let t = Y(e);
|
|
619
628
|
if (!t) return "";
|
|
620
629
|
let n = (e) => String(e).padStart(2, "0");
|
|
621
630
|
return `${n(t.getDate())}/${n(t.getMonth() + 1)}/${t.getFullYear()}`;
|
|
622
631
|
}
|
|
623
|
-
function
|
|
632
|
+
function ie(e) {
|
|
624
633
|
let t = e.trim(), n = /^\d{8}$/.test(t) ? [
|
|
625
634
|
t.slice(0, 2),
|
|
626
635
|
t.slice(2, 4),
|
|
@@ -628,220 +637,344 @@ function ce(e) {
|
|
|
628
637
|
] : /^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(t)?.slice(1);
|
|
629
638
|
if (!n) return null;
|
|
630
639
|
let [r, i, a] = n.map(Number), o = new Date(a, i - 1, r);
|
|
631
|
-
return o.getFullYear() === a && o.getMonth() === i - 1 && o.getDate() === r ?
|
|
640
|
+
return o.getFullYear() === a && o.getMonth() === i - 1 && o.getDate() === r ? J(o) : null;
|
|
632
641
|
}
|
|
633
|
-
function
|
|
642
|
+
function X(e, t) {
|
|
634
643
|
return new Date(e.getFullYear(), e.getMonth(), e.getDate() + t);
|
|
635
644
|
}
|
|
636
|
-
function
|
|
645
|
+
function ae(e, t) {
|
|
637
646
|
let n = new Date(e.getFullYear(), e.getMonth() + t, 1), r = new Date(n.getFullYear(), n.getMonth() + 1, 0).getDate();
|
|
638
647
|
return new Date(n.getFullYear(), n.getMonth(), Math.min(e.getDate(), r));
|
|
639
648
|
}
|
|
640
|
-
function
|
|
641
|
-
let n = new Date(e.getFullYear(), e.getMonth(), 1), r =
|
|
642
|
-
return Array.from({ length: 6 }, (e, t) => Array.from({ length: 7 }, (e, n) =>
|
|
649
|
+
function oe(e, t) {
|
|
650
|
+
let n = new Date(e.getFullYear(), e.getMonth(), 1), r = X(n, -((n.getDay() - t + 7) % 7));
|
|
651
|
+
return Array.from({ length: 6 }, (e, t) => Array.from({ length: 7 }, (e, n) => X(r, t * 7 + n)));
|
|
643
652
|
}
|
|
644
|
-
function
|
|
653
|
+
function se(e, t, n) {
|
|
645
654
|
return (!t || e >= t) && (!n || e <= n);
|
|
646
655
|
}
|
|
647
656
|
//#endregion
|
|
648
657
|
//#region src/components/DateInput/DateInput.tsx
|
|
649
|
-
var
|
|
650
|
-
function
|
|
651
|
-
let
|
|
652
|
-
|
|
653
|
-
function
|
|
654
|
-
t === void 0 &&
|
|
658
|
+
var ce = () => J(/* @__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", name: h, id: v, disabled: y, required: T, placeholder: E = "dd/mm/aaaa", className: k, ...A }) {
|
|
660
|
+
let j = G(v), [M, N] = _(n), P = t === void 0 ? M : t, [F, I] = _(() => re(P)), [L, R] = _(!1), [z, B] = _(() => Y(P) ?? /* @__PURE__ */ new Date()), V = g(null), H = g(null), U = g(null), W = g(!1), [te, ne] = _(P);
|
|
661
|
+
te !== P && (ne(P), I(re(P)));
|
|
662
|
+
function le(e) {
|
|
663
|
+
t === void 0 && N(e), e !== P && r?.(e);
|
|
655
664
|
}
|
|
656
|
-
function
|
|
657
|
-
if (
|
|
658
|
-
|
|
665
|
+
function Z(e) {
|
|
666
|
+
if (I(e), e.trim() === "") {
|
|
667
|
+
le("");
|
|
659
668
|
return;
|
|
660
669
|
}
|
|
661
|
-
let t =
|
|
662
|
-
t &&
|
|
670
|
+
let t = ie(e);
|
|
671
|
+
t && se(t, i, a) && le(t);
|
|
663
672
|
}
|
|
664
|
-
function
|
|
665
|
-
|
|
673
|
+
function ue() {
|
|
674
|
+
B(Y(P) ?? Y(ce()) ?? /* @__PURE__ */ new Date()), W.current = !0, R(!0);
|
|
666
675
|
}
|
|
667
|
-
function
|
|
668
|
-
|
|
676
|
+
function de(e) {
|
|
677
|
+
R(!1), e && H.current?.focus();
|
|
669
678
|
}
|
|
670
|
-
function
|
|
671
|
-
let t =
|
|
672
|
-
|
|
679
|
+
function fe(e) {
|
|
680
|
+
let t = J(e);
|
|
681
|
+
se(t, i, a) && (le(t), I(re(t)), de(!0));
|
|
673
682
|
}
|
|
674
683
|
m(() => {
|
|
675
|
-
if (!
|
|
684
|
+
if (!L || !V.current || !U.current) return;
|
|
676
685
|
let e = () => {
|
|
677
|
-
|
|
686
|
+
V.current && U.current && ee(V.current, U.current, "start");
|
|
678
687
|
};
|
|
679
688
|
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
680
689
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
681
690
|
};
|
|
682
|
-
}, [
|
|
683
|
-
|
|
691
|
+
}, [L]), f(() => {
|
|
692
|
+
L && W.current && (W.current = !1, U.current?.querySelector("[tabindex=\"0\"]")?.focus());
|
|
684
693
|
}), f(() => {
|
|
685
|
-
if (!
|
|
694
|
+
if (!L) return;
|
|
686
695
|
function e(e) {
|
|
687
696
|
let t = e.target;
|
|
688
|
-
|
|
697
|
+
V.current?.contains(t) || U.current?.contains(t) || R(!1);
|
|
689
698
|
}
|
|
690
699
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
691
|
-
}, [
|
|
692
|
-
function
|
|
693
|
-
|
|
700
|
+
}, [L]);
|
|
701
|
+
function pe(e) {
|
|
702
|
+
W.current = !0, B(e);
|
|
694
703
|
}
|
|
695
|
-
function
|
|
704
|
+
function me(e) {
|
|
696
705
|
let t = {
|
|
697
|
-
ArrowLeft: () =>
|
|
698
|
-
ArrowRight: () =>
|
|
699
|
-
ArrowUp: () =>
|
|
700
|
-
ArrowDown: () =>
|
|
701
|
-
Home: () =>
|
|
702
|
-
End: () =>
|
|
703
|
-
PageUp: () =>
|
|
704
|
-
PageDown: () =>
|
|
706
|
+
ArrowLeft: () => X(z, -1),
|
|
707
|
+
ArrowRight: () => X(z, 1),
|
|
708
|
+
ArrowUp: () => X(z, -7),
|
|
709
|
+
ArrowDown: () => X(z, 7),
|
|
710
|
+
Home: () => X(z, -((z.getDay() - l + 7) % 7)),
|
|
711
|
+
End: () => X(z, 6 - (z.getDay() - l + 7) % 7),
|
|
712
|
+
PageUp: () => ae(z, e.shiftKey ? -12 : -1),
|
|
713
|
+
PageDown: () => ae(z, e.shiftKey ? 12 : 1)
|
|
705
714
|
}[e.key];
|
|
706
|
-
t && (e.preventDefault(),
|
|
715
|
+
t && (e.preventDefault(), pe(t()));
|
|
707
716
|
}
|
|
708
|
-
function
|
|
709
|
-
(e.key === "Escape" || e.key === "Tab") && (e.preventDefault(),
|
|
717
|
+
function he(e) {
|
|
718
|
+
(e.key === "Escape" || e.key === "Tab") && (e.preventDefault(), de(!0));
|
|
710
719
|
}
|
|
711
|
-
let
|
|
720
|
+
let ge = new Intl.DateTimeFormat(c, {
|
|
712
721
|
month: "long",
|
|
713
722
|
year: "numeric"
|
|
714
|
-
}).format(
|
|
723
|
+
}).format(z), _e = ge.charAt(0).toLocaleUpperCase(c) + ge.slice(1), ve = new Intl.DateTimeFormat(c, { dateStyle: "full" }), ye = oe(z, l)[0].map((e) => ({
|
|
715
724
|
short: new Intl.DateTimeFormat(c, { weekday: "narrow" }).format(e),
|
|
716
725
|
long: new Intl.DateTimeFormat(c, { weekday: "long" }).format(e)
|
|
717
|
-
})),
|
|
726
|
+
})), be = J(z), Q = ce(), $ = `${j.id}-calendar-title`;
|
|
718
727
|
return /* @__PURE__ */ x("div", {
|
|
719
|
-
className: C("hds-field",
|
|
728
|
+
className: C("hds-field", k),
|
|
720
729
|
children: [
|
|
721
730
|
/* @__PURE__ */ b("label", {
|
|
722
731
|
className: "hds-label",
|
|
723
|
-
htmlFor:
|
|
732
|
+
htmlFor: j.id,
|
|
724
733
|
children: e
|
|
725
734
|
}),
|
|
726
735
|
/* @__PURE__ */ x("div", {
|
|
727
|
-
ref:
|
|
736
|
+
ref: V,
|
|
728
737
|
className: "hds-date-wrap",
|
|
729
738
|
children: [
|
|
730
739
|
/* @__PURE__ */ b("input", {
|
|
731
|
-
...
|
|
732
|
-
id:
|
|
740
|
+
...A,
|
|
741
|
+
id: j.id,
|
|
733
742
|
type: "text",
|
|
734
743
|
inputMode: "numeric",
|
|
735
744
|
autoComplete: "off",
|
|
736
|
-
placeholder:
|
|
737
|
-
value:
|
|
745
|
+
placeholder: E,
|
|
746
|
+
value: F,
|
|
738
747
|
disabled: y,
|
|
739
748
|
required: T,
|
|
740
749
|
"aria-invalid": s ? !0 : void 0,
|
|
741
|
-
"aria-describedby":
|
|
750
|
+
"aria-describedby": K({
|
|
742
751
|
hint: o,
|
|
743
752
|
error: s,
|
|
744
|
-
"aria-describedby":
|
|
745
|
-
},
|
|
753
|
+
"aria-describedby": A["aria-describedby"]
|
|
754
|
+
}, j),
|
|
746
755
|
className: "hds-input hds-input--numeric hds-date-input",
|
|
747
|
-
onChange: (e) =>
|
|
756
|
+
onChange: (e) => Z(e.target.value),
|
|
748
757
|
onBlur: (e) => {
|
|
749
|
-
|
|
758
|
+
A.onBlur?.(e), F.trim() !== "" && ie(F) !== P && I(re(P));
|
|
750
759
|
}
|
|
751
760
|
}),
|
|
752
|
-
/* @__PURE__ */ b(
|
|
753
|
-
ref:
|
|
761
|
+
/* @__PURE__ */ b(O, {
|
|
762
|
+
ref: H,
|
|
754
763
|
variant: "ghost",
|
|
755
764
|
size: "sm",
|
|
756
765
|
iconOnly: !0,
|
|
757
|
-
icon: /* @__PURE__ */ b(
|
|
766
|
+
icon: /* @__PURE__ */ b(D, { name: "calendar" }),
|
|
758
767
|
"aria-label": u,
|
|
759
768
|
"aria-haspopup": "dialog",
|
|
760
|
-
"aria-expanded":
|
|
769
|
+
"aria-expanded": L,
|
|
761
770
|
disabled: y,
|
|
762
771
|
className: "hds-date-button",
|
|
763
|
-
onClick: () =>
|
|
772
|
+
onClick: () => L ? de(!1) : ue()
|
|
764
773
|
}),
|
|
765
774
|
h ? /* @__PURE__ */ b("input", {
|
|
766
775
|
type: "hidden",
|
|
767
776
|
name: h,
|
|
768
|
-
value:
|
|
777
|
+
value: P
|
|
769
778
|
}) : null
|
|
770
779
|
]
|
|
771
780
|
}),
|
|
772
|
-
/* @__PURE__ */ b(
|
|
781
|
+
/* @__PURE__ */ b(q, {
|
|
773
782
|
hint: o,
|
|
774
783
|
error: s,
|
|
775
|
-
ids:
|
|
784
|
+
ids: j
|
|
776
785
|
}),
|
|
777
|
-
|
|
778
|
-
ref:
|
|
786
|
+
L ? S(/* @__PURE__ */ x(w, {
|
|
787
|
+
ref: U,
|
|
779
788
|
role: "dialog",
|
|
780
789
|
tone: "thick",
|
|
781
790
|
"aria-labelledby": $,
|
|
782
791
|
className: "hds-date-panel",
|
|
783
|
-
onKeyDown:
|
|
792
|
+
onKeyDown: he,
|
|
784
793
|
children: [/* @__PURE__ */ x("div", {
|
|
785
794
|
className: "hds-date-header",
|
|
786
795
|
children: [
|
|
787
|
-
/* @__PURE__ */ b(
|
|
796
|
+
/* @__PURE__ */ b(O, {
|
|
788
797
|
variant: "ghost",
|
|
789
798
|
size: "sm",
|
|
790
799
|
iconOnly: !0,
|
|
791
|
-
icon: /* @__PURE__ */ b(
|
|
800
|
+
icon: /* @__PURE__ */ b(D, { name: "chevron-left" }),
|
|
792
801
|
"aria-label": d,
|
|
793
|
-
onClick: () =>
|
|
802
|
+
onClick: () => B(ae(z, -1))
|
|
794
803
|
}),
|
|
795
804
|
/* @__PURE__ */ b("h2", {
|
|
796
805
|
id: $,
|
|
797
806
|
className: "hds-date-title",
|
|
798
807
|
"aria-live": "polite",
|
|
799
|
-
children:
|
|
808
|
+
children: _e
|
|
800
809
|
}),
|
|
801
|
-
/* @__PURE__ */ b(
|
|
810
|
+
/* @__PURE__ */ b(O, {
|
|
802
811
|
variant: "ghost",
|
|
803
812
|
size: "sm",
|
|
804
813
|
iconOnly: !0,
|
|
805
|
-
icon: /* @__PURE__ */ b(
|
|
814
|
+
icon: /* @__PURE__ */ b(D, { name: "chevron-right" }),
|
|
806
815
|
"aria-label": p,
|
|
807
|
-
onClick: () =>
|
|
816
|
+
onClick: () => B(ae(z, 1))
|
|
808
817
|
})
|
|
809
818
|
]
|
|
810
819
|
}), /* @__PURE__ */ x("table", {
|
|
811
820
|
role: "grid",
|
|
812
821
|
"aria-labelledby": $,
|
|
813
822
|
className: "hds-date-grid",
|
|
814
|
-
onKeyDown:
|
|
815
|
-
children: [/* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { children:
|
|
823
|
+
onKeyDown: me,
|
|
824
|
+
children: [/* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { children: ye.map((e) => /* @__PURE__ */ b("th", {
|
|
816
825
|
scope: "col",
|
|
817
826
|
abbr: e.long,
|
|
818
827
|
children: e.short
|
|
819
|
-
}, e.long)) }) }), /* @__PURE__ */ b("tbody", { children:
|
|
820
|
-
let t =
|
|
828
|
+
}, e.long)) }) }), /* @__PURE__ */ b("tbody", { children: oe(z, l).map((e) => /* @__PURE__ */ b("tr", { children: e.map((e) => {
|
|
829
|
+
let t = J(e), n = se(t, i, a);
|
|
821
830
|
return /* @__PURE__ */ b("td", {
|
|
822
831
|
role: "gridcell",
|
|
823
|
-
"aria-selected": t ===
|
|
832
|
+
"aria-selected": t === P,
|
|
824
833
|
children: /* @__PURE__ */ b("button", {
|
|
825
834
|
type: "button",
|
|
826
|
-
tabIndex: t ===
|
|
835
|
+
tabIndex: t === be ? 0 : -1,
|
|
827
836
|
"aria-label": ve.format(e),
|
|
828
|
-
"aria-current": t ===
|
|
837
|
+
"aria-current": t === Q ? "date" : void 0,
|
|
829
838
|
"aria-disabled": !n || void 0,
|
|
830
|
-
className: C("hds-date-day", e.getMonth() !==
|
|
831
|
-
onClick: () =>
|
|
839
|
+
className: C("hds-date-day", e.getMonth() !== z.getMonth() && "hds-date-day--outside", t === P && "hds-date-day--selected"),
|
|
840
|
+
onClick: () => fe(e),
|
|
832
841
|
children: e.getDate()
|
|
833
842
|
})
|
|
834
843
|
}, t);
|
|
835
|
-
}) },
|
|
844
|
+
}) }, J(e[0]))) })]
|
|
836
845
|
})]
|
|
837
846
|
}), document.body) : null
|
|
838
847
|
]
|
|
839
848
|
});
|
|
840
849
|
}
|
|
841
850
|
//#endregion
|
|
851
|
+
//#region src/components/Typeahead/Typeahead.tsx
|
|
852
|
+
function Z(e, t) {
|
|
853
|
+
return e.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLocaleLowerCase(t);
|
|
854
|
+
}
|
|
855
|
+
function ue(e, t, n = "pt-BR", r = 8) {
|
|
856
|
+
let i = Z(t.trim(), n), a = [...new Map(e.filter(Boolean).map((e) => [Z(e, n), e])).values()];
|
|
857
|
+
return i ? a.map((e) => ({
|
|
858
|
+
suggestion: e,
|
|
859
|
+
at: Z(e, n).indexOf(i)
|
|
860
|
+
})).filter(({ suggestion: e, at: t }) => t >= 0 && Z(e, n) !== i).sort((e, t) => (e.at === 0 ? 0 : 1) - (t.at === 0 ? 0 : 1) || e.suggestion.localeCompare(t.suggestion, n)).slice(0, r).map(({ suggestion: e }) => e) : a.slice(0, r);
|
|
861
|
+
}
|
|
862
|
+
function de({ text: e, query: t, locale: n }) {
|
|
863
|
+
let r = t.trim() ? Z(e, n).indexOf(Z(t.trim(), n)) : -1;
|
|
864
|
+
if (r < 0) return /* @__PURE__ */ b(y, { children: e });
|
|
865
|
+
let i = r + t.trim().length;
|
|
866
|
+
return /* @__PURE__ */ x(y, { children: [
|
|
867
|
+
e.slice(0, r),
|
|
868
|
+
/* @__PURE__ */ b("mark", {
|
|
869
|
+
className: "hds-typeahead-match",
|
|
870
|
+
children: e.slice(r, i)
|
|
871
|
+
}),
|
|
872
|
+
e.slice(i)
|
|
873
|
+
] });
|
|
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", id: l, className: u, disabled: d, ...p }) {
|
|
876
|
+
let h = G(l), v = `${h.id}-list`, y = `${h.id}-label`, [T, E] = _(n), D = t === void 0 ? T : t, [O, k] = _(!1), [A, j] = _(-1), M = g(null), N = g(null), P = ue(i, D, c, a), F = O && P.length > 0;
|
|
877
|
+
function I(e) {
|
|
878
|
+
t === void 0 && E(e), r?.(e);
|
|
879
|
+
}
|
|
880
|
+
function L(e) {
|
|
881
|
+
I(e), k(!1), j(-1);
|
|
882
|
+
}
|
|
883
|
+
m(() => {
|
|
884
|
+
if (!F || !M.current || !N.current) return;
|
|
885
|
+
let e = () => {
|
|
886
|
+
M.current && N.current && (N.current.style.width = `${M.current.offsetWidth}px`, ee(M.current, N.current, "start"));
|
|
887
|
+
};
|
|
888
|
+
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
889
|
+
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
890
|
+
};
|
|
891
|
+
}, [F, P.length]), f(() => {
|
|
892
|
+
!F || A < 0 || document.getElementById(`${v}-${A}`)?.scrollIntoView?.({ block: "nearest" });
|
|
893
|
+
}, [
|
|
894
|
+
F,
|
|
895
|
+
A,
|
|
896
|
+
v
|
|
897
|
+
]);
|
|
898
|
+
function R(e) {
|
|
899
|
+
if (p.onKeyDown?.(e), e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
900
|
+
if (e.preventDefault(), !F) {
|
|
901
|
+
k(!0), j(e.key === "ArrowDown" ? 0 : P.length - 1);
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
j((t) => e.key === "ArrowDown" ? (t + 1) % P.length : t <= 0 ? P.length - 1 : t - 1);
|
|
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
|
+
}
|
|
907
|
+
return /* @__PURE__ */ x("div", {
|
|
908
|
+
className: C("hds-field", u),
|
|
909
|
+
children: [
|
|
910
|
+
/* @__PURE__ */ b("label", {
|
|
911
|
+
id: y,
|
|
912
|
+
className: "hds-label",
|
|
913
|
+
htmlFor: h.id,
|
|
914
|
+
children: e
|
|
915
|
+
}),
|
|
916
|
+
/* @__PURE__ */ b("input", {
|
|
917
|
+
spellCheck: !1,
|
|
918
|
+
...p,
|
|
919
|
+
ref: M,
|
|
920
|
+
id: h.id,
|
|
921
|
+
type: "text",
|
|
922
|
+
role: "combobox",
|
|
923
|
+
autoComplete: "off",
|
|
924
|
+
"aria-autocomplete": "list",
|
|
925
|
+
"aria-expanded": F,
|
|
926
|
+
"aria-controls": F ? v : void 0,
|
|
927
|
+
"aria-activedescendant": F && A >= 0 ? `${v}-${A}` : void 0,
|
|
928
|
+
"aria-invalid": s ? !0 : void 0,
|
|
929
|
+
"aria-describedby": K({
|
|
930
|
+
hint: o,
|
|
931
|
+
error: s,
|
|
932
|
+
"aria-describedby": p["aria-describedby"]
|
|
933
|
+
}, h),
|
|
934
|
+
className: "hds-input",
|
|
935
|
+
disabled: d,
|
|
936
|
+
value: D,
|
|
937
|
+
onChange: (e) => {
|
|
938
|
+
I(e.target.value), k(!0), j(-1);
|
|
939
|
+
},
|
|
940
|
+
onKeyDown: R,
|
|
941
|
+
onBlur: (e) => {
|
|
942
|
+
p.onBlur?.(e), k(!1), j(-1);
|
|
943
|
+
}
|
|
944
|
+
}),
|
|
945
|
+
/* @__PURE__ */ b(q, {
|
|
946
|
+
hint: o,
|
|
947
|
+
error: s,
|
|
948
|
+
ids: h
|
|
949
|
+
}),
|
|
950
|
+
F ? S(/* @__PURE__ */ b(w, {
|
|
951
|
+
ref: N,
|
|
952
|
+
id: v,
|
|
953
|
+
role: "listbox",
|
|
954
|
+
"aria-labelledby": y,
|
|
955
|
+
className: "hds-typeahead-panel",
|
|
956
|
+
children: P.map((e, t) => /* @__PURE__ */ b("div", {
|
|
957
|
+
id: `${v}-${t}`,
|
|
958
|
+
role: "option",
|
|
959
|
+
"aria-selected": t === A,
|
|
960
|
+
className: "hds-typeahead-option",
|
|
961
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
962
|
+
onClick: () => L(e),
|
|
963
|
+
onMouseMove: () => j(t),
|
|
964
|
+
children: /* @__PURE__ */ b(de, {
|
|
965
|
+
text: e,
|
|
966
|
+
query: D,
|
|
967
|
+
locale: c
|
|
968
|
+
})
|
|
969
|
+
}, e))
|
|
970
|
+
}), document.body) : null
|
|
971
|
+
]
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
//#endregion
|
|
842
975
|
//#region src/components/Checkbox/Checkbox.tsx
|
|
843
|
-
var
|
|
844
|
-
let o =
|
|
976
|
+
var pe = l(function({ label: e, hint: t, id: n, className: r, ...i }, a) {
|
|
977
|
+
let o = G(n);
|
|
845
978
|
return /* @__PURE__ */ x("label", {
|
|
846
979
|
className: C("hds-checkbox", r),
|
|
847
980
|
htmlFor: o.id,
|
|
@@ -856,7 +989,7 @@ var fe = l(function({ label: e, hint: t, id: n, className: r, ...i }, a) {
|
|
|
856
989
|
"aria-describedby": t ? o.hint : i["aria-describedby"]
|
|
857
990
|
}), /* @__PURE__ */ b("span", {
|
|
858
991
|
className: "hds-checkbox-box",
|
|
859
|
-
children: /* @__PURE__ */ b(
|
|
992
|
+
children: /* @__PURE__ */ b(D, { name: "check" })
|
|
860
993
|
})]
|
|
861
994
|
}), /* @__PURE__ */ x("span", {
|
|
862
995
|
className: "hds-checkbox-text",
|
|
@@ -870,7 +1003,7 @@ var fe = l(function({ label: e, hint: t, id: n, className: r, ...i }, a) {
|
|
|
870
1003
|
});
|
|
871
1004
|
//#endregion
|
|
872
1005
|
//#region src/components/Card/Card.tsx
|
|
873
|
-
function
|
|
1006
|
+
function me({ as: e = "article", eyebrow: t, title: n, media: r, footer: i, interactive: a = !1, className: o, children: s, ...c }) {
|
|
874
1007
|
return /* @__PURE__ */ x(e, {
|
|
875
1008
|
...c,
|
|
876
1009
|
className: C("hds-card", a && "hds-card--interactive", o),
|
|
@@ -906,14 +1039,14 @@ function pe({ as: e = "article", eyebrow: t, title: n, media: r, footer: i, inte
|
|
|
906
1039
|
}
|
|
907
1040
|
//#endregion
|
|
908
1041
|
//#region src/components/Badge/Badge.tsx
|
|
909
|
-
var
|
|
1042
|
+
var he = {
|
|
910
1043
|
accent: "info",
|
|
911
1044
|
success: "circle-check",
|
|
912
1045
|
warning: "triangle-alert",
|
|
913
1046
|
danger: "circle-x"
|
|
914
1047
|
};
|
|
915
|
-
function
|
|
916
|
-
let i =
|
|
1048
|
+
function ge({ tone: e = "neutral", icon: t, children: n, className: r }) {
|
|
1049
|
+
let i = he[e], a = t === !1 ? null : t ?? (i ? /* @__PURE__ */ b(D, { name: i }) : null);
|
|
917
1050
|
return /* @__PURE__ */ x("span", {
|
|
918
1051
|
className: C("hds-badge", `hds-badge--${e}`, r),
|
|
919
1052
|
children: [a, n]
|
|
@@ -921,10 +1054,10 @@ function me({ tone: e = "neutral", icon: t, children: n, className: r }) {
|
|
|
921
1054
|
}
|
|
922
1055
|
//#endregion
|
|
923
1056
|
//#region src/components/Table/Table.tsx
|
|
924
|
-
function
|
|
1057
|
+
function _e(e) {
|
|
925
1058
|
return e.numeric ? "hds-cell--numeric" : e.align === "center" ? "hds-cell--center" : void 0;
|
|
926
1059
|
}
|
|
927
|
-
function
|
|
1060
|
+
function ve({ columns: e, rows: t, rowKey: n = "id", caption: r, hideCaption: i = !1, empty: a = "Nada para mostrar.", maxHeight: o, glass: s = !1, className: c }) {
|
|
928
1061
|
return /* @__PURE__ */ b("div", {
|
|
929
1062
|
className: C("hds-table-wrap", "hds-scroll", s && "hds-glass hds-table-wrap--glass", c),
|
|
930
1063
|
role: "region",
|
|
@@ -940,11 +1073,11 @@ function ge({ columns: e, rows: t, rowKey: n = "id", caption: r, hideCaption: i
|
|
|
940
1073
|
}) : null,
|
|
941
1074
|
/* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { children: e.map((e) => /* @__PURE__ */ b("th", {
|
|
942
1075
|
scope: "col",
|
|
943
|
-
className:
|
|
1076
|
+
className: _e(e),
|
|
944
1077
|
children: e.header
|
|
945
1078
|
}, e.key)) }) }),
|
|
946
1079
|
/* @__PURE__ */ b("tbody", { children: t.length ? t.map((t, r) => /* @__PURE__ */ b("tr", { children: e.map((e) => /* @__PURE__ */ b("td", {
|
|
947
|
-
className:
|
|
1080
|
+
className: _e(e),
|
|
948
1081
|
children: e.render ? e.render(t) : t[e.key]
|
|
949
1082
|
}, e.key)) }, String(t[n] ?? r))) : /* @__PURE__ */ b("tr", { children: /* @__PURE__ */ b("td", {
|
|
950
1083
|
colSpan: e.length || 1,
|
|
@@ -957,19 +1090,19 @@ function ge({ columns: e, rows: t, rowKey: n = "id", caption: r, hideCaption: i
|
|
|
957
1090
|
}
|
|
958
1091
|
//#endregion
|
|
959
1092
|
//#region src/appearance/useAppearance.ts
|
|
960
|
-
var
|
|
1093
|
+
var ye = !1, be = {
|
|
961
1094
|
theme: "dark",
|
|
962
1095
|
transparency: "full"
|
|
963
|
-
},
|
|
964
|
-
function
|
|
1096
|
+
}, Q = be;
|
|
1097
|
+
function $() {
|
|
965
1098
|
let e = a();
|
|
966
|
-
return (e.theme !==
|
|
1099
|
+
return (e.theme !== Q.theme || e.transparency !== Q.transparency) && (Q = e), Q;
|
|
967
1100
|
}
|
|
968
|
-
function
|
|
1101
|
+
function xe() {
|
|
969
1102
|
f(() => {
|
|
970
|
-
|
|
1103
|
+
ye || (ye = !0, document.documentElement.hasAttribute("data-theme") || r());
|
|
971
1104
|
}, []);
|
|
972
|
-
let e = v(o,
|
|
1105
|
+
let e = v(o, $, () => be);
|
|
973
1106
|
return {
|
|
974
1107
|
...e,
|
|
975
1108
|
setTheme: t,
|
|
@@ -980,25 +1113,25 @@ function Q() {
|
|
|
980
1113
|
}
|
|
981
1114
|
//#endregion
|
|
982
1115
|
//#region src/components/AppearanceToggles/AppearanceToggles.tsx
|
|
983
|
-
function
|
|
984
|
-
let { theme: i, toggleTheme: a } =
|
|
985
|
-
return /* @__PURE__ */ b(
|
|
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 } = xe(), o = i === "dark" ? e : t;
|
|
1118
|
+
return /* @__PURE__ */ b(O, {
|
|
986
1119
|
...r,
|
|
987
1120
|
variant: n,
|
|
988
1121
|
iconOnly: !0,
|
|
989
|
-
icon: /* @__PURE__ */ b(
|
|
1122
|
+
icon: /* @__PURE__ */ b(D, { name: i === "dark" ? "sun" : "moon" }),
|
|
990
1123
|
"aria-label": o,
|
|
991
1124
|
title: o,
|
|
992
1125
|
onClick: a
|
|
993
1126
|
});
|
|
994
1127
|
}
|
|
995
|
-
function
|
|
996
|
-
let { transparency: r, toggleTransparency: i } =
|
|
997
|
-
return /* @__PURE__ */ b(
|
|
1128
|
+
function Ce({ label: e = "Reduzir transparência", variant: t = "ghost", ...n }) {
|
|
1129
|
+
let { transparency: r, toggleTransparency: i } = xe();
|
|
1130
|
+
return /* @__PURE__ */ b(O, {
|
|
998
1131
|
...n,
|
|
999
1132
|
variant: t,
|
|
1000
1133
|
iconOnly: !0,
|
|
1001
|
-
icon: /* @__PURE__ */ b(
|
|
1134
|
+
icon: /* @__PURE__ */ b(D, { name: "blend" }),
|
|
1002
1135
|
"aria-label": e,
|
|
1003
1136
|
"aria-pressed": r === "reduced",
|
|
1004
1137
|
title: e,
|
|
@@ -1007,7 +1140,7 @@ function be({ label: e = "Reduzir transparência", variant: t = "ghost", ...n })
|
|
|
1007
1140
|
}
|
|
1008
1141
|
//#endregion
|
|
1009
1142
|
//#region src/components/Container/Container.tsx
|
|
1010
|
-
function
|
|
1143
|
+
function we({ as: e = "section", withSidebar: t = !1, className: n, ...r }) {
|
|
1011
1144
|
return /* @__PURE__ */ b(e, {
|
|
1012
1145
|
...r,
|
|
1013
1146
|
className: C("hds-container", t && "hds-container--with-sidebar", n)
|
|
@@ -1015,7 +1148,7 @@ function $({ as: e = "section", withSidebar: t = !1, className: n, ...r }) {
|
|
|
1015
1148
|
}
|
|
1016
1149
|
//#endregion
|
|
1017
1150
|
//#region src/components/SectionTitle/SectionTitle.tsx
|
|
1018
|
-
function
|
|
1151
|
+
function Te({ children: e, index: t, as: n = "h2", id: r, className: i }) {
|
|
1019
1152
|
return /* @__PURE__ */ x(n, {
|
|
1020
1153
|
id: r,
|
|
1021
1154
|
className: C("hds-section-title", i),
|
|
@@ -1028,7 +1161,7 @@ function xe({ children: e, index: t, as: n = "h2", id: r, className: i }) {
|
|
|
1028
1161
|
}
|
|
1029
1162
|
//#endregion
|
|
1030
1163
|
//#region src/components/Separator/Separator.tsx
|
|
1031
|
-
function
|
|
1164
|
+
function Ee({ orientation: e = "horizontal", decorative: t = !1, className: n }) {
|
|
1032
1165
|
return /* @__PURE__ */ b("div", {
|
|
1033
1166
|
role: t ? "none" : "separator",
|
|
1034
1167
|
"aria-orientation": t ? void 0 : e,
|
|
@@ -1037,7 +1170,7 @@ function Se({ orientation: e = "horizontal", decorative: t = !1, className: n })
|
|
|
1037
1170
|
}
|
|
1038
1171
|
//#endregion
|
|
1039
1172
|
//#region src/components/ScrollArea/ScrollArea.tsx
|
|
1040
|
-
function
|
|
1173
|
+
function De({ label: e, maxHeight: t, className: n, style: r, ...i }) {
|
|
1041
1174
|
return /* @__PURE__ */ b("div", {
|
|
1042
1175
|
...i,
|
|
1043
1176
|
role: "region",
|
|
@@ -1052,11 +1185,11 @@ function Ce({ label: e, maxHeight: t, className: n, style: r, ...i }) {
|
|
|
1052
1185
|
}
|
|
1053
1186
|
//#endregion
|
|
1054
1187
|
//#region src/components/Loading/Loading.tsx
|
|
1055
|
-
function
|
|
1188
|
+
function Oe({ size: e = "md", label: t = "Carregando…", showLabel: n = !1, className: r }) {
|
|
1056
1189
|
return /* @__PURE__ */ x("span", {
|
|
1057
1190
|
role: "status",
|
|
1058
1191
|
className: C("hds-loading", `hds-loading--${e}`, r),
|
|
1059
|
-
children: [/* @__PURE__ */ b(
|
|
1192
|
+
children: [/* @__PURE__ */ b(D, { name: "loader" }), /* @__PURE__ */ b("span", {
|
|
1060
1193
|
className: n ? void 0 : "hds-visually-hidden",
|
|
1061
1194
|
children: t
|
|
1062
1195
|
})]
|
|
@@ -1064,7 +1197,7 @@ function we({ size: e = "md", label: t = "Carregando…", showLabel: n = !1, cla
|
|
|
1064
1197
|
}
|
|
1065
1198
|
//#endregion
|
|
1066
1199
|
//#region src/components/GlowAvatar/GlowAvatar.tsx
|
|
1067
|
-
function
|
|
1200
|
+
function ke({ src: e, alt: t, size: n = 96, className: r }) {
|
|
1068
1201
|
return /* @__PURE__ */ x("span", {
|
|
1069
1202
|
className: C("hds-avatar", r),
|
|
1070
1203
|
style: {
|
|
@@ -1084,6 +1217,6 @@ function Te({ src: e, alt: t, size: n = 96, className: r }) {
|
|
|
1084
1217
|
});
|
|
1085
1218
|
}
|
|
1086
1219
|
//#endregion
|
|
1087
|
-
export { s as APPEARANCE_STORAGE_KEYS,
|
|
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, R as Dialog, I as FloatingButton, w as GlassPanel, ke as GlowAvatar, te as Input, Oe as Loading, F as Menu, j as NavBar, De as ScrollArea, Te as SectionTitle, P as SegmentedControl, ne as Select, Ee as Separator, M as Sidebar, ve as Table, Se as ThemeToggle, V as Toast, U 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, xe as useAppearance, W as useToast };
|
|
1088
1221
|
|
|
1089
1222
|
//# sourceMappingURL=index.js.map
|