twico-ui 1.8.0 → 1.8.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/CHANGELOG.md +8 -0
- package/dist/index.cjs +522 -519
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +522 -519
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var React36 = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactDom = require('react-dom');
|
|
7
7
|
|
|
@@ -23,14 +23,14 @@ function _interopNamespace(e) {
|
|
|
23
23
|
return Object.freeze(n);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var React36__namespace = /*#__PURE__*/_interopNamespace(React36);
|
|
27
27
|
|
|
28
28
|
// components/TwicoProvider.jsx
|
|
29
|
-
var SUPPORTS_STYLE_HOIST = parseInt(String(
|
|
30
|
-
var NonceContext =
|
|
29
|
+
var SUPPORTS_STYLE_HOIST = parseInt(String(React36__namespace.version), 10) >= 19;
|
|
30
|
+
var NonceContext = React36__namespace.createContext(void 0);
|
|
31
31
|
function useScopedStyles(id, css) {
|
|
32
|
-
const nonce =
|
|
33
|
-
|
|
32
|
+
const nonce = React36__namespace.useContext(NonceContext);
|
|
33
|
+
React36__namespace.useInsertionEffect(() => {
|
|
34
34
|
if (SUPPORTS_STYLE_HOIST) return;
|
|
35
35
|
if (typeof document === "undefined") return;
|
|
36
36
|
if (!css) return;
|
|
@@ -46,12 +46,12 @@ function useScopedStyles(id, css) {
|
|
|
46
46
|
}
|
|
47
47
|
if (el.textContent !== css) el.textContent = css;
|
|
48
48
|
}, [id, css, nonce]);
|
|
49
|
-
return SUPPORTS_STYLE_HOIST && css ?
|
|
49
|
+
return SUPPORTS_STYLE_HOIST && css ? React36__namespace.createElement("style", { href: id, precedence: "twc-ui", nonce }, css) : null;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// components/TwicoProvider.jsx
|
|
53
53
|
function TwicoProvider({ nonce, children }) {
|
|
54
|
-
return
|
|
54
|
+
return React36__namespace.default.createElement(NonceContext.Provider, { value: nonce }, children);
|
|
55
55
|
}
|
|
56
56
|
var GROUPS = { colors: "color", space: "space", radius: "radius", font: "font", shadow: "shadow", motion: "" };
|
|
57
57
|
function createTheme(partial = {}) {
|
|
@@ -71,8 +71,8 @@ function toVars(theme) {
|
|
|
71
71
|
return Object.keys(theme).some((k) => k.startsWith("--")) ? theme : createTheme(theme);
|
|
72
72
|
}
|
|
73
73
|
function ThemeProvider({ theme, mode = "inline", className = "", style, children, ...rest }) {
|
|
74
|
-
const vars =
|
|
75
|
-
const uid =
|
|
74
|
+
const vars = React36__namespace.default.useMemo(() => toVars(theme), [theme]);
|
|
75
|
+
const uid = React36__namespace.default.useId();
|
|
76
76
|
const scopeId = `twc-theme-${uid.replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
77
77
|
const css = mode === "stylesheet" ? `[data-twc-theme="${scopeId}"] { ${Object.entries(vars).map(([k, v]) => `${k}: ${v};`).join(" ")} }` : "";
|
|
78
78
|
const __twcStyles = useScopedStyles(mode === "stylesheet" ? scopeId : "twc-theme-noop", css);
|
|
@@ -94,7 +94,7 @@ var FORM_CSS = `
|
|
|
94
94
|
.twc-form { display: flex; flex-direction: column; gap: var(--space-4); font-family: var(--font-sans); }
|
|
95
95
|
.twc-form__fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: inherit; }
|
|
96
96
|
`;
|
|
97
|
-
var Form =
|
|
97
|
+
var Form = React36__namespace.default.forwardRef(function Form2({
|
|
98
98
|
onSubmit,
|
|
99
99
|
preventDefault = true,
|
|
100
100
|
loading = false,
|
|
@@ -129,7 +129,7 @@ Form.displayName = "Form";
|
|
|
129
129
|
var VH_CSS = `
|
|
130
130
|
.twc-visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
131
131
|
`;
|
|
132
|
-
var VisuallyHidden =
|
|
132
|
+
var VisuallyHidden = React36__namespace.default.forwardRef(function VisuallyHidden2({ as: Tag2 = "span", className = "", children, ...rest }, ref) {
|
|
133
133
|
const __twcStyles = useScopedStyles("twc-visually-hidden-styles", VH_CSS);
|
|
134
134
|
return /* @__PURE__ */ jsxRuntime.jsxs(Tag2, { ref, className: `twc-visually-hidden ${className}`.trim(), ...rest, children: [
|
|
135
135
|
__twcStyles,
|
|
@@ -138,10 +138,10 @@ var VisuallyHidden = React37__namespace.default.forwardRef(function VisuallyHidd
|
|
|
138
138
|
});
|
|
139
139
|
VisuallyHidden.displayName = "VisuallyHidden";
|
|
140
140
|
var canUseDOM = typeof window !== "undefined" && typeof document !== "undefined";
|
|
141
|
-
var useIsoLayoutEffect = canUseDOM ?
|
|
141
|
+
var useIsoLayoutEffect = canUseDOM ? React36__namespace.default.useLayoutEffect : React36__namespace.default.useEffect;
|
|
142
142
|
var FOCUSABLE = 'a[href]:not([tabindex="-1"]), button:not([disabled]):not([tabindex="-1"]), textarea:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([tabindex="-1"]), select:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])';
|
|
143
143
|
function useFocusTrap(ref, active = true, { restoreFocus = true, initialFocus } = {}) {
|
|
144
|
-
|
|
144
|
+
React36__namespace.default.useEffect(() => {
|
|
145
145
|
if (!active || !canUseDOM) return void 0;
|
|
146
146
|
const node = ref.current;
|
|
147
147
|
if (!node) return void 0;
|
|
@@ -152,7 +152,7 @@ function useFocusTrap(ref, active = true, { restoreFocus = true, initialFocus }
|
|
|
152
152
|
if (restoreFocus && prevFocused && typeof prevFocused.focus === "function") prevFocused.focus();
|
|
153
153
|
};
|
|
154
154
|
}, [active]);
|
|
155
|
-
|
|
155
|
+
React36__namespace.default.useEffect(() => {
|
|
156
156
|
if (!active || !canUseDOM) return void 0;
|
|
157
157
|
const node = ref.current;
|
|
158
158
|
const onKey = (e) => {
|
|
@@ -179,7 +179,7 @@ function useFocusTrap(ref, active = true, { restoreFocus = true, initialFocus }
|
|
|
179
179
|
}, [active]);
|
|
180
180
|
}
|
|
181
181
|
function usePortal() {
|
|
182
|
-
return
|
|
182
|
+
return React36__namespace.default.useCallback((node) => {
|
|
183
183
|
if (typeof document === "undefined") return null;
|
|
184
184
|
return typeof reactDom.createPortal === "function" ? reactDom.createPortal(node, document.body) : node;
|
|
185
185
|
}, []);
|
|
@@ -207,7 +207,7 @@ function useScrollLock(locked = true) {
|
|
|
207
207
|
}, [locked]);
|
|
208
208
|
}
|
|
209
209
|
function useInertBackground(ref, active) {
|
|
210
|
-
|
|
210
|
+
React36__namespace.default.useEffect(() => {
|
|
211
211
|
if (!active || !canUseDOM) return void 0;
|
|
212
212
|
const node = ref.current;
|
|
213
213
|
if (!node) return void 0;
|
|
@@ -232,14 +232,17 @@ function Portal({ children }) {
|
|
|
232
232
|
const render = usePortal();
|
|
233
233
|
return render(children);
|
|
234
234
|
}
|
|
235
|
+
function encodeScriptLiteral(value) {
|
|
236
|
+
return JSON.stringify(value).replace(/[<>&\u2028\u2029]/g, (c) => "\\u" + c.charCodeAt(0).toString(16).padStart(4, "0"));
|
|
237
|
+
}
|
|
235
238
|
function getColorSchemeScript({ storageKey = "twico-theme", attribute = "class", defaultScheme } = {}) {
|
|
236
|
-
const k =
|
|
237
|
-
const a =
|
|
238
|
-
const d = defaultScheme === "dark" || defaultScheme === "light" ?
|
|
239
|
+
const k = encodeScriptLiteral(storageKey);
|
|
240
|
+
const a = encodeScriptLiteral(attribute);
|
|
241
|
+
const d = defaultScheme === "dark" || defaultScheme === "light" ? encodeScriptLiteral(defaultScheme) : "null";
|
|
239
242
|
return `(function(){try{var k=${k},a=${a},d=${d},t=localStorage.getItem(k);if(t!=='light'){if(t!=='dark'){t=d?d:(window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light');}}if(a==='class'){document.documentElement.classList.toggle('dark',t==='dark');}else{document.documentElement.setAttribute(a,t);}}catch(e){}})();`;
|
|
240
243
|
}
|
|
241
244
|
function ColorSchemeScript({ storageKey = "twico-theme", attribute = "class", nonce, defaultScheme }) {
|
|
242
|
-
return
|
|
245
|
+
return React36__namespace.default.createElement("script", { nonce }, getColorSchemeScript({ storageKey, attribute, defaultScheme }));
|
|
243
246
|
}
|
|
244
247
|
var KBD_CSS = `
|
|
245
248
|
.twc-kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; padding: 2px 6px;
|
|
@@ -247,7 +250,7 @@ var KBD_CSS = `
|
|
|
247
250
|
background: var(--color-surface-sunken); border: var(--border-thin) solid var(--color-border);
|
|
248
251
|
border-bottom-width: 2px; border-radius: var(--radius-sm); }
|
|
249
252
|
`;
|
|
250
|
-
var Kbd =
|
|
253
|
+
var Kbd = React36__namespace.default.forwardRef(function Kbd2({ className = "", children, ...rest }, ref) {
|
|
251
254
|
const __twcStyles = useScopedStyles("twc-kbd-styles", KBD_CSS);
|
|
252
255
|
return /* @__PURE__ */ jsxRuntime.jsxs("kbd", { ref, className: `twc-kbd ${className}`.trim(), ...rest, children: [
|
|
253
256
|
__twcStyles,
|
|
@@ -262,7 +265,7 @@ var PRE_CSS = `
|
|
|
262
265
|
border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-lg);
|
|
263
266
|
white-space: pre; -webkit-overflow-scrolling: touch; }
|
|
264
267
|
`;
|
|
265
|
-
var Pre =
|
|
268
|
+
var Pre = React36__namespace.default.forwardRef(function Pre2({ className = "", children, ...rest }, ref) {
|
|
266
269
|
const __twcStyles = useScopedStyles("twc-pre-styles", PRE_CSS);
|
|
267
270
|
return /* @__PURE__ */ jsxRuntime.jsxs("pre", { ref, className: `twc-pre ${className}`.trim(), ...rest, children: [
|
|
268
271
|
__twcStyles,
|
|
@@ -282,7 +285,7 @@ function safeHref(url) {
|
|
|
282
285
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
283
286
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
284
287
|
}
|
|
285
|
-
var Anchor =
|
|
288
|
+
var Anchor = React36__namespace.default.forwardRef(function Anchor2({ as: Tag2 = "a", href, external = false, className = "", children, ...rest }, ref) {
|
|
286
289
|
const __twcStyles = useScopedStyles("twc-anchor-styles", ANCHOR_CSS);
|
|
287
290
|
const extra = external ? { target: "_blank", rel: "noopener noreferrer" } : {};
|
|
288
291
|
return /* @__PURE__ */ jsxRuntime.jsxs(Tag2, { ref, className: `twc-anchor ${className}`.trim(), href: Tag2 === "a" ? safeHref(href) : href, ...extra, ...rest, children: [
|
|
@@ -298,7 +301,7 @@ var LABEL_CSS = `
|
|
|
298
301
|
.twc-label[data-size="lg"] { font-size: var(--text-base); }
|
|
299
302
|
.twc-label__req { color: var(--color-danger); }
|
|
300
303
|
`;
|
|
301
|
-
var Label =
|
|
304
|
+
var Label = React36__namespace.default.forwardRef(function Label2({ htmlFor, required = false, size = "md", className = "", children, ...rest }, ref) {
|
|
302
305
|
const __twcStyles = useScopedStyles("twc-label-styles", LABEL_CSS);
|
|
303
306
|
return /* @__PURE__ */ jsxRuntime.jsxs("label", { ref, htmlFor, className: `twc-label ${className}`.trim(), "data-size": size, ...rest, children: [
|
|
304
307
|
__twcStyles,
|
|
@@ -311,7 +314,7 @@ var IMAGE_CSS = `
|
|
|
311
314
|
.twc-image { display: block; max-width: 100%; }
|
|
312
315
|
.twc-image[data-fit] { width: 100%; height: 100%; }
|
|
313
316
|
`;
|
|
314
|
-
var Image =
|
|
317
|
+
var Image = React36__namespace.default.forwardRef(function Image2({
|
|
315
318
|
src,
|
|
316
319
|
alt,
|
|
317
320
|
fit,
|
|
@@ -325,7 +328,7 @@ var Image = React37__namespace.default.forwardRef(function Image2({
|
|
|
325
328
|
...rest
|
|
326
329
|
}, ref) {
|
|
327
330
|
const __twcStyles = useScopedStyles("twc-image-styles", IMAGE_CSS);
|
|
328
|
-
const [failed, setFailed] =
|
|
331
|
+
const [failed, setFailed] = React36__namespace.default.useState(false);
|
|
329
332
|
const shownSrc = failed && fallback ? fallback : src;
|
|
330
333
|
const s = {
|
|
331
334
|
objectFit: fit,
|
|
@@ -394,10 +397,10 @@ function Accordion({
|
|
|
394
397
|
...rest
|
|
395
398
|
}) {
|
|
396
399
|
const __twcStyles = useScopedStyles("twc-accordion-styles", ACCORDION_CSS);
|
|
397
|
-
const rootRef =
|
|
398
|
-
const [internal, setInternal] =
|
|
400
|
+
const rootRef = React36__namespace.default.useRef(null);
|
|
401
|
+
const [internal, setInternal] = React36__namespace.default.useState(() => new Set(defaultOpen));
|
|
399
402
|
const open = openProp !== void 0 ? new Set(openProp) : internal;
|
|
400
|
-
const baseId =
|
|
403
|
+
const baseId = React36__namespace.default.useId();
|
|
401
404
|
function toggle(val) {
|
|
402
405
|
const item = items.find((x) => x.value === val);
|
|
403
406
|
if (item?.disabled) return;
|
|
@@ -583,7 +586,7 @@ function Avatar({
|
|
|
583
586
|
...rest
|
|
584
587
|
}) {
|
|
585
588
|
const __twcStyles = useScopedStyles("twc-avatar-styles", AVATAR_CSS);
|
|
586
|
-
const [errored, setErrored] =
|
|
589
|
+
const [errored, setErrored] = React36__namespace.default.useState(false);
|
|
587
590
|
const cleanSrc = safeSrc(src);
|
|
588
591
|
const showImg = cleanSrc && !errored;
|
|
589
592
|
const _statusLabel = status ? statusLabel ?? statusLabels?.[status] ?? STATUS_LABELS[status] : void 0;
|
|
@@ -661,25 +664,25 @@ function Menu({
|
|
|
661
664
|
...rest
|
|
662
665
|
}) {
|
|
663
666
|
const __twcStyles = useScopedStyles("twc-menu-styles", MENU_CSS);
|
|
664
|
-
const [openState, setOpenState] =
|
|
665
|
-
const [render, setRender] =
|
|
666
|
-
const [pos, setPos] =
|
|
667
|
-
const [active, setActive] =
|
|
668
|
-
const wrapRef =
|
|
669
|
-
const menuRef =
|
|
670
|
-
const typeBufRef =
|
|
671
|
-
const typeTimerRef =
|
|
672
|
-
const menuId =
|
|
667
|
+
const [openState, setOpenState] = React36__namespace.default.useState(defaultOpen);
|
|
668
|
+
const [render, setRender] = React36__namespace.default.useState(false);
|
|
669
|
+
const [pos, setPos] = React36__namespace.default.useState(null);
|
|
670
|
+
const [active, setActive] = React36__namespace.default.useState(-1);
|
|
671
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
672
|
+
const menuRef = React36__namespace.default.useRef(null);
|
|
673
|
+
const typeBufRef = React36__namespace.default.useRef("");
|
|
674
|
+
const typeTimerRef = React36__namespace.default.useRef(null);
|
|
675
|
+
const menuId = React36__namespace.default.useId();
|
|
673
676
|
const headerId = `${menuId}-header`;
|
|
674
677
|
const controlled = openProp !== void 0;
|
|
675
678
|
const open = controlled ? !!openProp : openState;
|
|
676
|
-
const openRef =
|
|
679
|
+
const openRef = React36__namespace.default.useRef(open);
|
|
677
680
|
openRef.current = open;
|
|
678
|
-
const controlledRef =
|
|
681
|
+
const controlledRef = React36__namespace.default.useRef(controlled);
|
|
679
682
|
controlledRef.current = controlled;
|
|
680
|
-
const onOpenChangeRef =
|
|
683
|
+
const onOpenChangeRef = React36__namespace.default.useRef(onOpenChange);
|
|
681
684
|
onOpenChangeRef.current = onOpenChange;
|
|
682
|
-
const setOpen =
|
|
685
|
+
const setOpen = React36__namespace.default.useCallback((next) => {
|
|
683
686
|
const value = typeof next === "function" ? next(openRef.current) : next;
|
|
684
687
|
if (value === openRef.current) return;
|
|
685
688
|
if (!controlledRef.current) setOpenState(value);
|
|
@@ -687,7 +690,7 @@ function Menu({
|
|
|
687
690
|
}, []);
|
|
688
691
|
const RD = { createPortal: typeof reactDom.createPortal === "function" ? reactDom.createPortal : typeof window !== "undefined" && window.ReactDOM && window.ReactDOM.createPortal };
|
|
689
692
|
const interactiveIdx = items.map((it, i) => !it.separator && !it.heading ? i : -1).filter((i) => i >= 0);
|
|
690
|
-
const place =
|
|
693
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
691
694
|
const t = wrapRef.current;
|
|
692
695
|
if (!t) return;
|
|
693
696
|
const r = t.getBoundingClientRect();
|
|
@@ -702,7 +705,7 @@ function Menu({
|
|
|
702
705
|
const avail = (flip ? r.top : vh - r.bottom) - gap - M;
|
|
703
706
|
setPos({ top, bottom, left, width: w, flip, maxHeight: Math.max(120, avail) });
|
|
704
707
|
}, [align, width]);
|
|
705
|
-
|
|
708
|
+
React36__namespace.default.useEffect(() => {
|
|
706
709
|
if (!open) return;
|
|
707
710
|
place();
|
|
708
711
|
const onMove = () => place();
|
|
@@ -720,7 +723,7 @@ function Menu({
|
|
|
720
723
|
document.removeEventListener("mousedown", onDown);
|
|
721
724
|
};
|
|
722
725
|
}, [open, place]);
|
|
723
|
-
|
|
726
|
+
React36__namespace.default.useEffect(() => {
|
|
724
727
|
if (open) {
|
|
725
728
|
setRender(true);
|
|
726
729
|
return;
|
|
@@ -843,7 +846,7 @@ function Menu({
|
|
|
843
846
|
}
|
|
844
847
|
) : null;
|
|
845
848
|
const activeDescId = open && active >= 0 ? `${menuId}-item-${active}` : void 0;
|
|
846
|
-
const triggerEl =
|
|
849
|
+
const triggerEl = React36__namespace.default.isValidElement(trigger) ? React36__namespace.default.cloneElement(trigger, {
|
|
847
850
|
onClick: (e) => {
|
|
848
851
|
trigger.props.onClick?.(e);
|
|
849
852
|
toggle();
|
|
@@ -1008,7 +1011,7 @@ function Breadcrumb({
|
|
|
1008
1011
|
...rest
|
|
1009
1012
|
}) {
|
|
1010
1013
|
const __twcStyles = useScopedStyles("twc-breadcrumb-styles", BREADCRUMB_CSS);
|
|
1011
|
-
const [expanded, setExpanded] =
|
|
1014
|
+
const [expanded, setExpanded] = React36__namespace.default.useState(false);
|
|
1012
1015
|
const sep = separator || /* @__PURE__ */ jsxRuntime.jsx(ChevronSep, {});
|
|
1013
1016
|
let display = items;
|
|
1014
1017
|
if (maxItems > 0 && items.length > maxItems && !expanded) {
|
|
@@ -1021,7 +1024,7 @@ function Breadcrumb({
|
|
|
1021
1024
|
__twcStyles,
|
|
1022
1025
|
display.map((it, i) => {
|
|
1023
1026
|
const last = i === display.length - 1;
|
|
1024
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1027
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React36__namespace.default.Fragment, { children: [
|
|
1025
1028
|
it.ellipsis ? /* @__PURE__ */ jsxRuntime.jsx("button", { className: "twc-breadcrumb__ellipsis", "aria-label": "Show more", onClick: () => setExpanded(true), children: "\u2026" }) : last ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1026
1029
|
"span",
|
|
1027
1030
|
{
|
|
@@ -1163,7 +1166,7 @@ function Button({
|
|
|
1163
1166
|
...rest
|
|
1164
1167
|
}) {
|
|
1165
1168
|
const __twcStyles = useScopedStyles("twc-btn-styles", CSS2);
|
|
1166
|
-
const [ripples, setRipples] =
|
|
1169
|
+
const [ripples, setRipples] = React36__namespace.default.useState([]);
|
|
1167
1170
|
const Tag2 = as;
|
|
1168
1171
|
const inert = Tag2 === "a" && (disabled || loading);
|
|
1169
1172
|
function handleClick(e) {
|
|
@@ -1328,9 +1331,9 @@ function buildSx(sx, uid) {
|
|
|
1328
1331
|
return { flatStyle, css };
|
|
1329
1332
|
}
|
|
1330
1333
|
function useSx(sx) {
|
|
1331
|
-
const rawId =
|
|
1334
|
+
const rawId = React36__namespace.default.useId();
|
|
1332
1335
|
const uid = `sx${rawId.replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
1333
|
-
const { flatStyle, css } =
|
|
1336
|
+
const { flatStyle, css } = React36__namespace.default.useMemo(() => buildSx(sx, uid), [sx, uid]);
|
|
1334
1337
|
const styleNode = useScopedStyles(`twc-sx-${uid}`, css);
|
|
1335
1338
|
return { flatStyle, styleNode, sxAttr: css ? uid : void 0 };
|
|
1336
1339
|
}
|
|
@@ -1459,14 +1462,14 @@ function Carousel({
|
|
|
1459
1462
|
...rest
|
|
1460
1463
|
}) {
|
|
1461
1464
|
const __twcStyles = useScopedStyles("twc-carousel-styles", CAROUSEL_CSS);
|
|
1462
|
-
const slides =
|
|
1465
|
+
const slides = React36__namespace.default.Children.toArray(children);
|
|
1463
1466
|
const count = slides.length;
|
|
1464
|
-
const [internal, setInternal] =
|
|
1467
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultIndex);
|
|
1465
1468
|
const index = indexProp !== void 0 ? indexProp : internal;
|
|
1466
|
-
const [paused, setPaused] =
|
|
1467
|
-
const [userPaused, setUserPaused] =
|
|
1468
|
-
const [prefersReduced, setPrefersReduced] =
|
|
1469
|
-
|
|
1469
|
+
const [paused, setPaused] = React36__namespace.default.useState(false);
|
|
1470
|
+
const [userPaused, setUserPaused] = React36__namespace.default.useState(false);
|
|
1471
|
+
const [prefersReduced, setPrefersReduced] = React36__namespace.default.useState(false);
|
|
1472
|
+
React36__namespace.default.useEffect(() => {
|
|
1470
1473
|
if (typeof window === "undefined" || !window.matchMedia) return void 0;
|
|
1471
1474
|
const mql = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
1472
1475
|
const on = () => setPrefersReduced(mql.matches);
|
|
@@ -1474,15 +1477,15 @@ function Carousel({
|
|
|
1474
1477
|
mql.addEventListener("change", on);
|
|
1475
1478
|
return () => mql.removeEventListener("change", on);
|
|
1476
1479
|
}, []);
|
|
1477
|
-
const setIndex =
|
|
1480
|
+
const setIndex = React36__namespace.default.useCallback((i) => {
|
|
1478
1481
|
if (indexProp === void 0) setInternal(i);
|
|
1479
1482
|
onIndexChange?.(i);
|
|
1480
1483
|
}, [indexProp, onIndexChange]);
|
|
1481
|
-
const go =
|
|
1484
|
+
const go = React36__namespace.default.useCallback((i) => {
|
|
1482
1485
|
setIndex(loop ? (i + count) % count : Math.min(Math.max(i, 0), count - 1));
|
|
1483
1486
|
}, [count, loop, setIndex]);
|
|
1484
1487
|
const autoRotating = autoPlay && !paused && !userPaused && !prefersReduced && count > 1;
|
|
1485
|
-
|
|
1488
|
+
React36__namespace.default.useEffect(() => {
|
|
1486
1489
|
if (!autoRotating) return void 0;
|
|
1487
1490
|
const t = setInterval(() => {
|
|
1488
1491
|
const next = loop ? (index + 1) % count : index + 1 >= count ? index : index + 1;
|
|
@@ -1577,7 +1580,7 @@ function Chart({
|
|
|
1577
1580
|
...rest
|
|
1578
1581
|
}) {
|
|
1579
1582
|
const __twcStyles = useScopedStyles("twc-chart-styles", CHART_CSS);
|
|
1580
|
-
const uid =
|
|
1583
|
+
const uid = React36__namespace.default.useId();
|
|
1581
1584
|
const tableId = tableFallback ? `${uid}-table` : void 0;
|
|
1582
1585
|
const keys = series || ["value"];
|
|
1583
1586
|
const palette = colors && colors.length ? colors : SERIES_COLORS;
|
|
@@ -1733,13 +1736,13 @@ function Checkbox({
|
|
|
1733
1736
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
1734
1737
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
1735
1738
|
`);
|
|
1736
|
-
const autoId =
|
|
1739
|
+
const autoId = React36__namespace.default.useId();
|
|
1737
1740
|
const fieldId = id || autoId;
|
|
1738
1741
|
const errId = `${fieldId}-error`;
|
|
1739
1742
|
const invalid = Boolean(error);
|
|
1740
|
-
const ref =
|
|
1743
|
+
const ref = React36__namespace.default.useRef(null);
|
|
1741
1744
|
const mixed = indeterminate && !checked;
|
|
1742
|
-
|
|
1745
|
+
React36__namespace.default.useEffect(() => {
|
|
1743
1746
|
if (ref.current) ref.current.indeterminate = mixed;
|
|
1744
1747
|
}, [mixed]);
|
|
1745
1748
|
if (process.env.NODE_ENV !== "production" && !label && !description && !rest["aria-label"] && !rest["aria-labelledby"]) {
|
|
@@ -1893,22 +1896,22 @@ function ColorPicker({
|
|
|
1893
1896
|
}) {
|
|
1894
1897
|
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS);
|
|
1895
1898
|
const __twcStyles1 = useScopedStyles("twc-colorpicker-styles", COLORPICKER_CSS);
|
|
1896
|
-
const [internal, setInternal] =
|
|
1899
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
1897
1900
|
const hex = (value !== void 0 ? value : internal) || "#000000";
|
|
1898
1901
|
const hexRe = alpha ? /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i : /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
1899
|
-
const lastValidRef =
|
|
1902
|
+
const lastValidRef = React36__namespace.default.useRef(hex);
|
|
1900
1903
|
if (hexRe.test(hex)) lastValidRef.current = hex;
|
|
1901
|
-
const [open, setOpen] =
|
|
1902
|
-
const [hsv, setHsv] =
|
|
1903
|
-
const [coords, setCoords] =
|
|
1904
|
-
const wrapRef =
|
|
1905
|
-
const triggerRef =
|
|
1906
|
-
const popRef =
|
|
1907
|
-
const areaRef =
|
|
1908
|
-
const hueRef =
|
|
1909
|
-
const alphaRef =
|
|
1904
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
1905
|
+
const [hsv, setHsv] = React36__namespace.default.useState(() => hexToHsv(hex) || { h: 239, s: 60, v: 94, a: 1 });
|
|
1906
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
1907
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
1908
|
+
const triggerRef = React36__namespace.default.useRef(null);
|
|
1909
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
1910
|
+
const areaRef = React36__namespace.default.useRef(null);
|
|
1911
|
+
const hueRef = React36__namespace.default.useRef(null);
|
|
1912
|
+
const alphaRef = React36__namespace.default.useRef(null);
|
|
1910
1913
|
const POP_W = 240;
|
|
1911
|
-
const place =
|
|
1914
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
1912
1915
|
const el = triggerRef.current;
|
|
1913
1916
|
if (!el) return;
|
|
1914
1917
|
const r = el.getBoundingClientRect();
|
|
@@ -1919,7 +1922,7 @@ function ColorPicker({
|
|
|
1919
1922
|
left = Math.max(8, left);
|
|
1920
1923
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
1921
1924
|
}, []);
|
|
1922
|
-
|
|
1925
|
+
React36__namespace.default.useEffect(() => {
|
|
1923
1926
|
if (!open) return void 0;
|
|
1924
1927
|
place();
|
|
1925
1928
|
const onMove = () => place();
|
|
@@ -1930,17 +1933,17 @@ function ColorPicker({
|
|
|
1930
1933
|
window.removeEventListener("resize", onMove);
|
|
1931
1934
|
};
|
|
1932
1935
|
}, [open, place]);
|
|
1933
|
-
const labelId =
|
|
1936
|
+
const labelId = React36__namespace.default.useId();
|
|
1934
1937
|
const descId = `${labelId}-desc`;
|
|
1935
1938
|
const invalid = Boolean(error);
|
|
1936
|
-
|
|
1939
|
+
React36__namespace.default.useEffect(() => {
|
|
1937
1940
|
if (disabled) setOpen(false);
|
|
1938
1941
|
}, [disabled]);
|
|
1939
|
-
|
|
1942
|
+
React36__namespace.default.useEffect(() => {
|
|
1940
1943
|
const v = hexToHsv(hex);
|
|
1941
1944
|
if (v && hsvToHex(v.h, v.s, v.v).toLowerCase() !== hsvToHex(hsv.h, hsv.s, hsv.v).toLowerCase()) setHsv(v);
|
|
1942
1945
|
}, [hex]);
|
|
1943
|
-
|
|
1946
|
+
React36__namespace.default.useEffect(() => {
|
|
1944
1947
|
if (!open) return;
|
|
1945
1948
|
const onDown = (e) => {
|
|
1946
1949
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -2312,34 +2315,34 @@ function Combobox({
|
|
|
2312
2315
|
...rest
|
|
2313
2316
|
}) {
|
|
2314
2317
|
const __twcStyles = useScopedStyles("twc-combo-styles", COMBO_CSS);
|
|
2315
|
-
const groups =
|
|
2316
|
-
const flat =
|
|
2317
|
-
const autoId =
|
|
2318
|
+
const groups = React36__namespace.default.useMemo(() => normalizeGroups(options), [options]);
|
|
2319
|
+
const flat = React36__namespace.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
2320
|
+
const autoId = React36__namespace.default.useId();
|
|
2318
2321
|
const fieldId = id || autoId;
|
|
2319
|
-
const [internal, setInternal] =
|
|
2322
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
2320
2323
|
const current = value !== void 0 ? value : internal;
|
|
2321
2324
|
const selected = flat.find((o) => o.value === current);
|
|
2322
|
-
const [open, setOpen] =
|
|
2323
|
-
const [query, setQuery] =
|
|
2324
|
-
const [active, setActive] =
|
|
2325
|
-
const [coords, setCoords] =
|
|
2326
|
-
const [scrollTop, setScrollTop] =
|
|
2327
|
-
const [listH, setListH] =
|
|
2328
|
-
const wrapRef =
|
|
2329
|
-
const controlRef =
|
|
2330
|
-
const inputRef =
|
|
2331
|
-
const popRef =
|
|
2332
|
-
const listRef =
|
|
2333
|
-
const activeRef =
|
|
2334
|
-
const fGroups =
|
|
2325
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
2326
|
+
const [query, setQuery] = React36__namespace.default.useState("");
|
|
2327
|
+
const [active, setActive] = React36__namespace.default.useState(0);
|
|
2328
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
2329
|
+
const [scrollTop, setScrollTop] = React36__namespace.default.useState(0);
|
|
2330
|
+
const [listH, setListH] = React36__namespace.default.useState(260);
|
|
2331
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
2332
|
+
const controlRef = React36__namespace.default.useRef(null);
|
|
2333
|
+
const inputRef = React36__namespace.default.useRef(null);
|
|
2334
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
2335
|
+
const listRef = React36__namespace.default.useRef(null);
|
|
2336
|
+
const activeRef = React36__namespace.default.useRef(null);
|
|
2337
|
+
const fGroups = React36__namespace.default.useMemo(() => {
|
|
2335
2338
|
const q = query.trim();
|
|
2336
2339
|
const fn = filter === false ? null : typeof filter === "function" ? filter : matches;
|
|
2337
2340
|
return groups.map((g) => ({ group: g.group, options: fn ? g.options.filter((o) => fn(o, q)) : g.options })).filter((g) => g.options.length);
|
|
2338
2341
|
}, [groups, query, filter]);
|
|
2339
|
-
const visible =
|
|
2340
|
-
const rowH =
|
|
2342
|
+
const visible = React36__namespace.default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
2343
|
+
const rowH = React36__namespace.default.useMemo(() => visible.some((o) => o.description) ? 48 : 36, [visible]);
|
|
2341
2344
|
const GROUP_H = 30;
|
|
2342
|
-
const { rows, totalH } =
|
|
2345
|
+
const { rows, totalH } = React36__namespace.default.useMemo(() => {
|
|
2343
2346
|
if (!virtualized) return { rows: [], totalH: 0 };
|
|
2344
2347
|
const rows2 = [];
|
|
2345
2348
|
let off = 0;
|
|
@@ -2365,7 +2368,7 @@ function Combobox({
|
|
|
2365
2368
|
}
|
|
2366
2369
|
return from;
|
|
2367
2370
|
};
|
|
2368
|
-
const place =
|
|
2371
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
2369
2372
|
const el = controlRef.current;
|
|
2370
2373
|
if (!el) return;
|
|
2371
2374
|
const r = el.getBoundingClientRect();
|
|
@@ -2380,7 +2383,7 @@ function Combobox({
|
|
|
2380
2383
|
flip
|
|
2381
2384
|
});
|
|
2382
2385
|
}, [placement, minWidth]);
|
|
2383
|
-
|
|
2386
|
+
React36__namespace.default.useEffect(() => {
|
|
2384
2387
|
if (!open || !portal) return;
|
|
2385
2388
|
place();
|
|
2386
2389
|
const onMove = () => place();
|
|
@@ -2391,7 +2394,7 @@ function Combobox({
|
|
|
2391
2394
|
window.removeEventListener("resize", onMove);
|
|
2392
2395
|
};
|
|
2393
2396
|
}, [open, portal, place]);
|
|
2394
|
-
|
|
2397
|
+
React36__namespace.default.useEffect(() => {
|
|
2395
2398
|
if (!open) return;
|
|
2396
2399
|
const onDown = (e) => {
|
|
2397
2400
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -2401,20 +2404,20 @@ function Combobox({
|
|
|
2401
2404
|
document.addEventListener("mousedown", onDown);
|
|
2402
2405
|
return () => document.removeEventListener("mousedown", onDown);
|
|
2403
2406
|
}, [open]);
|
|
2404
|
-
|
|
2407
|
+
React36__namespace.default.useEffect(() => {
|
|
2405
2408
|
setActive(0);
|
|
2406
2409
|
}, [query]);
|
|
2407
|
-
|
|
2410
|
+
React36__namespace.default.useEffect(() => {
|
|
2408
2411
|
if (!open) return;
|
|
2409
2412
|
const idx = flat.findIndex((o) => o.value === current);
|
|
2410
2413
|
setActive(idx >= 0 ? idx : 0);
|
|
2411
2414
|
}, [open]);
|
|
2412
|
-
|
|
2415
|
+
React36__namespace.default.useEffect(() => {
|
|
2413
2416
|
if (!open || !virtualized) return;
|
|
2414
2417
|
const el = listRef.current;
|
|
2415
2418
|
if (el && el.clientHeight) setListH(el.clientHeight);
|
|
2416
2419
|
}, [open, virtualized]);
|
|
2417
|
-
|
|
2420
|
+
React36__namespace.default.useEffect(() => {
|
|
2418
2421
|
if (!open) return;
|
|
2419
2422
|
if (!virtualized) {
|
|
2420
2423
|
ensureVisible(listRef.current, activeRef.current);
|
|
@@ -2523,7 +2526,7 @@ function Combobox({
|
|
|
2523
2526
|
vTop > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": "true", style: { height: vTop } }) : null,
|
|
2524
2527
|
vShown.map((r) => r.kind === "group" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: r.label }, `g${r.gi}`) : renderOption(r.o, r.idx)),
|
|
2525
2528
|
vBottom > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": "true", style: { height: vBottom } }) : null
|
|
2526
|
-
] }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2529
|
+
] }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React36__namespace.default.Fragment, { children: [
|
|
2527
2530
|
g.group ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
2528
2531
|
g.options.map((o) => {
|
|
2529
2532
|
counter += 1;
|
|
@@ -2686,14 +2689,14 @@ function CommandPalette({
|
|
|
2686
2689
|
}) {
|
|
2687
2690
|
const __twcStyles = useScopedStyles("twc-cmdk-styles", COMMAND_CSS);
|
|
2688
2691
|
const renderPortal = usePortal();
|
|
2689
|
-
const [query, setQuery] =
|
|
2690
|
-
const [active, setActive] =
|
|
2691
|
-
const inputRef =
|
|
2692
|
-
const listRef =
|
|
2693
|
-
const paletteRef =
|
|
2694
|
-
const baseId =
|
|
2695
|
-
const [mounted, setMounted] =
|
|
2696
|
-
|
|
2692
|
+
const [query, setQuery] = React36__namespace.default.useState("");
|
|
2693
|
+
const [active, setActive] = React36__namespace.default.useState(0);
|
|
2694
|
+
const inputRef = React36__namespace.default.useRef(null);
|
|
2695
|
+
const listRef = React36__namespace.default.useRef(null);
|
|
2696
|
+
const paletteRef = React36__namespace.default.useRef(null);
|
|
2697
|
+
const baseId = React36__namespace.default.useId();
|
|
2698
|
+
const [mounted, setMounted] = React36__namespace.default.useState(open);
|
|
2699
|
+
React36__namespace.default.useEffect(() => {
|
|
2697
2700
|
if (open) {
|
|
2698
2701
|
setMounted(true);
|
|
2699
2702
|
return;
|
|
@@ -2702,14 +2705,14 @@ function CommandPalette({
|
|
|
2702
2705
|
return () => clearTimeout(t);
|
|
2703
2706
|
}, [open]);
|
|
2704
2707
|
useScrollLock(open);
|
|
2705
|
-
|
|
2708
|
+
React36__namespace.default.useEffect(() => {
|
|
2706
2709
|
if (open) {
|
|
2707
2710
|
setQuery("");
|
|
2708
2711
|
setActive(0);
|
|
2709
2712
|
}
|
|
2710
2713
|
}, [open]);
|
|
2711
2714
|
useFocusTrap(paletteRef, open && mounted);
|
|
2712
|
-
|
|
2715
|
+
React36__namespace.default.useEffect(() => {
|
|
2713
2716
|
if (!open) return void 0;
|
|
2714
2717
|
const onKey = (e) => {
|
|
2715
2718
|
if (e.key === "Escape") {
|
|
@@ -2721,7 +2724,7 @@ function CommandPalette({
|
|
|
2721
2724
|
return () => document.removeEventListener("keydown", onKey);
|
|
2722
2725
|
}, [open, onClose]);
|
|
2723
2726
|
const q = query.trim().toLowerCase();
|
|
2724
|
-
const filtered =
|
|
2727
|
+
const filtered = React36__namespace.default.useMemo(() => commands.filter(
|
|
2725
2728
|
(c) => !q || c.label.toLowerCase().includes(q) || (c.keywords || "").toLowerCase().includes(q) || (c.group || "").toLowerCase().includes(q)
|
|
2726
2729
|
), [commands, q]);
|
|
2727
2730
|
const groups = [];
|
|
@@ -2736,7 +2739,7 @@ function CommandPalette({
|
|
|
2736
2739
|
g.items.push(c);
|
|
2737
2740
|
flat.push(c);
|
|
2738
2741
|
});
|
|
2739
|
-
|
|
2742
|
+
React36__namespace.default.useEffect(() => {
|
|
2740
2743
|
setActive(0);
|
|
2741
2744
|
}, [query]);
|
|
2742
2745
|
const run = (cmd) => {
|
|
@@ -2756,7 +2759,7 @@ function CommandPalette({
|
|
|
2756
2759
|
if (cmd) run(cmd);
|
|
2757
2760
|
}
|
|
2758
2761
|
}
|
|
2759
|
-
|
|
2762
|
+
React36__namespace.default.useEffect(() => {
|
|
2760
2763
|
const node = listRef.current?.querySelector('[data-active="true"]');
|
|
2761
2764
|
if (node) node.scrollIntoView({ block: "nearest" });
|
|
2762
2765
|
}, [active]);
|
|
@@ -2932,13 +2935,13 @@ function Currency({
|
|
|
2932
2935
|
const prec = precision != null ? precision : meta.precision;
|
|
2933
2936
|
const sym = symbol != null ? symbol : meta.symbol;
|
|
2934
2937
|
const cur = code != null ? code : meta.code;
|
|
2935
|
-
const autoId =
|
|
2938
|
+
const autoId = React36__namespace.default.useId();
|
|
2936
2939
|
const fieldId = id || autoId;
|
|
2937
2940
|
const invalid = Boolean(error);
|
|
2938
2941
|
const controlled = value !== void 0;
|
|
2939
|
-
const [internal, setInternal] =
|
|
2942
|
+
const [internal, setInternal] = React36__namespace.default.useState(() => clampPrecision(String(defaultValue ?? ""), prec));
|
|
2940
2943
|
const shown = controlled ? clampPrecision(String(value ?? ""), prec) : internal;
|
|
2941
|
-
|
|
2944
|
+
React36__namespace.default.useEffect(() => {
|
|
2942
2945
|
if (!controlled) return;
|
|
2943
2946
|
const raw = String(value ?? "");
|
|
2944
2947
|
if (shown !== raw) {
|
|
@@ -3134,37 +3137,37 @@ function Select({
|
|
|
3134
3137
|
...rest
|
|
3135
3138
|
}) {
|
|
3136
3139
|
const __twcStyles = useScopedStyles("twc-select-styles", SELECT_CSS);
|
|
3137
|
-
const bufferRef =
|
|
3138
|
-
const bufferTimerRef =
|
|
3139
|
-
const groups =
|
|
3140
|
-
const flat =
|
|
3141
|
-
const autoId =
|
|
3140
|
+
const bufferRef = React36__namespace.default.useRef("");
|
|
3141
|
+
const bufferTimerRef = React36__namespace.default.useRef(null);
|
|
3142
|
+
const groups = React36__namespace.default.useMemo(() => normalizeGroups2(options), [options]);
|
|
3143
|
+
const flat = React36__namespace.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
3144
|
+
const autoId = React36__namespace.default.useId();
|
|
3142
3145
|
const fieldId = id || autoId;
|
|
3143
|
-
const [internal, setInternal] =
|
|
3146
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
3144
3147
|
const current = value !== void 0 ? value : internal;
|
|
3145
|
-
const [open, setOpen] =
|
|
3146
|
-
const [render, setRender] =
|
|
3147
|
-
const [active, setActive] =
|
|
3148
|
-
const [coords, setCoords] =
|
|
3149
|
-
const [query, setQuery] =
|
|
3150
|
-
const [scrollTop, setScrollTop] =
|
|
3151
|
-
const [listH, setListH] =
|
|
3152
|
-
const wrapRef =
|
|
3153
|
-
const triggerRef =
|
|
3154
|
-
const popRef =
|
|
3155
|
-
const listRef =
|
|
3156
|
-
const activeRef =
|
|
3157
|
-
const searchRef =
|
|
3148
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
3149
|
+
const [render, setRender] = React36__namespace.default.useState(false);
|
|
3150
|
+
const [active, setActive] = React36__namespace.default.useState(0);
|
|
3151
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
3152
|
+
const [query, setQuery] = React36__namespace.default.useState("");
|
|
3153
|
+
const [scrollTop, setScrollTop] = React36__namespace.default.useState(0);
|
|
3154
|
+
const [listH, setListH] = React36__namespace.default.useState(260);
|
|
3155
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
3156
|
+
const triggerRef = React36__namespace.default.useRef(null);
|
|
3157
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
3158
|
+
const listRef = React36__namespace.default.useRef(null);
|
|
3159
|
+
const activeRef = React36__namespace.default.useRef(null);
|
|
3160
|
+
const searchRef = React36__namespace.default.useRef(null);
|
|
3158
3161
|
const showSearch = searchable === void 0 ? flat.length > 5 : searchable;
|
|
3159
|
-
const fGroups =
|
|
3162
|
+
const fGroups = React36__namespace.default.useMemo(() => {
|
|
3160
3163
|
const q = query.trim().toLowerCase();
|
|
3161
3164
|
if (!q) return groups;
|
|
3162
3165
|
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);
|
|
3163
3166
|
}, [groups, query]);
|
|
3164
|
-
const visible =
|
|
3165
|
-
const rowH =
|
|
3167
|
+
const visible = React36__namespace.default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
3168
|
+
const rowH = React36__namespace.default.useMemo(() => visible.some((o) => o.description) ? 48 : 36, [visible]);
|
|
3166
3169
|
const GROUP_H = 30;
|
|
3167
|
-
const { rows, totalH } =
|
|
3170
|
+
const { rows, totalH } = React36__namespace.default.useMemo(() => {
|
|
3168
3171
|
if (!virtualized) return { rows: [], totalH: 0 };
|
|
3169
3172
|
const rows2 = [];
|
|
3170
3173
|
let off = 0;
|
|
@@ -3191,7 +3194,7 @@ function Select({
|
|
|
3191
3194
|
}
|
|
3192
3195
|
return from;
|
|
3193
3196
|
};
|
|
3194
|
-
const place =
|
|
3197
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
3195
3198
|
const el = triggerRef.current;
|
|
3196
3199
|
if (!el) return;
|
|
3197
3200
|
const r = el.getBoundingClientRect();
|
|
@@ -3207,7 +3210,7 @@ function Select({
|
|
|
3207
3210
|
flip
|
|
3208
3211
|
});
|
|
3209
3212
|
}, [placement, minWidth, matchTriggerWidth]);
|
|
3210
|
-
|
|
3213
|
+
React36__namespace.default.useEffect(() => {
|
|
3211
3214
|
if (!open || !portal) return;
|
|
3212
3215
|
place();
|
|
3213
3216
|
const onMove = () => place();
|
|
@@ -3218,7 +3221,7 @@ function Select({
|
|
|
3218
3221
|
window.removeEventListener("resize", onMove);
|
|
3219
3222
|
};
|
|
3220
3223
|
}, [open, portal, place]);
|
|
3221
|
-
|
|
3224
|
+
React36__namespace.default.useEffect(() => {
|
|
3222
3225
|
if (!open) return;
|
|
3223
3226
|
const idx = flat.findIndex((o) => o.value === current);
|
|
3224
3227
|
setActive(idx >= 0 ? idx : 0);
|
|
@@ -3234,15 +3237,15 @@ function Select({
|
|
|
3234
3237
|
document.addEventListener("mousedown", onDown);
|
|
3235
3238
|
return () => document.removeEventListener("mousedown", onDown);
|
|
3236
3239
|
}, [open]);
|
|
3237
|
-
|
|
3240
|
+
React36__namespace.default.useEffect(() => {
|
|
3238
3241
|
setActive(0);
|
|
3239
3242
|
}, [query]);
|
|
3240
|
-
|
|
3243
|
+
React36__namespace.default.useEffect(() => {
|
|
3241
3244
|
if (!open || !virtualized) return;
|
|
3242
3245
|
const el = listRef.current;
|
|
3243
3246
|
if (el && el.clientHeight) setListH(el.clientHeight);
|
|
3244
3247
|
}, [open, virtualized, render]);
|
|
3245
|
-
|
|
3248
|
+
React36__namespace.default.useEffect(() => {
|
|
3246
3249
|
if (!open) return;
|
|
3247
3250
|
if (!virtualized) {
|
|
3248
3251
|
ensureVisible2(listRef.current, activeRef.current);
|
|
@@ -3259,7 +3262,7 @@ function Select({
|
|
|
3259
3262
|
if (next !== el.scrollTop) el.scrollTop = next;
|
|
3260
3263
|
setScrollTop(next);
|
|
3261
3264
|
}, [active, open, virtualized, rows, listH]);
|
|
3262
|
-
|
|
3265
|
+
React36__namespace.default.useEffect(() => {
|
|
3263
3266
|
if (open) {
|
|
3264
3267
|
setRender(true);
|
|
3265
3268
|
return;
|
|
@@ -3267,8 +3270,8 @@ function Select({
|
|
|
3267
3270
|
const t = setTimeout(() => setRender(false), 170);
|
|
3268
3271
|
return () => clearTimeout(t);
|
|
3269
3272
|
}, [open]);
|
|
3270
|
-
const prevOpen =
|
|
3271
|
-
|
|
3273
|
+
const prevOpen = React36__namespace.default.useRef(false);
|
|
3274
|
+
React36__namespace.default.useEffect(() => {
|
|
3272
3275
|
if (prevOpen.current && !open) {
|
|
3273
3276
|
const ae = typeof document !== "undefined" ? document.activeElement : null;
|
|
3274
3277
|
if (popRef.current && ae && popRef.current.contains(ae)) triggerRef.current?.focus();
|
|
@@ -3405,7 +3408,7 @@ function Select({
|
|
|
3405
3408
|
vTop > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": "true", style: { height: vTop } }) : null,
|
|
3406
3409
|
vShown.map((r) => r.kind === "group" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: r.label }, `g${r.gi}`) : renderOption(r.o, r.idx)),
|
|
3407
3410
|
vBottom > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": "true", style: { height: vBottom } }) : null
|
|
3408
|
-
] }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3411
|
+
] }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React36__namespace.default.Fragment, { children: [
|
|
3409
3412
|
g.group ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
3410
3413
|
g.options.map((o) => {
|
|
3411
3414
|
counter += 1;
|
|
@@ -3560,21 +3563,21 @@ function CurrencyField({
|
|
|
3560
3563
|
...rest
|
|
3561
3564
|
}) {
|
|
3562
3565
|
const __twcStyles = useScopedStyles("twc-curf-styles", CURF_CSS);
|
|
3563
|
-
const autoId =
|
|
3566
|
+
const autoId = React36__namespace.default.useId();
|
|
3564
3567
|
const fieldId = id || autoId;
|
|
3565
3568
|
const invalid = Boolean(error);
|
|
3566
3569
|
const curControlled = currency !== void 0;
|
|
3567
|
-
const [curInternal, setCurInternal] =
|
|
3570
|
+
const [curInternal, setCurInternal] = React36__namespace.default.useState(defaultCurrency);
|
|
3568
3571
|
const cur = curControlled ? currency : curInternal;
|
|
3569
3572
|
const meta = CURRENCIES[cur] || CURRENCIES.USD;
|
|
3570
3573
|
const prec = meta.precision;
|
|
3571
3574
|
const valControlled = value !== void 0;
|
|
3572
|
-
const [valInternal, setValInternal] =
|
|
3575
|
+
const [valInternal, setValInternal] = React36__namespace.default.useState(() => clampPrecision(String(defaultValue ?? ""), prec));
|
|
3573
3576
|
const shown = valControlled ? clampPrecision(String(value ?? ""), prec) : valInternal;
|
|
3574
3577
|
const descId = `${fieldId}-desc`;
|
|
3575
3578
|
const describedBy = [error || hint ? descId : null, rest["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
3576
3579
|
const ariaInvalid = invalid ? true : rest["aria-invalid"] ?? void 0;
|
|
3577
|
-
|
|
3580
|
+
React36__namespace.default.useEffect(() => {
|
|
3578
3581
|
if (!valControlled) {
|
|
3579
3582
|
const clamped = clampPrecision(valInternal, prec);
|
|
3580
3583
|
if (clamped !== valInternal) {
|
|
@@ -3590,7 +3593,7 @@ function CurrencyField({
|
|
|
3590
3593
|
}
|
|
3591
3594
|
}
|
|
3592
3595
|
}, [prec, cur, shown, value, valControlled, valInternal]);
|
|
3593
|
-
const options =
|
|
3596
|
+
const options = React36__namespace.default.useMemo(() => {
|
|
3594
3597
|
if (!currencies) return CURRENCY_OPTIONS;
|
|
3595
3598
|
return currencies.map((c) => typeof c === "string" ? { value: c, label: `${c} \u2014 ${(CURRENCIES[c] || {}).label || c}` } : c);
|
|
3596
3599
|
}, [currencies]);
|
|
@@ -3744,13 +3747,13 @@ function Input({
|
|
|
3744
3747
|
}) {
|
|
3745
3748
|
const __twcStyles = useScopedStyles("twc-field-styles", FIELD_CSS2);
|
|
3746
3749
|
const __twcExtra = useScopedStyles("twc-input-extra-styles", INPUT_EXTRA_CSS);
|
|
3747
|
-
const autoId =
|
|
3750
|
+
const autoId = React36__namespace.default.useId();
|
|
3748
3751
|
const fieldId = id || autoId;
|
|
3749
3752
|
const descId = `${fieldId}-desc`;
|
|
3750
3753
|
const countId = `${fieldId}-count`;
|
|
3751
3754
|
const invalid = Boolean(error);
|
|
3752
3755
|
const countControlled = rest.value !== void 0;
|
|
3753
|
-
const [len2, setLen] =
|
|
3756
|
+
const [len2, setLen] = React36__namespace.default.useState(() => String(rest.defaultValue ?? "").length);
|
|
3754
3757
|
const count = countControlled ? String(rest.value ?? "").length : len2;
|
|
3755
3758
|
const max = rest.maxLength;
|
|
3756
3759
|
const showCounter = showCount && max != null;
|
|
@@ -3762,7 +3765,7 @@ function Input({
|
|
|
3762
3765
|
const ariaInvalid = invalid ? true : rest["aria-invalid"] ?? void 0;
|
|
3763
3766
|
const describedBy = [error || hint ? descId : null, showCounter ? countId : null, rest["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
3764
3767
|
const isPassword = type === "password";
|
|
3765
|
-
const [revealed, setRevealed] =
|
|
3768
|
+
const [revealed, setRevealed] = React36__namespace.default.useState(false);
|
|
3766
3769
|
const effectiveType = isPassword && revealed ? "text" : type;
|
|
3767
3770
|
const suffix = rightIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-input__affix", children: rightIcon }) : isPassword ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3768
3771
|
"button",
|
|
@@ -3965,32 +3968,32 @@ function MultiSelect({
|
|
|
3965
3968
|
...rest
|
|
3966
3969
|
}) {
|
|
3967
3970
|
const __twcStyles = useScopedStyles("twc-ms-styles", MULTI_CSS);
|
|
3968
|
-
const groups =
|
|
3969
|
-
const flat =
|
|
3970
|
-
const autoId =
|
|
3971
|
+
const groups = React36__namespace.default.useMemo(() => normalizeGroups3(options), [options]);
|
|
3972
|
+
const flat = React36__namespace.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
3973
|
+
const autoId = React36__namespace.default.useId();
|
|
3971
3974
|
const fieldId = id || autoId;
|
|
3972
|
-
const [internal, setInternal] =
|
|
3975
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
3973
3976
|
const selected = value !== void 0 ? value : internal;
|
|
3974
|
-
const [open, setOpen] =
|
|
3975
|
-
const [query, setQuery] =
|
|
3976
|
-
const [active, setActive] =
|
|
3977
|
-
const [coords, setCoords] =
|
|
3978
|
-
const [scrollTop, setScrollTop] =
|
|
3979
|
-
const [listH, setListH] =
|
|
3980
|
-
const wrapRef =
|
|
3981
|
-
const controlRef =
|
|
3982
|
-
const inputRef =
|
|
3983
|
-
const popRef =
|
|
3984
|
-
const listRef =
|
|
3985
|
-
const activeRef =
|
|
3986
|
-
const fGroups =
|
|
3977
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
3978
|
+
const [query, setQuery] = React36__namespace.default.useState("");
|
|
3979
|
+
const [active, setActive] = React36__namespace.default.useState(0);
|
|
3980
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
3981
|
+
const [scrollTop, setScrollTop] = React36__namespace.default.useState(0);
|
|
3982
|
+
const [listH, setListH] = React36__namespace.default.useState(260);
|
|
3983
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
3984
|
+
const controlRef = React36__namespace.default.useRef(null);
|
|
3985
|
+
const inputRef = React36__namespace.default.useRef(null);
|
|
3986
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
3987
|
+
const listRef = React36__namespace.default.useRef(null);
|
|
3988
|
+
const activeRef = React36__namespace.default.useRef(null);
|
|
3989
|
+
const fGroups = React36__namespace.default.useMemo(
|
|
3987
3990
|
() => groups.map((g) => ({ group: g.group, options: g.options.filter((o) => matches2(o, query.trim())) })).filter((g) => g.options.length),
|
|
3988
3991
|
[groups, query]
|
|
3989
3992
|
);
|
|
3990
|
-
const visible =
|
|
3991
|
-
const rowH =
|
|
3993
|
+
const visible = React36__namespace.default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
3994
|
+
const rowH = React36__namespace.default.useMemo(() => visible.some((o) => o.description) ? 48 : 36, [visible]);
|
|
3992
3995
|
const GROUP_H = 30;
|
|
3993
|
-
const { rows, totalH } =
|
|
3996
|
+
const { rows, totalH } = React36__namespace.default.useMemo(() => {
|
|
3994
3997
|
if (!virtualized) return { rows: [], totalH: 0 };
|
|
3995
3998
|
const rows2 = [];
|
|
3996
3999
|
let off = 0;
|
|
@@ -4018,7 +4021,7 @@ function MultiSelect({
|
|
|
4018
4021
|
}
|
|
4019
4022
|
return from;
|
|
4020
4023
|
};
|
|
4021
|
-
const place =
|
|
4024
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
4022
4025
|
const el = controlRef.current;
|
|
4023
4026
|
if (!el) return;
|
|
4024
4027
|
const r = el.getBoundingClientRect();
|
|
@@ -4033,7 +4036,7 @@ function MultiSelect({
|
|
|
4033
4036
|
flip
|
|
4034
4037
|
});
|
|
4035
4038
|
}, [placement, minWidth]);
|
|
4036
|
-
|
|
4039
|
+
React36__namespace.default.useEffect(() => {
|
|
4037
4040
|
if (!open || !portal) return;
|
|
4038
4041
|
place();
|
|
4039
4042
|
const onMove = () => place();
|
|
@@ -4044,7 +4047,7 @@ function MultiSelect({
|
|
|
4044
4047
|
window.removeEventListener("resize", onMove);
|
|
4045
4048
|
};
|
|
4046
4049
|
}, [open, portal, place]);
|
|
4047
|
-
|
|
4050
|
+
React36__namespace.default.useEffect(() => {
|
|
4048
4051
|
if (!open) return;
|
|
4049
4052
|
const onDown = (e) => {
|
|
4050
4053
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -4055,15 +4058,15 @@ function MultiSelect({
|
|
|
4055
4058
|
document.addEventListener("mousedown", onDown);
|
|
4056
4059
|
return () => document.removeEventListener("mousedown", onDown);
|
|
4057
4060
|
}, [open]);
|
|
4058
|
-
|
|
4061
|
+
React36__namespace.default.useEffect(() => {
|
|
4059
4062
|
setActive(0);
|
|
4060
4063
|
}, [query]);
|
|
4061
|
-
|
|
4064
|
+
React36__namespace.default.useEffect(() => {
|
|
4062
4065
|
if (!open || !virtualized) return;
|
|
4063
4066
|
const el = listRef.current;
|
|
4064
4067
|
if (el && el.clientHeight) setListH(el.clientHeight);
|
|
4065
4068
|
}, [open, virtualized]);
|
|
4066
|
-
|
|
4069
|
+
React36__namespace.default.useEffect(() => {
|
|
4067
4070
|
if (!open) return;
|
|
4068
4071
|
if (!virtualized) {
|
|
4069
4072
|
ensureVisible3(listRef.current, activeRef.current);
|
|
@@ -4174,7 +4177,7 @@ function MultiSelect({
|
|
|
4174
4177
|
vTop > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": "true", style: { height: vTop } }) : null,
|
|
4175
4178
|
vShown.map((r) => r.kind === "group" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: r.label }, `g${r.gi}`) : renderOption(r.o, r.idx)),
|
|
4176
4179
|
vBottom > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": "true", style: { height: vBottom } }) : null
|
|
4177
|
-
] }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4180
|
+
] }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React36__namespace.default.Fragment, { children: [
|
|
4178
4181
|
g.group ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
4179
4182
|
g.options.map((o) => {
|
|
4180
4183
|
counter += 1;
|
|
@@ -4376,7 +4379,7 @@ function Pagination({
|
|
|
4376
4379
|
}
|
|
4377
4380
|
const jumperEnabled = showPageJumper ?? showJumper;
|
|
4378
4381
|
const __twcStyles = useScopedStyles("twc-pagination-styles", PAGINATION_CSS);
|
|
4379
|
-
const [internal, setInternal] =
|
|
4382
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultPage);
|
|
4380
4383
|
const page = pageProp !== void 0 ? pageProp : internal;
|
|
4381
4384
|
const pages = buildPages(page, total, siblings, boundaries);
|
|
4382
4385
|
const go = (p) => {
|
|
@@ -4384,7 +4387,7 @@ function Pagination({
|
|
|
4384
4387
|
if (pageProp === void 0) setInternal(p);
|
|
4385
4388
|
onChange?.(p);
|
|
4386
4389
|
};
|
|
4387
|
-
const [jump, setJump] =
|
|
4390
|
+
const [jump, setJump] = React36__namespace.default.useState("");
|
|
4388
4391
|
const submitJump = () => {
|
|
4389
4392
|
const n = parseInt(jump, 10);
|
|
4390
4393
|
if (!Number.isNaN(n)) go(Math.min(Math.max(n, 1), total));
|
|
@@ -4467,13 +4470,13 @@ function Tooltip({
|
|
|
4467
4470
|
...rest
|
|
4468
4471
|
}) {
|
|
4469
4472
|
const __twcStyles = useScopedStyles("twc-tooltip-styles", TOOLTIP_CSS);
|
|
4470
|
-
const id =
|
|
4471
|
-
const [show, setShow] =
|
|
4472
|
-
const [coords, setCoords] =
|
|
4473
|
-
const timer =
|
|
4474
|
-
const closeTimer =
|
|
4475
|
-
const wrapRef =
|
|
4476
|
-
const tipRef =
|
|
4473
|
+
const id = React36__namespace.default.useId();
|
|
4474
|
+
const [show, setShow] = React36__namespace.default.useState(false);
|
|
4475
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
4476
|
+
const timer = React36__namespace.default.useRef(null);
|
|
4477
|
+
const closeTimer = React36__namespace.default.useRef(null);
|
|
4478
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
4479
|
+
const tipRef = React36__namespace.default.useRef(null);
|
|
4477
4480
|
const open = () => {
|
|
4478
4481
|
clearTimeout(closeTimer.current);
|
|
4479
4482
|
clearTimeout(timer.current);
|
|
@@ -4487,11 +4490,11 @@ function Tooltip({
|
|
|
4487
4490
|
const cancelClose = () => {
|
|
4488
4491
|
clearTimeout(closeTimer.current);
|
|
4489
4492
|
};
|
|
4490
|
-
|
|
4493
|
+
React36__namespace.default.useEffect(() => () => {
|
|
4491
4494
|
clearTimeout(timer.current);
|
|
4492
4495
|
clearTimeout(closeTimer.current);
|
|
4493
4496
|
}, []);
|
|
4494
|
-
const place =
|
|
4497
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
4495
4498
|
const el = wrapRef.current;
|
|
4496
4499
|
if (!el) return;
|
|
4497
4500
|
const r = el.getBoundingClientRect();
|
|
@@ -4514,10 +4517,10 @@ function Tooltip({
|
|
|
4514
4517
|
else if (side === "right") setCoords({ ...base, top: clampY(cy), left: Math.round(r.right + gap) });
|
|
4515
4518
|
else setCoords({ ...base, left: clampX(cx), bottom: Math.round(vh - r.top + gap) });
|
|
4516
4519
|
}, [placement]);
|
|
4517
|
-
|
|
4520
|
+
React36__namespace.default.useEffect(() => {
|
|
4518
4521
|
place();
|
|
4519
4522
|
}, [place]);
|
|
4520
|
-
|
|
4523
|
+
React36__namespace.default.useEffect(() => {
|
|
4521
4524
|
if (!show) return void 0;
|
|
4522
4525
|
place();
|
|
4523
4526
|
const onMove = () => place();
|
|
@@ -4528,7 +4531,7 @@ function Tooltip({
|
|
|
4528
4531
|
window.removeEventListener("resize", onMove);
|
|
4529
4532
|
};
|
|
4530
4533
|
}, [show, place]);
|
|
4531
|
-
|
|
4534
|
+
React36__namespace.default.useEffect(() => {
|
|
4532
4535
|
if (!show) return;
|
|
4533
4536
|
const onKeyDown = (e) => {
|
|
4534
4537
|
if (e.key === "Escape") {
|
|
@@ -4540,7 +4543,7 @@ function Tooltip({
|
|
|
4540
4543
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
4541
4544
|
}, [show]);
|
|
4542
4545
|
const describedBy = show ? id : void 0;
|
|
4543
|
-
const trigger =
|
|
4546
|
+
const trigger = React36__namespace.default.isValidElement(children) && children.type !== React36__namespace.default.Fragment ? React36__namespace.default.cloneElement(children, {
|
|
4544
4547
|
"aria-describedby": [children.props["aria-describedby"], describedBy].filter(Boolean).join(" ") || void 0
|
|
4545
4548
|
}) : /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-describedby": describedBy, children });
|
|
4546
4549
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -5144,9 +5147,9 @@ function runDatatableQuery(rows, query, options = {}) {
|
|
|
5144
5147
|
return { rows: page, total, filtered: out };
|
|
5145
5148
|
}
|
|
5146
5149
|
function useFloating() {
|
|
5147
|
-
const [pos, setPos] =
|
|
5148
|
-
const cfg =
|
|
5149
|
-
const place =
|
|
5150
|
+
const [pos, setPos] = React36__namespace.default.useState(null);
|
|
5151
|
+
const cfg = React36__namespace.default.useRef(null);
|
|
5152
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
5150
5153
|
const c = cfg.current;
|
|
5151
5154
|
if (!c || !c.el || !c.el.isConnected) return null;
|
|
5152
5155
|
const r = c.el.getBoundingClientRect();
|
|
@@ -5157,17 +5160,17 @@ function useFloating() {
|
|
|
5157
5160
|
const top = r.bottom + 6;
|
|
5158
5161
|
return { top, left, width: c.width, anchorX: r.left + r.width / 2, maxHeight: Math.max(180, vh - top - M) };
|
|
5159
5162
|
}, []);
|
|
5160
|
-
const open =
|
|
5163
|
+
const open = React36__namespace.default.useCallback((el, align = "left", width = 220) => {
|
|
5161
5164
|
cfg.current = { el, align, width };
|
|
5162
5165
|
const p = place();
|
|
5163
5166
|
if (p) setPos(p);
|
|
5164
5167
|
}, [place]);
|
|
5165
|
-
const close =
|
|
5168
|
+
const close = React36__namespace.default.useCallback(() => {
|
|
5166
5169
|
cfg.current = null;
|
|
5167
5170
|
setPos(null);
|
|
5168
5171
|
}, []);
|
|
5169
5172
|
const isOpen = pos != null;
|
|
5170
|
-
|
|
5173
|
+
React36__namespace.default.useEffect(() => {
|
|
5171
5174
|
if (!isOpen) return void 0;
|
|
5172
5175
|
const update = () => {
|
|
5173
5176
|
const p = place();
|
|
@@ -5191,9 +5194,9 @@ function Caret({ pos }) {
|
|
|
5191
5194
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-dt__caret", style: { left } });
|
|
5192
5195
|
}
|
|
5193
5196
|
function EditCell({ col, value, options, onChange, onCommit, onCommitValue, onCancel, onKeyDown }) {
|
|
5194
|
-
const ref =
|
|
5197
|
+
const ref = React36__namespace.default.useRef(null);
|
|
5195
5198
|
const isSelect = col.editType === "select" || options && col.editType !== "text";
|
|
5196
|
-
|
|
5199
|
+
React36__namespace.default.useEffect(() => {
|
|
5197
5200
|
if (isSelect) {
|
|
5198
5201
|
const t = setTimeout(() => ref.current?.querySelector(".twc-sel__trigger")?.click(), 0);
|
|
5199
5202
|
return () => clearTimeout(t);
|
|
@@ -5401,7 +5404,7 @@ function Datatable({
|
|
|
5401
5404
|
...rest
|
|
5402
5405
|
}) {
|
|
5403
5406
|
const __twcStyles = useScopedStyles("twc-dt-styles", DT_CSS);
|
|
5404
|
-
const cols =
|
|
5407
|
+
const cols = React36__namespace.default.useMemo(() => {
|
|
5405
5408
|
const out = columns.map((c) => {
|
|
5406
5409
|
const isActions = c.type === "actions";
|
|
5407
5410
|
return {
|
|
@@ -5436,7 +5439,7 @@ function Datatable({
|
|
|
5436
5439
|
}
|
|
5437
5440
|
return out;
|
|
5438
5441
|
}, [columns, rowPinning]);
|
|
5439
|
-
const _autoKey =
|
|
5442
|
+
const _autoKey = React36__namespace.default.useRef();
|
|
5440
5443
|
if (!_autoKey.current) _autoKey.current = { map: /* @__PURE__ */ new WeakMap(), n: 0 };
|
|
5441
5444
|
const keyOf = rowKey || ((r, i) => {
|
|
5442
5445
|
if (r != null && r.id != null) return r.id;
|
|
@@ -5451,17 +5454,17 @@ function Datatable({
|
|
|
5451
5454
|
}
|
|
5452
5455
|
return i;
|
|
5453
5456
|
});
|
|
5454
|
-
const [sort, setSort] =
|
|
5455
|
-
const [filters, setFilters] =
|
|
5456
|
-
const [hidden, setHidden] =
|
|
5457
|
-
const [showRowNum, setShowRowNum] =
|
|
5458
|
-
const [wrapped, setWrapped] =
|
|
5457
|
+
const [sort, setSort] = React36__namespace.default.useState(null);
|
|
5458
|
+
const [filters, setFilters] = React36__namespace.default.useState([]);
|
|
5459
|
+
const [hidden, setHidden] = React36__namespace.default.useState(() => /* @__PURE__ */ new Set());
|
|
5460
|
+
const [showRowNum, setShowRowNum] = React36__namespace.default.useState(rowNumbers);
|
|
5461
|
+
const [wrapped, setWrapped] = React36__namespace.default.useState(() => new Set((columns || []).filter((c) => c.wrapText).map((c) => c.field)));
|
|
5459
5462
|
const toggleWrap = (field) => setWrapped((w) => {
|
|
5460
5463
|
const n = new Set(w);
|
|
5461
5464
|
n.has(field) ? n.delete(field) : n.add(field);
|
|
5462
5465
|
return n;
|
|
5463
5466
|
});
|
|
5464
|
-
const [pins, setPins] =
|
|
5467
|
+
const [pins, setPins] = React36__namespace.default.useState(() => {
|
|
5465
5468
|
const left = [], right = [];
|
|
5466
5469
|
columns.forEach((c) => {
|
|
5467
5470
|
if (c.pinned === "left") left.push(c.field);
|
|
@@ -5469,13 +5472,13 @@ function Datatable({
|
|
|
5469
5472
|
});
|
|
5470
5473
|
return { left, right };
|
|
5471
5474
|
});
|
|
5472
|
-
const [density, setDensity] =
|
|
5473
|
-
const [quick, setQuick] =
|
|
5474
|
-
const [selected, setSelected] =
|
|
5475
|
-
const [activeRow, setActiveRow] =
|
|
5476
|
-
const [activeCell, setActiveCell] =
|
|
5477
|
-
const [internalPage, setInternalPage] =
|
|
5478
|
-
const [internalRpp, setInternalRpp] =
|
|
5475
|
+
const [density, setDensity] = React36__namespace.default.useState(densityProp);
|
|
5476
|
+
const [quick, setQuick] = React36__namespace.default.useState("");
|
|
5477
|
+
const [selected, setSelected] = React36__namespace.default.useState(() => /* @__PURE__ */ new Set());
|
|
5478
|
+
const [activeRow, setActiveRow] = React36__namespace.default.useState(null);
|
|
5479
|
+
const [activeCell, setActiveCell] = React36__namespace.default.useState(null);
|
|
5480
|
+
const [internalPage, setInternalPage] = React36__namespace.default.useState(0);
|
|
5481
|
+
const [internalRpp, setInternalRpp] = React36__namespace.default.useState(pageSize > 0 ? pageSize : 10);
|
|
5479
5482
|
const pageControlled = page !== void 0;
|
|
5480
5483
|
const pageSizeControlled = onPageSizeChange !== void 0;
|
|
5481
5484
|
const pageVal = pageControlled ? page : internalPage;
|
|
@@ -5489,27 +5492,27 @@ function Datatable({
|
|
|
5489
5492
|
if (!pageSizeControlled) setInternalRpp(next);
|
|
5490
5493
|
commitPage(0);
|
|
5491
5494
|
};
|
|
5492
|
-
const [colQuery, setColQuery] =
|
|
5493
|
-
const [widths, setWidths] =
|
|
5494
|
-
const [order, setOrder] =
|
|
5495
|
-
const [drag, setDrag] =
|
|
5496
|
-
const [aggOn, setAggOn] =
|
|
5497
|
-
const [focus, setFocus] =
|
|
5498
|
-
const gridRef =
|
|
5499
|
-
const [groupBy, setGroupBy] =
|
|
5500
|
-
const [collapsed, setCollapsed] =
|
|
5501
|
-
const [pinnedRows, setPinnedRows] =
|
|
5502
|
-
const [headH, setHeadH] =
|
|
5503
|
-
const theadRef =
|
|
5504
|
-
const [rowOrder, setRowOrder] =
|
|
5505
|
-
const [rowHeights, setRowHeights] =
|
|
5506
|
-
const [rowDrag, setRowDrag] =
|
|
5507
|
-
const [rowGrab, setRowGrab] =
|
|
5508
|
-
const [reorderMsg, setReorderMsg] =
|
|
5509
|
-
const rowFocusRef =
|
|
5510
|
-
const rootRef =
|
|
5511
|
-
const [compact, setCompact] =
|
|
5512
|
-
|
|
5495
|
+
const [colQuery, setColQuery] = React36__namespace.default.useState("");
|
|
5496
|
+
const [widths, setWidths] = React36__namespace.default.useState({});
|
|
5497
|
+
const [order, setOrder] = React36__namespace.default.useState(() => columns.map((c) => c.field));
|
|
5498
|
+
const [drag, setDrag] = React36__namespace.default.useState({ from: null, over: null, after: false });
|
|
5499
|
+
const [aggOn, setAggOn] = React36__namespace.default.useState(showAggregation);
|
|
5500
|
+
const [focus, setFocus] = React36__namespace.default.useState({ r: 0, c: 0 });
|
|
5501
|
+
const gridRef = React36__namespace.default.useRef(null);
|
|
5502
|
+
const [groupBy, setGroupBy] = React36__namespace.default.useState(rowGrouping || []);
|
|
5503
|
+
const [collapsed, setCollapsed] = React36__namespace.default.useState(() => /* @__PURE__ */ new Set());
|
|
5504
|
+
const [pinnedRows, setPinnedRows] = React36__namespace.default.useState({ top: [], bottom: [] });
|
|
5505
|
+
const [headH, setHeadH] = React36__namespace.default.useState(41);
|
|
5506
|
+
const theadRef = React36__namespace.default.useRef(null);
|
|
5507
|
+
const [rowOrder, setRowOrder] = React36__namespace.default.useState(null);
|
|
5508
|
+
const [rowHeights, setRowHeights] = React36__namespace.default.useState({});
|
|
5509
|
+
const [rowDrag, setRowDrag] = React36__namespace.default.useState({ from: null, over: null, after: false });
|
|
5510
|
+
const [rowGrab, setRowGrab] = React36__namespace.default.useState(null);
|
|
5511
|
+
const [reorderMsg, setReorderMsg] = React36__namespace.default.useState("");
|
|
5512
|
+
const rowFocusRef = React36__namespace.default.useRef(null);
|
|
5513
|
+
const rootRef = React36__namespace.default.useRef(null);
|
|
5514
|
+
const [compact, setCompact] = React36__namespace.default.useState(false);
|
|
5515
|
+
React36__namespace.default.useEffect(() => {
|
|
5513
5516
|
const el = rootRef.current;
|
|
5514
5517
|
if (!el) return void 0;
|
|
5515
5518
|
const measure = () => setCompact((el.clientWidth || 0) < 720);
|
|
@@ -5522,11 +5525,11 @@ function Datatable({
|
|
|
5522
5525
|
else if (typeof window !== "undefined") window.removeEventListener("resize", measure);
|
|
5523
5526
|
};
|
|
5524
5527
|
}, []);
|
|
5525
|
-
const scrollRef =
|
|
5526
|
-
const [scrollTop, setScrollTop] =
|
|
5527
|
-
const [viewportH, setViewportH] =
|
|
5528
|
-
const [pivotOn, setPivotOn] =
|
|
5529
|
-
const [aggConfig, setAggConfig] =
|
|
5528
|
+
const scrollRef = React36__namespace.default.useRef(null);
|
|
5529
|
+
const [scrollTop, setScrollTop] = React36__namespace.default.useState(0);
|
|
5530
|
+
const [viewportH, setViewportH] = React36__namespace.default.useState(0);
|
|
5531
|
+
const [pivotOn, setPivotOn] = React36__namespace.default.useState(pivotMode);
|
|
5532
|
+
const [aggConfig, setAggConfig] = React36__namespace.default.useState(() => {
|
|
5530
5533
|
const m = {};
|
|
5531
5534
|
(columns || []).forEach((c) => {
|
|
5532
5535
|
if (typeof c.aggregation === "string") m[c.field] = c.aggregation;
|
|
@@ -5534,13 +5537,13 @@ function Datatable({
|
|
|
5534
5537
|
return m;
|
|
5535
5538
|
});
|
|
5536
5539
|
const aggOf = (c) => aggConfig[c.field] || (typeof c.aggregation === "function" ? c.aggregation : null);
|
|
5537
|
-
const [pivotConfig, setPivotConfig] =
|
|
5540
|
+
const [pivotConfig, setPivotConfig] = React36__namespace.default.useState(() => ({
|
|
5538
5541
|
rows: pivot && pivot.rows || [],
|
|
5539
5542
|
columns: pivot && pivot.columns || [],
|
|
5540
5543
|
values: pivot && pivot.values || []
|
|
5541
5544
|
}));
|
|
5542
5545
|
const pivotActive = pivotOn && pivotConfig.rows.length > 0 && pivotConfig.values.length > 0;
|
|
5543
|
-
|
|
5546
|
+
React36__namespace.default.useEffect(() => {
|
|
5544
5547
|
setOrder((prev) => {
|
|
5545
5548
|
const fields = columns.map((c) => c.field);
|
|
5546
5549
|
const kept = prev.filter((f) => fields.includes(f));
|
|
@@ -5548,37 +5551,37 @@ function Datatable({
|
|
|
5548
5551
|
return [...kept, ...added];
|
|
5549
5552
|
});
|
|
5550
5553
|
}, [columns]);
|
|
5551
|
-
|
|
5554
|
+
React36__namespace.default.useEffect(() => {
|
|
5552
5555
|
setDensity(densityProp);
|
|
5553
5556
|
}, [densityProp]);
|
|
5554
|
-
|
|
5557
|
+
React36__namespace.default.useEffect(() => {
|
|
5555
5558
|
setAggOn(showAggregation);
|
|
5556
5559
|
}, [showAggregation]);
|
|
5557
|
-
|
|
5560
|
+
React36__namespace.default.useEffect(() => {
|
|
5558
5561
|
if (pageSizeControlled) return;
|
|
5559
5562
|
setInternalRpp(pageSize > 0 ? pageSize : 10);
|
|
5560
5563
|
setInternalPage(0);
|
|
5561
5564
|
}, [pageSize]);
|
|
5562
5565
|
const rowGroupingKey = (rowGrouping || []).join("\0");
|
|
5563
|
-
const rowGroupingKeyRef =
|
|
5564
|
-
|
|
5566
|
+
const rowGroupingKeyRef = React36__namespace.default.useRef(rowGroupingKey);
|
|
5567
|
+
React36__namespace.default.useEffect(() => {
|
|
5565
5568
|
if (rowGroupingKeyRef.current === rowGroupingKey) return;
|
|
5566
5569
|
rowGroupingKeyRef.current = rowGroupingKey;
|
|
5567
5570
|
setGroupBy(rowGrouping || []);
|
|
5568
5571
|
}, [rowGroupingKey]);
|
|
5569
5572
|
const widthOf = (c) => widths[c.field] ?? c.width ?? 160;
|
|
5570
|
-
const [colMenu, setColMenu] =
|
|
5573
|
+
const [colMenu, setColMenu] = React36__namespace.default.useState(null);
|
|
5571
5574
|
const [menuPos, openMenu, closeMenu] = useFloating();
|
|
5572
|
-
const [panel, setPanel] =
|
|
5575
|
+
const [panel, setPanel] = React36__namespace.default.useState(null);
|
|
5573
5576
|
const [panelPos, openPanel, closePanel] = useFloating();
|
|
5574
|
-
const [rowMenu, setRowMenu] =
|
|
5577
|
+
const [rowMenu, setRowMenu] = React36__namespace.default.useState(null);
|
|
5575
5578
|
const [rowMenuPos, openRowMenu, closeRowMenu] = useFloating();
|
|
5576
|
-
const [exportOpen, setExportOpen] =
|
|
5579
|
+
const [exportOpen, setExportOpen] = React36__namespace.default.useState(false);
|
|
5577
5580
|
const [exportPos, openExport, closeExport] = useFloating();
|
|
5578
|
-
const menuTriggerRef =
|
|
5579
|
-
const colMenuRef =
|
|
5580
|
-
const rowMenuRef =
|
|
5581
|
-
const exportMenuRef =
|
|
5581
|
+
const menuTriggerRef = React36__namespace.default.useRef(null);
|
|
5582
|
+
const colMenuRef = React36__namespace.default.useRef(null);
|
|
5583
|
+
const rowMenuRef = React36__namespace.default.useRef(null);
|
|
5584
|
+
const exportMenuRef = React36__namespace.default.useRef(null);
|
|
5582
5585
|
function focusFirstItem(container) {
|
|
5583
5586
|
if (!container) return;
|
|
5584
5587
|
const first = container.querySelector('[role="menuitem"]:not([disabled])');
|
|
@@ -5617,16 +5620,16 @@ function Datatable({
|
|
|
5617
5620
|
restoreTriggerFocus();
|
|
5618
5621
|
}
|
|
5619
5622
|
}
|
|
5620
|
-
|
|
5623
|
+
React36__namespace.default.useEffect(() => {
|
|
5621
5624
|
if (colMenu) focusFirstItem(colMenuRef.current);
|
|
5622
5625
|
}, [colMenu]);
|
|
5623
|
-
|
|
5626
|
+
React36__namespace.default.useEffect(() => {
|
|
5624
5627
|
if (rowMenu) focusFirstItem(rowMenuRef.current);
|
|
5625
5628
|
}, [rowMenu]);
|
|
5626
|
-
|
|
5629
|
+
React36__namespace.default.useEffect(() => {
|
|
5627
5630
|
if (exportOpen) focusFirstItem(exportMenuRef.current);
|
|
5628
5631
|
}, [exportOpen]);
|
|
5629
|
-
|
|
5632
|
+
React36__namespace.default.useEffect(() => {
|
|
5630
5633
|
if (!colMenu && !panel && !rowMenu) return;
|
|
5631
5634
|
const closeAll = () => {
|
|
5632
5635
|
setColMenu(null);
|
|
@@ -5649,7 +5652,7 @@ function Datatable({
|
|
|
5649
5652
|
document.removeEventListener("keydown", onKey);
|
|
5650
5653
|
};
|
|
5651
5654
|
}, [colMenu, panel, rowMenu]);
|
|
5652
|
-
|
|
5655
|
+
React36__namespace.default.useEffect(() => {
|
|
5653
5656
|
if (!exportOpen) return;
|
|
5654
5657
|
const close = () => {
|
|
5655
5658
|
setExportOpen(false);
|
|
@@ -5668,9 +5671,9 @@ function Datatable({
|
|
|
5668
5671
|
document.removeEventListener("keydown", onKey);
|
|
5669
5672
|
};
|
|
5670
5673
|
}, [exportOpen]);
|
|
5671
|
-
const colByField =
|
|
5674
|
+
const colByField = React36__namespace.default.useMemo(() => Object.fromEntries(cols.map((c) => [c.field, c])), [cols]);
|
|
5672
5675
|
const visibleCols = cols.filter((c) => !hidden.has(c.field));
|
|
5673
|
-
const ordered =
|
|
5676
|
+
const ordered = React36__namespace.default.useMemo(() => {
|
|
5674
5677
|
const orderIdx = (f) => {
|
|
5675
5678
|
const i = order.indexOf(f);
|
|
5676
5679
|
return i === -1 ? 9999 : i;
|
|
@@ -5705,7 +5708,7 @@ function Datatable({
|
|
|
5705
5708
|
}
|
|
5706
5709
|
return {};
|
|
5707
5710
|
};
|
|
5708
|
-
const processed =
|
|
5711
|
+
const processed = React36__namespace.default.useMemo(() => {
|
|
5709
5712
|
if (serverMode) {
|
|
5710
5713
|
if (rowOrder) {
|
|
5711
5714
|
const idx = new Map(rowOrder.map((k, i) => [k, i]));
|
|
@@ -5744,10 +5747,10 @@ function Datatable({
|
|
|
5744
5747
|
const totalRows = serverMode ? serverTotal : processed.length;
|
|
5745
5748
|
const totalPages = paginated ? Math.max(1, Math.ceil(totalRows / sizeVal)) : 1;
|
|
5746
5749
|
const paged = !paginated || serverMode ? processed : processed.slice(pageVal * sizeVal, pageVal * sizeVal + sizeVal);
|
|
5747
|
-
|
|
5750
|
+
React36__namespace.default.useEffect(() => {
|
|
5748
5751
|
if (pageVal > totalPages - 1) commitPage(0);
|
|
5749
5752
|
}, [totalPages]);
|
|
5750
|
-
const activeGroupBy =
|
|
5753
|
+
const activeGroupBy = React36__namespace.default.useMemo(() => groupBy.filter((f) => colByField[f]), [groupBy, colByField]);
|
|
5751
5754
|
function subtotalText(rowsIn) {
|
|
5752
5755
|
const parts = [];
|
|
5753
5756
|
for (const c of ordered) {
|
|
@@ -5774,7 +5777,7 @@ function Datatable({
|
|
|
5774
5777
|
if (agg === "max") return Math.max(...nums);
|
|
5775
5778
|
return null;
|
|
5776
5779
|
}
|
|
5777
|
-
const displayItems =
|
|
5780
|
+
const displayItems = React36__namespace.default.useMemo(() => {
|
|
5778
5781
|
if (!activeGroupBy.length) return null;
|
|
5779
5782
|
const build = (rowsIn, depth, prefix) => {
|
|
5780
5783
|
if (depth >= activeGroupBy.length) return rowsIn.map((row) => ({ kind: "leaf", row }));
|
|
@@ -5816,7 +5819,7 @@ function Datatable({
|
|
|
5816
5819
|
return { top, bottom };
|
|
5817
5820
|
});
|
|
5818
5821
|
}
|
|
5819
|
-
|
|
5822
|
+
React36__namespace.default.useEffect(() => {
|
|
5820
5823
|
if (!rowPinning) return;
|
|
5821
5824
|
const measure = () => {
|
|
5822
5825
|
if (theadRef.current) setHeadH(theadRef.current.offsetHeight || 41);
|
|
@@ -5830,12 +5833,12 @@ function Datatable({
|
|
|
5830
5833
|
const pinnedTopRows = canPinRows ? pinnedRows.top.map((k) => leafRows.find((r, i) => keyOf(r, i) === k)).filter(Boolean) : [];
|
|
5831
5834
|
const pinnedBottomRows = canPinRows ? pinnedRows.bottom.map((k) => leafRows.find((r, i) => keyOf(r, i) === k)).filter(Boolean) : [];
|
|
5832
5835
|
const middleRows = canPinRows ? leafRows.filter((r, i) => !pinSideOf(keyOf(r, i))) : leafRows;
|
|
5833
|
-
const keyIndex =
|
|
5836
|
+
const keyIndex = React36__namespace.default.useMemo(() => {
|
|
5834
5837
|
const m = /* @__PURE__ */ new Map();
|
|
5835
5838
|
leafRows.forEach((r, i) => m.set(keyOf(r, i), i));
|
|
5836
5839
|
return m;
|
|
5837
5840
|
}, [leafRows]);
|
|
5838
|
-
const keyIndexMid =
|
|
5841
|
+
const keyIndexMid = React36__namespace.default.useMemo(() => {
|
|
5839
5842
|
const m = /* @__PURE__ */ new Map();
|
|
5840
5843
|
middleRows.forEach((r, i) => m.set(keyOf(r, keyIndex.get(keyOf(r)) ?? i), i));
|
|
5841
5844
|
return m;
|
|
@@ -5920,7 +5923,7 @@ function Datatable({
|
|
|
5920
5923
|
setReorderMsg("Reorder cancelled.");
|
|
5921
5924
|
}
|
|
5922
5925
|
}
|
|
5923
|
-
|
|
5926
|
+
React36__namespace.default.useEffect(() => {
|
|
5924
5927
|
if (rowFocusRef.current == null) return;
|
|
5925
5928
|
const key = rowFocusRef.current;
|
|
5926
5929
|
rowFocusRef.current = null;
|
|
@@ -5932,7 +5935,7 @@ function Datatable({
|
|
|
5932
5935
|
});
|
|
5933
5936
|
const estRowH = rowHeight ?? (density === "compact" ? 36 : density === "comfortable" ? 56 : 44);
|
|
5934
5937
|
const virtualizing = virtualized && !paginated && !activeGroupBy.length && !loading;
|
|
5935
|
-
|
|
5938
|
+
React36__namespace.default.useEffect(() => {
|
|
5936
5939
|
if (!virtualizing) return;
|
|
5937
5940
|
const el = scrollRef.current;
|
|
5938
5941
|
if (!el) return;
|
|
@@ -5942,13 +5945,13 @@ function Datatable({
|
|
|
5942
5945
|
if (ro) ro.observe(el);
|
|
5943
5946
|
return () => ro && ro.disconnect();
|
|
5944
5947
|
}, [virtualizing, height]);
|
|
5945
|
-
const onScrollVirtual =
|
|
5948
|
+
const onScrollVirtual = React36__namespace.default.useCallback((e) => {
|
|
5946
5949
|
setScrollTop(e.currentTarget.scrollTop);
|
|
5947
5950
|
}, []);
|
|
5948
5951
|
const vh = viewportH || (typeof height === "number" ? height : 440);
|
|
5949
|
-
const rowHRef =
|
|
5950
|
-
const [measureTick, setMeasureTick] =
|
|
5951
|
-
const offsets =
|
|
5952
|
+
const rowHRef = React36__namespace.default.useRef(/* @__PURE__ */ new Map());
|
|
5953
|
+
const [measureTick, setMeasureTick] = React36__namespace.default.useState(0);
|
|
5954
|
+
const offsets = React36__namespace.default.useMemo(() => {
|
|
5952
5955
|
if (!virtualizing) return null;
|
|
5953
5956
|
const total = middleRows.length;
|
|
5954
5957
|
const arr = new Float64Array(total + 1);
|
|
@@ -5958,7 +5961,7 @@ function Datatable({
|
|
|
5958
5961
|
}
|
|
5959
5962
|
return arr;
|
|
5960
5963
|
}, [virtualizing, middleRows, estRowH, measureTick]);
|
|
5961
|
-
const vWindow =
|
|
5964
|
+
const vWindow = React36__namespace.default.useMemo(() => {
|
|
5962
5965
|
if (!virtualizing || !offsets) return null;
|
|
5963
5966
|
const total = middleRows.length;
|
|
5964
5967
|
const totalH = offsets[total];
|
|
@@ -5987,7 +5990,7 @@ function Datatable({
|
|
|
5987
5990
|
if (start > end) start = end;
|
|
5988
5991
|
return { start, end, padTop: offsets[start], padBottom: Math.max(0, totalH - offsets[end]) };
|
|
5989
5992
|
}, [virtualizing, offsets, middleRows.length, vh, scrollTop, overscan]);
|
|
5990
|
-
|
|
5993
|
+
React36__namespace.default.useLayoutEffect(() => {
|
|
5991
5994
|
if (!virtualizing) return;
|
|
5992
5995
|
const el = scrollRef.current;
|
|
5993
5996
|
if (!el) return;
|
|
@@ -6002,9 +6005,9 @@ function Datatable({
|
|
|
6002
6005
|
}
|
|
6003
6006
|
if (changed) setMeasureTick((t) => t + 1);
|
|
6004
6007
|
});
|
|
6005
|
-
const onServerChangeRef =
|
|
6008
|
+
const onServerChangeRef = React36__namespace.default.useRef(onServerChange);
|
|
6006
6009
|
onServerChangeRef.current = onServerChange;
|
|
6007
|
-
|
|
6010
|
+
React36__namespace.default.useEffect(() => {
|
|
6008
6011
|
if (!serverMode) return;
|
|
6009
6012
|
const t = setTimeout(() => {
|
|
6010
6013
|
onServerChangeRef.current?.({
|
|
@@ -6039,7 +6042,7 @@ function Datatable({
|
|
|
6039
6042
|
return n;
|
|
6040
6043
|
});
|
|
6041
6044
|
}
|
|
6042
|
-
const movableMidFields =
|
|
6045
|
+
const movableMidFields = React36__namespace.default.useMemo(
|
|
6043
6046
|
() => ordered.filter((c) => !pins.left.includes(c.field) && !pins.right.includes(c.field) && c.reorderable !== false).map((c) => c.field),
|
|
6044
6047
|
[ordered, pins]
|
|
6045
6048
|
);
|
|
@@ -6070,7 +6073,7 @@ function Datatable({
|
|
|
6070
6073
|
}
|
|
6071
6074
|
return [...set].sort((a, b) => a.localeCompare(b)).map((v) => ({ value: v, label: v }));
|
|
6072
6075
|
}
|
|
6073
|
-
const [resizing, setResizing] =
|
|
6076
|
+
const [resizing, setResizing] = React36__namespace.default.useState(false);
|
|
6074
6077
|
function startResize(e, field) {
|
|
6075
6078
|
e.preventDefault();
|
|
6076
6079
|
e.stopPropagation();
|
|
@@ -6177,7 +6180,7 @@ function Datatable({
|
|
|
6177
6180
|
if (!agg) return null;
|
|
6178
6181
|
if (aggregationValues && col.field in aggregationValues) {
|
|
6179
6182
|
const pre = aggregationValues[col.field];
|
|
6180
|
-
if (pre && typeof pre === "object" && !
|
|
6183
|
+
if (pre && typeof pre === "object" && !React36__namespace.default.isValidElement(pre)) {
|
|
6181
6184
|
if (typeof agg === "string" && agg in pre) return pre[agg];
|
|
6182
6185
|
} else {
|
|
6183
6186
|
return pre;
|
|
@@ -6295,14 +6298,14 @@ function Datatable({
|
|
|
6295
6298
|
focusCell(r, c);
|
|
6296
6299
|
}
|
|
6297
6300
|
}
|
|
6298
|
-
|
|
6301
|
+
React36__namespace.default.useEffect(() => {
|
|
6299
6302
|
setFocus((f) => ({ r: Math.min(f.r, Math.max(0, leafRows.length - 1)), c: Math.min(f.c, Math.max(0, ordered.length - 1)) }));
|
|
6300
6303
|
}, [leafRows.length, ordered.length, pageVal]);
|
|
6301
|
-
const selectedRows =
|
|
6304
|
+
const selectedRows = React36__namespace.default.useMemo(() => rows.filter((r, i) => selected.has(keyOf(r, i))), [rows, selected]);
|
|
6302
6305
|
function clearSelection() {
|
|
6303
6306
|
setSelected(/* @__PURE__ */ new Set());
|
|
6304
6307
|
}
|
|
6305
|
-
const [editing, setEditing] =
|
|
6308
|
+
const [editing, setEditing] = React36__namespace.default.useState(null);
|
|
6306
6309
|
const isColEditable = (c) => c.type !== "actions" && (c.editable ?? (editMode && c.editable !== false));
|
|
6307
6310
|
function beginEdit(rowK, col, row) {
|
|
6308
6311
|
if (!isColEditable(col)) return;
|
|
@@ -6337,17 +6340,17 @@ function Datatable({
|
|
|
6337
6340
|
cancelEdit();
|
|
6338
6341
|
}
|
|
6339
6342
|
}
|
|
6340
|
-
const batchEditableCols =
|
|
6343
|
+
const batchEditableCols = React36__namespace.default.useMemo(
|
|
6341
6344
|
() => cols.filter((c) => c.type !== "actions" && (c.editable ?? (editMode && c.editable !== false))),
|
|
6342
6345
|
[cols, editMode]
|
|
6343
6346
|
);
|
|
6344
|
-
const [batchEdit, setBatchEdit] =
|
|
6347
|
+
const [batchEdit, setBatchEdit] = React36__namespace.default.useState(null);
|
|
6345
6348
|
const [batchEditPos, openBatchEdit, closeBatchEdit] = useFloating();
|
|
6346
6349
|
function openBatchEditor(el) {
|
|
6347
6350
|
setBatchEdit({ fields: {}, values: {} });
|
|
6348
6351
|
openBatchEdit(el, "left", 320);
|
|
6349
6352
|
}
|
|
6350
|
-
|
|
6353
|
+
React36__namespace.default.useEffect(() => {
|
|
6351
6354
|
if (!batchEdit) return;
|
|
6352
6355
|
const close = () => {
|
|
6353
6356
|
setBatchEdit(null);
|
|
@@ -6366,7 +6369,7 @@ function Datatable({
|
|
|
6366
6369
|
document.removeEventListener("keydown", onKey);
|
|
6367
6370
|
};
|
|
6368
6371
|
}, [batchEdit]);
|
|
6369
|
-
|
|
6372
|
+
React36__namespace.default.useEffect(() => {
|
|
6370
6373
|
if (batchEdit && selected.size === 0) {
|
|
6371
6374
|
setBatchEdit(null);
|
|
6372
6375
|
closeBatchEdit();
|
|
@@ -6403,7 +6406,7 @@ function Datatable({
|
|
|
6403
6406
|
setBatchEdit(null);
|
|
6404
6407
|
closeBatchEdit();
|
|
6405
6408
|
}
|
|
6406
|
-
|
|
6409
|
+
React36__namespace.default.useEffect(() => {
|
|
6407
6410
|
if (!editing) return;
|
|
6408
6411
|
const onDown = (e) => {
|
|
6409
6412
|
if (e.target.closest(".twc-dt__editor-wrap") || e.target.closest(".twc-pop")) return;
|
|
@@ -7937,25 +7940,25 @@ function DatePicker({
|
|
|
7937
7940
|
}) {
|
|
7938
7941
|
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS3);
|
|
7939
7942
|
const __twcStyles1 = useScopedStyles("twc-datepicker-styles", DATEPICKER_CSS);
|
|
7940
|
-
const autoId =
|
|
7943
|
+
const autoId = React36__namespace.default.useId();
|
|
7941
7944
|
const fieldId = id || autoId;
|
|
7942
7945
|
const descId = `${fieldId}-desc`;
|
|
7943
7946
|
const invalid = Boolean(error);
|
|
7944
|
-
const [internal, setInternal] =
|
|
7947
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
7945
7948
|
const selected = value !== void 0 ? value : internal;
|
|
7946
|
-
const [open, setOpen] =
|
|
7947
|
-
const [view, setView] =
|
|
7948
|
-
const [mode, setMode] =
|
|
7949
|
-
const [focusDate, setFocusDate] =
|
|
7950
|
-
const [focusMonth, setFocusMonth] =
|
|
7951
|
-
const [editText, setEditText] =
|
|
7952
|
-
const [coords, setCoords] =
|
|
7953
|
-
const wrapRef =
|
|
7954
|
-
const triggerRef =
|
|
7955
|
-
const popRef =
|
|
7956
|
-
const gridRef =
|
|
7949
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
7950
|
+
const [view, setView] = React36__namespace.default.useState(selected || /* @__PURE__ */ new Date());
|
|
7951
|
+
const [mode, setMode] = React36__namespace.default.useState("days");
|
|
7952
|
+
const [focusDate, setFocusDate] = React36__namespace.default.useState(null);
|
|
7953
|
+
const [focusMonth, setFocusMonth] = React36__namespace.default.useState(null);
|
|
7954
|
+
const [editText, setEditText] = React36__namespace.default.useState(null);
|
|
7955
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
7956
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
7957
|
+
const triggerRef = React36__namespace.default.useRef(null);
|
|
7958
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
7959
|
+
const gridRef = React36__namespace.default.useRef(null);
|
|
7957
7960
|
const POP_W = 280;
|
|
7958
|
-
const place =
|
|
7961
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
7959
7962
|
const el = triggerRef.current;
|
|
7960
7963
|
if (!el) return;
|
|
7961
7964
|
const r = el.getBoundingClientRect();
|
|
@@ -7966,7 +7969,7 @@ function DatePicker({
|
|
|
7966
7969
|
left = Math.max(8, left);
|
|
7967
7970
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
7968
7971
|
}, []);
|
|
7969
|
-
|
|
7972
|
+
React36__namespace.default.useEffect(() => {
|
|
7970
7973
|
if (!open) return void 0;
|
|
7971
7974
|
place();
|
|
7972
7975
|
const onMove = () => place();
|
|
@@ -7977,7 +7980,7 @@ function DatePicker({
|
|
|
7977
7980
|
window.removeEventListener("resize", onMove);
|
|
7978
7981
|
};
|
|
7979
7982
|
}, [open, place]);
|
|
7980
|
-
|
|
7983
|
+
React36__namespace.default.useEffect(() => {
|
|
7981
7984
|
if (!open) return;
|
|
7982
7985
|
setView(selected || /* @__PURE__ */ new Date());
|
|
7983
7986
|
setMode("days");
|
|
@@ -7998,9 +8001,9 @@ function DatePicker({
|
|
|
7998
8001
|
};
|
|
7999
8002
|
}, [open]);
|
|
8000
8003
|
useFocusTrap(popRef, open && !!coords, { initialFocus: () => gridRef.current?.querySelector('[tabindex="0"]') });
|
|
8001
|
-
const months =
|
|
8002
|
-
const monthsShort =
|
|
8003
|
-
const dows =
|
|
8004
|
+
const months = React36__namespace.default.useMemo(() => locale === void 0 ? MONTHS : monthNames(locale), [locale]);
|
|
8005
|
+
const monthsShort = React36__namespace.default.useMemo(() => locale === void 0 ? MONTHS.map((n) => n.slice(0, 3)) : monthShortNames(locale), [locale]);
|
|
8006
|
+
const dows = React36__namespace.default.useMemo(
|
|
8004
8007
|
() => locale === void 0 ? Array.from({ length: 7 }, (_, i) => DOW[(i + weekStartsOn) % 7]) : weekdayNames(locale, weekStartsOn),
|
|
8005
8008
|
[locale, weekStartsOn]
|
|
8006
8009
|
);
|
|
@@ -8053,11 +8056,11 @@ function DatePicker({
|
|
|
8053
8056
|
};
|
|
8054
8057
|
const cells = Array.from({ length: 42 }, (_, i) => new Date(gridStart.getFullYear(), gridStart.getMonth(), gridStart.getDate() + i));
|
|
8055
8058
|
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);
|
|
8056
|
-
|
|
8059
|
+
React36__namespace.default.useEffect(() => {
|
|
8057
8060
|
if (!open || mode !== "days" || !focusDate) return;
|
|
8058
8061
|
gridRef.current?.querySelector(`[data-key="${keyOf(focusDate)}"]`)?.focus();
|
|
8059
8062
|
}, [focusDate, open, mode]);
|
|
8060
|
-
|
|
8063
|
+
React36__namespace.default.useEffect(() => {
|
|
8061
8064
|
if (!open || mode !== "months" || focusMonth == null) return;
|
|
8062
8065
|
gridRef.current?.querySelector(`[data-mo="${focusMonth}"]`)?.focus();
|
|
8063
8066
|
}, [focusMonth, open, mode]);
|
|
@@ -8400,26 +8403,26 @@ function DateRangePicker({
|
|
|
8400
8403
|
}) {
|
|
8401
8404
|
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS4);
|
|
8402
8405
|
const __twcStyles1 = useScopedStyles("twc-drp-styles", RANGE_CSS);
|
|
8403
|
-
const [internal, setInternal] =
|
|
8406
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
8404
8407
|
const range = value !== void 0 ? value : internal;
|
|
8405
|
-
const [open, setOpen] =
|
|
8406
|
-
const [view, setView] =
|
|
8407
|
-
const [hover, setHover] =
|
|
8408
|
-
const [focusDate, setFocusDate] =
|
|
8409
|
-
const [editText, setEditText] =
|
|
8410
|
-
const [coords, setCoords] =
|
|
8411
|
-
const wrapRef =
|
|
8412
|
-
const triggerRef =
|
|
8413
|
-
const popRef =
|
|
8414
|
-
const gridRef =
|
|
8415
|
-
const labelId =
|
|
8408
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
8409
|
+
const [view, setView] = React36__namespace.default.useState(range.start || /* @__PURE__ */ new Date());
|
|
8410
|
+
const [hover, setHover] = React36__namespace.default.useState(null);
|
|
8411
|
+
const [focusDate, setFocusDate] = React36__namespace.default.useState(null);
|
|
8412
|
+
const [editText, setEditText] = React36__namespace.default.useState(null);
|
|
8413
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
8414
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
8415
|
+
const triggerRef = React36__namespace.default.useRef(null);
|
|
8416
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
8417
|
+
const gridRef = React36__namespace.default.useRef(null);
|
|
8418
|
+
const labelId = React36__namespace.default.useId();
|
|
8416
8419
|
const descId = `${labelId}-desc`;
|
|
8417
8420
|
const invalid = Boolean(error);
|
|
8418
|
-
|
|
8421
|
+
React36__namespace.default.useEffect(() => {
|
|
8419
8422
|
if (disabled) setOpen(false);
|
|
8420
8423
|
}, [disabled]);
|
|
8421
8424
|
const POP_W = 420;
|
|
8422
|
-
const place =
|
|
8425
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
8423
8426
|
const el = triggerRef.current;
|
|
8424
8427
|
if (!el) return;
|
|
8425
8428
|
const r = el.getBoundingClientRect();
|
|
@@ -8430,7 +8433,7 @@ function DateRangePicker({
|
|
|
8430
8433
|
left = Math.max(8, left);
|
|
8431
8434
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
8432
8435
|
}, []);
|
|
8433
|
-
|
|
8436
|
+
React36__namespace.default.useEffect(() => {
|
|
8434
8437
|
if (!open) return void 0;
|
|
8435
8438
|
place();
|
|
8436
8439
|
const onMove = () => place();
|
|
@@ -8441,7 +8444,7 @@ function DateRangePicker({
|
|
|
8441
8444
|
window.removeEventListener("resize", onMove);
|
|
8442
8445
|
};
|
|
8443
8446
|
}, [open, place]);
|
|
8444
|
-
|
|
8447
|
+
React36__namespace.default.useEffect(() => {
|
|
8445
8448
|
if (!open) return;
|
|
8446
8449
|
const onDown = (e) => {
|
|
8447
8450
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -8505,13 +8508,13 @@ function DateRangePicker({
|
|
|
8505
8508
|
const last = new Date(d.getFullYear(), d.getMonth() + n + 1, 0);
|
|
8506
8509
|
return new Date(last.getFullYear(), last.getMonth(), Math.min(d.getDate(), last.getDate()));
|
|
8507
8510
|
};
|
|
8508
|
-
|
|
8511
|
+
React36__namespace.default.useEffect(() => {
|
|
8509
8512
|
if (!open) {
|
|
8510
8513
|
setFocusDate(null);
|
|
8511
8514
|
setHover(null);
|
|
8512
8515
|
}
|
|
8513
8516
|
}, [open]);
|
|
8514
|
-
|
|
8517
|
+
React36__namespace.default.useEffect(() => {
|
|
8515
8518
|
if (!open || !focusDate) return;
|
|
8516
8519
|
gridRef.current?.querySelector(`[data-key="${keyOf(focusDate)}"]`)?.focus();
|
|
8517
8520
|
}, [focusDate, open]);
|
|
@@ -8560,8 +8563,8 @@ function DateRangePicker({
|
|
|
8560
8563
|
setView(start);
|
|
8561
8564
|
setOpen(false);
|
|
8562
8565
|
};
|
|
8563
|
-
const months =
|
|
8564
|
-
const dows =
|
|
8566
|
+
const months = React36__namespace.default.useMemo(() => locale === void 0 ? MONTHS2 : monthNames2(locale), [locale]);
|
|
8567
|
+
const dows = React36__namespace.default.useMemo(
|
|
8565
8568
|
() => locale === void 0 ? Array.from({ length: 7 }, (_, i) => DOW2[(i + weekStartsOn) % 7]) : weekdayNames2(locale, weekStartsOn),
|
|
8566
8569
|
[locale, weekStartsOn]
|
|
8567
8570
|
);
|
|
@@ -8801,14 +8804,14 @@ function Dialog({
|
|
|
8801
8804
|
className = "",
|
|
8802
8805
|
...rest
|
|
8803
8806
|
}) {
|
|
8804
|
-
const autoId =
|
|
8807
|
+
const autoId = React36__namespace.default.useId();
|
|
8805
8808
|
const titleId = `${autoId}-title`;
|
|
8806
8809
|
const descId = `${autoId}-desc`;
|
|
8807
|
-
const dialogRef =
|
|
8810
|
+
const dialogRef = React36__namespace.default.useRef(null);
|
|
8808
8811
|
const __twcStyles = useScopedStyles("twc-dialog-styles", DIALOG_CSS);
|
|
8809
8812
|
const renderPortal = usePortal();
|
|
8810
|
-
const [mounted, setMounted] =
|
|
8811
|
-
|
|
8813
|
+
const [mounted, setMounted] = React36__namespace.default.useState(open);
|
|
8814
|
+
React36__namespace.default.useEffect(() => {
|
|
8812
8815
|
if (open) {
|
|
8813
8816
|
setMounted(true);
|
|
8814
8817
|
return;
|
|
@@ -8819,7 +8822,7 @@ function Dialog({
|
|
|
8819
8822
|
useScrollLock(open);
|
|
8820
8823
|
useInertBackground(dialogRef, open && mounted);
|
|
8821
8824
|
useFocusTrap(dialogRef, open && mounted);
|
|
8822
|
-
|
|
8825
|
+
React36__namespace.default.useEffect(() => {
|
|
8823
8826
|
if (!open) return void 0;
|
|
8824
8827
|
const onKey = (e) => {
|
|
8825
8828
|
if (e.key === "Escape") {
|
|
@@ -8966,14 +8969,14 @@ function Drawer({
|
|
|
8966
8969
|
style,
|
|
8967
8970
|
...rest
|
|
8968
8971
|
}) {
|
|
8969
|
-
const autoId =
|
|
8972
|
+
const autoId = React36__namespace.default.useId();
|
|
8970
8973
|
const titleId = `${autoId}-title`;
|
|
8971
8974
|
const descId = `${autoId}-desc`;
|
|
8972
|
-
const panelRef =
|
|
8975
|
+
const panelRef = React36__namespace.default.useRef(null);
|
|
8973
8976
|
const __twcStyles = useScopedStyles("twc-drawer-styles", DRAWER_CSS);
|
|
8974
8977
|
const renderPortal = usePortal();
|
|
8975
|
-
const [mounted, setMounted] =
|
|
8976
|
-
|
|
8978
|
+
const [mounted, setMounted] = React36__namespace.default.useState(open);
|
|
8979
|
+
React36__namespace.default.useEffect(() => {
|
|
8977
8980
|
if (open) {
|
|
8978
8981
|
setMounted(true);
|
|
8979
8982
|
return;
|
|
@@ -8984,7 +8987,7 @@ function Drawer({
|
|
|
8984
8987
|
useScrollLock(open);
|
|
8985
8988
|
useInertBackground(panelRef, open && mounted);
|
|
8986
8989
|
useFocusTrap(panelRef, open && mounted);
|
|
8987
|
-
|
|
8990
|
+
React36__namespace.default.useEffect(() => {
|
|
8988
8991
|
if (!open) return void 0;
|
|
8989
8992
|
const onKey = (e) => {
|
|
8990
8993
|
if (e.key === "Escape") {
|
|
@@ -9073,11 +9076,11 @@ function Field({
|
|
|
9073
9076
|
...rest
|
|
9074
9077
|
}) {
|
|
9075
9078
|
const __twcStyles = useScopedStyles("twc-field-styles", FIELD_CSS5);
|
|
9076
|
-
const autoId =
|
|
9079
|
+
const autoId = React36__namespace.default.useId();
|
|
9077
9080
|
const fieldId = id || autoId;
|
|
9078
9081
|
const descId = `${fieldId}-desc`;
|
|
9079
9082
|
const hasMsg = Boolean(error || hint);
|
|
9080
|
-
const control =
|
|
9083
|
+
const control = React36__namespace.default.isValidElement(children) ? React36__namespace.default.cloneElement(children, {
|
|
9081
9084
|
"aria-describedby": [children.props["aria-describedby"], hasMsg ? descId : null].filter(Boolean).join(" ") || void 0,
|
|
9082
9085
|
"aria-invalid": children.props["aria-invalid"] !== void 0 ? children.props["aria-invalid"] : error ? true : void 0
|
|
9083
9086
|
}) : children;
|
|
@@ -9169,11 +9172,11 @@ function FileUpload({
|
|
|
9169
9172
|
...rest
|
|
9170
9173
|
}) {
|
|
9171
9174
|
const __twcStyles = useScopedStyles("twc-upload-styles", UPLOAD_CSS);
|
|
9172
|
-
const [internal, setInternal] =
|
|
9175
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
9173
9176
|
const files = value !== void 0 ? value : internal;
|
|
9174
|
-
const [drag, setDrag] =
|
|
9175
|
-
const inputRef =
|
|
9176
|
-
const autoId =
|
|
9177
|
+
const [drag, setDrag] = React36__namespace.default.useState(false);
|
|
9178
|
+
const inputRef = React36__namespace.default.useRef(null);
|
|
9179
|
+
const autoId = React36__namespace.default.useId();
|
|
9177
9180
|
const fieldId = id || autoId;
|
|
9178
9181
|
const descId = `${fieldId}-desc`;
|
|
9179
9182
|
const invalid = Boolean(error);
|
|
@@ -9396,15 +9399,15 @@ function Kanban({
|
|
|
9396
9399
|
...rest
|
|
9397
9400
|
}) {
|
|
9398
9401
|
const __twcStyles = useScopedStyles("twc-kanban-styles", KANBAN_CSS);
|
|
9399
|
-
const [internal, setInternal] =
|
|
9402
|
+
const [internal, setInternal] = React36__namespace.default.useState(cards ?? defaultCards ?? []);
|
|
9400
9403
|
const items = cards !== void 0 ? cards : internal;
|
|
9401
|
-
const [drag, setDrag] =
|
|
9402
|
-
const [overCol, setOverCol] =
|
|
9403
|
-
const [grab, setGrab] =
|
|
9404
|
-
const [announce, setAnnounce] =
|
|
9405
|
-
const rootRef =
|
|
9406
|
-
const focusIdRef =
|
|
9407
|
-
|
|
9404
|
+
const [drag, setDrag] = React36__namespace.default.useState(null);
|
|
9405
|
+
const [overCol, setOverCol] = React36__namespace.default.useState(null);
|
|
9406
|
+
const [grab, setGrab] = React36__namespace.default.useState(null);
|
|
9407
|
+
const [announce, setAnnounce] = React36__namespace.default.useState("");
|
|
9408
|
+
const rootRef = React36__namespace.default.useRef(null);
|
|
9409
|
+
const focusIdRef = React36__namespace.default.useRef(null);
|
|
9410
|
+
React36__namespace.default.useEffect(() => {
|
|
9408
9411
|
if (focusIdRef.current == null) return void 0;
|
|
9409
9412
|
const raf = requestAnimationFrame(() => {
|
|
9410
9413
|
const id = focusIdRef.current;
|
|
@@ -9714,21 +9717,21 @@ function Popover({
|
|
|
9714
9717
|
...rest
|
|
9715
9718
|
}) {
|
|
9716
9719
|
const __twcStyles = useScopedStyles("twc-popover-styles", POPOVER_CSS);
|
|
9717
|
-
const [openState, setOpenState] =
|
|
9718
|
-
const [render, setRender] =
|
|
9719
|
-
const [pos, setPos] =
|
|
9720
|
-
const wrapRef =
|
|
9721
|
-
const popRef =
|
|
9722
|
-
const popId =
|
|
9720
|
+
const [openState, setOpenState] = React36__namespace.default.useState(defaultOpen);
|
|
9721
|
+
const [render, setRender] = React36__namespace.default.useState(false);
|
|
9722
|
+
const [pos, setPos] = React36__namespace.default.useState(null);
|
|
9723
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
9724
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
9725
|
+
const popId = React36__namespace.default.useId();
|
|
9723
9726
|
const controlled = openProp !== void 0;
|
|
9724
9727
|
const open = controlled ? !!openProp : openState;
|
|
9725
|
-
const openRef =
|
|
9728
|
+
const openRef = React36__namespace.default.useRef(open);
|
|
9726
9729
|
openRef.current = open;
|
|
9727
|
-
const controlledRef =
|
|
9730
|
+
const controlledRef = React36__namespace.default.useRef(controlled);
|
|
9728
9731
|
controlledRef.current = controlled;
|
|
9729
|
-
const onOpenChangeRef =
|
|
9732
|
+
const onOpenChangeRef = React36__namespace.default.useRef(onOpenChange);
|
|
9730
9733
|
onOpenChangeRef.current = onOpenChange;
|
|
9731
|
-
const setOpen =
|
|
9734
|
+
const setOpen = React36__namespace.default.useCallback((next) => {
|
|
9732
9735
|
const value = typeof next === "function" ? next(openRef.current) : next;
|
|
9733
9736
|
if (value === openRef.current) return;
|
|
9734
9737
|
if (!controlledRef.current) setOpenState(value);
|
|
@@ -9736,7 +9739,7 @@ function Popover({
|
|
|
9736
9739
|
}, []);
|
|
9737
9740
|
const toggle = () => setOpen((o) => !o);
|
|
9738
9741
|
const RD = { createPortal: typeof reactDom.createPortal === "function" ? reactDom.createPortal : typeof window !== "undefined" && window.ReactDOM && window.ReactDOM.createPortal };
|
|
9739
|
-
const place =
|
|
9742
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
9740
9743
|
const t = wrapRef.current;
|
|
9741
9744
|
if (!t) return;
|
|
9742
9745
|
const r = t.getBoundingClientRect();
|
|
@@ -9773,7 +9776,7 @@ function Popover({
|
|
|
9773
9776
|
arrow = { top: Math.min(Math.max(cy - top - 5.5, 8), ph - 18), [onRight ? "left" : "right"]: -6 };
|
|
9774
9777
|
setPos({ top, left, width: w, flip: false, arrow });
|
|
9775
9778
|
}, [placement, align, width]);
|
|
9776
|
-
|
|
9779
|
+
React36__namespace.default.useEffect(() => {
|
|
9777
9780
|
if (!open) return;
|
|
9778
9781
|
place();
|
|
9779
9782
|
const onMove = () => place();
|
|
@@ -9796,7 +9799,7 @@ function Popover({
|
|
|
9796
9799
|
document.removeEventListener("keydown", onKey);
|
|
9797
9800
|
};
|
|
9798
9801
|
}, [open, place]);
|
|
9799
|
-
|
|
9802
|
+
React36__namespace.default.useEffect(() => {
|
|
9800
9803
|
if (open) {
|
|
9801
9804
|
setRender(true);
|
|
9802
9805
|
return;
|
|
@@ -9804,12 +9807,12 @@ function Popover({
|
|
|
9804
9807
|
const t = setTimeout(() => setRender(false), 170);
|
|
9805
9808
|
return () => clearTimeout(t);
|
|
9806
9809
|
}, [open]);
|
|
9807
|
-
|
|
9810
|
+
React36__namespace.default.useEffect(() => {
|
|
9808
9811
|
if (render && open) place();
|
|
9809
9812
|
}, [render, place]);
|
|
9810
|
-
const restoreRef =
|
|
9811
|
-
const needFocusRef =
|
|
9812
|
-
|
|
9813
|
+
const restoreRef = React36__namespace.default.useRef(null);
|
|
9814
|
+
const needFocusRef = React36__namespace.default.useRef(false);
|
|
9815
|
+
React36__namespace.default.useEffect(() => {
|
|
9813
9816
|
if (open) {
|
|
9814
9817
|
restoreRef.current = document.activeElement;
|
|
9815
9818
|
needFocusRef.current = true;
|
|
@@ -9844,7 +9847,7 @@ function Popover({
|
|
|
9844
9847
|
]
|
|
9845
9848
|
}
|
|
9846
9849
|
) : null;
|
|
9847
|
-
const triggerEl =
|
|
9850
|
+
const triggerEl = React36__namespace.default.isValidElement(trigger) ? React36__namespace.default.cloneElement(trigger, {
|
|
9848
9851
|
onClick: (e) => {
|
|
9849
9852
|
trigger.props.onClick?.(e);
|
|
9850
9853
|
toggle();
|
|
@@ -9887,7 +9890,7 @@ function Progress({
|
|
|
9887
9890
|
className = "",
|
|
9888
9891
|
...rest
|
|
9889
9892
|
}) {
|
|
9890
|
-
const labelId =
|
|
9893
|
+
const labelId = React36__namespace.default.useId();
|
|
9891
9894
|
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...restProps } = rest;
|
|
9892
9895
|
const __twcStyles = useScopedStyles("twc-progress-styles", `
|
|
9893
9896
|
.twc-progress-wrap { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-sans); }
|
|
@@ -10010,7 +10013,7 @@ function Radio({
|
|
|
10010
10013
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
10011
10014
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
10012
10015
|
`);
|
|
10013
|
-
const autoId =
|
|
10016
|
+
const autoId = React36__namespace.default.useId();
|
|
10014
10017
|
const fieldId = id || autoId;
|
|
10015
10018
|
const errId = `${fieldId}-error`;
|
|
10016
10019
|
const invalid = Boolean(error);
|
|
@@ -10080,13 +10083,13 @@ function RadioGroup({
|
|
|
10080
10083
|
...rest
|
|
10081
10084
|
}) {
|
|
10082
10085
|
const __twcStyles = useScopedStyles("twc-radio-group-styles", RADIO_GROUP_CSS);
|
|
10083
|
-
const autoId =
|
|
10086
|
+
const autoId = React36__namespace.default.useId();
|
|
10084
10087
|
const fieldId = id || autoId;
|
|
10085
10088
|
const labelId = `${fieldId}-label`;
|
|
10086
10089
|
const descId = `${fieldId}-desc`;
|
|
10087
10090
|
const groupName = name || `${fieldId}-name`;
|
|
10088
10091
|
const invalid = Boolean(error);
|
|
10089
|
-
const [internal, setInternal] =
|
|
10092
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
10090
10093
|
const current = value !== void 0 ? value : internal;
|
|
10091
10094
|
const select = (v) => {
|
|
10092
10095
|
if (value === void 0) setInternal(v);
|
|
@@ -10107,10 +10110,10 @@ function RadioGroup({
|
|
|
10107
10110
|
tone
|
|
10108
10111
|
},
|
|
10109
10112
|
o.value
|
|
10110
|
-
)) :
|
|
10111
|
-
if (!
|
|
10113
|
+
)) : React36__namespace.default.Children.map(children, (child) => {
|
|
10114
|
+
if (!React36__namespace.default.isValidElement(child)) return child;
|
|
10112
10115
|
const v = child.props.value;
|
|
10113
|
-
return
|
|
10116
|
+
return React36__namespace.default.cloneElement(child, {
|
|
10114
10117
|
name: child.props.name ?? groupName,
|
|
10115
10118
|
checked: child.props.checked ?? current === v,
|
|
10116
10119
|
onChange: child.props.onChange ?? (() => select(v)),
|
|
@@ -10190,12 +10193,12 @@ function Rating({
|
|
|
10190
10193
|
...rest
|
|
10191
10194
|
}) {
|
|
10192
10195
|
const __twcStyles = useScopedStyles("twc-rating-styles", RATING_CSS);
|
|
10193
|
-
const [internal, setInternal] =
|
|
10194
|
-
const [hover, setHover] =
|
|
10196
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
10197
|
+
const [hover, setHover] = React36__namespace.default.useState(0);
|
|
10195
10198
|
const val = value !== void 0 ? value : internal;
|
|
10196
10199
|
const shown = hover || val;
|
|
10197
10200
|
const interactive = !readOnly && !disabled;
|
|
10198
|
-
const btnRefs =
|
|
10201
|
+
const btnRefs = React36__namespace.default.useRef([]);
|
|
10199
10202
|
const tabStar = Math.min(count, Math.max(1, Math.round(val) || 1));
|
|
10200
10203
|
const fmt = (v) => format ? format(v) : Number.isInteger(v) ? String(v) : v.toFixed(1);
|
|
10201
10204
|
if (process.env.NODE_ENV !== "production" && interactive && !Number.isInteger(val)) {
|
|
@@ -10382,24 +10385,24 @@ function Sidebar({
|
|
|
10382
10385
|
...rest
|
|
10383
10386
|
}) {
|
|
10384
10387
|
const __twcStyles = useScopedStyles("twc-sidebar-styles", SIDEBAR_CSS);
|
|
10385
|
-
const navId =
|
|
10386
|
-
const panelRef =
|
|
10388
|
+
const navId = React36__namespace.default.useId();
|
|
10389
|
+
const panelRef = React36__namespace.default.useRef(null);
|
|
10387
10390
|
const renderPortal = usePortal();
|
|
10388
|
-
const [internal, setInternal] =
|
|
10391
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultCollapsed);
|
|
10389
10392
|
const collapsed = collapsedProp !== void 0 ? collapsedProp : internal;
|
|
10390
10393
|
const toggle = () => {
|
|
10391
10394
|
const next = !collapsed;
|
|
10392
10395
|
if (collapsedProp === void 0) setInternal(next);
|
|
10393
10396
|
onCollapsedChange?.(next);
|
|
10394
10397
|
};
|
|
10395
|
-
const [openInternal, setOpenInternal] =
|
|
10398
|
+
const [openInternal, setOpenInternal] = React36__namespace.default.useState(defaultOpen);
|
|
10396
10399
|
const open = openProp !== void 0 ? openProp : openInternal;
|
|
10397
10400
|
const setOpen = (next) => {
|
|
10398
10401
|
if (openProp === void 0) setOpenInternal(next);
|
|
10399
10402
|
onOpenChange?.(next);
|
|
10400
10403
|
};
|
|
10401
|
-
const [mounted, setMounted] =
|
|
10402
|
-
|
|
10404
|
+
const [mounted, setMounted] = React36__namespace.default.useState(open);
|
|
10405
|
+
React36__namespace.default.useEffect(() => {
|
|
10403
10406
|
if (!overlay) return void 0;
|
|
10404
10407
|
if (open) {
|
|
10405
10408
|
setMounted(true);
|
|
@@ -10408,7 +10411,7 @@ function Sidebar({
|
|
|
10408
10411
|
const t = setTimeout(() => setMounted(false), 170);
|
|
10409
10412
|
return () => clearTimeout(t);
|
|
10410
10413
|
}, [overlay, open]);
|
|
10411
|
-
|
|
10414
|
+
React36__namespace.default.useEffect(() => {
|
|
10412
10415
|
if (!overlay || !open) return void 0;
|
|
10413
10416
|
const prev = document.body.style.overflow;
|
|
10414
10417
|
document.body.style.overflow = "hidden";
|
|
@@ -10417,7 +10420,7 @@ function Sidebar({
|
|
|
10417
10420
|
};
|
|
10418
10421
|
}, [overlay, open]);
|
|
10419
10422
|
useFocusTrap(panelRef, overlay && open && mounted);
|
|
10420
|
-
|
|
10423
|
+
React36__namespace.default.useEffect(() => {
|
|
10421
10424
|
if (!overlay || !open) return void 0;
|
|
10422
10425
|
const onKey = (e) => {
|
|
10423
10426
|
if (e.key === "Escape") {
|
|
@@ -10469,7 +10472,7 @@ function Sidebar({
|
|
|
10469
10472
|
const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
10470
10473
|
__twcStyles,
|
|
10471
10474
|
brand ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-sidebar__head", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-sidebar__brand", children: brand }) }) : null,
|
|
10472
|
-
/* @__PURE__ */ jsxRuntime.jsx("nav", { id: navId, className: "twc-sidebar__nav", "aria-label": navLabel, children: groups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10475
|
+
/* @__PURE__ */ jsxRuntime.jsx("nav", { id: navId, className: "twc-sidebar__nav", "aria-label": navLabel, children: groups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React36__namespace.default.Fragment, { children: [
|
|
10473
10476
|
g.section != null ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-sidebar__section", id: g.sid, children: g.section }) : null,
|
|
10474
10477
|
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "twc-sidebar__list", ...g.section != null ? { "aria-labelledby": g.sid } : {}, children: g.entries.map(({ it, i }) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: renderItem(it) }, i)) })
|
|
10475
10478
|
] }, gi)) }),
|
|
@@ -10638,10 +10641,10 @@ function Slider({
|
|
|
10638
10641
|
return Math.min(max, Math.max(min, Math.round(stepped * 1e6) / 1e6));
|
|
10639
10642
|
};
|
|
10640
10643
|
const __twcStyles = useScopedStyles("twc-slider-styles", SLIDER_CSS);
|
|
10641
|
-
const autoId =
|
|
10644
|
+
const autoId = React36__namespace.default.useId();
|
|
10642
10645
|
const fieldId = id || autoId;
|
|
10643
10646
|
const isRange = range || Array.isArray(value) || Array.isArray(defaultValue);
|
|
10644
|
-
const [internal, setInternal] =
|
|
10647
|
+
const [internal, setInternal] = React36__namespace.default.useState(() => {
|
|
10645
10648
|
if (isRange) {
|
|
10646
10649
|
const dv = Array.isArray(defaultValue) ? defaultValue : [min, max];
|
|
10647
10650
|
return [clampSnap(dv[0]), clampSnap(dv[1])];
|
|
@@ -10651,8 +10654,8 @@ function Slider({
|
|
|
10651
10654
|
const rawVal = value !== void 0 ? value : internal;
|
|
10652
10655
|
const clampedVals = (isRange ? [Number(rawVal[0]), Number(rawVal[1])] : [Number(rawVal)]).map((v) => Math.min(max, Math.max(min, Number.isFinite(v) ? v : min)));
|
|
10653
10656
|
const indices = isRange ? [0, 1] : [0];
|
|
10654
|
-
const trackRef =
|
|
10655
|
-
const [dragging, setDragging] =
|
|
10657
|
+
const trackRef = React36__namespace.default.useRef(null);
|
|
10658
|
+
const [dragging, setDragging] = React36__namespace.default.useState(false);
|
|
10656
10659
|
const fmt = (v) => formatValue ? formatValue(v) : v.toFixed(decimals);
|
|
10657
10660
|
const valueTextFor = (v) => {
|
|
10658
10661
|
if (getAriaValueText) return getAriaValueText(v);
|
|
@@ -10683,8 +10686,8 @@ function Slider({
|
|
|
10683
10686
|
const ratio = Math.min(1, Math.max(0, (clientX - r.left) / r.width));
|
|
10684
10687
|
return clampSnap(min + ratio * (max - min));
|
|
10685
10688
|
};
|
|
10686
|
-
const dragCleanupRef =
|
|
10687
|
-
|
|
10689
|
+
const dragCleanupRef = React36__namespace.default.useRef(null);
|
|
10690
|
+
React36__namespace.default.useEffect(() => () => dragCleanupRef.current?.(), []);
|
|
10688
10691
|
function onPointerDown(e) {
|
|
10689
10692
|
if (disabled) return;
|
|
10690
10693
|
e.preventDefault();
|
|
@@ -10915,7 +10918,7 @@ function Stepper({
|
|
|
10915
10918
|
...rest
|
|
10916
10919
|
}) {
|
|
10917
10920
|
const __twcStyles = useScopedStyles("twc-stepper-styles", STEPPER_CSS);
|
|
10918
|
-
const [activeInternal, setActiveInternal] =
|
|
10921
|
+
const [activeInternal, setActiveInternal] = React36__namespace.default.useState(defaultActive);
|
|
10919
10922
|
const active = activeProp !== void 0 ? activeProp : activeInternal;
|
|
10920
10923
|
const handleStep = (i) => {
|
|
10921
10924
|
if (activeProp === void 0) setActiveInternal(i);
|
|
@@ -11047,7 +11050,7 @@ function Switch({
|
|
|
11047
11050
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
11048
11051
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
11049
11052
|
`);
|
|
11050
|
-
const autoId =
|
|
11053
|
+
const autoId = React36__namespace.default.useId();
|
|
11051
11054
|
const fieldId = id || autoId;
|
|
11052
11055
|
const errId = `${fieldId}-error`;
|
|
11053
11056
|
const invalid = Boolean(error);
|
|
@@ -11150,14 +11153,14 @@ function Table({
|
|
|
11150
11153
|
...rest
|
|
11151
11154
|
}) {
|
|
11152
11155
|
const __twcStyles = useScopedStyles("twc-table-styles", TABLE_CSS);
|
|
11153
|
-
const cols =
|
|
11156
|
+
const cols = React36__namespace.default.useMemo(
|
|
11154
11157
|
() => (columns || []).map((c) => ({ ...c, header: c.headerName, render: c.renderCell })),
|
|
11155
11158
|
[columns]
|
|
11156
11159
|
);
|
|
11157
11160
|
const dataRows = rowsProp || [];
|
|
11158
|
-
const [internalSort, setInternalSort] =
|
|
11161
|
+
const [internalSort, setInternalSort] = React36__namespace.default.useState(defaultSort || { field: null, dir: "asc" });
|
|
11159
11162
|
const sort = (sortProp !== void 0 ? sortProp : internalSort) || { field: null, dir: "asc" };
|
|
11160
|
-
const rows =
|
|
11163
|
+
const rows = React36__namespace.default.useMemo(() => {
|
|
11161
11164
|
if (!sortable || !sort.field) return dataRows;
|
|
11162
11165
|
const col = cols.find((c) => c.field === sort.field);
|
|
11163
11166
|
if (!col) return dataRows;
|
|
@@ -11304,15 +11307,15 @@ function Tabs({
|
|
|
11304
11307
|
}) {
|
|
11305
11308
|
const vertical = orientation === "vertical";
|
|
11306
11309
|
const __twcStyles = useScopedStyles("twc-tabs-styles", TABS_CSS);
|
|
11307
|
-
const [internal, setInternal] =
|
|
11310
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue ?? items[0]?.value);
|
|
11308
11311
|
const active = value ?? internal;
|
|
11309
|
-
const listRef =
|
|
11310
|
-
const [ind, setInd] =
|
|
11311
|
-
const baseId =
|
|
11312
|
+
const listRef = React36__namespace.default.useRef(null);
|
|
11313
|
+
const [ind, setInd] = React36__namespace.default.useState({ left: 0, width: 0, top: 0, height: 0 });
|
|
11314
|
+
const baseId = React36__namespace.default.useId();
|
|
11312
11315
|
const tabIdAt = (i) => `${baseId}-tab-${i}`;
|
|
11313
11316
|
const panelId = `${baseId}-panel`;
|
|
11314
11317
|
const activeIndex = items.findIndex((it) => it.value === active);
|
|
11315
|
-
const updateIndicator =
|
|
11318
|
+
const updateIndicator = React36__namespace.default.useCallback(() => {
|
|
11316
11319
|
const list = listRef.current;
|
|
11317
11320
|
if (!list) return;
|
|
11318
11321
|
const el = list.querySelector('[data-active="true"]');
|
|
@@ -11321,10 +11324,10 @@ function Tabs({
|
|
|
11321
11324
|
if (!vertical) el.scrollIntoView?.({ inline: "nearest", block: "nearest" });
|
|
11322
11325
|
}
|
|
11323
11326
|
}, [vertical]);
|
|
11324
|
-
|
|
11327
|
+
React36__namespace.default.useEffect(() => {
|
|
11325
11328
|
updateIndicator();
|
|
11326
11329
|
}, [active, updateIndicator, items, orientation]);
|
|
11327
|
-
|
|
11330
|
+
React36__namespace.default.useEffect(() => {
|
|
11328
11331
|
const r = () => updateIndicator();
|
|
11329
11332
|
window.addEventListener("resize", r);
|
|
11330
11333
|
if (typeof document !== "undefined" && document.fonts && document.fonts.ready) {
|
|
@@ -11469,7 +11472,7 @@ function Tag({
|
|
|
11469
11472
|
}, "aria-label": _removeLabel, type: "button", 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: "M18 6 6 18M6 6l12 12" }) }) }) : null
|
|
11470
11473
|
] });
|
|
11471
11474
|
}
|
|
11472
|
-
var useIso = typeof document !== "undefined" ?
|
|
11475
|
+
var useIso = typeof document !== "undefined" ? React36__namespace.default.useLayoutEffect : React36__namespace.default.useEffect;
|
|
11473
11476
|
var TEXTAREA_CSS = `
|
|
11474
11477
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
11475
11478
|
.twc-field__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); display: flex; gap: 4px; align-items: center; }
|
|
@@ -11505,7 +11508,7 @@ var TEXTAREA_CSS = `
|
|
|
11505
11508
|
.twc-field__count { margin-inline-start: auto; font-size: var(--text-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; flex: none; }
|
|
11506
11509
|
.twc-field__count[data-danger="true"] { color: var(--color-danger-subtle-fg); }
|
|
11507
11510
|
`;
|
|
11508
|
-
var Textarea =
|
|
11511
|
+
var Textarea = React36__namespace.default.forwardRef(function Textarea2({
|
|
11509
11512
|
label,
|
|
11510
11513
|
hint,
|
|
11511
11514
|
error,
|
|
@@ -11523,19 +11526,19 @@ var Textarea = React37__namespace.default.forwardRef(function Textarea2({
|
|
|
11523
11526
|
...rest
|
|
11524
11527
|
}, ref) {
|
|
11525
11528
|
const __twcStyles = useScopedStyles("twc-textarea-styles", TEXTAREA_CSS);
|
|
11526
|
-
const autoId =
|
|
11529
|
+
const autoId = React36__namespace.default.useId();
|
|
11527
11530
|
const fieldId = id || autoId;
|
|
11528
11531
|
const descId = `${fieldId}-desc`;
|
|
11529
11532
|
const countId = `${fieldId}-count`;
|
|
11530
11533
|
const invalid = Boolean(error);
|
|
11531
|
-
const innerRef =
|
|
11534
|
+
const innerRef = React36__namespace.default.useRef(null);
|
|
11532
11535
|
const setRef = (el) => {
|
|
11533
11536
|
innerRef.current = el;
|
|
11534
11537
|
if (typeof ref === "function") ref(el);
|
|
11535
11538
|
else if (ref) ref.current = el;
|
|
11536
11539
|
};
|
|
11537
11540
|
const countControlled = rest.value !== void 0;
|
|
11538
|
-
const [len2, setLen] =
|
|
11541
|
+
const [len2, setLen] = React36__namespace.default.useState(() => String(rest.defaultValue ?? "").length);
|
|
11539
11542
|
const count = countControlled ? String(rest.value ?? "").length : len2;
|
|
11540
11543
|
const max = rest.maxLength;
|
|
11541
11544
|
const showCounter = showCount && max != null;
|
|
@@ -11713,19 +11716,19 @@ function Toast({
|
|
|
11713
11716
|
}) {
|
|
11714
11717
|
const resolvedTone = tone === "neutral" ? "default" : tone;
|
|
11715
11718
|
const __twcStyles = useScopedStyles("twc-toast-styles", TOAST_CSS);
|
|
11716
|
-
const onCloseRef =
|
|
11717
|
-
|
|
11719
|
+
const onCloseRef = React36__namespace.default.useRef(onClose);
|
|
11720
|
+
React36__namespace.default.useEffect(() => {
|
|
11718
11721
|
onCloseRef.current = onClose;
|
|
11719
11722
|
}, [onClose]);
|
|
11720
|
-
const timer =
|
|
11721
|
-
const stop =
|
|
11722
|
-
const start =
|
|
11723
|
+
const timer = React36__namespace.default.useRef();
|
|
11724
|
+
const stop = React36__namespace.default.useCallback(() => clearTimeout(timer.current), []);
|
|
11725
|
+
const start = React36__namespace.default.useCallback(() => {
|
|
11723
11726
|
stop();
|
|
11724
11727
|
if (duration && duration !== Infinity && onCloseRef.current) {
|
|
11725
11728
|
timer.current = setTimeout(() => onCloseRef.current && onCloseRef.current(), duration);
|
|
11726
11729
|
}
|
|
11727
11730
|
}, [duration, stop]);
|
|
11728
|
-
|
|
11731
|
+
React36__namespace.default.useEffect(() => {
|
|
11729
11732
|
start();
|
|
11730
11733
|
return stop;
|
|
11731
11734
|
}, [start, stop]);
|
|
@@ -11770,30 +11773,30 @@ function Toast({
|
|
|
11770
11773
|
}
|
|
11771
11774
|
function ToastViewport({ children, limit, className = "", ...rest }) {
|
|
11772
11775
|
const __twcStyles = useScopedStyles("twc-toast-styles", TOAST_CSS);
|
|
11773
|
-
const shown = limit && limit > 0 ?
|
|
11776
|
+
const shown = limit && limit > 0 ? React36__namespace.default.Children.toArray(children).slice(-limit) : children;
|
|
11774
11777
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-toast-viewport ${className}`, role: "region", "aria-label": "Notifications", ...rest, children: [
|
|
11775
11778
|
__twcStyles,
|
|
11776
11779
|
shown
|
|
11777
11780
|
] });
|
|
11778
11781
|
}
|
|
11779
|
-
var ToastContext =
|
|
11782
|
+
var ToastContext = React36__namespace.default.createContext(null);
|
|
11780
11783
|
function useToast() {
|
|
11781
|
-
const ctx =
|
|
11784
|
+
const ctx = React36__namespace.default.useContext(ToastContext);
|
|
11782
11785
|
if (!ctx) throw new Error("useToast must be used within a <ToastProvider>.");
|
|
11783
11786
|
return ctx;
|
|
11784
11787
|
}
|
|
11785
11788
|
function ToastProvider({ children, limit = 4, duration = 4500, ...viewportProps }) {
|
|
11786
|
-
const [toasts, setToasts] =
|
|
11787
|
-
const idRef =
|
|
11788
|
-
const limitRef =
|
|
11789
|
-
|
|
11789
|
+
const [toasts, setToasts] = React36__namespace.default.useState([]);
|
|
11790
|
+
const idRef = React36__namespace.default.useRef(0);
|
|
11791
|
+
const limitRef = React36__namespace.default.useRef(limit);
|
|
11792
|
+
React36__namespace.default.useEffect(() => {
|
|
11790
11793
|
limitRef.current = limit;
|
|
11791
11794
|
}, [limit]);
|
|
11792
|
-
const dismiss =
|
|
11795
|
+
const dismiss = React36__namespace.default.useCallback((id) => {
|
|
11793
11796
|
setToasts((s) => s.filter((t) => t.id !== id));
|
|
11794
11797
|
}, []);
|
|
11795
|
-
const clear =
|
|
11796
|
-
const api =
|
|
11798
|
+
const clear = React36__namespace.default.useCallback(() => setToasts([]), []);
|
|
11799
|
+
const api = React36__namespace.default.useMemo(() => {
|
|
11797
11800
|
const push = (opts) => {
|
|
11798
11801
|
const id = idRef.current += 1;
|
|
11799
11802
|
const next = typeof opts === "string" ? { title: opts } : opts && typeof opts === "object" ? opts : {};
|
|
@@ -11814,7 +11817,7 @@ function ToastProvider({ children, limit = 4, duration = 4500, ...viewportProps
|
|
|
11814
11817
|
toast.show = withTone("default");
|
|
11815
11818
|
return { toast, dismiss, clear };
|
|
11816
11819
|
}, [dismiss, clear]);
|
|
11817
|
-
const value =
|
|
11820
|
+
const value = React36__namespace.default.useMemo(() => ({ ...api, toasts }), [api, toasts]);
|
|
11818
11821
|
return /* @__PURE__ */ jsxRuntime.jsxs(ToastContext.Provider, { value, children: [
|
|
11819
11822
|
children,
|
|
11820
11823
|
/* @__PURE__ */ jsxRuntime.jsx(ToastViewport, { limit, ...viewportProps, children: toasts.map((t) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -11922,13 +11925,13 @@ function TreeView({
|
|
|
11922
11925
|
}) {
|
|
11923
11926
|
const nodes = items;
|
|
11924
11927
|
const __twcStyles = useScopedStyles("twc-tree-styles", TREE_CSS);
|
|
11925
|
-
const [expInternal, setExpInternal] =
|
|
11928
|
+
const [expInternal, setExpInternal] = React36__namespace.default.useState(() => new Set(defaultExpanded));
|
|
11926
11929
|
const expanded = expandedProp !== void 0 ? new Set(expandedProp) : expInternal;
|
|
11927
|
-
const [selInternal, setSelInternal] =
|
|
11930
|
+
const [selInternal, setSelInternal] = React36__namespace.default.useState(defaultSelectedId);
|
|
11928
11931
|
const selectedId = selectedProp !== void 0 ? selectedProp : selInternal;
|
|
11929
|
-
const [focusId, setFocusId] =
|
|
11930
|
-
const rowRefs =
|
|
11931
|
-
const taRef =
|
|
11932
|
+
const [focusId, setFocusId] = React36__namespace.default.useState(null);
|
|
11933
|
+
const rowRefs = React36__namespace.default.useRef(/* @__PURE__ */ new Map());
|
|
11934
|
+
const taRef = React36__namespace.default.useRef({ str: "", t: 0 });
|
|
11932
11935
|
const toggle = (id) => {
|
|
11933
11936
|
const n = new Set(expanded);
|
|
11934
11937
|
n.has(id) ? n.delete(id) : n.add(id);
|
|
@@ -12060,7 +12063,7 @@ function AppShell({
|
|
|
12060
12063
|
...rest
|
|
12061
12064
|
}) {
|
|
12062
12065
|
const __twcStyles = useScopedStyles("twc-shell-styles", SHELL_CSS);
|
|
12063
|
-
const wiredSidebar =
|
|
12066
|
+
const wiredSidebar = React36__namespace.default.isValidElement(sidebar) && (sidebarOpen !== void 0 || onSidebarOpenChange !== void 0) ? React36__namespace.default.cloneElement(sidebar, {
|
|
12064
12067
|
overlay: sidebar.props.overlay !== void 0 ? sidebar.props.overlay : true,
|
|
12065
12068
|
open: sidebar.props.open !== void 0 ? sidebar.props.open : sidebarOpen,
|
|
12066
12069
|
onOpenChange: sidebar.props.onOpenChange !== void 0 ? sidebar.props.onOpenChange : onSidebarOpenChange
|
|
@@ -12095,7 +12098,7 @@ function safeHref6(url) {
|
|
|
12095
12098
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
12096
12099
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
12097
12100
|
}
|
|
12098
|
-
var Box =
|
|
12101
|
+
var Box = React36__namespace.default.forwardRef(function Box2({
|
|
12099
12102
|
as: Tag2 = "div",
|
|
12100
12103
|
p,
|
|
12101
12104
|
px,
|
|
@@ -12151,7 +12154,7 @@ function safeHref7(url) {
|
|
|
12151
12154
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
12152
12155
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
12153
12156
|
}
|
|
12154
|
-
var Container =
|
|
12157
|
+
var Container = React36__namespace.default.forwardRef(function Container2({
|
|
12155
12158
|
as: Tag2 = "div",
|
|
12156
12159
|
size = "lg",
|
|
12157
12160
|
padded = true,
|
|
@@ -12201,7 +12204,7 @@ function safeHref8(url) {
|
|
|
12201
12204
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
12202
12205
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
12203
12206
|
}
|
|
12204
|
-
var Grid =
|
|
12207
|
+
var Grid = React36__namespace.default.forwardRef(function Grid2({
|
|
12205
12208
|
as: Tag2 = "div",
|
|
12206
12209
|
columns,
|
|
12207
12210
|
minChildWidth,
|
|
@@ -12220,7 +12223,7 @@ var Grid = React37__namespace.default.forwardRef(function Grid2({
|
|
|
12220
12223
|
}, ref) {
|
|
12221
12224
|
const { flatStyle, styleNode, sxAttr } = useSx(sx);
|
|
12222
12225
|
const responsive = columns != null && typeof columns === "object";
|
|
12223
|
-
const uid =
|
|
12226
|
+
const uid = React36__namespace.default.useId();
|
|
12224
12227
|
const gridId = responsive ? `g${uid.replace(/[^a-zA-Z0-9]/g, "")}` : null;
|
|
12225
12228
|
let css = "";
|
|
12226
12229
|
if (responsive) {
|
|
@@ -12274,7 +12277,7 @@ function safeHref9(url) {
|
|
|
12274
12277
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
12275
12278
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
12276
12279
|
}
|
|
12277
|
-
var Stack =
|
|
12280
|
+
var Stack = React36__namespace.default.forwardRef(function Stack2({
|
|
12278
12281
|
as: Tag2 = "div",
|
|
12279
12282
|
direction = "column",
|
|
12280
12283
|
gap = 4,
|
|
@@ -12298,7 +12301,7 @@ var Stack = React37__namespace.default.forwardRef(function Stack2({
|
|
|
12298
12301
|
}, ref) {
|
|
12299
12302
|
const { flatStyle, styleNode, sxAttr } = useSx(sx);
|
|
12300
12303
|
if (Tag2 === "a" && rest.href != null) rest.href = safeHref9(rest.href);
|
|
12301
|
-
const kids = divider != null ?
|
|
12304
|
+
const kids = divider != null ? React36__namespace.default.Children.toArray(children).flatMap((child, i, arr) => i < arr.length - 1 ? [child, /* @__PURE__ */ jsxRuntime.jsx(React36__namespace.default.Fragment, { children: divider }, `twc-stack-div-${i}`)] : [child]) : children;
|
|
12302
12305
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12303
12306
|
Tag2,
|
|
12304
12307
|
{
|
|
@@ -12370,10 +12373,10 @@ function Code({
|
|
|
12370
12373
|
const __twcStyles = useScopedStyles("twc-code-styles", CODE_CSS);
|
|
12371
12374
|
const Tag2 = as ?? (block ? "pre" : "code");
|
|
12372
12375
|
if (Tag2 === "a" && rest.href != null) rest.href = safeHref10(rest.href);
|
|
12373
|
-
const rootRef =
|
|
12374
|
-
const [copied, setCopied] =
|
|
12375
|
-
const timerRef =
|
|
12376
|
-
|
|
12376
|
+
const rootRef = React36__namespace.default.useRef(null);
|
|
12377
|
+
const [copied, setCopied] = React36__namespace.default.useState(false);
|
|
12378
|
+
const timerRef = React36__namespace.default.useRef(null);
|
|
12379
|
+
React36__namespace.default.useEffect(() => () => clearTimeout(timerRef.current), []);
|
|
12377
12380
|
const doCopy = () => {
|
|
12378
12381
|
if (typeof navigator === "undefined" || !navigator.clipboard) return;
|
|
12379
12382
|
const text = typeof children === "string" ? children : rootRef.current?.textContent ?? "";
|
|
@@ -12399,7 +12402,7 @@ function safeHref11(url) {
|
|
|
12399
12402
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
12400
12403
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
12401
12404
|
}
|
|
12402
|
-
var Heading =
|
|
12405
|
+
var Heading = React36__namespace.default.forwardRef(function Heading2({
|
|
12403
12406
|
as,
|
|
12404
12407
|
level = 2,
|
|
12405
12408
|
size,
|
|
@@ -12465,7 +12468,7 @@ function safeHref12(url) {
|
|
|
12465
12468
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
12466
12469
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
12467
12470
|
}
|
|
12468
|
-
var Text =
|
|
12471
|
+
var Text = React36__namespace.default.forwardRef(function Text2({
|
|
12469
12472
|
as: Tag2 = "p",
|
|
12470
12473
|
size = "base",
|
|
12471
12474
|
tone = "default",
|
|
@@ -12510,45 +12513,45 @@ var Text = React37__namespace.default.forwardRef(function Text2({
|
|
|
12510
12513
|
});
|
|
12511
12514
|
Text.displayName = "Text";
|
|
12512
12515
|
var canUseDOM2 = typeof window !== "undefined" && typeof document !== "undefined";
|
|
12513
|
-
var useIsomorphicLayoutEffect = canUseDOM2 ?
|
|
12516
|
+
var useIsomorphicLayoutEffect = canUseDOM2 ? React36__namespace.default.useLayoutEffect : React36__namespace.default.useEffect;
|
|
12514
12517
|
function useMounted() {
|
|
12515
|
-
const [mounted, setMounted] =
|
|
12516
|
-
|
|
12518
|
+
const [mounted, setMounted] = React36__namespace.default.useState(false);
|
|
12519
|
+
React36__namespace.default.useEffect(() => {
|
|
12517
12520
|
setMounted(true);
|
|
12518
12521
|
}, []);
|
|
12519
12522
|
return mounted;
|
|
12520
12523
|
}
|
|
12521
12524
|
function usePrevious(value) {
|
|
12522
|
-
const ref =
|
|
12523
|
-
|
|
12525
|
+
const ref = React36__namespace.default.useRef(void 0);
|
|
12526
|
+
React36__namespace.default.useEffect(() => {
|
|
12524
12527
|
ref.current = value;
|
|
12525
12528
|
}, [value]);
|
|
12526
12529
|
return ref.current;
|
|
12527
12530
|
}
|
|
12528
12531
|
function useToggle(initial = false) {
|
|
12529
|
-
const [on, setOn] =
|
|
12530
|
-
const toggle =
|
|
12532
|
+
const [on, setOn] = React36__namespace.default.useState(initial);
|
|
12533
|
+
const toggle = React36__namespace.default.useCallback((next) => {
|
|
12531
12534
|
setOn((prev) => typeof next === "boolean" ? next : !prev);
|
|
12532
12535
|
}, []);
|
|
12533
12536
|
return [on, toggle, setOn];
|
|
12534
12537
|
}
|
|
12535
12538
|
function useDisclosure(initial = false) {
|
|
12536
|
-
const [open, setOpen] =
|
|
12537
|
-
const onOpen =
|
|
12538
|
-
const onClose =
|
|
12539
|
-
const onToggle =
|
|
12539
|
+
const [open, setOpen] = React36__namespace.default.useState(initial);
|
|
12540
|
+
const onOpen = React36__namespace.default.useCallback(() => setOpen(true), []);
|
|
12541
|
+
const onClose = React36__namespace.default.useCallback(() => setOpen(false), []);
|
|
12542
|
+
const onToggle = React36__namespace.default.useCallback(() => setOpen((p) => !p), []);
|
|
12540
12543
|
return { open, onOpen, onClose, onToggle, setOpen };
|
|
12541
12544
|
}
|
|
12542
12545
|
function useControllableState({ value, defaultValue, onChange } = {}) {
|
|
12543
12546
|
const isControlled = value !== void 0;
|
|
12544
|
-
const [uncontrolled, setUncontrolled] =
|
|
12547
|
+
const [uncontrolled, setUncontrolled] = React36__namespace.default.useState(defaultValue);
|
|
12545
12548
|
const current = isControlled ? value : uncontrolled;
|
|
12546
|
-
const ref =
|
|
12549
|
+
const ref = React36__namespace.default.useRef({ current, isControlled, onChange });
|
|
12547
12550
|
useIsomorphicLayoutEffect(() => {
|
|
12548
12551
|
ref.current = { current, isControlled, onChange };
|
|
12549
12552
|
});
|
|
12550
|
-
const wasControlled =
|
|
12551
|
-
|
|
12553
|
+
const wasControlled = React36__namespace.default.useRef(isControlled);
|
|
12554
|
+
React36__namespace.default.useEffect(() => {
|
|
12552
12555
|
if (wasControlled.current !== isControlled) {
|
|
12553
12556
|
warnOnce(
|
|
12554
12557
|
"useControllableState:switch",
|
|
@@ -12557,7 +12560,7 @@ function useControllableState({ value, defaultValue, onChange } = {}) {
|
|
|
12557
12560
|
wasControlled.current = isControlled;
|
|
12558
12561
|
}
|
|
12559
12562
|
});
|
|
12560
|
-
const setValue =
|
|
12563
|
+
const setValue = React36__namespace.default.useCallback((next) => {
|
|
12561
12564
|
const { current: cur, isControlled: ctrl, onChange: cb } = ref.current;
|
|
12562
12565
|
const resolved = typeof next === "function" ? next(cur) : next;
|
|
12563
12566
|
if (resolved === cur) return;
|
|
@@ -12568,7 +12571,7 @@ function useControllableState({ value, defaultValue, onChange } = {}) {
|
|
|
12568
12571
|
}
|
|
12569
12572
|
function useMediaQuery(query, { defaultValue = false, initializeWithValue = false } = {}) {
|
|
12570
12573
|
const get = () => canUseDOM2 ? window.matchMedia(query).matches : defaultValue;
|
|
12571
|
-
const [matches3, setMatches] =
|
|
12574
|
+
const [matches3, setMatches] = React36__namespace.default.useState(initializeWithValue ? get : defaultValue);
|
|
12572
12575
|
useIsomorphicLayoutEffect(() => {
|
|
12573
12576
|
if (!canUseDOM2) return void 0;
|
|
12574
12577
|
const mql = window.matchMedia(query);
|
|
@@ -12584,7 +12587,7 @@ function usePrefersReducedMotion() {
|
|
|
12584
12587
|
}
|
|
12585
12588
|
function useColorScheme({ storageKey = "twico-theme", attribute = "class", element, disableTransitionsOnChange = true } = {}) {
|
|
12586
12589
|
const getTarget = () => element || (canUseDOM2 ? document.documentElement : null);
|
|
12587
|
-
const firstApply =
|
|
12590
|
+
const firstApply = React36__namespace.default.useRef(true);
|
|
12588
12591
|
const read = () => {
|
|
12589
12592
|
if (!canUseDOM2) return "light";
|
|
12590
12593
|
try {
|
|
@@ -12594,8 +12597,8 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
12594
12597
|
}
|
|
12595
12598
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
12596
12599
|
};
|
|
12597
|
-
const [theme, setThemeState] =
|
|
12598
|
-
const apply =
|
|
12600
|
+
const [theme, setThemeState] = React36__namespace.default.useState(read);
|
|
12601
|
+
const apply = React36__namespace.default.useCallback(
|
|
12599
12602
|
(t) => {
|
|
12600
12603
|
const target = getTarget();
|
|
12601
12604
|
if (!target) return;
|
|
@@ -12621,11 +12624,11 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
12621
12624
|
useIsomorphicLayoutEffect(() => {
|
|
12622
12625
|
apply(theme);
|
|
12623
12626
|
}, [theme, apply]);
|
|
12624
|
-
const themeRef =
|
|
12627
|
+
const themeRef = React36__namespace.default.useRef(theme);
|
|
12625
12628
|
useIsomorphicLayoutEffect(() => {
|
|
12626
12629
|
themeRef.current = theme;
|
|
12627
12630
|
}, [theme]);
|
|
12628
|
-
const setTheme =
|
|
12631
|
+
const setTheme = React36__namespace.default.useCallback(
|
|
12629
12632
|
(t) => {
|
|
12630
12633
|
setThemeState(t);
|
|
12631
12634
|
try {
|
|
@@ -12636,10 +12639,10 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
12636
12639
|
},
|
|
12637
12640
|
[storageKey]
|
|
12638
12641
|
);
|
|
12639
|
-
const toggle =
|
|
12642
|
+
const toggle = React36__namespace.default.useCallback(() => {
|
|
12640
12643
|
setTheme(themeRef.current === "dark" ? "light" : "dark");
|
|
12641
12644
|
}, [setTheme]);
|
|
12642
|
-
|
|
12645
|
+
React36__namespace.default.useEffect(() => {
|
|
12643
12646
|
if (!canUseDOM2) return void 0;
|
|
12644
12647
|
const sync = () => setThemeState(read());
|
|
12645
12648
|
const onStorage = (e) => {
|
|
@@ -12655,14 +12658,14 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
12655
12658
|
return { theme, setTheme, toggle, isDark: theme === "dark" };
|
|
12656
12659
|
}
|
|
12657
12660
|
function useEventListener(eventName, handler, element, options) {
|
|
12658
|
-
const saved =
|
|
12661
|
+
const saved = React36__namespace.default.useRef(handler);
|
|
12659
12662
|
useIsomorphicLayoutEffect(() => {
|
|
12660
12663
|
saved.current = handler;
|
|
12661
12664
|
}, [handler]);
|
|
12662
12665
|
const capture = typeof options === "boolean" ? options : options && options.capture;
|
|
12663
12666
|
const passive = typeof options === "object" && options ? options.passive : void 0;
|
|
12664
12667
|
const once = typeof options === "object" && options ? options.once : void 0;
|
|
12665
|
-
|
|
12668
|
+
React36__namespace.default.useEffect(() => {
|
|
12666
12669
|
const target = element && element.current || element || (canUseDOM2 ? window : null);
|
|
12667
12670
|
if (!target || !target.addEventListener) return void 0;
|
|
12668
12671
|
const opts = typeof options === "boolean" ? options : { capture, passive, once };
|
|
@@ -12672,11 +12675,11 @@ function useEventListener(eventName, handler, element, options) {
|
|
|
12672
12675
|
}, [eventName, element, capture, passive, once]);
|
|
12673
12676
|
}
|
|
12674
12677
|
function useClickOutside(ref, handler, events = ["mousedown", "touchstart"]) {
|
|
12675
|
-
const saved =
|
|
12678
|
+
const saved = React36__namespace.default.useRef(handler);
|
|
12676
12679
|
useIsomorphicLayoutEffect(() => {
|
|
12677
12680
|
saved.current = handler;
|
|
12678
12681
|
}, [handler]);
|
|
12679
|
-
|
|
12682
|
+
React36__namespace.default.useEffect(() => {
|
|
12680
12683
|
if (!canUseDOM2) return void 0;
|
|
12681
12684
|
const listener = (e) => {
|
|
12682
12685
|
const el = ref && ref.current;
|
|
@@ -12711,8 +12714,8 @@ function useLocalStorage(key, initialValue) {
|
|
|
12711
12714
|
return initialValue;
|
|
12712
12715
|
}
|
|
12713
12716
|
};
|
|
12714
|
-
const [stored, setStored] =
|
|
12715
|
-
const setValue =
|
|
12717
|
+
const [stored, setStored] = React36__namespace.default.useState(read);
|
|
12718
|
+
const setValue = React36__namespace.default.useCallback(
|
|
12716
12719
|
(value) => {
|
|
12717
12720
|
setStored((prev) => {
|
|
12718
12721
|
const next = typeof value === "function" ? value(prev) : value;
|
|
@@ -12728,8 +12731,8 @@ function useLocalStorage(key, initialValue) {
|
|
|
12728
12731
|
return [stored, setValue];
|
|
12729
12732
|
}
|
|
12730
12733
|
function useCopyToClipboard(timeout = 1500) {
|
|
12731
|
-
const [copied, setCopied] =
|
|
12732
|
-
const copy =
|
|
12734
|
+
const [copied, setCopied] = React36__namespace.default.useState(false);
|
|
12735
|
+
const copy = React36__namespace.default.useCallback(async (text) => {
|
|
12733
12736
|
if (!canUseDOM2 || !navigator.clipboard) {
|
|
12734
12737
|
setCopied(false);
|
|
12735
12738
|
return false;
|
|
@@ -12743,7 +12746,7 @@ function useCopyToClipboard(timeout = 1500) {
|
|
|
12743
12746
|
return false;
|
|
12744
12747
|
}
|
|
12745
12748
|
}, []);
|
|
12746
|
-
|
|
12749
|
+
React36__namespace.default.useEffect(() => {
|
|
12747
12750
|
if (!copied) return void 0;
|
|
12748
12751
|
const t = setTimeout(() => setCopied(false), timeout);
|
|
12749
12752
|
return () => clearTimeout(t);
|
|
@@ -12751,23 +12754,23 @@ function useCopyToClipboard(timeout = 1500) {
|
|
|
12751
12754
|
return { copied, copy };
|
|
12752
12755
|
}
|
|
12753
12756
|
function useDebouncedValue(value, delay = 200) {
|
|
12754
|
-
const [debounced, setDebounced] =
|
|
12755
|
-
|
|
12757
|
+
const [debounced, setDebounced] = React36__namespace.default.useState(value);
|
|
12758
|
+
React36__namespace.default.useEffect(() => {
|
|
12756
12759
|
const t = setTimeout(() => setDebounced(value), delay);
|
|
12757
12760
|
return () => clearTimeout(t);
|
|
12758
12761
|
}, [value, delay]);
|
|
12759
12762
|
return debounced;
|
|
12760
12763
|
}
|
|
12761
12764
|
function useDebouncedCallback(callback, delay = 200) {
|
|
12762
|
-
const saved =
|
|
12763
|
-
const timer =
|
|
12765
|
+
const saved = React36__namespace.default.useRef(callback);
|
|
12766
|
+
const timer = React36__namespace.default.useRef(null);
|
|
12764
12767
|
useIsomorphicLayoutEffect(() => {
|
|
12765
12768
|
saved.current = callback;
|
|
12766
12769
|
}, [callback]);
|
|
12767
|
-
|
|
12770
|
+
React36__namespace.default.useEffect(() => () => {
|
|
12768
12771
|
if (timer.current) clearTimeout(timer.current);
|
|
12769
12772
|
}, []);
|
|
12770
|
-
return
|
|
12773
|
+
return React36__namespace.default.useCallback(
|
|
12771
12774
|
(...args) => {
|
|
12772
12775
|
if (timer.current) clearTimeout(timer.current);
|
|
12773
12776
|
timer.current = setTimeout(() => saved.current(...args), delay);
|
|
@@ -12776,33 +12779,33 @@ function useDebouncedCallback(callback, delay = 200) {
|
|
|
12776
12779
|
);
|
|
12777
12780
|
}
|
|
12778
12781
|
function useInterval(callback, delay) {
|
|
12779
|
-
const saved =
|
|
12782
|
+
const saved = React36__namespace.default.useRef(callback);
|
|
12780
12783
|
useIsomorphicLayoutEffect(() => {
|
|
12781
12784
|
saved.current = callback;
|
|
12782
12785
|
}, [callback]);
|
|
12783
|
-
|
|
12786
|
+
React36__namespace.default.useEffect(() => {
|
|
12784
12787
|
if (delay == null) return void 0;
|
|
12785
12788
|
const id = setInterval(() => saved.current(), delay);
|
|
12786
12789
|
return () => clearInterval(id);
|
|
12787
12790
|
}, [delay]);
|
|
12788
12791
|
}
|
|
12789
12792
|
function useTimeout(callback, delay) {
|
|
12790
|
-
const saved =
|
|
12793
|
+
const saved = React36__namespace.default.useRef(callback);
|
|
12791
12794
|
useIsomorphicLayoutEffect(() => {
|
|
12792
12795
|
saved.current = callback;
|
|
12793
12796
|
}, [callback]);
|
|
12794
|
-
|
|
12797
|
+
React36__namespace.default.useEffect(() => {
|
|
12795
12798
|
if (delay == null) return void 0;
|
|
12796
12799
|
const id = setTimeout(() => saved.current(), delay);
|
|
12797
12800
|
return () => clearTimeout(id);
|
|
12798
12801
|
}, [delay]);
|
|
12799
12802
|
}
|
|
12800
12803
|
function useWindowSize() {
|
|
12801
|
-
const [size, setSize] =
|
|
12804
|
+
const [size, setSize] = React36__namespace.default.useState(() => ({
|
|
12802
12805
|
width: canUseDOM2 ? window.innerWidth : 0,
|
|
12803
12806
|
height: canUseDOM2 ? window.innerHeight : 0
|
|
12804
12807
|
}));
|
|
12805
|
-
|
|
12808
|
+
React36__namespace.default.useEffect(() => {
|
|
12806
12809
|
if (!canUseDOM2) return void 0;
|
|
12807
12810
|
const onResize = () => setSize({ width: window.innerWidth, height: window.innerHeight });
|
|
12808
12811
|
onResize();
|
|
@@ -12812,8 +12815,8 @@ function useWindowSize() {
|
|
|
12812
12815
|
return size;
|
|
12813
12816
|
}
|
|
12814
12817
|
function useHover(ref) {
|
|
12815
|
-
const [hovered, setHovered] =
|
|
12816
|
-
|
|
12818
|
+
const [hovered, setHovered] = React36__namespace.default.useState(false);
|
|
12819
|
+
React36__namespace.default.useEffect(() => {
|
|
12817
12820
|
const el = ref && ref.current;
|
|
12818
12821
|
if (!el) return void 0;
|
|
12819
12822
|
const on = () => setHovered(true);
|
|
@@ -12829,8 +12832,8 @@ function useHover(ref) {
|
|
|
12829
12832
|
}
|
|
12830
12833
|
function useIntersectionObserver(ref, options = {}) {
|
|
12831
12834
|
const { root = null, rootMargin = "0px", threshold = 0 } = options;
|
|
12832
|
-
const [entry, setEntry] =
|
|
12833
|
-
|
|
12835
|
+
const [entry, setEntry] = React36__namespace.default.useState(null);
|
|
12836
|
+
React36__namespace.default.useEffect(() => {
|
|
12834
12837
|
const el = ref && ref.current;
|
|
12835
12838
|
if (!canUseDOM2 || !el || typeof IntersectionObserver === "undefined") return void 0;
|
|
12836
12839
|
const obs = new IntersectionObserver(([e]) => setEntry(e), { root, rootMargin, threshold });
|
|
@@ -12840,7 +12843,7 @@ function useIntersectionObserver(ref, options = {}) {
|
|
|
12840
12843
|
return entry;
|
|
12841
12844
|
}
|
|
12842
12845
|
function useId(prefix = "twc") {
|
|
12843
|
-
const raw =
|
|
12846
|
+
const raw = React36__namespace.default.useId();
|
|
12844
12847
|
return prefix ? `${prefix}-${raw.replace(/:/g, "")}` : raw;
|
|
12845
12848
|
}
|
|
12846
12849
|
var useFocusTrap2 = useFocusTrap;
|