twico-ui 1.0.0 → 1.0.2
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.cjs +874 -1115
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +858 -1114
- package/dist/index.mjs.map +1 -1
- package/llms.txt +2420 -0
- package/package.json +17 -10
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import * as React23 from 'react';
|
|
3
|
+
import React23__default from 'react';
|
|
4
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
5
|
import { createPortal } from 'react-dom';
|
|
5
6
|
|
|
6
7
|
// components/navigation/Accordion.jsx
|
|
8
|
+
var SUPPORTS_STYLE_HOIST = parseInt(String(React23.version), 10) >= 19;
|
|
9
|
+
function useScopedStyles(id, css) {
|
|
10
|
+
React23.useInsertionEffect(() => {
|
|
11
|
+
if (SUPPORTS_STYLE_HOIST) return;
|
|
12
|
+
if (typeof document === "undefined" || document.getElementById(id)) return;
|
|
13
|
+
const el = document.createElement("style");
|
|
14
|
+
el.id = id;
|
|
15
|
+
el.textContent = css;
|
|
16
|
+
document.head.appendChild(el);
|
|
17
|
+
}, [id, css]);
|
|
18
|
+
return SUPPORTS_STYLE_HOIST ? React23.createElement("style", { href: id, precedence: "twc-ui" }, css) : null;
|
|
19
|
+
}
|
|
7
20
|
var ACCORDION_CSS = `
|
|
8
21
|
.twc-accordion { display: flex; flex-direction: column; font-family: var(--font-sans);
|
|
9
22
|
border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; background: var(--color-surface); }
|
|
@@ -38,16 +51,10 @@ function Accordion({
|
|
|
38
51
|
className = "",
|
|
39
52
|
...rest
|
|
40
53
|
}) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const el = document.createElement("style");
|
|
44
|
-
el.id = "twc-accordion-styles";
|
|
45
|
-
el.textContent = ACCORDION_CSS;
|
|
46
|
-
document.head.appendChild(el);
|
|
47
|
-
}, []);
|
|
48
|
-
const [internal, setInternal] = React22.useState(() => new Set(defaultOpen));
|
|
54
|
+
const __twcStyles = useScopedStyles("twc-accordion-styles", ACCORDION_CSS);
|
|
55
|
+
const [internal, setInternal] = React23__default.useState(() => new Set(defaultOpen));
|
|
49
56
|
const open = openProp !== void 0 ? new Set(openProp) : internal;
|
|
50
|
-
const baseId =
|
|
57
|
+
const baseId = React23__default.useId();
|
|
51
58
|
function toggle(val) {
|
|
52
59
|
const next = new Set(open);
|
|
53
60
|
if (next.has(val)) next.delete(val);
|
|
@@ -58,19 +65,22 @@ function Accordion({
|
|
|
58
65
|
if (openProp === void 0) setInternal(next);
|
|
59
66
|
onOpenChange?.([...next]);
|
|
60
67
|
}
|
|
61
|
-
return /* @__PURE__ */
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-accordion ${className}`, ...rest, children: [
|
|
69
|
+
__twcStyles,
|
|
70
|
+
items.map((it, i) => {
|
|
71
|
+
const isOpen = open.has(it.value);
|
|
72
|
+
const triggerId = `${baseId}-trigger-${i}`;
|
|
73
|
+
const panelId = `${baseId}-panel-${i}`;
|
|
74
|
+
return /* @__PURE__ */ jsxs("div", { className: "twc-accordion__item", children: [
|
|
75
|
+
/* @__PURE__ */ jsxs("button", { type: "button", id: triggerId, className: "twc-accordion__trigger", "data-open": isOpen || void 0, "aria-expanded": isOpen, "aria-controls": panelId, onClick: () => toggle(it.value), children: [
|
|
76
|
+
it.icon,
|
|
77
|
+
/* @__PURE__ */ jsx("span", { className: "twc-accordion__label", children: it.label }),
|
|
78
|
+
/* @__PURE__ */ jsx("span", { className: "twc-accordion__chevron", "aria-hidden": "true", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" }) }) })
|
|
79
|
+
] }),
|
|
80
|
+
/* @__PURE__ */ jsx("div", { className: "twc-accordion__panel", id: panelId, role: "region", "aria-labelledby": triggerId, "data-open": isOpen || void 0, children: /* @__PURE__ */ jsx("div", { className: "twc-accordion__panel-inner", children: /* @__PURE__ */ jsx("div", { className: "twc-accordion__content", children: it.content }) }) })
|
|
81
|
+
] }, it.value);
|
|
82
|
+
})
|
|
83
|
+
] });
|
|
74
84
|
}
|
|
75
85
|
var ALERT_CSS = `
|
|
76
86
|
.twc-alert {
|
|
@@ -125,14 +135,9 @@ function Alert({
|
|
|
125
135
|
className = "",
|
|
126
136
|
...rest
|
|
127
137
|
}) {
|
|
128
|
-
|
|
129
|
-
if (document.getElementById("twc-alert-styles")) return;
|
|
130
|
-
const el = document.createElement("style");
|
|
131
|
-
el.id = "twc-alert-styles";
|
|
132
|
-
el.textContent = ALERT_CSS;
|
|
133
|
-
document.head.appendChild(el);
|
|
134
|
-
}, []);
|
|
138
|
+
const __twcStyles = useScopedStyles("twc-alert-styles", ALERT_CSS);
|
|
135
139
|
return /* @__PURE__ */ jsxs("div", { className: `twc-alert ${className}`, "data-tone": tone, "data-variant": variant, role: "alert", ...rest, children: [
|
|
140
|
+
__twcStyles,
|
|
136
141
|
/* @__PURE__ */ jsx("span", { className: "twc-alert__icon", "aria-hidden": "true", children: icon || /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
137
142
|
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
138
143
|
/* @__PURE__ */ jsx("path", { d: ICONS[tone] })
|
|
@@ -194,14 +199,8 @@ function Avatar({
|
|
|
194
199
|
className = "",
|
|
195
200
|
...rest
|
|
196
201
|
}) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const el = document.createElement("style");
|
|
200
|
-
el.id = "twc-avatar-styles";
|
|
201
|
-
el.textContent = AVATAR_CSS;
|
|
202
|
-
document.head.appendChild(el);
|
|
203
|
-
}, []);
|
|
204
|
-
const [errored, setErrored] = React22.useState(false);
|
|
202
|
+
const __twcStyles = useScopedStyles("twc-avatar-styles", AVATAR_CSS);
|
|
203
|
+
const [errored, setErrored] = React23__default.useState(false);
|
|
205
204
|
const cleanSrc = safeSrc(src);
|
|
206
205
|
const showImg = cleanSrc && !errored;
|
|
207
206
|
return /* @__PURE__ */ jsxs(
|
|
@@ -214,6 +213,7 @@ function Avatar({
|
|
|
214
213
|
"aria-label": name || "avatar",
|
|
215
214
|
...rest,
|
|
216
215
|
children: [
|
|
216
|
+
__twcStyles,
|
|
217
217
|
showImg ? /* @__PURE__ */ jsx("img", { className: "twc-avatar__img", src: cleanSrc, alt: name || "", onError: () => setErrored(true) }, cleanSrc) : initials(name),
|
|
218
218
|
status ? /* @__PURE__ */ jsx("span", { className: "twc-avatar__status", "data-status": status }) : null
|
|
219
219
|
]
|
|
@@ -235,7 +235,7 @@ var MENU_CSS = `
|
|
|
235
235
|
@media (prefers-reduced-motion: reduce) { .twc-menu[data-state] { animation-duration: 1ms; } }
|
|
236
236
|
.twc-menu[data-flip="true"] { transform-origin: bottom; }
|
|
237
237
|
.twc-menu__header { display: flex; align-items: center; gap: var(--space-2-5); padding: 8px 10px 10px; margin-bottom: var(--space-1-5); border-bottom: var(--border-thin) solid var(--color-divider); }
|
|
238
|
-
.twc-menu__header-main { min-width: 0; }
|
|
238
|
+
.twc-menu__header-main { min-width: 0; display: flex; flex-direction: column; }
|
|
239
239
|
.twc-menu__header-title { font-size: var(--text-sm); font-weight: var(--font-bold); color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
240
240
|
.twc-menu__header-sub { font-size: var(--text-xs); color: var(--color-text-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
241
241
|
.twc-menu__label { padding: 6px 10px 4px; font-size: var(--text-xs); font-weight: var(--font-semibold); letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--color-text-subtle); }
|
|
@@ -268,29 +268,23 @@ function Menu({
|
|
|
268
268
|
className = "",
|
|
269
269
|
...rest
|
|
270
270
|
}) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
const [render, setRender] = React22.useState(false);
|
|
280
|
-
const [pos, setPos] = React22.useState(null);
|
|
281
|
-
const [active, setActive] = React22.useState(-1);
|
|
282
|
-
const wrapRef = React22.useRef(null);
|
|
283
|
-
const menuRef = React22.useRef(null);
|
|
284
|
-
const menuId = React22.useId();
|
|
271
|
+
const __twcStyles = useScopedStyles("twc-menu-styles", MENU_CSS);
|
|
272
|
+
const [openState, setOpenState] = React23__default.useState(defaultOpen);
|
|
273
|
+
const [render, setRender] = React23__default.useState(false);
|
|
274
|
+
const [pos, setPos] = React23__default.useState(null);
|
|
275
|
+
const [active, setActive] = React23__default.useState(-1);
|
|
276
|
+
const wrapRef = React23__default.useRef(null);
|
|
277
|
+
const menuRef = React23__default.useRef(null);
|
|
278
|
+
const menuId = React23__default.useId();
|
|
285
279
|
const controlled = openProp !== void 0;
|
|
286
280
|
const open = controlled ? !!openProp : openState;
|
|
287
|
-
const openRef =
|
|
281
|
+
const openRef = React23__default.useRef(open);
|
|
288
282
|
openRef.current = open;
|
|
289
|
-
const controlledRef =
|
|
283
|
+
const controlledRef = React23__default.useRef(controlled);
|
|
290
284
|
controlledRef.current = controlled;
|
|
291
|
-
const onOpenChangeRef =
|
|
285
|
+
const onOpenChangeRef = React23__default.useRef(onOpenChange);
|
|
292
286
|
onOpenChangeRef.current = onOpenChange;
|
|
293
|
-
const setOpen =
|
|
287
|
+
const setOpen = React23__default.useCallback((next) => {
|
|
294
288
|
const value = typeof next === "function" ? next(openRef.current) : next;
|
|
295
289
|
if (value === openRef.current) return;
|
|
296
290
|
if (!controlledRef.current) setOpenState(value);
|
|
@@ -298,7 +292,7 @@ function Menu({
|
|
|
298
292
|
}, []);
|
|
299
293
|
const RD = { createPortal: typeof createPortal === "function" ? createPortal : typeof window !== "undefined" && window.ReactDOM && window.ReactDOM.createPortal };
|
|
300
294
|
const interactiveIdx = items.map((it, i) => !it.separator && !it.heading ? i : -1).filter((i) => i >= 0);
|
|
301
|
-
const place =
|
|
295
|
+
const place = React23__default.useCallback(() => {
|
|
302
296
|
const t = wrapRef.current;
|
|
303
297
|
if (!t) return;
|
|
304
298
|
const r = t.getBoundingClientRect();
|
|
@@ -313,7 +307,7 @@ function Menu({
|
|
|
313
307
|
const avail = (flip ? r.top : vh - r.bottom) - gap - M;
|
|
314
308
|
setPos({ top, bottom, left, width: w, flip, maxHeight: Math.max(120, avail) });
|
|
315
309
|
}, [align, width]);
|
|
316
|
-
|
|
310
|
+
React23__default.useEffect(() => {
|
|
317
311
|
if (!open) return;
|
|
318
312
|
place();
|
|
319
313
|
const onMove = () => place();
|
|
@@ -331,7 +325,7 @@ function Menu({
|
|
|
331
325
|
document.removeEventListener("mousedown", onDown);
|
|
332
326
|
};
|
|
333
327
|
}, [open, place]);
|
|
334
|
-
|
|
328
|
+
React23__default.useEffect(() => {
|
|
335
329
|
if (open) {
|
|
336
330
|
setRender(true);
|
|
337
331
|
return;
|
|
@@ -394,6 +388,7 @@ function Menu({
|
|
|
394
388
|
role: "menu",
|
|
395
389
|
style: { top: pos.top, bottom: pos.bottom, left: pos.left, minWidth: pos.width, width: pos.width, maxHeight: pos.maxHeight },
|
|
396
390
|
children: [
|
|
391
|
+
__twcStyles,
|
|
397
392
|
header ? /* @__PURE__ */ jsx("div", { className: "twc-menu__header", children: header }) : null,
|
|
398
393
|
items.map((it, i) => {
|
|
399
394
|
if (it.separator) return /* @__PURE__ */ jsx("div", { className: "twc-menu__sep", role: "separator" }, `s${i}`);
|
|
@@ -427,7 +422,7 @@ function Menu({
|
|
|
427
422
|
}
|
|
428
423
|
) : null;
|
|
429
424
|
const activeDescId = open && active >= 0 ? `${menuId}-item-${active}` : void 0;
|
|
430
|
-
const triggerEl =
|
|
425
|
+
const triggerEl = React23__default.isValidElement(trigger) ? React23__default.cloneElement(trigger, {
|
|
431
426
|
onClick: (e) => {
|
|
432
427
|
trigger.props.onClick?.(e);
|
|
433
428
|
toggle();
|
|
@@ -481,13 +476,7 @@ function AvatarMenu({
|
|
|
481
476
|
className = "",
|
|
482
477
|
...rest
|
|
483
478
|
}) {
|
|
484
|
-
|
|
485
|
-
if (document.getElementById("twc-avatar-menu-styles")) return;
|
|
486
|
-
const el = document.createElement("style");
|
|
487
|
-
el.id = "twc-avatar-menu-styles";
|
|
488
|
-
el.textContent = AVATARMENU_CSS;
|
|
489
|
-
document.head.appendChild(el);
|
|
490
|
-
}, []);
|
|
479
|
+
const __twcStyles = useScopedStyles("twc-avatar-menu-styles", AVATARMENU_CSS);
|
|
491
480
|
const sub = subtitle ?? email;
|
|
492
481
|
const showChev = showChevron ?? showName;
|
|
493
482
|
const header = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -506,6 +495,7 @@ function AvatarMenu({
|
|
|
506
495
|
"aria-haspopup": "menu",
|
|
507
496
|
"aria-label": `${name || "Account"} menu`,
|
|
508
497
|
children: [
|
|
498
|
+
__twcStyles,
|
|
509
499
|
/* @__PURE__ */ jsx(Avatar, { name, src, size, status }),
|
|
510
500
|
showName ? /* @__PURE__ */ jsxs("span", { className: "twc-avatar-menu__text", children: [
|
|
511
501
|
/* @__PURE__ */ jsx("span", { className: "twc-avatar-menu__name", children: name }),
|
|
@@ -563,14 +553,9 @@ function Badge({
|
|
|
563
553
|
className = "",
|
|
564
554
|
...rest
|
|
565
555
|
}) {
|
|
566
|
-
|
|
567
|
-
if (document.getElementById("twc-badge-styles")) return;
|
|
568
|
-
const el = document.createElement("style");
|
|
569
|
-
el.id = "twc-badge-styles";
|
|
570
|
-
el.textContent = BADGE_CSS;
|
|
571
|
-
document.head.appendChild(el);
|
|
572
|
-
}, []);
|
|
556
|
+
const __twcStyles = useScopedStyles("twc-badge-styles", BADGE_CSS);
|
|
573
557
|
return /* @__PURE__ */ jsxs("span", { className: `twc-badge ${className}`, "data-tone": tone, "data-variant": variant, "data-size": size, ...rest, children: [
|
|
558
|
+
__twcStyles,
|
|
574
559
|
dot ? /* @__PURE__ */ jsx("span", { className: "twc-badge__dot" }) : null,
|
|
575
560
|
children
|
|
576
561
|
] });
|
|
@@ -600,14 +585,8 @@ function Breadcrumb({
|
|
|
600
585
|
className = "",
|
|
601
586
|
...rest
|
|
602
587
|
}) {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
const el = document.createElement("style");
|
|
606
|
-
el.id = "twc-breadcrumb-styles";
|
|
607
|
-
el.textContent = BREADCRUMB_CSS;
|
|
608
|
-
document.head.appendChild(el);
|
|
609
|
-
}, []);
|
|
610
|
-
const [expanded, setExpanded] = React22.useState(false);
|
|
588
|
+
const __twcStyles = useScopedStyles("twc-breadcrumb-styles", BREADCRUMB_CSS);
|
|
589
|
+
const [expanded, setExpanded] = React23__default.useState(false);
|
|
611
590
|
const sep = separator || /* @__PURE__ */ jsx(ChevronSep, {});
|
|
612
591
|
let display = items;
|
|
613
592
|
if (maxItems > 0 && items.length > maxItems && !expanded) {
|
|
@@ -616,35 +595,38 @@ function Breadcrumb({
|
|
|
616
595
|
const tail = items.slice(items.length - keepTail);
|
|
617
596
|
display = [...head, { ellipsis: true }, ...tail];
|
|
618
597
|
}
|
|
619
|
-
return /* @__PURE__ */
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
{
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
598
|
+
return /* @__PURE__ */ jsxs("nav", { className: `twc-breadcrumb ${className}`, "aria-label": "Breadcrumb", ...rest, children: [
|
|
599
|
+
__twcStyles,
|
|
600
|
+
display.map((it, i) => {
|
|
601
|
+
const last = i === display.length - 1;
|
|
602
|
+
return /* @__PURE__ */ jsxs(React23__default.Fragment, { children: [
|
|
603
|
+
it.ellipsis ? /* @__PURE__ */ jsx("button", { className: "twc-breadcrumb__ellipsis", "aria-label": "Show more", onClick: () => setExpanded(true), children: "\u2026" }) : last ? /* @__PURE__ */ jsxs(
|
|
604
|
+
"span",
|
|
605
|
+
{
|
|
606
|
+
className: "twc-breadcrumb__item",
|
|
607
|
+
"aria-current": "page",
|
|
608
|
+
onClick: it.onClick,
|
|
609
|
+
children: [
|
|
610
|
+
it.icon ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { display: "inline-flex" }, children: it.icon }) : null,
|
|
611
|
+
it.label
|
|
612
|
+
]
|
|
613
|
+
}
|
|
614
|
+
) : /* @__PURE__ */ jsxs(
|
|
615
|
+
"a",
|
|
616
|
+
{
|
|
617
|
+
className: "twc-breadcrumb__item",
|
|
618
|
+
href: safeHref(it.href) || "#",
|
|
619
|
+
onClick: it.onClick,
|
|
620
|
+
children: [
|
|
621
|
+
it.icon ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { display: "inline-flex" }, children: it.icon }) : null,
|
|
622
|
+
it.label
|
|
623
|
+
]
|
|
624
|
+
}
|
|
625
|
+
),
|
|
626
|
+
!last ? /* @__PURE__ */ jsx("span", { className: "twc-breadcrumb__sep", "aria-hidden": "true", children: sep }) : null
|
|
627
|
+
] }, i);
|
|
628
|
+
})
|
|
629
|
+
] });
|
|
648
630
|
}
|
|
649
631
|
var CSS2 = `
|
|
650
632
|
.twc-btn {
|
|
@@ -741,15 +723,6 @@ function safeHref2(url) {
|
|
|
741
723
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
742
724
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
743
725
|
}
|
|
744
|
-
function useInjectedStyle(id, css) {
|
|
745
|
-
React22.useInsertionEffect(() => {
|
|
746
|
-
if (document.getElementById(id)) return;
|
|
747
|
-
const el = document.createElement("style");
|
|
748
|
-
el.id = id;
|
|
749
|
-
el.textContent = css;
|
|
750
|
-
document.head.appendChild(el);
|
|
751
|
-
}, [id, css]);
|
|
752
|
-
}
|
|
753
726
|
function Button({
|
|
754
727
|
children,
|
|
755
728
|
variant = "solid",
|
|
@@ -766,8 +739,8 @@ function Button({
|
|
|
766
739
|
onClick,
|
|
767
740
|
...rest
|
|
768
741
|
}) {
|
|
769
|
-
|
|
770
|
-
const [ripples, setRipples] =
|
|
742
|
+
const __twcStyles = useScopedStyles("twc-btn-styles", CSS2);
|
|
743
|
+
const [ripples, setRipples] = React23__default.useState([]);
|
|
771
744
|
const Tag2 = as;
|
|
772
745
|
const inert = Tag2 === "a" && (disabled || loading);
|
|
773
746
|
function handleClick(e) {
|
|
@@ -803,6 +776,7 @@ function Button({
|
|
|
803
776
|
onClick: handleClick,
|
|
804
777
|
...rest,
|
|
805
778
|
children: [
|
|
779
|
+
__twcStyles,
|
|
806
780
|
/* @__PURE__ */ jsxs("span", { className: "twc-btn__content", children: [
|
|
807
781
|
leftIcon ? /* @__PURE__ */ jsx("span", { className: "twc-btn__icon", "aria-hidden": "true", children: leftIcon }) : null,
|
|
808
782
|
children,
|
|
@@ -860,13 +834,7 @@ function Card({
|
|
|
860
834
|
className = "",
|
|
861
835
|
...rest
|
|
862
836
|
}) {
|
|
863
|
-
|
|
864
|
-
if (document.getElementById("twc-card-styles")) return;
|
|
865
|
-
const el = document.createElement("style");
|
|
866
|
-
el.id = "twc-card-styles";
|
|
867
|
-
el.textContent = CARD_CSS;
|
|
868
|
-
document.head.appendChild(el);
|
|
869
|
-
}, []);
|
|
837
|
+
const __twcStyles = useScopedStyles("twc-card-styles", CARD_CSS);
|
|
870
838
|
return /* @__PURE__ */ jsxs(
|
|
871
839
|
"div",
|
|
872
840
|
{
|
|
@@ -877,6 +845,7 @@ function Card({
|
|
|
877
845
|
"data-full": fullHeight || void 0,
|
|
878
846
|
...rest,
|
|
879
847
|
children: [
|
|
848
|
+
__twcStyles,
|
|
880
849
|
title || subtitle ? /* @__PURE__ */ jsxs("div", { className: "twc-card__header", children: [
|
|
881
850
|
title ? /* @__PURE__ */ jsx("div", { className: "twc-card__title", children: title }) : null,
|
|
882
851
|
subtitle ? /* @__PURE__ */ jsx("div", { className: "twc-card__subtitle", children: subtitle }) : null
|
|
@@ -922,26 +891,20 @@ function Carousel({
|
|
|
922
891
|
className = "",
|
|
923
892
|
...rest
|
|
924
893
|
}) {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
const el = document.createElement("style");
|
|
928
|
-
el.id = "twc-carousel-styles";
|
|
929
|
-
el.textContent = CAROUSEL_CSS;
|
|
930
|
-
document.head.appendChild(el);
|
|
931
|
-
}, []);
|
|
932
|
-
const slides = React22.Children.toArray(children);
|
|
894
|
+
const __twcStyles = useScopedStyles("twc-carousel-styles", CAROUSEL_CSS);
|
|
895
|
+
const slides = React23__default.Children.toArray(children);
|
|
933
896
|
const count = slides.length;
|
|
934
|
-
const [internal, setInternal] =
|
|
897
|
+
const [internal, setInternal] = React23__default.useState(defaultIndex);
|
|
935
898
|
const index = indexProp !== void 0 ? indexProp : internal;
|
|
936
|
-
const [paused, setPaused] =
|
|
937
|
-
const setIndex =
|
|
899
|
+
const [paused, setPaused] = React23__default.useState(false);
|
|
900
|
+
const setIndex = React23__default.useCallback((i) => {
|
|
938
901
|
if (indexProp === void 0) setInternal(i);
|
|
939
902
|
onIndexChange?.(i);
|
|
940
903
|
}, [indexProp, onIndexChange]);
|
|
941
|
-
const go =
|
|
904
|
+
const go = React23__default.useCallback((i) => {
|
|
942
905
|
setIndex(loop ? (i + count) % count : Math.min(Math.max(i, 0), count - 1));
|
|
943
906
|
}, [count, loop, setIndex]);
|
|
944
|
-
|
|
907
|
+
React23__default.useEffect(() => {
|
|
945
908
|
if (!autoPlay || paused || count <= 1) return;
|
|
946
909
|
const t = setInterval(() => {
|
|
947
910
|
const next = loop ? (index + 1) % count : index + 1 >= count ? index : index + 1;
|
|
@@ -963,6 +926,7 @@ function Carousel({
|
|
|
963
926
|
"aria-roledescription": "carousel",
|
|
964
927
|
...rest,
|
|
965
928
|
children: [
|
|
929
|
+
__twcStyles,
|
|
966
930
|
/* @__PURE__ */ jsx("div", { className: "twc-carousel__viewport", children: /* @__PURE__ */ jsx("div", { className: "twc-carousel__track", style: { transform: `translateX(-${index * 100}%)` }, children: slides.map((s, i) => /* @__PURE__ */ jsx("div", { className: "twc-carousel__slide", role: "group", "aria-roledescription": "slide", "aria-label": `${i + 1} of ${count}`, "aria-hidden": i !== index || void 0, inert: i !== index || void 0, children: s }, i)) }) }),
|
|
967
931
|
showArrows && count > 1 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
968
932
|
/* @__PURE__ */ jsx("button", { className: "twc-carousel__arrow", "data-dir": "prev", "aria-label": "Previous", disabled: atStart, onClick: () => go(index - 1), children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" }) }) }),
|
|
@@ -1003,13 +967,7 @@ function Chart({
|
|
|
1003
967
|
className = "",
|
|
1004
968
|
...rest
|
|
1005
969
|
}) {
|
|
1006
|
-
|
|
1007
|
-
if (document.getElementById("twc-chart-styles")) return;
|
|
1008
|
-
const el = document.createElement("style");
|
|
1009
|
-
el.id = "twc-chart-styles";
|
|
1010
|
-
el.textContent = CHART_CSS;
|
|
1011
|
-
document.head.appendChild(el);
|
|
1012
|
-
}, []);
|
|
970
|
+
const __twcStyles = useScopedStyles("twc-chart-styles", CHART_CSS);
|
|
1013
971
|
const keys = series || ["value"];
|
|
1014
972
|
const palette = colors && colors.length ? colors : SERIES_COLORS;
|
|
1015
973
|
const W = 600, H = height, padL = showAxis ? 40 : 8, padR = 8, padT = 12, padB = showAxis ? 26 : 8;
|
|
@@ -1021,6 +979,7 @@ function Chart({
|
|
|
1021
979
|
const ticks = 4;
|
|
1022
980
|
const svgAriaLabel = ariaLabelProp ?? ariaLabel ?? `${type} chart`;
|
|
1023
981
|
return /* @__PURE__ */ jsxs("div", { className: `twc-chart ${className}`, ...rest, children: [
|
|
982
|
+
__twcStyles,
|
|
1024
983
|
/* @__PURE__ */ jsxs("svg", { viewBox: `0 0 ${W} ${H}`, role: "img", "aria-label": svgAriaLabel, preserveAspectRatio: "none", children: [
|
|
1025
984
|
showGrid ? Array.from({ length: ticks + 1 }).map((_, i) => {
|
|
1026
985
|
const gy = padT + innerH / ticks * i;
|
|
@@ -1104,11 +1063,7 @@ function Checkbox({
|
|
|
1104
1063
|
onChange,
|
|
1105
1064
|
...rest
|
|
1106
1065
|
}) {
|
|
1107
|
-
|
|
1108
|
-
if (document.getElementById("twc-checkbox-styles")) return;
|
|
1109
|
-
const el = document.createElement("style");
|
|
1110
|
-
el.id = "twc-checkbox-styles";
|
|
1111
|
-
el.textContent = `
|
|
1066
|
+
const __twcStyles = useScopedStyles("twc-checkbox-styles", `
|
|
1112
1067
|
.twc-check { display: inline-flex; align-items: flex-start; gap: var(--space-2-5); cursor: pointer; font-family: var(--font-sans); }
|
|
1113
1068
|
/* tone \u2192 accent set (default primary). Mirrors Button's --_accent model; Badge's tone vocabulary. */
|
|
1114
1069
|
.twc-check { --_accent: var(--color-primary); --_accent-fg: var(--color-primary-fg); --_accent-subtle: var(--color-primary-subtle); --_accent-subtle-fg: var(--color-primary-subtle-fg); --_accent-border: var(--color-primary-border); }
|
|
@@ -1146,19 +1101,18 @@ function Checkbox({
|
|
|
1146
1101
|
.twc-check__desc { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
1147
1102
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
1148
1103
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
}, []);
|
|
1152
|
-
const autoId = React22.useId();
|
|
1104
|
+
`);
|
|
1105
|
+
const autoId = React23__default.useId();
|
|
1153
1106
|
const fieldId = id || autoId;
|
|
1154
1107
|
const errId = `${fieldId}-error`;
|
|
1155
1108
|
const invalid = Boolean(error);
|
|
1156
|
-
const ref =
|
|
1157
|
-
|
|
1109
|
+
const ref = React23__default.useRef(null);
|
|
1110
|
+
React23__default.useEffect(() => {
|
|
1158
1111
|
if (ref.current) ref.current.indeterminate = indeterminate;
|
|
1159
1112
|
}, [indeterminate]);
|
|
1160
1113
|
const describedBy = [rest["aria-describedby"], error ? errId : null].filter(Boolean).join(" ") || void 0;
|
|
1161
1114
|
const control = /* @__PURE__ */ jsxs("label", { className: `twc-check ${className}`, "data-size": size, "data-tone": tone, "data-invalid": invalid || void 0, "data-disabled": disabled || void 0, htmlFor: fieldId, children: [
|
|
1115
|
+
__twcStyles,
|
|
1162
1116
|
/* @__PURE__ */ jsx(
|
|
1163
1117
|
"input",
|
|
1164
1118
|
{
|
|
@@ -1288,33 +1242,22 @@ function ColorPicker({
|
|
|
1288
1242
|
className = "",
|
|
1289
1243
|
...rest
|
|
1290
1244
|
}) {
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
fel.id = "twc-field-styles";
|
|
1295
|
-
fel.textContent = FIELD_CSS;
|
|
1296
|
-
document.head.appendChild(fel);
|
|
1297
|
-
}
|
|
1298
|
-
if (document.getElementById("twc-colorpicker-styles")) return;
|
|
1299
|
-
const el = document.createElement("style");
|
|
1300
|
-
el.id = "twc-colorpicker-styles";
|
|
1301
|
-
el.textContent = COLORPICKER_CSS;
|
|
1302
|
-
document.head.appendChild(el);
|
|
1303
|
-
}, []);
|
|
1304
|
-
const [internal, setInternal] = React22.useState(defaultValue);
|
|
1245
|
+
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS);
|
|
1246
|
+
const __twcStyles1 = useScopedStyles("twc-colorpicker-styles", COLORPICKER_CSS);
|
|
1247
|
+
const [internal, setInternal] = React23__default.useState(defaultValue);
|
|
1305
1248
|
const hex = (value !== void 0 ? value : internal) || "#000000";
|
|
1306
|
-
const lastValidRef =
|
|
1249
|
+
const lastValidRef = React23__default.useRef(hex);
|
|
1307
1250
|
if (/^#[0-9a-f]{6}$/i.test(hex)) lastValidRef.current = hex;
|
|
1308
|
-
const [open, setOpen] =
|
|
1309
|
-
const [hsv, setHsv] =
|
|
1310
|
-
const [coords, setCoords] =
|
|
1311
|
-
const wrapRef =
|
|
1312
|
-
const triggerRef =
|
|
1313
|
-
const popRef =
|
|
1314
|
-
const areaRef =
|
|
1315
|
-
const hueRef =
|
|
1251
|
+
const [open, setOpen] = React23__default.useState(false);
|
|
1252
|
+
const [hsv, setHsv] = React23__default.useState(() => hexToHsv(hex) || { h: 239, s: 60, v: 94 });
|
|
1253
|
+
const [coords, setCoords] = React23__default.useState(null);
|
|
1254
|
+
const wrapRef = React23__default.useRef(null);
|
|
1255
|
+
const triggerRef = React23__default.useRef(null);
|
|
1256
|
+
const popRef = React23__default.useRef(null);
|
|
1257
|
+
const areaRef = React23__default.useRef(null);
|
|
1258
|
+
const hueRef = React23__default.useRef(null);
|
|
1316
1259
|
const POP_W = 240;
|
|
1317
|
-
const place =
|
|
1260
|
+
const place = React23__default.useCallback(() => {
|
|
1318
1261
|
const el = triggerRef.current;
|
|
1319
1262
|
if (!el) return;
|
|
1320
1263
|
const r = el.getBoundingClientRect();
|
|
@@ -1325,7 +1268,7 @@ function ColorPicker({
|
|
|
1325
1268
|
left = Math.max(8, left);
|
|
1326
1269
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
1327
1270
|
}, []);
|
|
1328
|
-
|
|
1271
|
+
React23__default.useEffect(() => {
|
|
1329
1272
|
if (!open) return void 0;
|
|
1330
1273
|
place();
|
|
1331
1274
|
const onMove = () => place();
|
|
@@ -1336,17 +1279,17 @@ function ColorPicker({
|
|
|
1336
1279
|
window.removeEventListener("resize", onMove);
|
|
1337
1280
|
};
|
|
1338
1281
|
}, [open, place]);
|
|
1339
|
-
const labelId =
|
|
1282
|
+
const labelId = React23__default.useId();
|
|
1340
1283
|
const descId = `${labelId}-desc`;
|
|
1341
1284
|
const invalid = Boolean(error);
|
|
1342
|
-
|
|
1285
|
+
React23__default.useEffect(() => {
|
|
1343
1286
|
if (disabled) setOpen(false);
|
|
1344
1287
|
}, [disabled]);
|
|
1345
|
-
|
|
1288
|
+
React23__default.useEffect(() => {
|
|
1346
1289
|
const v = hexToHsv(hex);
|
|
1347
1290
|
if (v && hsvToHex(v.h, v.s, v.v).toLowerCase() !== hsvToHex(hsv.h, hsv.s, hsv.v).toLowerCase()) setHsv(v);
|
|
1348
1291
|
}, [hex]);
|
|
1349
|
-
|
|
1292
|
+
React23__default.useEffect(() => {
|
|
1350
1293
|
if (!open) return;
|
|
1351
1294
|
const onDown = (e) => {
|
|
1352
1295
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -1363,8 +1306,8 @@ function ColorPicker({
|
|
|
1363
1306
|
document.removeEventListener("keydown", onKey);
|
|
1364
1307
|
};
|
|
1365
1308
|
}, [open]);
|
|
1366
|
-
const prevOpen =
|
|
1367
|
-
|
|
1309
|
+
const prevOpen = React23__default.useRef(false);
|
|
1310
|
+
React23__default.useEffect(() => {
|
|
1368
1311
|
let id;
|
|
1369
1312
|
if (!prevOpen.current && open) {
|
|
1370
1313
|
id = setTimeout(() => areaRef.current?.focus({ preventScroll: true }), 20);
|
|
@@ -1424,6 +1367,8 @@ function ColorPicker({
|
|
|
1424
1367
|
commit({ ...hsv, h });
|
|
1425
1368
|
};
|
|
1426
1369
|
return /* @__PURE__ */ jsxs("div", { className: `twc-cp twc-field ${className}`, ref: wrapRef, ...rest, children: [
|
|
1370
|
+
__twcStyles0,
|
|
1371
|
+
__twcStyles1,
|
|
1427
1372
|
label ? /* @__PURE__ */ jsxs("span", { className: "twc-field__label", id: labelId, children: [
|
|
1428
1373
|
label,
|
|
1429
1374
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -1681,36 +1626,30 @@ function Combobox({
|
|
|
1681
1626
|
onKeyDown,
|
|
1682
1627
|
...rest
|
|
1683
1628
|
}) {
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
el.textContent = COMBO_CSS;
|
|
1689
|
-
document.head.appendChild(el);
|
|
1690
|
-
}, []);
|
|
1691
|
-
const groups = React22.useMemo(() => normalizeGroups(options), [options]);
|
|
1692
|
-
const flat = React22.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
1693
|
-
const autoId = React22.useId();
|
|
1629
|
+
const __twcStyles = useScopedStyles("twc-combo-styles", COMBO_CSS);
|
|
1630
|
+
const groups = React23__default.useMemo(() => normalizeGroups(options), [options]);
|
|
1631
|
+
const flat = React23__default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
1632
|
+
const autoId = React23__default.useId();
|
|
1694
1633
|
const fieldId = id || autoId;
|
|
1695
|
-
const [internal, setInternal] =
|
|
1634
|
+
const [internal, setInternal] = React23__default.useState(defaultValue);
|
|
1696
1635
|
const current = value !== void 0 ? value : internal;
|
|
1697
1636
|
const selected = flat.find((o) => o.value === current);
|
|
1698
|
-
const [open, setOpen] =
|
|
1699
|
-
const [query, setQuery] =
|
|
1700
|
-
const [active, setActive] =
|
|
1701
|
-
const [coords, setCoords] =
|
|
1702
|
-
const wrapRef =
|
|
1703
|
-
const controlRef =
|
|
1704
|
-
const inputRef =
|
|
1705
|
-
const popRef =
|
|
1706
|
-
const listRef =
|
|
1707
|
-
const activeRef =
|
|
1708
|
-
const fGroups =
|
|
1637
|
+
const [open, setOpen] = React23__default.useState(false);
|
|
1638
|
+
const [query, setQuery] = React23__default.useState("");
|
|
1639
|
+
const [active, setActive] = React23__default.useState(0);
|
|
1640
|
+
const [coords, setCoords] = React23__default.useState(null);
|
|
1641
|
+
const wrapRef = React23__default.useRef(null);
|
|
1642
|
+
const controlRef = React23__default.useRef(null);
|
|
1643
|
+
const inputRef = React23__default.useRef(null);
|
|
1644
|
+
const popRef = React23__default.useRef(null);
|
|
1645
|
+
const listRef = React23__default.useRef(null);
|
|
1646
|
+
const activeRef = React23__default.useRef(null);
|
|
1647
|
+
const fGroups = React23__default.useMemo(
|
|
1709
1648
|
() => groups.map((g) => ({ group: g.group, options: g.options.filter((o) => matches(o, query.trim())) })).filter((g) => g.options.length),
|
|
1710
1649
|
[groups, query]
|
|
1711
1650
|
);
|
|
1712
|
-
const visible =
|
|
1713
|
-
const place =
|
|
1651
|
+
const visible = React23__default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
1652
|
+
const place = React23__default.useCallback(() => {
|
|
1714
1653
|
const el = controlRef.current;
|
|
1715
1654
|
if (!el) return;
|
|
1716
1655
|
const r = el.getBoundingClientRect();
|
|
@@ -1725,7 +1664,7 @@ function Combobox({
|
|
|
1725
1664
|
flip
|
|
1726
1665
|
});
|
|
1727
1666
|
}, [placement, minWidth]);
|
|
1728
|
-
|
|
1667
|
+
React23__default.useEffect(() => {
|
|
1729
1668
|
if (!open || !portal) return;
|
|
1730
1669
|
place();
|
|
1731
1670
|
const onMove = () => place();
|
|
@@ -1736,7 +1675,7 @@ function Combobox({
|
|
|
1736
1675
|
window.removeEventListener("resize", onMove);
|
|
1737
1676
|
};
|
|
1738
1677
|
}, [open, portal, place]);
|
|
1739
|
-
|
|
1678
|
+
React23__default.useEffect(() => {
|
|
1740
1679
|
if (!open) return;
|
|
1741
1680
|
const onDown = (e) => {
|
|
1742
1681
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -1746,10 +1685,10 @@ function Combobox({
|
|
|
1746
1685
|
document.addEventListener("mousedown", onDown);
|
|
1747
1686
|
return () => document.removeEventListener("mousedown", onDown);
|
|
1748
1687
|
}, [open]);
|
|
1749
|
-
|
|
1688
|
+
React23__default.useEffect(() => {
|
|
1750
1689
|
setActive(0);
|
|
1751
1690
|
}, [query]);
|
|
1752
|
-
|
|
1691
|
+
React23__default.useEffect(() => {
|
|
1753
1692
|
if (open) ensureVisible(listRef.current, activeRef.current);
|
|
1754
1693
|
}, [active, open]);
|
|
1755
1694
|
function openMenu() {
|
|
@@ -1792,7 +1731,7 @@ function Combobox({
|
|
|
1792
1731
|
const descId = `${fieldId}-desc`;
|
|
1793
1732
|
const describedBy = error || hint ? descId : void 0;
|
|
1794
1733
|
let counter = -1;
|
|
1795
|
-
const popInner = /* @__PURE__ */ jsx("div", { className: "twc-pop__list", ref: listRef, children: visible.length === 0 ? /* @__PURE__ */ jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxs(
|
|
1734
|
+
const popInner = /* @__PURE__ */ jsx("div", { className: "twc-pop__list", ref: listRef, children: visible.length === 0 ? /* @__PURE__ */ jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxs(React23__default.Fragment, { children: [
|
|
1796
1735
|
g.group ? /* @__PURE__ */ jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
1797
1736
|
g.options.map((o) => {
|
|
1798
1737
|
counter += 1;
|
|
@@ -1849,6 +1788,7 @@ function Combobox({
|
|
|
1849
1788
|
}
|
|
1850
1789
|
}
|
|
1851
1790
|
return /* @__PURE__ */ jsxs("div", { className: `twc-field ${className}`, ref: wrapRef, children: [
|
|
1791
|
+
__twcStyles,
|
|
1852
1792
|
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
1853
1793
|
label,
|
|
1854
1794
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -1973,21 +1913,15 @@ function CommandPalette({
|
|
|
1973
1913
|
className = "",
|
|
1974
1914
|
...rest
|
|
1975
1915
|
}) {
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
const [
|
|
1984
|
-
|
|
1985
|
-
const inputRef = React22.useRef(null);
|
|
1986
|
-
const listRef = React22.useRef(null);
|
|
1987
|
-
const paletteRef = React22.useRef(null);
|
|
1988
|
-
const baseId = React22.useId();
|
|
1989
|
-
const [mounted, setMounted] = React22.useState(open);
|
|
1990
|
-
React22.useEffect(() => {
|
|
1916
|
+
const __twcStyles = useScopedStyles("twc-cmdk-styles", COMMAND_CSS);
|
|
1917
|
+
const [query, setQuery] = React23__default.useState("");
|
|
1918
|
+
const [active, setActive] = React23__default.useState(0);
|
|
1919
|
+
const inputRef = React23__default.useRef(null);
|
|
1920
|
+
const listRef = React23__default.useRef(null);
|
|
1921
|
+
const paletteRef = React23__default.useRef(null);
|
|
1922
|
+
const baseId = React23__default.useId();
|
|
1923
|
+
const [mounted, setMounted] = React23__default.useState(open);
|
|
1924
|
+
React23__default.useEffect(() => {
|
|
1991
1925
|
if (open) {
|
|
1992
1926
|
setMounted(true);
|
|
1993
1927
|
return;
|
|
@@ -1995,7 +1929,7 @@ function CommandPalette({
|
|
|
1995
1929
|
const t = setTimeout(() => setMounted(false), 170);
|
|
1996
1930
|
return () => clearTimeout(t);
|
|
1997
1931
|
}, [open]);
|
|
1998
|
-
|
|
1932
|
+
React23__default.useEffect(() => {
|
|
1999
1933
|
if (!open) return void 0;
|
|
2000
1934
|
const prev = document.body.style.overflow;
|
|
2001
1935
|
document.body.style.overflow = "hidden";
|
|
@@ -2003,7 +1937,7 @@ function CommandPalette({
|
|
|
2003
1937
|
document.body.style.overflow = prev;
|
|
2004
1938
|
};
|
|
2005
1939
|
}, [open]);
|
|
2006
|
-
|
|
1940
|
+
React23__default.useEffect(() => {
|
|
2007
1941
|
if (open) {
|
|
2008
1942
|
setQuery("");
|
|
2009
1943
|
setActive(0);
|
|
@@ -2011,14 +1945,14 @@ function CommandPalette({
|
|
|
2011
1945
|
return () => clearTimeout(t);
|
|
2012
1946
|
}
|
|
2013
1947
|
}, [open]);
|
|
2014
|
-
|
|
1948
|
+
React23__default.useEffect(() => {
|
|
2015
1949
|
if (!open) return;
|
|
2016
1950
|
const prevFocused = document.activeElement;
|
|
2017
1951
|
return () => {
|
|
2018
1952
|
if (prevFocused && typeof prevFocused.focus === "function") prevFocused.focus();
|
|
2019
1953
|
};
|
|
2020
1954
|
}, [open]);
|
|
2021
|
-
|
|
1955
|
+
React23__default.useEffect(() => {
|
|
2022
1956
|
if (!open) return;
|
|
2023
1957
|
const focusables = (node) => node ? Array.from(
|
|
2024
1958
|
node.querySelectorAll(
|
|
@@ -2054,7 +1988,7 @@ function CommandPalette({
|
|
|
2054
1988
|
return () => document.removeEventListener("keydown", onKey);
|
|
2055
1989
|
}, [open, onClose]);
|
|
2056
1990
|
const q = query.trim().toLowerCase();
|
|
2057
|
-
const filtered =
|
|
1991
|
+
const filtered = React23__default.useMemo(() => commands.filter(
|
|
2058
1992
|
(c) => !q || c.label.toLowerCase().includes(q) || (c.keywords || "").toLowerCase().includes(q) || (c.group || "").toLowerCase().includes(q)
|
|
2059
1993
|
), [commands, q]);
|
|
2060
1994
|
const groups = [];
|
|
@@ -2069,7 +2003,7 @@ function CommandPalette({
|
|
|
2069
2003
|
g.items.push(c);
|
|
2070
2004
|
flat.push(c);
|
|
2071
2005
|
});
|
|
2072
|
-
|
|
2006
|
+
React23__default.useEffect(() => {
|
|
2073
2007
|
setActive(0);
|
|
2074
2008
|
}, [query]);
|
|
2075
2009
|
const run = (cmd) => {
|
|
@@ -2089,7 +2023,7 @@ function CommandPalette({
|
|
|
2089
2023
|
if (cmd) run(cmd);
|
|
2090
2024
|
}
|
|
2091
2025
|
}
|
|
2092
|
-
|
|
2026
|
+
React23__default.useEffect(() => {
|
|
2093
2027
|
const node = listRef.current?.querySelector('[data-active="true"]');
|
|
2094
2028
|
if (node) node.scrollIntoView({ block: "nearest" });
|
|
2095
2029
|
}, [active]);
|
|
@@ -2099,63 +2033,66 @@ function CommandPalette({
|
|
|
2099
2033
|
const optionId = (i) => `${baseId}-opt-${i}`;
|
|
2100
2034
|
const activeId = flat[active] ? optionId(active) : void 0;
|
|
2101
2035
|
let idx = -1;
|
|
2102
|
-
const overlay = /* @__PURE__ */
|
|
2036
|
+
const overlay = /* @__PURE__ */ jsxs("div", { className: "twc-cmdk__overlay", "data-state": state, onMouseDown: (e) => {
|
|
2103
2037
|
if (e.target === e.currentTarget) onClose?.();
|
|
2104
|
-
}, children:
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
/* @__PURE__ */
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
className: "twc-cmdk__input",
|
|
2115
|
-
value: query,
|
|
2116
|
-
placeholder,
|
|
2117
|
-
role: "combobox",
|
|
2118
|
-
"aria-expanded": "true",
|
|
2119
|
-
"aria-controls": listId,
|
|
2120
|
-
"aria-activedescendant": activeId,
|
|
2121
|
-
onChange: (e) => setQuery(e.target.value),
|
|
2122
|
-
onKeyDown
|
|
2123
|
-
}
|
|
2124
|
-
),
|
|
2125
|
-
/* @__PURE__ */ jsx("span", { className: "twc-cmdk__kbd", children: "esc" })
|
|
2126
|
-
] }),
|
|
2127
|
-
/* @__PURE__ */ jsx("div", { className: "twc-cmdk__list", id: listId, role: "listbox", ref: listRef, children: flat.length === 0 ? /* @__PURE__ */ jsx("div", { className: "twc-cmdk__empty", children: emptyText }) : groups.map((g) => /* @__PURE__ */ jsxs("div", { role: "group", children: [
|
|
2128
|
-
g.key ? /* @__PURE__ */ jsx("div", { className: "twc-cmdk__group-label", children: g.key }) : null,
|
|
2129
|
-
g.items.map((c) => {
|
|
2130
|
-
idx += 1;
|
|
2131
|
-
const i = idx;
|
|
2132
|
-
return /* @__PURE__ */ jsxs(
|
|
2133
|
-
"button",
|
|
2038
|
+
}, children: [
|
|
2039
|
+
__twcStyles,
|
|
2040
|
+
/* @__PURE__ */ jsxs("div", { ref: paletteRef, className: `twc-cmdk ${className}`, "data-state": state, role: "dialog", "aria-modal": "true", "aria-label": "Command palette", tabIndex: -1, ...rest, children: [
|
|
2041
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-cmdk__search", children: [
|
|
2042
|
+
/* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2043
|
+
/* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "8" }),
|
|
2044
|
+
/* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" })
|
|
2045
|
+
] }),
|
|
2046
|
+
/* @__PURE__ */ jsx(
|
|
2047
|
+
"input",
|
|
2134
2048
|
{
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
"
|
|
2140
|
-
|
|
2141
|
-
"
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2049
|
+
ref: inputRef,
|
|
2050
|
+
className: "twc-cmdk__input",
|
|
2051
|
+
value: query,
|
|
2052
|
+
placeholder,
|
|
2053
|
+
role: "combobox",
|
|
2054
|
+
"aria-expanded": "true",
|
|
2055
|
+
"aria-controls": listId,
|
|
2056
|
+
"aria-activedescendant": activeId,
|
|
2057
|
+
onChange: (e) => setQuery(e.target.value),
|
|
2058
|
+
onKeyDown
|
|
2059
|
+
}
|
|
2060
|
+
),
|
|
2061
|
+
/* @__PURE__ */ jsx("span", { className: "twc-cmdk__kbd", children: "esc" })
|
|
2062
|
+
] }),
|
|
2063
|
+
/* @__PURE__ */ jsx("div", { className: "twc-cmdk__list", id: listId, role: "listbox", ref: listRef, children: flat.length === 0 ? /* @__PURE__ */ jsx("div", { className: "twc-cmdk__empty", children: emptyText }) : groups.map((g) => /* @__PURE__ */ jsxs("div", { role: "group", children: [
|
|
2064
|
+
g.key ? /* @__PURE__ */ jsx("div", { className: "twc-cmdk__group-label", children: g.key }) : null,
|
|
2065
|
+
g.items.map((c) => {
|
|
2066
|
+
idx += 1;
|
|
2067
|
+
const i = idx;
|
|
2068
|
+
return /* @__PURE__ */ jsxs(
|
|
2069
|
+
"button",
|
|
2070
|
+
{
|
|
2071
|
+
id: optionId(i),
|
|
2072
|
+
type: "button",
|
|
2073
|
+
className: "twc-cmdk__item",
|
|
2074
|
+
role: "option",
|
|
2075
|
+
"aria-selected": i === active,
|
|
2076
|
+
tabIndex: -1,
|
|
2077
|
+
"data-active": i === active || void 0,
|
|
2078
|
+
onMouseEnter: () => setActive(i),
|
|
2079
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
2080
|
+
onClick: () => run(c),
|
|
2081
|
+
children: [
|
|
2082
|
+
c.icon ? /* @__PURE__ */ jsx("span", { className: "twc-cmdk__item-ic", "aria-hidden": "true", children: c.icon }) : null,
|
|
2083
|
+
/* @__PURE__ */ jsxs("span", { className: "twc-cmdk__item-main", children: [
|
|
2084
|
+
/* @__PURE__ */ jsx("span", { className: "twc-cmdk__item-label", children: c.label }),
|
|
2085
|
+
c.description ? /* @__PURE__ */ jsx("span", { className: "twc-cmdk__item-desc", children: c.description }) : null
|
|
2086
|
+
] }),
|
|
2087
|
+
c.shortcut ? /* @__PURE__ */ jsx("span", { className: "twc-cmdk__item-sc", children: c.shortcut }) : null
|
|
2088
|
+
]
|
|
2089
|
+
},
|
|
2090
|
+
c.id || i
|
|
2091
|
+
);
|
|
2092
|
+
})
|
|
2093
|
+
] }, g.key || "_")) })
|
|
2094
|
+
] })
|
|
2095
|
+
] });
|
|
2159
2096
|
const RD = typeof createPortal === "function" ? createPortal : null;
|
|
2160
2097
|
return RD ? RD(overlay, document.body) : overlay;
|
|
2161
2098
|
}
|
|
@@ -2234,15 +2171,6 @@ var CUR_CSS = `
|
|
|
2234
2171
|
.twc-cur__el::placeholder { color: var(--color-text-subtle); }
|
|
2235
2172
|
.twc-cur__el::-webkit-outer-spin-button, .twc-cur__el::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
|
|
2236
2173
|
`;
|
|
2237
|
-
function useCurStyles() {
|
|
2238
|
-
React22.useInsertionEffect(() => {
|
|
2239
|
-
if (document.getElementById("twc-cur-styles")) return;
|
|
2240
|
-
const el = document.createElement("style");
|
|
2241
|
-
el.id = "twc-cur-styles";
|
|
2242
|
-
el.textContent = CUR_CSS;
|
|
2243
|
-
document.head.appendChild(el);
|
|
2244
|
-
}, []);
|
|
2245
|
-
}
|
|
2246
2174
|
function Currency({
|
|
2247
2175
|
label,
|
|
2248
2176
|
hint,
|
|
@@ -2264,16 +2192,16 @@ function Currency({
|
|
|
2264
2192
|
className = "",
|
|
2265
2193
|
...rest
|
|
2266
2194
|
}) {
|
|
2267
|
-
|
|
2195
|
+
const __twcStyles = useScopedStyles("twc-cur-styles", CUR_CSS);
|
|
2268
2196
|
const meta = CURRENCIES[currency] || CURRENCIES.USD;
|
|
2269
2197
|
const prec = precision != null ? precision : meta.precision;
|
|
2270
2198
|
const sym = symbol != null ? symbol : meta.symbol;
|
|
2271
2199
|
const cur = code != null ? code : meta.code;
|
|
2272
|
-
const autoId =
|
|
2200
|
+
const autoId = React23__default.useId();
|
|
2273
2201
|
const fieldId = id || autoId;
|
|
2274
2202
|
const invalid = Boolean(error);
|
|
2275
2203
|
const controlled = value !== void 0;
|
|
2276
|
-
const [internal, setInternal] =
|
|
2204
|
+
const [internal, setInternal] = React23__default.useState(() => clampPrecision(String(defaultValue ?? ""), prec));
|
|
2277
2205
|
const shown = controlled ? clampPrecision(String(value ?? ""), prec) : internal;
|
|
2278
2206
|
const describedBy = [error ? `${fieldId}-error` : hint ? `${fieldId}-hint` : null, rest["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
2279
2207
|
function handleChange(e) {
|
|
@@ -2292,6 +2220,7 @@ function Currency({
|
|
|
2292
2220
|
onValueChange?.(Number(fixed), fixed);
|
|
2293
2221
|
}
|
|
2294
2222
|
return /* @__PURE__ */ jsxs("div", { className: `twc-field ${className}`, children: [
|
|
2223
|
+
__twcStyles,
|
|
2295
2224
|
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
2296
2225
|
label,
|
|
2297
2226
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -2445,39 +2374,33 @@ function Select({
|
|
|
2445
2374
|
onKeyDown,
|
|
2446
2375
|
...rest
|
|
2447
2376
|
}) {
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
el.textContent = SELECT_CSS;
|
|
2453
|
-
document.head.appendChild(el);
|
|
2454
|
-
}, []);
|
|
2455
|
-
const groups = React22.useMemo(() => normalizeGroups2(options), [options]);
|
|
2456
|
-
const flat = React22.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
2457
|
-
const autoId = React22.useId();
|
|
2377
|
+
const __twcStyles = useScopedStyles("twc-select-styles", SELECT_CSS);
|
|
2378
|
+
const groups = React23__default.useMemo(() => normalizeGroups2(options), [options]);
|
|
2379
|
+
const flat = React23__default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
2380
|
+
const autoId = React23__default.useId();
|
|
2458
2381
|
const fieldId = id || autoId;
|
|
2459
|
-
const [internal, setInternal] =
|
|
2382
|
+
const [internal, setInternal] = React23__default.useState(defaultValue);
|
|
2460
2383
|
const current = value !== void 0 ? value : internal;
|
|
2461
|
-
const [open, setOpen] =
|
|
2462
|
-
const [render, setRender] =
|
|
2463
|
-
const [active, setActive] =
|
|
2464
|
-
const [coords, setCoords] =
|
|
2465
|
-
const [query, setQuery] =
|
|
2466
|
-
const wrapRef =
|
|
2467
|
-
const triggerRef =
|
|
2468
|
-
const popRef =
|
|
2469
|
-
const listRef =
|
|
2470
|
-
const activeRef =
|
|
2471
|
-
const searchRef =
|
|
2384
|
+
const [open, setOpen] = React23__default.useState(false);
|
|
2385
|
+
const [render, setRender] = React23__default.useState(false);
|
|
2386
|
+
const [active, setActive] = React23__default.useState(0);
|
|
2387
|
+
const [coords, setCoords] = React23__default.useState(null);
|
|
2388
|
+
const [query, setQuery] = React23__default.useState("");
|
|
2389
|
+
const wrapRef = React23__default.useRef(null);
|
|
2390
|
+
const triggerRef = React23__default.useRef(null);
|
|
2391
|
+
const popRef = React23__default.useRef(null);
|
|
2392
|
+
const listRef = React23__default.useRef(null);
|
|
2393
|
+
const activeRef = React23__default.useRef(null);
|
|
2394
|
+
const searchRef = React23__default.useRef(null);
|
|
2472
2395
|
const showSearch = searchable === void 0 ? flat.length > 5 : searchable;
|
|
2473
|
-
const fGroups =
|
|
2396
|
+
const fGroups = React23__default.useMemo(() => {
|
|
2474
2397
|
const q = query.trim().toLowerCase();
|
|
2475
2398
|
if (!q) return groups;
|
|
2476
2399
|
return groups.map((g) => ({ group: g.group, options: g.options.filter((o) => o.label.toLowerCase().includes(q) || o.description && o.description.toLowerCase().includes(q)) })).filter((g) => g.options.length);
|
|
2477
2400
|
}, [groups, query]);
|
|
2478
|
-
const visible =
|
|
2401
|
+
const visible = React23__default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
2479
2402
|
const selected = flat.find((o) => o.value === current);
|
|
2480
|
-
const place =
|
|
2403
|
+
const place = React23__default.useCallback(() => {
|
|
2481
2404
|
const el = triggerRef.current;
|
|
2482
2405
|
if (!el) return;
|
|
2483
2406
|
const r = el.getBoundingClientRect();
|
|
@@ -2492,7 +2415,7 @@ function Select({
|
|
|
2492
2415
|
flip
|
|
2493
2416
|
});
|
|
2494
2417
|
}, [placement, minWidth]);
|
|
2495
|
-
|
|
2418
|
+
React23__default.useEffect(() => {
|
|
2496
2419
|
if (!open || !portal) return;
|
|
2497
2420
|
place();
|
|
2498
2421
|
const onMove = () => place();
|
|
@@ -2503,7 +2426,7 @@ function Select({
|
|
|
2503
2426
|
window.removeEventListener("resize", onMove);
|
|
2504
2427
|
};
|
|
2505
2428
|
}, [open, portal, place]);
|
|
2506
|
-
|
|
2429
|
+
React23__default.useEffect(() => {
|
|
2507
2430
|
if (!open) return;
|
|
2508
2431
|
const idx = flat.findIndex((o) => o.value === current);
|
|
2509
2432
|
setActive(idx >= 0 ? idx : 0);
|
|
@@ -2519,13 +2442,13 @@ function Select({
|
|
|
2519
2442
|
document.addEventListener("mousedown", onDown);
|
|
2520
2443
|
return () => document.removeEventListener("mousedown", onDown);
|
|
2521
2444
|
}, [open]);
|
|
2522
|
-
|
|
2445
|
+
React23__default.useEffect(() => {
|
|
2523
2446
|
setActive(0);
|
|
2524
2447
|
}, [query]);
|
|
2525
|
-
|
|
2448
|
+
React23__default.useEffect(() => {
|
|
2526
2449
|
if (open) ensureVisible2(listRef.current, activeRef.current);
|
|
2527
2450
|
}, [active, open]);
|
|
2528
|
-
|
|
2451
|
+
React23__default.useEffect(() => {
|
|
2529
2452
|
if (open) {
|
|
2530
2453
|
setRender(true);
|
|
2531
2454
|
return;
|
|
@@ -2533,8 +2456,8 @@ function Select({
|
|
|
2533
2456
|
const t = setTimeout(() => setRender(false), 170);
|
|
2534
2457
|
return () => clearTimeout(t);
|
|
2535
2458
|
}, [open]);
|
|
2536
|
-
const prevOpen =
|
|
2537
|
-
|
|
2459
|
+
const prevOpen = React23__default.useRef(false);
|
|
2460
|
+
React23__default.useEffect(() => {
|
|
2538
2461
|
if (prevOpen.current && !open) {
|
|
2539
2462
|
const ae = typeof document !== "undefined" ? document.activeElement : null;
|
|
2540
2463
|
if (popRef.current && ae && popRef.current.contains(ae)) triggerRef.current?.focus();
|
|
@@ -2607,7 +2530,7 @@ function Select({
|
|
|
2607
2530
|
}
|
|
2608
2531
|
)
|
|
2609
2532
|
] }) : null,
|
|
2610
|
-
/* @__PURE__ */ jsx("div", { className: "twc-pop__list", ref: listRef, children: visible.length === 0 ? /* @__PURE__ */ jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxs(
|
|
2533
|
+
/* @__PURE__ */ jsx("div", { className: "twc-pop__list", ref: listRef, children: visible.length === 0 ? /* @__PURE__ */ jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxs(React23__default.Fragment, { children: [
|
|
2611
2534
|
g.group ? /* @__PURE__ */ jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
2612
2535
|
g.options.map((o) => {
|
|
2613
2536
|
counter += 1;
|
|
@@ -2666,6 +2589,7 @@ function Select({
|
|
|
2666
2589
|
}
|
|
2667
2590
|
}
|
|
2668
2591
|
return /* @__PURE__ */ jsxs("div", { className: `twc-field ${className}`, ref: wrapRef, children: [
|
|
2592
|
+
__twcStyles,
|
|
2669
2593
|
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
2670
2594
|
label,
|
|
2671
2595
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -2758,15 +2682,6 @@ var CURF_CSS = `
|
|
|
2758
2682
|
.twc-curf__pick .twc-sel__trigger:focus-visible { box-shadow: var(--ring); }
|
|
2759
2683
|
.twc-curf__pick .twc-sel__value { font-weight: var(--font-semibold); color: var(--color-text-muted); }
|
|
2760
2684
|
`;
|
|
2761
|
-
function useCurfStyles() {
|
|
2762
|
-
React22.useInsertionEffect(() => {
|
|
2763
|
-
if (document.getElementById("twc-curf-styles")) return;
|
|
2764
|
-
const el = document.createElement("style");
|
|
2765
|
-
el.id = "twc-curf-styles";
|
|
2766
|
-
el.textContent = CURF_CSS;
|
|
2767
|
-
document.head.appendChild(el);
|
|
2768
|
-
}, []);
|
|
2769
|
-
}
|
|
2770
2685
|
function CurrencyField({
|
|
2771
2686
|
label,
|
|
2772
2687
|
hint,
|
|
@@ -2788,20 +2703,20 @@ function CurrencyField({
|
|
|
2788
2703
|
className = "",
|
|
2789
2704
|
...rest
|
|
2790
2705
|
}) {
|
|
2791
|
-
|
|
2792
|
-
const autoId =
|
|
2706
|
+
const __twcStyles = useScopedStyles("twc-curf-styles", CURF_CSS);
|
|
2707
|
+
const autoId = React23__default.useId();
|
|
2793
2708
|
const fieldId = id || autoId;
|
|
2794
2709
|
const invalid = Boolean(error);
|
|
2795
2710
|
const curControlled = currency !== void 0;
|
|
2796
|
-
const [curInternal, setCurInternal] =
|
|
2711
|
+
const [curInternal, setCurInternal] = React23__default.useState(defaultCurrency);
|
|
2797
2712
|
const cur = curControlled ? currency : curInternal;
|
|
2798
2713
|
const meta = CURRENCIES[cur] || CURRENCIES.USD;
|
|
2799
2714
|
const prec = meta.precision;
|
|
2800
2715
|
const valControlled = value !== void 0;
|
|
2801
|
-
const [valInternal, setValInternal] =
|
|
2716
|
+
const [valInternal, setValInternal] = React23__default.useState(() => clampPrecision(String(defaultValue ?? ""), prec));
|
|
2802
2717
|
const shown = valControlled ? clampPrecision(String(value ?? ""), prec) : valInternal;
|
|
2803
2718
|
const describedBy = [error ? `${fieldId}-error` : hint ? `${fieldId}-hint` : null, rest["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
2804
|
-
const options =
|
|
2719
|
+
const options = React23__default.useMemo(() => {
|
|
2805
2720
|
if (!currencies) return CURRENCY_OPTIONS;
|
|
2806
2721
|
return currencies.map((c) => typeof c === "string" ? { value: c, label: `${c} \u2014 ${(CURRENCIES[c] || {}).label || c}` } : c);
|
|
2807
2722
|
}, [currencies]);
|
|
@@ -2828,6 +2743,7 @@ function CurrencyField({
|
|
|
2828
2743
|
onValueChange?.(Number(fixed), fixed, cur);
|
|
2829
2744
|
}
|
|
2830
2745
|
return /* @__PURE__ */ jsxs("div", { className: `twc-field ${className}`, children: [
|
|
2746
|
+
__twcStyles,
|
|
2831
2747
|
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
2832
2748
|
label,
|
|
2833
2749
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -2919,15 +2835,6 @@ var FIELD_CSS2 = `
|
|
|
2919
2835
|
.twc-input__reveal:focus-visible { outline: none; box-shadow: var(--ring); }
|
|
2920
2836
|
.twc-input__reveal svg { width: 17px; height: 17px; }
|
|
2921
2837
|
`;
|
|
2922
|
-
function useFieldStyles() {
|
|
2923
|
-
React22.useInsertionEffect(() => {
|
|
2924
|
-
if (document.getElementById("twc-field-styles")) return;
|
|
2925
|
-
const el = document.createElement("style");
|
|
2926
|
-
el.id = "twc-field-styles";
|
|
2927
|
-
el.textContent = FIELD_CSS2;
|
|
2928
|
-
document.head.appendChild(el);
|
|
2929
|
-
}, []);
|
|
2930
|
-
}
|
|
2931
2838
|
function Input({
|
|
2932
2839
|
label,
|
|
2933
2840
|
hint,
|
|
@@ -2943,13 +2850,13 @@ function Input({
|
|
|
2943
2850
|
className = "",
|
|
2944
2851
|
...rest
|
|
2945
2852
|
}) {
|
|
2946
|
-
|
|
2947
|
-
const autoId =
|
|
2853
|
+
const __twcStyles = useScopedStyles("twc-field-styles", FIELD_CSS2);
|
|
2854
|
+
const autoId = React23__default.useId();
|
|
2948
2855
|
const fieldId = id || autoId;
|
|
2949
2856
|
const descId = `${fieldId}-desc`;
|
|
2950
2857
|
const invalid = Boolean(error);
|
|
2951
2858
|
const isPassword = type === "password";
|
|
2952
|
-
const [revealed, setRevealed] =
|
|
2859
|
+
const [revealed, setRevealed] = React23__default.useState(false);
|
|
2953
2860
|
const effectiveType = isPassword && revealed ? "text" : type;
|
|
2954
2861
|
const suffix = rightIcon ? /* @__PURE__ */ jsx("span", { className: "twc-input__affix", children: rightIcon }) : isPassword ? /* @__PURE__ */ jsx(
|
|
2955
2862
|
"button",
|
|
@@ -2973,6 +2880,7 @@ function Input({
|
|
|
2973
2880
|
}
|
|
2974
2881
|
) : null;
|
|
2975
2882
|
return /* @__PURE__ */ jsxs("div", { className: `twc-field ${className}`, children: [
|
|
2883
|
+
__twcStyles,
|
|
2976
2884
|
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
2977
2885
|
label,
|
|
2978
2886
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -3128,35 +3036,29 @@ function MultiSelect({
|
|
|
3128
3036
|
onKeyDown,
|
|
3129
3037
|
...rest
|
|
3130
3038
|
}) {
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
el.textContent = MULTI_CSS;
|
|
3136
|
-
document.head.appendChild(el);
|
|
3137
|
-
}, []);
|
|
3138
|
-
const groups = React22.useMemo(() => normalizeGroups3(options), [options]);
|
|
3139
|
-
const flat = React22.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
3140
|
-
const autoId = React22.useId();
|
|
3039
|
+
const __twcStyles = useScopedStyles("twc-ms-styles", MULTI_CSS);
|
|
3040
|
+
const groups = React23__default.useMemo(() => normalizeGroups3(options), [options]);
|
|
3041
|
+
const flat = React23__default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
3042
|
+
const autoId = React23__default.useId();
|
|
3141
3043
|
const fieldId = id || autoId;
|
|
3142
|
-
const [internal, setInternal] =
|
|
3044
|
+
const [internal, setInternal] = React23__default.useState(defaultValue);
|
|
3143
3045
|
const selected = value !== void 0 ? value : internal;
|
|
3144
|
-
const [open, setOpen] =
|
|
3145
|
-
const [query, setQuery] =
|
|
3146
|
-
const [active, setActive] =
|
|
3147
|
-
const [coords, setCoords] =
|
|
3148
|
-
const wrapRef =
|
|
3149
|
-
const controlRef =
|
|
3150
|
-
const inputRef =
|
|
3151
|
-
const popRef =
|
|
3152
|
-
const listRef =
|
|
3153
|
-
const activeRef =
|
|
3154
|
-
const fGroups =
|
|
3046
|
+
const [open, setOpen] = React23__default.useState(false);
|
|
3047
|
+
const [query, setQuery] = React23__default.useState("");
|
|
3048
|
+
const [active, setActive] = React23__default.useState(0);
|
|
3049
|
+
const [coords, setCoords] = React23__default.useState(null);
|
|
3050
|
+
const wrapRef = React23__default.useRef(null);
|
|
3051
|
+
const controlRef = React23__default.useRef(null);
|
|
3052
|
+
const inputRef = React23__default.useRef(null);
|
|
3053
|
+
const popRef = React23__default.useRef(null);
|
|
3054
|
+
const listRef = React23__default.useRef(null);
|
|
3055
|
+
const activeRef = React23__default.useRef(null);
|
|
3056
|
+
const fGroups = React23__default.useMemo(
|
|
3155
3057
|
() => groups.map((g) => ({ group: g.group, options: g.options.filter((o) => matches2(o, query.trim())) })).filter((g) => g.options.length),
|
|
3156
3058
|
[groups, query]
|
|
3157
3059
|
);
|
|
3158
|
-
const visible =
|
|
3159
|
-
const place =
|
|
3060
|
+
const visible = React23__default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
3061
|
+
const place = React23__default.useCallback(() => {
|
|
3160
3062
|
const el = controlRef.current;
|
|
3161
3063
|
if (!el) return;
|
|
3162
3064
|
const r = el.getBoundingClientRect();
|
|
@@ -3171,7 +3073,7 @@ function MultiSelect({
|
|
|
3171
3073
|
flip
|
|
3172
3074
|
});
|
|
3173
3075
|
}, [placement, minWidth]);
|
|
3174
|
-
|
|
3076
|
+
React23__default.useEffect(() => {
|
|
3175
3077
|
if (!open || !portal) return;
|
|
3176
3078
|
place();
|
|
3177
3079
|
const onMove = () => place();
|
|
@@ -3182,7 +3084,7 @@ function MultiSelect({
|
|
|
3182
3084
|
window.removeEventListener("resize", onMove);
|
|
3183
3085
|
};
|
|
3184
3086
|
}, [open, portal, place]);
|
|
3185
|
-
|
|
3087
|
+
React23__default.useEffect(() => {
|
|
3186
3088
|
if (!open) return;
|
|
3187
3089
|
const onDown = (e) => {
|
|
3188
3090
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -3193,10 +3095,10 @@ function MultiSelect({
|
|
|
3193
3095
|
document.addEventListener("mousedown", onDown);
|
|
3194
3096
|
return () => document.removeEventListener("mousedown", onDown);
|
|
3195
3097
|
}, [open]);
|
|
3196
|
-
|
|
3098
|
+
React23__default.useEffect(() => {
|
|
3197
3099
|
setActive(0);
|
|
3198
3100
|
}, [query]);
|
|
3199
|
-
|
|
3101
|
+
React23__default.useEffect(() => {
|
|
3200
3102
|
if (open) ensureVisible3(listRef.current, activeRef.current);
|
|
3201
3103
|
}, [active, open]);
|
|
3202
3104
|
function commit(next) {
|
|
@@ -3233,7 +3135,7 @@ function MultiSelect({
|
|
|
3233
3135
|
const descId = `${fieldId}-desc`;
|
|
3234
3136
|
const describedBy = error || hint ? descId : void 0;
|
|
3235
3137
|
let counter = -1;
|
|
3236
|
-
const popInner = /* @__PURE__ */ jsx("div", { className: "twc-pop__list", id: listboxId, ref: listRef, role: "listbox", "aria-multiselectable": "true", children: visible.length === 0 ? /* @__PURE__ */ jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxs(
|
|
3138
|
+
const popInner = /* @__PURE__ */ jsx("div", { className: "twc-pop__list", id: listboxId, ref: listRef, role: "listbox", "aria-multiselectable": "true", children: visible.length === 0 ? /* @__PURE__ */ jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxs(React23__default.Fragment, { children: [
|
|
3237
3139
|
g.group ? /* @__PURE__ */ jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
3238
3140
|
g.options.map((o) => {
|
|
3239
3141
|
counter += 1;
|
|
@@ -3288,6 +3190,7 @@ function MultiSelect({
|
|
|
3288
3190
|
}
|
|
3289
3191
|
}
|
|
3290
3192
|
return /* @__PURE__ */ jsxs("div", { className: `twc-field ${className}`, ref: wrapRef, children: [
|
|
3193
|
+
__twcStyles,
|
|
3291
3194
|
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
3292
3195
|
label,
|
|
3293
3196
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -3445,14 +3348,8 @@ function Pagination({
|
|
|
3445
3348
|
...rest
|
|
3446
3349
|
}) {
|
|
3447
3350
|
const jumperEnabled = showPageJumper ?? showJumper;
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
const el = document.createElement("style");
|
|
3451
|
-
el.id = "twc-pagination-styles";
|
|
3452
|
-
el.textContent = PAGINATION_CSS;
|
|
3453
|
-
document.head.appendChild(el);
|
|
3454
|
-
}, []);
|
|
3455
|
-
const [internal, setInternal] = React22.useState(defaultPage);
|
|
3351
|
+
const __twcStyles = useScopedStyles("twc-pagination-styles", PAGINATION_CSS);
|
|
3352
|
+
const [internal, setInternal] = React23__default.useState(defaultPage);
|
|
3456
3353
|
const page = pageProp !== void 0 ? pageProp : internal;
|
|
3457
3354
|
const pages = buildPages(page, total, siblings, boundaries);
|
|
3458
3355
|
const go = (p) => {
|
|
@@ -3460,13 +3357,14 @@ function Pagination({
|
|
|
3460
3357
|
if (pageProp === void 0) setInternal(p);
|
|
3461
3358
|
onChange?.(p);
|
|
3462
3359
|
};
|
|
3463
|
-
const [jump, setJump] =
|
|
3360
|
+
const [jump, setJump] = React23__default.useState("");
|
|
3464
3361
|
const submitJump = () => {
|
|
3465
3362
|
const n = parseInt(jump, 10);
|
|
3466
3363
|
if (!Number.isNaN(n)) go(Math.min(Math.max(n, 1), total));
|
|
3467
3364
|
setJump("");
|
|
3468
3365
|
};
|
|
3469
3366
|
return /* @__PURE__ */ jsxs("nav", { className: `twc-pagination ${className}`, "aria-label": "Pagination", ...rest, children: [
|
|
3367
|
+
__twcStyles,
|
|
3470
3368
|
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-page", "data-size": size, onClick: () => go(page - 1), disabled: page <= 1, "aria-label": "Previous page", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" }) }) }),
|
|
3471
3369
|
pages.map(
|
|
3472
3370
|
(p, i) => p === "\u2026" ? /* @__PURE__ */ jsx("span", { className: "twc-page twc-page__ellipsis", "aria-hidden": "true", children: "\u2026" }, `e${i}`) : /* @__PURE__ */ jsx(
|
|
@@ -4069,9 +3967,9 @@ function runDatatableQuery(rows, query, options = {}) {
|
|
|
4069
3967
|
return { rows: page, total, filtered: out };
|
|
4070
3968
|
}
|
|
4071
3969
|
function useFloating() {
|
|
4072
|
-
const [pos, setPos] =
|
|
4073
|
-
const cfg =
|
|
4074
|
-
const place =
|
|
3970
|
+
const [pos, setPos] = React23__default.useState(null);
|
|
3971
|
+
const cfg = React23__default.useRef(null);
|
|
3972
|
+
const place = React23__default.useCallback(() => {
|
|
4075
3973
|
const c = cfg.current;
|
|
4076
3974
|
if (!c || !c.el || !c.el.isConnected) return null;
|
|
4077
3975
|
const r = c.el.getBoundingClientRect();
|
|
@@ -4082,17 +3980,17 @@ function useFloating() {
|
|
|
4082
3980
|
const top = r.bottom + 6;
|
|
4083
3981
|
return { top, left, width: c.width, anchorX: r.left + r.width / 2, maxHeight: Math.max(180, vh - top - M) };
|
|
4084
3982
|
}, []);
|
|
4085
|
-
const open =
|
|
3983
|
+
const open = React23__default.useCallback((el, align = "left", width = 220) => {
|
|
4086
3984
|
cfg.current = { el, align, width };
|
|
4087
3985
|
const p = place();
|
|
4088
3986
|
if (p) setPos(p);
|
|
4089
3987
|
}, [place]);
|
|
4090
|
-
const close =
|
|
3988
|
+
const close = React23__default.useCallback(() => {
|
|
4091
3989
|
cfg.current = null;
|
|
4092
3990
|
setPos(null);
|
|
4093
3991
|
}, []);
|
|
4094
3992
|
const isOpen = pos != null;
|
|
4095
|
-
|
|
3993
|
+
React23__default.useEffect(() => {
|
|
4096
3994
|
if (!isOpen) return void 0;
|
|
4097
3995
|
const update = () => {
|
|
4098
3996
|
const p = place();
|
|
@@ -4116,9 +4014,9 @@ function Caret({ pos }) {
|
|
|
4116
4014
|
return /* @__PURE__ */ jsx("span", { className: "twc-dt__caret", style: { left } });
|
|
4117
4015
|
}
|
|
4118
4016
|
function EditCell({ col, value, options, onChange, onCommit, onCommitValue, onCancel, onKeyDown }) {
|
|
4119
|
-
const ref =
|
|
4017
|
+
const ref = React23__default.useRef(null);
|
|
4120
4018
|
const isSelect = col.editType === "select" || options && col.editType !== "text";
|
|
4121
|
-
|
|
4019
|
+
React23__default.useEffect(() => {
|
|
4122
4020
|
if (isSelect) {
|
|
4123
4021
|
const t = setTimeout(() => ref.current?.querySelector(".twc-sel__trigger")?.click(), 0);
|
|
4124
4022
|
return () => clearTimeout(t);
|
|
@@ -4318,14 +4216,8 @@ function Datatable({
|
|
|
4318
4216
|
className = "",
|
|
4319
4217
|
...rest
|
|
4320
4218
|
}) {
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
const el = document.createElement("style");
|
|
4324
|
-
el.id = "twc-dt-styles";
|
|
4325
|
-
el.textContent = DT_CSS;
|
|
4326
|
-
document.head.appendChild(el);
|
|
4327
|
-
}, []);
|
|
4328
|
-
const cols = React22.useMemo(() => {
|
|
4219
|
+
const __twcStyles = useScopedStyles("twc-dt-styles", DT_CSS);
|
|
4220
|
+
const cols = React23__default.useMemo(() => {
|
|
4329
4221
|
const out = columns.map((c) => {
|
|
4330
4222
|
const isActions = c.type === "actions";
|
|
4331
4223
|
return {
|
|
@@ -4360,7 +4252,7 @@ function Datatable({
|
|
|
4360
4252
|
}
|
|
4361
4253
|
return out;
|
|
4362
4254
|
}, [columns, rowPinning]);
|
|
4363
|
-
const _autoKey =
|
|
4255
|
+
const _autoKey = React23__default.useRef();
|
|
4364
4256
|
if (!_autoKey.current) _autoKey.current = { map: /* @__PURE__ */ new WeakMap(), n: 0 };
|
|
4365
4257
|
const keyOf = rowKey || ((r, i) => {
|
|
4366
4258
|
if (r != null && r.id != null) return r.id;
|
|
@@ -4375,17 +4267,17 @@ function Datatable({
|
|
|
4375
4267
|
}
|
|
4376
4268
|
return i;
|
|
4377
4269
|
});
|
|
4378
|
-
const [sort, setSort] =
|
|
4379
|
-
const [filters, setFilters] =
|
|
4380
|
-
const [hidden, setHidden] =
|
|
4381
|
-
const [showRowNum, setShowRowNum] =
|
|
4382
|
-
const [wrapped, setWrapped] =
|
|
4270
|
+
const [sort, setSort] = React23__default.useState(null);
|
|
4271
|
+
const [filters, setFilters] = React23__default.useState([]);
|
|
4272
|
+
const [hidden, setHidden] = React23__default.useState(() => /* @__PURE__ */ new Set());
|
|
4273
|
+
const [showRowNum, setShowRowNum] = React23__default.useState(rowNumbers);
|
|
4274
|
+
const [wrapped, setWrapped] = React23__default.useState(() => new Set((columns || []).filter((c) => c.wrapText).map((c) => c.field)));
|
|
4383
4275
|
const toggleWrap = (field) => setWrapped((w) => {
|
|
4384
4276
|
const n = new Set(w);
|
|
4385
4277
|
n.has(field) ? n.delete(field) : n.add(field);
|
|
4386
4278
|
return n;
|
|
4387
4279
|
});
|
|
4388
|
-
const [pins, setPins] =
|
|
4280
|
+
const [pins, setPins] = React23__default.useState(() => {
|
|
4389
4281
|
const left = [], right = [];
|
|
4390
4282
|
columns.forEach((c) => {
|
|
4391
4283
|
if (c.pinned === "left") left.push(c.field);
|
|
@@ -4393,34 +4285,34 @@ function Datatable({
|
|
|
4393
4285
|
});
|
|
4394
4286
|
return { left, right };
|
|
4395
4287
|
});
|
|
4396
|
-
const [density, setDensity] =
|
|
4397
|
-
const [quick, setQuick] =
|
|
4398
|
-
const [selected, setSelected] =
|
|
4399
|
-
const [activeRow, setActiveRow] =
|
|
4400
|
-
const [activeCell, setActiveCell] =
|
|
4401
|
-
const [page, setPage] =
|
|
4402
|
-
const [rowsPerPage, setRowsPerPage] =
|
|
4403
|
-
const [colQuery, setColQuery] =
|
|
4404
|
-
const [widths, setWidths] =
|
|
4405
|
-
const [order, setOrder] =
|
|
4406
|
-
const [drag, setDrag] =
|
|
4407
|
-
const [aggOn, setAggOn] =
|
|
4408
|
-
const [focus, setFocus] =
|
|
4409
|
-
const gridRef =
|
|
4410
|
-
const [groupBy, setGroupBy] =
|
|
4411
|
-
const [collapsed, setCollapsed] =
|
|
4412
|
-
const [pinnedRows, setPinnedRows] =
|
|
4413
|
-
const [headH, setHeadH] =
|
|
4414
|
-
const theadRef =
|
|
4415
|
-
const [rowOrder, setRowOrder] =
|
|
4416
|
-
const [rowHeights, setRowHeights] =
|
|
4417
|
-
const [rowDrag, setRowDrag] =
|
|
4418
|
-
const [rowGrab, setRowGrab] =
|
|
4419
|
-
const [reorderMsg, setReorderMsg] =
|
|
4420
|
-
const rowFocusRef =
|
|
4421
|
-
const rootRef =
|
|
4422
|
-
const [compact, setCompact] =
|
|
4423
|
-
|
|
4288
|
+
const [density, setDensity] = React23__default.useState(densityProp);
|
|
4289
|
+
const [quick, setQuick] = React23__default.useState("");
|
|
4290
|
+
const [selected, setSelected] = React23__default.useState(() => /* @__PURE__ */ new Set());
|
|
4291
|
+
const [activeRow, setActiveRow] = React23__default.useState(null);
|
|
4292
|
+
const [activeCell, setActiveCell] = React23__default.useState(null);
|
|
4293
|
+
const [page, setPage] = React23__default.useState(0);
|
|
4294
|
+
const [rowsPerPage, setRowsPerPage] = React23__default.useState(pageSize > 0 ? pageSize : 10);
|
|
4295
|
+
const [colQuery, setColQuery] = React23__default.useState("");
|
|
4296
|
+
const [widths, setWidths] = React23__default.useState({});
|
|
4297
|
+
const [order, setOrder] = React23__default.useState(() => columns.map((c) => c.field));
|
|
4298
|
+
const [drag, setDrag] = React23__default.useState({ from: null, over: null, after: false });
|
|
4299
|
+
const [aggOn, setAggOn] = React23__default.useState(showAggregation);
|
|
4300
|
+
const [focus, setFocus] = React23__default.useState({ r: 0, c: 0 });
|
|
4301
|
+
const gridRef = React23__default.useRef(null);
|
|
4302
|
+
const [groupBy, setGroupBy] = React23__default.useState(rowGrouping || []);
|
|
4303
|
+
const [collapsed, setCollapsed] = React23__default.useState(() => /* @__PURE__ */ new Set());
|
|
4304
|
+
const [pinnedRows, setPinnedRows] = React23__default.useState({ top: [], bottom: [] });
|
|
4305
|
+
const [headH, setHeadH] = React23__default.useState(41);
|
|
4306
|
+
const theadRef = React23__default.useRef(null);
|
|
4307
|
+
const [rowOrder, setRowOrder] = React23__default.useState(null);
|
|
4308
|
+
const [rowHeights, setRowHeights] = React23__default.useState({});
|
|
4309
|
+
const [rowDrag, setRowDrag] = React23__default.useState({ from: null, over: null, after: false });
|
|
4310
|
+
const [rowGrab, setRowGrab] = React23__default.useState(null);
|
|
4311
|
+
const [reorderMsg, setReorderMsg] = React23__default.useState("");
|
|
4312
|
+
const rowFocusRef = React23__default.useRef(null);
|
|
4313
|
+
const rootRef = React23__default.useRef(null);
|
|
4314
|
+
const [compact, setCompact] = React23__default.useState(false);
|
|
4315
|
+
React23__default.useEffect(() => {
|
|
4424
4316
|
const el = rootRef.current;
|
|
4425
4317
|
if (!el) return void 0;
|
|
4426
4318
|
const measure = () => setCompact((el.clientWidth || 0) < 720);
|
|
@@ -4433,11 +4325,11 @@ function Datatable({
|
|
|
4433
4325
|
else if (typeof window !== "undefined") window.removeEventListener("resize", measure);
|
|
4434
4326
|
};
|
|
4435
4327
|
}, []);
|
|
4436
|
-
const scrollRef =
|
|
4437
|
-
const [scrollTop, setScrollTop] =
|
|
4438
|
-
const [viewportH, setViewportH] =
|
|
4439
|
-
const [pivotOn, setPivotOn] =
|
|
4440
|
-
const [aggConfig, setAggConfig] =
|
|
4328
|
+
const scrollRef = React23__default.useRef(null);
|
|
4329
|
+
const [scrollTop, setScrollTop] = React23__default.useState(0);
|
|
4330
|
+
const [viewportH, setViewportH] = React23__default.useState(0);
|
|
4331
|
+
const [pivotOn, setPivotOn] = React23__default.useState(pivotMode);
|
|
4332
|
+
const [aggConfig, setAggConfig] = React23__default.useState(() => {
|
|
4441
4333
|
const m = {};
|
|
4442
4334
|
(columns || []).forEach((c) => {
|
|
4443
4335
|
if (typeof c.aggregation === "string") m[c.field] = c.aggregation;
|
|
@@ -4445,13 +4337,13 @@ function Datatable({
|
|
|
4445
4337
|
return m;
|
|
4446
4338
|
});
|
|
4447
4339
|
const aggOf = (c) => aggConfig[c.field] || (typeof c.aggregation === "function" ? c.aggregation : null);
|
|
4448
|
-
const [pivotConfig, setPivotConfig] =
|
|
4340
|
+
const [pivotConfig, setPivotConfig] = React23__default.useState(() => ({
|
|
4449
4341
|
rows: pivot && pivot.rows || [],
|
|
4450
4342
|
columns: pivot && pivot.columns || [],
|
|
4451
4343
|
values: pivot && pivot.values || []
|
|
4452
4344
|
}));
|
|
4453
4345
|
const pivotActive = pivotOn && pivotConfig.rows.length > 0 && pivotConfig.values.length > 0;
|
|
4454
|
-
|
|
4346
|
+
React23__default.useEffect(() => {
|
|
4455
4347
|
setOrder((prev) => {
|
|
4456
4348
|
const fields = columns.map((c) => c.field);
|
|
4457
4349
|
const kept = prev.filter((f) => fields.includes(f));
|
|
@@ -4459,32 +4351,32 @@ function Datatable({
|
|
|
4459
4351
|
return [...kept, ...added];
|
|
4460
4352
|
});
|
|
4461
4353
|
}, [columns]);
|
|
4462
|
-
|
|
4354
|
+
React23__default.useEffect(() => {
|
|
4463
4355
|
setDensity(densityProp);
|
|
4464
4356
|
}, [densityProp]);
|
|
4465
|
-
|
|
4357
|
+
React23__default.useEffect(() => {
|
|
4466
4358
|
setAggOn(showAggregation);
|
|
4467
4359
|
}, [showAggregation]);
|
|
4468
4360
|
const rowGroupingKey = (rowGrouping || []).join("\0");
|
|
4469
|
-
const rowGroupingKeyRef =
|
|
4470
|
-
|
|
4361
|
+
const rowGroupingKeyRef = React23__default.useRef(rowGroupingKey);
|
|
4362
|
+
React23__default.useEffect(() => {
|
|
4471
4363
|
if (rowGroupingKeyRef.current === rowGroupingKey) return;
|
|
4472
4364
|
rowGroupingKeyRef.current = rowGroupingKey;
|
|
4473
4365
|
setGroupBy(rowGrouping || []);
|
|
4474
4366
|
}, [rowGroupingKey]);
|
|
4475
4367
|
const widthOf = (c) => widths[c.field] ?? c.width ?? 160;
|
|
4476
|
-
const [colMenu, setColMenu] =
|
|
4368
|
+
const [colMenu, setColMenu] = React23__default.useState(null);
|
|
4477
4369
|
const [menuPos, openMenu, closeMenu] = useFloating();
|
|
4478
|
-
const [panel, setPanel] =
|
|
4370
|
+
const [panel, setPanel] = React23__default.useState(null);
|
|
4479
4371
|
const [panelPos, openPanel, closePanel] = useFloating();
|
|
4480
|
-
const [rowMenu, setRowMenu] =
|
|
4372
|
+
const [rowMenu, setRowMenu] = React23__default.useState(null);
|
|
4481
4373
|
const [rowMenuPos, openRowMenu, closeRowMenu] = useFloating();
|
|
4482
|
-
const [exportOpen, setExportOpen] =
|
|
4374
|
+
const [exportOpen, setExportOpen] = React23__default.useState(false);
|
|
4483
4375
|
const [exportPos, openExport, closeExport] = useFloating();
|
|
4484
|
-
const menuTriggerRef =
|
|
4485
|
-
const colMenuRef =
|
|
4486
|
-
const rowMenuRef =
|
|
4487
|
-
const exportMenuRef =
|
|
4376
|
+
const menuTriggerRef = React23__default.useRef(null);
|
|
4377
|
+
const colMenuRef = React23__default.useRef(null);
|
|
4378
|
+
const rowMenuRef = React23__default.useRef(null);
|
|
4379
|
+
const exportMenuRef = React23__default.useRef(null);
|
|
4488
4380
|
function focusFirstItem(container) {
|
|
4489
4381
|
if (!container) return;
|
|
4490
4382
|
const first = container.querySelector('[role="menuitem"]:not([disabled])');
|
|
@@ -4523,16 +4415,16 @@ function Datatable({
|
|
|
4523
4415
|
restoreTriggerFocus();
|
|
4524
4416
|
}
|
|
4525
4417
|
}
|
|
4526
|
-
|
|
4418
|
+
React23__default.useEffect(() => {
|
|
4527
4419
|
if (colMenu) focusFirstItem(colMenuRef.current);
|
|
4528
4420
|
}, [colMenu]);
|
|
4529
|
-
|
|
4421
|
+
React23__default.useEffect(() => {
|
|
4530
4422
|
if (rowMenu) focusFirstItem(rowMenuRef.current);
|
|
4531
4423
|
}, [rowMenu]);
|
|
4532
|
-
|
|
4424
|
+
React23__default.useEffect(() => {
|
|
4533
4425
|
if (exportOpen) focusFirstItem(exportMenuRef.current);
|
|
4534
4426
|
}, [exportOpen]);
|
|
4535
|
-
|
|
4427
|
+
React23__default.useEffect(() => {
|
|
4536
4428
|
if (!colMenu && !panel && !rowMenu) return;
|
|
4537
4429
|
const closeAll = () => {
|
|
4538
4430
|
setColMenu(null);
|
|
@@ -4555,7 +4447,7 @@ function Datatable({
|
|
|
4555
4447
|
document.removeEventListener("keydown", onKey);
|
|
4556
4448
|
};
|
|
4557
4449
|
}, [colMenu, panel, rowMenu]);
|
|
4558
|
-
|
|
4450
|
+
React23__default.useEffect(() => {
|
|
4559
4451
|
if (!exportOpen) return;
|
|
4560
4452
|
const close = () => {
|
|
4561
4453
|
setExportOpen(false);
|
|
@@ -4574,9 +4466,9 @@ function Datatable({
|
|
|
4574
4466
|
document.removeEventListener("keydown", onKey);
|
|
4575
4467
|
};
|
|
4576
4468
|
}, [exportOpen]);
|
|
4577
|
-
const colByField =
|
|
4469
|
+
const colByField = React23__default.useMemo(() => Object.fromEntries(cols.map((c) => [c.field, c])), [cols]);
|
|
4578
4470
|
const visibleCols = cols.filter((c) => !hidden.has(c.field));
|
|
4579
|
-
const ordered =
|
|
4471
|
+
const ordered = React23__default.useMemo(() => {
|
|
4580
4472
|
const orderIdx = (f) => {
|
|
4581
4473
|
const i = order.indexOf(f);
|
|
4582
4474
|
return i === -1 ? 9999 : i;
|
|
@@ -4611,7 +4503,7 @@ function Datatable({
|
|
|
4611
4503
|
}
|
|
4612
4504
|
return {};
|
|
4613
4505
|
};
|
|
4614
|
-
const processed =
|
|
4506
|
+
const processed = React23__default.useMemo(() => {
|
|
4615
4507
|
if (serverMode) {
|
|
4616
4508
|
if (rowOrder) {
|
|
4617
4509
|
const idx = new Map(rowOrder.map((k, i) => [k, i]));
|
|
@@ -4650,10 +4542,10 @@ function Datatable({
|
|
|
4650
4542
|
const totalRows = serverMode ? serverTotal : processed.length;
|
|
4651
4543
|
const totalPages = paginated ? Math.max(1, Math.ceil(totalRows / rowsPerPage)) : 1;
|
|
4652
4544
|
const paged = !paginated || serverMode ? processed : processed.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage);
|
|
4653
|
-
|
|
4545
|
+
React23__default.useEffect(() => {
|
|
4654
4546
|
if (page > totalPages - 1) setPage(0);
|
|
4655
4547
|
}, [totalPages]);
|
|
4656
|
-
const activeGroupBy =
|
|
4548
|
+
const activeGroupBy = React23__default.useMemo(() => groupBy.filter((f) => colByField[f]), [groupBy, colByField]);
|
|
4657
4549
|
function subtotalText(rowsIn) {
|
|
4658
4550
|
const parts = [];
|
|
4659
4551
|
for (const c of ordered) {
|
|
@@ -4680,7 +4572,7 @@ function Datatable({
|
|
|
4680
4572
|
if (agg === "max") return Math.max(...nums);
|
|
4681
4573
|
return null;
|
|
4682
4574
|
}
|
|
4683
|
-
const displayItems =
|
|
4575
|
+
const displayItems = React23__default.useMemo(() => {
|
|
4684
4576
|
if (!activeGroupBy.length) return null;
|
|
4685
4577
|
const build = (rowsIn, depth, prefix) => {
|
|
4686
4578
|
if (depth >= activeGroupBy.length) return rowsIn.map((row) => ({ kind: "leaf", row }));
|
|
@@ -4722,7 +4614,7 @@ function Datatable({
|
|
|
4722
4614
|
return { top, bottom };
|
|
4723
4615
|
});
|
|
4724
4616
|
}
|
|
4725
|
-
|
|
4617
|
+
React23__default.useEffect(() => {
|
|
4726
4618
|
if (!rowPinning) return;
|
|
4727
4619
|
const measure = () => {
|
|
4728
4620
|
if (theadRef.current) setHeadH(theadRef.current.offsetHeight || 41);
|
|
@@ -4736,12 +4628,12 @@ function Datatable({
|
|
|
4736
4628
|
const pinnedTopRows = canPinRows ? pinnedRows.top.map((k) => leafRows.find((r, i) => keyOf(r, i) === k)).filter(Boolean) : [];
|
|
4737
4629
|
const pinnedBottomRows = canPinRows ? pinnedRows.bottom.map((k) => leafRows.find((r, i) => keyOf(r, i) === k)).filter(Boolean) : [];
|
|
4738
4630
|
const middleRows = canPinRows ? leafRows.filter((r, i) => !pinSideOf(keyOf(r, i))) : leafRows;
|
|
4739
|
-
const keyIndex =
|
|
4631
|
+
const keyIndex = React23__default.useMemo(() => {
|
|
4740
4632
|
const m = /* @__PURE__ */ new Map();
|
|
4741
4633
|
leafRows.forEach((r, i) => m.set(keyOf(r, i), i));
|
|
4742
4634
|
return m;
|
|
4743
4635
|
}, [leafRows]);
|
|
4744
|
-
const keyIndexMid =
|
|
4636
|
+
const keyIndexMid = React23__default.useMemo(() => {
|
|
4745
4637
|
const m = /* @__PURE__ */ new Map();
|
|
4746
4638
|
middleRows.forEach((r, i) => m.set(keyOf(r, keyIndex.get(keyOf(r)) ?? i), i));
|
|
4747
4639
|
return m;
|
|
@@ -4826,7 +4718,7 @@ function Datatable({
|
|
|
4826
4718
|
setReorderMsg("Reorder cancelled.");
|
|
4827
4719
|
}
|
|
4828
4720
|
}
|
|
4829
|
-
|
|
4721
|
+
React23__default.useEffect(() => {
|
|
4830
4722
|
if (rowFocusRef.current == null) return;
|
|
4831
4723
|
const key = rowFocusRef.current;
|
|
4832
4724
|
rowFocusRef.current = null;
|
|
@@ -4838,7 +4730,7 @@ function Datatable({
|
|
|
4838
4730
|
});
|
|
4839
4731
|
const estRowH = rowHeight ?? (density === "compact" ? 36 : density === "comfortable" ? 56 : 44);
|
|
4840
4732
|
const virtualizing = virtualized && !paginated && !activeGroupBy.length && !loading;
|
|
4841
|
-
|
|
4733
|
+
React23__default.useEffect(() => {
|
|
4842
4734
|
if (!virtualizing) return;
|
|
4843
4735
|
const el = scrollRef.current;
|
|
4844
4736
|
if (!el) return;
|
|
@@ -4848,13 +4740,13 @@ function Datatable({
|
|
|
4848
4740
|
if (ro) ro.observe(el);
|
|
4849
4741
|
return () => ro && ro.disconnect();
|
|
4850
4742
|
}, [virtualizing, height]);
|
|
4851
|
-
const onScrollVirtual =
|
|
4743
|
+
const onScrollVirtual = React23__default.useCallback((e) => {
|
|
4852
4744
|
setScrollTop(e.currentTarget.scrollTop);
|
|
4853
4745
|
}, []);
|
|
4854
4746
|
const vh = viewportH || (typeof height === "number" ? height : 440);
|
|
4855
|
-
const rowHRef =
|
|
4856
|
-
const [measureTick, setMeasureTick] =
|
|
4857
|
-
const offsets =
|
|
4747
|
+
const rowHRef = React23__default.useRef(/* @__PURE__ */ new Map());
|
|
4748
|
+
const [measureTick, setMeasureTick] = React23__default.useState(0);
|
|
4749
|
+
const offsets = React23__default.useMemo(() => {
|
|
4858
4750
|
if (!virtualizing) return null;
|
|
4859
4751
|
const total = middleRows.length;
|
|
4860
4752
|
const arr = new Float64Array(total + 1);
|
|
@@ -4864,7 +4756,7 @@ function Datatable({
|
|
|
4864
4756
|
}
|
|
4865
4757
|
return arr;
|
|
4866
4758
|
}, [virtualizing, middleRows, estRowH, measureTick]);
|
|
4867
|
-
const vWindow =
|
|
4759
|
+
const vWindow = React23__default.useMemo(() => {
|
|
4868
4760
|
if (!virtualizing || !offsets) return null;
|
|
4869
4761
|
const total = middleRows.length;
|
|
4870
4762
|
const totalH = offsets[total];
|
|
@@ -4893,7 +4785,7 @@ function Datatable({
|
|
|
4893
4785
|
if (start > end) start = end;
|
|
4894
4786
|
return { start, end, padTop: offsets[start], padBottom: Math.max(0, totalH - offsets[end]) };
|
|
4895
4787
|
}, [virtualizing, offsets, middleRows.length, vh, scrollTop, overscan]);
|
|
4896
|
-
|
|
4788
|
+
React23__default.useLayoutEffect(() => {
|
|
4897
4789
|
if (!virtualizing) return;
|
|
4898
4790
|
const el = scrollRef.current;
|
|
4899
4791
|
if (!el) return;
|
|
@@ -4908,9 +4800,9 @@ function Datatable({
|
|
|
4908
4800
|
}
|
|
4909
4801
|
if (changed) setMeasureTick((t) => t + 1);
|
|
4910
4802
|
});
|
|
4911
|
-
const onServerChangeRef =
|
|
4803
|
+
const onServerChangeRef = React23__default.useRef(onServerChange);
|
|
4912
4804
|
onServerChangeRef.current = onServerChange;
|
|
4913
|
-
|
|
4805
|
+
React23__default.useEffect(() => {
|
|
4914
4806
|
if (!serverMode) return;
|
|
4915
4807
|
const t = setTimeout(() => {
|
|
4916
4808
|
onServerChangeRef.current?.({
|
|
@@ -4945,7 +4837,7 @@ function Datatable({
|
|
|
4945
4837
|
return n;
|
|
4946
4838
|
});
|
|
4947
4839
|
}
|
|
4948
|
-
const movableMidFields =
|
|
4840
|
+
const movableMidFields = React23__default.useMemo(
|
|
4949
4841
|
() => ordered.filter((c) => !pins.left.includes(c.field) && !pins.right.includes(c.field)).map((c) => c.field),
|
|
4950
4842
|
[ordered, pins]
|
|
4951
4843
|
);
|
|
@@ -4976,7 +4868,7 @@ function Datatable({
|
|
|
4976
4868
|
}
|
|
4977
4869
|
return [...set].sort((a, b) => a.localeCompare(b)).map((v) => ({ value: v, label: v }));
|
|
4978
4870
|
}
|
|
4979
|
-
const [resizing, setResizing] =
|
|
4871
|
+
const [resizing, setResizing] = React23__default.useState(false);
|
|
4980
4872
|
function startResize(e, field) {
|
|
4981
4873
|
e.preventDefault();
|
|
4982
4874
|
e.stopPropagation();
|
|
@@ -5083,7 +4975,7 @@ function Datatable({
|
|
|
5083
4975
|
if (!agg) return null;
|
|
5084
4976
|
if (aggregationValues && col.field in aggregationValues) {
|
|
5085
4977
|
const pre = aggregationValues[col.field];
|
|
5086
|
-
if (pre && typeof pre === "object" && !
|
|
4978
|
+
if (pre && typeof pre === "object" && !React23__default.isValidElement(pre)) {
|
|
5087
4979
|
if (typeof agg === "string" && agg in pre) return pre[agg];
|
|
5088
4980
|
} else {
|
|
5089
4981
|
return pre;
|
|
@@ -5201,14 +5093,14 @@ function Datatable({
|
|
|
5201
5093
|
focusCell(r, c);
|
|
5202
5094
|
}
|
|
5203
5095
|
}
|
|
5204
|
-
|
|
5096
|
+
React23__default.useEffect(() => {
|
|
5205
5097
|
setFocus((f) => ({ r: Math.min(f.r, Math.max(0, leafRows.length - 1)), c: Math.min(f.c, Math.max(0, ordered.length - 1)) }));
|
|
5206
5098
|
}, [leafRows.length, ordered.length, page]);
|
|
5207
|
-
const selectedRows =
|
|
5099
|
+
const selectedRows = React23__default.useMemo(() => rows.filter((r, i) => selected.has(keyOf(r, i))), [rows, selected]);
|
|
5208
5100
|
function clearSelection() {
|
|
5209
5101
|
setSelected(/* @__PURE__ */ new Set());
|
|
5210
5102
|
}
|
|
5211
|
-
const [editing, setEditing] =
|
|
5103
|
+
const [editing, setEditing] = React23__default.useState(null);
|
|
5212
5104
|
const isColEditable = (c) => c.type !== "actions" && (c.editable ?? (editMode && c.editable !== false));
|
|
5213
5105
|
function beginEdit(rowK, col, row) {
|
|
5214
5106
|
if (!isColEditable(col)) return;
|
|
@@ -5243,17 +5135,17 @@ function Datatable({
|
|
|
5243
5135
|
cancelEdit();
|
|
5244
5136
|
}
|
|
5245
5137
|
}
|
|
5246
|
-
const batchEditableCols =
|
|
5138
|
+
const batchEditableCols = React23__default.useMemo(
|
|
5247
5139
|
() => cols.filter((c) => c.type !== "actions" && (c.editable ?? (editMode && c.editable !== false))),
|
|
5248
5140
|
[cols, editMode]
|
|
5249
5141
|
);
|
|
5250
|
-
const [batchEdit, setBatchEdit] =
|
|
5142
|
+
const [batchEdit, setBatchEdit] = React23__default.useState(null);
|
|
5251
5143
|
const [batchEditPos, openBatchEdit, closeBatchEdit] = useFloating();
|
|
5252
5144
|
function openBatchEditor(el) {
|
|
5253
5145
|
setBatchEdit({ fields: {}, values: {} });
|
|
5254
5146
|
openBatchEdit(el, "left", 320);
|
|
5255
5147
|
}
|
|
5256
|
-
|
|
5148
|
+
React23__default.useEffect(() => {
|
|
5257
5149
|
if (!batchEdit) return;
|
|
5258
5150
|
const close = () => {
|
|
5259
5151
|
setBatchEdit(null);
|
|
@@ -5272,7 +5164,7 @@ function Datatable({
|
|
|
5272
5164
|
document.removeEventListener("keydown", onKey);
|
|
5273
5165
|
};
|
|
5274
5166
|
}, [batchEdit]);
|
|
5275
|
-
|
|
5167
|
+
React23__default.useEffect(() => {
|
|
5276
5168
|
if (batchEdit && selected.size === 0) {
|
|
5277
5169
|
setBatchEdit(null);
|
|
5278
5170
|
closeBatchEdit();
|
|
@@ -5309,7 +5201,7 @@ function Datatable({
|
|
|
5309
5201
|
setBatchEdit(null);
|
|
5310
5202
|
closeBatchEdit();
|
|
5311
5203
|
}
|
|
5312
|
-
|
|
5204
|
+
React23__default.useEffect(() => {
|
|
5313
5205
|
if (!editing) return;
|
|
5314
5206
|
const onDown = (e) => {
|
|
5315
5207
|
if (e.target.closest(".twc-dt__editor-wrap") || e.target.closest(".twc-pop")) return;
|
|
@@ -5665,6 +5557,7 @@ function Datatable({
|
|
|
5665
5557
|
] }) });
|
|
5666
5558
|
}
|
|
5667
5559
|
return /* @__PURE__ */ jsxs("div", { className: `twc-dt ${className}`, ref: rootRef, "data-density": density, "data-resizing": resizing || void 0, ...rest, children: [
|
|
5560
|
+
__twcStyles,
|
|
5668
5561
|
/* @__PURE__ */ jsxs("div", { className: "twc-dt__toolbar", "data-compact": compact || void 0, children: [
|
|
5669
5562
|
batchActions.length && selected.size > 0 ? /* @__PURE__ */ jsxs("div", { className: "twc-dt__batch", children: [
|
|
5670
5563
|
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__batch-x", onClick: clearSelection, "aria-label": "Clear selection", children: /* @__PURE__ */ jsx(Svg, { d: I.x }) }),
|
|
@@ -6819,36 +6712,25 @@ function DatePicker({
|
|
|
6819
6712
|
className = "",
|
|
6820
6713
|
...rest
|
|
6821
6714
|
}) {
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
fel.id = "twc-field-styles";
|
|
6826
|
-
fel.textContent = FIELD_CSS3;
|
|
6827
|
-
document.head.appendChild(fel);
|
|
6828
|
-
}
|
|
6829
|
-
if (document.getElementById("twc-datepicker-styles")) return;
|
|
6830
|
-
const el = document.createElement("style");
|
|
6831
|
-
el.id = "twc-datepicker-styles";
|
|
6832
|
-
el.textContent = DATEPICKER_CSS;
|
|
6833
|
-
document.head.appendChild(el);
|
|
6834
|
-
}, []);
|
|
6835
|
-
const autoId = React22.useId();
|
|
6715
|
+
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS3);
|
|
6716
|
+
const __twcStyles1 = useScopedStyles("twc-datepicker-styles", DATEPICKER_CSS);
|
|
6717
|
+
const autoId = React23__default.useId();
|
|
6836
6718
|
const fieldId = id || autoId;
|
|
6837
6719
|
const descId = `${fieldId}-desc`;
|
|
6838
6720
|
const invalid = Boolean(error);
|
|
6839
|
-
const [internal, setInternal] =
|
|
6721
|
+
const [internal, setInternal] = React23__default.useState(defaultValue);
|
|
6840
6722
|
const selected = value !== void 0 ? value : internal;
|
|
6841
|
-
const [open, setOpen] =
|
|
6842
|
-
const [view, setView] =
|
|
6843
|
-
const [mode, setMode] =
|
|
6844
|
-
const [focusDate, setFocusDate] =
|
|
6845
|
-
const [coords, setCoords] =
|
|
6846
|
-
const wrapRef =
|
|
6847
|
-
const triggerRef =
|
|
6848
|
-
const popRef =
|
|
6849
|
-
const gridRef =
|
|
6723
|
+
const [open, setOpen] = React23__default.useState(false);
|
|
6724
|
+
const [view, setView] = React23__default.useState(selected || /* @__PURE__ */ new Date());
|
|
6725
|
+
const [mode, setMode] = React23__default.useState("days");
|
|
6726
|
+
const [focusDate, setFocusDate] = React23__default.useState(null);
|
|
6727
|
+
const [coords, setCoords] = React23__default.useState(null);
|
|
6728
|
+
const wrapRef = React23__default.useRef(null);
|
|
6729
|
+
const triggerRef = React23__default.useRef(null);
|
|
6730
|
+
const popRef = React23__default.useRef(null);
|
|
6731
|
+
const gridRef = React23__default.useRef(null);
|
|
6850
6732
|
const POP_W = 280;
|
|
6851
|
-
const place =
|
|
6733
|
+
const place = React23__default.useCallback(() => {
|
|
6852
6734
|
const el = triggerRef.current;
|
|
6853
6735
|
if (!el) return;
|
|
6854
6736
|
const r = el.getBoundingClientRect();
|
|
@@ -6859,7 +6741,7 @@ function DatePicker({
|
|
|
6859
6741
|
left = Math.max(8, left);
|
|
6860
6742
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
6861
6743
|
}, []);
|
|
6862
|
-
|
|
6744
|
+
React23__default.useEffect(() => {
|
|
6863
6745
|
if (!open) return void 0;
|
|
6864
6746
|
place();
|
|
6865
6747
|
const onMove = () => place();
|
|
@@ -6870,7 +6752,7 @@ function DatePicker({
|
|
|
6870
6752
|
window.removeEventListener("resize", onMove);
|
|
6871
6753
|
};
|
|
6872
6754
|
}, [open, place]);
|
|
6873
|
-
|
|
6755
|
+
React23__default.useEffect(() => {
|
|
6874
6756
|
if (!open) return;
|
|
6875
6757
|
setView(selected || /* @__PURE__ */ new Date());
|
|
6876
6758
|
setMode("days");
|
|
@@ -6890,8 +6772,8 @@ function DatePicker({
|
|
|
6890
6772
|
document.removeEventListener("keydown", onKey);
|
|
6891
6773
|
};
|
|
6892
6774
|
}, [open]);
|
|
6893
|
-
const prevOpen =
|
|
6894
|
-
|
|
6775
|
+
const prevOpen = React23__default.useRef(false);
|
|
6776
|
+
React23__default.useEffect(() => {
|
|
6895
6777
|
let id2;
|
|
6896
6778
|
if (!prevOpen.current && open) {
|
|
6897
6779
|
id2 = setTimeout(() => gridRef.current?.querySelector('[tabindex="0"]')?.focus({ preventScroll: true }), 30);
|
|
@@ -6902,9 +6784,9 @@ function DatePicker({
|
|
|
6902
6784
|
prevOpen.current = open;
|
|
6903
6785
|
return () => clearTimeout(id2);
|
|
6904
6786
|
}, [open]);
|
|
6905
|
-
const months =
|
|
6906
|
-
const monthsShort =
|
|
6907
|
-
const dows =
|
|
6787
|
+
const months = React23__default.useMemo(() => locale === void 0 ? MONTHS : monthNames(locale), [locale]);
|
|
6788
|
+
const monthsShort = React23__default.useMemo(() => locale === void 0 ? MONTHS.map((n) => n.slice(0, 3)) : monthShortNames(locale), [locale]);
|
|
6789
|
+
const dows = React23__default.useMemo(
|
|
6908
6790
|
() => locale === void 0 ? Array.from({ length: 7 }, (_, i) => DOW[(i + weekStartsOn) % 7]) : weekdayNames(locale, weekStartsOn),
|
|
6909
6791
|
[locale, weekStartsOn]
|
|
6910
6792
|
);
|
|
@@ -6932,7 +6814,7 @@ function DatePicker({
|
|
|
6932
6814
|
};
|
|
6933
6815
|
const cells = Array.from({ length: 42 }, (_, i) => new Date(gridStart.getFullYear(), gridStart.getMonth(), gridStart.getDate() + i));
|
|
6934
6816
|
const tabbableDate = (focusDate && cells.some((c) => sameDay(c, focusDate)) ? focusDate : null) || (selected && cells.some((c) => sameDay(c, selected)) ? selected : null) || (cells.some((c) => sameDay(c, today)) ? today : null) || new Date(y, m, 1);
|
|
6935
|
-
|
|
6817
|
+
React23__default.useEffect(() => {
|
|
6936
6818
|
if (!open || mode !== "days" || !focusDate) return;
|
|
6937
6819
|
gridRef.current?.querySelector(`[data-key="${keyOf(focusDate)}"]`)?.focus();
|
|
6938
6820
|
}, [focusDate, open, mode]);
|
|
@@ -6963,6 +6845,8 @@ function DatePicker({
|
|
|
6963
6845
|
if (next.getFullYear() !== y || next.getMonth() !== m) setView(new Date(next.getFullYear(), next.getMonth(), 1));
|
|
6964
6846
|
};
|
|
6965
6847
|
return /* @__PURE__ */ jsxs("div", { className: `twc-dp twc-field ${className}`, ref: wrapRef, ...rest, children: [
|
|
6848
|
+
__twcStyles0,
|
|
6849
|
+
__twcStyles1,
|
|
6966
6850
|
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", id: `${fieldId}-label`, children: [
|
|
6967
6851
|
label,
|
|
6968
6852
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -7151,36 +7035,25 @@ function DateRangePicker({
|
|
|
7151
7035
|
className = "",
|
|
7152
7036
|
...rest
|
|
7153
7037
|
}) {
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
fel.id = "twc-field-styles";
|
|
7158
|
-
fel.textContent = FIELD_CSS4;
|
|
7159
|
-
document.head.appendChild(fel);
|
|
7160
|
-
}
|
|
7161
|
-
if (document.getElementById("twc-drp-styles")) return;
|
|
7162
|
-
const el = document.createElement("style");
|
|
7163
|
-
el.id = "twc-drp-styles";
|
|
7164
|
-
el.textContent = RANGE_CSS;
|
|
7165
|
-
document.head.appendChild(el);
|
|
7166
|
-
}, []);
|
|
7167
|
-
const [internal, setInternal] = React22.useState(defaultValue);
|
|
7038
|
+
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS4);
|
|
7039
|
+
const __twcStyles1 = useScopedStyles("twc-drp-styles", RANGE_CSS);
|
|
7040
|
+
const [internal, setInternal] = React23__default.useState(defaultValue);
|
|
7168
7041
|
const range = value !== void 0 ? value : internal;
|
|
7169
|
-
const [open, setOpen] =
|
|
7170
|
-
const [view, setView] =
|
|
7171
|
-
const [hover, setHover] =
|
|
7172
|
-
const [coords, setCoords] =
|
|
7173
|
-
const wrapRef =
|
|
7174
|
-
const triggerRef =
|
|
7175
|
-
const popRef =
|
|
7176
|
-
const labelId =
|
|
7042
|
+
const [open, setOpen] = React23__default.useState(false);
|
|
7043
|
+
const [view, setView] = React23__default.useState(range.start || /* @__PURE__ */ new Date());
|
|
7044
|
+
const [hover, setHover] = React23__default.useState(null);
|
|
7045
|
+
const [coords, setCoords] = React23__default.useState(null);
|
|
7046
|
+
const wrapRef = React23__default.useRef(null);
|
|
7047
|
+
const triggerRef = React23__default.useRef(null);
|
|
7048
|
+
const popRef = React23__default.useRef(null);
|
|
7049
|
+
const labelId = React23__default.useId();
|
|
7177
7050
|
const descId = `${labelId}-desc`;
|
|
7178
7051
|
const invalid = Boolean(error);
|
|
7179
|
-
|
|
7052
|
+
React23__default.useEffect(() => {
|
|
7180
7053
|
if (disabled) setOpen(false);
|
|
7181
7054
|
}, [disabled]);
|
|
7182
7055
|
const POP_W = 420;
|
|
7183
|
-
const place =
|
|
7056
|
+
const place = React23__default.useCallback(() => {
|
|
7184
7057
|
const el = triggerRef.current;
|
|
7185
7058
|
if (!el) return;
|
|
7186
7059
|
const r = el.getBoundingClientRect();
|
|
@@ -7191,7 +7064,7 @@ function DateRangePicker({
|
|
|
7191
7064
|
left = Math.max(8, left);
|
|
7192
7065
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
7193
7066
|
}, []);
|
|
7194
|
-
|
|
7067
|
+
React23__default.useEffect(() => {
|
|
7195
7068
|
if (!open) return void 0;
|
|
7196
7069
|
place();
|
|
7197
7070
|
const onMove = () => place();
|
|
@@ -7202,7 +7075,7 @@ function DateRangePicker({
|
|
|
7202
7075
|
window.removeEventListener("resize", onMove);
|
|
7203
7076
|
};
|
|
7204
7077
|
}, [open, place]);
|
|
7205
|
-
|
|
7078
|
+
React23__default.useEffect(() => {
|
|
7206
7079
|
if (!open) return;
|
|
7207
7080
|
const onDown = (e) => {
|
|
7208
7081
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -7240,8 +7113,8 @@ function DateRangePicker({
|
|
|
7240
7113
|
setView(start);
|
|
7241
7114
|
setOpen(false);
|
|
7242
7115
|
};
|
|
7243
|
-
const months =
|
|
7244
|
-
const dows =
|
|
7116
|
+
const months = React23__default.useMemo(() => locale === void 0 ? MONTHS2 : monthNames2(locale), [locale]);
|
|
7117
|
+
const dows = React23__default.useMemo(
|
|
7245
7118
|
() => locale === void 0 ? Array.from({ length: 7 }, (_, i) => DOW2[(i + weekStartsOn) % 7]) : weekdayNames2(locale, weekStartsOn),
|
|
7246
7119
|
[locale, weekStartsOn]
|
|
7247
7120
|
);
|
|
@@ -7265,6 +7138,8 @@ function DateRangePicker({
|
|
|
7265
7138
|
};
|
|
7266
7139
|
const text = range.start ? `${fmtD(range.start, locale)} \u2013 ${range.end ? fmtD(range.end, locale) : "\u2026"}` : "";
|
|
7267
7140
|
return /* @__PURE__ */ jsxs("div", { className: `twc-drp twc-field ${className}`, ref: wrapRef, ...rest, children: [
|
|
7141
|
+
__twcStyles0,
|
|
7142
|
+
__twcStyles1,
|
|
7268
7143
|
label ? /* @__PURE__ */ jsxs("span", { className: "twc-field__label", id: labelId, children: [
|
|
7269
7144
|
label,
|
|
7270
7145
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -7420,19 +7295,13 @@ function Dialog({
|
|
|
7420
7295
|
className = "",
|
|
7421
7296
|
...rest
|
|
7422
7297
|
}) {
|
|
7423
|
-
const autoId =
|
|
7298
|
+
const autoId = React23__default.useId();
|
|
7424
7299
|
const titleId = `${autoId}-title`;
|
|
7425
7300
|
const descId = `${autoId}-desc`;
|
|
7426
|
-
const dialogRef =
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
el.id = "twc-dialog-styles";
|
|
7431
|
-
el.textContent = DIALOG_CSS;
|
|
7432
|
-
document.head.appendChild(el);
|
|
7433
|
-
}, []);
|
|
7434
|
-
const [mounted, setMounted] = React22.useState(open);
|
|
7435
|
-
React22.useEffect(() => {
|
|
7301
|
+
const dialogRef = React23__default.useRef(null);
|
|
7302
|
+
const __twcStyles = useScopedStyles("twc-dialog-styles", DIALOG_CSS);
|
|
7303
|
+
const [mounted, setMounted] = React23__default.useState(open);
|
|
7304
|
+
React23__default.useEffect(() => {
|
|
7436
7305
|
if (open) {
|
|
7437
7306
|
setMounted(true);
|
|
7438
7307
|
return;
|
|
@@ -7440,7 +7309,7 @@ function Dialog({
|
|
|
7440
7309
|
const t = setTimeout(() => setMounted(false), 170);
|
|
7441
7310
|
return () => clearTimeout(t);
|
|
7442
7311
|
}, [open]);
|
|
7443
|
-
|
|
7312
|
+
React23__default.useEffect(() => {
|
|
7444
7313
|
if (!open) return void 0;
|
|
7445
7314
|
const prev = document.body.style.overflow;
|
|
7446
7315
|
document.body.style.overflow = "hidden";
|
|
@@ -7448,7 +7317,7 @@ function Dialog({
|
|
|
7448
7317
|
document.body.style.overflow = prev;
|
|
7449
7318
|
};
|
|
7450
7319
|
}, [open]);
|
|
7451
|
-
|
|
7320
|
+
React23__default.useEffect(() => {
|
|
7452
7321
|
if (!open || !mounted) return void 0;
|
|
7453
7322
|
const node = dialogRef.current;
|
|
7454
7323
|
const prevFocused = document.activeElement;
|
|
@@ -7460,7 +7329,7 @@ function Dialog({
|
|
|
7460
7329
|
if (prevFocused && typeof prevFocused.focus === "function") prevFocused.focus();
|
|
7461
7330
|
};
|
|
7462
7331
|
}, [open, mounted]);
|
|
7463
|
-
|
|
7332
|
+
React23__default.useEffect(() => {
|
|
7464
7333
|
if (!open) return;
|
|
7465
7334
|
const node = dialogRef.current;
|
|
7466
7335
|
const focusables = () => node ? Array.from(
|
|
@@ -7497,19 +7366,22 @@ function Dialog({
|
|
|
7497
7366
|
}, [open, onClose]);
|
|
7498
7367
|
if (!mounted) return null;
|
|
7499
7368
|
const state = open ? "open" : "closed";
|
|
7500
|
-
const overlay = /* @__PURE__ */
|
|
7369
|
+
const overlay = /* @__PURE__ */ jsxs("div", { className: "twc-dialog__overlay", "data-state": state, onMouseDown: (e) => {
|
|
7501
7370
|
if (closeOnBackdrop && e.target === e.currentTarget) onClose?.();
|
|
7502
|
-
}, children:
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7371
|
+
}, children: [
|
|
7372
|
+
__twcStyles,
|
|
7373
|
+
/* @__PURE__ */ jsxs("div", { ref: dialogRef, className: `twc-dialog ${className}`, "data-state": state, "data-size": size, "data-scroll-body": scrollBody ? "true" : void 0, role: "dialog", "aria-modal": "true", tabIndex: -1, "aria-labelledby": title ? titleId : void 0, "aria-label": !title ? "Dialog" : void 0, "aria-describedby": description ? descId : void 0, ...rest, children: [
|
|
7374
|
+
title || description || onClose ? /* @__PURE__ */ jsxs("div", { className: "twc-dialog__header", children: [
|
|
7375
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-dialog__titles", children: [
|
|
7376
|
+
title ? /* @__PURE__ */ jsx("div", { className: "twc-dialog__title", id: titleId, children: title }) : null,
|
|
7377
|
+
description ? /* @__PURE__ */ jsx("div", { className: "twc-dialog__desc", id: descId, children: description }) : null
|
|
7378
|
+
] }),
|
|
7379
|
+
onClose ? /* @__PURE__ */ jsx("button", { className: "twc-dialog__close", onClick: onClose, "aria-label": "Close", type: "button", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) }) }) : null
|
|
7380
|
+
] }) : null,
|
|
7381
|
+
children ? /* @__PURE__ */ jsx("div", { className: "twc-dialog__body", children }) : null,
|
|
7382
|
+
footer ? /* @__PURE__ */ jsx("div", { className: "twc-dialog__footer", children: footer }) : null
|
|
7383
|
+
] })
|
|
7384
|
+
] });
|
|
7513
7385
|
if (typeof document === "undefined") return null;
|
|
7514
7386
|
const RD = typeof createPortal === "function" ? createPortal : null;
|
|
7515
7387
|
return RD ? RD(overlay, document.body) : overlay;
|
|
@@ -7536,28 +7408,28 @@ function Divider({
|
|
|
7536
7408
|
className = "",
|
|
7537
7409
|
...rest
|
|
7538
7410
|
}) {
|
|
7539
|
-
|
|
7540
|
-
if (document.getElementById("twc-divider-styles")) return;
|
|
7541
|
-
const el = document.createElement("style");
|
|
7542
|
-
el.id = "twc-divider-styles";
|
|
7543
|
-
el.textContent = DIVIDER_CSS;
|
|
7544
|
-
document.head.appendChild(el);
|
|
7545
|
-
}, []);
|
|
7411
|
+
const __twcStyles = useScopedStyles("twc-divider-styles", DIVIDER_CSS);
|
|
7546
7412
|
const resolvedAlign = align === "left" ? "start" : align === "right" ? "end" : align;
|
|
7547
7413
|
if (children) {
|
|
7548
|
-
return /* @__PURE__ */
|
|
7414
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-divider-label ${className}`, "data-align": resolvedAlign, role: "separator", ...rest, children: [
|
|
7415
|
+
__twcStyles,
|
|
7416
|
+
children
|
|
7417
|
+
] });
|
|
7549
7418
|
}
|
|
7550
|
-
return /* @__PURE__ */
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7419
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7420
|
+
__twcStyles,
|
|
7421
|
+
/* @__PURE__ */ jsx(
|
|
7422
|
+
"hr",
|
|
7423
|
+
{
|
|
7424
|
+
className: `twc-divider ${className}`,
|
|
7425
|
+
"data-orientation": orientation,
|
|
7426
|
+
"data-inset": inset || void 0,
|
|
7427
|
+
role: "separator",
|
|
7428
|
+
"aria-orientation": orientation,
|
|
7429
|
+
...rest
|
|
7430
|
+
}
|
|
7431
|
+
)
|
|
7432
|
+
] });
|
|
7561
7433
|
}
|
|
7562
7434
|
var DRAWER_CSS = `
|
|
7563
7435
|
.twc-drawer__overlay { position: fixed; inset: 0; z-index: var(--z-modal); background: var(--color-overlay); backdrop-filter: blur(2px); }
|
|
@@ -7626,19 +7498,13 @@ function Drawer({
|
|
|
7626
7498
|
style,
|
|
7627
7499
|
...rest
|
|
7628
7500
|
}) {
|
|
7629
|
-
const autoId =
|
|
7501
|
+
const autoId = React23__default.useId();
|
|
7630
7502
|
const titleId = `${autoId}-title`;
|
|
7631
7503
|
const descId = `${autoId}-desc`;
|
|
7632
|
-
const panelRef =
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
el.id = "twc-drawer-styles";
|
|
7637
|
-
el.textContent = DRAWER_CSS;
|
|
7638
|
-
document.head.appendChild(el);
|
|
7639
|
-
}, []);
|
|
7640
|
-
const [mounted, setMounted] = React22.useState(open);
|
|
7641
|
-
React22.useEffect(() => {
|
|
7504
|
+
const panelRef = React23__default.useRef(null);
|
|
7505
|
+
const __twcStyles = useScopedStyles("twc-drawer-styles", DRAWER_CSS);
|
|
7506
|
+
const [mounted, setMounted] = React23__default.useState(open);
|
|
7507
|
+
React23__default.useEffect(() => {
|
|
7642
7508
|
if (open) {
|
|
7643
7509
|
setMounted(true);
|
|
7644
7510
|
return;
|
|
@@ -7646,7 +7512,7 @@ function Drawer({
|
|
|
7646
7512
|
const t = setTimeout(() => setMounted(false), 170);
|
|
7647
7513
|
return () => clearTimeout(t);
|
|
7648
7514
|
}, [open]);
|
|
7649
|
-
|
|
7515
|
+
React23__default.useEffect(() => {
|
|
7650
7516
|
if (!open) return void 0;
|
|
7651
7517
|
const prev = document.body.style.overflow;
|
|
7652
7518
|
document.body.style.overflow = "hidden";
|
|
@@ -7654,7 +7520,7 @@ function Drawer({
|
|
|
7654
7520
|
document.body.style.overflow = prev;
|
|
7655
7521
|
};
|
|
7656
7522
|
}, [open]);
|
|
7657
|
-
|
|
7523
|
+
React23__default.useEffect(() => {
|
|
7658
7524
|
if (!open || !mounted) return void 0;
|
|
7659
7525
|
const node = panelRef.current;
|
|
7660
7526
|
const prevFocused = document.activeElement;
|
|
@@ -7666,7 +7532,7 @@ function Drawer({
|
|
|
7666
7532
|
if (prevFocused && typeof prevFocused.focus === "function") prevFocused.focus();
|
|
7667
7533
|
};
|
|
7668
7534
|
}, [open, mounted]);
|
|
7669
|
-
|
|
7535
|
+
React23__default.useEffect(() => {
|
|
7670
7536
|
if (!open) return;
|
|
7671
7537
|
const node = panelRef.current;
|
|
7672
7538
|
const focusables = () => node ? Array.from(
|
|
@@ -7707,19 +7573,22 @@ function Drawer({
|
|
|
7707
7573
|
const raw = isHorizontal ? width : height;
|
|
7708
7574
|
const dim = DRAWER_SIZES[raw] || (typeof raw === "number" ? `${raw}px` : raw);
|
|
7709
7575
|
const sizeVar = isHorizontal ? { "--_w": dim } : { "--_h": dim };
|
|
7710
|
-
const overlay = /* @__PURE__ */
|
|
7576
|
+
const overlay = /* @__PURE__ */ jsxs("div", { className: "twc-drawer__overlay", "data-state": state, onMouseDown: (e) => {
|
|
7711
7577
|
if (closeOnBackdrop && e.target === e.currentTarget) onClose?.();
|
|
7712
|
-
}, children:
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7578
|
+
}, children: [
|
|
7579
|
+
__twcStyles,
|
|
7580
|
+
/* @__PURE__ */ jsxs("div", { ref: panelRef, className: `twc-drawer ${className}`, "data-side": side, "data-state": state, role: "dialog", "aria-modal": "true", tabIndex: -1, "aria-labelledby": title ? titleId : void 0, "aria-label": !title ? "Drawer" : void 0, "aria-describedby": description ? descId : void 0, style: { ...dim ? sizeVar : null, ...style }, ...rest, children: [
|
|
7581
|
+
title || description || onClose ? /* @__PURE__ */ jsxs("div", { className: "twc-drawer__header", children: [
|
|
7582
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-drawer__titles", children: [
|
|
7583
|
+
title ? /* @__PURE__ */ jsx("div", { className: "twc-drawer__title", id: titleId, children: title }) : null,
|
|
7584
|
+
description ? /* @__PURE__ */ jsx("div", { className: "twc-drawer__desc", id: descId, children: description }) : null
|
|
7585
|
+
] }),
|
|
7586
|
+
onClose ? /* @__PURE__ */ jsx("button", { className: "twc-drawer__close", onClick: onClose, "aria-label": "Close", type: "button", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) }) }) : null
|
|
7587
|
+
] }) : null,
|
|
7588
|
+
/* @__PURE__ */ jsx("div", { className: "twc-drawer__body", children }),
|
|
7589
|
+
footer ? /* @__PURE__ */ jsx("div", { className: "twc-drawer__footer", children: footer }) : null
|
|
7590
|
+
] })
|
|
7591
|
+
] });
|
|
7723
7592
|
if (typeof document === "undefined") return null;
|
|
7724
7593
|
const RD = typeof createPortal === "function" ? createPortal : null;
|
|
7725
7594
|
return RD ? RD(overlay, document.body) : overlay;
|
|
@@ -7746,14 +7615,9 @@ function EmptyState({
|
|
|
7746
7615
|
...rest
|
|
7747
7616
|
}) {
|
|
7748
7617
|
const hasBorder = border ?? bordered;
|
|
7749
|
-
|
|
7750
|
-
if (document.getElementById("twc-empty-styles")) return;
|
|
7751
|
-
const el = document.createElement("style");
|
|
7752
|
-
el.id = "twc-empty-styles";
|
|
7753
|
-
el.textContent = EMPTY_CSS;
|
|
7754
|
-
document.head.appendChild(el);
|
|
7755
|
-
}, []);
|
|
7618
|
+
const __twcStyles = useScopedStyles("twc-empty-styles", EMPTY_CSS);
|
|
7756
7619
|
return /* @__PURE__ */ jsxs("div", { className: `twc-empty ${className}`, "data-bordered": hasBorder || void 0, ...rest, children: [
|
|
7620
|
+
__twcStyles,
|
|
7757
7621
|
icon ? /* @__PURE__ */ jsx("span", { className: "twc-empty__icon", "aria-hidden": "true", children: icon }) : null,
|
|
7758
7622
|
title ? /* @__PURE__ */ jsx("div", { className: "twc-empty__title", children: title }) : null,
|
|
7759
7623
|
description ? /* @__PURE__ */ jsx("div", { className: "twc-empty__desc", children: description }) : null,
|
|
@@ -7767,15 +7631,6 @@ var FIELD_CSS5 = `
|
|
|
7767
7631
|
.twc-field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
7768
7632
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
7769
7633
|
`;
|
|
7770
|
-
function useFieldStyles2() {
|
|
7771
|
-
React22.useInsertionEffect(() => {
|
|
7772
|
-
if (document.getElementById("twc-field-styles")) return;
|
|
7773
|
-
const el = document.createElement("style");
|
|
7774
|
-
el.id = "twc-field-styles";
|
|
7775
|
-
el.textContent = FIELD_CSS5;
|
|
7776
|
-
document.head.appendChild(el);
|
|
7777
|
-
}, []);
|
|
7778
|
-
}
|
|
7779
7634
|
function Field({
|
|
7780
7635
|
label,
|
|
7781
7636
|
hint,
|
|
@@ -7788,11 +7643,12 @@ function Field({
|
|
|
7788
7643
|
children,
|
|
7789
7644
|
...rest
|
|
7790
7645
|
}) {
|
|
7791
|
-
|
|
7792
|
-
const autoId =
|
|
7646
|
+
const __twcStyles = useScopedStyles("twc-field-styles", FIELD_CSS5);
|
|
7647
|
+
const autoId = React23__default.useId();
|
|
7793
7648
|
const fieldId = id || autoId;
|
|
7794
7649
|
const descId = `${fieldId}-desc`;
|
|
7795
7650
|
return /* @__PURE__ */ jsxs("div", { className: `twc-field ${className}`, "data-size": size, ...rest, children: [
|
|
7651
|
+
__twcStyles,
|
|
7796
7652
|
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", htmlFor, children: [
|
|
7797
7653
|
label,
|
|
7798
7654
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -7867,18 +7723,12 @@ function FileUpload({
|
|
|
7867
7723
|
className = "",
|
|
7868
7724
|
...rest
|
|
7869
7725
|
}) {
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
const el = document.createElement("style");
|
|
7873
|
-
el.id = "twc-upload-styles";
|
|
7874
|
-
el.textContent = UPLOAD_CSS;
|
|
7875
|
-
document.head.appendChild(el);
|
|
7876
|
-
}, []);
|
|
7877
|
-
const [internal, setInternal] = React22.useState(defaultValue);
|
|
7726
|
+
const __twcStyles = useScopedStyles("twc-upload-styles", UPLOAD_CSS);
|
|
7727
|
+
const [internal, setInternal] = React23__default.useState(defaultValue);
|
|
7878
7728
|
const files = value !== void 0 ? value : internal;
|
|
7879
|
-
const [drag, setDrag] =
|
|
7880
|
-
const inputRef =
|
|
7881
|
-
const autoId =
|
|
7729
|
+
const [drag, setDrag] = React23__default.useState(false);
|
|
7730
|
+
const inputRef = React23__default.useRef(null);
|
|
7731
|
+
const autoId = React23__default.useId();
|
|
7882
7732
|
const fieldId = id || autoId;
|
|
7883
7733
|
const descId = `${fieldId}-desc`;
|
|
7884
7734
|
const invalid = Boolean(error);
|
|
@@ -7894,6 +7744,7 @@ function FileUpload({
|
|
|
7894
7744
|
set(files.filter((_, idx) => idx !== i));
|
|
7895
7745
|
}
|
|
7896
7746
|
return /* @__PURE__ */ jsxs("div", { className: `twc-upload ${className}`, ...rest, children: [
|
|
7747
|
+
__twcStyles,
|
|
7897
7748
|
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
7898
7749
|
label,
|
|
7899
7750
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -8025,14 +7876,8 @@ function IconButton({
|
|
|
8025
7876
|
"aria-label": ariaLabel,
|
|
8026
7877
|
...rest
|
|
8027
7878
|
}) {
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
const el = document.createElement("style");
|
|
8031
|
-
el.id = "twc-iconbtn-styles";
|
|
8032
|
-
el.textContent = ICONBTN_CSS;
|
|
8033
|
-
document.head.appendChild(el);
|
|
8034
|
-
}, []);
|
|
8035
|
-
return /* @__PURE__ */ jsx(
|
|
7879
|
+
const __twcStyles = useScopedStyles("twc-iconbtn-styles", ICONBTN_CSS);
|
|
7880
|
+
return /* @__PURE__ */ jsxs(
|
|
8036
7881
|
"button",
|
|
8037
7882
|
{
|
|
8038
7883
|
className: `twc-iconbtn ${className}`,
|
|
@@ -8044,7 +7889,10 @@ function IconButton({
|
|
|
8044
7889
|
type: "button",
|
|
8045
7890
|
"aria-label": ariaLabel,
|
|
8046
7891
|
...rest,
|
|
8047
|
-
children:
|
|
7892
|
+
children: [
|
|
7893
|
+
__twcStyles,
|
|
7894
|
+
icon || children
|
|
7895
|
+
]
|
|
8048
7896
|
}
|
|
8049
7897
|
);
|
|
8050
7898
|
}
|
|
@@ -8081,22 +7929,16 @@ function Kanban({
|
|
|
8081
7929
|
className = "",
|
|
8082
7930
|
...rest
|
|
8083
7931
|
}) {
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
const el = document.createElement("style");
|
|
8087
|
-
el.id = "twc-kanban-styles";
|
|
8088
|
-
el.textContent = KANBAN_CSS;
|
|
8089
|
-
document.head.appendChild(el);
|
|
8090
|
-
}, []);
|
|
8091
|
-
const [internal, setInternal] = React22.useState(cards ?? defaultCards ?? []);
|
|
7932
|
+
const __twcStyles = useScopedStyles("twc-kanban-styles", KANBAN_CSS);
|
|
7933
|
+
const [internal, setInternal] = React23__default.useState(cards ?? defaultCards ?? []);
|
|
8092
7934
|
const items = cards !== void 0 ? cards : internal;
|
|
8093
|
-
const [drag, setDrag] =
|
|
8094
|
-
const [overCol, setOverCol] =
|
|
8095
|
-
const [grab, setGrab] =
|
|
8096
|
-
const [announce, setAnnounce] =
|
|
8097
|
-
const rootRef =
|
|
8098
|
-
const focusIdRef =
|
|
8099
|
-
|
|
7935
|
+
const [drag, setDrag] = React23__default.useState(null);
|
|
7936
|
+
const [overCol, setOverCol] = React23__default.useState(null);
|
|
7937
|
+
const [grab, setGrab] = React23__default.useState(null);
|
|
7938
|
+
const [announce, setAnnounce] = React23__default.useState("");
|
|
7939
|
+
const rootRef = React23__default.useRef(null);
|
|
7940
|
+
const focusIdRef = React23__default.useRef(null);
|
|
7941
|
+
React23__default.useEffect(() => {
|
|
8100
7942
|
if (focusIdRef.current == null) return void 0;
|
|
8101
7943
|
const raf = requestAnimationFrame(() => {
|
|
8102
7944
|
const id = focusIdRef.current;
|
|
@@ -8149,6 +7991,7 @@ function Kanban({
|
|
|
8149
7991
|
};
|
|
8150
7992
|
const keyTargetCol = grab ? columns[grab.targetIdx]?.id : null;
|
|
8151
7993
|
return /* @__PURE__ */ jsxs("div", { className: `twc-kanban ${className}`, ref: rootRef, ...rest, children: [
|
|
7994
|
+
__twcStyles,
|
|
8152
7995
|
/* @__PURE__ */ jsx("div", { className: "twc-kanban__sr", role: "status", "aria-live": "polite", children: announce }),
|
|
8153
7996
|
columns.map((col, colIdx) => {
|
|
8154
7997
|
const colCards = items.filter((c) => c.column === col.id);
|
|
@@ -8240,43 +8083,40 @@ var LIST_CSS = `
|
|
|
8240
8083
|
.twc-list__trail { flex: none; display: inline-flex; align-items: center; gap: var(--space-2); color: var(--color-text-subtle); font-size: var(--text-sm); }
|
|
8241
8084
|
`;
|
|
8242
8085
|
function List({ items, plain = false, className = "", ...rest }) {
|
|
8243
|
-
|
|
8244
|
-
if (document.getElementById("twc-list-styles")) return;
|
|
8245
|
-
const el = document.createElement("style");
|
|
8246
|
-
el.id = "twc-list-styles";
|
|
8247
|
-
el.textContent = LIST_CSS;
|
|
8248
|
-
document.head.appendChild(el);
|
|
8249
|
-
}, []);
|
|
8086
|
+
const __twcStyles = useScopedStyles("twc-list-styles", LIST_CSS);
|
|
8250
8087
|
const safeHref11 = (url) => {
|
|
8251
8088
|
if (url == null) return void 0;
|
|
8252
8089
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
8253
8090
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
8254
8091
|
};
|
|
8255
|
-
return /* @__PURE__ */
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
/* @__PURE__ */ jsxs(
|
|
8262
|
-
/* @__PURE__ */ jsx("span", { className: "twc-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
{
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8092
|
+
return /* @__PURE__ */ jsxs("ul", { className: `twc-list ${className}`, "data-plain": plain || void 0, ...rest, children: [
|
|
8093
|
+
__twcStyles,
|
|
8094
|
+
items.map((it, i) => {
|
|
8095
|
+
const href = safeHref11(it.href);
|
|
8096
|
+
const interactive = Boolean(it.onClick || href);
|
|
8097
|
+
const Tag2 = href ? "a" : interactive ? "button" : "div";
|
|
8098
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8099
|
+
it.leading ? /* @__PURE__ */ jsx("span", { className: "twc-list__lead", "aria-hidden": "true", children: it.leading }) : null,
|
|
8100
|
+
/* @__PURE__ */ jsxs("span", { className: "twc-list__main", children: [
|
|
8101
|
+
/* @__PURE__ */ jsx("span", { className: "twc-list__title", children: it.title }),
|
|
8102
|
+
it.description ? /* @__PURE__ */ jsx("span", { className: "twc-list__desc", children: it.description }) : null
|
|
8103
|
+
] }),
|
|
8104
|
+
it.trailing ? /* @__PURE__ */ jsx("span", { className: "twc-list__trail", children: it.trailing }) : null
|
|
8105
|
+
] });
|
|
8106
|
+
return /* @__PURE__ */ jsx("li", { style: { display: "contents" }, children: /* @__PURE__ */ jsx(
|
|
8107
|
+
Tag2,
|
|
8108
|
+
{
|
|
8109
|
+
className: "twc-list__item",
|
|
8110
|
+
"data-interactive": interactive || void 0,
|
|
8111
|
+
"data-active": it.active || void 0,
|
|
8112
|
+
href,
|
|
8113
|
+
type: Tag2 === "button" ? "button" : void 0,
|
|
8114
|
+
onClick: it.onClick,
|
|
8115
|
+
children: content
|
|
8116
|
+
}
|
|
8117
|
+
) }, i);
|
|
8118
|
+
})
|
|
8119
|
+
] });
|
|
8280
8120
|
}
|
|
8281
8121
|
var NAVBAR_CSS = `
|
|
8282
8122
|
.twc-navbar { display: flex; align-items: center; gap: var(--space-4); height: 60px; padding: 0 var(--space-5);
|
|
@@ -8322,14 +8162,9 @@ function Navbar({
|
|
|
8322
8162
|
className = "",
|
|
8323
8163
|
...rest
|
|
8324
8164
|
}) {
|
|
8325
|
-
|
|
8326
|
-
if (document.getElementById("twc-navbar-styles")) return;
|
|
8327
|
-
const el = document.createElement("style");
|
|
8328
|
-
el.id = "twc-navbar-styles";
|
|
8329
|
-
el.textContent = NAVBAR_CSS;
|
|
8330
|
-
document.head.appendChild(el);
|
|
8331
|
-
}, []);
|
|
8165
|
+
const __twcStyles = useScopedStyles("twc-navbar-styles", NAVBAR_CSS);
|
|
8332
8166
|
return /* @__PURE__ */ jsxs("header", { className: `twc-navbar ${className}`, "data-sticky": sticky || void 0, ...rest, children: [
|
|
8167
|
+
__twcStyles,
|
|
8333
8168
|
onMenuClick ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-navbar__menu-btn", "aria-label": "Open menu", onClick: onMenuClick, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M4 6h16M4 12h16M4 18h16" }) }) }) : null,
|
|
8334
8169
|
brand ? brandHref ? /* @__PURE__ */ jsx("a", { className: "twc-navbar__brand", href: safeHref3(brandHref), children: brand }) : onBrandClick ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-navbar__brand", onClick: onBrandClick, children: brand }) : /* @__PURE__ */ jsx("span", { className: "twc-navbar__brand", children: brand }) : null,
|
|
8335
8170
|
/* @__PURE__ */ jsx("nav", { className: "twc-navbar__links", children: links.map((l, i) => {
|
|
@@ -8400,28 +8235,22 @@ function Popover({
|
|
|
8400
8235
|
className = "",
|
|
8401
8236
|
...rest
|
|
8402
8237
|
}) {
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
const [openState, setOpenState] = React22.useState(defaultOpen);
|
|
8411
|
-
const [render, setRender] = React22.useState(false);
|
|
8412
|
-
const [pos, setPos] = React22.useState(null);
|
|
8413
|
-
const wrapRef = React22.useRef(null);
|
|
8414
|
-
const popRef = React22.useRef(null);
|
|
8415
|
-
const popId = React22.useId();
|
|
8238
|
+
const __twcStyles = useScopedStyles("twc-popover-styles", POPOVER_CSS);
|
|
8239
|
+
const [openState, setOpenState] = React23__default.useState(defaultOpen);
|
|
8240
|
+
const [render, setRender] = React23__default.useState(false);
|
|
8241
|
+
const [pos, setPos] = React23__default.useState(null);
|
|
8242
|
+
const wrapRef = React23__default.useRef(null);
|
|
8243
|
+
const popRef = React23__default.useRef(null);
|
|
8244
|
+
const popId = React23__default.useId();
|
|
8416
8245
|
const controlled = openProp !== void 0;
|
|
8417
8246
|
const open = controlled ? !!openProp : openState;
|
|
8418
|
-
const openRef =
|
|
8247
|
+
const openRef = React23__default.useRef(open);
|
|
8419
8248
|
openRef.current = open;
|
|
8420
|
-
const controlledRef =
|
|
8249
|
+
const controlledRef = React23__default.useRef(controlled);
|
|
8421
8250
|
controlledRef.current = controlled;
|
|
8422
|
-
const onOpenChangeRef =
|
|
8251
|
+
const onOpenChangeRef = React23__default.useRef(onOpenChange);
|
|
8423
8252
|
onOpenChangeRef.current = onOpenChange;
|
|
8424
|
-
const setOpen =
|
|
8253
|
+
const setOpen = React23__default.useCallback((next) => {
|
|
8425
8254
|
const value = typeof next === "function" ? next(openRef.current) : next;
|
|
8426
8255
|
if (value === openRef.current) return;
|
|
8427
8256
|
if (!controlledRef.current) setOpenState(value);
|
|
@@ -8429,7 +8258,7 @@ function Popover({
|
|
|
8429
8258
|
}, []);
|
|
8430
8259
|
const toggle = () => setOpen((o) => !o);
|
|
8431
8260
|
const RD = { createPortal: typeof createPortal === "function" ? createPortal : typeof window !== "undefined" && window.ReactDOM && window.ReactDOM.createPortal };
|
|
8432
|
-
const place =
|
|
8261
|
+
const place = React23__default.useCallback(() => {
|
|
8433
8262
|
const t = wrapRef.current;
|
|
8434
8263
|
if (!t) return;
|
|
8435
8264
|
const r = t.getBoundingClientRect();
|
|
@@ -8460,7 +8289,7 @@ function Popover({
|
|
|
8460
8289
|
arrow = { top: Math.min(Math.max(cy - top - 5.5, 8), ph - 18), [onRight ? "left" : "right"]: -6 };
|
|
8461
8290
|
setPos({ top, left, width: w, flip: false, arrow });
|
|
8462
8291
|
}, [placement, align, width]);
|
|
8463
|
-
|
|
8292
|
+
React23__default.useEffect(() => {
|
|
8464
8293
|
if (!open) return;
|
|
8465
8294
|
place();
|
|
8466
8295
|
const onMove = () => place();
|
|
@@ -8483,7 +8312,7 @@ function Popover({
|
|
|
8483
8312
|
document.removeEventListener("keydown", onKey);
|
|
8484
8313
|
};
|
|
8485
8314
|
}, [open, place]);
|
|
8486
|
-
|
|
8315
|
+
React23__default.useEffect(() => {
|
|
8487
8316
|
if (open) {
|
|
8488
8317
|
setRender(true);
|
|
8489
8318
|
return;
|
|
@@ -8491,12 +8320,12 @@ function Popover({
|
|
|
8491
8320
|
const t = setTimeout(() => setRender(false), 170);
|
|
8492
8321
|
return () => clearTimeout(t);
|
|
8493
8322
|
}, [open]);
|
|
8494
|
-
|
|
8323
|
+
React23__default.useEffect(() => {
|
|
8495
8324
|
if (render && open) place();
|
|
8496
8325
|
}, [render, place]);
|
|
8497
|
-
const restoreRef =
|
|
8498
|
-
const needFocusRef =
|
|
8499
|
-
|
|
8326
|
+
const restoreRef = React23__default.useRef(null);
|
|
8327
|
+
const needFocusRef = React23__default.useRef(false);
|
|
8328
|
+
React23__default.useEffect(() => {
|
|
8500
8329
|
if (open) {
|
|
8501
8330
|
restoreRef.current = document.activeElement;
|
|
8502
8331
|
needFocusRef.current = true;
|
|
@@ -8507,7 +8336,7 @@ function Popover({
|
|
|
8507
8336
|
needFocusRef.current = false;
|
|
8508
8337
|
if (prev && typeof prev.focus === "function" && popRef.current?.contains(document.activeElement)) prev.focus();
|
|
8509
8338
|
}, [open]);
|
|
8510
|
-
|
|
8339
|
+
React23__default.useEffect(() => {
|
|
8511
8340
|
if (open && render && pos && needFocusRef.current) {
|
|
8512
8341
|
needFocusRef.current = false;
|
|
8513
8342
|
popRef.current?.focus({ preventScroll: true });
|
|
@@ -8526,6 +8355,7 @@ function Popover({
|
|
|
8526
8355
|
"aria-labelledby": title ? `${popId}-title` : void 0,
|
|
8527
8356
|
style: { top: pos.top, bottom: pos.bottom, left: pos.left, width: pos.width },
|
|
8528
8357
|
children: [
|
|
8358
|
+
__twcStyles,
|
|
8529
8359
|
/* @__PURE__ */ jsx("span", { className: "twc-popover__arrow", style: pos.arrow, "aria-hidden": "true" }),
|
|
8530
8360
|
/* @__PURE__ */ jsxs("div", { className: "twc-popover__inner", children: [
|
|
8531
8361
|
title ? /* @__PURE__ */ jsx("div", { className: "twc-popover__title", id: `${popId}-title`, children: title }) : null,
|
|
@@ -8534,7 +8364,7 @@ function Popover({
|
|
|
8534
8364
|
]
|
|
8535
8365
|
}
|
|
8536
8366
|
) : null;
|
|
8537
|
-
const triggerEl =
|
|
8367
|
+
const triggerEl = React23__default.isValidElement(trigger) ? React23__default.cloneElement(trigger, {
|
|
8538
8368
|
onClick: (e) => {
|
|
8539
8369
|
trigger.props.onClick?.(e);
|
|
8540
8370
|
toggle();
|
|
@@ -8576,11 +8406,7 @@ function Progress({
|
|
|
8576
8406
|
className = "",
|
|
8577
8407
|
...rest
|
|
8578
8408
|
}) {
|
|
8579
|
-
|
|
8580
|
-
if (document.getElementById("twc-progress-styles")) return;
|
|
8581
|
-
const el = document.createElement("style");
|
|
8582
|
-
el.id = "twc-progress-styles";
|
|
8583
|
-
el.textContent = `
|
|
8409
|
+
const __twcStyles = useScopedStyles("twc-progress-styles", `
|
|
8584
8410
|
.twc-progress-wrap { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-sans); }
|
|
8585
8411
|
.twc-progress {
|
|
8586
8412
|
--_h: 8px;
|
|
@@ -8612,15 +8438,14 @@ function Progress({
|
|
|
8612
8438
|
@media (prefers-reduced-motion: reduce) {
|
|
8613
8439
|
.twc-progress[data-indeterminate="true"] .twc-progress__bar { animation-duration: 1.3s !important; animation-iteration-count: infinite !important; }
|
|
8614
8440
|
}
|
|
8615
|
-
|
|
8616
|
-
document.head.appendChild(el);
|
|
8617
|
-
}, []);
|
|
8441
|
+
`);
|
|
8618
8442
|
const v = Number.isFinite(value) ? value : 0;
|
|
8619
8443
|
const pct = indeterminate ? 0 : max > 0 ? Math.min(100, Math.max(0, v / max * 100)) : 0;
|
|
8620
8444
|
return (
|
|
8621
8445
|
// Single-root contract: className and ...rest (style, id, handlers, …) share the outer
|
|
8622
8446
|
// wrapper; role="progressbar" + aria-value* stay on the inner track.
|
|
8623
8447
|
/* @__PURE__ */ jsxs("div", { className: `twc-progress-wrap ${className}`, ...rest, children: [
|
|
8448
|
+
__twcStyles,
|
|
8624
8449
|
showLabel && !indeterminate ? /* @__PURE__ */ jsxs("div", { className: "twc-progress__meta", children: [
|
|
8625
8450
|
/* @__PURE__ */ jsx("span", { children: "Progress" }),
|
|
8626
8451
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
@@ -8662,11 +8487,7 @@ function Radio({
|
|
|
8662
8487
|
onChange,
|
|
8663
8488
|
...rest
|
|
8664
8489
|
}) {
|
|
8665
|
-
|
|
8666
|
-
if (document.getElementById("twc-radio-styles")) return;
|
|
8667
|
-
const el = document.createElement("style");
|
|
8668
|
-
el.id = "twc-radio-styles";
|
|
8669
|
-
el.textContent = `
|
|
8490
|
+
const __twcStyles = useScopedStyles("twc-radio-styles", `
|
|
8670
8491
|
.twc-radio { display: inline-flex; align-items: flex-start; gap: var(--space-2-5); cursor: pointer; font-family: var(--font-sans); }
|
|
8671
8492
|
/* tone \u2192 accent set (default primary). Mirrors Button's --_accent model; Badge's tone vocabulary. */
|
|
8672
8493
|
.twc-radio { --_accent: var(--color-primary); --_accent-fg: var(--color-primary-fg); --_accent-subtle: var(--color-primary-subtle); --_accent-subtle-fg: var(--color-primary-subtle-fg); --_accent-border: var(--color-primary-border); }
|
|
@@ -8703,15 +8524,14 @@ function Radio({
|
|
|
8703
8524
|
.twc-radio__desc { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
8704
8525
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
8705
8526
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
}, []);
|
|
8709
|
-
const autoId = React22.useId();
|
|
8527
|
+
`);
|
|
8528
|
+
const autoId = React23__default.useId();
|
|
8710
8529
|
const fieldId = id || autoId;
|
|
8711
8530
|
const errId = `${fieldId}-error`;
|
|
8712
8531
|
const invalid = Boolean(error);
|
|
8713
8532
|
const describedBy = [rest["aria-describedby"], error ? errId : null].filter(Boolean).join(" ") || void 0;
|
|
8714
8533
|
const control = /* @__PURE__ */ jsxs("label", { className: `twc-radio ${className}`, "data-size": size, "data-tone": tone, "data-invalid": invalid || void 0, "data-disabled": disabled || void 0, htmlFor: fieldId, children: [
|
|
8534
|
+
__twcStyles,
|
|
8715
8535
|
/* @__PURE__ */ jsx(
|
|
8716
8536
|
"input",
|
|
8717
8537
|
{
|
|
@@ -8782,19 +8602,13 @@ function Rating({
|
|
|
8782
8602
|
style,
|
|
8783
8603
|
...rest
|
|
8784
8604
|
}) {
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
el.id = "twc-rating-styles";
|
|
8789
|
-
el.textContent = RATING_CSS;
|
|
8790
|
-
document.head.appendChild(el);
|
|
8791
|
-
}, []);
|
|
8792
|
-
const [internal, setInternal] = React22.useState(defaultValue);
|
|
8793
|
-
const [hover, setHover] = React22.useState(0);
|
|
8605
|
+
const __twcStyles = useScopedStyles("twc-rating-styles", RATING_CSS);
|
|
8606
|
+
const [internal, setInternal] = React23__default.useState(defaultValue);
|
|
8607
|
+
const [hover, setHover] = React23__default.useState(0);
|
|
8794
8608
|
const val = value !== void 0 ? value : internal;
|
|
8795
8609
|
const shown = hover || val;
|
|
8796
8610
|
const interactive = !readOnly && !disabled;
|
|
8797
|
-
const btnRefs =
|
|
8611
|
+
const btnRefs = React23__default.useRef([]);
|
|
8798
8612
|
const tabStar = Math.min(count, Math.max(1, Math.round(val) || 1));
|
|
8799
8613
|
const set = (v) => {
|
|
8800
8614
|
if (!interactive) return;
|
|
@@ -8827,6 +8641,7 @@ function Rating({
|
|
|
8827
8641
|
"aria-disabled": disabled || void 0,
|
|
8828
8642
|
...rest,
|
|
8829
8643
|
children: [
|
|
8644
|
+
__twcStyles,
|
|
8830
8645
|
/* @__PURE__ */ jsx("span", { className: "twc-rating__stars", onMouseLeave: () => setHover(0), onKeyDown, children: Array.from({ length: count }).map((_, i) => {
|
|
8831
8646
|
const n = i + 1;
|
|
8832
8647
|
return /* @__PURE__ */ jsx(
|
|
@@ -8908,14 +8723,8 @@ function Sidebar({
|
|
|
8908
8723
|
className = "",
|
|
8909
8724
|
...rest
|
|
8910
8725
|
}) {
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
const el = document.createElement("style");
|
|
8914
|
-
el.id = "twc-sidebar-styles";
|
|
8915
|
-
el.textContent = SIDEBAR_CSS;
|
|
8916
|
-
document.head.appendChild(el);
|
|
8917
|
-
}, []);
|
|
8918
|
-
const [internal, setInternal] = React22.useState(defaultCollapsed);
|
|
8726
|
+
const __twcStyles = useScopedStyles("twc-sidebar-styles", SIDEBAR_CSS);
|
|
8727
|
+
const [internal, setInternal] = React23__default.useState(defaultCollapsed);
|
|
8919
8728
|
const collapsed = collapsedProp !== void 0 ? collapsedProp : internal;
|
|
8920
8729
|
const toggle = () => {
|
|
8921
8730
|
const next = !collapsed;
|
|
@@ -8928,6 +8737,7 @@ function Sidebar({
|
|
|
8928
8737
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
8929
8738
|
};
|
|
8930
8739
|
return /* @__PURE__ */ jsxs("aside", { className: `twc-sidebar ${className}`, "data-collapsed": collapsed || void 0, ...rest, children: [
|
|
8740
|
+
__twcStyles,
|
|
8931
8741
|
brand ? /* @__PURE__ */ jsx("div", { className: "twc-sidebar__head", children: /* @__PURE__ */ jsx("span", { className: "twc-sidebar__brand", children: brand }) }) : null,
|
|
8932
8742
|
/* @__PURE__ */ jsx("nav", { className: "twc-sidebar__nav", children: items.map(
|
|
8933
8743
|
(it, i) => it.section ? /* @__PURE__ */ jsx("div", { className: "twc-sidebar__section", children: it.section }, i) : (() => {
|
|
@@ -8967,11 +8777,7 @@ function Skeleton({
|
|
|
8967
8777
|
style,
|
|
8968
8778
|
...rest
|
|
8969
8779
|
}) {
|
|
8970
|
-
|
|
8971
|
-
if (document.getElementById("twc-skeleton-styles")) return;
|
|
8972
|
-
const el = document.createElement("style");
|
|
8973
|
-
el.id = "twc-skeleton-styles";
|
|
8974
|
-
el.textContent = `
|
|
8780
|
+
const __twcStyles = useScopedStyles("twc-skeleton-styles", `
|
|
8975
8781
|
.twc-skeleton {
|
|
8976
8782
|
position: relative; overflow: hidden;
|
|
8977
8783
|
background: var(--color-surface-sunken); border-radius: var(--radius-md);
|
|
@@ -8990,11 +8796,12 @@ function Skeleton({
|
|
|
8990
8796
|
@media (prefers-reduced-motion: reduce) {
|
|
8991
8797
|
.twc-skeleton::after { animation-duration: 1.4s !important; animation-iteration-count: infinite !important; }
|
|
8992
8798
|
}
|
|
8993
|
-
|
|
8994
|
-
document.head.appendChild(el);
|
|
8995
|
-
}, []);
|
|
8799
|
+
`);
|
|
8996
8800
|
if (variant === "text" && lines > 1) {
|
|
8997
|
-
return /* @__PURE__ */
|
|
8801
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-skeleton__group ${className}`, style: { height, ...style }, ...rest, children: [
|
|
8802
|
+
__twcStyles,
|
|
8803
|
+
Array.from({ length: lines }).map((_, i) => /* @__PURE__ */ jsx("span", { className: "twc-skeleton", "data-variant": "text", style: { width: width || "100%" } }, i))
|
|
8804
|
+
] });
|
|
8998
8805
|
}
|
|
8999
8806
|
return /* @__PURE__ */ jsx(
|
|
9000
8807
|
"span",
|
|
@@ -9002,7 +8809,8 @@ function Skeleton({
|
|
|
9002
8809
|
className: `twc-skeleton ${className}`,
|
|
9003
8810
|
"data-variant": variant,
|
|
9004
8811
|
style: { width, height, ...style },
|
|
9005
|
-
...rest
|
|
8812
|
+
...rest,
|
|
8813
|
+
children: __twcStyles
|
|
9006
8814
|
}
|
|
9007
8815
|
);
|
|
9008
8816
|
}
|
|
@@ -9068,19 +8876,13 @@ function Slider({
|
|
|
9068
8876
|
const min = Number.isFinite(minProp) ? minProp : 0;
|
|
9069
8877
|
const max = Number.isFinite(maxProp) && maxProp > min ? maxProp : min + 1;
|
|
9070
8878
|
const step = Number.isFinite(stepProp) && stepProp > 0 ? stepProp : 1;
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
const el = document.createElement("style");
|
|
9074
|
-
el.id = "twc-slider-styles";
|
|
9075
|
-
el.textContent = SLIDER_CSS;
|
|
9076
|
-
document.head.appendChild(el);
|
|
9077
|
-
}, []);
|
|
9078
|
-
const autoId = React22.useId();
|
|
8879
|
+
const __twcStyles = useScopedStyles("twc-slider-styles", SLIDER_CSS);
|
|
8880
|
+
const autoId = React23__default.useId();
|
|
9079
8881
|
const fieldId = id || autoId;
|
|
9080
|
-
const [internal, setInternal] =
|
|
8882
|
+
const [internal, setInternal] = React23__default.useState(defaultValue);
|
|
9081
8883
|
const val = value !== void 0 ? value : internal;
|
|
9082
|
-
const trackRef =
|
|
9083
|
-
const [dragging, setDragging] =
|
|
8884
|
+
const trackRef = React23__default.useRef(null);
|
|
8885
|
+
const [dragging, setDragging] = React23__default.useState(false);
|
|
9084
8886
|
const pct = (val - min) / (max - min) * 100;
|
|
9085
8887
|
const fmt = (v) => formatValue ? formatValue(v) : v;
|
|
9086
8888
|
const clampSnap = (raw) => {
|
|
@@ -9098,8 +8900,8 @@ function Slider({
|
|
|
9098
8900
|
const ratio = Math.min(1, Math.max(0, (clientX - r.left) / r.width));
|
|
9099
8901
|
return clampSnap(min + ratio * (max - min));
|
|
9100
8902
|
};
|
|
9101
|
-
const dragCleanupRef =
|
|
9102
|
-
|
|
8903
|
+
const dragCleanupRef = React23__default.useRef(null);
|
|
8904
|
+
React23__default.useEffect(() => () => dragCleanupRef.current?.(), []);
|
|
9103
8905
|
function onPointerDown(e) {
|
|
9104
8906
|
if (disabled) return;
|
|
9105
8907
|
e.preventDefault();
|
|
@@ -9137,6 +8939,7 @@ function Slider({
|
|
|
9137
8939
|
const display = fmt(val);
|
|
9138
8940
|
const valueText = formatValue && (typeof display === "string" || typeof display === "number") ? String(display) : void 0;
|
|
9139
8941
|
return /* @__PURE__ */ jsxs("div", { className: `twc-slider ${className}`, "data-tone": tone, "data-disabled": disabled || void 0, ...rest, children: [
|
|
8942
|
+
__twcStyles,
|
|
9140
8943
|
label || showValue ? /* @__PURE__ */ jsxs("div", { className: "twc-slider__head", children: [
|
|
9141
8944
|
label ? /* @__PURE__ */ jsx("label", { className: "twc-slider__label", id: labelId, children: label }) : /* @__PURE__ */ jsx("span", {}),
|
|
9142
8945
|
showValue ? /* @__PURE__ */ jsx("span", { className: "twc-slider__value", children: display }) : null
|
|
@@ -9179,11 +8982,7 @@ function Spinner({
|
|
|
9179
8982
|
...rest
|
|
9180
8983
|
}) {
|
|
9181
8984
|
const resolvedColor = color ?? tone;
|
|
9182
|
-
|
|
9183
|
-
if (document.getElementById("twc-spinner-styles")) return;
|
|
9184
|
-
const el = document.createElement("style");
|
|
9185
|
-
el.id = "twc-spinner-styles";
|
|
9186
|
-
el.textContent = `
|
|
8985
|
+
const __twcStyles = useScopedStyles("twc-spinner-styles", `
|
|
9187
8986
|
.twc-spinner {
|
|
9188
8987
|
--_sz: 24px; --_bw: 2.5px;
|
|
9189
8988
|
display: inline-block; width: var(--_sz); height: var(--_sz);
|
|
@@ -9207,10 +9006,8 @@ function Spinner({
|
|
|
9207
9006
|
@media (prefers-reduced-motion: reduce) {
|
|
9208
9007
|
.twc-spinner { animation-duration: 0.65s !important; animation-iteration-count: infinite !important; }
|
|
9209
9008
|
}
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
}, []);
|
|
9213
|
-
return /* @__PURE__ */ jsx("span", { className: `twc-spinner ${className}`, "data-size": size, "data-tone": resolvedColor, role: "status", "aria-label": label, ...rest });
|
|
9009
|
+
`);
|
|
9010
|
+
return /* @__PURE__ */ jsx("span", { className: `twc-spinner ${className}`, "data-size": size, "data-tone": resolvedColor, role: "status", "aria-label": label, ...rest, children: __twcStyles });
|
|
9214
9011
|
}
|
|
9215
9012
|
var STAT_CSS = `
|
|
9216
9013
|
.twc-stat { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-sans);
|
|
@@ -9243,16 +9040,11 @@ function Stat({
|
|
|
9243
9040
|
className = "",
|
|
9244
9041
|
...rest
|
|
9245
9042
|
}) {
|
|
9246
|
-
|
|
9247
|
-
if (document.getElementById("twc-stat-styles")) return;
|
|
9248
|
-
const el = document.createElement("style");
|
|
9249
|
-
el.id = "twc-stat-styles";
|
|
9250
|
-
el.textContent = STAT_CSS;
|
|
9251
|
-
document.head.appendChild(el);
|
|
9252
|
-
}, []);
|
|
9043
|
+
const __twcStyles = useScopedStyles("twc-stat-styles", STAT_CSS);
|
|
9253
9044
|
const isNeg = delta != null && String(delta).trim().startsWith("-");
|
|
9254
9045
|
const dir = deltaDirection || (delta != null ? isNeg ? "down" : "up" : void 0);
|
|
9255
9046
|
return /* @__PURE__ */ jsxs("div", { className: `twc-stat ${className}`, "data-plain": plain || void 0, ...rest, children: [
|
|
9047
|
+
__twcStyles,
|
|
9256
9048
|
/* @__PURE__ */ jsxs("div", { className: "twc-stat__top", children: [
|
|
9257
9049
|
/* @__PURE__ */ jsx("span", { className: "twc-stat__label", children: label }),
|
|
9258
9050
|
icon ? /* @__PURE__ */ jsx("span", { className: "twc-stat__icon", "aria-hidden": "true", children: icon }) : null
|
|
@@ -9319,14 +9111,8 @@ function Stepper({
|
|
|
9319
9111
|
className = "",
|
|
9320
9112
|
...rest
|
|
9321
9113
|
}) {
|
|
9322
|
-
|
|
9323
|
-
|
|
9324
|
-
const el = document.createElement("style");
|
|
9325
|
-
el.id = "twc-stepper-styles";
|
|
9326
|
-
el.textContent = STEPPER_CSS;
|
|
9327
|
-
document.head.appendChild(el);
|
|
9328
|
-
}, []);
|
|
9329
|
-
const [activeInternal, setActiveInternal] = React22.useState(defaultActive);
|
|
9114
|
+
const __twcStyles = useScopedStyles("twc-stepper-styles", STEPPER_CSS);
|
|
9115
|
+
const [activeInternal, setActiveInternal] = React23__default.useState(defaultActive);
|
|
9330
9116
|
const active = activeProp !== void 0 ? activeProp : activeInternal;
|
|
9331
9117
|
const handleStep = (i) => {
|
|
9332
9118
|
if (activeProp === void 0) setActiveInternal(i);
|
|
@@ -9338,23 +9124,47 @@ function Stepper({
|
|
|
9338
9124
|
if (i === active) return "active";
|
|
9339
9125
|
return "upcoming";
|
|
9340
9126
|
};
|
|
9341
|
-
return /* @__PURE__ */
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9127
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-stepper ${className}`, "data-orientation": orientation, "data-tone": tone, ...rest, children: [
|
|
9128
|
+
__twcStyles,
|
|
9129
|
+
steps.map((step, i) => {
|
|
9130
|
+
const state = stateOf(i, step);
|
|
9131
|
+
const last = i === steps.length - 1;
|
|
9132
|
+
const isClickable = clickable && i <= active;
|
|
9133
|
+
const interactive = isClickable ? {
|
|
9134
|
+
role: "button",
|
|
9135
|
+
tabIndex: 0,
|
|
9136
|
+
onClick: () => handleStep(i),
|
|
9137
|
+
onKeyDown: (e) => {
|
|
9138
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
9139
|
+
e.preventDefault();
|
|
9140
|
+
handleStep(i);
|
|
9141
|
+
}
|
|
9353
9142
|
}
|
|
9143
|
+
} : null;
|
|
9144
|
+
const indicator = /* @__PURE__ */ jsx("span", { className: "twc-step__indicator", "aria-hidden": "true", children: state === "complete" ? /* @__PURE__ */ jsx(CheckIcon, {}) : state === "error" ? /* @__PURE__ */ jsx(BangIcon, {}) : step.icon || i + 1 });
|
|
9145
|
+
if (orientation === "vertical") {
|
|
9146
|
+
return /* @__PURE__ */ jsxs(
|
|
9147
|
+
"div",
|
|
9148
|
+
{
|
|
9149
|
+
className: "twc-step",
|
|
9150
|
+
"data-state": state,
|
|
9151
|
+
"data-clickable": isClickable || void 0,
|
|
9152
|
+
"aria-current": state === "active" ? "step" : void 0,
|
|
9153
|
+
...interactive,
|
|
9154
|
+
children: [
|
|
9155
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-step__col", children: [
|
|
9156
|
+
indicator,
|
|
9157
|
+
!last ? /* @__PURE__ */ jsx("span", { className: "twc-step__connector" }) : null
|
|
9158
|
+
] }),
|
|
9159
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-step__body twc-step__vbody", children: [
|
|
9160
|
+
/* @__PURE__ */ jsx("span", { className: "twc-step__title", children: step.title }),
|
|
9161
|
+
step.description ? /* @__PURE__ */ jsx("span", { className: "twc-step__desc", children: step.description }) : null
|
|
9162
|
+
] })
|
|
9163
|
+
]
|
|
9164
|
+
},
|
|
9165
|
+
i
|
|
9166
|
+
);
|
|
9354
9167
|
}
|
|
9355
|
-
} : null;
|
|
9356
|
-
const indicator = /* @__PURE__ */ jsx("span", { className: "twc-step__indicator", "aria-hidden": "true", children: state === "complete" ? /* @__PURE__ */ jsx(CheckIcon, {}) : state === "error" ? /* @__PURE__ */ jsx(BangIcon, {}) : step.icon || i + 1 });
|
|
9357
|
-
if (orientation === "vertical") {
|
|
9358
9168
|
return /* @__PURE__ */ jsxs(
|
|
9359
9169
|
"div",
|
|
9360
9170
|
{
|
|
@@ -9364,11 +9174,9 @@ function Stepper({
|
|
|
9364
9174
|
"aria-current": state === "active" ? "step" : void 0,
|
|
9365
9175
|
...interactive,
|
|
9366
9176
|
children: [
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
] }),
|
|
9371
|
-
/* @__PURE__ */ jsxs("div", { className: "twc-step__body twc-step__vbody", children: [
|
|
9177
|
+
indicator,
|
|
9178
|
+
!last ? /* @__PURE__ */ jsx("span", { className: "twc-step__connector" }) : null,
|
|
9179
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-step__body", children: [
|
|
9372
9180
|
/* @__PURE__ */ jsx("span", { className: "twc-step__title", children: step.title }),
|
|
9373
9181
|
step.description ? /* @__PURE__ */ jsx("span", { className: "twc-step__desc", children: step.description }) : null
|
|
9374
9182
|
] })
|
|
@@ -9376,27 +9184,8 @@ function Stepper({
|
|
|
9376
9184
|
},
|
|
9377
9185
|
i
|
|
9378
9186
|
);
|
|
9379
|
-
}
|
|
9380
|
-
|
|
9381
|
-
"div",
|
|
9382
|
-
{
|
|
9383
|
-
className: "twc-step",
|
|
9384
|
-
"data-state": state,
|
|
9385
|
-
"data-clickable": isClickable || void 0,
|
|
9386
|
-
"aria-current": state === "active" ? "step" : void 0,
|
|
9387
|
-
...interactive,
|
|
9388
|
-
children: [
|
|
9389
|
-
indicator,
|
|
9390
|
-
!last ? /* @__PURE__ */ jsx("span", { className: "twc-step__connector" }) : null,
|
|
9391
|
-
/* @__PURE__ */ jsxs("div", { className: "twc-step__body", children: [
|
|
9392
|
-
/* @__PURE__ */ jsx("span", { className: "twc-step__title", children: step.title }),
|
|
9393
|
-
step.description ? /* @__PURE__ */ jsx("span", { className: "twc-step__desc", children: step.description }) : null
|
|
9394
|
-
] })
|
|
9395
|
-
]
|
|
9396
|
-
},
|
|
9397
|
-
i
|
|
9398
|
-
);
|
|
9399
|
-
}) });
|
|
9187
|
+
})
|
|
9188
|
+
] });
|
|
9400
9189
|
}
|
|
9401
9190
|
function Switch({
|
|
9402
9191
|
label,
|
|
@@ -9413,11 +9202,7 @@ function Switch({
|
|
|
9413
9202
|
onChange,
|
|
9414
9203
|
...rest
|
|
9415
9204
|
}) {
|
|
9416
|
-
|
|
9417
|
-
if (document.getElementById("twc-switch-styles")) return;
|
|
9418
|
-
const el = document.createElement("style");
|
|
9419
|
-
el.id = "twc-switch-styles";
|
|
9420
|
-
el.textContent = `
|
|
9205
|
+
const __twcStyles = useScopedStyles("twc-switch-styles", `
|
|
9421
9206
|
/* tone \u2192 accent set (default primary). Mirrors Button's --_accent model; Badge's tone vocabulary. */
|
|
9422
9207
|
.twc-switch { --_accent: var(--color-primary); --_accent-fg: var(--color-primary-fg); --_accent-subtle: var(--color-primary-subtle); --_accent-subtle-fg: var(--color-primary-subtle-fg); --_accent-border: var(--color-primary-border); }
|
|
9423
9208
|
.twc-switch[data-tone="success"] { --_accent: var(--color-success); --_accent-fg: var(--color-success-fg); --_accent-subtle: var(--color-success-subtle); --_accent-subtle-fg: var(--color-success-subtle-fg); --_accent-border: var(--color-success); }
|
|
@@ -9453,15 +9238,14 @@ function Switch({
|
|
|
9453
9238
|
.twc-switch__desc { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
9454
9239
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
9455
9240
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
}, []);
|
|
9459
|
-
const autoId = React22.useId();
|
|
9241
|
+
`);
|
|
9242
|
+
const autoId = React23__default.useId();
|
|
9460
9243
|
const fieldId = id || autoId;
|
|
9461
9244
|
const errId = `${fieldId}-error`;
|
|
9462
9245
|
const invalid = Boolean(error);
|
|
9463
9246
|
const describedBy = [rest["aria-describedby"], error ? errId : null].filter(Boolean).join(" ") || void 0;
|
|
9464
9247
|
const control = /* @__PURE__ */ jsxs("label", { className: `twc-switch ${className}`, "data-size": size, "data-tone": tone, "data-invalid": invalid || void 0, "data-disabled": disabled || void 0, htmlFor: fieldId, children: [
|
|
9248
|
+
__twcStyles,
|
|
9465
9249
|
/* @__PURE__ */ jsx(
|
|
9466
9250
|
"input",
|
|
9467
9251
|
{
|
|
@@ -9538,21 +9322,15 @@ function Table({
|
|
|
9538
9322
|
className = "",
|
|
9539
9323
|
...rest
|
|
9540
9324
|
}) {
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
const el = document.createElement("style");
|
|
9544
|
-
el.id = "twc-table-styles";
|
|
9545
|
-
el.textContent = TABLE_CSS;
|
|
9546
|
-
document.head.appendChild(el);
|
|
9547
|
-
}, []);
|
|
9548
|
-
const cols = React22.useMemo(
|
|
9325
|
+
const __twcStyles = useScopedStyles("twc-table-styles", TABLE_CSS);
|
|
9326
|
+
const cols = React23__default.useMemo(
|
|
9549
9327
|
() => (columns || []).map((c) => ({ ...c, header: c.headerName, render: c.renderCell })),
|
|
9550
9328
|
[columns]
|
|
9551
9329
|
);
|
|
9552
9330
|
const dataRows = rowsProp || [];
|
|
9553
|
-
const [internalSort, setInternalSort] =
|
|
9331
|
+
const [internalSort, setInternalSort] = React23__default.useState(defaultSort || { field: null, dir: "asc" });
|
|
9554
9332
|
const sort = (sortProp !== void 0 ? sortProp : internalSort) || { field: null, dir: "asc" };
|
|
9555
|
-
const rows =
|
|
9333
|
+
const rows = React23__default.useMemo(() => {
|
|
9556
9334
|
if (!sortable || !sort.field) return dataRows;
|
|
9557
9335
|
const col = cols.find((c) => c.field === sort.field);
|
|
9558
9336
|
if (!col) return dataRows;
|
|
@@ -9573,32 +9351,35 @@ function Table({
|
|
|
9573
9351
|
const keyFn = rowKey || ((_, i) => i);
|
|
9574
9352
|
const selected = new Set(selectedKeys || []);
|
|
9575
9353
|
const wrapStyle = maxHeight !== void 0 ? { ...rest.style, maxHeight, overflowY: "auto" } : rest.style;
|
|
9576
|
-
return /* @__PURE__ */
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
"
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
/* @__PURE__ */
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9354
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-table-wrap ${className}`, ...rest, style: wrapStyle, children: [
|
|
9355
|
+
__twcStyles,
|
|
9356
|
+
/* @__PURE__ */ jsxs("table", { className: "twc-table", "data-hover": hover || void 0, "data-striped": striped || void 0, "data-size": size, "data-sticky": stickyHeader || void 0, children: [
|
|
9357
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: cols.map((c) => {
|
|
9358
|
+
const active = sort.field === c.field;
|
|
9359
|
+
const canSort = sortable && c.sortable !== false;
|
|
9360
|
+
return /* @__PURE__ */ jsx(
|
|
9361
|
+
"th",
|
|
9362
|
+
{
|
|
9363
|
+
"data-align": c.align,
|
|
9364
|
+
"data-sortable": canSort || void 0,
|
|
9365
|
+
"data-active": active || void 0,
|
|
9366
|
+
"data-dir": active ? sort.dir : void 0,
|
|
9367
|
+
style: c.width ? { width: c.width } : void 0,
|
|
9368
|
+
"aria-sort": active ? sort.dir === "asc" ? "ascending" : "descending" : canSort ? "none" : void 0,
|
|
9369
|
+
children: canSort ? /* @__PURE__ */ jsxs("button", { type: "button", className: "twc-table__sort", onClick: () => toggleSort(c.field), children: [
|
|
9370
|
+
c.header,
|
|
9371
|
+
/* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "m18 15-6-6-6 6" }) })
|
|
9372
|
+
] }) : c.header
|
|
9373
|
+
},
|
|
9374
|
+
c.field
|
|
9375
|
+
);
|
|
9376
|
+
}) }) }),
|
|
9377
|
+
/* @__PURE__ */ jsx("tbody", { children: rows.map((row, i) => {
|
|
9378
|
+
const k = keyFn(row, i);
|
|
9379
|
+
return /* @__PURE__ */ jsx("tr", { "data-selected": selected.has(k) || void 0, children: cols.map((c) => /* @__PURE__ */ jsx("td", { "data-align": c.align, children: c.render ? c.render(row[c.field], row, i) : row[c.field] }, c.field)) }, k);
|
|
9380
|
+
}) })
|
|
9381
|
+
] })
|
|
9382
|
+
] });
|
|
9602
9383
|
}
|
|
9603
9384
|
var TABS_CSS = `
|
|
9604
9385
|
.twc-tabs { font-family: var(--font-sans); }
|
|
@@ -9674,31 +9455,25 @@ function Tabs({
|
|
|
9674
9455
|
...rest
|
|
9675
9456
|
}) {
|
|
9676
9457
|
const vertical = orientation === "vertical";
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
const el = document.createElement("style");
|
|
9680
|
-
el.id = "twc-tabs-styles";
|
|
9681
|
-
el.textContent = TABS_CSS;
|
|
9682
|
-
document.head.appendChild(el);
|
|
9683
|
-
}, []);
|
|
9684
|
-
const [internal, setInternal] = React22.useState(defaultValue ?? items[0]?.value);
|
|
9458
|
+
const __twcStyles = useScopedStyles("twc-tabs-styles", TABS_CSS);
|
|
9459
|
+
const [internal, setInternal] = React23__default.useState(defaultValue ?? items[0]?.value);
|
|
9685
9460
|
const active = value ?? internal;
|
|
9686
|
-
const listRef =
|
|
9687
|
-
const [ind, setInd] =
|
|
9688
|
-
const baseId =
|
|
9461
|
+
const listRef = React23__default.useRef(null);
|
|
9462
|
+
const [ind, setInd] = React23__default.useState({ left: 0, width: 0, top: 0, height: 0 });
|
|
9463
|
+
const baseId = React23__default.useId();
|
|
9689
9464
|
const tabIdAt = (i) => `${baseId}-tab-${i}`;
|
|
9690
9465
|
const panelId = `${baseId}-panel`;
|
|
9691
9466
|
const activeIndex = items.findIndex((it) => it.value === active);
|
|
9692
|
-
const updateIndicator =
|
|
9467
|
+
const updateIndicator = React23__default.useCallback(() => {
|
|
9693
9468
|
const list = listRef.current;
|
|
9694
9469
|
if (!list) return;
|
|
9695
9470
|
const el = list.querySelector('[data-active="true"]');
|
|
9696
9471
|
if (el) setInd({ left: el.offsetLeft, width: el.offsetWidth, top: el.offsetTop, height: el.offsetHeight });
|
|
9697
9472
|
}, []);
|
|
9698
|
-
|
|
9473
|
+
React23__default.useEffect(() => {
|
|
9699
9474
|
updateIndicator();
|
|
9700
9475
|
}, [active, updateIndicator, items, orientation]);
|
|
9701
|
-
|
|
9476
|
+
React23__default.useEffect(() => {
|
|
9702
9477
|
const r = () => updateIndicator();
|
|
9703
9478
|
window.addEventListener("resize", r);
|
|
9704
9479
|
if (typeof document !== "undefined" && document.fonts && document.fonts.ready) {
|
|
@@ -9735,6 +9510,7 @@ function Tabs({
|
|
|
9735
9510
|
if (btns && btns[i]) btns[i].focus();
|
|
9736
9511
|
}
|
|
9737
9512
|
return /* @__PURE__ */ jsxs("div", { className: `twc-tabs ${className}`, "data-variant": variant, "data-tone": tone, "data-orientation": orientation, ...rest, children: [
|
|
9513
|
+
__twcStyles,
|
|
9738
9514
|
/* @__PURE__ */ jsxs("div", { className: "twc-tabs__list", ref: listRef, role: "tablist", "aria-orientation": orientation, onKeyDown: onListKeyDown, children: [
|
|
9739
9515
|
items.map((it, i) => /* @__PURE__ */ jsxs(
|
|
9740
9516
|
"button",
|
|
@@ -9813,14 +9589,9 @@ function Tag({
|
|
|
9813
9589
|
className = "",
|
|
9814
9590
|
...rest
|
|
9815
9591
|
}) {
|
|
9816
|
-
|
|
9817
|
-
if (document.getElementById("twc-tag-styles")) return;
|
|
9818
|
-
const el = document.createElement("style");
|
|
9819
|
-
el.id = "twc-tag-styles";
|
|
9820
|
-
el.textContent = TAG_CSS;
|
|
9821
|
-
document.head.appendChild(el);
|
|
9822
|
-
}, []);
|
|
9592
|
+
const __twcStyles = useScopedStyles("twc-tag-styles", TAG_CSS);
|
|
9823
9593
|
return /* @__PURE__ */ jsxs("span", { className: `twc-tag ${className}`, "data-tone": tone, "data-variant": variant, "data-no-remove": !onRemove || void 0, ...rest, children: [
|
|
9594
|
+
__twcStyles,
|
|
9824
9595
|
leftIcon,
|
|
9825
9596
|
children,
|
|
9826
9597
|
onRemove ? /* @__PURE__ */ jsx("button", { className: "twc-tag__remove", onClick: (e) => {
|
|
@@ -9842,11 +9613,7 @@ function Textarea({
|
|
|
9842
9613
|
className = "",
|
|
9843
9614
|
...rest
|
|
9844
9615
|
}) {
|
|
9845
|
-
|
|
9846
|
-
if (document.getElementById("twc-textarea-styles")) return;
|
|
9847
|
-
const el = document.createElement("style");
|
|
9848
|
-
el.id = "twc-textarea-styles";
|
|
9849
|
-
el.textContent = `
|
|
9616
|
+
const __twcStyles = useScopedStyles("twc-textarea-styles", `
|
|
9850
9617
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
9851
9618
|
.twc-field__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); display: flex; gap: 4px; align-items: center; }
|
|
9852
9619
|
.twc-field__req { color: var(--color-danger); }
|
|
@@ -9875,14 +9642,13 @@ function Textarea({
|
|
|
9875
9642
|
.twc-textarea__el:focus { border-color: var(--_accent); box-shadow: var(--_ring); }
|
|
9876
9643
|
.twc-textarea__el[aria-invalid="true"] { border-color: var(--color-danger); }
|
|
9877
9644
|
.twc-textarea__el:disabled { background: var(--color-surface-sunken); opacity: 0.7; cursor: not-allowed; }
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
}, []);
|
|
9881
|
-
const autoId = React22.useId();
|
|
9645
|
+
`);
|
|
9646
|
+
const autoId = React23__default.useId();
|
|
9882
9647
|
const fieldId = id || autoId;
|
|
9883
9648
|
const descId = `${fieldId}-desc`;
|
|
9884
9649
|
const invalid = Boolean(error);
|
|
9885
9650
|
return /* @__PURE__ */ jsxs("div", { className: `twc-field ${className}`, children: [
|
|
9651
|
+
__twcStyles,
|
|
9886
9652
|
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
9887
9653
|
label,
|
|
9888
9654
|
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -9930,26 +9696,23 @@ var TIMELINE_CSS = `
|
|
|
9930
9696
|
.twc-timeline__desc { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 2px; line-height: var(--leading-snug); }
|
|
9931
9697
|
`;
|
|
9932
9698
|
function Timeline({ items, className = "", ...rest }) {
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
return /* @__PURE__ */ jsx("ul", { className: `twc-timeline ${className}`, ...rest, children: items.map((it, i) => /* @__PURE__ */ jsxs("li", { className: "twc-timeline__item", "data-tone": it.tone || void 0, children: [
|
|
9941
|
-
/* @__PURE__ */ jsxs("div", { className: "twc-timeline__rail", children: [
|
|
9942
|
-
/* @__PURE__ */ jsx("span", { className: "twc-timeline__dot", "aria-hidden": "true", children: it.icon || null }),
|
|
9943
|
-
/* @__PURE__ */ jsx("span", { className: "twc-timeline__line" })
|
|
9944
|
-
] }),
|
|
9945
|
-
/* @__PURE__ */ jsxs("div", { className: "twc-timeline__body", children: [
|
|
9946
|
-
/* @__PURE__ */ jsxs("div", { className: "twc-timeline__head", children: [
|
|
9947
|
-
/* @__PURE__ */ jsx("span", { className: "twc-timeline__title", children: it.title }),
|
|
9948
|
-
it.time ? /* @__PURE__ */ jsx("span", { className: "twc-timeline__time", children: it.time }) : null
|
|
9699
|
+
const __twcStyles = useScopedStyles("twc-timeline-styles", TIMELINE_CSS);
|
|
9700
|
+
return /* @__PURE__ */ jsxs("ul", { className: `twc-timeline ${className}`, ...rest, children: [
|
|
9701
|
+
__twcStyles,
|
|
9702
|
+
items.map((it, i) => /* @__PURE__ */ jsxs("li", { className: "twc-timeline__item", "data-tone": it.tone || void 0, children: [
|
|
9703
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-timeline__rail", children: [
|
|
9704
|
+
/* @__PURE__ */ jsx("span", { className: "twc-timeline__dot", "aria-hidden": "true", children: it.icon || null }),
|
|
9705
|
+
/* @__PURE__ */ jsx("span", { className: "twc-timeline__line" })
|
|
9949
9706
|
] }),
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
9707
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-timeline__body", children: [
|
|
9708
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-timeline__head", children: [
|
|
9709
|
+
/* @__PURE__ */ jsx("span", { className: "twc-timeline__title", children: it.title }),
|
|
9710
|
+
it.time ? /* @__PURE__ */ jsx("span", { className: "twc-timeline__time", children: it.time }) : null
|
|
9711
|
+
] }),
|
|
9712
|
+
it.description ? /* @__PURE__ */ jsx("div", { className: "twc-timeline__desc", children: it.description }) : null
|
|
9713
|
+
] })
|
|
9714
|
+
] }, i))
|
|
9715
|
+
] });
|
|
9953
9716
|
}
|
|
9954
9717
|
var TOAST_CSS = `
|
|
9955
9718
|
.twc-toast {
|
|
@@ -10017,26 +9780,20 @@ function Toast({
|
|
|
10017
9780
|
...rest
|
|
10018
9781
|
}) {
|
|
10019
9782
|
const resolvedTone = tone === "neutral" ? "default" : tone;
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
el.id = "twc-toast-styles";
|
|
10024
|
-
el.textContent = TOAST_CSS;
|
|
10025
|
-
document.head.appendChild(el);
|
|
10026
|
-
}, []);
|
|
10027
|
-
const onCloseRef = React22.useRef(onClose);
|
|
10028
|
-
React22.useEffect(() => {
|
|
9783
|
+
const __twcStyles = useScopedStyles("twc-toast-styles", TOAST_CSS);
|
|
9784
|
+
const onCloseRef = React23__default.useRef(onClose);
|
|
9785
|
+
React23__default.useEffect(() => {
|
|
10029
9786
|
onCloseRef.current = onClose;
|
|
10030
9787
|
}, [onClose]);
|
|
10031
|
-
const timer =
|
|
10032
|
-
const stop =
|
|
10033
|
-
const start =
|
|
9788
|
+
const timer = React23__default.useRef();
|
|
9789
|
+
const stop = React23__default.useCallback(() => clearTimeout(timer.current), []);
|
|
9790
|
+
const start = React23__default.useCallback(() => {
|
|
10034
9791
|
stop();
|
|
10035
9792
|
if (duration && duration !== Infinity && onCloseRef.current) {
|
|
10036
9793
|
timer.current = setTimeout(() => onCloseRef.current && onCloseRef.current(), duration);
|
|
10037
9794
|
}
|
|
10038
9795
|
}, [duration, stop]);
|
|
10039
|
-
|
|
9796
|
+
React23__default.useEffect(() => {
|
|
10040
9797
|
start();
|
|
10041
9798
|
return stop;
|
|
10042
9799
|
}, [start, stop]);
|
|
@@ -10064,6 +9821,7 @@ function Toast({
|
|
|
10064
9821
|
start();
|
|
10065
9822
|
},
|
|
10066
9823
|
children: [
|
|
9824
|
+
__twcStyles,
|
|
10067
9825
|
/* @__PURE__ */ jsx("span", { className: "twc-toast__icon", "aria-hidden": "true", children: icon || /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
10068
9826
|
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
10069
9827
|
/* @__PURE__ */ jsx("path", { d: TOAST_ICONS[resolvedTone] || TOAST_ICONS.default })
|
|
@@ -10078,34 +9836,31 @@ function Toast({
|
|
|
10078
9836
|
);
|
|
10079
9837
|
}
|
|
10080
9838
|
function ToastViewport({ children, limit, className = "", ...rest }) {
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
10087
|
-
}, []);
|
|
10088
|
-
const shown = limit && limit > 0 ? React22.Children.toArray(children).slice(-limit) : children;
|
|
10089
|
-
return /* @__PURE__ */ jsx("div", { className: `twc-toast-viewport ${className}`, ...rest, children: shown });
|
|
9839
|
+
const __twcStyles = useScopedStyles("twc-toast-styles", TOAST_CSS);
|
|
9840
|
+
const shown = limit && limit > 0 ? React23__default.Children.toArray(children).slice(-limit) : children;
|
|
9841
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-toast-viewport ${className}`, ...rest, children: [
|
|
9842
|
+
__twcStyles,
|
|
9843
|
+
shown
|
|
9844
|
+
] });
|
|
10090
9845
|
}
|
|
10091
|
-
var ToastContext =
|
|
9846
|
+
var ToastContext = React23__default.createContext(null);
|
|
10092
9847
|
function useToast() {
|
|
10093
|
-
const ctx =
|
|
9848
|
+
const ctx = React23__default.useContext(ToastContext);
|
|
10094
9849
|
if (!ctx) throw new Error("useToast must be used within a <ToastProvider>.");
|
|
10095
9850
|
return ctx;
|
|
10096
9851
|
}
|
|
10097
9852
|
function ToastProvider({ children, limit = 4, duration = 4500, ...viewportProps }) {
|
|
10098
|
-
const [toasts, setToasts] =
|
|
10099
|
-
const idRef =
|
|
10100
|
-
const limitRef =
|
|
10101
|
-
|
|
9853
|
+
const [toasts, setToasts] = React23__default.useState([]);
|
|
9854
|
+
const idRef = React23__default.useRef(0);
|
|
9855
|
+
const limitRef = React23__default.useRef(limit);
|
|
9856
|
+
React23__default.useEffect(() => {
|
|
10102
9857
|
limitRef.current = limit;
|
|
10103
9858
|
}, [limit]);
|
|
10104
|
-
const dismiss =
|
|
9859
|
+
const dismiss = React23__default.useCallback((id) => {
|
|
10105
9860
|
setToasts((s) => s.filter((t) => t.id !== id));
|
|
10106
9861
|
}, []);
|
|
10107
|
-
const clear =
|
|
10108
|
-
const api =
|
|
9862
|
+
const clear = React23__default.useCallback(() => setToasts([]), []);
|
|
9863
|
+
const api = React23__default.useMemo(() => {
|
|
10109
9864
|
const push = (opts) => {
|
|
10110
9865
|
const id = idRef.current += 1;
|
|
10111
9866
|
const next = typeof opts === "string" ? { title: opts } : opts && typeof opts === "object" ? opts : {};
|
|
@@ -10126,7 +9881,7 @@ function ToastProvider({ children, limit = 4, duration = 4500, ...viewportProps
|
|
|
10126
9881
|
toast.show = withTone("default");
|
|
10127
9882
|
return { toast, dismiss, clear };
|
|
10128
9883
|
}, [dismiss, clear]);
|
|
10129
|
-
const value =
|
|
9884
|
+
const value = React23__default.useMemo(() => ({ ...api, toasts }), [api, toasts]);
|
|
10130
9885
|
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
|
|
10131
9886
|
children,
|
|
10132
9887
|
/* @__PURE__ */ jsx(ToastViewport, { limit, ...viewportProps, children: toasts.map((t) => /* @__PURE__ */ jsx(
|
|
@@ -10174,19 +9929,13 @@ function Tooltip({
|
|
|
10174
9929
|
className = "",
|
|
10175
9930
|
...rest
|
|
10176
9931
|
}) {
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
const id = React22.useId();
|
|
10185
|
-
const [show, setShow] = React22.useState(false);
|
|
10186
|
-
const [coords, setCoords] = React22.useState(null);
|
|
10187
|
-
const timer = React22.useRef(null);
|
|
10188
|
-
const wrapRef = React22.useRef(null);
|
|
10189
|
-
const tipRef = React22.useRef(null);
|
|
9932
|
+
const __twcStyles = useScopedStyles("twc-tooltip-styles", TOOLTIP_CSS);
|
|
9933
|
+
const id = React23__default.useId();
|
|
9934
|
+
const [show, setShow] = React23__default.useState(false);
|
|
9935
|
+
const [coords, setCoords] = React23__default.useState(null);
|
|
9936
|
+
const timer = React23__default.useRef(null);
|
|
9937
|
+
const wrapRef = React23__default.useRef(null);
|
|
9938
|
+
const tipRef = React23__default.useRef(null);
|
|
10190
9939
|
const open = () => {
|
|
10191
9940
|
clearTimeout(timer.current);
|
|
10192
9941
|
timer.current = setTimeout(() => setShow(true), delay);
|
|
@@ -10195,8 +9944,8 @@ function Tooltip({
|
|
|
10195
9944
|
clearTimeout(timer.current);
|
|
10196
9945
|
setShow(false);
|
|
10197
9946
|
};
|
|
10198
|
-
|
|
10199
|
-
const place =
|
|
9947
|
+
React23__default.useEffect(() => () => clearTimeout(timer.current), []);
|
|
9948
|
+
const place = React23__default.useCallback(() => {
|
|
10200
9949
|
const el = wrapRef.current;
|
|
10201
9950
|
if (!el) return;
|
|
10202
9951
|
const r = el.getBoundingClientRect();
|
|
@@ -10212,10 +9961,10 @@ function Tooltip({
|
|
|
10212
9961
|
else if (placement === "right") setCoords({ ...base, top: clampY(cy), left: Math.round(r.right + gap) });
|
|
10213
9962
|
else setCoords({ ...base, left: clampX(cx), bottom: Math.round(vh - r.top + gap) });
|
|
10214
9963
|
}, [placement]);
|
|
10215
|
-
|
|
9964
|
+
React23__default.useEffect(() => {
|
|
10216
9965
|
place();
|
|
10217
9966
|
}, [place]);
|
|
10218
|
-
|
|
9967
|
+
React23__default.useEffect(() => {
|
|
10219
9968
|
if (!show) return void 0;
|
|
10220
9969
|
place();
|
|
10221
9970
|
const onMove = () => place();
|
|
@@ -10226,7 +9975,7 @@ function Tooltip({
|
|
|
10226
9975
|
window.removeEventListener("resize", onMove);
|
|
10227
9976
|
};
|
|
10228
9977
|
}, [show, place]);
|
|
10229
|
-
|
|
9978
|
+
React23__default.useEffect(() => {
|
|
10230
9979
|
if (!show) return;
|
|
10231
9980
|
const onKeyDown = (e) => {
|
|
10232
9981
|
if (e.key === "Escape") {
|
|
@@ -10238,7 +9987,7 @@ function Tooltip({
|
|
|
10238
9987
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
10239
9988
|
}, [show]);
|
|
10240
9989
|
const describedBy = show ? id : void 0;
|
|
10241
|
-
const trigger =
|
|
9990
|
+
const trigger = React23__default.isValidElement(children) && children.type !== React23__default.Fragment ? React23__default.cloneElement(children, {
|
|
10242
9991
|
"aria-describedby": [children.props["aria-describedby"], describedBy].filter(Boolean).join(" ") || void 0
|
|
10243
9992
|
}) : /* @__PURE__ */ jsx("span", { "aria-describedby": describedBy, children });
|
|
10244
9993
|
return /* @__PURE__ */ jsxs(
|
|
@@ -10252,6 +10001,7 @@ function Tooltip({
|
|
|
10252
10001
|
onBlur: close,
|
|
10253
10002
|
...rest,
|
|
10254
10003
|
children: [
|
|
10004
|
+
__twcStyles,
|
|
10255
10005
|
trigger,
|
|
10256
10006
|
coords ? createPortal(
|
|
10257
10007
|
/* @__PURE__ */ jsxs(
|
|
@@ -10363,19 +10113,13 @@ function TreeView({
|
|
|
10363
10113
|
...rest
|
|
10364
10114
|
}) {
|
|
10365
10115
|
const nodes = items;
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
const el = document.createElement("style");
|
|
10369
|
-
el.id = "twc-tree-styles";
|
|
10370
|
-
el.textContent = TREE_CSS;
|
|
10371
|
-
document.head.appendChild(el);
|
|
10372
|
-
}, []);
|
|
10373
|
-
const [expInternal, setExpInternal] = React22.useState(() => new Set(defaultExpanded));
|
|
10116
|
+
const __twcStyles = useScopedStyles("twc-tree-styles", TREE_CSS);
|
|
10117
|
+
const [expInternal, setExpInternal] = React23__default.useState(() => new Set(defaultExpanded));
|
|
10374
10118
|
const expanded = expandedProp !== void 0 ? new Set(expandedProp) : expInternal;
|
|
10375
|
-
const [selInternal, setSelInternal] =
|
|
10119
|
+
const [selInternal, setSelInternal] = React23__default.useState(defaultSelectedId);
|
|
10376
10120
|
const selectedId = selectedProp !== void 0 ? selectedProp : selInternal;
|
|
10377
|
-
const [focusId, setFocusId] =
|
|
10378
|
-
const rowRefs =
|
|
10121
|
+
const [focusId, setFocusId] = React23__default.useState(null);
|
|
10122
|
+
const rowRefs = React23__default.useRef(/* @__PURE__ */ new Map());
|
|
10379
10123
|
const toggle = (id) => {
|
|
10380
10124
|
const n = new Set(expanded);
|
|
10381
10125
|
n.has(id) ? n.delete(id) : n.add(id);
|
|
@@ -10434,21 +10178,24 @@ function TreeView({
|
|
|
10434
10178
|
e.preventDefault();
|
|
10435
10179
|
if (next != null) focusRow(next);
|
|
10436
10180
|
};
|
|
10437
|
-
return /* @__PURE__ */
|
|
10438
|
-
|
|
10439
|
-
{
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
|
|
10181
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-tree ${className}`, role: "tree", onKeyDown, ...rest, children: [
|
|
10182
|
+
__twcStyles,
|
|
10183
|
+
/* @__PURE__ */ jsx("ul", { className: "twc-tree__group", role: "none", children: nodes.map((n) => /* @__PURE__ */ jsx(
|
|
10184
|
+
Node,
|
|
10185
|
+
{
|
|
10186
|
+
node: n,
|
|
10187
|
+
depth: 0,
|
|
10188
|
+
expanded,
|
|
10189
|
+
selectedId,
|
|
10190
|
+
tabbableId,
|
|
10191
|
+
rowRefs,
|
|
10192
|
+
onToggle: toggle,
|
|
10193
|
+
onSelect: select,
|
|
10194
|
+
onRowFocus: setFocusId
|
|
10195
|
+
},
|
|
10196
|
+
n.id
|
|
10197
|
+
)) })
|
|
10198
|
+
] });
|
|
10452
10199
|
}
|
|
10453
10200
|
function sp(v) {
|
|
10454
10201
|
if (v == null) return void 0;
|
|
@@ -10648,15 +10395,12 @@ function safeHref8(url) {
|
|
|
10648
10395
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
10649
10396
|
}
|
|
10650
10397
|
function Code({ as: Tag2 = "code", className = "", children, ...rest }) {
|
|
10651
|
-
|
|
10652
|
-
if (document.getElementById("twc-code-styles")) return;
|
|
10653
|
-
const el = document.createElement("style");
|
|
10654
|
-
el.id = "twc-code-styles";
|
|
10655
|
-
el.textContent = CODE_CSS;
|
|
10656
|
-
document.head.appendChild(el);
|
|
10657
|
-
}, []);
|
|
10398
|
+
const __twcStyles = useScopedStyles("twc-code-styles", CODE_CSS);
|
|
10658
10399
|
if (Tag2 === "a" && rest.href != null) rest.href = safeHref8(rest.href);
|
|
10659
|
-
return /* @__PURE__ */
|
|
10400
|
+
return /* @__PURE__ */ jsxs(Tag2, { className: `twc-code ${className}`.trim(), ...rest, children: [
|
|
10401
|
+
__twcStyles,
|
|
10402
|
+
children
|
|
10403
|
+
] });
|
|
10660
10404
|
}
|
|
10661
10405
|
var LEVEL_SIZE = { 1: "4xl", 2: "2xl", 3: "xl", 4: "lg", 5: "base", 6: "sm" };
|
|
10662
10406
|
function safeHref9(url) {
|
|
@@ -10747,44 +10491,44 @@ function Text({
|
|
|
10747
10491
|
);
|
|
10748
10492
|
}
|
|
10749
10493
|
var canUseDOM = typeof window !== "undefined" && typeof document !== "undefined";
|
|
10750
|
-
var useIsomorphicLayoutEffect = canUseDOM ?
|
|
10494
|
+
var useIsomorphicLayoutEffect = canUseDOM ? React23__default.useLayoutEffect : React23__default.useEffect;
|
|
10751
10495
|
function useMounted() {
|
|
10752
|
-
const [mounted, setMounted] =
|
|
10753
|
-
|
|
10496
|
+
const [mounted, setMounted] = React23__default.useState(false);
|
|
10497
|
+
React23__default.useEffect(() => {
|
|
10754
10498
|
setMounted(true);
|
|
10755
10499
|
}, []);
|
|
10756
10500
|
return mounted;
|
|
10757
10501
|
}
|
|
10758
10502
|
function usePrevious(value) {
|
|
10759
|
-
const ref =
|
|
10760
|
-
|
|
10503
|
+
const ref = React23__default.useRef(void 0);
|
|
10504
|
+
React23__default.useEffect(() => {
|
|
10761
10505
|
ref.current = value;
|
|
10762
10506
|
}, [value]);
|
|
10763
10507
|
return ref.current;
|
|
10764
10508
|
}
|
|
10765
10509
|
function useToggle(initial = false) {
|
|
10766
|
-
const [on, setOn] =
|
|
10767
|
-
const toggle =
|
|
10510
|
+
const [on, setOn] = React23__default.useState(initial);
|
|
10511
|
+
const toggle = React23__default.useCallback((next) => {
|
|
10768
10512
|
setOn((prev) => typeof next === "boolean" ? next : !prev);
|
|
10769
10513
|
}, []);
|
|
10770
10514
|
return [on, toggle, setOn];
|
|
10771
10515
|
}
|
|
10772
10516
|
function useDisclosure(initial = false) {
|
|
10773
|
-
const [open, setOpen] =
|
|
10774
|
-
const onOpen =
|
|
10775
|
-
const onClose =
|
|
10776
|
-
const onToggle =
|
|
10517
|
+
const [open, setOpen] = React23__default.useState(initial);
|
|
10518
|
+
const onOpen = React23__default.useCallback(() => setOpen(true), []);
|
|
10519
|
+
const onClose = React23__default.useCallback(() => setOpen(false), []);
|
|
10520
|
+
const onToggle = React23__default.useCallback(() => setOpen((p) => !p), []);
|
|
10777
10521
|
return { open, onOpen, onClose, onToggle, setOpen };
|
|
10778
10522
|
}
|
|
10779
10523
|
function useControllableState({ value, defaultValue, onChange } = {}) {
|
|
10780
10524
|
const isControlled = value !== void 0;
|
|
10781
|
-
const [uncontrolled, setUncontrolled] =
|
|
10525
|
+
const [uncontrolled, setUncontrolled] = React23__default.useState(defaultValue);
|
|
10782
10526
|
const current = isControlled ? value : uncontrolled;
|
|
10783
|
-
const ref =
|
|
10527
|
+
const ref = React23__default.useRef({ current, isControlled, onChange });
|
|
10784
10528
|
useIsomorphicLayoutEffect(() => {
|
|
10785
10529
|
ref.current = { current, isControlled, onChange };
|
|
10786
10530
|
});
|
|
10787
|
-
const setValue =
|
|
10531
|
+
const setValue = React23__default.useCallback((next) => {
|
|
10788
10532
|
const { current: cur, isControlled: ctrl, onChange: cb } = ref.current;
|
|
10789
10533
|
const resolved = typeof next === "function" ? next(cur) : next;
|
|
10790
10534
|
if (resolved === cur) return;
|
|
@@ -10795,8 +10539,8 @@ function useControllableState({ value, defaultValue, onChange } = {}) {
|
|
|
10795
10539
|
}
|
|
10796
10540
|
function useMediaQuery(query) {
|
|
10797
10541
|
const get = () => canUseDOM ? window.matchMedia(query).matches : false;
|
|
10798
|
-
const [matches3, setMatches] =
|
|
10799
|
-
|
|
10542
|
+
const [matches3, setMatches] = React23__default.useState(get);
|
|
10543
|
+
React23__default.useEffect(() => {
|
|
10800
10544
|
if (!canUseDOM) return void 0;
|
|
10801
10545
|
const mql = window.matchMedia(query);
|
|
10802
10546
|
const onChange = () => setMatches(mql.matches);
|
|
@@ -10811,7 +10555,7 @@ function usePrefersReducedMotion() {
|
|
|
10811
10555
|
}
|
|
10812
10556
|
function useColorScheme({ storageKey = "twico-theme", attribute = "class", element, disableTransitionsOnChange = true } = {}) {
|
|
10813
10557
|
const getTarget = () => element || (canUseDOM ? document.documentElement : null);
|
|
10814
|
-
const firstApply =
|
|
10558
|
+
const firstApply = React23__default.useRef(true);
|
|
10815
10559
|
const read = () => {
|
|
10816
10560
|
if (!canUseDOM) return "light";
|
|
10817
10561
|
try {
|
|
@@ -10821,8 +10565,8 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
10821
10565
|
}
|
|
10822
10566
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
10823
10567
|
};
|
|
10824
|
-
const [theme, setThemeState] =
|
|
10825
|
-
const apply =
|
|
10568
|
+
const [theme, setThemeState] = React23__default.useState(read);
|
|
10569
|
+
const apply = React23__default.useCallback(
|
|
10826
10570
|
(t) => {
|
|
10827
10571
|
const target = getTarget();
|
|
10828
10572
|
if (!target) return;
|
|
@@ -10848,11 +10592,11 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
10848
10592
|
useIsomorphicLayoutEffect(() => {
|
|
10849
10593
|
apply(theme);
|
|
10850
10594
|
}, [theme, apply]);
|
|
10851
|
-
const themeRef =
|
|
10595
|
+
const themeRef = React23__default.useRef(theme);
|
|
10852
10596
|
useIsomorphicLayoutEffect(() => {
|
|
10853
10597
|
themeRef.current = theme;
|
|
10854
10598
|
}, [theme]);
|
|
10855
|
-
const setTheme =
|
|
10599
|
+
const setTheme = React23__default.useCallback(
|
|
10856
10600
|
(t) => {
|
|
10857
10601
|
setThemeState(t);
|
|
10858
10602
|
try {
|
|
@@ -10863,10 +10607,10 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
10863
10607
|
},
|
|
10864
10608
|
[storageKey]
|
|
10865
10609
|
);
|
|
10866
|
-
const toggle =
|
|
10610
|
+
const toggle = React23__default.useCallback(() => {
|
|
10867
10611
|
setTheme(themeRef.current === "dark" ? "light" : "dark");
|
|
10868
10612
|
}, [setTheme]);
|
|
10869
|
-
|
|
10613
|
+
React23__default.useEffect(() => {
|
|
10870
10614
|
if (!canUseDOM) return void 0;
|
|
10871
10615
|
const sync = () => setThemeState(read());
|
|
10872
10616
|
const onStorage = (e) => {
|
|
@@ -10882,14 +10626,14 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
10882
10626
|
return { theme, setTheme, toggle, isDark: theme === "dark" };
|
|
10883
10627
|
}
|
|
10884
10628
|
function useEventListener(eventName, handler, element, options) {
|
|
10885
|
-
const saved =
|
|
10629
|
+
const saved = React23__default.useRef(handler);
|
|
10886
10630
|
useIsomorphicLayoutEffect(() => {
|
|
10887
10631
|
saved.current = handler;
|
|
10888
10632
|
}, [handler]);
|
|
10889
10633
|
const capture = typeof options === "boolean" ? options : options && options.capture;
|
|
10890
10634
|
const passive = typeof options === "object" && options ? options.passive : void 0;
|
|
10891
10635
|
const once = typeof options === "object" && options ? options.once : void 0;
|
|
10892
|
-
|
|
10636
|
+
React23__default.useEffect(() => {
|
|
10893
10637
|
const target = element && element.current || element || (canUseDOM ? window : null);
|
|
10894
10638
|
if (!target || !target.addEventListener) return void 0;
|
|
10895
10639
|
const opts = typeof options === "boolean" ? options : { capture, passive, once };
|
|
@@ -10899,11 +10643,11 @@ function useEventListener(eventName, handler, element, options) {
|
|
|
10899
10643
|
}, [eventName, element, capture, passive, once]);
|
|
10900
10644
|
}
|
|
10901
10645
|
function useClickOutside(ref, handler, events = ["mousedown", "touchstart"]) {
|
|
10902
|
-
const saved =
|
|
10646
|
+
const saved = React23__default.useRef(handler);
|
|
10903
10647
|
useIsomorphicLayoutEffect(() => {
|
|
10904
10648
|
saved.current = handler;
|
|
10905
10649
|
}, [handler]);
|
|
10906
|
-
|
|
10650
|
+
React23__default.useEffect(() => {
|
|
10907
10651
|
if (!canUseDOM) return void 0;
|
|
10908
10652
|
const listener = (e) => {
|
|
10909
10653
|
const el = ref && ref.current;
|
|
@@ -10938,8 +10682,8 @@ function useLocalStorage(key, initialValue) {
|
|
|
10938
10682
|
return initialValue;
|
|
10939
10683
|
}
|
|
10940
10684
|
};
|
|
10941
|
-
const [stored, setStored] =
|
|
10942
|
-
const setValue =
|
|
10685
|
+
const [stored, setStored] = React23__default.useState(read);
|
|
10686
|
+
const setValue = React23__default.useCallback(
|
|
10943
10687
|
(value) => {
|
|
10944
10688
|
setStored((prev) => {
|
|
10945
10689
|
const next = typeof value === "function" ? value(prev) : value;
|
|
@@ -10955,8 +10699,8 @@ function useLocalStorage(key, initialValue) {
|
|
|
10955
10699
|
return [stored, setValue];
|
|
10956
10700
|
}
|
|
10957
10701
|
function useCopyToClipboard(timeout = 1500) {
|
|
10958
|
-
const [copied, setCopied] =
|
|
10959
|
-
const copy =
|
|
10702
|
+
const [copied, setCopied] = React23__default.useState(false);
|
|
10703
|
+
const copy = React23__default.useCallback(async (text) => {
|
|
10960
10704
|
if (!canUseDOM || !navigator.clipboard) {
|
|
10961
10705
|
setCopied(false);
|
|
10962
10706
|
return false;
|
|
@@ -10970,7 +10714,7 @@ function useCopyToClipboard(timeout = 1500) {
|
|
|
10970
10714
|
return false;
|
|
10971
10715
|
}
|
|
10972
10716
|
}, []);
|
|
10973
|
-
|
|
10717
|
+
React23__default.useEffect(() => {
|
|
10974
10718
|
if (!copied) return void 0;
|
|
10975
10719
|
const t = setTimeout(() => setCopied(false), timeout);
|
|
10976
10720
|
return () => clearTimeout(t);
|
|
@@ -10978,23 +10722,23 @@ function useCopyToClipboard(timeout = 1500) {
|
|
|
10978
10722
|
return { copied, copy };
|
|
10979
10723
|
}
|
|
10980
10724
|
function useDebouncedValue(value, delay = 200) {
|
|
10981
|
-
const [debounced, setDebounced] =
|
|
10982
|
-
|
|
10725
|
+
const [debounced, setDebounced] = React23__default.useState(value);
|
|
10726
|
+
React23__default.useEffect(() => {
|
|
10983
10727
|
const t = setTimeout(() => setDebounced(value), delay);
|
|
10984
10728
|
return () => clearTimeout(t);
|
|
10985
10729
|
}, [value, delay]);
|
|
10986
10730
|
return debounced;
|
|
10987
10731
|
}
|
|
10988
10732
|
function useDebouncedCallback(callback, delay = 200) {
|
|
10989
|
-
const saved =
|
|
10990
|
-
const timer =
|
|
10733
|
+
const saved = React23__default.useRef(callback);
|
|
10734
|
+
const timer = React23__default.useRef(null);
|
|
10991
10735
|
useIsomorphicLayoutEffect(() => {
|
|
10992
10736
|
saved.current = callback;
|
|
10993
10737
|
}, [callback]);
|
|
10994
|
-
|
|
10738
|
+
React23__default.useEffect(() => () => {
|
|
10995
10739
|
if (timer.current) clearTimeout(timer.current);
|
|
10996
10740
|
}, []);
|
|
10997
|
-
return
|
|
10741
|
+
return React23__default.useCallback(
|
|
10998
10742
|
(...args) => {
|
|
10999
10743
|
if (timer.current) clearTimeout(timer.current);
|
|
11000
10744
|
timer.current = setTimeout(() => saved.current(...args), delay);
|
|
@@ -11003,33 +10747,33 @@ function useDebouncedCallback(callback, delay = 200) {
|
|
|
11003
10747
|
);
|
|
11004
10748
|
}
|
|
11005
10749
|
function useInterval(callback, delay) {
|
|
11006
|
-
const saved =
|
|
10750
|
+
const saved = React23__default.useRef(callback);
|
|
11007
10751
|
useIsomorphicLayoutEffect(() => {
|
|
11008
10752
|
saved.current = callback;
|
|
11009
10753
|
}, [callback]);
|
|
11010
|
-
|
|
10754
|
+
React23__default.useEffect(() => {
|
|
11011
10755
|
if (delay == null) return void 0;
|
|
11012
10756
|
const id = setInterval(() => saved.current(), delay);
|
|
11013
10757
|
return () => clearInterval(id);
|
|
11014
10758
|
}, [delay]);
|
|
11015
10759
|
}
|
|
11016
10760
|
function useTimeout(callback, delay) {
|
|
11017
|
-
const saved =
|
|
10761
|
+
const saved = React23__default.useRef(callback);
|
|
11018
10762
|
useIsomorphicLayoutEffect(() => {
|
|
11019
10763
|
saved.current = callback;
|
|
11020
10764
|
}, [callback]);
|
|
11021
|
-
|
|
10765
|
+
React23__default.useEffect(() => {
|
|
11022
10766
|
if (delay == null) return void 0;
|
|
11023
10767
|
const id = setTimeout(() => saved.current(), delay);
|
|
11024
10768
|
return () => clearTimeout(id);
|
|
11025
10769
|
}, [delay]);
|
|
11026
10770
|
}
|
|
11027
10771
|
function useWindowSize() {
|
|
11028
|
-
const [size, setSize] =
|
|
10772
|
+
const [size, setSize] = React23__default.useState(() => ({
|
|
11029
10773
|
width: canUseDOM ? window.innerWidth : 0,
|
|
11030
10774
|
height: canUseDOM ? window.innerHeight : 0
|
|
11031
10775
|
}));
|
|
11032
|
-
|
|
10776
|
+
React23__default.useEffect(() => {
|
|
11033
10777
|
if (!canUseDOM) return void 0;
|
|
11034
10778
|
const onResize = () => setSize({ width: window.innerWidth, height: window.innerHeight });
|
|
11035
10779
|
onResize();
|
|
@@ -11039,8 +10783,8 @@ function useWindowSize() {
|
|
|
11039
10783
|
return size;
|
|
11040
10784
|
}
|
|
11041
10785
|
function useHover(ref) {
|
|
11042
|
-
const [hovered, setHovered] =
|
|
11043
|
-
|
|
10786
|
+
const [hovered, setHovered] = React23__default.useState(false);
|
|
10787
|
+
React23__default.useEffect(() => {
|
|
11044
10788
|
const el = ref && ref.current;
|
|
11045
10789
|
if (!el) return void 0;
|
|
11046
10790
|
const on = () => setHovered(true);
|
|
@@ -11056,8 +10800,8 @@ function useHover(ref) {
|
|
|
11056
10800
|
}
|
|
11057
10801
|
function useIntersectionObserver(ref, options = {}) {
|
|
11058
10802
|
const { root = null, rootMargin = "0px", threshold = 0 } = options;
|
|
11059
|
-
const [entry, setEntry] =
|
|
11060
|
-
|
|
10803
|
+
const [entry, setEntry] = React23__default.useState(null);
|
|
10804
|
+
React23__default.useEffect(() => {
|
|
11061
10805
|
const el = ref && ref.current;
|
|
11062
10806
|
if (!canUseDOM || !el || typeof IntersectionObserver === "undefined") return void 0;
|
|
11063
10807
|
const obs = new IntersectionObserver(([e]) => setEntry(e), { root, rootMargin, threshold });
|
|
@@ -11085,7 +10829,7 @@ function useScrollLock(locked = true) {
|
|
|
11085
10829
|
}, [locked]);
|
|
11086
10830
|
}
|
|
11087
10831
|
function useId(prefix = "twc") {
|
|
11088
|
-
const raw =
|
|
10832
|
+
const raw = React23__default.useId();
|
|
11089
10833
|
return prefix ? `${prefix}-${raw.replace(/:/g, "")}` : raw;
|
|
11090
10834
|
}
|
|
11091
10835
|
|