twico-ui 1.0.0 → 1.0.1
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 +873 -1114
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +857 -1113
- package/dist/index.mjs.map +1 -1
- package/llms.txt +2420 -0
- package/package.json +17 -10
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var React23 = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactDom = require('react-dom');
|
|
7
7
|
|
|
8
|
-
function
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
9
25
|
|
|
10
|
-
var
|
|
26
|
+
var React23__namespace = /*#__PURE__*/_interopNamespace(React23);
|
|
11
27
|
|
|
12
28
|
// components/navigation/Accordion.jsx
|
|
29
|
+
var SUPPORTS_STYLE_HOIST = parseInt(String(React23__namespace.version), 10) >= 19;
|
|
30
|
+
function useScopedStyles(id, css) {
|
|
31
|
+
React23__namespace.useInsertionEffect(() => {
|
|
32
|
+
if (SUPPORTS_STYLE_HOIST) return;
|
|
33
|
+
if (typeof document === "undefined" || document.getElementById(id)) return;
|
|
34
|
+
const el = document.createElement("style");
|
|
35
|
+
el.id = id;
|
|
36
|
+
el.textContent = css;
|
|
37
|
+
document.head.appendChild(el);
|
|
38
|
+
}, [id, css]);
|
|
39
|
+
return SUPPORTS_STYLE_HOIST ? React23__namespace.createElement("style", { href: id, precedence: "twc-ui" }, css) : null;
|
|
40
|
+
}
|
|
13
41
|
var ACCORDION_CSS = `
|
|
14
42
|
.twc-accordion { display: flex; flex-direction: column; font-family: var(--font-sans);
|
|
15
43
|
border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; background: var(--color-surface); }
|
|
@@ -44,16 +72,10 @@ function Accordion({
|
|
|
44
72
|
className = "",
|
|
45
73
|
...rest
|
|
46
74
|
}) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const el = document.createElement("style");
|
|
50
|
-
el.id = "twc-accordion-styles";
|
|
51
|
-
el.textContent = ACCORDION_CSS;
|
|
52
|
-
document.head.appendChild(el);
|
|
53
|
-
}, []);
|
|
54
|
-
const [internal, setInternal] = React22__default.default.useState(() => new Set(defaultOpen));
|
|
75
|
+
const __twcStyles = useScopedStyles("twc-accordion-styles", ACCORDION_CSS);
|
|
76
|
+
const [internal, setInternal] = React23__namespace.default.useState(() => new Set(defaultOpen));
|
|
55
77
|
const open = openProp !== void 0 ? new Set(openProp) : internal;
|
|
56
|
-
const baseId =
|
|
78
|
+
const baseId = React23__namespace.default.useId();
|
|
57
79
|
function toggle(val) {
|
|
58
80
|
const next = new Set(open);
|
|
59
81
|
if (next.has(val)) next.delete(val);
|
|
@@ -64,19 +86,22 @@ function Accordion({
|
|
|
64
86
|
if (openProp === void 0) setInternal(next);
|
|
65
87
|
onOpenChange?.([...next]);
|
|
66
88
|
}
|
|
67
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/* @__PURE__ */ jsxRuntime.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-accordion ${className}`, ...rest, children: [
|
|
90
|
+
__twcStyles,
|
|
91
|
+
items.map((it, i) => {
|
|
92
|
+
const isOpen = open.has(it.value);
|
|
93
|
+
const triggerId = `${baseId}-trigger-${i}`;
|
|
94
|
+
const panelId = `${baseId}-panel-${i}`;
|
|
95
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-accordion__item", children: [
|
|
96
|
+
/* @__PURE__ */ jsxRuntime.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: [
|
|
97
|
+
it.icon,
|
|
98
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-accordion__label", children: it.label }),
|
|
99
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-accordion__chevron", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 9 6 6 6-6" }) }) })
|
|
100
|
+
] }),
|
|
101
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-accordion__panel", id: panelId, role: "region", "aria-labelledby": triggerId, "data-open": isOpen || void 0, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-accordion__panel-inner", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-accordion__content", children: it.content }) }) })
|
|
102
|
+
] }, it.value);
|
|
103
|
+
})
|
|
104
|
+
] });
|
|
80
105
|
}
|
|
81
106
|
var ALERT_CSS = `
|
|
82
107
|
.twc-alert {
|
|
@@ -131,14 +156,9 @@ function Alert({
|
|
|
131
156
|
className = "",
|
|
132
157
|
...rest
|
|
133
158
|
}) {
|
|
134
|
-
|
|
135
|
-
if (document.getElementById("twc-alert-styles")) return;
|
|
136
|
-
const el = document.createElement("style");
|
|
137
|
-
el.id = "twc-alert-styles";
|
|
138
|
-
el.textContent = ALERT_CSS;
|
|
139
|
-
document.head.appendChild(el);
|
|
140
|
-
}, []);
|
|
159
|
+
const __twcStyles = useScopedStyles("twc-alert-styles", ALERT_CSS);
|
|
141
160
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-alert ${className}`, "data-tone": tone, "data-variant": variant, role: "alert", ...rest, children: [
|
|
161
|
+
__twcStyles,
|
|
142
162
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-alert__icon", "aria-hidden": "true", children: icon || /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
143
163
|
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
144
164
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: ICONS[tone] })
|
|
@@ -200,14 +220,8 @@ function Avatar({
|
|
|
200
220
|
className = "",
|
|
201
221
|
...rest
|
|
202
222
|
}) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const el = document.createElement("style");
|
|
206
|
-
el.id = "twc-avatar-styles";
|
|
207
|
-
el.textContent = AVATAR_CSS;
|
|
208
|
-
document.head.appendChild(el);
|
|
209
|
-
}, []);
|
|
210
|
-
const [errored, setErrored] = React22__default.default.useState(false);
|
|
223
|
+
const __twcStyles = useScopedStyles("twc-avatar-styles", AVATAR_CSS);
|
|
224
|
+
const [errored, setErrored] = React23__namespace.default.useState(false);
|
|
211
225
|
const cleanSrc = safeSrc(src);
|
|
212
226
|
const showImg = cleanSrc && !errored;
|
|
213
227
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -220,6 +234,7 @@ function Avatar({
|
|
|
220
234
|
"aria-label": name || "avatar",
|
|
221
235
|
...rest,
|
|
222
236
|
children: [
|
|
237
|
+
__twcStyles,
|
|
223
238
|
showImg ? /* @__PURE__ */ jsxRuntime.jsx("img", { className: "twc-avatar__img", src: cleanSrc, alt: name || "", onError: () => setErrored(true) }, cleanSrc) : initials(name),
|
|
224
239
|
status ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-avatar__status", "data-status": status }) : null
|
|
225
240
|
]
|
|
@@ -274,29 +289,23 @@ function Menu({
|
|
|
274
289
|
className = "",
|
|
275
290
|
...rest
|
|
276
291
|
}) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
const [render, setRender] = React22__default.default.useState(false);
|
|
286
|
-
const [pos, setPos] = React22__default.default.useState(null);
|
|
287
|
-
const [active, setActive] = React22__default.default.useState(-1);
|
|
288
|
-
const wrapRef = React22__default.default.useRef(null);
|
|
289
|
-
const menuRef = React22__default.default.useRef(null);
|
|
290
|
-
const menuId = React22__default.default.useId();
|
|
292
|
+
const __twcStyles = useScopedStyles("twc-menu-styles", MENU_CSS);
|
|
293
|
+
const [openState, setOpenState] = React23__namespace.default.useState(defaultOpen);
|
|
294
|
+
const [render, setRender] = React23__namespace.default.useState(false);
|
|
295
|
+
const [pos, setPos] = React23__namespace.default.useState(null);
|
|
296
|
+
const [active, setActive] = React23__namespace.default.useState(-1);
|
|
297
|
+
const wrapRef = React23__namespace.default.useRef(null);
|
|
298
|
+
const menuRef = React23__namespace.default.useRef(null);
|
|
299
|
+
const menuId = React23__namespace.default.useId();
|
|
291
300
|
const controlled = openProp !== void 0;
|
|
292
301
|
const open = controlled ? !!openProp : openState;
|
|
293
|
-
const openRef =
|
|
302
|
+
const openRef = React23__namespace.default.useRef(open);
|
|
294
303
|
openRef.current = open;
|
|
295
|
-
const controlledRef =
|
|
304
|
+
const controlledRef = React23__namespace.default.useRef(controlled);
|
|
296
305
|
controlledRef.current = controlled;
|
|
297
|
-
const onOpenChangeRef =
|
|
306
|
+
const onOpenChangeRef = React23__namespace.default.useRef(onOpenChange);
|
|
298
307
|
onOpenChangeRef.current = onOpenChange;
|
|
299
|
-
const setOpen =
|
|
308
|
+
const setOpen = React23__namespace.default.useCallback((next) => {
|
|
300
309
|
const value = typeof next === "function" ? next(openRef.current) : next;
|
|
301
310
|
if (value === openRef.current) return;
|
|
302
311
|
if (!controlledRef.current) setOpenState(value);
|
|
@@ -304,7 +313,7 @@ function Menu({
|
|
|
304
313
|
}, []);
|
|
305
314
|
const RD = { createPortal: typeof reactDom.createPortal === "function" ? reactDom.createPortal : typeof window !== "undefined" && window.ReactDOM && window.ReactDOM.createPortal };
|
|
306
315
|
const interactiveIdx = items.map((it, i) => !it.separator && !it.heading ? i : -1).filter((i) => i >= 0);
|
|
307
|
-
const place =
|
|
316
|
+
const place = React23__namespace.default.useCallback(() => {
|
|
308
317
|
const t = wrapRef.current;
|
|
309
318
|
if (!t) return;
|
|
310
319
|
const r = t.getBoundingClientRect();
|
|
@@ -319,7 +328,7 @@ function Menu({
|
|
|
319
328
|
const avail = (flip ? r.top : vh - r.bottom) - gap - M;
|
|
320
329
|
setPos({ top, bottom, left, width: w, flip, maxHeight: Math.max(120, avail) });
|
|
321
330
|
}, [align, width]);
|
|
322
|
-
|
|
331
|
+
React23__namespace.default.useEffect(() => {
|
|
323
332
|
if (!open) return;
|
|
324
333
|
place();
|
|
325
334
|
const onMove = () => place();
|
|
@@ -337,7 +346,7 @@ function Menu({
|
|
|
337
346
|
document.removeEventListener("mousedown", onDown);
|
|
338
347
|
};
|
|
339
348
|
}, [open, place]);
|
|
340
|
-
|
|
349
|
+
React23__namespace.default.useEffect(() => {
|
|
341
350
|
if (open) {
|
|
342
351
|
setRender(true);
|
|
343
352
|
return;
|
|
@@ -400,6 +409,7 @@ function Menu({
|
|
|
400
409
|
role: "menu",
|
|
401
410
|
style: { top: pos.top, bottom: pos.bottom, left: pos.left, minWidth: pos.width, width: pos.width, maxHeight: pos.maxHeight },
|
|
402
411
|
children: [
|
|
412
|
+
__twcStyles,
|
|
403
413
|
header ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-menu__header", children: header }) : null,
|
|
404
414
|
items.map((it, i) => {
|
|
405
415
|
if (it.separator) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-menu__sep", role: "separator" }, `s${i}`);
|
|
@@ -433,7 +443,7 @@ function Menu({
|
|
|
433
443
|
}
|
|
434
444
|
) : null;
|
|
435
445
|
const activeDescId = open && active >= 0 ? `${menuId}-item-${active}` : void 0;
|
|
436
|
-
const triggerEl =
|
|
446
|
+
const triggerEl = React23__namespace.default.isValidElement(trigger) ? React23__namespace.default.cloneElement(trigger, {
|
|
437
447
|
onClick: (e) => {
|
|
438
448
|
trigger.props.onClick?.(e);
|
|
439
449
|
toggle();
|
|
@@ -487,13 +497,7 @@ function AvatarMenu({
|
|
|
487
497
|
className = "",
|
|
488
498
|
...rest
|
|
489
499
|
}) {
|
|
490
|
-
|
|
491
|
-
if (document.getElementById("twc-avatar-menu-styles")) return;
|
|
492
|
-
const el = document.createElement("style");
|
|
493
|
-
el.id = "twc-avatar-menu-styles";
|
|
494
|
-
el.textContent = AVATARMENU_CSS;
|
|
495
|
-
document.head.appendChild(el);
|
|
496
|
-
}, []);
|
|
500
|
+
const __twcStyles = useScopedStyles("twc-avatar-menu-styles", AVATARMENU_CSS);
|
|
497
501
|
const sub = subtitle ?? email;
|
|
498
502
|
const showChev = showChevron ?? showName;
|
|
499
503
|
const header = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -512,6 +516,7 @@ function AvatarMenu({
|
|
|
512
516
|
"aria-haspopup": "menu",
|
|
513
517
|
"aria-label": `${name || "Account"} menu`,
|
|
514
518
|
children: [
|
|
519
|
+
__twcStyles,
|
|
515
520
|
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { name, src, size, status }),
|
|
516
521
|
showName ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "twc-avatar-menu__text", children: [
|
|
517
522
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-avatar-menu__name", children: name }),
|
|
@@ -569,14 +574,9 @@ function Badge({
|
|
|
569
574
|
className = "",
|
|
570
575
|
...rest
|
|
571
576
|
}) {
|
|
572
|
-
|
|
573
|
-
if (document.getElementById("twc-badge-styles")) return;
|
|
574
|
-
const el = document.createElement("style");
|
|
575
|
-
el.id = "twc-badge-styles";
|
|
576
|
-
el.textContent = BADGE_CSS;
|
|
577
|
-
document.head.appendChild(el);
|
|
578
|
-
}, []);
|
|
577
|
+
const __twcStyles = useScopedStyles("twc-badge-styles", BADGE_CSS);
|
|
579
578
|
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: `twc-badge ${className}`, "data-tone": tone, "data-variant": variant, "data-size": size, ...rest, children: [
|
|
579
|
+
__twcStyles,
|
|
580
580
|
dot ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-badge__dot" }) : null,
|
|
581
581
|
children
|
|
582
582
|
] });
|
|
@@ -606,14 +606,8 @@ function Breadcrumb({
|
|
|
606
606
|
className = "",
|
|
607
607
|
...rest
|
|
608
608
|
}) {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
const el = document.createElement("style");
|
|
612
|
-
el.id = "twc-breadcrumb-styles";
|
|
613
|
-
el.textContent = BREADCRUMB_CSS;
|
|
614
|
-
document.head.appendChild(el);
|
|
615
|
-
}, []);
|
|
616
|
-
const [expanded, setExpanded] = React22__default.default.useState(false);
|
|
609
|
+
const __twcStyles = useScopedStyles("twc-breadcrumb-styles", BREADCRUMB_CSS);
|
|
610
|
+
const [expanded, setExpanded] = React23__namespace.default.useState(false);
|
|
617
611
|
const sep = separator || /* @__PURE__ */ jsxRuntime.jsx(ChevronSep, {});
|
|
618
612
|
let display = items;
|
|
619
613
|
if (maxItems > 0 && items.length > maxItems && !expanded) {
|
|
@@ -622,35 +616,38 @@ function Breadcrumb({
|
|
|
622
616
|
const tail = items.slice(items.length - keepTail);
|
|
623
617
|
display = [...head, { ellipsis: true }, ...tail];
|
|
624
618
|
}
|
|
625
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
{
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
619
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("nav", { className: `twc-breadcrumb ${className}`, "aria-label": "Breadcrumb", ...rest, children: [
|
|
620
|
+
__twcStyles,
|
|
621
|
+
display.map((it, i) => {
|
|
622
|
+
const last = i === display.length - 1;
|
|
623
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React23__namespace.default.Fragment, { children: [
|
|
624
|
+
it.ellipsis ? /* @__PURE__ */ jsxRuntime.jsx("button", { className: "twc-breadcrumb__ellipsis", "aria-label": "Show more", onClick: () => setExpanded(true), children: "\u2026" }) : last ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
625
|
+
"span",
|
|
626
|
+
{
|
|
627
|
+
className: "twc-breadcrumb__item",
|
|
628
|
+
"aria-current": "page",
|
|
629
|
+
onClick: it.onClick,
|
|
630
|
+
children: [
|
|
631
|
+
it.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", style: { display: "inline-flex" }, children: it.icon }) : null,
|
|
632
|
+
it.label
|
|
633
|
+
]
|
|
634
|
+
}
|
|
635
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
636
|
+
"a",
|
|
637
|
+
{
|
|
638
|
+
className: "twc-breadcrumb__item",
|
|
639
|
+
href: safeHref(it.href) || "#",
|
|
640
|
+
onClick: it.onClick,
|
|
641
|
+
children: [
|
|
642
|
+
it.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", style: { display: "inline-flex" }, children: it.icon }) : null,
|
|
643
|
+
it.label
|
|
644
|
+
]
|
|
645
|
+
}
|
|
646
|
+
),
|
|
647
|
+
!last ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-breadcrumb__sep", "aria-hidden": "true", children: sep }) : null
|
|
648
|
+
] }, i);
|
|
649
|
+
})
|
|
650
|
+
] });
|
|
654
651
|
}
|
|
655
652
|
var CSS2 = `
|
|
656
653
|
.twc-btn {
|
|
@@ -747,15 +744,6 @@ function safeHref2(url) {
|
|
|
747
744
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
748
745
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
749
746
|
}
|
|
750
|
-
function useInjectedStyle(id, css) {
|
|
751
|
-
React22__default.default.useInsertionEffect(() => {
|
|
752
|
-
if (document.getElementById(id)) return;
|
|
753
|
-
const el = document.createElement("style");
|
|
754
|
-
el.id = id;
|
|
755
|
-
el.textContent = css;
|
|
756
|
-
document.head.appendChild(el);
|
|
757
|
-
}, [id, css]);
|
|
758
|
-
}
|
|
759
747
|
function Button({
|
|
760
748
|
children,
|
|
761
749
|
variant = "solid",
|
|
@@ -772,8 +760,8 @@ function Button({
|
|
|
772
760
|
onClick,
|
|
773
761
|
...rest
|
|
774
762
|
}) {
|
|
775
|
-
|
|
776
|
-
const [ripples, setRipples] =
|
|
763
|
+
const __twcStyles = useScopedStyles("twc-btn-styles", CSS2);
|
|
764
|
+
const [ripples, setRipples] = React23__namespace.default.useState([]);
|
|
777
765
|
const Tag2 = as;
|
|
778
766
|
const inert = Tag2 === "a" && (disabled || loading);
|
|
779
767
|
function handleClick(e) {
|
|
@@ -809,6 +797,7 @@ function Button({
|
|
|
809
797
|
onClick: handleClick,
|
|
810
798
|
...rest,
|
|
811
799
|
children: [
|
|
800
|
+
__twcStyles,
|
|
812
801
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "twc-btn__content", children: [
|
|
813
802
|
leftIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-btn__icon", "aria-hidden": "true", children: leftIcon }) : null,
|
|
814
803
|
children,
|
|
@@ -866,13 +855,7 @@ function Card({
|
|
|
866
855
|
className = "",
|
|
867
856
|
...rest
|
|
868
857
|
}) {
|
|
869
|
-
|
|
870
|
-
if (document.getElementById("twc-card-styles")) return;
|
|
871
|
-
const el = document.createElement("style");
|
|
872
|
-
el.id = "twc-card-styles";
|
|
873
|
-
el.textContent = CARD_CSS;
|
|
874
|
-
document.head.appendChild(el);
|
|
875
|
-
}, []);
|
|
858
|
+
const __twcStyles = useScopedStyles("twc-card-styles", CARD_CSS);
|
|
876
859
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
877
860
|
"div",
|
|
878
861
|
{
|
|
@@ -883,6 +866,7 @@ function Card({
|
|
|
883
866
|
"data-full": fullHeight || void 0,
|
|
884
867
|
...rest,
|
|
885
868
|
children: [
|
|
869
|
+
__twcStyles,
|
|
886
870
|
title || subtitle ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-card__header", children: [
|
|
887
871
|
title ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-card__title", children: title }) : null,
|
|
888
872
|
subtitle ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-card__subtitle", children: subtitle }) : null
|
|
@@ -928,26 +912,20 @@ function Carousel({
|
|
|
928
912
|
className = "",
|
|
929
913
|
...rest
|
|
930
914
|
}) {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
const el = document.createElement("style");
|
|
934
|
-
el.id = "twc-carousel-styles";
|
|
935
|
-
el.textContent = CAROUSEL_CSS;
|
|
936
|
-
document.head.appendChild(el);
|
|
937
|
-
}, []);
|
|
938
|
-
const slides = React22__default.default.Children.toArray(children);
|
|
915
|
+
const __twcStyles = useScopedStyles("twc-carousel-styles", CAROUSEL_CSS);
|
|
916
|
+
const slides = React23__namespace.default.Children.toArray(children);
|
|
939
917
|
const count = slides.length;
|
|
940
|
-
const [internal, setInternal] =
|
|
918
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultIndex);
|
|
941
919
|
const index = indexProp !== void 0 ? indexProp : internal;
|
|
942
|
-
const [paused, setPaused] =
|
|
943
|
-
const setIndex =
|
|
920
|
+
const [paused, setPaused] = React23__namespace.default.useState(false);
|
|
921
|
+
const setIndex = React23__namespace.default.useCallback((i) => {
|
|
944
922
|
if (indexProp === void 0) setInternal(i);
|
|
945
923
|
onIndexChange?.(i);
|
|
946
924
|
}, [indexProp, onIndexChange]);
|
|
947
|
-
const go =
|
|
925
|
+
const go = React23__namespace.default.useCallback((i) => {
|
|
948
926
|
setIndex(loop ? (i + count) % count : Math.min(Math.max(i, 0), count - 1));
|
|
949
927
|
}, [count, loop, setIndex]);
|
|
950
|
-
|
|
928
|
+
React23__namespace.default.useEffect(() => {
|
|
951
929
|
if (!autoPlay || paused || count <= 1) return;
|
|
952
930
|
const t = setInterval(() => {
|
|
953
931
|
const next = loop ? (index + 1) % count : index + 1 >= count ? index : index + 1;
|
|
@@ -969,6 +947,7 @@ function Carousel({
|
|
|
969
947
|
"aria-roledescription": "carousel",
|
|
970
948
|
...rest,
|
|
971
949
|
children: [
|
|
950
|
+
__twcStyles,
|
|
972
951
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-carousel__viewport", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-carousel__track", style: { transform: `translateX(-${index * 100}%)` }, children: slides.map((s, i) => /* @__PURE__ */ jsxRuntime.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)) }) }),
|
|
973
952
|
showArrows && count > 1 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
974
953
|
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "twc-carousel__arrow", "data-dir": "prev", "aria-label": "Previous", disabled: atStart, onClick: () => go(index - 1), children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m15 18-6-6 6-6" }) }) }),
|
|
@@ -1009,13 +988,7 @@ function Chart({
|
|
|
1009
988
|
className = "",
|
|
1010
989
|
...rest
|
|
1011
990
|
}) {
|
|
1012
|
-
|
|
1013
|
-
if (document.getElementById("twc-chart-styles")) return;
|
|
1014
|
-
const el = document.createElement("style");
|
|
1015
|
-
el.id = "twc-chart-styles";
|
|
1016
|
-
el.textContent = CHART_CSS;
|
|
1017
|
-
document.head.appendChild(el);
|
|
1018
|
-
}, []);
|
|
991
|
+
const __twcStyles = useScopedStyles("twc-chart-styles", CHART_CSS);
|
|
1019
992
|
const keys = series || ["value"];
|
|
1020
993
|
const palette = colors && colors.length ? colors : SERIES_COLORS;
|
|
1021
994
|
const W = 600, H = height, padL = showAxis ? 40 : 8, padR = 8, padT = 12, padB = showAxis ? 26 : 8;
|
|
@@ -1027,6 +1000,7 @@ function Chart({
|
|
|
1027
1000
|
const ticks = 4;
|
|
1028
1001
|
const svgAriaLabel = ariaLabelProp ?? ariaLabel ?? `${type} chart`;
|
|
1029
1002
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-chart ${className}`, ...rest, children: [
|
|
1003
|
+
__twcStyles,
|
|
1030
1004
|
/* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: `0 0 ${W} ${H}`, role: "img", "aria-label": svgAriaLabel, preserveAspectRatio: "none", children: [
|
|
1031
1005
|
showGrid ? Array.from({ length: ticks + 1 }).map((_, i) => {
|
|
1032
1006
|
const gy = padT + innerH / ticks * i;
|
|
@@ -1110,11 +1084,7 @@ function Checkbox({
|
|
|
1110
1084
|
onChange,
|
|
1111
1085
|
...rest
|
|
1112
1086
|
}) {
|
|
1113
|
-
|
|
1114
|
-
if (document.getElementById("twc-checkbox-styles")) return;
|
|
1115
|
-
const el = document.createElement("style");
|
|
1116
|
-
el.id = "twc-checkbox-styles";
|
|
1117
|
-
el.textContent = `
|
|
1087
|
+
const __twcStyles = useScopedStyles("twc-checkbox-styles", `
|
|
1118
1088
|
.twc-check { display: inline-flex; align-items: flex-start; gap: var(--space-2-5); cursor: pointer; font-family: var(--font-sans); }
|
|
1119
1089
|
/* tone \u2192 accent set (default primary). Mirrors Button's --_accent model; Badge's tone vocabulary. */
|
|
1120
1090
|
.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); }
|
|
@@ -1152,19 +1122,18 @@ function Checkbox({
|
|
|
1152
1122
|
.twc-check__desc { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
1153
1123
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
1154
1124
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
}, []);
|
|
1158
|
-
const autoId = React22__default.default.useId();
|
|
1125
|
+
`);
|
|
1126
|
+
const autoId = React23__namespace.default.useId();
|
|
1159
1127
|
const fieldId = id || autoId;
|
|
1160
1128
|
const errId = `${fieldId}-error`;
|
|
1161
1129
|
const invalid = Boolean(error);
|
|
1162
|
-
const ref =
|
|
1163
|
-
|
|
1130
|
+
const ref = React23__namespace.default.useRef(null);
|
|
1131
|
+
React23__namespace.default.useEffect(() => {
|
|
1164
1132
|
if (ref.current) ref.current.indeterminate = indeterminate;
|
|
1165
1133
|
}, [indeterminate]);
|
|
1166
1134
|
const describedBy = [rest["aria-describedby"], error ? errId : null].filter(Boolean).join(" ") || void 0;
|
|
1167
1135
|
const control = /* @__PURE__ */ jsxRuntime.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: [
|
|
1136
|
+
__twcStyles,
|
|
1168
1137
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1169
1138
|
"input",
|
|
1170
1139
|
{
|
|
@@ -1294,33 +1263,22 @@ function ColorPicker({
|
|
|
1294
1263
|
className = "",
|
|
1295
1264
|
...rest
|
|
1296
1265
|
}) {
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
fel.id = "twc-field-styles";
|
|
1301
|
-
fel.textContent = FIELD_CSS;
|
|
1302
|
-
document.head.appendChild(fel);
|
|
1303
|
-
}
|
|
1304
|
-
if (document.getElementById("twc-colorpicker-styles")) return;
|
|
1305
|
-
const el = document.createElement("style");
|
|
1306
|
-
el.id = "twc-colorpicker-styles";
|
|
1307
|
-
el.textContent = COLORPICKER_CSS;
|
|
1308
|
-
document.head.appendChild(el);
|
|
1309
|
-
}, []);
|
|
1310
|
-
const [internal, setInternal] = React22__default.default.useState(defaultValue);
|
|
1266
|
+
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS);
|
|
1267
|
+
const __twcStyles1 = useScopedStyles("twc-colorpicker-styles", COLORPICKER_CSS);
|
|
1268
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultValue);
|
|
1311
1269
|
const hex = (value !== void 0 ? value : internal) || "#000000";
|
|
1312
|
-
const lastValidRef =
|
|
1270
|
+
const lastValidRef = React23__namespace.default.useRef(hex);
|
|
1313
1271
|
if (/^#[0-9a-f]{6}$/i.test(hex)) lastValidRef.current = hex;
|
|
1314
|
-
const [open, setOpen] =
|
|
1315
|
-
const [hsv, setHsv] =
|
|
1316
|
-
const [coords, setCoords] =
|
|
1317
|
-
const wrapRef =
|
|
1318
|
-
const triggerRef =
|
|
1319
|
-
const popRef =
|
|
1320
|
-
const areaRef =
|
|
1321
|
-
const hueRef =
|
|
1272
|
+
const [open, setOpen] = React23__namespace.default.useState(false);
|
|
1273
|
+
const [hsv, setHsv] = React23__namespace.default.useState(() => hexToHsv(hex) || { h: 239, s: 60, v: 94 });
|
|
1274
|
+
const [coords, setCoords] = React23__namespace.default.useState(null);
|
|
1275
|
+
const wrapRef = React23__namespace.default.useRef(null);
|
|
1276
|
+
const triggerRef = React23__namespace.default.useRef(null);
|
|
1277
|
+
const popRef = React23__namespace.default.useRef(null);
|
|
1278
|
+
const areaRef = React23__namespace.default.useRef(null);
|
|
1279
|
+
const hueRef = React23__namespace.default.useRef(null);
|
|
1322
1280
|
const POP_W = 240;
|
|
1323
|
-
const place =
|
|
1281
|
+
const place = React23__namespace.default.useCallback(() => {
|
|
1324
1282
|
const el = triggerRef.current;
|
|
1325
1283
|
if (!el) return;
|
|
1326
1284
|
const r = el.getBoundingClientRect();
|
|
@@ -1331,7 +1289,7 @@ function ColorPicker({
|
|
|
1331
1289
|
left = Math.max(8, left);
|
|
1332
1290
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
1333
1291
|
}, []);
|
|
1334
|
-
|
|
1292
|
+
React23__namespace.default.useEffect(() => {
|
|
1335
1293
|
if (!open) return void 0;
|
|
1336
1294
|
place();
|
|
1337
1295
|
const onMove = () => place();
|
|
@@ -1342,17 +1300,17 @@ function ColorPicker({
|
|
|
1342
1300
|
window.removeEventListener("resize", onMove);
|
|
1343
1301
|
};
|
|
1344
1302
|
}, [open, place]);
|
|
1345
|
-
const labelId =
|
|
1303
|
+
const labelId = React23__namespace.default.useId();
|
|
1346
1304
|
const descId = `${labelId}-desc`;
|
|
1347
1305
|
const invalid = Boolean(error);
|
|
1348
|
-
|
|
1306
|
+
React23__namespace.default.useEffect(() => {
|
|
1349
1307
|
if (disabled) setOpen(false);
|
|
1350
1308
|
}, [disabled]);
|
|
1351
|
-
|
|
1309
|
+
React23__namespace.default.useEffect(() => {
|
|
1352
1310
|
const v = hexToHsv(hex);
|
|
1353
1311
|
if (v && hsvToHex(v.h, v.s, v.v).toLowerCase() !== hsvToHex(hsv.h, hsv.s, hsv.v).toLowerCase()) setHsv(v);
|
|
1354
1312
|
}, [hex]);
|
|
1355
|
-
|
|
1313
|
+
React23__namespace.default.useEffect(() => {
|
|
1356
1314
|
if (!open) return;
|
|
1357
1315
|
const onDown = (e) => {
|
|
1358
1316
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -1369,8 +1327,8 @@ function ColorPicker({
|
|
|
1369
1327
|
document.removeEventListener("keydown", onKey);
|
|
1370
1328
|
};
|
|
1371
1329
|
}, [open]);
|
|
1372
|
-
const prevOpen =
|
|
1373
|
-
|
|
1330
|
+
const prevOpen = React23__namespace.default.useRef(false);
|
|
1331
|
+
React23__namespace.default.useEffect(() => {
|
|
1374
1332
|
let id;
|
|
1375
1333
|
if (!prevOpen.current && open) {
|
|
1376
1334
|
id = setTimeout(() => areaRef.current?.focus({ preventScroll: true }), 20);
|
|
@@ -1430,6 +1388,8 @@ function ColorPicker({
|
|
|
1430
1388
|
commit({ ...hsv, h });
|
|
1431
1389
|
};
|
|
1432
1390
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-cp twc-field ${className}`, ref: wrapRef, ...rest, children: [
|
|
1391
|
+
__twcStyles0,
|
|
1392
|
+
__twcStyles1,
|
|
1433
1393
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "twc-field__label", id: labelId, children: [
|
|
1434
1394
|
label,
|
|
1435
1395
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -1687,36 +1647,30 @@ function Combobox({
|
|
|
1687
1647
|
onKeyDown,
|
|
1688
1648
|
...rest
|
|
1689
1649
|
}) {
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
el.textContent = COMBO_CSS;
|
|
1695
|
-
document.head.appendChild(el);
|
|
1696
|
-
}, []);
|
|
1697
|
-
const groups = React22__default.default.useMemo(() => normalizeGroups(options), [options]);
|
|
1698
|
-
const flat = React22__default.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
1699
|
-
const autoId = React22__default.default.useId();
|
|
1650
|
+
const __twcStyles = useScopedStyles("twc-combo-styles", COMBO_CSS);
|
|
1651
|
+
const groups = React23__namespace.default.useMemo(() => normalizeGroups(options), [options]);
|
|
1652
|
+
const flat = React23__namespace.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
1653
|
+
const autoId = React23__namespace.default.useId();
|
|
1700
1654
|
const fieldId = id || autoId;
|
|
1701
|
-
const [internal, setInternal] =
|
|
1655
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultValue);
|
|
1702
1656
|
const current = value !== void 0 ? value : internal;
|
|
1703
1657
|
const selected = flat.find((o) => o.value === current);
|
|
1704
|
-
const [open, setOpen] =
|
|
1705
|
-
const [query, setQuery] =
|
|
1706
|
-
const [active, setActive] =
|
|
1707
|
-
const [coords, setCoords] =
|
|
1708
|
-
const wrapRef =
|
|
1709
|
-
const controlRef =
|
|
1710
|
-
const inputRef =
|
|
1711
|
-
const popRef =
|
|
1712
|
-
const listRef =
|
|
1713
|
-
const activeRef =
|
|
1714
|
-
const fGroups =
|
|
1658
|
+
const [open, setOpen] = React23__namespace.default.useState(false);
|
|
1659
|
+
const [query, setQuery] = React23__namespace.default.useState("");
|
|
1660
|
+
const [active, setActive] = React23__namespace.default.useState(0);
|
|
1661
|
+
const [coords, setCoords] = React23__namespace.default.useState(null);
|
|
1662
|
+
const wrapRef = React23__namespace.default.useRef(null);
|
|
1663
|
+
const controlRef = React23__namespace.default.useRef(null);
|
|
1664
|
+
const inputRef = React23__namespace.default.useRef(null);
|
|
1665
|
+
const popRef = React23__namespace.default.useRef(null);
|
|
1666
|
+
const listRef = React23__namespace.default.useRef(null);
|
|
1667
|
+
const activeRef = React23__namespace.default.useRef(null);
|
|
1668
|
+
const fGroups = React23__namespace.default.useMemo(
|
|
1715
1669
|
() => groups.map((g) => ({ group: g.group, options: g.options.filter((o) => matches(o, query.trim())) })).filter((g) => g.options.length),
|
|
1716
1670
|
[groups, query]
|
|
1717
1671
|
);
|
|
1718
|
-
const visible =
|
|
1719
|
-
const place =
|
|
1672
|
+
const visible = React23__namespace.default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
1673
|
+
const place = React23__namespace.default.useCallback(() => {
|
|
1720
1674
|
const el = controlRef.current;
|
|
1721
1675
|
if (!el) return;
|
|
1722
1676
|
const r = el.getBoundingClientRect();
|
|
@@ -1731,7 +1685,7 @@ function Combobox({
|
|
|
1731
1685
|
flip
|
|
1732
1686
|
});
|
|
1733
1687
|
}, [placement, minWidth]);
|
|
1734
|
-
|
|
1688
|
+
React23__namespace.default.useEffect(() => {
|
|
1735
1689
|
if (!open || !portal) return;
|
|
1736
1690
|
place();
|
|
1737
1691
|
const onMove = () => place();
|
|
@@ -1742,7 +1696,7 @@ function Combobox({
|
|
|
1742
1696
|
window.removeEventListener("resize", onMove);
|
|
1743
1697
|
};
|
|
1744
1698
|
}, [open, portal, place]);
|
|
1745
|
-
|
|
1699
|
+
React23__namespace.default.useEffect(() => {
|
|
1746
1700
|
if (!open) return;
|
|
1747
1701
|
const onDown = (e) => {
|
|
1748
1702
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -1752,10 +1706,10 @@ function Combobox({
|
|
|
1752
1706
|
document.addEventListener("mousedown", onDown);
|
|
1753
1707
|
return () => document.removeEventListener("mousedown", onDown);
|
|
1754
1708
|
}, [open]);
|
|
1755
|
-
|
|
1709
|
+
React23__namespace.default.useEffect(() => {
|
|
1756
1710
|
setActive(0);
|
|
1757
1711
|
}, [query]);
|
|
1758
|
-
|
|
1712
|
+
React23__namespace.default.useEffect(() => {
|
|
1759
1713
|
if (open) ensureVisible(listRef.current, activeRef.current);
|
|
1760
1714
|
}, [active, open]);
|
|
1761
1715
|
function openMenu() {
|
|
@@ -1798,7 +1752,7 @@ function Combobox({
|
|
|
1798
1752
|
const descId = `${fieldId}-desc`;
|
|
1799
1753
|
const describedBy = error || hint ? descId : void 0;
|
|
1800
1754
|
let counter = -1;
|
|
1801
|
-
const popInner = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__list", ref: listRef, children: visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1755
|
+
const popInner = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__list", ref: listRef, children: visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React23__namespace.default.Fragment, { children: [
|
|
1802
1756
|
g.group ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
1803
1757
|
g.options.map((o) => {
|
|
1804
1758
|
counter += 1;
|
|
@@ -1855,6 +1809,7 @@ function Combobox({
|
|
|
1855
1809
|
}
|
|
1856
1810
|
}
|
|
1857
1811
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-field ${className}`, ref: wrapRef, children: [
|
|
1812
|
+
__twcStyles,
|
|
1858
1813
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
1859
1814
|
label,
|
|
1860
1815
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -1979,21 +1934,15 @@ function CommandPalette({
|
|
|
1979
1934
|
className = "",
|
|
1980
1935
|
...rest
|
|
1981
1936
|
}) {
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
const [
|
|
1990
|
-
|
|
1991
|
-
const inputRef = React22__default.default.useRef(null);
|
|
1992
|
-
const listRef = React22__default.default.useRef(null);
|
|
1993
|
-
const paletteRef = React22__default.default.useRef(null);
|
|
1994
|
-
const baseId = React22__default.default.useId();
|
|
1995
|
-
const [mounted, setMounted] = React22__default.default.useState(open);
|
|
1996
|
-
React22__default.default.useEffect(() => {
|
|
1937
|
+
const __twcStyles = useScopedStyles("twc-cmdk-styles", COMMAND_CSS);
|
|
1938
|
+
const [query, setQuery] = React23__namespace.default.useState("");
|
|
1939
|
+
const [active, setActive] = React23__namespace.default.useState(0);
|
|
1940
|
+
const inputRef = React23__namespace.default.useRef(null);
|
|
1941
|
+
const listRef = React23__namespace.default.useRef(null);
|
|
1942
|
+
const paletteRef = React23__namespace.default.useRef(null);
|
|
1943
|
+
const baseId = React23__namespace.default.useId();
|
|
1944
|
+
const [mounted, setMounted] = React23__namespace.default.useState(open);
|
|
1945
|
+
React23__namespace.default.useEffect(() => {
|
|
1997
1946
|
if (open) {
|
|
1998
1947
|
setMounted(true);
|
|
1999
1948
|
return;
|
|
@@ -2001,7 +1950,7 @@ function CommandPalette({
|
|
|
2001
1950
|
const t = setTimeout(() => setMounted(false), 170);
|
|
2002
1951
|
return () => clearTimeout(t);
|
|
2003
1952
|
}, [open]);
|
|
2004
|
-
|
|
1953
|
+
React23__namespace.default.useEffect(() => {
|
|
2005
1954
|
if (!open) return void 0;
|
|
2006
1955
|
const prev = document.body.style.overflow;
|
|
2007
1956
|
document.body.style.overflow = "hidden";
|
|
@@ -2009,7 +1958,7 @@ function CommandPalette({
|
|
|
2009
1958
|
document.body.style.overflow = prev;
|
|
2010
1959
|
};
|
|
2011
1960
|
}, [open]);
|
|
2012
|
-
|
|
1961
|
+
React23__namespace.default.useEffect(() => {
|
|
2013
1962
|
if (open) {
|
|
2014
1963
|
setQuery("");
|
|
2015
1964
|
setActive(0);
|
|
@@ -2017,14 +1966,14 @@ function CommandPalette({
|
|
|
2017
1966
|
return () => clearTimeout(t);
|
|
2018
1967
|
}
|
|
2019
1968
|
}, [open]);
|
|
2020
|
-
|
|
1969
|
+
React23__namespace.default.useEffect(() => {
|
|
2021
1970
|
if (!open) return;
|
|
2022
1971
|
const prevFocused = document.activeElement;
|
|
2023
1972
|
return () => {
|
|
2024
1973
|
if (prevFocused && typeof prevFocused.focus === "function") prevFocused.focus();
|
|
2025
1974
|
};
|
|
2026
1975
|
}, [open]);
|
|
2027
|
-
|
|
1976
|
+
React23__namespace.default.useEffect(() => {
|
|
2028
1977
|
if (!open) return;
|
|
2029
1978
|
const focusables = (node) => node ? Array.from(
|
|
2030
1979
|
node.querySelectorAll(
|
|
@@ -2060,7 +2009,7 @@ function CommandPalette({
|
|
|
2060
2009
|
return () => document.removeEventListener("keydown", onKey);
|
|
2061
2010
|
}, [open, onClose]);
|
|
2062
2011
|
const q = query.trim().toLowerCase();
|
|
2063
|
-
const filtered =
|
|
2012
|
+
const filtered = React23__namespace.default.useMemo(() => commands.filter(
|
|
2064
2013
|
(c) => !q || c.label.toLowerCase().includes(q) || (c.keywords || "").toLowerCase().includes(q) || (c.group || "").toLowerCase().includes(q)
|
|
2065
2014
|
), [commands, q]);
|
|
2066
2015
|
const groups = [];
|
|
@@ -2075,7 +2024,7 @@ function CommandPalette({
|
|
|
2075
2024
|
g.items.push(c);
|
|
2076
2025
|
flat.push(c);
|
|
2077
2026
|
});
|
|
2078
|
-
|
|
2027
|
+
React23__namespace.default.useEffect(() => {
|
|
2079
2028
|
setActive(0);
|
|
2080
2029
|
}, [query]);
|
|
2081
2030
|
const run = (cmd) => {
|
|
@@ -2095,7 +2044,7 @@ function CommandPalette({
|
|
|
2095
2044
|
if (cmd) run(cmd);
|
|
2096
2045
|
}
|
|
2097
2046
|
}
|
|
2098
|
-
|
|
2047
|
+
React23__namespace.default.useEffect(() => {
|
|
2099
2048
|
const node = listRef.current?.querySelector('[data-active="true"]');
|
|
2100
2049
|
if (node) node.scrollIntoView({ block: "nearest" });
|
|
2101
2050
|
}, [active]);
|
|
@@ -2105,63 +2054,66 @@ function CommandPalette({
|
|
|
2105
2054
|
const optionId = (i) => `${baseId}-opt-${i}`;
|
|
2106
2055
|
const activeId = flat[active] ? optionId(active) : void 0;
|
|
2107
2056
|
let idx = -1;
|
|
2108
|
-
const overlay = /* @__PURE__ */ jsxRuntime.
|
|
2057
|
+
const overlay = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-cmdk__overlay", "data-state": state, onMouseDown: (e) => {
|
|
2109
2058
|
if (e.target === e.currentTarget) onClose?.();
|
|
2110
|
-
}, children:
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
className: "twc-cmdk__input",
|
|
2121
|
-
value: query,
|
|
2122
|
-
placeholder,
|
|
2123
|
-
role: "combobox",
|
|
2124
|
-
"aria-expanded": "true",
|
|
2125
|
-
"aria-controls": listId,
|
|
2126
|
-
"aria-activedescendant": activeId,
|
|
2127
|
-
onChange: (e) => setQuery(e.target.value),
|
|
2128
|
-
onKeyDown
|
|
2129
|
-
}
|
|
2130
|
-
),
|
|
2131
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-cmdk__kbd", children: "esc" })
|
|
2132
|
-
] }),
|
|
2133
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-cmdk__list", id: listId, role: "listbox", ref: listRef, children: flat.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-cmdk__empty", children: emptyText }) : groups.map((g) => /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "group", children: [
|
|
2134
|
-
g.key ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-cmdk__group-label", children: g.key }) : null,
|
|
2135
|
-
g.items.map((c) => {
|
|
2136
|
-
idx += 1;
|
|
2137
|
-
const i = idx;
|
|
2138
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2139
|
-
"button",
|
|
2059
|
+
}, children: [
|
|
2060
|
+
__twcStyles,
|
|
2061
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: paletteRef, className: `twc-cmdk ${className}`, "data-state": state, role: "dialog", "aria-modal": "true", "aria-label": "Command palette", tabIndex: -1, ...rest, children: [
|
|
2062
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-cmdk__search", children: [
|
|
2063
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2064
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "11", cy: "11", r: "8" }),
|
|
2065
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m21 21-4.3-4.3" })
|
|
2066
|
+
] }),
|
|
2067
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2068
|
+
"input",
|
|
2140
2069
|
{
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
"
|
|
2146
|
-
|
|
2147
|
-
"
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2070
|
+
ref: inputRef,
|
|
2071
|
+
className: "twc-cmdk__input",
|
|
2072
|
+
value: query,
|
|
2073
|
+
placeholder,
|
|
2074
|
+
role: "combobox",
|
|
2075
|
+
"aria-expanded": "true",
|
|
2076
|
+
"aria-controls": listId,
|
|
2077
|
+
"aria-activedescendant": activeId,
|
|
2078
|
+
onChange: (e) => setQuery(e.target.value),
|
|
2079
|
+
onKeyDown
|
|
2080
|
+
}
|
|
2081
|
+
),
|
|
2082
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-cmdk__kbd", children: "esc" })
|
|
2083
|
+
] }),
|
|
2084
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-cmdk__list", id: listId, role: "listbox", ref: listRef, children: flat.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-cmdk__empty", children: emptyText }) : groups.map((g) => /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "group", children: [
|
|
2085
|
+
g.key ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-cmdk__group-label", children: g.key }) : null,
|
|
2086
|
+
g.items.map((c) => {
|
|
2087
|
+
idx += 1;
|
|
2088
|
+
const i = idx;
|
|
2089
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2090
|
+
"button",
|
|
2091
|
+
{
|
|
2092
|
+
id: optionId(i),
|
|
2093
|
+
type: "button",
|
|
2094
|
+
className: "twc-cmdk__item",
|
|
2095
|
+
role: "option",
|
|
2096
|
+
"aria-selected": i === active,
|
|
2097
|
+
tabIndex: -1,
|
|
2098
|
+
"data-active": i === active || void 0,
|
|
2099
|
+
onMouseEnter: () => setActive(i),
|
|
2100
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
2101
|
+
onClick: () => run(c),
|
|
2102
|
+
children: [
|
|
2103
|
+
c.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-cmdk__item-ic", "aria-hidden": "true", children: c.icon }) : null,
|
|
2104
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "twc-cmdk__item-main", children: [
|
|
2105
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-cmdk__item-label", children: c.label }),
|
|
2106
|
+
c.description ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-cmdk__item-desc", children: c.description }) : null
|
|
2107
|
+
] }),
|
|
2108
|
+
c.shortcut ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-cmdk__item-sc", children: c.shortcut }) : null
|
|
2109
|
+
]
|
|
2110
|
+
},
|
|
2111
|
+
c.id || i
|
|
2112
|
+
);
|
|
2113
|
+
})
|
|
2114
|
+
] }, g.key || "_")) })
|
|
2115
|
+
] })
|
|
2116
|
+
] });
|
|
2165
2117
|
const RD = typeof reactDom.createPortal === "function" ? reactDom.createPortal : null;
|
|
2166
2118
|
return RD ? RD(overlay, document.body) : overlay;
|
|
2167
2119
|
}
|
|
@@ -2240,15 +2192,6 @@ var CUR_CSS = `
|
|
|
2240
2192
|
.twc-cur__el::placeholder { color: var(--color-text-subtle); }
|
|
2241
2193
|
.twc-cur__el::-webkit-outer-spin-button, .twc-cur__el::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
|
|
2242
2194
|
`;
|
|
2243
|
-
function useCurStyles() {
|
|
2244
|
-
React22__default.default.useInsertionEffect(() => {
|
|
2245
|
-
if (document.getElementById("twc-cur-styles")) return;
|
|
2246
|
-
const el = document.createElement("style");
|
|
2247
|
-
el.id = "twc-cur-styles";
|
|
2248
|
-
el.textContent = CUR_CSS;
|
|
2249
|
-
document.head.appendChild(el);
|
|
2250
|
-
}, []);
|
|
2251
|
-
}
|
|
2252
2195
|
function Currency({
|
|
2253
2196
|
label,
|
|
2254
2197
|
hint,
|
|
@@ -2270,16 +2213,16 @@ function Currency({
|
|
|
2270
2213
|
className = "",
|
|
2271
2214
|
...rest
|
|
2272
2215
|
}) {
|
|
2273
|
-
|
|
2216
|
+
const __twcStyles = useScopedStyles("twc-cur-styles", CUR_CSS);
|
|
2274
2217
|
const meta = CURRENCIES[currency] || CURRENCIES.USD;
|
|
2275
2218
|
const prec = precision != null ? precision : meta.precision;
|
|
2276
2219
|
const sym = symbol != null ? symbol : meta.symbol;
|
|
2277
2220
|
const cur = code != null ? code : meta.code;
|
|
2278
|
-
const autoId =
|
|
2221
|
+
const autoId = React23__namespace.default.useId();
|
|
2279
2222
|
const fieldId = id || autoId;
|
|
2280
2223
|
const invalid = Boolean(error);
|
|
2281
2224
|
const controlled = value !== void 0;
|
|
2282
|
-
const [internal, setInternal] =
|
|
2225
|
+
const [internal, setInternal] = React23__namespace.default.useState(() => clampPrecision(String(defaultValue ?? ""), prec));
|
|
2283
2226
|
const shown = controlled ? clampPrecision(String(value ?? ""), prec) : internal;
|
|
2284
2227
|
const describedBy = [error ? `${fieldId}-error` : hint ? `${fieldId}-hint` : null, rest["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
2285
2228
|
function handleChange(e) {
|
|
@@ -2298,6 +2241,7 @@ function Currency({
|
|
|
2298
2241
|
onValueChange?.(Number(fixed), fixed);
|
|
2299
2242
|
}
|
|
2300
2243
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-field ${className}`, children: [
|
|
2244
|
+
__twcStyles,
|
|
2301
2245
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
2302
2246
|
label,
|
|
2303
2247
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -2451,39 +2395,33 @@ function Select({
|
|
|
2451
2395
|
onKeyDown,
|
|
2452
2396
|
...rest
|
|
2453
2397
|
}) {
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
el.textContent = SELECT_CSS;
|
|
2459
|
-
document.head.appendChild(el);
|
|
2460
|
-
}, []);
|
|
2461
|
-
const groups = React22__default.default.useMemo(() => normalizeGroups2(options), [options]);
|
|
2462
|
-
const flat = React22__default.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
2463
|
-
const autoId = React22__default.default.useId();
|
|
2398
|
+
const __twcStyles = useScopedStyles("twc-select-styles", SELECT_CSS);
|
|
2399
|
+
const groups = React23__namespace.default.useMemo(() => normalizeGroups2(options), [options]);
|
|
2400
|
+
const flat = React23__namespace.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
2401
|
+
const autoId = React23__namespace.default.useId();
|
|
2464
2402
|
const fieldId = id || autoId;
|
|
2465
|
-
const [internal, setInternal] =
|
|
2403
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultValue);
|
|
2466
2404
|
const current = value !== void 0 ? value : internal;
|
|
2467
|
-
const [open, setOpen] =
|
|
2468
|
-
const [render, setRender] =
|
|
2469
|
-
const [active, setActive] =
|
|
2470
|
-
const [coords, setCoords] =
|
|
2471
|
-
const [query, setQuery] =
|
|
2472
|
-
const wrapRef =
|
|
2473
|
-
const triggerRef =
|
|
2474
|
-
const popRef =
|
|
2475
|
-
const listRef =
|
|
2476
|
-
const activeRef =
|
|
2477
|
-
const searchRef =
|
|
2405
|
+
const [open, setOpen] = React23__namespace.default.useState(false);
|
|
2406
|
+
const [render, setRender] = React23__namespace.default.useState(false);
|
|
2407
|
+
const [active, setActive] = React23__namespace.default.useState(0);
|
|
2408
|
+
const [coords, setCoords] = React23__namespace.default.useState(null);
|
|
2409
|
+
const [query, setQuery] = React23__namespace.default.useState("");
|
|
2410
|
+
const wrapRef = React23__namespace.default.useRef(null);
|
|
2411
|
+
const triggerRef = React23__namespace.default.useRef(null);
|
|
2412
|
+
const popRef = React23__namespace.default.useRef(null);
|
|
2413
|
+
const listRef = React23__namespace.default.useRef(null);
|
|
2414
|
+
const activeRef = React23__namespace.default.useRef(null);
|
|
2415
|
+
const searchRef = React23__namespace.default.useRef(null);
|
|
2478
2416
|
const showSearch = searchable === void 0 ? flat.length > 5 : searchable;
|
|
2479
|
-
const fGroups =
|
|
2417
|
+
const fGroups = React23__namespace.default.useMemo(() => {
|
|
2480
2418
|
const q = query.trim().toLowerCase();
|
|
2481
2419
|
if (!q) return groups;
|
|
2482
2420
|
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);
|
|
2483
2421
|
}, [groups, query]);
|
|
2484
|
-
const visible =
|
|
2422
|
+
const visible = React23__namespace.default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
2485
2423
|
const selected = flat.find((o) => o.value === current);
|
|
2486
|
-
const place =
|
|
2424
|
+
const place = React23__namespace.default.useCallback(() => {
|
|
2487
2425
|
const el = triggerRef.current;
|
|
2488
2426
|
if (!el) return;
|
|
2489
2427
|
const r = el.getBoundingClientRect();
|
|
@@ -2498,7 +2436,7 @@ function Select({
|
|
|
2498
2436
|
flip
|
|
2499
2437
|
});
|
|
2500
2438
|
}, [placement, minWidth]);
|
|
2501
|
-
|
|
2439
|
+
React23__namespace.default.useEffect(() => {
|
|
2502
2440
|
if (!open || !portal) return;
|
|
2503
2441
|
place();
|
|
2504
2442
|
const onMove = () => place();
|
|
@@ -2509,7 +2447,7 @@ function Select({
|
|
|
2509
2447
|
window.removeEventListener("resize", onMove);
|
|
2510
2448
|
};
|
|
2511
2449
|
}, [open, portal, place]);
|
|
2512
|
-
|
|
2450
|
+
React23__namespace.default.useEffect(() => {
|
|
2513
2451
|
if (!open) return;
|
|
2514
2452
|
const idx = flat.findIndex((o) => o.value === current);
|
|
2515
2453
|
setActive(idx >= 0 ? idx : 0);
|
|
@@ -2525,13 +2463,13 @@ function Select({
|
|
|
2525
2463
|
document.addEventListener("mousedown", onDown);
|
|
2526
2464
|
return () => document.removeEventListener("mousedown", onDown);
|
|
2527
2465
|
}, [open]);
|
|
2528
|
-
|
|
2466
|
+
React23__namespace.default.useEffect(() => {
|
|
2529
2467
|
setActive(0);
|
|
2530
2468
|
}, [query]);
|
|
2531
|
-
|
|
2469
|
+
React23__namespace.default.useEffect(() => {
|
|
2532
2470
|
if (open) ensureVisible2(listRef.current, activeRef.current);
|
|
2533
2471
|
}, [active, open]);
|
|
2534
|
-
|
|
2472
|
+
React23__namespace.default.useEffect(() => {
|
|
2535
2473
|
if (open) {
|
|
2536
2474
|
setRender(true);
|
|
2537
2475
|
return;
|
|
@@ -2539,8 +2477,8 @@ function Select({
|
|
|
2539
2477
|
const t = setTimeout(() => setRender(false), 170);
|
|
2540
2478
|
return () => clearTimeout(t);
|
|
2541
2479
|
}, [open]);
|
|
2542
|
-
const prevOpen =
|
|
2543
|
-
|
|
2480
|
+
const prevOpen = React23__namespace.default.useRef(false);
|
|
2481
|
+
React23__namespace.default.useEffect(() => {
|
|
2544
2482
|
if (prevOpen.current && !open) {
|
|
2545
2483
|
const ae = typeof document !== "undefined" ? document.activeElement : null;
|
|
2546
2484
|
if (popRef.current && ae && popRef.current.contains(ae)) triggerRef.current?.focus();
|
|
@@ -2613,7 +2551,7 @@ function Select({
|
|
|
2613
2551
|
}
|
|
2614
2552
|
)
|
|
2615
2553
|
] }) : null,
|
|
2616
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__list", ref: listRef, children: visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2554
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__list", ref: listRef, children: visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React23__namespace.default.Fragment, { children: [
|
|
2617
2555
|
g.group ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
2618
2556
|
g.options.map((o) => {
|
|
2619
2557
|
counter += 1;
|
|
@@ -2672,6 +2610,7 @@ function Select({
|
|
|
2672
2610
|
}
|
|
2673
2611
|
}
|
|
2674
2612
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-field ${className}`, ref: wrapRef, children: [
|
|
2613
|
+
__twcStyles,
|
|
2675
2614
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
2676
2615
|
label,
|
|
2677
2616
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -2764,15 +2703,6 @@ var CURF_CSS = `
|
|
|
2764
2703
|
.twc-curf__pick .twc-sel__trigger:focus-visible { box-shadow: var(--ring); }
|
|
2765
2704
|
.twc-curf__pick .twc-sel__value { font-weight: var(--font-semibold); color: var(--color-text-muted); }
|
|
2766
2705
|
`;
|
|
2767
|
-
function useCurfStyles() {
|
|
2768
|
-
React22__default.default.useInsertionEffect(() => {
|
|
2769
|
-
if (document.getElementById("twc-curf-styles")) return;
|
|
2770
|
-
const el = document.createElement("style");
|
|
2771
|
-
el.id = "twc-curf-styles";
|
|
2772
|
-
el.textContent = CURF_CSS;
|
|
2773
|
-
document.head.appendChild(el);
|
|
2774
|
-
}, []);
|
|
2775
|
-
}
|
|
2776
2706
|
function CurrencyField({
|
|
2777
2707
|
label,
|
|
2778
2708
|
hint,
|
|
@@ -2794,20 +2724,20 @@ function CurrencyField({
|
|
|
2794
2724
|
className = "",
|
|
2795
2725
|
...rest
|
|
2796
2726
|
}) {
|
|
2797
|
-
|
|
2798
|
-
const autoId =
|
|
2727
|
+
const __twcStyles = useScopedStyles("twc-curf-styles", CURF_CSS);
|
|
2728
|
+
const autoId = React23__namespace.default.useId();
|
|
2799
2729
|
const fieldId = id || autoId;
|
|
2800
2730
|
const invalid = Boolean(error);
|
|
2801
2731
|
const curControlled = currency !== void 0;
|
|
2802
|
-
const [curInternal, setCurInternal] =
|
|
2732
|
+
const [curInternal, setCurInternal] = React23__namespace.default.useState(defaultCurrency);
|
|
2803
2733
|
const cur = curControlled ? currency : curInternal;
|
|
2804
2734
|
const meta = CURRENCIES[cur] || CURRENCIES.USD;
|
|
2805
2735
|
const prec = meta.precision;
|
|
2806
2736
|
const valControlled = value !== void 0;
|
|
2807
|
-
const [valInternal, setValInternal] =
|
|
2737
|
+
const [valInternal, setValInternal] = React23__namespace.default.useState(() => clampPrecision(String(defaultValue ?? ""), prec));
|
|
2808
2738
|
const shown = valControlled ? clampPrecision(String(value ?? ""), prec) : valInternal;
|
|
2809
2739
|
const describedBy = [error ? `${fieldId}-error` : hint ? `${fieldId}-hint` : null, rest["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
2810
|
-
const options =
|
|
2740
|
+
const options = React23__namespace.default.useMemo(() => {
|
|
2811
2741
|
if (!currencies) return CURRENCY_OPTIONS;
|
|
2812
2742
|
return currencies.map((c) => typeof c === "string" ? { value: c, label: `${c} \u2014 ${(CURRENCIES[c] || {}).label || c}` } : c);
|
|
2813
2743
|
}, [currencies]);
|
|
@@ -2834,6 +2764,7 @@ function CurrencyField({
|
|
|
2834
2764
|
onValueChange?.(Number(fixed), fixed, cur);
|
|
2835
2765
|
}
|
|
2836
2766
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-field ${className}`, children: [
|
|
2767
|
+
__twcStyles,
|
|
2837
2768
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
2838
2769
|
label,
|
|
2839
2770
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -2925,15 +2856,6 @@ var FIELD_CSS2 = `
|
|
|
2925
2856
|
.twc-input__reveal:focus-visible { outline: none; box-shadow: var(--ring); }
|
|
2926
2857
|
.twc-input__reveal svg { width: 17px; height: 17px; }
|
|
2927
2858
|
`;
|
|
2928
|
-
function useFieldStyles() {
|
|
2929
|
-
React22__default.default.useInsertionEffect(() => {
|
|
2930
|
-
if (document.getElementById("twc-field-styles")) return;
|
|
2931
|
-
const el = document.createElement("style");
|
|
2932
|
-
el.id = "twc-field-styles";
|
|
2933
|
-
el.textContent = FIELD_CSS2;
|
|
2934
|
-
document.head.appendChild(el);
|
|
2935
|
-
}, []);
|
|
2936
|
-
}
|
|
2937
2859
|
function Input({
|
|
2938
2860
|
label,
|
|
2939
2861
|
hint,
|
|
@@ -2949,13 +2871,13 @@ function Input({
|
|
|
2949
2871
|
className = "",
|
|
2950
2872
|
...rest
|
|
2951
2873
|
}) {
|
|
2952
|
-
|
|
2953
|
-
const autoId =
|
|
2874
|
+
const __twcStyles = useScopedStyles("twc-field-styles", FIELD_CSS2);
|
|
2875
|
+
const autoId = React23__namespace.default.useId();
|
|
2954
2876
|
const fieldId = id || autoId;
|
|
2955
2877
|
const descId = `${fieldId}-desc`;
|
|
2956
2878
|
const invalid = Boolean(error);
|
|
2957
2879
|
const isPassword = type === "password";
|
|
2958
|
-
const [revealed, setRevealed] =
|
|
2880
|
+
const [revealed, setRevealed] = React23__namespace.default.useState(false);
|
|
2959
2881
|
const effectiveType = isPassword && revealed ? "text" : type;
|
|
2960
2882
|
const suffix = rightIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-input__affix", children: rightIcon }) : isPassword ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2961
2883
|
"button",
|
|
@@ -2979,6 +2901,7 @@ function Input({
|
|
|
2979
2901
|
}
|
|
2980
2902
|
) : null;
|
|
2981
2903
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-field ${className}`, children: [
|
|
2904
|
+
__twcStyles,
|
|
2982
2905
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
2983
2906
|
label,
|
|
2984
2907
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -3134,35 +3057,29 @@ function MultiSelect({
|
|
|
3134
3057
|
onKeyDown,
|
|
3135
3058
|
...rest
|
|
3136
3059
|
}) {
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
el.textContent = MULTI_CSS;
|
|
3142
|
-
document.head.appendChild(el);
|
|
3143
|
-
}, []);
|
|
3144
|
-
const groups = React22__default.default.useMemo(() => normalizeGroups3(options), [options]);
|
|
3145
|
-
const flat = React22__default.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
3146
|
-
const autoId = React22__default.default.useId();
|
|
3060
|
+
const __twcStyles = useScopedStyles("twc-ms-styles", MULTI_CSS);
|
|
3061
|
+
const groups = React23__namespace.default.useMemo(() => normalizeGroups3(options), [options]);
|
|
3062
|
+
const flat = React23__namespace.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
3063
|
+
const autoId = React23__namespace.default.useId();
|
|
3147
3064
|
const fieldId = id || autoId;
|
|
3148
|
-
const [internal, setInternal] =
|
|
3065
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultValue);
|
|
3149
3066
|
const selected = value !== void 0 ? value : internal;
|
|
3150
|
-
const [open, setOpen] =
|
|
3151
|
-
const [query, setQuery] =
|
|
3152
|
-
const [active, setActive] =
|
|
3153
|
-
const [coords, setCoords] =
|
|
3154
|
-
const wrapRef =
|
|
3155
|
-
const controlRef =
|
|
3156
|
-
const inputRef =
|
|
3157
|
-
const popRef =
|
|
3158
|
-
const listRef =
|
|
3159
|
-
const activeRef =
|
|
3160
|
-
const fGroups =
|
|
3067
|
+
const [open, setOpen] = React23__namespace.default.useState(false);
|
|
3068
|
+
const [query, setQuery] = React23__namespace.default.useState("");
|
|
3069
|
+
const [active, setActive] = React23__namespace.default.useState(0);
|
|
3070
|
+
const [coords, setCoords] = React23__namespace.default.useState(null);
|
|
3071
|
+
const wrapRef = React23__namespace.default.useRef(null);
|
|
3072
|
+
const controlRef = React23__namespace.default.useRef(null);
|
|
3073
|
+
const inputRef = React23__namespace.default.useRef(null);
|
|
3074
|
+
const popRef = React23__namespace.default.useRef(null);
|
|
3075
|
+
const listRef = React23__namespace.default.useRef(null);
|
|
3076
|
+
const activeRef = React23__namespace.default.useRef(null);
|
|
3077
|
+
const fGroups = React23__namespace.default.useMemo(
|
|
3161
3078
|
() => groups.map((g) => ({ group: g.group, options: g.options.filter((o) => matches2(o, query.trim())) })).filter((g) => g.options.length),
|
|
3162
3079
|
[groups, query]
|
|
3163
3080
|
);
|
|
3164
|
-
const visible =
|
|
3165
|
-
const place =
|
|
3081
|
+
const visible = React23__namespace.default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
3082
|
+
const place = React23__namespace.default.useCallback(() => {
|
|
3166
3083
|
const el = controlRef.current;
|
|
3167
3084
|
if (!el) return;
|
|
3168
3085
|
const r = el.getBoundingClientRect();
|
|
@@ -3177,7 +3094,7 @@ function MultiSelect({
|
|
|
3177
3094
|
flip
|
|
3178
3095
|
});
|
|
3179
3096
|
}, [placement, minWidth]);
|
|
3180
|
-
|
|
3097
|
+
React23__namespace.default.useEffect(() => {
|
|
3181
3098
|
if (!open || !portal) return;
|
|
3182
3099
|
place();
|
|
3183
3100
|
const onMove = () => place();
|
|
@@ -3188,7 +3105,7 @@ function MultiSelect({
|
|
|
3188
3105
|
window.removeEventListener("resize", onMove);
|
|
3189
3106
|
};
|
|
3190
3107
|
}, [open, portal, place]);
|
|
3191
|
-
|
|
3108
|
+
React23__namespace.default.useEffect(() => {
|
|
3192
3109
|
if (!open) return;
|
|
3193
3110
|
const onDown = (e) => {
|
|
3194
3111
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -3199,10 +3116,10 @@ function MultiSelect({
|
|
|
3199
3116
|
document.addEventListener("mousedown", onDown);
|
|
3200
3117
|
return () => document.removeEventListener("mousedown", onDown);
|
|
3201
3118
|
}, [open]);
|
|
3202
|
-
|
|
3119
|
+
React23__namespace.default.useEffect(() => {
|
|
3203
3120
|
setActive(0);
|
|
3204
3121
|
}, [query]);
|
|
3205
|
-
|
|
3122
|
+
React23__namespace.default.useEffect(() => {
|
|
3206
3123
|
if (open) ensureVisible3(listRef.current, activeRef.current);
|
|
3207
3124
|
}, [active, open]);
|
|
3208
3125
|
function commit(next) {
|
|
@@ -3239,7 +3156,7 @@ function MultiSelect({
|
|
|
3239
3156
|
const descId = `${fieldId}-desc`;
|
|
3240
3157
|
const describedBy = error || hint ? descId : void 0;
|
|
3241
3158
|
let counter = -1;
|
|
3242
|
-
const popInner = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__list", id: listboxId, ref: listRef, role: "listbox", "aria-multiselectable": "true", children: visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3159
|
+
const popInner = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__list", id: listboxId, ref: listRef, role: "listbox", "aria-multiselectable": "true", children: visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: "No results found" }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React23__namespace.default.Fragment, { children: [
|
|
3243
3160
|
g.group ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
3244
3161
|
g.options.map((o) => {
|
|
3245
3162
|
counter += 1;
|
|
@@ -3294,6 +3211,7 @@ function MultiSelect({
|
|
|
3294
3211
|
}
|
|
3295
3212
|
}
|
|
3296
3213
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-field ${className}`, ref: wrapRef, children: [
|
|
3214
|
+
__twcStyles,
|
|
3297
3215
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
3298
3216
|
label,
|
|
3299
3217
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -3451,14 +3369,8 @@ function Pagination({
|
|
|
3451
3369
|
...rest
|
|
3452
3370
|
}) {
|
|
3453
3371
|
const jumperEnabled = showPageJumper ?? showJumper;
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
const el = document.createElement("style");
|
|
3457
|
-
el.id = "twc-pagination-styles";
|
|
3458
|
-
el.textContent = PAGINATION_CSS;
|
|
3459
|
-
document.head.appendChild(el);
|
|
3460
|
-
}, []);
|
|
3461
|
-
const [internal, setInternal] = React22__default.default.useState(defaultPage);
|
|
3372
|
+
const __twcStyles = useScopedStyles("twc-pagination-styles", PAGINATION_CSS);
|
|
3373
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultPage);
|
|
3462
3374
|
const page = pageProp !== void 0 ? pageProp : internal;
|
|
3463
3375
|
const pages = buildPages(page, total, siblings, boundaries);
|
|
3464
3376
|
const go = (p) => {
|
|
@@ -3466,13 +3378,14 @@ function Pagination({
|
|
|
3466
3378
|
if (pageProp === void 0) setInternal(p);
|
|
3467
3379
|
onChange?.(p);
|
|
3468
3380
|
};
|
|
3469
|
-
const [jump, setJump] =
|
|
3381
|
+
const [jump, setJump] = React23__namespace.default.useState("");
|
|
3470
3382
|
const submitJump = () => {
|
|
3471
3383
|
const n = parseInt(jump, 10);
|
|
3472
3384
|
if (!Number.isNaN(n)) go(Math.min(Math.max(n, 1), total));
|
|
3473
3385
|
setJump("");
|
|
3474
3386
|
};
|
|
3475
3387
|
return /* @__PURE__ */ jsxRuntime.jsxs("nav", { className: `twc-pagination ${className}`, "aria-label": "Pagination", ...rest, children: [
|
|
3388
|
+
__twcStyles,
|
|
3476
3389
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-page", "data-size": size, onClick: () => go(page - 1), disabled: page <= 1, "aria-label": "Previous page", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m15 18-6-6 6-6" }) }) }),
|
|
3477
3390
|
pages.map(
|
|
3478
3391
|
(p, i) => p === "\u2026" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-page twc-page__ellipsis", "aria-hidden": "true", children: "\u2026" }, `e${i}`) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4075,9 +3988,9 @@ function runDatatableQuery(rows, query, options = {}) {
|
|
|
4075
3988
|
return { rows: page, total, filtered: out };
|
|
4076
3989
|
}
|
|
4077
3990
|
function useFloating() {
|
|
4078
|
-
const [pos, setPos] =
|
|
4079
|
-
const cfg =
|
|
4080
|
-
const place =
|
|
3991
|
+
const [pos, setPos] = React23__namespace.default.useState(null);
|
|
3992
|
+
const cfg = React23__namespace.default.useRef(null);
|
|
3993
|
+
const place = React23__namespace.default.useCallback(() => {
|
|
4081
3994
|
const c = cfg.current;
|
|
4082
3995
|
if (!c || !c.el || !c.el.isConnected) return null;
|
|
4083
3996
|
const r = c.el.getBoundingClientRect();
|
|
@@ -4088,17 +4001,17 @@ function useFloating() {
|
|
|
4088
4001
|
const top = r.bottom + 6;
|
|
4089
4002
|
return { top, left, width: c.width, anchorX: r.left + r.width / 2, maxHeight: Math.max(180, vh - top - M) };
|
|
4090
4003
|
}, []);
|
|
4091
|
-
const open =
|
|
4004
|
+
const open = React23__namespace.default.useCallback((el, align = "left", width = 220) => {
|
|
4092
4005
|
cfg.current = { el, align, width };
|
|
4093
4006
|
const p = place();
|
|
4094
4007
|
if (p) setPos(p);
|
|
4095
4008
|
}, [place]);
|
|
4096
|
-
const close =
|
|
4009
|
+
const close = React23__namespace.default.useCallback(() => {
|
|
4097
4010
|
cfg.current = null;
|
|
4098
4011
|
setPos(null);
|
|
4099
4012
|
}, []);
|
|
4100
4013
|
const isOpen = pos != null;
|
|
4101
|
-
|
|
4014
|
+
React23__namespace.default.useEffect(() => {
|
|
4102
4015
|
if (!isOpen) return void 0;
|
|
4103
4016
|
const update = () => {
|
|
4104
4017
|
const p = place();
|
|
@@ -4122,9 +4035,9 @@ function Caret({ pos }) {
|
|
|
4122
4035
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-dt__caret", style: { left } });
|
|
4123
4036
|
}
|
|
4124
4037
|
function EditCell({ col, value, options, onChange, onCommit, onCommitValue, onCancel, onKeyDown }) {
|
|
4125
|
-
const ref =
|
|
4038
|
+
const ref = React23__namespace.default.useRef(null);
|
|
4126
4039
|
const isSelect = col.editType === "select" || options && col.editType !== "text";
|
|
4127
|
-
|
|
4040
|
+
React23__namespace.default.useEffect(() => {
|
|
4128
4041
|
if (isSelect) {
|
|
4129
4042
|
const t = setTimeout(() => ref.current?.querySelector(".twc-sel__trigger")?.click(), 0);
|
|
4130
4043
|
return () => clearTimeout(t);
|
|
@@ -4324,14 +4237,8 @@ function Datatable({
|
|
|
4324
4237
|
className = "",
|
|
4325
4238
|
...rest
|
|
4326
4239
|
}) {
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
const el = document.createElement("style");
|
|
4330
|
-
el.id = "twc-dt-styles";
|
|
4331
|
-
el.textContent = DT_CSS;
|
|
4332
|
-
document.head.appendChild(el);
|
|
4333
|
-
}, []);
|
|
4334
|
-
const cols = React22__default.default.useMemo(() => {
|
|
4240
|
+
const __twcStyles = useScopedStyles("twc-dt-styles", DT_CSS);
|
|
4241
|
+
const cols = React23__namespace.default.useMemo(() => {
|
|
4335
4242
|
const out = columns.map((c) => {
|
|
4336
4243
|
const isActions = c.type === "actions";
|
|
4337
4244
|
return {
|
|
@@ -4366,7 +4273,7 @@ function Datatable({
|
|
|
4366
4273
|
}
|
|
4367
4274
|
return out;
|
|
4368
4275
|
}, [columns, rowPinning]);
|
|
4369
|
-
const _autoKey =
|
|
4276
|
+
const _autoKey = React23__namespace.default.useRef();
|
|
4370
4277
|
if (!_autoKey.current) _autoKey.current = { map: /* @__PURE__ */ new WeakMap(), n: 0 };
|
|
4371
4278
|
const keyOf = rowKey || ((r, i) => {
|
|
4372
4279
|
if (r != null && r.id != null) return r.id;
|
|
@@ -4381,17 +4288,17 @@ function Datatable({
|
|
|
4381
4288
|
}
|
|
4382
4289
|
return i;
|
|
4383
4290
|
});
|
|
4384
|
-
const [sort, setSort] =
|
|
4385
|
-
const [filters, setFilters] =
|
|
4386
|
-
const [hidden, setHidden] =
|
|
4387
|
-
const [showRowNum, setShowRowNum] =
|
|
4388
|
-
const [wrapped, setWrapped] =
|
|
4291
|
+
const [sort, setSort] = React23__namespace.default.useState(null);
|
|
4292
|
+
const [filters, setFilters] = React23__namespace.default.useState([]);
|
|
4293
|
+
const [hidden, setHidden] = React23__namespace.default.useState(() => /* @__PURE__ */ new Set());
|
|
4294
|
+
const [showRowNum, setShowRowNum] = React23__namespace.default.useState(rowNumbers);
|
|
4295
|
+
const [wrapped, setWrapped] = React23__namespace.default.useState(() => new Set((columns || []).filter((c) => c.wrapText).map((c) => c.field)));
|
|
4389
4296
|
const toggleWrap = (field) => setWrapped((w) => {
|
|
4390
4297
|
const n = new Set(w);
|
|
4391
4298
|
n.has(field) ? n.delete(field) : n.add(field);
|
|
4392
4299
|
return n;
|
|
4393
4300
|
});
|
|
4394
|
-
const [pins, setPins] =
|
|
4301
|
+
const [pins, setPins] = React23__namespace.default.useState(() => {
|
|
4395
4302
|
const left = [], right = [];
|
|
4396
4303
|
columns.forEach((c) => {
|
|
4397
4304
|
if (c.pinned === "left") left.push(c.field);
|
|
@@ -4399,34 +4306,34 @@ function Datatable({
|
|
|
4399
4306
|
});
|
|
4400
4307
|
return { left, right };
|
|
4401
4308
|
});
|
|
4402
|
-
const [density, setDensity] =
|
|
4403
|
-
const [quick, setQuick] =
|
|
4404
|
-
const [selected, setSelected] =
|
|
4405
|
-
const [activeRow, setActiveRow] =
|
|
4406
|
-
const [activeCell, setActiveCell] =
|
|
4407
|
-
const [page, setPage] =
|
|
4408
|
-
const [rowsPerPage, setRowsPerPage] =
|
|
4409
|
-
const [colQuery, setColQuery] =
|
|
4410
|
-
const [widths, setWidths] =
|
|
4411
|
-
const [order, setOrder] =
|
|
4412
|
-
const [drag, setDrag] =
|
|
4413
|
-
const [aggOn, setAggOn] =
|
|
4414
|
-
const [focus, setFocus] =
|
|
4415
|
-
const gridRef =
|
|
4416
|
-
const [groupBy, setGroupBy] =
|
|
4417
|
-
const [collapsed, setCollapsed] =
|
|
4418
|
-
const [pinnedRows, setPinnedRows] =
|
|
4419
|
-
const [headH, setHeadH] =
|
|
4420
|
-
const theadRef =
|
|
4421
|
-
const [rowOrder, setRowOrder] =
|
|
4422
|
-
const [rowHeights, setRowHeights] =
|
|
4423
|
-
const [rowDrag, setRowDrag] =
|
|
4424
|
-
const [rowGrab, setRowGrab] =
|
|
4425
|
-
const [reorderMsg, setReorderMsg] =
|
|
4426
|
-
const rowFocusRef =
|
|
4427
|
-
const rootRef =
|
|
4428
|
-
const [compact, setCompact] =
|
|
4429
|
-
|
|
4309
|
+
const [density, setDensity] = React23__namespace.default.useState(densityProp);
|
|
4310
|
+
const [quick, setQuick] = React23__namespace.default.useState("");
|
|
4311
|
+
const [selected, setSelected] = React23__namespace.default.useState(() => /* @__PURE__ */ new Set());
|
|
4312
|
+
const [activeRow, setActiveRow] = React23__namespace.default.useState(null);
|
|
4313
|
+
const [activeCell, setActiveCell] = React23__namespace.default.useState(null);
|
|
4314
|
+
const [page, setPage] = React23__namespace.default.useState(0);
|
|
4315
|
+
const [rowsPerPage, setRowsPerPage] = React23__namespace.default.useState(pageSize > 0 ? pageSize : 10);
|
|
4316
|
+
const [colQuery, setColQuery] = React23__namespace.default.useState("");
|
|
4317
|
+
const [widths, setWidths] = React23__namespace.default.useState({});
|
|
4318
|
+
const [order, setOrder] = React23__namespace.default.useState(() => columns.map((c) => c.field));
|
|
4319
|
+
const [drag, setDrag] = React23__namespace.default.useState({ from: null, over: null, after: false });
|
|
4320
|
+
const [aggOn, setAggOn] = React23__namespace.default.useState(showAggregation);
|
|
4321
|
+
const [focus, setFocus] = React23__namespace.default.useState({ r: 0, c: 0 });
|
|
4322
|
+
const gridRef = React23__namespace.default.useRef(null);
|
|
4323
|
+
const [groupBy, setGroupBy] = React23__namespace.default.useState(rowGrouping || []);
|
|
4324
|
+
const [collapsed, setCollapsed] = React23__namespace.default.useState(() => /* @__PURE__ */ new Set());
|
|
4325
|
+
const [pinnedRows, setPinnedRows] = React23__namespace.default.useState({ top: [], bottom: [] });
|
|
4326
|
+
const [headH, setHeadH] = React23__namespace.default.useState(41);
|
|
4327
|
+
const theadRef = React23__namespace.default.useRef(null);
|
|
4328
|
+
const [rowOrder, setRowOrder] = React23__namespace.default.useState(null);
|
|
4329
|
+
const [rowHeights, setRowHeights] = React23__namespace.default.useState({});
|
|
4330
|
+
const [rowDrag, setRowDrag] = React23__namespace.default.useState({ from: null, over: null, after: false });
|
|
4331
|
+
const [rowGrab, setRowGrab] = React23__namespace.default.useState(null);
|
|
4332
|
+
const [reorderMsg, setReorderMsg] = React23__namespace.default.useState("");
|
|
4333
|
+
const rowFocusRef = React23__namespace.default.useRef(null);
|
|
4334
|
+
const rootRef = React23__namespace.default.useRef(null);
|
|
4335
|
+
const [compact, setCompact] = React23__namespace.default.useState(false);
|
|
4336
|
+
React23__namespace.default.useEffect(() => {
|
|
4430
4337
|
const el = rootRef.current;
|
|
4431
4338
|
if (!el) return void 0;
|
|
4432
4339
|
const measure = () => setCompact((el.clientWidth || 0) < 720);
|
|
@@ -4439,11 +4346,11 @@ function Datatable({
|
|
|
4439
4346
|
else if (typeof window !== "undefined") window.removeEventListener("resize", measure);
|
|
4440
4347
|
};
|
|
4441
4348
|
}, []);
|
|
4442
|
-
const scrollRef =
|
|
4443
|
-
const [scrollTop, setScrollTop] =
|
|
4444
|
-
const [viewportH, setViewportH] =
|
|
4445
|
-
const [pivotOn, setPivotOn] =
|
|
4446
|
-
const [aggConfig, setAggConfig] =
|
|
4349
|
+
const scrollRef = React23__namespace.default.useRef(null);
|
|
4350
|
+
const [scrollTop, setScrollTop] = React23__namespace.default.useState(0);
|
|
4351
|
+
const [viewportH, setViewportH] = React23__namespace.default.useState(0);
|
|
4352
|
+
const [pivotOn, setPivotOn] = React23__namespace.default.useState(pivotMode);
|
|
4353
|
+
const [aggConfig, setAggConfig] = React23__namespace.default.useState(() => {
|
|
4447
4354
|
const m = {};
|
|
4448
4355
|
(columns || []).forEach((c) => {
|
|
4449
4356
|
if (typeof c.aggregation === "string") m[c.field] = c.aggregation;
|
|
@@ -4451,13 +4358,13 @@ function Datatable({
|
|
|
4451
4358
|
return m;
|
|
4452
4359
|
});
|
|
4453
4360
|
const aggOf = (c) => aggConfig[c.field] || (typeof c.aggregation === "function" ? c.aggregation : null);
|
|
4454
|
-
const [pivotConfig, setPivotConfig] =
|
|
4361
|
+
const [pivotConfig, setPivotConfig] = React23__namespace.default.useState(() => ({
|
|
4455
4362
|
rows: pivot && pivot.rows || [],
|
|
4456
4363
|
columns: pivot && pivot.columns || [],
|
|
4457
4364
|
values: pivot && pivot.values || []
|
|
4458
4365
|
}));
|
|
4459
4366
|
const pivotActive = pivotOn && pivotConfig.rows.length > 0 && pivotConfig.values.length > 0;
|
|
4460
|
-
|
|
4367
|
+
React23__namespace.default.useEffect(() => {
|
|
4461
4368
|
setOrder((prev) => {
|
|
4462
4369
|
const fields = columns.map((c) => c.field);
|
|
4463
4370
|
const kept = prev.filter((f) => fields.includes(f));
|
|
@@ -4465,32 +4372,32 @@ function Datatable({
|
|
|
4465
4372
|
return [...kept, ...added];
|
|
4466
4373
|
});
|
|
4467
4374
|
}, [columns]);
|
|
4468
|
-
|
|
4375
|
+
React23__namespace.default.useEffect(() => {
|
|
4469
4376
|
setDensity(densityProp);
|
|
4470
4377
|
}, [densityProp]);
|
|
4471
|
-
|
|
4378
|
+
React23__namespace.default.useEffect(() => {
|
|
4472
4379
|
setAggOn(showAggregation);
|
|
4473
4380
|
}, [showAggregation]);
|
|
4474
4381
|
const rowGroupingKey = (rowGrouping || []).join("\0");
|
|
4475
|
-
const rowGroupingKeyRef =
|
|
4476
|
-
|
|
4382
|
+
const rowGroupingKeyRef = React23__namespace.default.useRef(rowGroupingKey);
|
|
4383
|
+
React23__namespace.default.useEffect(() => {
|
|
4477
4384
|
if (rowGroupingKeyRef.current === rowGroupingKey) return;
|
|
4478
4385
|
rowGroupingKeyRef.current = rowGroupingKey;
|
|
4479
4386
|
setGroupBy(rowGrouping || []);
|
|
4480
4387
|
}, [rowGroupingKey]);
|
|
4481
4388
|
const widthOf = (c) => widths[c.field] ?? c.width ?? 160;
|
|
4482
|
-
const [colMenu, setColMenu] =
|
|
4389
|
+
const [colMenu, setColMenu] = React23__namespace.default.useState(null);
|
|
4483
4390
|
const [menuPos, openMenu, closeMenu] = useFloating();
|
|
4484
|
-
const [panel, setPanel] =
|
|
4391
|
+
const [panel, setPanel] = React23__namespace.default.useState(null);
|
|
4485
4392
|
const [panelPos, openPanel, closePanel] = useFloating();
|
|
4486
|
-
const [rowMenu, setRowMenu] =
|
|
4393
|
+
const [rowMenu, setRowMenu] = React23__namespace.default.useState(null);
|
|
4487
4394
|
const [rowMenuPos, openRowMenu, closeRowMenu] = useFloating();
|
|
4488
|
-
const [exportOpen, setExportOpen] =
|
|
4395
|
+
const [exportOpen, setExportOpen] = React23__namespace.default.useState(false);
|
|
4489
4396
|
const [exportPos, openExport, closeExport] = useFloating();
|
|
4490
|
-
const menuTriggerRef =
|
|
4491
|
-
const colMenuRef =
|
|
4492
|
-
const rowMenuRef =
|
|
4493
|
-
const exportMenuRef =
|
|
4397
|
+
const menuTriggerRef = React23__namespace.default.useRef(null);
|
|
4398
|
+
const colMenuRef = React23__namespace.default.useRef(null);
|
|
4399
|
+
const rowMenuRef = React23__namespace.default.useRef(null);
|
|
4400
|
+
const exportMenuRef = React23__namespace.default.useRef(null);
|
|
4494
4401
|
function focusFirstItem(container) {
|
|
4495
4402
|
if (!container) return;
|
|
4496
4403
|
const first = container.querySelector('[role="menuitem"]:not([disabled])');
|
|
@@ -4529,16 +4436,16 @@ function Datatable({
|
|
|
4529
4436
|
restoreTriggerFocus();
|
|
4530
4437
|
}
|
|
4531
4438
|
}
|
|
4532
|
-
|
|
4439
|
+
React23__namespace.default.useEffect(() => {
|
|
4533
4440
|
if (colMenu) focusFirstItem(colMenuRef.current);
|
|
4534
4441
|
}, [colMenu]);
|
|
4535
|
-
|
|
4442
|
+
React23__namespace.default.useEffect(() => {
|
|
4536
4443
|
if (rowMenu) focusFirstItem(rowMenuRef.current);
|
|
4537
4444
|
}, [rowMenu]);
|
|
4538
|
-
|
|
4445
|
+
React23__namespace.default.useEffect(() => {
|
|
4539
4446
|
if (exportOpen) focusFirstItem(exportMenuRef.current);
|
|
4540
4447
|
}, [exportOpen]);
|
|
4541
|
-
|
|
4448
|
+
React23__namespace.default.useEffect(() => {
|
|
4542
4449
|
if (!colMenu && !panel && !rowMenu) return;
|
|
4543
4450
|
const closeAll = () => {
|
|
4544
4451
|
setColMenu(null);
|
|
@@ -4561,7 +4468,7 @@ function Datatable({
|
|
|
4561
4468
|
document.removeEventListener("keydown", onKey);
|
|
4562
4469
|
};
|
|
4563
4470
|
}, [colMenu, panel, rowMenu]);
|
|
4564
|
-
|
|
4471
|
+
React23__namespace.default.useEffect(() => {
|
|
4565
4472
|
if (!exportOpen) return;
|
|
4566
4473
|
const close = () => {
|
|
4567
4474
|
setExportOpen(false);
|
|
@@ -4580,9 +4487,9 @@ function Datatable({
|
|
|
4580
4487
|
document.removeEventListener("keydown", onKey);
|
|
4581
4488
|
};
|
|
4582
4489
|
}, [exportOpen]);
|
|
4583
|
-
const colByField =
|
|
4490
|
+
const colByField = React23__namespace.default.useMemo(() => Object.fromEntries(cols.map((c) => [c.field, c])), [cols]);
|
|
4584
4491
|
const visibleCols = cols.filter((c) => !hidden.has(c.field));
|
|
4585
|
-
const ordered =
|
|
4492
|
+
const ordered = React23__namespace.default.useMemo(() => {
|
|
4586
4493
|
const orderIdx = (f) => {
|
|
4587
4494
|
const i = order.indexOf(f);
|
|
4588
4495
|
return i === -1 ? 9999 : i;
|
|
@@ -4617,7 +4524,7 @@ function Datatable({
|
|
|
4617
4524
|
}
|
|
4618
4525
|
return {};
|
|
4619
4526
|
};
|
|
4620
|
-
const processed =
|
|
4527
|
+
const processed = React23__namespace.default.useMemo(() => {
|
|
4621
4528
|
if (serverMode) {
|
|
4622
4529
|
if (rowOrder) {
|
|
4623
4530
|
const idx = new Map(rowOrder.map((k, i) => [k, i]));
|
|
@@ -4656,10 +4563,10 @@ function Datatable({
|
|
|
4656
4563
|
const totalRows = serverMode ? serverTotal : processed.length;
|
|
4657
4564
|
const totalPages = paginated ? Math.max(1, Math.ceil(totalRows / rowsPerPage)) : 1;
|
|
4658
4565
|
const paged = !paginated || serverMode ? processed : processed.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage);
|
|
4659
|
-
|
|
4566
|
+
React23__namespace.default.useEffect(() => {
|
|
4660
4567
|
if (page > totalPages - 1) setPage(0);
|
|
4661
4568
|
}, [totalPages]);
|
|
4662
|
-
const activeGroupBy =
|
|
4569
|
+
const activeGroupBy = React23__namespace.default.useMemo(() => groupBy.filter((f) => colByField[f]), [groupBy, colByField]);
|
|
4663
4570
|
function subtotalText(rowsIn) {
|
|
4664
4571
|
const parts = [];
|
|
4665
4572
|
for (const c of ordered) {
|
|
@@ -4686,7 +4593,7 @@ function Datatable({
|
|
|
4686
4593
|
if (agg === "max") return Math.max(...nums);
|
|
4687
4594
|
return null;
|
|
4688
4595
|
}
|
|
4689
|
-
const displayItems =
|
|
4596
|
+
const displayItems = React23__namespace.default.useMemo(() => {
|
|
4690
4597
|
if (!activeGroupBy.length) return null;
|
|
4691
4598
|
const build = (rowsIn, depth, prefix) => {
|
|
4692
4599
|
if (depth >= activeGroupBy.length) return rowsIn.map((row) => ({ kind: "leaf", row }));
|
|
@@ -4728,7 +4635,7 @@ function Datatable({
|
|
|
4728
4635
|
return { top, bottom };
|
|
4729
4636
|
});
|
|
4730
4637
|
}
|
|
4731
|
-
|
|
4638
|
+
React23__namespace.default.useEffect(() => {
|
|
4732
4639
|
if (!rowPinning) return;
|
|
4733
4640
|
const measure = () => {
|
|
4734
4641
|
if (theadRef.current) setHeadH(theadRef.current.offsetHeight || 41);
|
|
@@ -4742,12 +4649,12 @@ function Datatable({
|
|
|
4742
4649
|
const pinnedTopRows = canPinRows ? pinnedRows.top.map((k) => leafRows.find((r, i) => keyOf(r, i) === k)).filter(Boolean) : [];
|
|
4743
4650
|
const pinnedBottomRows = canPinRows ? pinnedRows.bottom.map((k) => leafRows.find((r, i) => keyOf(r, i) === k)).filter(Boolean) : [];
|
|
4744
4651
|
const middleRows = canPinRows ? leafRows.filter((r, i) => !pinSideOf(keyOf(r, i))) : leafRows;
|
|
4745
|
-
const keyIndex =
|
|
4652
|
+
const keyIndex = React23__namespace.default.useMemo(() => {
|
|
4746
4653
|
const m = /* @__PURE__ */ new Map();
|
|
4747
4654
|
leafRows.forEach((r, i) => m.set(keyOf(r, i), i));
|
|
4748
4655
|
return m;
|
|
4749
4656
|
}, [leafRows]);
|
|
4750
|
-
const keyIndexMid =
|
|
4657
|
+
const keyIndexMid = React23__namespace.default.useMemo(() => {
|
|
4751
4658
|
const m = /* @__PURE__ */ new Map();
|
|
4752
4659
|
middleRows.forEach((r, i) => m.set(keyOf(r, keyIndex.get(keyOf(r)) ?? i), i));
|
|
4753
4660
|
return m;
|
|
@@ -4832,7 +4739,7 @@ function Datatable({
|
|
|
4832
4739
|
setReorderMsg("Reorder cancelled.");
|
|
4833
4740
|
}
|
|
4834
4741
|
}
|
|
4835
|
-
|
|
4742
|
+
React23__namespace.default.useEffect(() => {
|
|
4836
4743
|
if (rowFocusRef.current == null) return;
|
|
4837
4744
|
const key = rowFocusRef.current;
|
|
4838
4745
|
rowFocusRef.current = null;
|
|
@@ -4844,7 +4751,7 @@ function Datatable({
|
|
|
4844
4751
|
});
|
|
4845
4752
|
const estRowH = rowHeight ?? (density === "compact" ? 36 : density === "comfortable" ? 56 : 44);
|
|
4846
4753
|
const virtualizing = virtualized && !paginated && !activeGroupBy.length && !loading;
|
|
4847
|
-
|
|
4754
|
+
React23__namespace.default.useEffect(() => {
|
|
4848
4755
|
if (!virtualizing) return;
|
|
4849
4756
|
const el = scrollRef.current;
|
|
4850
4757
|
if (!el) return;
|
|
@@ -4854,13 +4761,13 @@ function Datatable({
|
|
|
4854
4761
|
if (ro) ro.observe(el);
|
|
4855
4762
|
return () => ro && ro.disconnect();
|
|
4856
4763
|
}, [virtualizing, height]);
|
|
4857
|
-
const onScrollVirtual =
|
|
4764
|
+
const onScrollVirtual = React23__namespace.default.useCallback((e) => {
|
|
4858
4765
|
setScrollTop(e.currentTarget.scrollTop);
|
|
4859
4766
|
}, []);
|
|
4860
4767
|
const vh = viewportH || (typeof height === "number" ? height : 440);
|
|
4861
|
-
const rowHRef =
|
|
4862
|
-
const [measureTick, setMeasureTick] =
|
|
4863
|
-
const offsets =
|
|
4768
|
+
const rowHRef = React23__namespace.default.useRef(/* @__PURE__ */ new Map());
|
|
4769
|
+
const [measureTick, setMeasureTick] = React23__namespace.default.useState(0);
|
|
4770
|
+
const offsets = React23__namespace.default.useMemo(() => {
|
|
4864
4771
|
if (!virtualizing) return null;
|
|
4865
4772
|
const total = middleRows.length;
|
|
4866
4773
|
const arr = new Float64Array(total + 1);
|
|
@@ -4870,7 +4777,7 @@ function Datatable({
|
|
|
4870
4777
|
}
|
|
4871
4778
|
return arr;
|
|
4872
4779
|
}, [virtualizing, middleRows, estRowH, measureTick]);
|
|
4873
|
-
const vWindow =
|
|
4780
|
+
const vWindow = React23__namespace.default.useMemo(() => {
|
|
4874
4781
|
if (!virtualizing || !offsets) return null;
|
|
4875
4782
|
const total = middleRows.length;
|
|
4876
4783
|
const totalH = offsets[total];
|
|
@@ -4899,7 +4806,7 @@ function Datatable({
|
|
|
4899
4806
|
if (start > end) start = end;
|
|
4900
4807
|
return { start, end, padTop: offsets[start], padBottom: Math.max(0, totalH - offsets[end]) };
|
|
4901
4808
|
}, [virtualizing, offsets, middleRows.length, vh, scrollTop, overscan]);
|
|
4902
|
-
|
|
4809
|
+
React23__namespace.default.useLayoutEffect(() => {
|
|
4903
4810
|
if (!virtualizing) return;
|
|
4904
4811
|
const el = scrollRef.current;
|
|
4905
4812
|
if (!el) return;
|
|
@@ -4914,9 +4821,9 @@ function Datatable({
|
|
|
4914
4821
|
}
|
|
4915
4822
|
if (changed) setMeasureTick((t) => t + 1);
|
|
4916
4823
|
});
|
|
4917
|
-
const onServerChangeRef =
|
|
4824
|
+
const onServerChangeRef = React23__namespace.default.useRef(onServerChange);
|
|
4918
4825
|
onServerChangeRef.current = onServerChange;
|
|
4919
|
-
|
|
4826
|
+
React23__namespace.default.useEffect(() => {
|
|
4920
4827
|
if (!serverMode) return;
|
|
4921
4828
|
const t = setTimeout(() => {
|
|
4922
4829
|
onServerChangeRef.current?.({
|
|
@@ -4951,7 +4858,7 @@ function Datatable({
|
|
|
4951
4858
|
return n;
|
|
4952
4859
|
});
|
|
4953
4860
|
}
|
|
4954
|
-
const movableMidFields =
|
|
4861
|
+
const movableMidFields = React23__namespace.default.useMemo(
|
|
4955
4862
|
() => ordered.filter((c) => !pins.left.includes(c.field) && !pins.right.includes(c.field)).map((c) => c.field),
|
|
4956
4863
|
[ordered, pins]
|
|
4957
4864
|
);
|
|
@@ -4982,7 +4889,7 @@ function Datatable({
|
|
|
4982
4889
|
}
|
|
4983
4890
|
return [...set].sort((a, b) => a.localeCompare(b)).map((v) => ({ value: v, label: v }));
|
|
4984
4891
|
}
|
|
4985
|
-
const [resizing, setResizing] =
|
|
4892
|
+
const [resizing, setResizing] = React23__namespace.default.useState(false);
|
|
4986
4893
|
function startResize(e, field) {
|
|
4987
4894
|
e.preventDefault();
|
|
4988
4895
|
e.stopPropagation();
|
|
@@ -5089,7 +4996,7 @@ function Datatable({
|
|
|
5089
4996
|
if (!agg) return null;
|
|
5090
4997
|
if (aggregationValues && col.field in aggregationValues) {
|
|
5091
4998
|
const pre = aggregationValues[col.field];
|
|
5092
|
-
if (pre && typeof pre === "object" && !
|
|
4999
|
+
if (pre && typeof pre === "object" && !React23__namespace.default.isValidElement(pre)) {
|
|
5093
5000
|
if (typeof agg === "string" && agg in pre) return pre[agg];
|
|
5094
5001
|
} else {
|
|
5095
5002
|
return pre;
|
|
@@ -5207,14 +5114,14 @@ function Datatable({
|
|
|
5207
5114
|
focusCell(r, c);
|
|
5208
5115
|
}
|
|
5209
5116
|
}
|
|
5210
|
-
|
|
5117
|
+
React23__namespace.default.useEffect(() => {
|
|
5211
5118
|
setFocus((f) => ({ r: Math.min(f.r, Math.max(0, leafRows.length - 1)), c: Math.min(f.c, Math.max(0, ordered.length - 1)) }));
|
|
5212
5119
|
}, [leafRows.length, ordered.length, page]);
|
|
5213
|
-
const selectedRows =
|
|
5120
|
+
const selectedRows = React23__namespace.default.useMemo(() => rows.filter((r, i) => selected.has(keyOf(r, i))), [rows, selected]);
|
|
5214
5121
|
function clearSelection() {
|
|
5215
5122
|
setSelected(/* @__PURE__ */ new Set());
|
|
5216
5123
|
}
|
|
5217
|
-
const [editing, setEditing] =
|
|
5124
|
+
const [editing, setEditing] = React23__namespace.default.useState(null);
|
|
5218
5125
|
const isColEditable = (c) => c.type !== "actions" && (c.editable ?? (editMode && c.editable !== false));
|
|
5219
5126
|
function beginEdit(rowK, col, row) {
|
|
5220
5127
|
if (!isColEditable(col)) return;
|
|
@@ -5249,17 +5156,17 @@ function Datatable({
|
|
|
5249
5156
|
cancelEdit();
|
|
5250
5157
|
}
|
|
5251
5158
|
}
|
|
5252
|
-
const batchEditableCols =
|
|
5159
|
+
const batchEditableCols = React23__namespace.default.useMemo(
|
|
5253
5160
|
() => cols.filter((c) => c.type !== "actions" && (c.editable ?? (editMode && c.editable !== false))),
|
|
5254
5161
|
[cols, editMode]
|
|
5255
5162
|
);
|
|
5256
|
-
const [batchEdit, setBatchEdit] =
|
|
5163
|
+
const [batchEdit, setBatchEdit] = React23__namespace.default.useState(null);
|
|
5257
5164
|
const [batchEditPos, openBatchEdit, closeBatchEdit] = useFloating();
|
|
5258
5165
|
function openBatchEditor(el) {
|
|
5259
5166
|
setBatchEdit({ fields: {}, values: {} });
|
|
5260
5167
|
openBatchEdit(el, "left", 320);
|
|
5261
5168
|
}
|
|
5262
|
-
|
|
5169
|
+
React23__namespace.default.useEffect(() => {
|
|
5263
5170
|
if (!batchEdit) return;
|
|
5264
5171
|
const close = () => {
|
|
5265
5172
|
setBatchEdit(null);
|
|
@@ -5278,7 +5185,7 @@ function Datatable({
|
|
|
5278
5185
|
document.removeEventListener("keydown", onKey);
|
|
5279
5186
|
};
|
|
5280
5187
|
}, [batchEdit]);
|
|
5281
|
-
|
|
5188
|
+
React23__namespace.default.useEffect(() => {
|
|
5282
5189
|
if (batchEdit && selected.size === 0) {
|
|
5283
5190
|
setBatchEdit(null);
|
|
5284
5191
|
closeBatchEdit();
|
|
@@ -5315,7 +5222,7 @@ function Datatable({
|
|
|
5315
5222
|
setBatchEdit(null);
|
|
5316
5223
|
closeBatchEdit();
|
|
5317
5224
|
}
|
|
5318
|
-
|
|
5225
|
+
React23__namespace.default.useEffect(() => {
|
|
5319
5226
|
if (!editing) return;
|
|
5320
5227
|
const onDown = (e) => {
|
|
5321
5228
|
if (e.target.closest(".twc-dt__editor-wrap") || e.target.closest(".twc-pop")) return;
|
|
@@ -5671,6 +5578,7 @@ function Datatable({
|
|
|
5671
5578
|
] }) });
|
|
5672
5579
|
}
|
|
5673
5580
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-dt ${className}`, ref: rootRef, "data-density": density, "data-resizing": resizing || void 0, ...rest, children: [
|
|
5581
|
+
__twcStyles,
|
|
5674
5582
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-dt__toolbar", "data-compact": compact || void 0, children: [
|
|
5675
5583
|
batchActions.length && selected.size > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-dt__batch", children: [
|
|
5676
5584
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-dt__batch-x", onClick: clearSelection, "aria-label": "Clear selection", children: /* @__PURE__ */ jsxRuntime.jsx(Svg, { d: I.x }) }),
|
|
@@ -6825,36 +6733,25 @@ function DatePicker({
|
|
|
6825
6733
|
className = "",
|
|
6826
6734
|
...rest
|
|
6827
6735
|
}) {
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
fel.id = "twc-field-styles";
|
|
6832
|
-
fel.textContent = FIELD_CSS3;
|
|
6833
|
-
document.head.appendChild(fel);
|
|
6834
|
-
}
|
|
6835
|
-
if (document.getElementById("twc-datepicker-styles")) return;
|
|
6836
|
-
const el = document.createElement("style");
|
|
6837
|
-
el.id = "twc-datepicker-styles";
|
|
6838
|
-
el.textContent = DATEPICKER_CSS;
|
|
6839
|
-
document.head.appendChild(el);
|
|
6840
|
-
}, []);
|
|
6841
|
-
const autoId = React22__default.default.useId();
|
|
6736
|
+
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS3);
|
|
6737
|
+
const __twcStyles1 = useScopedStyles("twc-datepicker-styles", DATEPICKER_CSS);
|
|
6738
|
+
const autoId = React23__namespace.default.useId();
|
|
6842
6739
|
const fieldId = id || autoId;
|
|
6843
6740
|
const descId = `${fieldId}-desc`;
|
|
6844
6741
|
const invalid = Boolean(error);
|
|
6845
|
-
const [internal, setInternal] =
|
|
6742
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultValue);
|
|
6846
6743
|
const selected = value !== void 0 ? value : internal;
|
|
6847
|
-
const [open, setOpen] =
|
|
6848
|
-
const [view, setView] =
|
|
6849
|
-
const [mode, setMode] =
|
|
6850
|
-
const [focusDate, setFocusDate] =
|
|
6851
|
-
const [coords, setCoords] =
|
|
6852
|
-
const wrapRef =
|
|
6853
|
-
const triggerRef =
|
|
6854
|
-
const popRef =
|
|
6855
|
-
const gridRef =
|
|
6744
|
+
const [open, setOpen] = React23__namespace.default.useState(false);
|
|
6745
|
+
const [view, setView] = React23__namespace.default.useState(selected || /* @__PURE__ */ new Date());
|
|
6746
|
+
const [mode, setMode] = React23__namespace.default.useState("days");
|
|
6747
|
+
const [focusDate, setFocusDate] = React23__namespace.default.useState(null);
|
|
6748
|
+
const [coords, setCoords] = React23__namespace.default.useState(null);
|
|
6749
|
+
const wrapRef = React23__namespace.default.useRef(null);
|
|
6750
|
+
const triggerRef = React23__namespace.default.useRef(null);
|
|
6751
|
+
const popRef = React23__namespace.default.useRef(null);
|
|
6752
|
+
const gridRef = React23__namespace.default.useRef(null);
|
|
6856
6753
|
const POP_W = 280;
|
|
6857
|
-
const place =
|
|
6754
|
+
const place = React23__namespace.default.useCallback(() => {
|
|
6858
6755
|
const el = triggerRef.current;
|
|
6859
6756
|
if (!el) return;
|
|
6860
6757
|
const r = el.getBoundingClientRect();
|
|
@@ -6865,7 +6762,7 @@ function DatePicker({
|
|
|
6865
6762
|
left = Math.max(8, left);
|
|
6866
6763
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
6867
6764
|
}, []);
|
|
6868
|
-
|
|
6765
|
+
React23__namespace.default.useEffect(() => {
|
|
6869
6766
|
if (!open) return void 0;
|
|
6870
6767
|
place();
|
|
6871
6768
|
const onMove = () => place();
|
|
@@ -6876,7 +6773,7 @@ function DatePicker({
|
|
|
6876
6773
|
window.removeEventListener("resize", onMove);
|
|
6877
6774
|
};
|
|
6878
6775
|
}, [open, place]);
|
|
6879
|
-
|
|
6776
|
+
React23__namespace.default.useEffect(() => {
|
|
6880
6777
|
if (!open) return;
|
|
6881
6778
|
setView(selected || /* @__PURE__ */ new Date());
|
|
6882
6779
|
setMode("days");
|
|
@@ -6896,8 +6793,8 @@ function DatePicker({
|
|
|
6896
6793
|
document.removeEventListener("keydown", onKey);
|
|
6897
6794
|
};
|
|
6898
6795
|
}, [open]);
|
|
6899
|
-
const prevOpen =
|
|
6900
|
-
|
|
6796
|
+
const prevOpen = React23__namespace.default.useRef(false);
|
|
6797
|
+
React23__namespace.default.useEffect(() => {
|
|
6901
6798
|
let id2;
|
|
6902
6799
|
if (!prevOpen.current && open) {
|
|
6903
6800
|
id2 = setTimeout(() => gridRef.current?.querySelector('[tabindex="0"]')?.focus({ preventScroll: true }), 30);
|
|
@@ -6908,9 +6805,9 @@ function DatePicker({
|
|
|
6908
6805
|
prevOpen.current = open;
|
|
6909
6806
|
return () => clearTimeout(id2);
|
|
6910
6807
|
}, [open]);
|
|
6911
|
-
const months =
|
|
6912
|
-
const monthsShort =
|
|
6913
|
-
const dows =
|
|
6808
|
+
const months = React23__namespace.default.useMemo(() => locale === void 0 ? MONTHS : monthNames(locale), [locale]);
|
|
6809
|
+
const monthsShort = React23__namespace.default.useMemo(() => locale === void 0 ? MONTHS.map((n) => n.slice(0, 3)) : monthShortNames(locale), [locale]);
|
|
6810
|
+
const dows = React23__namespace.default.useMemo(
|
|
6914
6811
|
() => locale === void 0 ? Array.from({ length: 7 }, (_, i) => DOW[(i + weekStartsOn) % 7]) : weekdayNames(locale, weekStartsOn),
|
|
6915
6812
|
[locale, weekStartsOn]
|
|
6916
6813
|
);
|
|
@@ -6938,7 +6835,7 @@ function DatePicker({
|
|
|
6938
6835
|
};
|
|
6939
6836
|
const cells = Array.from({ length: 42 }, (_, i) => new Date(gridStart.getFullYear(), gridStart.getMonth(), gridStart.getDate() + i));
|
|
6940
6837
|
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);
|
|
6941
|
-
|
|
6838
|
+
React23__namespace.default.useEffect(() => {
|
|
6942
6839
|
if (!open || mode !== "days" || !focusDate) return;
|
|
6943
6840
|
gridRef.current?.querySelector(`[data-key="${keyOf(focusDate)}"]`)?.focus();
|
|
6944
6841
|
}, [focusDate, open, mode]);
|
|
@@ -6969,6 +6866,8 @@ function DatePicker({
|
|
|
6969
6866
|
if (next.getFullYear() !== y || next.getMonth() !== m) setView(new Date(next.getFullYear(), next.getMonth(), 1));
|
|
6970
6867
|
};
|
|
6971
6868
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-dp twc-field ${className}`, ref: wrapRef, ...rest, children: [
|
|
6869
|
+
__twcStyles0,
|
|
6870
|
+
__twcStyles1,
|
|
6972
6871
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "twc-field__label", id: `${fieldId}-label`, children: [
|
|
6973
6872
|
label,
|
|
6974
6873
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -7157,36 +7056,25 @@ function DateRangePicker({
|
|
|
7157
7056
|
className = "",
|
|
7158
7057
|
...rest
|
|
7159
7058
|
}) {
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
fel.id = "twc-field-styles";
|
|
7164
|
-
fel.textContent = FIELD_CSS4;
|
|
7165
|
-
document.head.appendChild(fel);
|
|
7166
|
-
}
|
|
7167
|
-
if (document.getElementById("twc-drp-styles")) return;
|
|
7168
|
-
const el = document.createElement("style");
|
|
7169
|
-
el.id = "twc-drp-styles";
|
|
7170
|
-
el.textContent = RANGE_CSS;
|
|
7171
|
-
document.head.appendChild(el);
|
|
7172
|
-
}, []);
|
|
7173
|
-
const [internal, setInternal] = React22__default.default.useState(defaultValue);
|
|
7059
|
+
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS4);
|
|
7060
|
+
const __twcStyles1 = useScopedStyles("twc-drp-styles", RANGE_CSS);
|
|
7061
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultValue);
|
|
7174
7062
|
const range = value !== void 0 ? value : internal;
|
|
7175
|
-
const [open, setOpen] =
|
|
7176
|
-
const [view, setView] =
|
|
7177
|
-
const [hover, setHover] =
|
|
7178
|
-
const [coords, setCoords] =
|
|
7179
|
-
const wrapRef =
|
|
7180
|
-
const triggerRef =
|
|
7181
|
-
const popRef =
|
|
7182
|
-
const labelId =
|
|
7063
|
+
const [open, setOpen] = React23__namespace.default.useState(false);
|
|
7064
|
+
const [view, setView] = React23__namespace.default.useState(range.start || /* @__PURE__ */ new Date());
|
|
7065
|
+
const [hover, setHover] = React23__namespace.default.useState(null);
|
|
7066
|
+
const [coords, setCoords] = React23__namespace.default.useState(null);
|
|
7067
|
+
const wrapRef = React23__namespace.default.useRef(null);
|
|
7068
|
+
const triggerRef = React23__namespace.default.useRef(null);
|
|
7069
|
+
const popRef = React23__namespace.default.useRef(null);
|
|
7070
|
+
const labelId = React23__namespace.default.useId();
|
|
7183
7071
|
const descId = `${labelId}-desc`;
|
|
7184
7072
|
const invalid = Boolean(error);
|
|
7185
|
-
|
|
7073
|
+
React23__namespace.default.useEffect(() => {
|
|
7186
7074
|
if (disabled) setOpen(false);
|
|
7187
7075
|
}, [disabled]);
|
|
7188
7076
|
const POP_W = 420;
|
|
7189
|
-
const place =
|
|
7077
|
+
const place = React23__namespace.default.useCallback(() => {
|
|
7190
7078
|
const el = triggerRef.current;
|
|
7191
7079
|
if (!el) return;
|
|
7192
7080
|
const r = el.getBoundingClientRect();
|
|
@@ -7197,7 +7085,7 @@ function DateRangePicker({
|
|
|
7197
7085
|
left = Math.max(8, left);
|
|
7198
7086
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
7199
7087
|
}, []);
|
|
7200
|
-
|
|
7088
|
+
React23__namespace.default.useEffect(() => {
|
|
7201
7089
|
if (!open) return void 0;
|
|
7202
7090
|
place();
|
|
7203
7091
|
const onMove = () => place();
|
|
@@ -7208,7 +7096,7 @@ function DateRangePicker({
|
|
|
7208
7096
|
window.removeEventListener("resize", onMove);
|
|
7209
7097
|
};
|
|
7210
7098
|
}, [open, place]);
|
|
7211
|
-
|
|
7099
|
+
React23__namespace.default.useEffect(() => {
|
|
7212
7100
|
if (!open) return;
|
|
7213
7101
|
const onDown = (e) => {
|
|
7214
7102
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -7246,8 +7134,8 @@ function DateRangePicker({
|
|
|
7246
7134
|
setView(start);
|
|
7247
7135
|
setOpen(false);
|
|
7248
7136
|
};
|
|
7249
|
-
const months =
|
|
7250
|
-
const dows =
|
|
7137
|
+
const months = React23__namespace.default.useMemo(() => locale === void 0 ? MONTHS2 : monthNames2(locale), [locale]);
|
|
7138
|
+
const dows = React23__namespace.default.useMemo(
|
|
7251
7139
|
() => locale === void 0 ? Array.from({ length: 7 }, (_, i) => DOW2[(i + weekStartsOn) % 7]) : weekdayNames2(locale, weekStartsOn),
|
|
7252
7140
|
[locale, weekStartsOn]
|
|
7253
7141
|
);
|
|
@@ -7271,6 +7159,8 @@ function DateRangePicker({
|
|
|
7271
7159
|
};
|
|
7272
7160
|
const text = range.start ? `${fmtD(range.start, locale)} \u2013 ${range.end ? fmtD(range.end, locale) : "\u2026"}` : "";
|
|
7273
7161
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-drp twc-field ${className}`, ref: wrapRef, ...rest, children: [
|
|
7162
|
+
__twcStyles0,
|
|
7163
|
+
__twcStyles1,
|
|
7274
7164
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "twc-field__label", id: labelId, children: [
|
|
7275
7165
|
label,
|
|
7276
7166
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -7426,19 +7316,13 @@ function Dialog({
|
|
|
7426
7316
|
className = "",
|
|
7427
7317
|
...rest
|
|
7428
7318
|
}) {
|
|
7429
|
-
const autoId =
|
|
7319
|
+
const autoId = React23__namespace.default.useId();
|
|
7430
7320
|
const titleId = `${autoId}-title`;
|
|
7431
7321
|
const descId = `${autoId}-desc`;
|
|
7432
|
-
const dialogRef =
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
el.id = "twc-dialog-styles";
|
|
7437
|
-
el.textContent = DIALOG_CSS;
|
|
7438
|
-
document.head.appendChild(el);
|
|
7439
|
-
}, []);
|
|
7440
|
-
const [mounted, setMounted] = React22__default.default.useState(open);
|
|
7441
|
-
React22__default.default.useEffect(() => {
|
|
7322
|
+
const dialogRef = React23__namespace.default.useRef(null);
|
|
7323
|
+
const __twcStyles = useScopedStyles("twc-dialog-styles", DIALOG_CSS);
|
|
7324
|
+
const [mounted, setMounted] = React23__namespace.default.useState(open);
|
|
7325
|
+
React23__namespace.default.useEffect(() => {
|
|
7442
7326
|
if (open) {
|
|
7443
7327
|
setMounted(true);
|
|
7444
7328
|
return;
|
|
@@ -7446,7 +7330,7 @@ function Dialog({
|
|
|
7446
7330
|
const t = setTimeout(() => setMounted(false), 170);
|
|
7447
7331
|
return () => clearTimeout(t);
|
|
7448
7332
|
}, [open]);
|
|
7449
|
-
|
|
7333
|
+
React23__namespace.default.useEffect(() => {
|
|
7450
7334
|
if (!open) return void 0;
|
|
7451
7335
|
const prev = document.body.style.overflow;
|
|
7452
7336
|
document.body.style.overflow = "hidden";
|
|
@@ -7454,7 +7338,7 @@ function Dialog({
|
|
|
7454
7338
|
document.body.style.overflow = prev;
|
|
7455
7339
|
};
|
|
7456
7340
|
}, [open]);
|
|
7457
|
-
|
|
7341
|
+
React23__namespace.default.useEffect(() => {
|
|
7458
7342
|
if (!open || !mounted) return void 0;
|
|
7459
7343
|
const node = dialogRef.current;
|
|
7460
7344
|
const prevFocused = document.activeElement;
|
|
@@ -7466,7 +7350,7 @@ function Dialog({
|
|
|
7466
7350
|
if (prevFocused && typeof prevFocused.focus === "function") prevFocused.focus();
|
|
7467
7351
|
};
|
|
7468
7352
|
}, [open, mounted]);
|
|
7469
|
-
|
|
7353
|
+
React23__namespace.default.useEffect(() => {
|
|
7470
7354
|
if (!open) return;
|
|
7471
7355
|
const node = dialogRef.current;
|
|
7472
7356
|
const focusables = () => node ? Array.from(
|
|
@@ -7503,19 +7387,22 @@ function Dialog({
|
|
|
7503
7387
|
}, [open, onClose]);
|
|
7504
7388
|
if (!mounted) return null;
|
|
7505
7389
|
const state = open ? "open" : "closed";
|
|
7506
|
-
const overlay = /* @__PURE__ */ jsxRuntime.
|
|
7390
|
+
const overlay = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-dialog__overlay", "data-state": state, onMouseDown: (e) => {
|
|
7507
7391
|
if (closeOnBackdrop && e.target === e.currentTarget) onClose?.();
|
|
7508
|
-
}, children:
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7392
|
+
}, children: [
|
|
7393
|
+
__twcStyles,
|
|
7394
|
+
/* @__PURE__ */ jsxRuntime.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: [
|
|
7395
|
+
title || description || onClose ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-dialog__header", children: [
|
|
7396
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-dialog__titles", children: [
|
|
7397
|
+
title ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-dialog__title", id: titleId, children: title }) : null,
|
|
7398
|
+
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-dialog__desc", id: descId, children: description }) : null
|
|
7399
|
+
] }),
|
|
7400
|
+
onClose ? /* @__PURE__ */ jsxRuntime.jsx("button", { className: "twc-dialog__close", onClick: onClose, "aria-label": "Close", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6 6 18M6 6l12 12" }) }) }) : null
|
|
7401
|
+
] }) : null,
|
|
7402
|
+
children ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-dialog__body", children }) : null,
|
|
7403
|
+
footer ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-dialog__footer", children: footer }) : null
|
|
7404
|
+
] })
|
|
7405
|
+
] });
|
|
7519
7406
|
if (typeof document === "undefined") return null;
|
|
7520
7407
|
const RD = typeof reactDom.createPortal === "function" ? reactDom.createPortal : null;
|
|
7521
7408
|
return RD ? RD(overlay, document.body) : overlay;
|
|
@@ -7542,28 +7429,28 @@ function Divider({
|
|
|
7542
7429
|
className = "",
|
|
7543
7430
|
...rest
|
|
7544
7431
|
}) {
|
|
7545
|
-
|
|
7546
|
-
if (document.getElementById("twc-divider-styles")) return;
|
|
7547
|
-
const el = document.createElement("style");
|
|
7548
|
-
el.id = "twc-divider-styles";
|
|
7549
|
-
el.textContent = DIVIDER_CSS;
|
|
7550
|
-
document.head.appendChild(el);
|
|
7551
|
-
}, []);
|
|
7432
|
+
const __twcStyles = useScopedStyles("twc-divider-styles", DIVIDER_CSS);
|
|
7552
7433
|
const resolvedAlign = align === "left" ? "start" : align === "right" ? "end" : align;
|
|
7553
7434
|
if (children) {
|
|
7554
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
7435
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-divider-label ${className}`, "data-align": resolvedAlign, role: "separator", ...rest, children: [
|
|
7436
|
+
__twcStyles,
|
|
7437
|
+
children
|
|
7438
|
+
] });
|
|
7555
7439
|
}
|
|
7556
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7440
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7441
|
+
__twcStyles,
|
|
7442
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7443
|
+
"hr",
|
|
7444
|
+
{
|
|
7445
|
+
className: `twc-divider ${className}`,
|
|
7446
|
+
"data-orientation": orientation,
|
|
7447
|
+
"data-inset": inset || void 0,
|
|
7448
|
+
role: "separator",
|
|
7449
|
+
"aria-orientation": orientation,
|
|
7450
|
+
...rest
|
|
7451
|
+
}
|
|
7452
|
+
)
|
|
7453
|
+
] });
|
|
7567
7454
|
}
|
|
7568
7455
|
var DRAWER_CSS = `
|
|
7569
7456
|
.twc-drawer__overlay { position: fixed; inset: 0; z-index: var(--z-modal); background: var(--color-overlay); backdrop-filter: blur(2px); }
|
|
@@ -7632,19 +7519,13 @@ function Drawer({
|
|
|
7632
7519
|
style,
|
|
7633
7520
|
...rest
|
|
7634
7521
|
}) {
|
|
7635
|
-
const autoId =
|
|
7522
|
+
const autoId = React23__namespace.default.useId();
|
|
7636
7523
|
const titleId = `${autoId}-title`;
|
|
7637
7524
|
const descId = `${autoId}-desc`;
|
|
7638
|
-
const panelRef =
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
el.id = "twc-drawer-styles";
|
|
7643
|
-
el.textContent = DRAWER_CSS;
|
|
7644
|
-
document.head.appendChild(el);
|
|
7645
|
-
}, []);
|
|
7646
|
-
const [mounted, setMounted] = React22__default.default.useState(open);
|
|
7647
|
-
React22__default.default.useEffect(() => {
|
|
7525
|
+
const panelRef = React23__namespace.default.useRef(null);
|
|
7526
|
+
const __twcStyles = useScopedStyles("twc-drawer-styles", DRAWER_CSS);
|
|
7527
|
+
const [mounted, setMounted] = React23__namespace.default.useState(open);
|
|
7528
|
+
React23__namespace.default.useEffect(() => {
|
|
7648
7529
|
if (open) {
|
|
7649
7530
|
setMounted(true);
|
|
7650
7531
|
return;
|
|
@@ -7652,7 +7533,7 @@ function Drawer({
|
|
|
7652
7533
|
const t = setTimeout(() => setMounted(false), 170);
|
|
7653
7534
|
return () => clearTimeout(t);
|
|
7654
7535
|
}, [open]);
|
|
7655
|
-
|
|
7536
|
+
React23__namespace.default.useEffect(() => {
|
|
7656
7537
|
if (!open) return void 0;
|
|
7657
7538
|
const prev = document.body.style.overflow;
|
|
7658
7539
|
document.body.style.overflow = "hidden";
|
|
@@ -7660,7 +7541,7 @@ function Drawer({
|
|
|
7660
7541
|
document.body.style.overflow = prev;
|
|
7661
7542
|
};
|
|
7662
7543
|
}, [open]);
|
|
7663
|
-
|
|
7544
|
+
React23__namespace.default.useEffect(() => {
|
|
7664
7545
|
if (!open || !mounted) return void 0;
|
|
7665
7546
|
const node = panelRef.current;
|
|
7666
7547
|
const prevFocused = document.activeElement;
|
|
@@ -7672,7 +7553,7 @@ function Drawer({
|
|
|
7672
7553
|
if (prevFocused && typeof prevFocused.focus === "function") prevFocused.focus();
|
|
7673
7554
|
};
|
|
7674
7555
|
}, [open, mounted]);
|
|
7675
|
-
|
|
7556
|
+
React23__namespace.default.useEffect(() => {
|
|
7676
7557
|
if (!open) return;
|
|
7677
7558
|
const node = panelRef.current;
|
|
7678
7559
|
const focusables = () => node ? Array.from(
|
|
@@ -7713,19 +7594,22 @@ function Drawer({
|
|
|
7713
7594
|
const raw = isHorizontal ? width : height;
|
|
7714
7595
|
const dim = DRAWER_SIZES[raw] || (typeof raw === "number" ? `${raw}px` : raw);
|
|
7715
7596
|
const sizeVar = isHorizontal ? { "--_w": dim } : { "--_h": dim };
|
|
7716
|
-
const overlay = /* @__PURE__ */ jsxRuntime.
|
|
7597
|
+
const overlay = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-drawer__overlay", "data-state": state, onMouseDown: (e) => {
|
|
7717
7598
|
if (closeOnBackdrop && e.target === e.currentTarget) onClose?.();
|
|
7718
|
-
}, children:
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7599
|
+
}, children: [
|
|
7600
|
+
__twcStyles,
|
|
7601
|
+
/* @__PURE__ */ jsxRuntime.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: [
|
|
7602
|
+
title || description || onClose ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-drawer__header", children: [
|
|
7603
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-drawer__titles", children: [
|
|
7604
|
+
title ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-drawer__title", id: titleId, children: title }) : null,
|
|
7605
|
+
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-drawer__desc", id: descId, children: description }) : null
|
|
7606
|
+
] }),
|
|
7607
|
+
onClose ? /* @__PURE__ */ jsxRuntime.jsx("button", { className: "twc-drawer__close", onClick: onClose, "aria-label": "Close", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6 6 18M6 6l12 12" }) }) }) : null
|
|
7608
|
+
] }) : null,
|
|
7609
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-drawer__body", children }),
|
|
7610
|
+
footer ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-drawer__footer", children: footer }) : null
|
|
7611
|
+
] })
|
|
7612
|
+
] });
|
|
7729
7613
|
if (typeof document === "undefined") return null;
|
|
7730
7614
|
const RD = typeof reactDom.createPortal === "function" ? reactDom.createPortal : null;
|
|
7731
7615
|
return RD ? RD(overlay, document.body) : overlay;
|
|
@@ -7752,14 +7636,9 @@ function EmptyState({
|
|
|
7752
7636
|
...rest
|
|
7753
7637
|
}) {
|
|
7754
7638
|
const hasBorder = border ?? bordered;
|
|
7755
|
-
|
|
7756
|
-
if (document.getElementById("twc-empty-styles")) return;
|
|
7757
|
-
const el = document.createElement("style");
|
|
7758
|
-
el.id = "twc-empty-styles";
|
|
7759
|
-
el.textContent = EMPTY_CSS;
|
|
7760
|
-
document.head.appendChild(el);
|
|
7761
|
-
}, []);
|
|
7639
|
+
const __twcStyles = useScopedStyles("twc-empty-styles", EMPTY_CSS);
|
|
7762
7640
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-empty ${className}`, "data-bordered": hasBorder || void 0, ...rest, children: [
|
|
7641
|
+
__twcStyles,
|
|
7763
7642
|
icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-empty__icon", "aria-hidden": "true", children: icon }) : null,
|
|
7764
7643
|
title ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-empty__title", children: title }) : null,
|
|
7765
7644
|
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-empty__desc", children: description }) : null,
|
|
@@ -7773,15 +7652,6 @@ var FIELD_CSS5 = `
|
|
|
7773
7652
|
.twc-field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
7774
7653
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
7775
7654
|
`;
|
|
7776
|
-
function useFieldStyles2() {
|
|
7777
|
-
React22__default.default.useInsertionEffect(() => {
|
|
7778
|
-
if (document.getElementById("twc-field-styles")) return;
|
|
7779
|
-
const el = document.createElement("style");
|
|
7780
|
-
el.id = "twc-field-styles";
|
|
7781
|
-
el.textContent = FIELD_CSS5;
|
|
7782
|
-
document.head.appendChild(el);
|
|
7783
|
-
}, []);
|
|
7784
|
-
}
|
|
7785
7655
|
function Field({
|
|
7786
7656
|
label,
|
|
7787
7657
|
hint,
|
|
@@ -7794,11 +7664,12 @@ function Field({
|
|
|
7794
7664
|
children,
|
|
7795
7665
|
...rest
|
|
7796
7666
|
}) {
|
|
7797
|
-
|
|
7798
|
-
const autoId =
|
|
7667
|
+
const __twcStyles = useScopedStyles("twc-field-styles", FIELD_CSS5);
|
|
7668
|
+
const autoId = React23__namespace.default.useId();
|
|
7799
7669
|
const fieldId = id || autoId;
|
|
7800
7670
|
const descId = `${fieldId}-desc`;
|
|
7801
7671
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-field ${className}`, "data-size": size, ...rest, children: [
|
|
7672
|
+
__twcStyles,
|
|
7802
7673
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "twc-field__label", htmlFor, children: [
|
|
7803
7674
|
label,
|
|
7804
7675
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -7873,18 +7744,12 @@ function FileUpload({
|
|
|
7873
7744
|
className = "",
|
|
7874
7745
|
...rest
|
|
7875
7746
|
}) {
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
const el = document.createElement("style");
|
|
7879
|
-
el.id = "twc-upload-styles";
|
|
7880
|
-
el.textContent = UPLOAD_CSS;
|
|
7881
|
-
document.head.appendChild(el);
|
|
7882
|
-
}, []);
|
|
7883
|
-
const [internal, setInternal] = React22__default.default.useState(defaultValue);
|
|
7747
|
+
const __twcStyles = useScopedStyles("twc-upload-styles", UPLOAD_CSS);
|
|
7748
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultValue);
|
|
7884
7749
|
const files = value !== void 0 ? value : internal;
|
|
7885
|
-
const [drag, setDrag] =
|
|
7886
|
-
const inputRef =
|
|
7887
|
-
const autoId =
|
|
7750
|
+
const [drag, setDrag] = React23__namespace.default.useState(false);
|
|
7751
|
+
const inputRef = React23__namespace.default.useRef(null);
|
|
7752
|
+
const autoId = React23__namespace.default.useId();
|
|
7888
7753
|
const fieldId = id || autoId;
|
|
7889
7754
|
const descId = `${fieldId}-desc`;
|
|
7890
7755
|
const invalid = Boolean(error);
|
|
@@ -7900,6 +7765,7 @@ function FileUpload({
|
|
|
7900
7765
|
set(files.filter((_, idx) => idx !== i));
|
|
7901
7766
|
}
|
|
7902
7767
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-upload ${className}`, ...rest, children: [
|
|
7768
|
+
__twcStyles,
|
|
7903
7769
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
7904
7770
|
label,
|
|
7905
7771
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -8031,14 +7897,8 @@ function IconButton({
|
|
|
8031
7897
|
"aria-label": ariaLabel,
|
|
8032
7898
|
...rest
|
|
8033
7899
|
}) {
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
const el = document.createElement("style");
|
|
8037
|
-
el.id = "twc-iconbtn-styles";
|
|
8038
|
-
el.textContent = ICONBTN_CSS;
|
|
8039
|
-
document.head.appendChild(el);
|
|
8040
|
-
}, []);
|
|
8041
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7900
|
+
const __twcStyles = useScopedStyles("twc-iconbtn-styles", ICONBTN_CSS);
|
|
7901
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8042
7902
|
"button",
|
|
8043
7903
|
{
|
|
8044
7904
|
className: `twc-iconbtn ${className}`,
|
|
@@ -8050,7 +7910,10 @@ function IconButton({
|
|
|
8050
7910
|
type: "button",
|
|
8051
7911
|
"aria-label": ariaLabel,
|
|
8052
7912
|
...rest,
|
|
8053
|
-
children:
|
|
7913
|
+
children: [
|
|
7914
|
+
__twcStyles,
|
|
7915
|
+
icon || children
|
|
7916
|
+
]
|
|
8054
7917
|
}
|
|
8055
7918
|
);
|
|
8056
7919
|
}
|
|
@@ -8087,22 +7950,16 @@ function Kanban({
|
|
|
8087
7950
|
className = "",
|
|
8088
7951
|
...rest
|
|
8089
7952
|
}) {
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
const el = document.createElement("style");
|
|
8093
|
-
el.id = "twc-kanban-styles";
|
|
8094
|
-
el.textContent = KANBAN_CSS;
|
|
8095
|
-
document.head.appendChild(el);
|
|
8096
|
-
}, []);
|
|
8097
|
-
const [internal, setInternal] = React22__default.default.useState(cards ?? defaultCards ?? []);
|
|
7953
|
+
const __twcStyles = useScopedStyles("twc-kanban-styles", KANBAN_CSS);
|
|
7954
|
+
const [internal, setInternal] = React23__namespace.default.useState(cards ?? defaultCards ?? []);
|
|
8098
7955
|
const items = cards !== void 0 ? cards : internal;
|
|
8099
|
-
const [drag, setDrag] =
|
|
8100
|
-
const [overCol, setOverCol] =
|
|
8101
|
-
const [grab, setGrab] =
|
|
8102
|
-
const [announce, setAnnounce] =
|
|
8103
|
-
const rootRef =
|
|
8104
|
-
const focusIdRef =
|
|
8105
|
-
|
|
7956
|
+
const [drag, setDrag] = React23__namespace.default.useState(null);
|
|
7957
|
+
const [overCol, setOverCol] = React23__namespace.default.useState(null);
|
|
7958
|
+
const [grab, setGrab] = React23__namespace.default.useState(null);
|
|
7959
|
+
const [announce, setAnnounce] = React23__namespace.default.useState("");
|
|
7960
|
+
const rootRef = React23__namespace.default.useRef(null);
|
|
7961
|
+
const focusIdRef = React23__namespace.default.useRef(null);
|
|
7962
|
+
React23__namespace.default.useEffect(() => {
|
|
8106
7963
|
if (focusIdRef.current == null) return void 0;
|
|
8107
7964
|
const raf = requestAnimationFrame(() => {
|
|
8108
7965
|
const id = focusIdRef.current;
|
|
@@ -8155,6 +8012,7 @@ function Kanban({
|
|
|
8155
8012
|
};
|
|
8156
8013
|
const keyTargetCol = grab ? columns[grab.targetIdx]?.id : null;
|
|
8157
8014
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-kanban ${className}`, ref: rootRef, ...rest, children: [
|
|
8015
|
+
__twcStyles,
|
|
8158
8016
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-kanban__sr", role: "status", "aria-live": "polite", children: announce }),
|
|
8159
8017
|
columns.map((col, colIdx) => {
|
|
8160
8018
|
const colCards = items.filter((c) => c.column === col.id);
|
|
@@ -8246,43 +8104,40 @@ var LIST_CSS = `
|
|
|
8246
8104
|
.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); }
|
|
8247
8105
|
`;
|
|
8248
8106
|
function List({ items, plain = false, className = "", ...rest }) {
|
|
8249
|
-
|
|
8250
|
-
if (document.getElementById("twc-list-styles")) return;
|
|
8251
|
-
const el = document.createElement("style");
|
|
8252
|
-
el.id = "twc-list-styles";
|
|
8253
|
-
el.textContent = LIST_CSS;
|
|
8254
|
-
document.head.appendChild(el);
|
|
8255
|
-
}, []);
|
|
8107
|
+
const __twcStyles = useScopedStyles("twc-list-styles", LIST_CSS);
|
|
8256
8108
|
const safeHref11 = (url) => {
|
|
8257
8109
|
if (url == null) return void 0;
|
|
8258
8110
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
8259
8111
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
8260
8112
|
};
|
|
8261
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8268
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
{
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8113
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: `twc-list ${className}`, "data-plain": plain || void 0, ...rest, children: [
|
|
8114
|
+
__twcStyles,
|
|
8115
|
+
items.map((it, i) => {
|
|
8116
|
+
const href = safeHref11(it.href);
|
|
8117
|
+
const interactive = Boolean(it.onClick || href);
|
|
8118
|
+
const Tag2 = href ? "a" : interactive ? "button" : "div";
|
|
8119
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8120
|
+
it.leading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-list__lead", "aria-hidden": "true", children: it.leading }) : null,
|
|
8121
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "twc-list__main", children: [
|
|
8122
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-list__title", children: it.title }),
|
|
8123
|
+
it.description ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-list__desc", children: it.description }) : null
|
|
8124
|
+
] }),
|
|
8125
|
+
it.trailing ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-list__trail", children: it.trailing }) : null
|
|
8126
|
+
] });
|
|
8127
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { style: { display: "contents" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8128
|
+
Tag2,
|
|
8129
|
+
{
|
|
8130
|
+
className: "twc-list__item",
|
|
8131
|
+
"data-interactive": interactive || void 0,
|
|
8132
|
+
"data-active": it.active || void 0,
|
|
8133
|
+
href,
|
|
8134
|
+
type: Tag2 === "button" ? "button" : void 0,
|
|
8135
|
+
onClick: it.onClick,
|
|
8136
|
+
children: content
|
|
8137
|
+
}
|
|
8138
|
+
) }, i);
|
|
8139
|
+
})
|
|
8140
|
+
] });
|
|
8286
8141
|
}
|
|
8287
8142
|
var NAVBAR_CSS = `
|
|
8288
8143
|
.twc-navbar { display: flex; align-items: center; gap: var(--space-4); height: 60px; padding: 0 var(--space-5);
|
|
@@ -8328,14 +8183,9 @@ function Navbar({
|
|
|
8328
8183
|
className = "",
|
|
8329
8184
|
...rest
|
|
8330
8185
|
}) {
|
|
8331
|
-
|
|
8332
|
-
if (document.getElementById("twc-navbar-styles")) return;
|
|
8333
|
-
const el = document.createElement("style");
|
|
8334
|
-
el.id = "twc-navbar-styles";
|
|
8335
|
-
el.textContent = NAVBAR_CSS;
|
|
8336
|
-
document.head.appendChild(el);
|
|
8337
|
-
}, []);
|
|
8186
|
+
const __twcStyles = useScopedStyles("twc-navbar-styles", NAVBAR_CSS);
|
|
8338
8187
|
return /* @__PURE__ */ jsxRuntime.jsxs("header", { className: `twc-navbar ${className}`, "data-sticky": sticky || void 0, ...rest, children: [
|
|
8188
|
+
__twcStyles,
|
|
8339
8189
|
onMenuClick ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-navbar__menu-btn", "aria-label": "Open menu", onClick: onMenuClick, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 6h16M4 12h16M4 18h16" }) }) }) : null,
|
|
8340
8190
|
brand ? brandHref ? /* @__PURE__ */ jsxRuntime.jsx("a", { className: "twc-navbar__brand", href: safeHref3(brandHref), children: brand }) : onBrandClick ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-navbar__brand", onClick: onBrandClick, children: brand }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-navbar__brand", children: brand }) : null,
|
|
8341
8191
|
/* @__PURE__ */ jsxRuntime.jsx("nav", { className: "twc-navbar__links", children: links.map((l, i) => {
|
|
@@ -8406,28 +8256,22 @@ function Popover({
|
|
|
8406
8256
|
className = "",
|
|
8407
8257
|
...rest
|
|
8408
8258
|
}) {
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
const [openState, setOpenState] = React22__default.default.useState(defaultOpen);
|
|
8417
|
-
const [render, setRender] = React22__default.default.useState(false);
|
|
8418
|
-
const [pos, setPos] = React22__default.default.useState(null);
|
|
8419
|
-
const wrapRef = React22__default.default.useRef(null);
|
|
8420
|
-
const popRef = React22__default.default.useRef(null);
|
|
8421
|
-
const popId = React22__default.default.useId();
|
|
8259
|
+
const __twcStyles = useScopedStyles("twc-popover-styles", POPOVER_CSS);
|
|
8260
|
+
const [openState, setOpenState] = React23__namespace.default.useState(defaultOpen);
|
|
8261
|
+
const [render, setRender] = React23__namespace.default.useState(false);
|
|
8262
|
+
const [pos, setPos] = React23__namespace.default.useState(null);
|
|
8263
|
+
const wrapRef = React23__namespace.default.useRef(null);
|
|
8264
|
+
const popRef = React23__namespace.default.useRef(null);
|
|
8265
|
+
const popId = React23__namespace.default.useId();
|
|
8422
8266
|
const controlled = openProp !== void 0;
|
|
8423
8267
|
const open = controlled ? !!openProp : openState;
|
|
8424
|
-
const openRef =
|
|
8268
|
+
const openRef = React23__namespace.default.useRef(open);
|
|
8425
8269
|
openRef.current = open;
|
|
8426
|
-
const controlledRef =
|
|
8270
|
+
const controlledRef = React23__namespace.default.useRef(controlled);
|
|
8427
8271
|
controlledRef.current = controlled;
|
|
8428
|
-
const onOpenChangeRef =
|
|
8272
|
+
const onOpenChangeRef = React23__namespace.default.useRef(onOpenChange);
|
|
8429
8273
|
onOpenChangeRef.current = onOpenChange;
|
|
8430
|
-
const setOpen =
|
|
8274
|
+
const setOpen = React23__namespace.default.useCallback((next) => {
|
|
8431
8275
|
const value = typeof next === "function" ? next(openRef.current) : next;
|
|
8432
8276
|
if (value === openRef.current) return;
|
|
8433
8277
|
if (!controlledRef.current) setOpenState(value);
|
|
@@ -8435,7 +8279,7 @@ function Popover({
|
|
|
8435
8279
|
}, []);
|
|
8436
8280
|
const toggle = () => setOpen((o) => !o);
|
|
8437
8281
|
const RD = { createPortal: typeof reactDom.createPortal === "function" ? reactDom.createPortal : typeof window !== "undefined" && window.ReactDOM && window.ReactDOM.createPortal };
|
|
8438
|
-
const place =
|
|
8282
|
+
const place = React23__namespace.default.useCallback(() => {
|
|
8439
8283
|
const t = wrapRef.current;
|
|
8440
8284
|
if (!t) return;
|
|
8441
8285
|
const r = t.getBoundingClientRect();
|
|
@@ -8466,7 +8310,7 @@ function Popover({
|
|
|
8466
8310
|
arrow = { top: Math.min(Math.max(cy - top - 5.5, 8), ph - 18), [onRight ? "left" : "right"]: -6 };
|
|
8467
8311
|
setPos({ top, left, width: w, flip: false, arrow });
|
|
8468
8312
|
}, [placement, align, width]);
|
|
8469
|
-
|
|
8313
|
+
React23__namespace.default.useEffect(() => {
|
|
8470
8314
|
if (!open) return;
|
|
8471
8315
|
place();
|
|
8472
8316
|
const onMove = () => place();
|
|
@@ -8489,7 +8333,7 @@ function Popover({
|
|
|
8489
8333
|
document.removeEventListener("keydown", onKey);
|
|
8490
8334
|
};
|
|
8491
8335
|
}, [open, place]);
|
|
8492
|
-
|
|
8336
|
+
React23__namespace.default.useEffect(() => {
|
|
8493
8337
|
if (open) {
|
|
8494
8338
|
setRender(true);
|
|
8495
8339
|
return;
|
|
@@ -8497,12 +8341,12 @@ function Popover({
|
|
|
8497
8341
|
const t = setTimeout(() => setRender(false), 170);
|
|
8498
8342
|
return () => clearTimeout(t);
|
|
8499
8343
|
}, [open]);
|
|
8500
|
-
|
|
8344
|
+
React23__namespace.default.useEffect(() => {
|
|
8501
8345
|
if (render && open) place();
|
|
8502
8346
|
}, [render, place]);
|
|
8503
|
-
const restoreRef =
|
|
8504
|
-
const needFocusRef =
|
|
8505
|
-
|
|
8347
|
+
const restoreRef = React23__namespace.default.useRef(null);
|
|
8348
|
+
const needFocusRef = React23__namespace.default.useRef(false);
|
|
8349
|
+
React23__namespace.default.useEffect(() => {
|
|
8506
8350
|
if (open) {
|
|
8507
8351
|
restoreRef.current = document.activeElement;
|
|
8508
8352
|
needFocusRef.current = true;
|
|
@@ -8513,7 +8357,7 @@ function Popover({
|
|
|
8513
8357
|
needFocusRef.current = false;
|
|
8514
8358
|
if (prev && typeof prev.focus === "function" && popRef.current?.contains(document.activeElement)) prev.focus();
|
|
8515
8359
|
}, [open]);
|
|
8516
|
-
|
|
8360
|
+
React23__namespace.default.useEffect(() => {
|
|
8517
8361
|
if (open && render && pos && needFocusRef.current) {
|
|
8518
8362
|
needFocusRef.current = false;
|
|
8519
8363
|
popRef.current?.focus({ preventScroll: true });
|
|
@@ -8532,6 +8376,7 @@ function Popover({
|
|
|
8532
8376
|
"aria-labelledby": title ? `${popId}-title` : void 0,
|
|
8533
8377
|
style: { top: pos.top, bottom: pos.bottom, left: pos.left, width: pos.width },
|
|
8534
8378
|
children: [
|
|
8379
|
+
__twcStyles,
|
|
8535
8380
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-popover__arrow", style: pos.arrow, "aria-hidden": "true" }),
|
|
8536
8381
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-popover__inner", children: [
|
|
8537
8382
|
title ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-popover__title", id: `${popId}-title`, children: title }) : null,
|
|
@@ -8540,7 +8385,7 @@ function Popover({
|
|
|
8540
8385
|
]
|
|
8541
8386
|
}
|
|
8542
8387
|
) : null;
|
|
8543
|
-
const triggerEl =
|
|
8388
|
+
const triggerEl = React23__namespace.default.isValidElement(trigger) ? React23__namespace.default.cloneElement(trigger, {
|
|
8544
8389
|
onClick: (e) => {
|
|
8545
8390
|
trigger.props.onClick?.(e);
|
|
8546
8391
|
toggle();
|
|
@@ -8582,11 +8427,7 @@ function Progress({
|
|
|
8582
8427
|
className = "",
|
|
8583
8428
|
...rest
|
|
8584
8429
|
}) {
|
|
8585
|
-
|
|
8586
|
-
if (document.getElementById("twc-progress-styles")) return;
|
|
8587
|
-
const el = document.createElement("style");
|
|
8588
|
-
el.id = "twc-progress-styles";
|
|
8589
|
-
el.textContent = `
|
|
8430
|
+
const __twcStyles = useScopedStyles("twc-progress-styles", `
|
|
8590
8431
|
.twc-progress-wrap { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-sans); }
|
|
8591
8432
|
.twc-progress {
|
|
8592
8433
|
--_h: 8px;
|
|
@@ -8618,15 +8459,14 @@ function Progress({
|
|
|
8618
8459
|
@media (prefers-reduced-motion: reduce) {
|
|
8619
8460
|
.twc-progress[data-indeterminate="true"] .twc-progress__bar { animation-duration: 1.3s !important; animation-iteration-count: infinite !important; }
|
|
8620
8461
|
}
|
|
8621
|
-
|
|
8622
|
-
document.head.appendChild(el);
|
|
8623
|
-
}, []);
|
|
8462
|
+
`);
|
|
8624
8463
|
const v = Number.isFinite(value) ? value : 0;
|
|
8625
8464
|
const pct = indeterminate ? 0 : max > 0 ? Math.min(100, Math.max(0, v / max * 100)) : 0;
|
|
8626
8465
|
return (
|
|
8627
8466
|
// Single-root contract: className and ...rest (style, id, handlers, …) share the outer
|
|
8628
8467
|
// wrapper; role="progressbar" + aria-value* stay on the inner track.
|
|
8629
8468
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-progress-wrap ${className}`, ...rest, children: [
|
|
8469
|
+
__twcStyles,
|
|
8630
8470
|
showLabel && !indeterminate ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-progress__meta", children: [
|
|
8631
8471
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Progress" }),
|
|
8632
8472
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
@@ -8668,11 +8508,7 @@ function Radio({
|
|
|
8668
8508
|
onChange,
|
|
8669
8509
|
...rest
|
|
8670
8510
|
}) {
|
|
8671
|
-
|
|
8672
|
-
if (document.getElementById("twc-radio-styles")) return;
|
|
8673
|
-
const el = document.createElement("style");
|
|
8674
|
-
el.id = "twc-radio-styles";
|
|
8675
|
-
el.textContent = `
|
|
8511
|
+
const __twcStyles = useScopedStyles("twc-radio-styles", `
|
|
8676
8512
|
.twc-radio { display: inline-flex; align-items: flex-start; gap: var(--space-2-5); cursor: pointer; font-family: var(--font-sans); }
|
|
8677
8513
|
/* tone \u2192 accent set (default primary). Mirrors Button's --_accent model; Badge's tone vocabulary. */
|
|
8678
8514
|
.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); }
|
|
@@ -8709,15 +8545,14 @@ function Radio({
|
|
|
8709
8545
|
.twc-radio__desc { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
8710
8546
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
8711
8547
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
}, []);
|
|
8715
|
-
const autoId = React22__default.default.useId();
|
|
8548
|
+
`);
|
|
8549
|
+
const autoId = React23__namespace.default.useId();
|
|
8716
8550
|
const fieldId = id || autoId;
|
|
8717
8551
|
const errId = `${fieldId}-error`;
|
|
8718
8552
|
const invalid = Boolean(error);
|
|
8719
8553
|
const describedBy = [rest["aria-describedby"], error ? errId : null].filter(Boolean).join(" ") || void 0;
|
|
8720
8554
|
const control = /* @__PURE__ */ jsxRuntime.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: [
|
|
8555
|
+
__twcStyles,
|
|
8721
8556
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8722
8557
|
"input",
|
|
8723
8558
|
{
|
|
@@ -8788,19 +8623,13 @@ function Rating({
|
|
|
8788
8623
|
style,
|
|
8789
8624
|
...rest
|
|
8790
8625
|
}) {
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
el.id = "twc-rating-styles";
|
|
8795
|
-
el.textContent = RATING_CSS;
|
|
8796
|
-
document.head.appendChild(el);
|
|
8797
|
-
}, []);
|
|
8798
|
-
const [internal, setInternal] = React22__default.default.useState(defaultValue);
|
|
8799
|
-
const [hover, setHover] = React22__default.default.useState(0);
|
|
8626
|
+
const __twcStyles = useScopedStyles("twc-rating-styles", RATING_CSS);
|
|
8627
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultValue);
|
|
8628
|
+
const [hover, setHover] = React23__namespace.default.useState(0);
|
|
8800
8629
|
const val = value !== void 0 ? value : internal;
|
|
8801
8630
|
const shown = hover || val;
|
|
8802
8631
|
const interactive = !readOnly && !disabled;
|
|
8803
|
-
const btnRefs =
|
|
8632
|
+
const btnRefs = React23__namespace.default.useRef([]);
|
|
8804
8633
|
const tabStar = Math.min(count, Math.max(1, Math.round(val) || 1));
|
|
8805
8634
|
const set = (v) => {
|
|
8806
8635
|
if (!interactive) return;
|
|
@@ -8833,6 +8662,7 @@ function Rating({
|
|
|
8833
8662
|
"aria-disabled": disabled || void 0,
|
|
8834
8663
|
...rest,
|
|
8835
8664
|
children: [
|
|
8665
|
+
__twcStyles,
|
|
8836
8666
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-rating__stars", onMouseLeave: () => setHover(0), onKeyDown, children: Array.from({ length: count }).map((_, i) => {
|
|
8837
8667
|
const n = i + 1;
|
|
8838
8668
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -8914,14 +8744,8 @@ function Sidebar({
|
|
|
8914
8744
|
className = "",
|
|
8915
8745
|
...rest
|
|
8916
8746
|
}) {
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
const el = document.createElement("style");
|
|
8920
|
-
el.id = "twc-sidebar-styles";
|
|
8921
|
-
el.textContent = SIDEBAR_CSS;
|
|
8922
|
-
document.head.appendChild(el);
|
|
8923
|
-
}, []);
|
|
8924
|
-
const [internal, setInternal] = React22__default.default.useState(defaultCollapsed);
|
|
8747
|
+
const __twcStyles = useScopedStyles("twc-sidebar-styles", SIDEBAR_CSS);
|
|
8748
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultCollapsed);
|
|
8925
8749
|
const collapsed = collapsedProp !== void 0 ? collapsedProp : internal;
|
|
8926
8750
|
const toggle = () => {
|
|
8927
8751
|
const next = !collapsed;
|
|
@@ -8934,6 +8758,7 @@ function Sidebar({
|
|
|
8934
8758
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
8935
8759
|
};
|
|
8936
8760
|
return /* @__PURE__ */ jsxRuntime.jsxs("aside", { className: `twc-sidebar ${className}`, "data-collapsed": collapsed || void 0, ...rest, children: [
|
|
8761
|
+
__twcStyles,
|
|
8937
8762
|
brand ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-sidebar__head", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-sidebar__brand", children: brand }) }) : null,
|
|
8938
8763
|
/* @__PURE__ */ jsxRuntime.jsx("nav", { className: "twc-sidebar__nav", children: items.map(
|
|
8939
8764
|
(it, i) => it.section ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-sidebar__section", children: it.section }, i) : (() => {
|
|
@@ -8973,11 +8798,7 @@ function Skeleton({
|
|
|
8973
8798
|
style,
|
|
8974
8799
|
...rest
|
|
8975
8800
|
}) {
|
|
8976
|
-
|
|
8977
|
-
if (document.getElementById("twc-skeleton-styles")) return;
|
|
8978
|
-
const el = document.createElement("style");
|
|
8979
|
-
el.id = "twc-skeleton-styles";
|
|
8980
|
-
el.textContent = `
|
|
8801
|
+
const __twcStyles = useScopedStyles("twc-skeleton-styles", `
|
|
8981
8802
|
.twc-skeleton {
|
|
8982
8803
|
position: relative; overflow: hidden;
|
|
8983
8804
|
background: var(--color-surface-sunken); border-radius: var(--radius-md);
|
|
@@ -8996,11 +8817,12 @@ function Skeleton({
|
|
|
8996
8817
|
@media (prefers-reduced-motion: reduce) {
|
|
8997
8818
|
.twc-skeleton::after { animation-duration: 1.4s !important; animation-iteration-count: infinite !important; }
|
|
8998
8819
|
}
|
|
8999
|
-
|
|
9000
|
-
document.head.appendChild(el);
|
|
9001
|
-
}, []);
|
|
8820
|
+
`);
|
|
9002
8821
|
if (variant === "text" && lines > 1) {
|
|
9003
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
8822
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-skeleton__group ${className}`, style: { height, ...style }, ...rest, children: [
|
|
8823
|
+
__twcStyles,
|
|
8824
|
+
Array.from({ length: lines }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-skeleton", "data-variant": "text", style: { width: width || "100%" } }, i))
|
|
8825
|
+
] });
|
|
9004
8826
|
}
|
|
9005
8827
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9006
8828
|
"span",
|
|
@@ -9008,7 +8830,8 @@ function Skeleton({
|
|
|
9008
8830
|
className: `twc-skeleton ${className}`,
|
|
9009
8831
|
"data-variant": variant,
|
|
9010
8832
|
style: { width, height, ...style },
|
|
9011
|
-
...rest
|
|
8833
|
+
...rest,
|
|
8834
|
+
children: __twcStyles
|
|
9012
8835
|
}
|
|
9013
8836
|
);
|
|
9014
8837
|
}
|
|
@@ -9074,19 +8897,13 @@ function Slider({
|
|
|
9074
8897
|
const min = Number.isFinite(minProp) ? minProp : 0;
|
|
9075
8898
|
const max = Number.isFinite(maxProp) && maxProp > min ? maxProp : min + 1;
|
|
9076
8899
|
const step = Number.isFinite(stepProp) && stepProp > 0 ? stepProp : 1;
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
const el = document.createElement("style");
|
|
9080
|
-
el.id = "twc-slider-styles";
|
|
9081
|
-
el.textContent = SLIDER_CSS;
|
|
9082
|
-
document.head.appendChild(el);
|
|
9083
|
-
}, []);
|
|
9084
|
-
const autoId = React22__default.default.useId();
|
|
8900
|
+
const __twcStyles = useScopedStyles("twc-slider-styles", SLIDER_CSS);
|
|
8901
|
+
const autoId = React23__namespace.default.useId();
|
|
9085
8902
|
const fieldId = id || autoId;
|
|
9086
|
-
const [internal, setInternal] =
|
|
8903
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultValue);
|
|
9087
8904
|
const val = value !== void 0 ? value : internal;
|
|
9088
|
-
const trackRef =
|
|
9089
|
-
const [dragging, setDragging] =
|
|
8905
|
+
const trackRef = React23__namespace.default.useRef(null);
|
|
8906
|
+
const [dragging, setDragging] = React23__namespace.default.useState(false);
|
|
9090
8907
|
const pct = (val - min) / (max - min) * 100;
|
|
9091
8908
|
const fmt = (v) => formatValue ? formatValue(v) : v;
|
|
9092
8909
|
const clampSnap = (raw) => {
|
|
@@ -9104,8 +8921,8 @@ function Slider({
|
|
|
9104
8921
|
const ratio = Math.min(1, Math.max(0, (clientX - r.left) / r.width));
|
|
9105
8922
|
return clampSnap(min + ratio * (max - min));
|
|
9106
8923
|
};
|
|
9107
|
-
const dragCleanupRef =
|
|
9108
|
-
|
|
8924
|
+
const dragCleanupRef = React23__namespace.default.useRef(null);
|
|
8925
|
+
React23__namespace.default.useEffect(() => () => dragCleanupRef.current?.(), []);
|
|
9109
8926
|
function onPointerDown(e) {
|
|
9110
8927
|
if (disabled) return;
|
|
9111
8928
|
e.preventDefault();
|
|
@@ -9143,6 +8960,7 @@ function Slider({
|
|
|
9143
8960
|
const display = fmt(val);
|
|
9144
8961
|
const valueText = formatValue && (typeof display === "string" || typeof display === "number") ? String(display) : void 0;
|
|
9145
8962
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-slider ${className}`, "data-tone": tone, "data-disabled": disabled || void 0, ...rest, children: [
|
|
8963
|
+
__twcStyles,
|
|
9146
8964
|
label || showValue ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-slider__head", children: [
|
|
9147
8965
|
label ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: "twc-slider__label", id: labelId, children: label }) : /* @__PURE__ */ jsxRuntime.jsx("span", {}),
|
|
9148
8966
|
showValue ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-slider__value", children: display }) : null
|
|
@@ -9185,11 +9003,7 @@ function Spinner({
|
|
|
9185
9003
|
...rest
|
|
9186
9004
|
}) {
|
|
9187
9005
|
const resolvedColor = color ?? tone;
|
|
9188
|
-
|
|
9189
|
-
if (document.getElementById("twc-spinner-styles")) return;
|
|
9190
|
-
const el = document.createElement("style");
|
|
9191
|
-
el.id = "twc-spinner-styles";
|
|
9192
|
-
el.textContent = `
|
|
9006
|
+
const __twcStyles = useScopedStyles("twc-spinner-styles", `
|
|
9193
9007
|
.twc-spinner {
|
|
9194
9008
|
--_sz: 24px; --_bw: 2.5px;
|
|
9195
9009
|
display: inline-block; width: var(--_sz); height: var(--_sz);
|
|
@@ -9213,10 +9027,8 @@ function Spinner({
|
|
|
9213
9027
|
@media (prefers-reduced-motion: reduce) {
|
|
9214
9028
|
.twc-spinner { animation-duration: 0.65s !important; animation-iteration-count: infinite !important; }
|
|
9215
9029
|
}
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
}, []);
|
|
9219
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `twc-spinner ${className}`, "data-size": size, "data-tone": resolvedColor, role: "status", "aria-label": label, ...rest });
|
|
9030
|
+
`);
|
|
9031
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `twc-spinner ${className}`, "data-size": size, "data-tone": resolvedColor, role: "status", "aria-label": label, ...rest, children: __twcStyles });
|
|
9220
9032
|
}
|
|
9221
9033
|
var STAT_CSS = `
|
|
9222
9034
|
.twc-stat { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-sans);
|
|
@@ -9249,16 +9061,11 @@ function Stat({
|
|
|
9249
9061
|
className = "",
|
|
9250
9062
|
...rest
|
|
9251
9063
|
}) {
|
|
9252
|
-
|
|
9253
|
-
if (document.getElementById("twc-stat-styles")) return;
|
|
9254
|
-
const el = document.createElement("style");
|
|
9255
|
-
el.id = "twc-stat-styles";
|
|
9256
|
-
el.textContent = STAT_CSS;
|
|
9257
|
-
document.head.appendChild(el);
|
|
9258
|
-
}, []);
|
|
9064
|
+
const __twcStyles = useScopedStyles("twc-stat-styles", STAT_CSS);
|
|
9259
9065
|
const isNeg = delta != null && String(delta).trim().startsWith("-");
|
|
9260
9066
|
const dir = deltaDirection || (delta != null ? isNeg ? "down" : "up" : void 0);
|
|
9261
9067
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-stat ${className}`, "data-plain": plain || void 0, ...rest, children: [
|
|
9068
|
+
__twcStyles,
|
|
9262
9069
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-stat__top", children: [
|
|
9263
9070
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-stat__label", children: label }),
|
|
9264
9071
|
icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-stat__icon", "aria-hidden": "true", children: icon }) : null
|
|
@@ -9325,14 +9132,8 @@ function Stepper({
|
|
|
9325
9132
|
className = "",
|
|
9326
9133
|
...rest
|
|
9327
9134
|
}) {
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
const el = document.createElement("style");
|
|
9331
|
-
el.id = "twc-stepper-styles";
|
|
9332
|
-
el.textContent = STEPPER_CSS;
|
|
9333
|
-
document.head.appendChild(el);
|
|
9334
|
-
}, []);
|
|
9335
|
-
const [activeInternal, setActiveInternal] = React22__default.default.useState(defaultActive);
|
|
9135
|
+
const __twcStyles = useScopedStyles("twc-stepper-styles", STEPPER_CSS);
|
|
9136
|
+
const [activeInternal, setActiveInternal] = React23__namespace.default.useState(defaultActive);
|
|
9336
9137
|
const active = activeProp !== void 0 ? activeProp : activeInternal;
|
|
9337
9138
|
const handleStep = (i) => {
|
|
9338
9139
|
if (activeProp === void 0) setActiveInternal(i);
|
|
@@ -9344,23 +9145,47 @@ function Stepper({
|
|
|
9344
9145
|
if (i === active) return "active";
|
|
9345
9146
|
return "upcoming";
|
|
9346
9147
|
};
|
|
9347
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
|
|
9358
|
-
|
|
9148
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-stepper ${className}`, "data-orientation": orientation, "data-tone": tone, ...rest, children: [
|
|
9149
|
+
__twcStyles,
|
|
9150
|
+
steps.map((step, i) => {
|
|
9151
|
+
const state = stateOf(i, step);
|
|
9152
|
+
const last = i === steps.length - 1;
|
|
9153
|
+
const isClickable = clickable && i <= active;
|
|
9154
|
+
const interactive = isClickable ? {
|
|
9155
|
+
role: "button",
|
|
9156
|
+
tabIndex: 0,
|
|
9157
|
+
onClick: () => handleStep(i),
|
|
9158
|
+
onKeyDown: (e) => {
|
|
9159
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
9160
|
+
e.preventDefault();
|
|
9161
|
+
handleStep(i);
|
|
9162
|
+
}
|
|
9359
9163
|
}
|
|
9164
|
+
} : null;
|
|
9165
|
+
const indicator = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-step__indicator", "aria-hidden": "true", children: state === "complete" ? /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) : state === "error" ? /* @__PURE__ */ jsxRuntime.jsx(BangIcon, {}) : step.icon || i + 1 });
|
|
9166
|
+
if (orientation === "vertical") {
|
|
9167
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9168
|
+
"div",
|
|
9169
|
+
{
|
|
9170
|
+
className: "twc-step",
|
|
9171
|
+
"data-state": state,
|
|
9172
|
+
"data-clickable": isClickable || void 0,
|
|
9173
|
+
"aria-current": state === "active" ? "step" : void 0,
|
|
9174
|
+
...interactive,
|
|
9175
|
+
children: [
|
|
9176
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-step__col", children: [
|
|
9177
|
+
indicator,
|
|
9178
|
+
!last ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-step__connector" }) : null
|
|
9179
|
+
] }),
|
|
9180
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-step__body twc-step__vbody", children: [
|
|
9181
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-step__title", children: step.title }),
|
|
9182
|
+
step.description ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-step__desc", children: step.description }) : null
|
|
9183
|
+
] })
|
|
9184
|
+
]
|
|
9185
|
+
},
|
|
9186
|
+
i
|
|
9187
|
+
);
|
|
9360
9188
|
}
|
|
9361
|
-
} : null;
|
|
9362
|
-
const indicator = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-step__indicator", "aria-hidden": "true", children: state === "complete" ? /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) : state === "error" ? /* @__PURE__ */ jsxRuntime.jsx(BangIcon, {}) : step.icon || i + 1 });
|
|
9363
|
-
if (orientation === "vertical") {
|
|
9364
9189
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9365
9190
|
"div",
|
|
9366
9191
|
{
|
|
@@ -9370,11 +9195,9 @@ function Stepper({
|
|
|
9370
9195
|
"aria-current": state === "active" ? "step" : void 0,
|
|
9371
9196
|
...interactive,
|
|
9372
9197
|
children: [
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
] }),
|
|
9377
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-step__body twc-step__vbody", children: [
|
|
9198
|
+
indicator,
|
|
9199
|
+
!last ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-step__connector" }) : null,
|
|
9200
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-step__body", children: [
|
|
9378
9201
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-step__title", children: step.title }),
|
|
9379
9202
|
step.description ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-step__desc", children: step.description }) : null
|
|
9380
9203
|
] })
|
|
@@ -9382,27 +9205,8 @@ function Stepper({
|
|
|
9382
9205
|
},
|
|
9383
9206
|
i
|
|
9384
9207
|
);
|
|
9385
|
-
}
|
|
9386
|
-
|
|
9387
|
-
"div",
|
|
9388
|
-
{
|
|
9389
|
-
className: "twc-step",
|
|
9390
|
-
"data-state": state,
|
|
9391
|
-
"data-clickable": isClickable || void 0,
|
|
9392
|
-
"aria-current": state === "active" ? "step" : void 0,
|
|
9393
|
-
...interactive,
|
|
9394
|
-
children: [
|
|
9395
|
-
indicator,
|
|
9396
|
-
!last ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-step__connector" }) : null,
|
|
9397
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-step__body", children: [
|
|
9398
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-step__title", children: step.title }),
|
|
9399
|
-
step.description ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-step__desc", children: step.description }) : null
|
|
9400
|
-
] })
|
|
9401
|
-
]
|
|
9402
|
-
},
|
|
9403
|
-
i
|
|
9404
|
-
);
|
|
9405
|
-
}) });
|
|
9208
|
+
})
|
|
9209
|
+
] });
|
|
9406
9210
|
}
|
|
9407
9211
|
function Switch({
|
|
9408
9212
|
label,
|
|
@@ -9419,11 +9223,7 @@ function Switch({
|
|
|
9419
9223
|
onChange,
|
|
9420
9224
|
...rest
|
|
9421
9225
|
}) {
|
|
9422
|
-
|
|
9423
|
-
if (document.getElementById("twc-switch-styles")) return;
|
|
9424
|
-
const el = document.createElement("style");
|
|
9425
|
-
el.id = "twc-switch-styles";
|
|
9426
|
-
el.textContent = `
|
|
9226
|
+
const __twcStyles = useScopedStyles("twc-switch-styles", `
|
|
9427
9227
|
/* tone \u2192 accent set (default primary). Mirrors Button's --_accent model; Badge's tone vocabulary. */
|
|
9428
9228
|
.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); }
|
|
9429
9229
|
.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); }
|
|
@@ -9459,15 +9259,14 @@ function Switch({
|
|
|
9459
9259
|
.twc-switch__desc { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
9460
9260
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
9461
9261
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
}, []);
|
|
9465
|
-
const autoId = React22__default.default.useId();
|
|
9262
|
+
`);
|
|
9263
|
+
const autoId = React23__namespace.default.useId();
|
|
9466
9264
|
const fieldId = id || autoId;
|
|
9467
9265
|
const errId = `${fieldId}-error`;
|
|
9468
9266
|
const invalid = Boolean(error);
|
|
9469
9267
|
const describedBy = [rest["aria-describedby"], error ? errId : null].filter(Boolean).join(" ") || void 0;
|
|
9470
9268
|
const control = /* @__PURE__ */ jsxRuntime.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: [
|
|
9269
|
+
__twcStyles,
|
|
9471
9270
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9472
9271
|
"input",
|
|
9473
9272
|
{
|
|
@@ -9544,21 +9343,15 @@ function Table({
|
|
|
9544
9343
|
className = "",
|
|
9545
9344
|
...rest
|
|
9546
9345
|
}) {
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
const el = document.createElement("style");
|
|
9550
|
-
el.id = "twc-table-styles";
|
|
9551
|
-
el.textContent = TABLE_CSS;
|
|
9552
|
-
document.head.appendChild(el);
|
|
9553
|
-
}, []);
|
|
9554
|
-
const cols = React22__default.default.useMemo(
|
|
9346
|
+
const __twcStyles = useScopedStyles("twc-table-styles", TABLE_CSS);
|
|
9347
|
+
const cols = React23__namespace.default.useMemo(
|
|
9555
9348
|
() => (columns || []).map((c) => ({ ...c, header: c.headerName, render: c.renderCell })),
|
|
9556
9349
|
[columns]
|
|
9557
9350
|
);
|
|
9558
9351
|
const dataRows = rowsProp || [];
|
|
9559
|
-
const [internalSort, setInternalSort] =
|
|
9352
|
+
const [internalSort, setInternalSort] = React23__namespace.default.useState(defaultSort || { field: null, dir: "asc" });
|
|
9560
9353
|
const sort = (sortProp !== void 0 ? sortProp : internalSort) || { field: null, dir: "asc" };
|
|
9561
|
-
const rows =
|
|
9354
|
+
const rows = React23__namespace.default.useMemo(() => {
|
|
9562
9355
|
if (!sortable || !sort.field) return dataRows;
|
|
9563
9356
|
const col = cols.find((c) => c.field === sort.field);
|
|
9564
9357
|
if (!col) return dataRows;
|
|
@@ -9579,32 +9372,35 @@ function Table({
|
|
|
9579
9372
|
const keyFn = rowKey || ((_, i) => i);
|
|
9580
9373
|
const selected = new Set(selectedKeys || []);
|
|
9581
9374
|
const wrapStyle = maxHeight !== void 0 ? { ...rest.style, maxHeight, overflowY: "auto" } : rest.style;
|
|
9582
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
"
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
/* @__PURE__ */ jsxRuntime.
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9375
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-table-wrap ${className}`, ...rest, style: wrapStyle, children: [
|
|
9376
|
+
__twcStyles,
|
|
9377
|
+
/* @__PURE__ */ jsxRuntime.jsxs("table", { className: "twc-table", "data-hover": hover || void 0, "data-striped": striped || void 0, "data-size": size, "data-sticky": stickyHeader || void 0, children: [
|
|
9378
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: cols.map((c) => {
|
|
9379
|
+
const active = sort.field === c.field;
|
|
9380
|
+
const canSort = sortable && c.sortable !== false;
|
|
9381
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9382
|
+
"th",
|
|
9383
|
+
{
|
|
9384
|
+
"data-align": c.align,
|
|
9385
|
+
"data-sortable": canSort || void 0,
|
|
9386
|
+
"data-active": active || void 0,
|
|
9387
|
+
"data-dir": active ? sort.dir : void 0,
|
|
9388
|
+
style: c.width ? { width: c.width } : void 0,
|
|
9389
|
+
"aria-sort": active ? sort.dir === "asc" ? "ascending" : "descending" : canSort ? "none" : void 0,
|
|
9390
|
+
children: canSort ? /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "twc-table__sort", onClick: () => toggleSort(c.field), children: [
|
|
9391
|
+
c.header,
|
|
9392
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m18 15-6-6-6 6" }) })
|
|
9393
|
+
] }) : c.header
|
|
9394
|
+
},
|
|
9395
|
+
c.field
|
|
9396
|
+
);
|
|
9397
|
+
}) }) }),
|
|
9398
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: rows.map((row, i) => {
|
|
9399
|
+
const k = keyFn(row, i);
|
|
9400
|
+
return /* @__PURE__ */ jsxRuntime.jsx("tr", { "data-selected": selected.has(k) || void 0, children: cols.map((c) => /* @__PURE__ */ jsxRuntime.jsx("td", { "data-align": c.align, children: c.render ? c.render(row[c.field], row, i) : row[c.field] }, c.field)) }, k);
|
|
9401
|
+
}) })
|
|
9402
|
+
] })
|
|
9403
|
+
] });
|
|
9608
9404
|
}
|
|
9609
9405
|
var TABS_CSS = `
|
|
9610
9406
|
.twc-tabs { font-family: var(--font-sans); }
|
|
@@ -9680,31 +9476,25 @@ function Tabs({
|
|
|
9680
9476
|
...rest
|
|
9681
9477
|
}) {
|
|
9682
9478
|
const vertical = orientation === "vertical";
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
const el = document.createElement("style");
|
|
9686
|
-
el.id = "twc-tabs-styles";
|
|
9687
|
-
el.textContent = TABS_CSS;
|
|
9688
|
-
document.head.appendChild(el);
|
|
9689
|
-
}, []);
|
|
9690
|
-
const [internal, setInternal] = React22__default.default.useState(defaultValue ?? items[0]?.value);
|
|
9479
|
+
const __twcStyles = useScopedStyles("twc-tabs-styles", TABS_CSS);
|
|
9480
|
+
const [internal, setInternal] = React23__namespace.default.useState(defaultValue ?? items[0]?.value);
|
|
9691
9481
|
const active = value ?? internal;
|
|
9692
|
-
const listRef =
|
|
9693
|
-
const [ind, setInd] =
|
|
9694
|
-
const baseId =
|
|
9482
|
+
const listRef = React23__namespace.default.useRef(null);
|
|
9483
|
+
const [ind, setInd] = React23__namespace.default.useState({ left: 0, width: 0, top: 0, height: 0 });
|
|
9484
|
+
const baseId = React23__namespace.default.useId();
|
|
9695
9485
|
const tabIdAt = (i) => `${baseId}-tab-${i}`;
|
|
9696
9486
|
const panelId = `${baseId}-panel`;
|
|
9697
9487
|
const activeIndex = items.findIndex((it) => it.value === active);
|
|
9698
|
-
const updateIndicator =
|
|
9488
|
+
const updateIndicator = React23__namespace.default.useCallback(() => {
|
|
9699
9489
|
const list = listRef.current;
|
|
9700
9490
|
if (!list) return;
|
|
9701
9491
|
const el = list.querySelector('[data-active="true"]');
|
|
9702
9492
|
if (el) setInd({ left: el.offsetLeft, width: el.offsetWidth, top: el.offsetTop, height: el.offsetHeight });
|
|
9703
9493
|
}, []);
|
|
9704
|
-
|
|
9494
|
+
React23__namespace.default.useEffect(() => {
|
|
9705
9495
|
updateIndicator();
|
|
9706
9496
|
}, [active, updateIndicator, items, orientation]);
|
|
9707
|
-
|
|
9497
|
+
React23__namespace.default.useEffect(() => {
|
|
9708
9498
|
const r = () => updateIndicator();
|
|
9709
9499
|
window.addEventListener("resize", r);
|
|
9710
9500
|
if (typeof document !== "undefined" && document.fonts && document.fonts.ready) {
|
|
@@ -9741,6 +9531,7 @@ function Tabs({
|
|
|
9741
9531
|
if (btns && btns[i]) btns[i].focus();
|
|
9742
9532
|
}
|
|
9743
9533
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-tabs ${className}`, "data-variant": variant, "data-tone": tone, "data-orientation": orientation, ...rest, children: [
|
|
9534
|
+
__twcStyles,
|
|
9744
9535
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-tabs__list", ref: listRef, role: "tablist", "aria-orientation": orientation, onKeyDown: onListKeyDown, children: [
|
|
9745
9536
|
items.map((it, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9746
9537
|
"button",
|
|
@@ -9819,14 +9610,9 @@ function Tag({
|
|
|
9819
9610
|
className = "",
|
|
9820
9611
|
...rest
|
|
9821
9612
|
}) {
|
|
9822
|
-
|
|
9823
|
-
if (document.getElementById("twc-tag-styles")) return;
|
|
9824
|
-
const el = document.createElement("style");
|
|
9825
|
-
el.id = "twc-tag-styles";
|
|
9826
|
-
el.textContent = TAG_CSS;
|
|
9827
|
-
document.head.appendChild(el);
|
|
9828
|
-
}, []);
|
|
9613
|
+
const __twcStyles = useScopedStyles("twc-tag-styles", TAG_CSS);
|
|
9829
9614
|
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: `twc-tag ${className}`, "data-tone": tone, "data-variant": variant, "data-no-remove": !onRemove || void 0, ...rest, children: [
|
|
9615
|
+
__twcStyles,
|
|
9830
9616
|
leftIcon,
|
|
9831
9617
|
children,
|
|
9832
9618
|
onRemove ? /* @__PURE__ */ jsxRuntime.jsx("button", { className: "twc-tag__remove", onClick: (e) => {
|
|
@@ -9848,11 +9634,7 @@ function Textarea({
|
|
|
9848
9634
|
className = "",
|
|
9849
9635
|
...rest
|
|
9850
9636
|
}) {
|
|
9851
|
-
|
|
9852
|
-
if (document.getElementById("twc-textarea-styles")) return;
|
|
9853
|
-
const el = document.createElement("style");
|
|
9854
|
-
el.id = "twc-textarea-styles";
|
|
9855
|
-
el.textContent = `
|
|
9637
|
+
const __twcStyles = useScopedStyles("twc-textarea-styles", `
|
|
9856
9638
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
9857
9639
|
.twc-field__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); display: flex; gap: 4px; align-items: center; }
|
|
9858
9640
|
.twc-field__req { color: var(--color-danger); }
|
|
@@ -9881,14 +9663,13 @@ function Textarea({
|
|
|
9881
9663
|
.twc-textarea__el:focus { border-color: var(--_accent); box-shadow: var(--_ring); }
|
|
9882
9664
|
.twc-textarea__el[aria-invalid="true"] { border-color: var(--color-danger); }
|
|
9883
9665
|
.twc-textarea__el:disabled { background: var(--color-surface-sunken); opacity: 0.7; cursor: not-allowed; }
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
}, []);
|
|
9887
|
-
const autoId = React22__default.default.useId();
|
|
9666
|
+
`);
|
|
9667
|
+
const autoId = React23__namespace.default.useId();
|
|
9888
9668
|
const fieldId = id || autoId;
|
|
9889
9669
|
const descId = `${fieldId}-desc`;
|
|
9890
9670
|
const invalid = Boolean(error);
|
|
9891
9671
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-field ${className}`, children: [
|
|
9672
|
+
__twcStyles,
|
|
9892
9673
|
label ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
9893
9674
|
label,
|
|
9894
9675
|
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
@@ -9936,26 +9717,23 @@ var TIMELINE_CSS = `
|
|
|
9936
9717
|
.twc-timeline__desc { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 2px; line-height: var(--leading-snug); }
|
|
9937
9718
|
`;
|
|
9938
9719
|
function Timeline({ items, className = "", ...rest }) {
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: `twc-timeline ${className}`, ...rest, children: items.map((it, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "twc-timeline__item", "data-tone": it.tone || void 0, children: [
|
|
9947
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-timeline__rail", children: [
|
|
9948
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-timeline__dot", "aria-hidden": "true", children: it.icon || null }),
|
|
9949
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-timeline__line" })
|
|
9950
|
-
] }),
|
|
9951
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-timeline__body", children: [
|
|
9952
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-timeline__head", children: [
|
|
9953
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-timeline__title", children: it.title }),
|
|
9954
|
-
it.time ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-timeline__time", children: it.time }) : null
|
|
9720
|
+
const __twcStyles = useScopedStyles("twc-timeline-styles", TIMELINE_CSS);
|
|
9721
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: `twc-timeline ${className}`, ...rest, children: [
|
|
9722
|
+
__twcStyles,
|
|
9723
|
+
items.map((it, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "twc-timeline__item", "data-tone": it.tone || void 0, children: [
|
|
9724
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-timeline__rail", children: [
|
|
9725
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-timeline__dot", "aria-hidden": "true", children: it.icon || null }),
|
|
9726
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-timeline__line" })
|
|
9955
9727
|
] }),
|
|
9956
|
-
|
|
9957
|
-
|
|
9958
|
-
|
|
9728
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-timeline__body", children: [
|
|
9729
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-timeline__head", children: [
|
|
9730
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-timeline__title", children: it.title }),
|
|
9731
|
+
it.time ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-timeline__time", children: it.time }) : null
|
|
9732
|
+
] }),
|
|
9733
|
+
it.description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-timeline__desc", children: it.description }) : null
|
|
9734
|
+
] })
|
|
9735
|
+
] }, i))
|
|
9736
|
+
] });
|
|
9959
9737
|
}
|
|
9960
9738
|
var TOAST_CSS = `
|
|
9961
9739
|
.twc-toast {
|
|
@@ -10023,26 +9801,20 @@ function Toast({
|
|
|
10023
9801
|
...rest
|
|
10024
9802
|
}) {
|
|
10025
9803
|
const resolvedTone = tone === "neutral" ? "default" : tone;
|
|
10026
|
-
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
el.id = "twc-toast-styles";
|
|
10030
|
-
el.textContent = TOAST_CSS;
|
|
10031
|
-
document.head.appendChild(el);
|
|
10032
|
-
}, []);
|
|
10033
|
-
const onCloseRef = React22__default.default.useRef(onClose);
|
|
10034
|
-
React22__default.default.useEffect(() => {
|
|
9804
|
+
const __twcStyles = useScopedStyles("twc-toast-styles", TOAST_CSS);
|
|
9805
|
+
const onCloseRef = React23__namespace.default.useRef(onClose);
|
|
9806
|
+
React23__namespace.default.useEffect(() => {
|
|
10035
9807
|
onCloseRef.current = onClose;
|
|
10036
9808
|
}, [onClose]);
|
|
10037
|
-
const timer =
|
|
10038
|
-
const stop =
|
|
10039
|
-
const start =
|
|
9809
|
+
const timer = React23__namespace.default.useRef();
|
|
9810
|
+
const stop = React23__namespace.default.useCallback(() => clearTimeout(timer.current), []);
|
|
9811
|
+
const start = React23__namespace.default.useCallback(() => {
|
|
10040
9812
|
stop();
|
|
10041
9813
|
if (duration && duration !== Infinity && onCloseRef.current) {
|
|
10042
9814
|
timer.current = setTimeout(() => onCloseRef.current && onCloseRef.current(), duration);
|
|
10043
9815
|
}
|
|
10044
9816
|
}, [duration, stop]);
|
|
10045
|
-
|
|
9817
|
+
React23__namespace.default.useEffect(() => {
|
|
10046
9818
|
start();
|
|
10047
9819
|
return stop;
|
|
10048
9820
|
}, [start, stop]);
|
|
@@ -10070,6 +9842,7 @@ function Toast({
|
|
|
10070
9842
|
start();
|
|
10071
9843
|
},
|
|
10072
9844
|
children: [
|
|
9845
|
+
__twcStyles,
|
|
10073
9846
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-toast__icon", "aria-hidden": "true", children: icon || /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
10074
9847
|
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
10075
9848
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: TOAST_ICONS[resolvedTone] || TOAST_ICONS.default })
|
|
@@ -10084,34 +9857,31 @@ function Toast({
|
|
|
10084
9857
|
);
|
|
10085
9858
|
}
|
|
10086
9859
|
function ToastViewport({ children, limit, className = "", ...rest }) {
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
}, []);
|
|
10094
|
-
const shown = limit && limit > 0 ? React22__default.default.Children.toArray(children).slice(-limit) : children;
|
|
10095
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `twc-toast-viewport ${className}`, ...rest, children: shown });
|
|
9860
|
+
const __twcStyles = useScopedStyles("twc-toast-styles", TOAST_CSS);
|
|
9861
|
+
const shown = limit && limit > 0 ? React23__namespace.default.Children.toArray(children).slice(-limit) : children;
|
|
9862
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-toast-viewport ${className}`, ...rest, children: [
|
|
9863
|
+
__twcStyles,
|
|
9864
|
+
shown
|
|
9865
|
+
] });
|
|
10096
9866
|
}
|
|
10097
|
-
var ToastContext =
|
|
9867
|
+
var ToastContext = React23__namespace.default.createContext(null);
|
|
10098
9868
|
function useToast() {
|
|
10099
|
-
const ctx =
|
|
9869
|
+
const ctx = React23__namespace.default.useContext(ToastContext);
|
|
10100
9870
|
if (!ctx) throw new Error("useToast must be used within a <ToastProvider>.");
|
|
10101
9871
|
return ctx;
|
|
10102
9872
|
}
|
|
10103
9873
|
function ToastProvider({ children, limit = 4, duration = 4500, ...viewportProps }) {
|
|
10104
|
-
const [toasts, setToasts] =
|
|
10105
|
-
const idRef =
|
|
10106
|
-
const limitRef =
|
|
10107
|
-
|
|
9874
|
+
const [toasts, setToasts] = React23__namespace.default.useState([]);
|
|
9875
|
+
const idRef = React23__namespace.default.useRef(0);
|
|
9876
|
+
const limitRef = React23__namespace.default.useRef(limit);
|
|
9877
|
+
React23__namespace.default.useEffect(() => {
|
|
10108
9878
|
limitRef.current = limit;
|
|
10109
9879
|
}, [limit]);
|
|
10110
|
-
const dismiss =
|
|
9880
|
+
const dismiss = React23__namespace.default.useCallback((id) => {
|
|
10111
9881
|
setToasts((s) => s.filter((t) => t.id !== id));
|
|
10112
9882
|
}, []);
|
|
10113
|
-
const clear =
|
|
10114
|
-
const api =
|
|
9883
|
+
const clear = React23__namespace.default.useCallback(() => setToasts([]), []);
|
|
9884
|
+
const api = React23__namespace.default.useMemo(() => {
|
|
10115
9885
|
const push = (opts) => {
|
|
10116
9886
|
const id = idRef.current += 1;
|
|
10117
9887
|
const next = typeof opts === "string" ? { title: opts } : opts && typeof opts === "object" ? opts : {};
|
|
@@ -10132,7 +9902,7 @@ function ToastProvider({ children, limit = 4, duration = 4500, ...viewportProps
|
|
|
10132
9902
|
toast.show = withTone("default");
|
|
10133
9903
|
return { toast, dismiss, clear };
|
|
10134
9904
|
}, [dismiss, clear]);
|
|
10135
|
-
const value =
|
|
9905
|
+
const value = React23__namespace.default.useMemo(() => ({ ...api, toasts }), [api, toasts]);
|
|
10136
9906
|
return /* @__PURE__ */ jsxRuntime.jsxs(ToastContext.Provider, { value, children: [
|
|
10137
9907
|
children,
|
|
10138
9908
|
/* @__PURE__ */ jsxRuntime.jsx(ToastViewport, { limit, ...viewportProps, children: toasts.map((t) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -10180,19 +9950,13 @@ function Tooltip({
|
|
|
10180
9950
|
className = "",
|
|
10181
9951
|
...rest
|
|
10182
9952
|
}) {
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
const id = React22__default.default.useId();
|
|
10191
|
-
const [show, setShow] = React22__default.default.useState(false);
|
|
10192
|
-
const [coords, setCoords] = React22__default.default.useState(null);
|
|
10193
|
-
const timer = React22__default.default.useRef(null);
|
|
10194
|
-
const wrapRef = React22__default.default.useRef(null);
|
|
10195
|
-
const tipRef = React22__default.default.useRef(null);
|
|
9953
|
+
const __twcStyles = useScopedStyles("twc-tooltip-styles", TOOLTIP_CSS);
|
|
9954
|
+
const id = React23__namespace.default.useId();
|
|
9955
|
+
const [show, setShow] = React23__namespace.default.useState(false);
|
|
9956
|
+
const [coords, setCoords] = React23__namespace.default.useState(null);
|
|
9957
|
+
const timer = React23__namespace.default.useRef(null);
|
|
9958
|
+
const wrapRef = React23__namespace.default.useRef(null);
|
|
9959
|
+
const tipRef = React23__namespace.default.useRef(null);
|
|
10196
9960
|
const open = () => {
|
|
10197
9961
|
clearTimeout(timer.current);
|
|
10198
9962
|
timer.current = setTimeout(() => setShow(true), delay);
|
|
@@ -10201,8 +9965,8 @@ function Tooltip({
|
|
|
10201
9965
|
clearTimeout(timer.current);
|
|
10202
9966
|
setShow(false);
|
|
10203
9967
|
};
|
|
10204
|
-
|
|
10205
|
-
const place =
|
|
9968
|
+
React23__namespace.default.useEffect(() => () => clearTimeout(timer.current), []);
|
|
9969
|
+
const place = React23__namespace.default.useCallback(() => {
|
|
10206
9970
|
const el = wrapRef.current;
|
|
10207
9971
|
if (!el) return;
|
|
10208
9972
|
const r = el.getBoundingClientRect();
|
|
@@ -10218,10 +9982,10 @@ function Tooltip({
|
|
|
10218
9982
|
else if (placement === "right") setCoords({ ...base, top: clampY(cy), left: Math.round(r.right + gap) });
|
|
10219
9983
|
else setCoords({ ...base, left: clampX(cx), bottom: Math.round(vh - r.top + gap) });
|
|
10220
9984
|
}, [placement]);
|
|
10221
|
-
|
|
9985
|
+
React23__namespace.default.useEffect(() => {
|
|
10222
9986
|
place();
|
|
10223
9987
|
}, [place]);
|
|
10224
|
-
|
|
9988
|
+
React23__namespace.default.useEffect(() => {
|
|
10225
9989
|
if (!show) return void 0;
|
|
10226
9990
|
place();
|
|
10227
9991
|
const onMove = () => place();
|
|
@@ -10232,7 +9996,7 @@ function Tooltip({
|
|
|
10232
9996
|
window.removeEventListener("resize", onMove);
|
|
10233
9997
|
};
|
|
10234
9998
|
}, [show, place]);
|
|
10235
|
-
|
|
9999
|
+
React23__namespace.default.useEffect(() => {
|
|
10236
10000
|
if (!show) return;
|
|
10237
10001
|
const onKeyDown = (e) => {
|
|
10238
10002
|
if (e.key === "Escape") {
|
|
@@ -10244,7 +10008,7 @@ function Tooltip({
|
|
|
10244
10008
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
10245
10009
|
}, [show]);
|
|
10246
10010
|
const describedBy = show ? id : void 0;
|
|
10247
|
-
const trigger =
|
|
10011
|
+
const trigger = React23__namespace.default.isValidElement(children) && children.type !== React23__namespace.default.Fragment ? React23__namespace.default.cloneElement(children, {
|
|
10248
10012
|
"aria-describedby": [children.props["aria-describedby"], describedBy].filter(Boolean).join(" ") || void 0
|
|
10249
10013
|
}) : /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-describedby": describedBy, children });
|
|
10250
10014
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -10258,6 +10022,7 @@ function Tooltip({
|
|
|
10258
10022
|
onBlur: close,
|
|
10259
10023
|
...rest,
|
|
10260
10024
|
children: [
|
|
10025
|
+
__twcStyles,
|
|
10261
10026
|
trigger,
|
|
10262
10027
|
coords ? reactDom.createPortal(
|
|
10263
10028
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -10369,19 +10134,13 @@ function TreeView({
|
|
|
10369
10134
|
...rest
|
|
10370
10135
|
}) {
|
|
10371
10136
|
const nodes = items;
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
const el = document.createElement("style");
|
|
10375
|
-
el.id = "twc-tree-styles";
|
|
10376
|
-
el.textContent = TREE_CSS;
|
|
10377
|
-
document.head.appendChild(el);
|
|
10378
|
-
}, []);
|
|
10379
|
-
const [expInternal, setExpInternal] = React22__default.default.useState(() => new Set(defaultExpanded));
|
|
10137
|
+
const __twcStyles = useScopedStyles("twc-tree-styles", TREE_CSS);
|
|
10138
|
+
const [expInternal, setExpInternal] = React23__namespace.default.useState(() => new Set(defaultExpanded));
|
|
10380
10139
|
const expanded = expandedProp !== void 0 ? new Set(expandedProp) : expInternal;
|
|
10381
|
-
const [selInternal, setSelInternal] =
|
|
10140
|
+
const [selInternal, setSelInternal] = React23__namespace.default.useState(defaultSelectedId);
|
|
10382
10141
|
const selectedId = selectedProp !== void 0 ? selectedProp : selInternal;
|
|
10383
|
-
const [focusId, setFocusId] =
|
|
10384
|
-
const rowRefs =
|
|
10142
|
+
const [focusId, setFocusId] = React23__namespace.default.useState(null);
|
|
10143
|
+
const rowRefs = React23__namespace.default.useRef(/* @__PURE__ */ new Map());
|
|
10385
10144
|
const toggle = (id) => {
|
|
10386
10145
|
const n = new Set(expanded);
|
|
10387
10146
|
n.has(id) ? n.delete(id) : n.add(id);
|
|
@@ -10440,21 +10199,24 @@ function TreeView({
|
|
|
10440
10199
|
e.preventDefault();
|
|
10441
10200
|
if (next != null) focusRow(next);
|
|
10442
10201
|
};
|
|
10443
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
10444
|
-
|
|
10445
|
-
{
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10202
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-tree ${className}`, role: "tree", onKeyDown, ...rest, children: [
|
|
10203
|
+
__twcStyles,
|
|
10204
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "twc-tree__group", role: "none", children: nodes.map((n) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
10205
|
+
Node,
|
|
10206
|
+
{
|
|
10207
|
+
node: n,
|
|
10208
|
+
depth: 0,
|
|
10209
|
+
expanded,
|
|
10210
|
+
selectedId,
|
|
10211
|
+
tabbableId,
|
|
10212
|
+
rowRefs,
|
|
10213
|
+
onToggle: toggle,
|
|
10214
|
+
onSelect: select,
|
|
10215
|
+
onRowFocus: setFocusId
|
|
10216
|
+
},
|
|
10217
|
+
n.id
|
|
10218
|
+
)) })
|
|
10219
|
+
] });
|
|
10458
10220
|
}
|
|
10459
10221
|
function sp(v) {
|
|
10460
10222
|
if (v == null) return void 0;
|
|
@@ -10654,15 +10416,12 @@ function safeHref8(url) {
|
|
|
10654
10416
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
10655
10417
|
}
|
|
10656
10418
|
function Code({ as: Tag2 = "code", className = "", children, ...rest }) {
|
|
10657
|
-
|
|
10658
|
-
if (document.getElementById("twc-code-styles")) return;
|
|
10659
|
-
const el = document.createElement("style");
|
|
10660
|
-
el.id = "twc-code-styles";
|
|
10661
|
-
el.textContent = CODE_CSS;
|
|
10662
|
-
document.head.appendChild(el);
|
|
10663
|
-
}, []);
|
|
10419
|
+
const __twcStyles = useScopedStyles("twc-code-styles", CODE_CSS);
|
|
10664
10420
|
if (Tag2 === "a" && rest.href != null) rest.href = safeHref8(rest.href);
|
|
10665
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
10421
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Tag2, { className: `twc-code ${className}`.trim(), ...rest, children: [
|
|
10422
|
+
__twcStyles,
|
|
10423
|
+
children
|
|
10424
|
+
] });
|
|
10666
10425
|
}
|
|
10667
10426
|
var LEVEL_SIZE = { 1: "4xl", 2: "2xl", 3: "xl", 4: "lg", 5: "base", 6: "sm" };
|
|
10668
10427
|
function safeHref9(url) {
|
|
@@ -10753,44 +10512,44 @@ function Text({
|
|
|
10753
10512
|
);
|
|
10754
10513
|
}
|
|
10755
10514
|
var canUseDOM = typeof window !== "undefined" && typeof document !== "undefined";
|
|
10756
|
-
var useIsomorphicLayoutEffect = canUseDOM ?
|
|
10515
|
+
var useIsomorphicLayoutEffect = canUseDOM ? React23__namespace.default.useLayoutEffect : React23__namespace.default.useEffect;
|
|
10757
10516
|
function useMounted() {
|
|
10758
|
-
const [mounted, setMounted] =
|
|
10759
|
-
|
|
10517
|
+
const [mounted, setMounted] = React23__namespace.default.useState(false);
|
|
10518
|
+
React23__namespace.default.useEffect(() => {
|
|
10760
10519
|
setMounted(true);
|
|
10761
10520
|
}, []);
|
|
10762
10521
|
return mounted;
|
|
10763
10522
|
}
|
|
10764
10523
|
function usePrevious(value) {
|
|
10765
|
-
const ref =
|
|
10766
|
-
|
|
10524
|
+
const ref = React23__namespace.default.useRef(void 0);
|
|
10525
|
+
React23__namespace.default.useEffect(() => {
|
|
10767
10526
|
ref.current = value;
|
|
10768
10527
|
}, [value]);
|
|
10769
10528
|
return ref.current;
|
|
10770
10529
|
}
|
|
10771
10530
|
function useToggle(initial = false) {
|
|
10772
|
-
const [on, setOn] =
|
|
10773
|
-
const toggle =
|
|
10531
|
+
const [on, setOn] = React23__namespace.default.useState(initial);
|
|
10532
|
+
const toggle = React23__namespace.default.useCallback((next) => {
|
|
10774
10533
|
setOn((prev) => typeof next === "boolean" ? next : !prev);
|
|
10775
10534
|
}, []);
|
|
10776
10535
|
return [on, toggle, setOn];
|
|
10777
10536
|
}
|
|
10778
10537
|
function useDisclosure(initial = false) {
|
|
10779
|
-
const [open, setOpen] =
|
|
10780
|
-
const onOpen =
|
|
10781
|
-
const onClose =
|
|
10782
|
-
const onToggle =
|
|
10538
|
+
const [open, setOpen] = React23__namespace.default.useState(initial);
|
|
10539
|
+
const onOpen = React23__namespace.default.useCallback(() => setOpen(true), []);
|
|
10540
|
+
const onClose = React23__namespace.default.useCallback(() => setOpen(false), []);
|
|
10541
|
+
const onToggle = React23__namespace.default.useCallback(() => setOpen((p) => !p), []);
|
|
10783
10542
|
return { open, onOpen, onClose, onToggle, setOpen };
|
|
10784
10543
|
}
|
|
10785
10544
|
function useControllableState({ value, defaultValue, onChange } = {}) {
|
|
10786
10545
|
const isControlled = value !== void 0;
|
|
10787
|
-
const [uncontrolled, setUncontrolled] =
|
|
10546
|
+
const [uncontrolled, setUncontrolled] = React23__namespace.default.useState(defaultValue);
|
|
10788
10547
|
const current = isControlled ? value : uncontrolled;
|
|
10789
|
-
const ref =
|
|
10548
|
+
const ref = React23__namespace.default.useRef({ current, isControlled, onChange });
|
|
10790
10549
|
useIsomorphicLayoutEffect(() => {
|
|
10791
10550
|
ref.current = { current, isControlled, onChange };
|
|
10792
10551
|
});
|
|
10793
|
-
const setValue =
|
|
10552
|
+
const setValue = React23__namespace.default.useCallback((next) => {
|
|
10794
10553
|
const { current: cur, isControlled: ctrl, onChange: cb } = ref.current;
|
|
10795
10554
|
const resolved = typeof next === "function" ? next(cur) : next;
|
|
10796
10555
|
if (resolved === cur) return;
|
|
@@ -10801,8 +10560,8 @@ function useControllableState({ value, defaultValue, onChange } = {}) {
|
|
|
10801
10560
|
}
|
|
10802
10561
|
function useMediaQuery(query) {
|
|
10803
10562
|
const get = () => canUseDOM ? window.matchMedia(query).matches : false;
|
|
10804
|
-
const [matches3, setMatches] =
|
|
10805
|
-
|
|
10563
|
+
const [matches3, setMatches] = React23__namespace.default.useState(get);
|
|
10564
|
+
React23__namespace.default.useEffect(() => {
|
|
10806
10565
|
if (!canUseDOM) return void 0;
|
|
10807
10566
|
const mql = window.matchMedia(query);
|
|
10808
10567
|
const onChange = () => setMatches(mql.matches);
|
|
@@ -10817,7 +10576,7 @@ function usePrefersReducedMotion() {
|
|
|
10817
10576
|
}
|
|
10818
10577
|
function useColorScheme({ storageKey = "twico-theme", attribute = "class", element, disableTransitionsOnChange = true } = {}) {
|
|
10819
10578
|
const getTarget = () => element || (canUseDOM ? document.documentElement : null);
|
|
10820
|
-
const firstApply =
|
|
10579
|
+
const firstApply = React23__namespace.default.useRef(true);
|
|
10821
10580
|
const read = () => {
|
|
10822
10581
|
if (!canUseDOM) return "light";
|
|
10823
10582
|
try {
|
|
@@ -10827,8 +10586,8 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
10827
10586
|
}
|
|
10828
10587
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
10829
10588
|
};
|
|
10830
|
-
const [theme, setThemeState] =
|
|
10831
|
-
const apply =
|
|
10589
|
+
const [theme, setThemeState] = React23__namespace.default.useState(read);
|
|
10590
|
+
const apply = React23__namespace.default.useCallback(
|
|
10832
10591
|
(t) => {
|
|
10833
10592
|
const target = getTarget();
|
|
10834
10593
|
if (!target) return;
|
|
@@ -10854,11 +10613,11 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
10854
10613
|
useIsomorphicLayoutEffect(() => {
|
|
10855
10614
|
apply(theme);
|
|
10856
10615
|
}, [theme, apply]);
|
|
10857
|
-
const themeRef =
|
|
10616
|
+
const themeRef = React23__namespace.default.useRef(theme);
|
|
10858
10617
|
useIsomorphicLayoutEffect(() => {
|
|
10859
10618
|
themeRef.current = theme;
|
|
10860
10619
|
}, [theme]);
|
|
10861
|
-
const setTheme =
|
|
10620
|
+
const setTheme = React23__namespace.default.useCallback(
|
|
10862
10621
|
(t) => {
|
|
10863
10622
|
setThemeState(t);
|
|
10864
10623
|
try {
|
|
@@ -10869,10 +10628,10 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
10869
10628
|
},
|
|
10870
10629
|
[storageKey]
|
|
10871
10630
|
);
|
|
10872
|
-
const toggle =
|
|
10631
|
+
const toggle = React23__namespace.default.useCallback(() => {
|
|
10873
10632
|
setTheme(themeRef.current === "dark" ? "light" : "dark");
|
|
10874
10633
|
}, [setTheme]);
|
|
10875
|
-
|
|
10634
|
+
React23__namespace.default.useEffect(() => {
|
|
10876
10635
|
if (!canUseDOM) return void 0;
|
|
10877
10636
|
const sync = () => setThemeState(read());
|
|
10878
10637
|
const onStorage = (e) => {
|
|
@@ -10888,14 +10647,14 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
10888
10647
|
return { theme, setTheme, toggle, isDark: theme === "dark" };
|
|
10889
10648
|
}
|
|
10890
10649
|
function useEventListener(eventName, handler, element, options) {
|
|
10891
|
-
const saved =
|
|
10650
|
+
const saved = React23__namespace.default.useRef(handler);
|
|
10892
10651
|
useIsomorphicLayoutEffect(() => {
|
|
10893
10652
|
saved.current = handler;
|
|
10894
10653
|
}, [handler]);
|
|
10895
10654
|
const capture = typeof options === "boolean" ? options : options && options.capture;
|
|
10896
10655
|
const passive = typeof options === "object" && options ? options.passive : void 0;
|
|
10897
10656
|
const once = typeof options === "object" && options ? options.once : void 0;
|
|
10898
|
-
|
|
10657
|
+
React23__namespace.default.useEffect(() => {
|
|
10899
10658
|
const target = element && element.current || element || (canUseDOM ? window : null);
|
|
10900
10659
|
if (!target || !target.addEventListener) return void 0;
|
|
10901
10660
|
const opts = typeof options === "boolean" ? options : { capture, passive, once };
|
|
@@ -10905,11 +10664,11 @@ function useEventListener(eventName, handler, element, options) {
|
|
|
10905
10664
|
}, [eventName, element, capture, passive, once]);
|
|
10906
10665
|
}
|
|
10907
10666
|
function useClickOutside(ref, handler, events = ["mousedown", "touchstart"]) {
|
|
10908
|
-
const saved =
|
|
10667
|
+
const saved = React23__namespace.default.useRef(handler);
|
|
10909
10668
|
useIsomorphicLayoutEffect(() => {
|
|
10910
10669
|
saved.current = handler;
|
|
10911
10670
|
}, [handler]);
|
|
10912
|
-
|
|
10671
|
+
React23__namespace.default.useEffect(() => {
|
|
10913
10672
|
if (!canUseDOM) return void 0;
|
|
10914
10673
|
const listener = (e) => {
|
|
10915
10674
|
const el = ref && ref.current;
|
|
@@ -10944,8 +10703,8 @@ function useLocalStorage(key, initialValue) {
|
|
|
10944
10703
|
return initialValue;
|
|
10945
10704
|
}
|
|
10946
10705
|
};
|
|
10947
|
-
const [stored, setStored] =
|
|
10948
|
-
const setValue =
|
|
10706
|
+
const [stored, setStored] = React23__namespace.default.useState(read);
|
|
10707
|
+
const setValue = React23__namespace.default.useCallback(
|
|
10949
10708
|
(value) => {
|
|
10950
10709
|
setStored((prev) => {
|
|
10951
10710
|
const next = typeof value === "function" ? value(prev) : value;
|
|
@@ -10961,8 +10720,8 @@ function useLocalStorage(key, initialValue) {
|
|
|
10961
10720
|
return [stored, setValue];
|
|
10962
10721
|
}
|
|
10963
10722
|
function useCopyToClipboard(timeout = 1500) {
|
|
10964
|
-
const [copied, setCopied] =
|
|
10965
|
-
const copy =
|
|
10723
|
+
const [copied, setCopied] = React23__namespace.default.useState(false);
|
|
10724
|
+
const copy = React23__namespace.default.useCallback(async (text) => {
|
|
10966
10725
|
if (!canUseDOM || !navigator.clipboard) {
|
|
10967
10726
|
setCopied(false);
|
|
10968
10727
|
return false;
|
|
@@ -10976,7 +10735,7 @@ function useCopyToClipboard(timeout = 1500) {
|
|
|
10976
10735
|
return false;
|
|
10977
10736
|
}
|
|
10978
10737
|
}, []);
|
|
10979
|
-
|
|
10738
|
+
React23__namespace.default.useEffect(() => {
|
|
10980
10739
|
if (!copied) return void 0;
|
|
10981
10740
|
const t = setTimeout(() => setCopied(false), timeout);
|
|
10982
10741
|
return () => clearTimeout(t);
|
|
@@ -10984,23 +10743,23 @@ function useCopyToClipboard(timeout = 1500) {
|
|
|
10984
10743
|
return { copied, copy };
|
|
10985
10744
|
}
|
|
10986
10745
|
function useDebouncedValue(value, delay = 200) {
|
|
10987
|
-
const [debounced, setDebounced] =
|
|
10988
|
-
|
|
10746
|
+
const [debounced, setDebounced] = React23__namespace.default.useState(value);
|
|
10747
|
+
React23__namespace.default.useEffect(() => {
|
|
10989
10748
|
const t = setTimeout(() => setDebounced(value), delay);
|
|
10990
10749
|
return () => clearTimeout(t);
|
|
10991
10750
|
}, [value, delay]);
|
|
10992
10751
|
return debounced;
|
|
10993
10752
|
}
|
|
10994
10753
|
function useDebouncedCallback(callback, delay = 200) {
|
|
10995
|
-
const saved =
|
|
10996
|
-
const timer =
|
|
10754
|
+
const saved = React23__namespace.default.useRef(callback);
|
|
10755
|
+
const timer = React23__namespace.default.useRef(null);
|
|
10997
10756
|
useIsomorphicLayoutEffect(() => {
|
|
10998
10757
|
saved.current = callback;
|
|
10999
10758
|
}, [callback]);
|
|
11000
|
-
|
|
10759
|
+
React23__namespace.default.useEffect(() => () => {
|
|
11001
10760
|
if (timer.current) clearTimeout(timer.current);
|
|
11002
10761
|
}, []);
|
|
11003
|
-
return
|
|
10762
|
+
return React23__namespace.default.useCallback(
|
|
11004
10763
|
(...args) => {
|
|
11005
10764
|
if (timer.current) clearTimeout(timer.current);
|
|
11006
10765
|
timer.current = setTimeout(() => saved.current(...args), delay);
|
|
@@ -11009,33 +10768,33 @@ function useDebouncedCallback(callback, delay = 200) {
|
|
|
11009
10768
|
);
|
|
11010
10769
|
}
|
|
11011
10770
|
function useInterval(callback, delay) {
|
|
11012
|
-
const saved =
|
|
10771
|
+
const saved = React23__namespace.default.useRef(callback);
|
|
11013
10772
|
useIsomorphicLayoutEffect(() => {
|
|
11014
10773
|
saved.current = callback;
|
|
11015
10774
|
}, [callback]);
|
|
11016
|
-
|
|
10775
|
+
React23__namespace.default.useEffect(() => {
|
|
11017
10776
|
if (delay == null) return void 0;
|
|
11018
10777
|
const id = setInterval(() => saved.current(), delay);
|
|
11019
10778
|
return () => clearInterval(id);
|
|
11020
10779
|
}, [delay]);
|
|
11021
10780
|
}
|
|
11022
10781
|
function useTimeout(callback, delay) {
|
|
11023
|
-
const saved =
|
|
10782
|
+
const saved = React23__namespace.default.useRef(callback);
|
|
11024
10783
|
useIsomorphicLayoutEffect(() => {
|
|
11025
10784
|
saved.current = callback;
|
|
11026
10785
|
}, [callback]);
|
|
11027
|
-
|
|
10786
|
+
React23__namespace.default.useEffect(() => {
|
|
11028
10787
|
if (delay == null) return void 0;
|
|
11029
10788
|
const id = setTimeout(() => saved.current(), delay);
|
|
11030
10789
|
return () => clearTimeout(id);
|
|
11031
10790
|
}, [delay]);
|
|
11032
10791
|
}
|
|
11033
10792
|
function useWindowSize() {
|
|
11034
|
-
const [size, setSize] =
|
|
10793
|
+
const [size, setSize] = React23__namespace.default.useState(() => ({
|
|
11035
10794
|
width: canUseDOM ? window.innerWidth : 0,
|
|
11036
10795
|
height: canUseDOM ? window.innerHeight : 0
|
|
11037
10796
|
}));
|
|
11038
|
-
|
|
10797
|
+
React23__namespace.default.useEffect(() => {
|
|
11039
10798
|
if (!canUseDOM) return void 0;
|
|
11040
10799
|
const onResize = () => setSize({ width: window.innerWidth, height: window.innerHeight });
|
|
11041
10800
|
onResize();
|
|
@@ -11045,8 +10804,8 @@ function useWindowSize() {
|
|
|
11045
10804
|
return size;
|
|
11046
10805
|
}
|
|
11047
10806
|
function useHover(ref) {
|
|
11048
|
-
const [hovered, setHovered] =
|
|
11049
|
-
|
|
10807
|
+
const [hovered, setHovered] = React23__namespace.default.useState(false);
|
|
10808
|
+
React23__namespace.default.useEffect(() => {
|
|
11050
10809
|
const el = ref && ref.current;
|
|
11051
10810
|
if (!el) return void 0;
|
|
11052
10811
|
const on = () => setHovered(true);
|
|
@@ -11062,8 +10821,8 @@ function useHover(ref) {
|
|
|
11062
10821
|
}
|
|
11063
10822
|
function useIntersectionObserver(ref, options = {}) {
|
|
11064
10823
|
const { root = null, rootMargin = "0px", threshold = 0 } = options;
|
|
11065
|
-
const [entry, setEntry] =
|
|
11066
|
-
|
|
10824
|
+
const [entry, setEntry] = React23__namespace.default.useState(null);
|
|
10825
|
+
React23__namespace.default.useEffect(() => {
|
|
11067
10826
|
const el = ref && ref.current;
|
|
11068
10827
|
if (!canUseDOM || !el || typeof IntersectionObserver === "undefined") return void 0;
|
|
11069
10828
|
const obs = new IntersectionObserver(([e]) => setEntry(e), { root, rootMargin, threshold });
|
|
@@ -11091,7 +10850,7 @@ function useScrollLock(locked = true) {
|
|
|
11091
10850
|
}, [locked]);
|
|
11092
10851
|
}
|
|
11093
10852
|
function useId(prefix = "twc") {
|
|
11094
|
-
const raw =
|
|
10853
|
+
const raw = React23__namespace.default.useId();
|
|
11095
10854
|
return prefix ? `${prefix}-${raw.replace(/:/g, "")}` : raw;
|
|
11096
10855
|
}
|
|
11097
10856
|
|