twico-ui 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +251 -0
- package/README.md +4 -0
- package/dist/index.cjs +939 -630
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +145 -7
- package/dist/index.d.ts +145 -7
- package/dist/index.mjs +927 -631
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -2
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,21 +23,334 @@ 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
|
-
// components/
|
|
29
|
-
var SUPPORTS_STYLE_HOIST = parseInt(String(
|
|
28
|
+
// components/TwicoProvider.jsx
|
|
29
|
+
var SUPPORTS_STYLE_HOIST = parseInt(String(React36__namespace.version), 10) >= 19;
|
|
30
|
+
var NonceContext = React36__namespace.createContext(void 0);
|
|
30
31
|
function useScopedStyles(id, css) {
|
|
31
|
-
|
|
32
|
+
const nonce = React36__namespace.useContext(NonceContext);
|
|
33
|
+
React36__namespace.useInsertionEffect(() => {
|
|
32
34
|
if (SUPPORTS_STYLE_HOIST) return;
|
|
33
35
|
if (typeof document === "undefined" || document.getElementById(id)) return;
|
|
34
36
|
const el = document.createElement("style");
|
|
35
37
|
el.id = id;
|
|
38
|
+
if (nonce) {
|
|
39
|
+
el.setAttribute("nonce", nonce);
|
|
40
|
+
el.nonce = nonce;
|
|
41
|
+
}
|
|
36
42
|
el.textContent = css;
|
|
37
43
|
document.head.appendChild(el);
|
|
38
|
-
}, [id, css]);
|
|
39
|
-
return SUPPORTS_STYLE_HOIST ?
|
|
44
|
+
}, [id, css, nonce]);
|
|
45
|
+
return SUPPORTS_STYLE_HOIST ? React36__namespace.createElement("style", { href: id, precedence: "twc-ui", nonce }, css) : null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// components/TwicoProvider.jsx
|
|
49
|
+
function TwicoProvider({ nonce, children }) {
|
|
50
|
+
return React36__namespace.default.createElement(NonceContext.Provider, { value: nonce }, children);
|
|
51
|
+
}
|
|
52
|
+
var GROUPS = { colors: "color", space: "space", radius: "radius", font: "font", shadow: "shadow", motion: "" };
|
|
53
|
+
function createTheme(partial = {}) {
|
|
54
|
+
const vars = {};
|
|
55
|
+
for (const [group, prefix] of Object.entries(GROUPS)) {
|
|
56
|
+
const obj = partial[group];
|
|
57
|
+
if (!obj || typeof obj !== "object") continue;
|
|
58
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
59
|
+
if (value == null) continue;
|
|
60
|
+
vars[`--${prefix ? `${prefix}-` : ""}${key}`] = String(value);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return vars;
|
|
64
|
+
}
|
|
65
|
+
function toVars(theme) {
|
|
66
|
+
if (!theme) return {};
|
|
67
|
+
return Object.keys(theme).some((k) => k.startsWith("--")) ? theme : createTheme(theme);
|
|
68
|
+
}
|
|
69
|
+
function ThemeProvider({ theme, mode = "inline", className = "", style, children, ...rest }) {
|
|
70
|
+
const vars = React36__namespace.default.useMemo(() => toVars(theme), [theme]);
|
|
71
|
+
const uid = React36__namespace.default.useId();
|
|
72
|
+
const scopeId = `twc-theme-${uid.replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
73
|
+
const css = mode === "stylesheet" ? `[data-twc-theme="${scopeId}"] { ${Object.entries(vars).map(([k, v]) => `${k}: ${v};`).join(" ")} }` : "";
|
|
74
|
+
const __twcStyles = useScopedStyles(mode === "stylesheet" ? scopeId : "twc-theme-noop", css);
|
|
75
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
className: `twc-theme ${className}`.trim(),
|
|
79
|
+
"data-twc-theme": mode === "stylesheet" ? scopeId : void 0,
|
|
80
|
+
style: mode === "stylesheet" ? style : { ...vars, ...style },
|
|
81
|
+
...rest,
|
|
82
|
+
children: [
|
|
83
|
+
mode === "stylesheet" ? __twcStyles : null,
|
|
84
|
+
children
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
var FORM_CSS = `
|
|
90
|
+
.twc-form { display: flex; flex-direction: column; gap: var(--space-4); font-family: var(--font-sans); }
|
|
91
|
+
.twc-form__fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: inherit; }
|
|
92
|
+
`;
|
|
93
|
+
var Form = React36__namespace.default.forwardRef(function Form2({
|
|
94
|
+
onSubmit,
|
|
95
|
+
preventDefault = true,
|
|
96
|
+
loading = false,
|
|
97
|
+
disabled = false,
|
|
98
|
+
gap,
|
|
99
|
+
className = "",
|
|
100
|
+
style,
|
|
101
|
+
children,
|
|
102
|
+
...rest
|
|
103
|
+
}, ref) {
|
|
104
|
+
const __twcStyles = useScopedStyles("twc-form-styles", FORM_CSS);
|
|
105
|
+
const handleSubmit = (e) => {
|
|
106
|
+
if (preventDefault) e.preventDefault();
|
|
107
|
+
onSubmit?.(e);
|
|
108
|
+
};
|
|
109
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
110
|
+
"form",
|
|
111
|
+
{
|
|
112
|
+
ref,
|
|
113
|
+
className: `twc-form ${className}`.trim(),
|
|
114
|
+
onSubmit: handleSubmit,
|
|
115
|
+
style: gap != null ? { gap: `var(--space-${gap})`, ...style } : style,
|
|
116
|
+
...rest,
|
|
117
|
+
children: [
|
|
118
|
+
__twcStyles,
|
|
119
|
+
/* @__PURE__ */ jsxRuntime.jsx("fieldset", { className: "twc-form__fieldset", disabled: loading || disabled || void 0, "aria-busy": loading || void 0, children })
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
Form.displayName = "Form";
|
|
125
|
+
var VH_CSS = `
|
|
126
|
+
.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; }
|
|
127
|
+
`;
|
|
128
|
+
var VisuallyHidden = React36__namespace.default.forwardRef(function VisuallyHidden2({ as: Tag2 = "span", className = "", children, ...rest }, ref) {
|
|
129
|
+
const __twcStyles = useScopedStyles("twc-visually-hidden-styles", VH_CSS);
|
|
130
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Tag2, { ref, className: `twc-visually-hidden ${className}`.trim(), ...rest, children: [
|
|
131
|
+
__twcStyles,
|
|
132
|
+
children
|
|
133
|
+
] });
|
|
134
|
+
});
|
|
135
|
+
VisuallyHidden.displayName = "VisuallyHidden";
|
|
136
|
+
var canUseDOM = typeof window !== "undefined" && typeof document !== "undefined";
|
|
137
|
+
var useIsoLayoutEffect = canUseDOM ? React36__namespace.default.useLayoutEffect : React36__namespace.default.useEffect;
|
|
138
|
+
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"])';
|
|
139
|
+
function useFocusTrap(ref, active = true, { restoreFocus = true, initialFocus } = {}) {
|
|
140
|
+
React36__namespace.default.useEffect(() => {
|
|
141
|
+
if (!active || !canUseDOM) return void 0;
|
|
142
|
+
const node = ref.current;
|
|
143
|
+
if (!node) return void 0;
|
|
144
|
+
const prevFocused = document.activeElement;
|
|
145
|
+
const target = (typeof initialFocus === "function" ? initialFocus() : initialFocus && initialFocus.current) || node.querySelector(FOCUSABLE);
|
|
146
|
+
(target || node).focus();
|
|
147
|
+
return () => {
|
|
148
|
+
if (restoreFocus && prevFocused && typeof prevFocused.focus === "function") prevFocused.focus();
|
|
149
|
+
};
|
|
150
|
+
}, [active]);
|
|
151
|
+
React36__namespace.default.useEffect(() => {
|
|
152
|
+
if (!active || !canUseDOM) return void 0;
|
|
153
|
+
const node = ref.current;
|
|
154
|
+
const onKey = (e) => {
|
|
155
|
+
if (e.key !== "Tab" || !node) return;
|
|
156
|
+
const f = Array.from(node.querySelectorAll(FOCUSABLE)).filter((el) => el.offsetParent !== null);
|
|
157
|
+
if (!f.length) {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
node.focus();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const first = f[0], last = f[f.length - 1], ae = document.activeElement;
|
|
163
|
+
if (e.shiftKey) {
|
|
164
|
+
if (ae === first || ae === node || !node.contains(ae)) {
|
|
165
|
+
e.preventDefault();
|
|
166
|
+
last.focus();
|
|
167
|
+
}
|
|
168
|
+
} else if (ae === last || !node.contains(ae)) {
|
|
169
|
+
e.preventDefault();
|
|
170
|
+
first.focus();
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
document.addEventListener("keydown", onKey);
|
|
174
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
175
|
+
}, [active]);
|
|
176
|
+
}
|
|
177
|
+
function usePortal() {
|
|
178
|
+
return React36__namespace.default.useCallback((node) => {
|
|
179
|
+
if (typeof document === "undefined") return null;
|
|
180
|
+
return typeof reactDom.createPortal === "function" ? reactDom.createPortal(node, document.body) : node;
|
|
181
|
+
}, []);
|
|
182
|
+
}
|
|
183
|
+
var __scrollLockCount = 0;
|
|
184
|
+
var __scrollLockSaved = { overflow: "", paddingRight: "" };
|
|
185
|
+
function useScrollLock(locked = true) {
|
|
186
|
+
useIsoLayoutEffect(() => {
|
|
187
|
+
if (!canUseDOM || !locked) return void 0;
|
|
188
|
+
if (__scrollLockCount === 0) {
|
|
189
|
+
const b = document.body;
|
|
190
|
+
__scrollLockSaved = { overflow: b.style.overflow, paddingRight: b.style.paddingRight };
|
|
191
|
+
const gutter = window.innerWidth - document.documentElement.clientWidth;
|
|
192
|
+
b.style.overflow = "hidden";
|
|
193
|
+
if (gutter > 0) b.style.paddingRight = `${(parseFloat(getComputedStyle(b).paddingRight) || 0) + gutter}px`;
|
|
194
|
+
}
|
|
195
|
+
__scrollLockCount += 1;
|
|
196
|
+
return () => {
|
|
197
|
+
__scrollLockCount -= 1;
|
|
198
|
+
if (__scrollLockCount === 0) {
|
|
199
|
+
document.body.style.overflow = __scrollLockSaved.overflow;
|
|
200
|
+
document.body.style.paddingRight = __scrollLockSaved.paddingRight;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}, [locked]);
|
|
40
204
|
}
|
|
205
|
+
function useInertBackground(ref, active) {
|
|
206
|
+
React36__namespace.default.useEffect(() => {
|
|
207
|
+
if (!active || !canUseDOM) return void 0;
|
|
208
|
+
const node = ref.current;
|
|
209
|
+
if (!node) return void 0;
|
|
210
|
+
const changed = [];
|
|
211
|
+
Array.from(document.body.children).forEach((el) => {
|
|
212
|
+
if (el.contains(node) || el.hasAttribute("aria-hidden") || el.inert) return;
|
|
213
|
+
el.inert = true;
|
|
214
|
+
el.setAttribute("aria-hidden", "true");
|
|
215
|
+
changed.push(el);
|
|
216
|
+
});
|
|
217
|
+
return () => {
|
|
218
|
+
changed.forEach((el) => {
|
|
219
|
+
el.inert = false;
|
|
220
|
+
el.removeAttribute("aria-hidden");
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
}, [active]);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// components/layout/Portal.jsx
|
|
227
|
+
function Portal({ children }) {
|
|
228
|
+
const render = usePortal();
|
|
229
|
+
return render(children);
|
|
230
|
+
}
|
|
231
|
+
function getColorSchemeScript({ storageKey = "twico-theme", attribute = "class", defaultScheme } = {}) {
|
|
232
|
+
const k = JSON.stringify(storageKey);
|
|
233
|
+
const a = JSON.stringify(attribute);
|
|
234
|
+
const d = defaultScheme === "dark" || defaultScheme === "light" ? JSON.stringify(defaultScheme) : "null";
|
|
235
|
+
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){}})();`;
|
|
236
|
+
}
|
|
237
|
+
function ColorSchemeScript({ storageKey = "twico-theme", attribute = "class", nonce, defaultScheme }) {
|
|
238
|
+
return React36__namespace.default.createElement("script", { nonce }, getColorSchemeScript({ storageKey, attribute, defaultScheme }));
|
|
239
|
+
}
|
|
240
|
+
var KBD_CSS = `
|
|
241
|
+
.twc-kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; padding: 2px 6px;
|
|
242
|
+
font-family: var(--font-mono); font-size: 11px; font-weight: var(--font-semibold); line-height: 1; color: var(--color-text-muted);
|
|
243
|
+
background: var(--color-surface-sunken); border: var(--border-thin) solid var(--color-border);
|
|
244
|
+
border-bottom-width: 2px; border-radius: var(--radius-sm); }
|
|
245
|
+
`;
|
|
246
|
+
var Kbd = React36__namespace.default.forwardRef(function Kbd2({ className = "", children, ...rest }, ref) {
|
|
247
|
+
const __twcStyles = useScopedStyles("twc-kbd-styles", KBD_CSS);
|
|
248
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("kbd", { ref, className: `twc-kbd ${className}`.trim(), ...rest, children: [
|
|
249
|
+
__twcStyles,
|
|
250
|
+
children
|
|
251
|
+
] });
|
|
252
|
+
});
|
|
253
|
+
Kbd.displayName = "Kbd";
|
|
254
|
+
var PRE_CSS = `
|
|
255
|
+
.twc-pre { margin: 0; padding: var(--space-4); overflow-x: auto; max-width: 100%;
|
|
256
|
+
font-family: var(--font-mono); font-size: var(--text-sm); line-height: var(--leading-normal);
|
|
257
|
+
color: var(--color-text); background: var(--color-surface-sunken);
|
|
258
|
+
border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-lg);
|
|
259
|
+
white-space: pre; -webkit-overflow-scrolling: touch; }
|
|
260
|
+
`;
|
|
261
|
+
var Pre = React36__namespace.default.forwardRef(function Pre2({ className = "", children, ...rest }, ref) {
|
|
262
|
+
const __twcStyles = useScopedStyles("twc-pre-styles", PRE_CSS);
|
|
263
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("pre", { ref, className: `twc-pre ${className}`.trim(), ...rest, children: [
|
|
264
|
+
__twcStyles,
|
|
265
|
+
children
|
|
266
|
+
] });
|
|
267
|
+
});
|
|
268
|
+
Pre.displayName = "Pre";
|
|
269
|
+
var ANCHOR_CSS = `
|
|
270
|
+
.twc-anchor { color: var(--color-primary); text-decoration: none; border-radius: var(--radius-sm);
|
|
271
|
+
transition: color var(--duration-fast) var(--ease-standard); }
|
|
272
|
+
.twc-anchor:hover { text-decoration: underline; color: var(--color-primary-hover, var(--color-primary)); }
|
|
273
|
+
.twc-anchor:focus-visible { outline: none; box-shadow: var(--ring); }
|
|
274
|
+
.twc-anchor__ext { display: inline-block; margin-inline-start: 3px; font-size: 0.85em; vertical-align: baseline; }
|
|
275
|
+
`;
|
|
276
|
+
function safeHref(url) {
|
|
277
|
+
if (url == null) return void 0;
|
|
278
|
+
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
279
|
+
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
280
|
+
}
|
|
281
|
+
var Anchor = React36__namespace.default.forwardRef(function Anchor2({ as: Tag2 = "a", href, external = false, className = "", children, ...rest }, ref) {
|
|
282
|
+
const __twcStyles = useScopedStyles("twc-anchor-styles", ANCHOR_CSS);
|
|
283
|
+
const extra = external ? { target: "_blank", rel: "noopener noreferrer" } : {};
|
|
284
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Tag2, { ref, className: `twc-anchor ${className}`.trim(), href: Tag2 === "a" ? safeHref(href) : href, ...extra, ...rest, children: [
|
|
285
|
+
__twcStyles,
|
|
286
|
+
children,
|
|
287
|
+
external ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-anchor__ext", "aria-hidden": "true", children: "\u2197" }) : null
|
|
288
|
+
] });
|
|
289
|
+
});
|
|
290
|
+
Anchor.displayName = "Anchor";
|
|
291
|
+
var LABEL_CSS = `
|
|
292
|
+
.twc-label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); display: inline-flex; gap: 4px; align-items: center; }
|
|
293
|
+
.twc-label[data-size="sm"] { font-size: var(--text-xs); }
|
|
294
|
+
.twc-label[data-size="lg"] { font-size: var(--text-base); }
|
|
295
|
+
.twc-label__req { color: var(--color-danger); }
|
|
296
|
+
`;
|
|
297
|
+
var Label = React36__namespace.default.forwardRef(function Label2({ htmlFor, required = false, size = "md", className = "", children, ...rest }, ref) {
|
|
298
|
+
const __twcStyles = useScopedStyles("twc-label-styles", LABEL_CSS);
|
|
299
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("label", { ref, htmlFor, className: `twc-label ${className}`.trim(), "data-size": size, ...rest, children: [
|
|
300
|
+
__twcStyles,
|
|
301
|
+
children,
|
|
302
|
+
required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-label__req", "aria-hidden": "true", children: "*" }) : null
|
|
303
|
+
] });
|
|
304
|
+
});
|
|
305
|
+
Label.displayName = "Label";
|
|
306
|
+
var IMAGE_CSS = `
|
|
307
|
+
.twc-image { display: block; max-width: 100%; }
|
|
308
|
+
.twc-image[data-fit] { width: 100%; height: 100%; }
|
|
309
|
+
`;
|
|
310
|
+
var Image = React36__namespace.default.forwardRef(function Image2({
|
|
311
|
+
src,
|
|
312
|
+
alt,
|
|
313
|
+
fit,
|
|
314
|
+
radius,
|
|
315
|
+
aspectRatio,
|
|
316
|
+
fallback,
|
|
317
|
+
loading = "lazy",
|
|
318
|
+
className = "",
|
|
319
|
+
style,
|
|
320
|
+
onError,
|
|
321
|
+
...rest
|
|
322
|
+
}, ref) {
|
|
323
|
+
const __twcStyles = useScopedStyles("twc-image-styles", IMAGE_CSS);
|
|
324
|
+
const [failed, setFailed] = React36__namespace.default.useState(false);
|
|
325
|
+
const shownSrc = failed && fallback ? fallback : src;
|
|
326
|
+
const s = {
|
|
327
|
+
objectFit: fit,
|
|
328
|
+
borderRadius: radius ? `var(--radius-${radius})` : void 0,
|
|
329
|
+
aspectRatio,
|
|
330
|
+
...style
|
|
331
|
+
};
|
|
332
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
333
|
+
__twcStyles,
|
|
334
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
335
|
+
"img",
|
|
336
|
+
{
|
|
337
|
+
ref,
|
|
338
|
+
src: shownSrc,
|
|
339
|
+
alt,
|
|
340
|
+
loading,
|
|
341
|
+
className: `twc-image ${className}`.trim(),
|
|
342
|
+
"data-fit": fit || void 0,
|
|
343
|
+
style: s,
|
|
344
|
+
onError: (e) => {
|
|
345
|
+
onError?.(e);
|
|
346
|
+
if (fallback && !failed) setFailed(true);
|
|
347
|
+
},
|
|
348
|
+
...rest
|
|
349
|
+
}
|
|
350
|
+
)
|
|
351
|
+
] });
|
|
352
|
+
});
|
|
353
|
+
Image.displayName = "Image";
|
|
41
354
|
var ACCORDION_CSS = `
|
|
42
355
|
.twc-accordion { display: flex; flex-direction: column; font-family: var(--font-sans);
|
|
43
356
|
border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; background: var(--color-surface); }
|
|
@@ -77,10 +390,10 @@ function Accordion({
|
|
|
77
390
|
...rest
|
|
78
391
|
}) {
|
|
79
392
|
const __twcStyles = useScopedStyles("twc-accordion-styles", ACCORDION_CSS);
|
|
80
|
-
const rootRef =
|
|
81
|
-
const [internal, setInternal] =
|
|
393
|
+
const rootRef = React36__namespace.default.useRef(null);
|
|
394
|
+
const [internal, setInternal] = React36__namespace.default.useState(() => new Set(defaultOpen));
|
|
82
395
|
const open = openProp !== void 0 ? new Set(openProp) : internal;
|
|
83
|
-
const baseId =
|
|
396
|
+
const baseId = React36__namespace.default.useId();
|
|
84
397
|
function toggle(val) {
|
|
85
398
|
const item = items.find((x) => x.value === val);
|
|
86
399
|
if (item?.disabled) return;
|
|
@@ -127,9 +440,9 @@ function Accordion({
|
|
|
127
440
|
const triggerId = `${baseId}-trigger-${i}`;
|
|
128
441
|
const panelId = `${baseId}-panel-${i}`;
|
|
129
442
|
const lvl = Math.min(6, Math.max(1, it.headingLevel ?? headingLevel));
|
|
130
|
-
const
|
|
443
|
+
const Heading3 = `h${lvl}`;
|
|
131
444
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-accordion__item", children: [
|
|
132
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
445
|
+
/* @__PURE__ */ jsxRuntime.jsx(Heading3, { className: "twc-accordion__heading", children: /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", id: triggerId, className: "twc-accordion__trigger", "data-open": isOpen || void 0, disabled: it.disabled || void 0, "aria-disabled": it.disabled || void 0, "data-disabled": it.disabled || void 0, "aria-expanded": isOpen, "aria-controls": panelId, onClick: () => toggle(it.value), children: [
|
|
133
446
|
it.icon,
|
|
134
447
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-accordion__label", children: it.label }),
|
|
135
448
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-accordion__chevron", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 9 6 6 6-6" }) }) })
|
|
@@ -266,7 +579,7 @@ function Avatar({
|
|
|
266
579
|
...rest
|
|
267
580
|
}) {
|
|
268
581
|
const __twcStyles = useScopedStyles("twc-avatar-styles", AVATAR_CSS);
|
|
269
|
-
const [errored, setErrored] =
|
|
582
|
+
const [errored, setErrored] = React36__namespace.default.useState(false);
|
|
270
583
|
const cleanSrc = safeSrc(src);
|
|
271
584
|
const showImg = cleanSrc && !errored;
|
|
272
585
|
const _statusLabel = status ? statusLabel ?? statusLabels?.[status] ?? STATUS_LABELS[status] : void 0;
|
|
@@ -324,7 +637,7 @@ var MENU_CSS = `
|
|
|
324
637
|
.twc-menu__item-label { flex: 1 1 auto; min-width: 0; }
|
|
325
638
|
.twc-menu__shortcut { margin-inline-start: auto; padding-inline-start: var(--space-3); font-size: var(--text-xs); color: var(--color-text-subtle); font-family: var(--font-mono); }
|
|
326
639
|
`;
|
|
327
|
-
var
|
|
640
|
+
var safeHref2 = (url) => {
|
|
328
641
|
if (url == null) return void 0;
|
|
329
642
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
330
643
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -344,25 +657,25 @@ function Menu({
|
|
|
344
657
|
...rest
|
|
345
658
|
}) {
|
|
346
659
|
const __twcStyles = useScopedStyles("twc-menu-styles", MENU_CSS);
|
|
347
|
-
const [openState, setOpenState] =
|
|
348
|
-
const [render, setRender] =
|
|
349
|
-
const [pos, setPos] =
|
|
350
|
-
const [active, setActive] =
|
|
351
|
-
const wrapRef =
|
|
352
|
-
const menuRef =
|
|
353
|
-
const typeBufRef =
|
|
354
|
-
const typeTimerRef =
|
|
355
|
-
const menuId =
|
|
660
|
+
const [openState, setOpenState] = React36__namespace.default.useState(defaultOpen);
|
|
661
|
+
const [render, setRender] = React36__namespace.default.useState(false);
|
|
662
|
+
const [pos, setPos] = React36__namespace.default.useState(null);
|
|
663
|
+
const [active, setActive] = React36__namespace.default.useState(-1);
|
|
664
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
665
|
+
const menuRef = React36__namespace.default.useRef(null);
|
|
666
|
+
const typeBufRef = React36__namespace.default.useRef("");
|
|
667
|
+
const typeTimerRef = React36__namespace.default.useRef(null);
|
|
668
|
+
const menuId = React36__namespace.default.useId();
|
|
356
669
|
const headerId = `${menuId}-header`;
|
|
357
670
|
const controlled = openProp !== void 0;
|
|
358
671
|
const open = controlled ? !!openProp : openState;
|
|
359
|
-
const openRef =
|
|
672
|
+
const openRef = React36__namespace.default.useRef(open);
|
|
360
673
|
openRef.current = open;
|
|
361
|
-
const controlledRef =
|
|
674
|
+
const controlledRef = React36__namespace.default.useRef(controlled);
|
|
362
675
|
controlledRef.current = controlled;
|
|
363
|
-
const onOpenChangeRef =
|
|
676
|
+
const onOpenChangeRef = React36__namespace.default.useRef(onOpenChange);
|
|
364
677
|
onOpenChangeRef.current = onOpenChange;
|
|
365
|
-
const setOpen =
|
|
678
|
+
const setOpen = React36__namespace.default.useCallback((next) => {
|
|
366
679
|
const value = typeof next === "function" ? next(openRef.current) : next;
|
|
367
680
|
if (value === openRef.current) return;
|
|
368
681
|
if (!controlledRef.current) setOpenState(value);
|
|
@@ -370,7 +683,7 @@ function Menu({
|
|
|
370
683
|
}, []);
|
|
371
684
|
const RD = { createPortal: typeof reactDom.createPortal === "function" ? reactDom.createPortal : typeof window !== "undefined" && window.ReactDOM && window.ReactDOM.createPortal };
|
|
372
685
|
const interactiveIdx = items.map((it, i) => !it.separator && !it.heading ? i : -1).filter((i) => i >= 0);
|
|
373
|
-
const place =
|
|
686
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
374
687
|
const t = wrapRef.current;
|
|
375
688
|
if (!t) return;
|
|
376
689
|
const r = t.getBoundingClientRect();
|
|
@@ -385,7 +698,7 @@ function Menu({
|
|
|
385
698
|
const avail = (flip ? r.top : vh - r.bottom) - gap - M;
|
|
386
699
|
setPos({ top, bottom, left, width: w, flip, maxHeight: Math.max(120, avail) });
|
|
387
700
|
}, [align, width]);
|
|
388
|
-
|
|
701
|
+
React36__namespace.default.useEffect(() => {
|
|
389
702
|
if (!open) return;
|
|
390
703
|
place();
|
|
391
704
|
const onMove = () => place();
|
|
@@ -403,7 +716,7 @@ function Menu({
|
|
|
403
716
|
document.removeEventListener("mousedown", onDown);
|
|
404
717
|
};
|
|
405
718
|
}, [open, place]);
|
|
406
|
-
|
|
719
|
+
React36__namespace.default.useEffect(() => {
|
|
407
720
|
if (open) {
|
|
408
721
|
setRender(true);
|
|
409
722
|
return;
|
|
@@ -496,7 +809,7 @@ function Menu({
|
|
|
496
809
|
items.map((it, i) => {
|
|
497
810
|
if (it.separator) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-menu__sep", role: "separator" }, `s${i}`);
|
|
498
811
|
if (it.label && it.heading) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-menu__label", children: it.label }, `h${i}`);
|
|
499
|
-
const href = !it.disabled ?
|
|
812
|
+
const href = !it.disabled ? safeHref2(it.href) : void 0;
|
|
500
813
|
const Tag2 = href ? "a" : "button";
|
|
501
814
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
502
815
|
Tag2,
|
|
@@ -526,7 +839,7 @@ function Menu({
|
|
|
526
839
|
}
|
|
527
840
|
) : null;
|
|
528
841
|
const activeDescId = open && active >= 0 ? `${menuId}-item-${active}` : void 0;
|
|
529
|
-
const triggerEl =
|
|
842
|
+
const triggerEl = React36__namespace.default.isValidElement(trigger) ? React36__namespace.default.cloneElement(trigger, {
|
|
530
843
|
onClick: (e) => {
|
|
531
844
|
trigger.props.onClick?.(e);
|
|
532
845
|
toggle();
|
|
@@ -677,7 +990,7 @@ a.twc-breadcrumb__item:hover, button.twc-breadcrumb__item:hover { color: var(--c
|
|
|
677
990
|
.twc-breadcrumb__ellipsis { border: none; background: transparent; cursor: pointer; color: var(--color-text-subtle); padding: 3px 7px; border-radius: var(--radius-sm); font: inherit; }
|
|
678
991
|
.twc-breadcrumb__ellipsis:hover { background: var(--color-surface-sunken); color: var(--color-text); }
|
|
679
992
|
`;
|
|
680
|
-
function
|
|
993
|
+
function safeHref3(url) {
|
|
681
994
|
if (url == null) return void 0;
|
|
682
995
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
683
996
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -691,7 +1004,7 @@ function Breadcrumb({
|
|
|
691
1004
|
...rest
|
|
692
1005
|
}) {
|
|
693
1006
|
const __twcStyles = useScopedStyles("twc-breadcrumb-styles", BREADCRUMB_CSS);
|
|
694
|
-
const [expanded, setExpanded] =
|
|
1007
|
+
const [expanded, setExpanded] = React36__namespace.default.useState(false);
|
|
695
1008
|
const sep = separator || /* @__PURE__ */ jsxRuntime.jsx(ChevronSep, {});
|
|
696
1009
|
let display = items;
|
|
697
1010
|
if (maxItems > 0 && items.length > maxItems && !expanded) {
|
|
@@ -704,7 +1017,7 @@ function Breadcrumb({
|
|
|
704
1017
|
__twcStyles,
|
|
705
1018
|
display.map((it, i) => {
|
|
706
1019
|
const last = i === display.length - 1;
|
|
707
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1020
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React36__namespace.default.Fragment, { children: [
|
|
708
1021
|
it.ellipsis ? /* @__PURE__ */ jsxRuntime.jsx("button", { className: "twc-breadcrumb__ellipsis", "aria-label": "Show more", onClick: () => setExpanded(true), children: "\u2026" }) : last ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
709
1022
|
"span",
|
|
710
1023
|
{
|
|
@@ -716,7 +1029,7 @@ function Breadcrumb({
|
|
|
716
1029
|
it.label
|
|
717
1030
|
]
|
|
718
1031
|
}
|
|
719
|
-
) :
|
|
1032
|
+
) : safeHref3(it.href) ? /* @__PURE__ */ jsxRuntime.jsxs("a", { className: "twc-breadcrumb__item", href: safeHref3(it.href), onClick: it.onClick, children: [
|
|
720
1033
|
it.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", style: { display: "inline-flex" }, children: it.icon }) : null,
|
|
721
1034
|
it.label
|
|
722
1035
|
] }) : it.onClick ? /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "twc-breadcrumb__item", onClick: it.onClick, children: [
|
|
@@ -824,7 +1137,7 @@ var CSS2 = `
|
|
|
824
1137
|
animation: twico-ripple var(--duration-slow) var(--ease-out) forwards;
|
|
825
1138
|
}
|
|
826
1139
|
`;
|
|
827
|
-
function
|
|
1140
|
+
function safeHref4(url) {
|
|
828
1141
|
if (url == null) return void 0;
|
|
829
1142
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
830
1143
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -846,7 +1159,7 @@ function Button({
|
|
|
846
1159
|
...rest
|
|
847
1160
|
}) {
|
|
848
1161
|
const __twcStyles = useScopedStyles("twc-btn-styles", CSS2);
|
|
849
|
-
const [ripples, setRipples] =
|
|
1162
|
+
const [ripples, setRipples] = React36__namespace.default.useState([]);
|
|
850
1163
|
const Tag2 = as;
|
|
851
1164
|
const inert = Tag2 === "a" && (disabled || loading);
|
|
852
1165
|
function handleClick(e) {
|
|
@@ -875,7 +1188,7 @@ function Button({
|
|
|
875
1188
|
"data-block": fullWidth || void 0,
|
|
876
1189
|
disabled: Tag2 === "button" ? disabled || loading : void 0,
|
|
877
1190
|
type: Tag2 === "button" ? "button" : void 0,
|
|
878
|
-
href: inert ? void 0 :
|
|
1191
|
+
href: inert ? void 0 : safeHref4(href),
|
|
879
1192
|
"aria-disabled": inert || void 0,
|
|
880
1193
|
tabIndex: inert ? -1 : void 0,
|
|
881
1194
|
"aria-busy": loading || void 0,
|
|
@@ -1020,14 +1333,14 @@ function Carousel({
|
|
|
1020
1333
|
...rest
|
|
1021
1334
|
}) {
|
|
1022
1335
|
const __twcStyles = useScopedStyles("twc-carousel-styles", CAROUSEL_CSS);
|
|
1023
|
-
const slides =
|
|
1336
|
+
const slides = React36__namespace.default.Children.toArray(children);
|
|
1024
1337
|
const count = slides.length;
|
|
1025
|
-
const [internal, setInternal] =
|
|
1338
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultIndex);
|
|
1026
1339
|
const index = indexProp !== void 0 ? indexProp : internal;
|
|
1027
|
-
const [paused, setPaused] =
|
|
1028
|
-
const [userPaused, setUserPaused] =
|
|
1029
|
-
const [prefersReduced, setPrefersReduced] =
|
|
1030
|
-
|
|
1340
|
+
const [paused, setPaused] = React36__namespace.default.useState(false);
|
|
1341
|
+
const [userPaused, setUserPaused] = React36__namespace.default.useState(false);
|
|
1342
|
+
const [prefersReduced, setPrefersReduced] = React36__namespace.default.useState(false);
|
|
1343
|
+
React36__namespace.default.useEffect(() => {
|
|
1031
1344
|
if (typeof window === "undefined" || !window.matchMedia) return void 0;
|
|
1032
1345
|
const mql = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
1033
1346
|
const on = () => setPrefersReduced(mql.matches);
|
|
@@ -1035,15 +1348,15 @@ function Carousel({
|
|
|
1035
1348
|
mql.addEventListener("change", on);
|
|
1036
1349
|
return () => mql.removeEventListener("change", on);
|
|
1037
1350
|
}, []);
|
|
1038
|
-
const setIndex =
|
|
1351
|
+
const setIndex = React36__namespace.default.useCallback((i) => {
|
|
1039
1352
|
if (indexProp === void 0) setInternal(i);
|
|
1040
1353
|
onIndexChange?.(i);
|
|
1041
1354
|
}, [indexProp, onIndexChange]);
|
|
1042
|
-
const go =
|
|
1355
|
+
const go = React36__namespace.default.useCallback((i) => {
|
|
1043
1356
|
setIndex(loop ? (i + count) % count : Math.min(Math.max(i, 0), count - 1));
|
|
1044
1357
|
}, [count, loop, setIndex]);
|
|
1045
1358
|
const autoRotating = autoPlay && !paused && !userPaused && !prefersReduced && count > 1;
|
|
1046
|
-
|
|
1359
|
+
React36__namespace.default.useEffect(() => {
|
|
1047
1360
|
if (!autoRotating) return void 0;
|
|
1048
1361
|
const t = setInterval(() => {
|
|
1049
1362
|
const next = loop ? (index + 1) % count : index + 1 >= count ? index : index + 1;
|
|
@@ -1138,7 +1451,7 @@ function Chart({
|
|
|
1138
1451
|
...rest
|
|
1139
1452
|
}) {
|
|
1140
1453
|
const __twcStyles = useScopedStyles("twc-chart-styles", CHART_CSS);
|
|
1141
|
-
const uid =
|
|
1454
|
+
const uid = React36__namespace.default.useId();
|
|
1142
1455
|
const tableId = tableFallback ? `${uid}-table` : void 0;
|
|
1143
1456
|
const keys = series || ["value"];
|
|
1144
1457
|
const palette = colors && colors.length ? colors : SERIES_COLORS;
|
|
@@ -1294,13 +1607,13 @@ function Checkbox({
|
|
|
1294
1607
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
1295
1608
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
1296
1609
|
`);
|
|
1297
|
-
const autoId =
|
|
1610
|
+
const autoId = React36__namespace.default.useId();
|
|
1298
1611
|
const fieldId = id || autoId;
|
|
1299
1612
|
const errId = `${fieldId}-error`;
|
|
1300
1613
|
const invalid = Boolean(error);
|
|
1301
|
-
const ref =
|
|
1614
|
+
const ref = React36__namespace.default.useRef(null);
|
|
1302
1615
|
const mixed = indeterminate && !checked;
|
|
1303
|
-
|
|
1616
|
+
React36__namespace.default.useEffect(() => {
|
|
1304
1617
|
if (ref.current) ref.current.indeterminate = mixed;
|
|
1305
1618
|
}, [mixed]);
|
|
1306
1619
|
if (process.env.NODE_ENV !== "production" && !label && !description && !rest["aria-label"] && !rest["aria-labelledby"]) {
|
|
@@ -1443,20 +1756,20 @@ function ColorPicker({
|
|
|
1443
1756
|
}) {
|
|
1444
1757
|
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS);
|
|
1445
1758
|
const __twcStyles1 = useScopedStyles("twc-colorpicker-styles", COLORPICKER_CSS);
|
|
1446
|
-
const [internal, setInternal] =
|
|
1759
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
1447
1760
|
const hex = (value !== void 0 ? value : internal) || "#000000";
|
|
1448
|
-
const lastValidRef =
|
|
1761
|
+
const lastValidRef = React36__namespace.default.useRef(hex);
|
|
1449
1762
|
if (/^#[0-9a-f]{6}$/i.test(hex)) lastValidRef.current = hex;
|
|
1450
|
-
const [open, setOpen] =
|
|
1451
|
-
const [hsv, setHsv] =
|
|
1452
|
-
const [coords, setCoords] =
|
|
1453
|
-
const wrapRef =
|
|
1454
|
-
const triggerRef =
|
|
1455
|
-
const popRef =
|
|
1456
|
-
const areaRef =
|
|
1457
|
-
const hueRef =
|
|
1763
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
1764
|
+
const [hsv, setHsv] = React36__namespace.default.useState(() => hexToHsv(hex) || { h: 239, s: 60, v: 94 });
|
|
1765
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
1766
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
1767
|
+
const triggerRef = React36__namespace.default.useRef(null);
|
|
1768
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
1769
|
+
const areaRef = React36__namespace.default.useRef(null);
|
|
1770
|
+
const hueRef = React36__namespace.default.useRef(null);
|
|
1458
1771
|
const POP_W = 240;
|
|
1459
|
-
const place =
|
|
1772
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
1460
1773
|
const el = triggerRef.current;
|
|
1461
1774
|
if (!el) return;
|
|
1462
1775
|
const r = el.getBoundingClientRect();
|
|
@@ -1467,7 +1780,7 @@ function ColorPicker({
|
|
|
1467
1780
|
left = Math.max(8, left);
|
|
1468
1781
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
1469
1782
|
}, []);
|
|
1470
|
-
|
|
1783
|
+
React36__namespace.default.useEffect(() => {
|
|
1471
1784
|
if (!open) return void 0;
|
|
1472
1785
|
place();
|
|
1473
1786
|
const onMove = () => place();
|
|
@@ -1478,17 +1791,17 @@ function ColorPicker({
|
|
|
1478
1791
|
window.removeEventListener("resize", onMove);
|
|
1479
1792
|
};
|
|
1480
1793
|
}, [open, place]);
|
|
1481
|
-
const labelId =
|
|
1794
|
+
const labelId = React36__namespace.default.useId();
|
|
1482
1795
|
const descId = `${labelId}-desc`;
|
|
1483
1796
|
const invalid = Boolean(error);
|
|
1484
|
-
|
|
1797
|
+
React36__namespace.default.useEffect(() => {
|
|
1485
1798
|
if (disabled) setOpen(false);
|
|
1486
1799
|
}, [disabled]);
|
|
1487
|
-
|
|
1800
|
+
React36__namespace.default.useEffect(() => {
|
|
1488
1801
|
const v = hexToHsv(hex);
|
|
1489
1802
|
if (v && hsvToHex(v.h, v.s, v.v).toLowerCase() !== hsvToHex(hsv.h, hsv.s, hsv.v).toLowerCase()) setHsv(v);
|
|
1490
1803
|
}, [hex]);
|
|
1491
|
-
|
|
1804
|
+
React36__namespace.default.useEffect(() => {
|
|
1492
1805
|
if (!open) return;
|
|
1493
1806
|
const onDown = (e) => {
|
|
1494
1807
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -1505,18 +1818,7 @@ function ColorPicker({
|
|
|
1505
1818
|
document.removeEventListener("keydown", onKey);
|
|
1506
1819
|
};
|
|
1507
1820
|
}, [open]);
|
|
1508
|
-
|
|
1509
|
-
React25__namespace.default.useEffect(() => {
|
|
1510
|
-
let id;
|
|
1511
|
-
if (!prevOpen.current && open) {
|
|
1512
|
-
id = setTimeout(() => areaRef.current?.focus({ preventScroll: true }), 20);
|
|
1513
|
-
} else if (prevOpen.current && !open) {
|
|
1514
|
-
const ae = typeof document !== "undefined" ? document.activeElement : null;
|
|
1515
|
-
if (!ae || ae === document.body) triggerRef.current?.focus();
|
|
1516
|
-
}
|
|
1517
|
-
prevOpen.current = open;
|
|
1518
|
-
return () => clearTimeout(id);
|
|
1519
|
-
}, [open]);
|
|
1821
|
+
useFocusTrap(popRef, open && !!coords, { initialFocus: areaRef });
|
|
1520
1822
|
const commit = (next) => {
|
|
1521
1823
|
const h = hsvToHex(next.h, next.s, next.v);
|
|
1522
1824
|
setHsv(next);
|
|
@@ -1609,6 +1911,7 @@ function ColorPicker({
|
|
|
1609
1911
|
className: "twc-cp__pop",
|
|
1610
1912
|
ref: popRef,
|
|
1611
1913
|
role: "dialog",
|
|
1914
|
+
"aria-modal": "true",
|
|
1612
1915
|
"aria-label": "Color picker",
|
|
1613
1916
|
style: { position: "fixed", left: coords.left, right: "auto", top: coords.top, bottom: coords.bottom, zIndex: "var(--z-tooltip)" },
|
|
1614
1917
|
children: [
|
|
@@ -1836,29 +2139,29 @@ function Combobox({
|
|
|
1836
2139
|
...rest
|
|
1837
2140
|
}) {
|
|
1838
2141
|
const __twcStyles = useScopedStyles("twc-combo-styles", COMBO_CSS);
|
|
1839
|
-
const groups =
|
|
1840
|
-
const flat =
|
|
1841
|
-
const autoId =
|
|
2142
|
+
const groups = React36__namespace.default.useMemo(() => normalizeGroups(options), [options]);
|
|
2143
|
+
const flat = React36__namespace.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
2144
|
+
const autoId = React36__namespace.default.useId();
|
|
1842
2145
|
const fieldId = id || autoId;
|
|
1843
|
-
const [internal, setInternal] =
|
|
2146
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
1844
2147
|
const current = value !== void 0 ? value : internal;
|
|
1845
2148
|
const selected = flat.find((o) => o.value === current);
|
|
1846
|
-
const [open, setOpen] =
|
|
1847
|
-
const [query, setQuery] =
|
|
1848
|
-
const [active, setActive] =
|
|
1849
|
-
const [coords, setCoords] =
|
|
1850
|
-
const wrapRef =
|
|
1851
|
-
const controlRef =
|
|
1852
|
-
const inputRef =
|
|
1853
|
-
const popRef =
|
|
1854
|
-
const listRef =
|
|
1855
|
-
const activeRef =
|
|
1856
|
-
const fGroups =
|
|
2149
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
2150
|
+
const [query, setQuery] = React36__namespace.default.useState("");
|
|
2151
|
+
const [active, setActive] = React36__namespace.default.useState(0);
|
|
2152
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
2153
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
2154
|
+
const controlRef = React36__namespace.default.useRef(null);
|
|
2155
|
+
const inputRef = React36__namespace.default.useRef(null);
|
|
2156
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
2157
|
+
const listRef = React36__namespace.default.useRef(null);
|
|
2158
|
+
const activeRef = React36__namespace.default.useRef(null);
|
|
2159
|
+
const fGroups = React36__namespace.default.useMemo(() => {
|
|
1857
2160
|
const q = query.trim();
|
|
1858
2161
|
const fn = filter === false ? null : typeof filter === "function" ? filter : matches;
|
|
1859
2162
|
return groups.map((g) => ({ group: g.group, options: fn ? g.options.filter((o) => fn(o, q)) : g.options })).filter((g) => g.options.length);
|
|
1860
2163
|
}, [groups, query, filter]);
|
|
1861
|
-
const visible =
|
|
2164
|
+
const visible = React36__namespace.default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
1862
2165
|
const nextEnabled = (from, dir) => {
|
|
1863
2166
|
let i = from + dir;
|
|
1864
2167
|
while (i >= 0 && i < visible.length) {
|
|
@@ -1867,7 +2170,7 @@ function Combobox({
|
|
|
1867
2170
|
}
|
|
1868
2171
|
return from;
|
|
1869
2172
|
};
|
|
1870
|
-
const place =
|
|
2173
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
1871
2174
|
const el = controlRef.current;
|
|
1872
2175
|
if (!el) return;
|
|
1873
2176
|
const r = el.getBoundingClientRect();
|
|
@@ -1882,7 +2185,7 @@ function Combobox({
|
|
|
1882
2185
|
flip
|
|
1883
2186
|
});
|
|
1884
2187
|
}, [placement, minWidth]);
|
|
1885
|
-
|
|
2188
|
+
React36__namespace.default.useEffect(() => {
|
|
1886
2189
|
if (!open || !portal) return;
|
|
1887
2190
|
place();
|
|
1888
2191
|
const onMove = () => place();
|
|
@@ -1893,7 +2196,7 @@ function Combobox({
|
|
|
1893
2196
|
window.removeEventListener("resize", onMove);
|
|
1894
2197
|
};
|
|
1895
2198
|
}, [open, portal, place]);
|
|
1896
|
-
|
|
2199
|
+
React36__namespace.default.useEffect(() => {
|
|
1897
2200
|
if (!open) return;
|
|
1898
2201
|
const onDown = (e) => {
|
|
1899
2202
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -1903,15 +2206,15 @@ function Combobox({
|
|
|
1903
2206
|
document.addEventListener("mousedown", onDown);
|
|
1904
2207
|
return () => document.removeEventListener("mousedown", onDown);
|
|
1905
2208
|
}, [open]);
|
|
1906
|
-
|
|
2209
|
+
React36__namespace.default.useEffect(() => {
|
|
1907
2210
|
setActive(0);
|
|
1908
2211
|
}, [query]);
|
|
1909
|
-
|
|
2212
|
+
React36__namespace.default.useEffect(() => {
|
|
1910
2213
|
if (!open) return;
|
|
1911
2214
|
const idx = flat.findIndex((o) => o.value === current);
|
|
1912
2215
|
setActive(idx >= 0 ? idx : 0);
|
|
1913
2216
|
}, [open]);
|
|
1914
|
-
|
|
2217
|
+
React36__namespace.default.useEffect(() => {
|
|
1915
2218
|
if (open) ensureVisible(listRef.current, activeRef.current);
|
|
1916
2219
|
}, [active, open]);
|
|
1917
2220
|
function openMenu() {
|
|
@@ -1962,7 +2265,7 @@ function Combobox({
|
|
|
1962
2265
|
const popInner = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__list", ref: listRef, children: loading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-pop__loading", role: "status", children: [
|
|
1963
2266
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-pop__spinner", "aria-hidden": "true" }),
|
|
1964
2267
|
"Loading\u2026"
|
|
1965
|
-
] }) : visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: emptyText }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2268
|
+
] }) : visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: emptyText }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React36__namespace.default.Fragment, { children: [
|
|
1966
2269
|
g.group ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
1967
2270
|
g.options.map((o) => {
|
|
1968
2271
|
counter += 1;
|
|
@@ -2107,95 +2410,6 @@ function Combobox({
|
|
|
2107
2410
|
error ? /* @__PURE__ */ jsxRuntime.jsx("span", { id: descId, className: "twc-field__error", children: error }) : hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { id: descId, className: "twc-field__hint", children: hint }) : null
|
|
2108
2411
|
] });
|
|
2109
2412
|
}
|
|
2110
|
-
var canUseDOM = typeof window !== "undefined" && typeof document !== "undefined";
|
|
2111
|
-
var useIsoLayoutEffect = canUseDOM ? React25__namespace.default.useLayoutEffect : React25__namespace.default.useEffect;
|
|
2112
|
-
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"])';
|
|
2113
|
-
function useFocusTrap(ref, active = true, { restoreFocus = true } = {}) {
|
|
2114
|
-
React25__namespace.default.useEffect(() => {
|
|
2115
|
-
if (!active || !canUseDOM) return void 0;
|
|
2116
|
-
const node = ref.current;
|
|
2117
|
-
if (!node) return void 0;
|
|
2118
|
-
const prevFocused = document.activeElement;
|
|
2119
|
-
const first = node.querySelector(FOCUSABLE);
|
|
2120
|
-
(first || node).focus();
|
|
2121
|
-
return () => {
|
|
2122
|
-
if (restoreFocus && prevFocused && typeof prevFocused.focus === "function") prevFocused.focus();
|
|
2123
|
-
};
|
|
2124
|
-
}, [active]);
|
|
2125
|
-
React25__namespace.default.useEffect(() => {
|
|
2126
|
-
if (!active || !canUseDOM) return void 0;
|
|
2127
|
-
const node = ref.current;
|
|
2128
|
-
const onKey = (e) => {
|
|
2129
|
-
if (e.key !== "Tab" || !node) return;
|
|
2130
|
-
const f = Array.from(node.querySelectorAll(FOCUSABLE)).filter((el) => el.offsetParent !== null);
|
|
2131
|
-
if (!f.length) {
|
|
2132
|
-
e.preventDefault();
|
|
2133
|
-
node.focus();
|
|
2134
|
-
return;
|
|
2135
|
-
}
|
|
2136
|
-
const first = f[0], last = f[f.length - 1], ae = document.activeElement;
|
|
2137
|
-
if (e.shiftKey) {
|
|
2138
|
-
if (ae === first || ae === node || !node.contains(ae)) {
|
|
2139
|
-
e.preventDefault();
|
|
2140
|
-
last.focus();
|
|
2141
|
-
}
|
|
2142
|
-
} else if (ae === last || !node.contains(ae)) {
|
|
2143
|
-
e.preventDefault();
|
|
2144
|
-
first.focus();
|
|
2145
|
-
}
|
|
2146
|
-
};
|
|
2147
|
-
document.addEventListener("keydown", onKey);
|
|
2148
|
-
return () => document.removeEventListener("keydown", onKey);
|
|
2149
|
-
}, [active]);
|
|
2150
|
-
}
|
|
2151
|
-
function usePortal() {
|
|
2152
|
-
return React25__namespace.default.useCallback((node) => {
|
|
2153
|
-
if (typeof document === "undefined") return null;
|
|
2154
|
-
return typeof reactDom.createPortal === "function" ? reactDom.createPortal(node, document.body) : node;
|
|
2155
|
-
}, []);
|
|
2156
|
-
}
|
|
2157
|
-
var __scrollLockCount = 0;
|
|
2158
|
-
var __scrollLockSaved = { overflow: "", paddingRight: "" };
|
|
2159
|
-
function useScrollLock(locked = true) {
|
|
2160
|
-
useIsoLayoutEffect(() => {
|
|
2161
|
-
if (!canUseDOM || !locked) return void 0;
|
|
2162
|
-
if (__scrollLockCount === 0) {
|
|
2163
|
-
const b = document.body;
|
|
2164
|
-
__scrollLockSaved = { overflow: b.style.overflow, paddingRight: b.style.paddingRight };
|
|
2165
|
-
const gutter = window.innerWidth - document.documentElement.clientWidth;
|
|
2166
|
-
b.style.overflow = "hidden";
|
|
2167
|
-
if (gutter > 0) b.style.paddingRight = `${(parseFloat(getComputedStyle(b).paddingRight) || 0) + gutter}px`;
|
|
2168
|
-
}
|
|
2169
|
-
__scrollLockCount += 1;
|
|
2170
|
-
return () => {
|
|
2171
|
-
__scrollLockCount -= 1;
|
|
2172
|
-
if (__scrollLockCount === 0) {
|
|
2173
|
-
document.body.style.overflow = __scrollLockSaved.overflow;
|
|
2174
|
-
document.body.style.paddingRight = __scrollLockSaved.paddingRight;
|
|
2175
|
-
}
|
|
2176
|
-
};
|
|
2177
|
-
}, [locked]);
|
|
2178
|
-
}
|
|
2179
|
-
function useInertBackground(ref, active) {
|
|
2180
|
-
React25__namespace.default.useEffect(() => {
|
|
2181
|
-
if (!active || !canUseDOM) return void 0;
|
|
2182
|
-
const node = ref.current;
|
|
2183
|
-
if (!node) return void 0;
|
|
2184
|
-
const changed = [];
|
|
2185
|
-
Array.from(document.body.children).forEach((el) => {
|
|
2186
|
-
if (el.contains(node) || el.hasAttribute("aria-hidden") || el.inert) return;
|
|
2187
|
-
el.inert = true;
|
|
2188
|
-
el.setAttribute("aria-hidden", "true");
|
|
2189
|
-
changed.push(el);
|
|
2190
|
-
});
|
|
2191
|
-
return () => {
|
|
2192
|
-
changed.forEach((el) => {
|
|
2193
|
-
el.inert = false;
|
|
2194
|
-
el.removeAttribute("aria-hidden");
|
|
2195
|
-
});
|
|
2196
|
-
};
|
|
2197
|
-
}, [active]);
|
|
2198
|
-
}
|
|
2199
2413
|
var COMMAND_CSS = `
|
|
2200
2414
|
.twc-cmdk__overlay { position: fixed; inset: 0; z-index: var(--z-modal); background: var(--color-overlay); backdrop-filter: blur(3px);
|
|
2201
2415
|
display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
|
|
@@ -2243,14 +2457,14 @@ function CommandPalette({
|
|
|
2243
2457
|
}) {
|
|
2244
2458
|
const __twcStyles = useScopedStyles("twc-cmdk-styles", COMMAND_CSS);
|
|
2245
2459
|
const renderPortal = usePortal();
|
|
2246
|
-
const [query, setQuery] =
|
|
2247
|
-
const [active, setActive] =
|
|
2248
|
-
const inputRef =
|
|
2249
|
-
const listRef =
|
|
2250
|
-
const paletteRef =
|
|
2251
|
-
const baseId =
|
|
2252
|
-
const [mounted, setMounted] =
|
|
2253
|
-
|
|
2460
|
+
const [query, setQuery] = React36__namespace.default.useState("");
|
|
2461
|
+
const [active, setActive] = React36__namespace.default.useState(0);
|
|
2462
|
+
const inputRef = React36__namespace.default.useRef(null);
|
|
2463
|
+
const listRef = React36__namespace.default.useRef(null);
|
|
2464
|
+
const paletteRef = React36__namespace.default.useRef(null);
|
|
2465
|
+
const baseId = React36__namespace.default.useId();
|
|
2466
|
+
const [mounted, setMounted] = React36__namespace.default.useState(open);
|
|
2467
|
+
React36__namespace.default.useEffect(() => {
|
|
2254
2468
|
if (open) {
|
|
2255
2469
|
setMounted(true);
|
|
2256
2470
|
return;
|
|
@@ -2259,14 +2473,14 @@ function CommandPalette({
|
|
|
2259
2473
|
return () => clearTimeout(t);
|
|
2260
2474
|
}, [open]);
|
|
2261
2475
|
useScrollLock(open);
|
|
2262
|
-
|
|
2476
|
+
React36__namespace.default.useEffect(() => {
|
|
2263
2477
|
if (open) {
|
|
2264
2478
|
setQuery("");
|
|
2265
2479
|
setActive(0);
|
|
2266
2480
|
}
|
|
2267
2481
|
}, [open]);
|
|
2268
2482
|
useFocusTrap(paletteRef, open && mounted);
|
|
2269
|
-
|
|
2483
|
+
React36__namespace.default.useEffect(() => {
|
|
2270
2484
|
if (!open) return void 0;
|
|
2271
2485
|
const onKey = (e) => {
|
|
2272
2486
|
if (e.key === "Escape") {
|
|
@@ -2278,7 +2492,7 @@ function CommandPalette({
|
|
|
2278
2492
|
return () => document.removeEventListener("keydown", onKey);
|
|
2279
2493
|
}, [open, onClose]);
|
|
2280
2494
|
const q = query.trim().toLowerCase();
|
|
2281
|
-
const filtered =
|
|
2495
|
+
const filtered = React36__namespace.default.useMemo(() => commands.filter(
|
|
2282
2496
|
(c) => !q || c.label.toLowerCase().includes(q) || (c.keywords || "").toLowerCase().includes(q) || (c.group || "").toLowerCase().includes(q)
|
|
2283
2497
|
), [commands, q]);
|
|
2284
2498
|
const groups = [];
|
|
@@ -2293,7 +2507,7 @@ function CommandPalette({
|
|
|
2293
2507
|
g.items.push(c);
|
|
2294
2508
|
flat.push(c);
|
|
2295
2509
|
});
|
|
2296
|
-
|
|
2510
|
+
React36__namespace.default.useEffect(() => {
|
|
2297
2511
|
setActive(0);
|
|
2298
2512
|
}, [query]);
|
|
2299
2513
|
const run = (cmd) => {
|
|
@@ -2313,7 +2527,7 @@ function CommandPalette({
|
|
|
2313
2527
|
if (cmd) run(cmd);
|
|
2314
2528
|
}
|
|
2315
2529
|
}
|
|
2316
|
-
|
|
2530
|
+
React36__namespace.default.useEffect(() => {
|
|
2317
2531
|
const node = listRef.current?.querySelector('[data-active="true"]');
|
|
2318
2532
|
if (node) node.scrollIntoView({ block: "nearest" });
|
|
2319
2533
|
}, [active]);
|
|
@@ -2489,13 +2703,13 @@ function Currency({
|
|
|
2489
2703
|
const prec = precision != null ? precision : meta.precision;
|
|
2490
2704
|
const sym = symbol != null ? symbol : meta.symbol;
|
|
2491
2705
|
const cur = code != null ? code : meta.code;
|
|
2492
|
-
const autoId =
|
|
2706
|
+
const autoId = React36__namespace.default.useId();
|
|
2493
2707
|
const fieldId = id || autoId;
|
|
2494
2708
|
const invalid = Boolean(error);
|
|
2495
2709
|
const controlled = value !== void 0;
|
|
2496
|
-
const [internal, setInternal] =
|
|
2710
|
+
const [internal, setInternal] = React36__namespace.default.useState(() => clampPrecision(String(defaultValue ?? ""), prec));
|
|
2497
2711
|
const shown = controlled ? clampPrecision(String(value ?? ""), prec) : internal;
|
|
2498
|
-
|
|
2712
|
+
React36__namespace.default.useEffect(() => {
|
|
2499
2713
|
if (!controlled) return;
|
|
2500
2714
|
const raw = String(value ?? "");
|
|
2501
2715
|
if (shown !== raw) {
|
|
@@ -2689,32 +2903,32 @@ function Select({
|
|
|
2689
2903
|
...rest
|
|
2690
2904
|
}) {
|
|
2691
2905
|
const __twcStyles = useScopedStyles("twc-select-styles", SELECT_CSS);
|
|
2692
|
-
const bufferRef =
|
|
2693
|
-
const bufferTimerRef =
|
|
2694
|
-
const groups =
|
|
2695
|
-
const flat =
|
|
2696
|
-
const autoId =
|
|
2906
|
+
const bufferRef = React36__namespace.default.useRef("");
|
|
2907
|
+
const bufferTimerRef = React36__namespace.default.useRef(null);
|
|
2908
|
+
const groups = React36__namespace.default.useMemo(() => normalizeGroups2(options), [options]);
|
|
2909
|
+
const flat = React36__namespace.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
2910
|
+
const autoId = React36__namespace.default.useId();
|
|
2697
2911
|
const fieldId = id || autoId;
|
|
2698
|
-
const [internal, setInternal] =
|
|
2912
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
2699
2913
|
const current = value !== void 0 ? value : internal;
|
|
2700
|
-
const [open, setOpen] =
|
|
2701
|
-
const [render, setRender] =
|
|
2702
|
-
const [active, setActive] =
|
|
2703
|
-
const [coords, setCoords] =
|
|
2704
|
-
const [query, setQuery] =
|
|
2705
|
-
const wrapRef =
|
|
2706
|
-
const triggerRef =
|
|
2707
|
-
const popRef =
|
|
2708
|
-
const listRef =
|
|
2709
|
-
const activeRef =
|
|
2710
|
-
const searchRef =
|
|
2914
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
2915
|
+
const [render, setRender] = React36__namespace.default.useState(false);
|
|
2916
|
+
const [active, setActive] = React36__namespace.default.useState(0);
|
|
2917
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
2918
|
+
const [query, setQuery] = React36__namespace.default.useState("");
|
|
2919
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
2920
|
+
const triggerRef = React36__namespace.default.useRef(null);
|
|
2921
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
2922
|
+
const listRef = React36__namespace.default.useRef(null);
|
|
2923
|
+
const activeRef = React36__namespace.default.useRef(null);
|
|
2924
|
+
const searchRef = React36__namespace.default.useRef(null);
|
|
2711
2925
|
const showSearch = searchable === void 0 ? flat.length > 5 : searchable;
|
|
2712
|
-
const fGroups =
|
|
2926
|
+
const fGroups = React36__namespace.default.useMemo(() => {
|
|
2713
2927
|
const q = query.trim().toLowerCase();
|
|
2714
2928
|
if (!q) return groups;
|
|
2715
2929
|
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);
|
|
2716
2930
|
}, [groups, query]);
|
|
2717
|
-
const visible =
|
|
2931
|
+
const visible = React36__namespace.default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
2718
2932
|
const selected = flat.find((o) => o.value === current);
|
|
2719
2933
|
const nextEnabled = (from, dir) => {
|
|
2720
2934
|
let i = from + dir;
|
|
@@ -2724,7 +2938,7 @@ function Select({
|
|
|
2724
2938
|
}
|
|
2725
2939
|
return from;
|
|
2726
2940
|
};
|
|
2727
|
-
const place =
|
|
2941
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
2728
2942
|
const el = triggerRef.current;
|
|
2729
2943
|
if (!el) return;
|
|
2730
2944
|
const r = el.getBoundingClientRect();
|
|
@@ -2740,7 +2954,7 @@ function Select({
|
|
|
2740
2954
|
flip
|
|
2741
2955
|
});
|
|
2742
2956
|
}, [placement, minWidth, matchTriggerWidth]);
|
|
2743
|
-
|
|
2957
|
+
React36__namespace.default.useEffect(() => {
|
|
2744
2958
|
if (!open || !portal) return;
|
|
2745
2959
|
place();
|
|
2746
2960
|
const onMove = () => place();
|
|
@@ -2751,7 +2965,7 @@ function Select({
|
|
|
2751
2965
|
window.removeEventListener("resize", onMove);
|
|
2752
2966
|
};
|
|
2753
2967
|
}, [open, portal, place]);
|
|
2754
|
-
|
|
2968
|
+
React36__namespace.default.useEffect(() => {
|
|
2755
2969
|
if (!open) return;
|
|
2756
2970
|
const idx = flat.findIndex((o) => o.value === current);
|
|
2757
2971
|
setActive(idx >= 0 ? idx : 0);
|
|
@@ -2767,13 +2981,13 @@ function Select({
|
|
|
2767
2981
|
document.addEventListener("mousedown", onDown);
|
|
2768
2982
|
return () => document.removeEventListener("mousedown", onDown);
|
|
2769
2983
|
}, [open]);
|
|
2770
|
-
|
|
2984
|
+
React36__namespace.default.useEffect(() => {
|
|
2771
2985
|
setActive(0);
|
|
2772
2986
|
}, [query]);
|
|
2773
|
-
|
|
2987
|
+
React36__namespace.default.useEffect(() => {
|
|
2774
2988
|
if (open) ensureVisible2(listRef.current, activeRef.current);
|
|
2775
2989
|
}, [active, open]);
|
|
2776
|
-
|
|
2990
|
+
React36__namespace.default.useEffect(() => {
|
|
2777
2991
|
if (open) {
|
|
2778
2992
|
setRender(true);
|
|
2779
2993
|
return;
|
|
@@ -2781,8 +2995,8 @@ function Select({
|
|
|
2781
2995
|
const t = setTimeout(() => setRender(false), 170);
|
|
2782
2996
|
return () => clearTimeout(t);
|
|
2783
2997
|
}, [open]);
|
|
2784
|
-
const prevOpen =
|
|
2785
|
-
|
|
2998
|
+
const prevOpen = React36__namespace.default.useRef(false);
|
|
2999
|
+
React36__namespace.default.useEffect(() => {
|
|
2786
3000
|
if (prevOpen.current && !open) {
|
|
2787
3001
|
const ae = typeof document !== "undefined" ? document.activeElement : null;
|
|
2788
3002
|
if (popRef.current && ae && popRef.current.contains(ae)) triggerRef.current?.focus();
|
|
@@ -2876,7 +3090,7 @@ function Select({
|
|
|
2876
3090
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__list", ref: listRef, children: loading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-pop__loading", role: "status", children: [
|
|
2877
3091
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-pop__spinner", "aria-hidden": "true" }),
|
|
2878
3092
|
"Loading\u2026"
|
|
2879
|
-
] }) : visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: emptyText }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3093
|
+
] }) : visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: emptyText }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React36__namespace.default.Fragment, { children: [
|
|
2880
3094
|
g.group ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
2881
3095
|
g.options.map((o) => {
|
|
2882
3096
|
counter += 1;
|
|
@@ -3059,21 +3273,21 @@ function CurrencyField({
|
|
|
3059
3273
|
...rest
|
|
3060
3274
|
}) {
|
|
3061
3275
|
const __twcStyles = useScopedStyles("twc-curf-styles", CURF_CSS);
|
|
3062
|
-
const autoId =
|
|
3276
|
+
const autoId = React36__namespace.default.useId();
|
|
3063
3277
|
const fieldId = id || autoId;
|
|
3064
3278
|
const invalid = Boolean(error);
|
|
3065
3279
|
const curControlled = currency !== void 0;
|
|
3066
|
-
const [curInternal, setCurInternal] =
|
|
3280
|
+
const [curInternal, setCurInternal] = React36__namespace.default.useState(defaultCurrency);
|
|
3067
3281
|
const cur = curControlled ? currency : curInternal;
|
|
3068
3282
|
const meta = CURRENCIES[cur] || CURRENCIES.USD;
|
|
3069
3283
|
const prec = meta.precision;
|
|
3070
3284
|
const valControlled = value !== void 0;
|
|
3071
|
-
const [valInternal, setValInternal] =
|
|
3285
|
+
const [valInternal, setValInternal] = React36__namespace.default.useState(() => clampPrecision(String(defaultValue ?? ""), prec));
|
|
3072
3286
|
const shown = valControlled ? clampPrecision(String(value ?? ""), prec) : valInternal;
|
|
3073
3287
|
const descId = `${fieldId}-desc`;
|
|
3074
3288
|
const describedBy = [error || hint ? descId : null, rest["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
3075
3289
|
const ariaInvalid = invalid ? true : rest["aria-invalid"] ?? void 0;
|
|
3076
|
-
|
|
3290
|
+
React36__namespace.default.useEffect(() => {
|
|
3077
3291
|
if (!valControlled) {
|
|
3078
3292
|
const clamped = clampPrecision(valInternal, prec);
|
|
3079
3293
|
if (clamped !== valInternal) {
|
|
@@ -3089,7 +3303,7 @@ function CurrencyField({
|
|
|
3089
3303
|
}
|
|
3090
3304
|
}
|
|
3091
3305
|
}, [prec, cur, shown, value, valControlled, valInternal]);
|
|
3092
|
-
const options =
|
|
3306
|
+
const options = React36__namespace.default.useMemo(() => {
|
|
3093
3307
|
if (!currencies) return CURRENCY_OPTIONS;
|
|
3094
3308
|
return currencies.map((c) => typeof c === "string" ? { value: c, label: `${c} \u2014 ${(CURRENCIES[c] || {}).label || c}` } : c);
|
|
3095
3309
|
}, [currencies]);
|
|
@@ -3243,13 +3457,13 @@ function Input({
|
|
|
3243
3457
|
}) {
|
|
3244
3458
|
const __twcStyles = useScopedStyles("twc-field-styles", FIELD_CSS2);
|
|
3245
3459
|
const __twcExtra = useScopedStyles("twc-input-extra-styles", INPUT_EXTRA_CSS);
|
|
3246
|
-
const autoId =
|
|
3460
|
+
const autoId = React36__namespace.default.useId();
|
|
3247
3461
|
const fieldId = id || autoId;
|
|
3248
3462
|
const descId = `${fieldId}-desc`;
|
|
3249
3463
|
const countId = `${fieldId}-count`;
|
|
3250
3464
|
const invalid = Boolean(error);
|
|
3251
3465
|
const countControlled = rest.value !== void 0;
|
|
3252
|
-
const [len2, setLen] =
|
|
3466
|
+
const [len2, setLen] = React36__namespace.default.useState(() => String(rest.defaultValue ?? "").length);
|
|
3253
3467
|
const count = countControlled ? String(rest.value ?? "").length : len2;
|
|
3254
3468
|
const max = rest.maxLength;
|
|
3255
3469
|
const showCounter = showCount && max != null;
|
|
@@ -3261,7 +3475,7 @@ function Input({
|
|
|
3261
3475
|
const ariaInvalid = invalid ? true : rest["aria-invalid"] ?? void 0;
|
|
3262
3476
|
const describedBy = [error || hint ? descId : null, showCounter ? countId : null, rest["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
3263
3477
|
const isPassword = type === "password";
|
|
3264
|
-
const [revealed, setRevealed] =
|
|
3478
|
+
const [revealed, setRevealed] = React36__namespace.default.useState(false);
|
|
3265
3479
|
const effectiveType = isPassword && revealed ? "text" : type;
|
|
3266
3480
|
const suffix = rightIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-input__affix", children: rightIcon }) : isPassword ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3267
3481
|
"button",
|
|
@@ -3462,27 +3676,27 @@ function MultiSelect({
|
|
|
3462
3676
|
...rest
|
|
3463
3677
|
}) {
|
|
3464
3678
|
const __twcStyles = useScopedStyles("twc-ms-styles", MULTI_CSS);
|
|
3465
|
-
const groups =
|
|
3466
|
-
const flat =
|
|
3467
|
-
const autoId =
|
|
3679
|
+
const groups = React36__namespace.default.useMemo(() => normalizeGroups3(options), [options]);
|
|
3680
|
+
const flat = React36__namespace.default.useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
3681
|
+
const autoId = React36__namespace.default.useId();
|
|
3468
3682
|
const fieldId = id || autoId;
|
|
3469
|
-
const [internal, setInternal] =
|
|
3683
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
3470
3684
|
const selected = value !== void 0 ? value : internal;
|
|
3471
|
-
const [open, setOpen] =
|
|
3472
|
-
const [query, setQuery] =
|
|
3473
|
-
const [active, setActive] =
|
|
3474
|
-
const [coords, setCoords] =
|
|
3475
|
-
const wrapRef =
|
|
3476
|
-
const controlRef =
|
|
3477
|
-
const inputRef =
|
|
3478
|
-
const popRef =
|
|
3479
|
-
const listRef =
|
|
3480
|
-
const activeRef =
|
|
3481
|
-
const fGroups =
|
|
3685
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
3686
|
+
const [query, setQuery] = React36__namespace.default.useState("");
|
|
3687
|
+
const [active, setActive] = React36__namespace.default.useState(0);
|
|
3688
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
3689
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
3690
|
+
const controlRef = React36__namespace.default.useRef(null);
|
|
3691
|
+
const inputRef = React36__namespace.default.useRef(null);
|
|
3692
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
3693
|
+
const listRef = React36__namespace.default.useRef(null);
|
|
3694
|
+
const activeRef = React36__namespace.default.useRef(null);
|
|
3695
|
+
const fGroups = React36__namespace.default.useMemo(
|
|
3482
3696
|
() => groups.map((g) => ({ group: g.group, options: g.options.filter((o) => matches2(o, query.trim())) })).filter((g) => g.options.length),
|
|
3483
3697
|
[groups, query]
|
|
3484
3698
|
);
|
|
3485
|
-
const visible =
|
|
3699
|
+
const visible = React36__namespace.default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
3486
3700
|
const capReached = max != null && (value !== void 0 ? value : internal).length >= max;
|
|
3487
3701
|
const isOptDisabled = (o) => o.disabled || capReached && !(value !== void 0 ? value : internal).includes(o.value);
|
|
3488
3702
|
const nextEnabled = (from, dir) => {
|
|
@@ -3493,7 +3707,7 @@ function MultiSelect({
|
|
|
3493
3707
|
}
|
|
3494
3708
|
return from;
|
|
3495
3709
|
};
|
|
3496
|
-
const place =
|
|
3710
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
3497
3711
|
const el = controlRef.current;
|
|
3498
3712
|
if (!el) return;
|
|
3499
3713
|
const r = el.getBoundingClientRect();
|
|
@@ -3508,7 +3722,7 @@ function MultiSelect({
|
|
|
3508
3722
|
flip
|
|
3509
3723
|
});
|
|
3510
3724
|
}, [placement, minWidth]);
|
|
3511
|
-
|
|
3725
|
+
React36__namespace.default.useEffect(() => {
|
|
3512
3726
|
if (!open || !portal) return;
|
|
3513
3727
|
place();
|
|
3514
3728
|
const onMove = () => place();
|
|
@@ -3519,7 +3733,7 @@ function MultiSelect({
|
|
|
3519
3733
|
window.removeEventListener("resize", onMove);
|
|
3520
3734
|
};
|
|
3521
3735
|
}, [open, portal, place]);
|
|
3522
|
-
|
|
3736
|
+
React36__namespace.default.useEffect(() => {
|
|
3523
3737
|
if (!open) return;
|
|
3524
3738
|
const onDown = (e) => {
|
|
3525
3739
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -3530,10 +3744,10 @@ function MultiSelect({
|
|
|
3530
3744
|
document.addEventListener("mousedown", onDown);
|
|
3531
3745
|
return () => document.removeEventListener("mousedown", onDown);
|
|
3532
3746
|
}, [open]);
|
|
3533
|
-
|
|
3747
|
+
React36__namespace.default.useEffect(() => {
|
|
3534
3748
|
setActive(0);
|
|
3535
3749
|
}, [query]);
|
|
3536
|
-
|
|
3750
|
+
React36__namespace.default.useEffect(() => {
|
|
3537
3751
|
if (open) ensureVisible3(listRef.current, activeRef.current);
|
|
3538
3752
|
}, [active, open]);
|
|
3539
3753
|
function commit(next) {
|
|
@@ -3576,7 +3790,7 @@ function MultiSelect({
|
|
|
3576
3790
|
const popInner = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__list", id: listboxId, ref: listRef, role: "listbox", "aria-multiselectable": "true", children: loading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-pop__loading", role: "status", children: [
|
|
3577
3791
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-pop__spinner", "aria-hidden": "true" }),
|
|
3578
3792
|
"Loading\u2026"
|
|
3579
|
-
] }) : visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: emptyText }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3793
|
+
] }) : visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__empty", children: emptyText }) : fGroups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React36__namespace.default.Fragment, { children: [
|
|
3580
3794
|
g.group ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-pop__group", children: g.group }) : null,
|
|
3581
3795
|
g.options.map((o) => {
|
|
3582
3796
|
counter += 1;
|
|
@@ -3806,7 +4020,7 @@ function Pagination({
|
|
|
3806
4020
|
}
|
|
3807
4021
|
const jumperEnabled = showPageJumper ?? showJumper;
|
|
3808
4022
|
const __twcStyles = useScopedStyles("twc-pagination-styles", PAGINATION_CSS);
|
|
3809
|
-
const [internal, setInternal] =
|
|
4023
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultPage);
|
|
3810
4024
|
const page = pageProp !== void 0 ? pageProp : internal;
|
|
3811
4025
|
const pages = buildPages(page, total, siblings, boundaries);
|
|
3812
4026
|
const go = (p) => {
|
|
@@ -3814,7 +4028,7 @@ function Pagination({
|
|
|
3814
4028
|
if (pageProp === void 0) setInternal(p);
|
|
3815
4029
|
onChange?.(p);
|
|
3816
4030
|
};
|
|
3817
|
-
const [jump, setJump] =
|
|
4031
|
+
const [jump, setJump] = React36__namespace.default.useState("");
|
|
3818
4032
|
const submitJump = () => {
|
|
3819
4033
|
const n = parseInt(jump, 10);
|
|
3820
4034
|
if (!Number.isNaN(n)) go(Math.min(Math.max(n, 1), total));
|
|
@@ -3897,13 +4111,13 @@ function Tooltip({
|
|
|
3897
4111
|
...rest
|
|
3898
4112
|
}) {
|
|
3899
4113
|
const __twcStyles = useScopedStyles("twc-tooltip-styles", TOOLTIP_CSS);
|
|
3900
|
-
const id =
|
|
3901
|
-
const [show, setShow] =
|
|
3902
|
-
const [coords, setCoords] =
|
|
3903
|
-
const timer =
|
|
3904
|
-
const closeTimer =
|
|
3905
|
-
const wrapRef =
|
|
3906
|
-
const tipRef =
|
|
4114
|
+
const id = React36__namespace.default.useId();
|
|
4115
|
+
const [show, setShow] = React36__namespace.default.useState(false);
|
|
4116
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
4117
|
+
const timer = React36__namespace.default.useRef(null);
|
|
4118
|
+
const closeTimer = React36__namespace.default.useRef(null);
|
|
4119
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
4120
|
+
const tipRef = React36__namespace.default.useRef(null);
|
|
3907
4121
|
const open = () => {
|
|
3908
4122
|
clearTimeout(closeTimer.current);
|
|
3909
4123
|
clearTimeout(timer.current);
|
|
@@ -3917,11 +4131,11 @@ function Tooltip({
|
|
|
3917
4131
|
const cancelClose = () => {
|
|
3918
4132
|
clearTimeout(closeTimer.current);
|
|
3919
4133
|
};
|
|
3920
|
-
|
|
4134
|
+
React36__namespace.default.useEffect(() => () => {
|
|
3921
4135
|
clearTimeout(timer.current);
|
|
3922
4136
|
clearTimeout(closeTimer.current);
|
|
3923
4137
|
}, []);
|
|
3924
|
-
const place =
|
|
4138
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
3925
4139
|
const el = wrapRef.current;
|
|
3926
4140
|
if (!el) return;
|
|
3927
4141
|
const r = el.getBoundingClientRect();
|
|
@@ -3944,10 +4158,10 @@ function Tooltip({
|
|
|
3944
4158
|
else if (side === "right") setCoords({ ...base, top: clampY(cy), left: Math.round(r.right + gap) });
|
|
3945
4159
|
else setCoords({ ...base, left: clampX(cx), bottom: Math.round(vh - r.top + gap) });
|
|
3946
4160
|
}, [placement]);
|
|
3947
|
-
|
|
4161
|
+
React36__namespace.default.useEffect(() => {
|
|
3948
4162
|
place();
|
|
3949
4163
|
}, [place]);
|
|
3950
|
-
|
|
4164
|
+
React36__namespace.default.useEffect(() => {
|
|
3951
4165
|
if (!show) return void 0;
|
|
3952
4166
|
place();
|
|
3953
4167
|
const onMove = () => place();
|
|
@@ -3958,7 +4172,7 @@ function Tooltip({
|
|
|
3958
4172
|
window.removeEventListener("resize", onMove);
|
|
3959
4173
|
};
|
|
3960
4174
|
}, [show, place]);
|
|
3961
|
-
|
|
4175
|
+
React36__namespace.default.useEffect(() => {
|
|
3962
4176
|
if (!show) return;
|
|
3963
4177
|
const onKeyDown = (e) => {
|
|
3964
4178
|
if (e.key === "Escape") {
|
|
@@ -3970,7 +4184,7 @@ function Tooltip({
|
|
|
3970
4184
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
3971
4185
|
}, [show]);
|
|
3972
4186
|
const describedBy = show ? id : void 0;
|
|
3973
|
-
const trigger =
|
|
4187
|
+
const trigger = React36__namespace.default.isValidElement(children) && children.type !== React36__namespace.default.Fragment ? React36__namespace.default.cloneElement(children, {
|
|
3974
4188
|
"aria-describedby": [children.props["aria-describedby"], describedBy].filter(Boolean).join(" ") || void 0
|
|
3975
4189
|
}) : /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-describedby": describedBy, children });
|
|
3976
4190
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -4574,9 +4788,9 @@ function runDatatableQuery(rows, query, options = {}) {
|
|
|
4574
4788
|
return { rows: page, total, filtered: out };
|
|
4575
4789
|
}
|
|
4576
4790
|
function useFloating() {
|
|
4577
|
-
const [pos, setPos] =
|
|
4578
|
-
const cfg =
|
|
4579
|
-
const place =
|
|
4791
|
+
const [pos, setPos] = React36__namespace.default.useState(null);
|
|
4792
|
+
const cfg = React36__namespace.default.useRef(null);
|
|
4793
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
4580
4794
|
const c = cfg.current;
|
|
4581
4795
|
if (!c || !c.el || !c.el.isConnected) return null;
|
|
4582
4796
|
const r = c.el.getBoundingClientRect();
|
|
@@ -4587,17 +4801,17 @@ function useFloating() {
|
|
|
4587
4801
|
const top = r.bottom + 6;
|
|
4588
4802
|
return { top, left, width: c.width, anchorX: r.left + r.width / 2, maxHeight: Math.max(180, vh - top - M) };
|
|
4589
4803
|
}, []);
|
|
4590
|
-
const open =
|
|
4804
|
+
const open = React36__namespace.default.useCallback((el, align = "left", width = 220) => {
|
|
4591
4805
|
cfg.current = { el, align, width };
|
|
4592
4806
|
const p = place();
|
|
4593
4807
|
if (p) setPos(p);
|
|
4594
4808
|
}, [place]);
|
|
4595
|
-
const close =
|
|
4809
|
+
const close = React36__namespace.default.useCallback(() => {
|
|
4596
4810
|
cfg.current = null;
|
|
4597
4811
|
setPos(null);
|
|
4598
4812
|
}, []);
|
|
4599
4813
|
const isOpen = pos != null;
|
|
4600
|
-
|
|
4814
|
+
React36__namespace.default.useEffect(() => {
|
|
4601
4815
|
if (!isOpen) return void 0;
|
|
4602
4816
|
const update = () => {
|
|
4603
4817
|
const p = place();
|
|
@@ -4621,9 +4835,9 @@ function Caret({ pos }) {
|
|
|
4621
4835
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-dt__caret", style: { left } });
|
|
4622
4836
|
}
|
|
4623
4837
|
function EditCell({ col, value, options, onChange, onCommit, onCommitValue, onCancel, onKeyDown }) {
|
|
4624
|
-
const ref =
|
|
4838
|
+
const ref = React36__namespace.default.useRef(null);
|
|
4625
4839
|
const isSelect = col.editType === "select" || options && col.editType !== "text";
|
|
4626
|
-
|
|
4840
|
+
React36__namespace.default.useEffect(() => {
|
|
4627
4841
|
if (isSelect) {
|
|
4628
4842
|
const t = setTimeout(() => ref.current?.querySelector(".twc-sel__trigger")?.click(), 0);
|
|
4629
4843
|
return () => clearTimeout(t);
|
|
@@ -4828,7 +5042,7 @@ function Datatable({
|
|
|
4828
5042
|
...rest
|
|
4829
5043
|
}) {
|
|
4830
5044
|
const __twcStyles = useScopedStyles("twc-dt-styles", DT_CSS);
|
|
4831
|
-
const cols =
|
|
5045
|
+
const cols = React36__namespace.default.useMemo(() => {
|
|
4832
5046
|
const out = columns.map((c) => {
|
|
4833
5047
|
const isActions = c.type === "actions";
|
|
4834
5048
|
return {
|
|
@@ -4863,7 +5077,7 @@ function Datatable({
|
|
|
4863
5077
|
}
|
|
4864
5078
|
return out;
|
|
4865
5079
|
}, [columns, rowPinning]);
|
|
4866
|
-
const _autoKey =
|
|
5080
|
+
const _autoKey = React36__namespace.default.useRef();
|
|
4867
5081
|
if (!_autoKey.current) _autoKey.current = { map: /* @__PURE__ */ new WeakMap(), n: 0 };
|
|
4868
5082
|
const keyOf = rowKey || ((r, i) => {
|
|
4869
5083
|
if (r != null && r.id != null) return r.id;
|
|
@@ -4878,17 +5092,17 @@ function Datatable({
|
|
|
4878
5092
|
}
|
|
4879
5093
|
return i;
|
|
4880
5094
|
});
|
|
4881
|
-
const [sort, setSort] =
|
|
4882
|
-
const [filters, setFilters] =
|
|
4883
|
-
const [hidden, setHidden] =
|
|
4884
|
-
const [showRowNum, setShowRowNum] =
|
|
4885
|
-
const [wrapped, setWrapped] =
|
|
5095
|
+
const [sort, setSort] = React36__namespace.default.useState(null);
|
|
5096
|
+
const [filters, setFilters] = React36__namespace.default.useState([]);
|
|
5097
|
+
const [hidden, setHidden] = React36__namespace.default.useState(() => /* @__PURE__ */ new Set());
|
|
5098
|
+
const [showRowNum, setShowRowNum] = React36__namespace.default.useState(rowNumbers);
|
|
5099
|
+
const [wrapped, setWrapped] = React36__namespace.default.useState(() => new Set((columns || []).filter((c) => c.wrapText).map((c) => c.field)));
|
|
4886
5100
|
const toggleWrap = (field) => setWrapped((w) => {
|
|
4887
5101
|
const n = new Set(w);
|
|
4888
5102
|
n.has(field) ? n.delete(field) : n.add(field);
|
|
4889
5103
|
return n;
|
|
4890
5104
|
});
|
|
4891
|
-
const [pins, setPins] =
|
|
5105
|
+
const [pins, setPins] = React36__namespace.default.useState(() => {
|
|
4892
5106
|
const left = [], right = [];
|
|
4893
5107
|
columns.forEach((c) => {
|
|
4894
5108
|
if (c.pinned === "left") left.push(c.field);
|
|
@@ -4896,34 +5110,34 @@ function Datatable({
|
|
|
4896
5110
|
});
|
|
4897
5111
|
return { left, right };
|
|
4898
5112
|
});
|
|
4899
|
-
const [density, setDensity] =
|
|
4900
|
-
const [quick, setQuick] =
|
|
4901
|
-
const [selected, setSelected] =
|
|
4902
|
-
const [activeRow, setActiveRow] =
|
|
4903
|
-
const [activeCell, setActiveCell] =
|
|
4904
|
-
const [page, setPage] =
|
|
4905
|
-
const [rowsPerPage, setRowsPerPage] =
|
|
4906
|
-
const [colQuery, setColQuery] =
|
|
4907
|
-
const [widths, setWidths] =
|
|
4908
|
-
const [order, setOrder] =
|
|
4909
|
-
const [drag, setDrag] =
|
|
4910
|
-
const [aggOn, setAggOn] =
|
|
4911
|
-
const [focus, setFocus] =
|
|
4912
|
-
const gridRef =
|
|
4913
|
-
const [groupBy, setGroupBy] =
|
|
4914
|
-
const [collapsed, setCollapsed] =
|
|
4915
|
-
const [pinnedRows, setPinnedRows] =
|
|
4916
|
-
const [headH, setHeadH] =
|
|
4917
|
-
const theadRef =
|
|
4918
|
-
const [rowOrder, setRowOrder] =
|
|
4919
|
-
const [rowHeights, setRowHeights] =
|
|
4920
|
-
const [rowDrag, setRowDrag] =
|
|
4921
|
-
const [rowGrab, setRowGrab] =
|
|
4922
|
-
const [reorderMsg, setReorderMsg] =
|
|
4923
|
-
const rowFocusRef =
|
|
4924
|
-
const rootRef =
|
|
4925
|
-
const [compact, setCompact] =
|
|
4926
|
-
|
|
5113
|
+
const [density, setDensity] = React36__namespace.default.useState(densityProp);
|
|
5114
|
+
const [quick, setQuick] = React36__namespace.default.useState("");
|
|
5115
|
+
const [selected, setSelected] = React36__namespace.default.useState(() => /* @__PURE__ */ new Set());
|
|
5116
|
+
const [activeRow, setActiveRow] = React36__namespace.default.useState(null);
|
|
5117
|
+
const [activeCell, setActiveCell] = React36__namespace.default.useState(null);
|
|
5118
|
+
const [page, setPage] = React36__namespace.default.useState(0);
|
|
5119
|
+
const [rowsPerPage, setRowsPerPage] = React36__namespace.default.useState(pageSize > 0 ? pageSize : 10);
|
|
5120
|
+
const [colQuery, setColQuery] = React36__namespace.default.useState("");
|
|
5121
|
+
const [widths, setWidths] = React36__namespace.default.useState({});
|
|
5122
|
+
const [order, setOrder] = React36__namespace.default.useState(() => columns.map((c) => c.field));
|
|
5123
|
+
const [drag, setDrag] = React36__namespace.default.useState({ from: null, over: null, after: false });
|
|
5124
|
+
const [aggOn, setAggOn] = React36__namespace.default.useState(showAggregation);
|
|
5125
|
+
const [focus, setFocus] = React36__namespace.default.useState({ r: 0, c: 0 });
|
|
5126
|
+
const gridRef = React36__namespace.default.useRef(null);
|
|
5127
|
+
const [groupBy, setGroupBy] = React36__namespace.default.useState(rowGrouping || []);
|
|
5128
|
+
const [collapsed, setCollapsed] = React36__namespace.default.useState(() => /* @__PURE__ */ new Set());
|
|
5129
|
+
const [pinnedRows, setPinnedRows] = React36__namespace.default.useState({ top: [], bottom: [] });
|
|
5130
|
+
const [headH, setHeadH] = React36__namespace.default.useState(41);
|
|
5131
|
+
const theadRef = React36__namespace.default.useRef(null);
|
|
5132
|
+
const [rowOrder, setRowOrder] = React36__namespace.default.useState(null);
|
|
5133
|
+
const [rowHeights, setRowHeights] = React36__namespace.default.useState({});
|
|
5134
|
+
const [rowDrag, setRowDrag] = React36__namespace.default.useState({ from: null, over: null, after: false });
|
|
5135
|
+
const [rowGrab, setRowGrab] = React36__namespace.default.useState(null);
|
|
5136
|
+
const [reorderMsg, setReorderMsg] = React36__namespace.default.useState("");
|
|
5137
|
+
const rowFocusRef = React36__namespace.default.useRef(null);
|
|
5138
|
+
const rootRef = React36__namespace.default.useRef(null);
|
|
5139
|
+
const [compact, setCompact] = React36__namespace.default.useState(false);
|
|
5140
|
+
React36__namespace.default.useEffect(() => {
|
|
4927
5141
|
const el = rootRef.current;
|
|
4928
5142
|
if (!el) return void 0;
|
|
4929
5143
|
const measure = () => setCompact((el.clientWidth || 0) < 720);
|
|
@@ -4936,11 +5150,11 @@ function Datatable({
|
|
|
4936
5150
|
else if (typeof window !== "undefined") window.removeEventListener("resize", measure);
|
|
4937
5151
|
};
|
|
4938
5152
|
}, []);
|
|
4939
|
-
const scrollRef =
|
|
4940
|
-
const [scrollTop, setScrollTop] =
|
|
4941
|
-
const [viewportH, setViewportH] =
|
|
4942
|
-
const [pivotOn, setPivotOn] =
|
|
4943
|
-
const [aggConfig, setAggConfig] =
|
|
5153
|
+
const scrollRef = React36__namespace.default.useRef(null);
|
|
5154
|
+
const [scrollTop, setScrollTop] = React36__namespace.default.useState(0);
|
|
5155
|
+
const [viewportH, setViewportH] = React36__namespace.default.useState(0);
|
|
5156
|
+
const [pivotOn, setPivotOn] = React36__namespace.default.useState(pivotMode);
|
|
5157
|
+
const [aggConfig, setAggConfig] = React36__namespace.default.useState(() => {
|
|
4944
5158
|
const m = {};
|
|
4945
5159
|
(columns || []).forEach((c) => {
|
|
4946
5160
|
if (typeof c.aggregation === "string") m[c.field] = c.aggregation;
|
|
@@ -4948,13 +5162,13 @@ function Datatable({
|
|
|
4948
5162
|
return m;
|
|
4949
5163
|
});
|
|
4950
5164
|
const aggOf = (c) => aggConfig[c.field] || (typeof c.aggregation === "function" ? c.aggregation : null);
|
|
4951
|
-
const [pivotConfig, setPivotConfig] =
|
|
5165
|
+
const [pivotConfig, setPivotConfig] = React36__namespace.default.useState(() => ({
|
|
4952
5166
|
rows: pivot && pivot.rows || [],
|
|
4953
5167
|
columns: pivot && pivot.columns || [],
|
|
4954
5168
|
values: pivot && pivot.values || []
|
|
4955
5169
|
}));
|
|
4956
5170
|
const pivotActive = pivotOn && pivotConfig.rows.length > 0 && pivotConfig.values.length > 0;
|
|
4957
|
-
|
|
5171
|
+
React36__namespace.default.useEffect(() => {
|
|
4958
5172
|
setOrder((prev) => {
|
|
4959
5173
|
const fields = columns.map((c) => c.field);
|
|
4960
5174
|
const kept = prev.filter((f) => fields.includes(f));
|
|
@@ -4962,32 +5176,32 @@ function Datatable({
|
|
|
4962
5176
|
return [...kept, ...added];
|
|
4963
5177
|
});
|
|
4964
5178
|
}, [columns]);
|
|
4965
|
-
|
|
5179
|
+
React36__namespace.default.useEffect(() => {
|
|
4966
5180
|
setDensity(densityProp);
|
|
4967
5181
|
}, [densityProp]);
|
|
4968
|
-
|
|
5182
|
+
React36__namespace.default.useEffect(() => {
|
|
4969
5183
|
setAggOn(showAggregation);
|
|
4970
5184
|
}, [showAggregation]);
|
|
4971
5185
|
const rowGroupingKey = (rowGrouping || []).join("\0");
|
|
4972
|
-
const rowGroupingKeyRef =
|
|
4973
|
-
|
|
5186
|
+
const rowGroupingKeyRef = React36__namespace.default.useRef(rowGroupingKey);
|
|
5187
|
+
React36__namespace.default.useEffect(() => {
|
|
4974
5188
|
if (rowGroupingKeyRef.current === rowGroupingKey) return;
|
|
4975
5189
|
rowGroupingKeyRef.current = rowGroupingKey;
|
|
4976
5190
|
setGroupBy(rowGrouping || []);
|
|
4977
5191
|
}, [rowGroupingKey]);
|
|
4978
5192
|
const widthOf = (c) => widths[c.field] ?? c.width ?? 160;
|
|
4979
|
-
const [colMenu, setColMenu] =
|
|
5193
|
+
const [colMenu, setColMenu] = React36__namespace.default.useState(null);
|
|
4980
5194
|
const [menuPos, openMenu, closeMenu] = useFloating();
|
|
4981
|
-
const [panel, setPanel] =
|
|
5195
|
+
const [panel, setPanel] = React36__namespace.default.useState(null);
|
|
4982
5196
|
const [panelPos, openPanel, closePanel] = useFloating();
|
|
4983
|
-
const [rowMenu, setRowMenu] =
|
|
5197
|
+
const [rowMenu, setRowMenu] = React36__namespace.default.useState(null);
|
|
4984
5198
|
const [rowMenuPos, openRowMenu, closeRowMenu] = useFloating();
|
|
4985
|
-
const [exportOpen, setExportOpen] =
|
|
5199
|
+
const [exportOpen, setExportOpen] = React36__namespace.default.useState(false);
|
|
4986
5200
|
const [exportPos, openExport, closeExport] = useFloating();
|
|
4987
|
-
const menuTriggerRef =
|
|
4988
|
-
const colMenuRef =
|
|
4989
|
-
const rowMenuRef =
|
|
4990
|
-
const exportMenuRef =
|
|
5201
|
+
const menuTriggerRef = React36__namespace.default.useRef(null);
|
|
5202
|
+
const colMenuRef = React36__namespace.default.useRef(null);
|
|
5203
|
+
const rowMenuRef = React36__namespace.default.useRef(null);
|
|
5204
|
+
const exportMenuRef = React36__namespace.default.useRef(null);
|
|
4991
5205
|
function focusFirstItem(container) {
|
|
4992
5206
|
if (!container) return;
|
|
4993
5207
|
const first = container.querySelector('[role="menuitem"]:not([disabled])');
|
|
@@ -5026,16 +5240,16 @@ function Datatable({
|
|
|
5026
5240
|
restoreTriggerFocus();
|
|
5027
5241
|
}
|
|
5028
5242
|
}
|
|
5029
|
-
|
|
5243
|
+
React36__namespace.default.useEffect(() => {
|
|
5030
5244
|
if (colMenu) focusFirstItem(colMenuRef.current);
|
|
5031
5245
|
}, [colMenu]);
|
|
5032
|
-
|
|
5246
|
+
React36__namespace.default.useEffect(() => {
|
|
5033
5247
|
if (rowMenu) focusFirstItem(rowMenuRef.current);
|
|
5034
5248
|
}, [rowMenu]);
|
|
5035
|
-
|
|
5249
|
+
React36__namespace.default.useEffect(() => {
|
|
5036
5250
|
if (exportOpen) focusFirstItem(exportMenuRef.current);
|
|
5037
5251
|
}, [exportOpen]);
|
|
5038
|
-
|
|
5252
|
+
React36__namespace.default.useEffect(() => {
|
|
5039
5253
|
if (!colMenu && !panel && !rowMenu) return;
|
|
5040
5254
|
const closeAll = () => {
|
|
5041
5255
|
setColMenu(null);
|
|
@@ -5058,7 +5272,7 @@ function Datatable({
|
|
|
5058
5272
|
document.removeEventListener("keydown", onKey);
|
|
5059
5273
|
};
|
|
5060
5274
|
}, [colMenu, panel, rowMenu]);
|
|
5061
|
-
|
|
5275
|
+
React36__namespace.default.useEffect(() => {
|
|
5062
5276
|
if (!exportOpen) return;
|
|
5063
5277
|
const close = () => {
|
|
5064
5278
|
setExportOpen(false);
|
|
@@ -5077,9 +5291,9 @@ function Datatable({
|
|
|
5077
5291
|
document.removeEventListener("keydown", onKey);
|
|
5078
5292
|
};
|
|
5079
5293
|
}, [exportOpen]);
|
|
5080
|
-
const colByField =
|
|
5294
|
+
const colByField = React36__namespace.default.useMemo(() => Object.fromEntries(cols.map((c) => [c.field, c])), [cols]);
|
|
5081
5295
|
const visibleCols = cols.filter((c) => !hidden.has(c.field));
|
|
5082
|
-
const ordered =
|
|
5296
|
+
const ordered = React36__namespace.default.useMemo(() => {
|
|
5083
5297
|
const orderIdx = (f) => {
|
|
5084
5298
|
const i = order.indexOf(f);
|
|
5085
5299
|
return i === -1 ? 9999 : i;
|
|
@@ -5114,7 +5328,7 @@ function Datatable({
|
|
|
5114
5328
|
}
|
|
5115
5329
|
return {};
|
|
5116
5330
|
};
|
|
5117
|
-
const processed =
|
|
5331
|
+
const processed = React36__namespace.default.useMemo(() => {
|
|
5118
5332
|
if (serverMode) {
|
|
5119
5333
|
if (rowOrder) {
|
|
5120
5334
|
const idx = new Map(rowOrder.map((k, i) => [k, i]));
|
|
@@ -5153,10 +5367,10 @@ function Datatable({
|
|
|
5153
5367
|
const totalRows = serverMode ? serverTotal : processed.length;
|
|
5154
5368
|
const totalPages = paginated ? Math.max(1, Math.ceil(totalRows / rowsPerPage)) : 1;
|
|
5155
5369
|
const paged = !paginated || serverMode ? processed : processed.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage);
|
|
5156
|
-
|
|
5370
|
+
React36__namespace.default.useEffect(() => {
|
|
5157
5371
|
if (page > totalPages - 1) setPage(0);
|
|
5158
5372
|
}, [totalPages]);
|
|
5159
|
-
const activeGroupBy =
|
|
5373
|
+
const activeGroupBy = React36__namespace.default.useMemo(() => groupBy.filter((f) => colByField[f]), [groupBy, colByField]);
|
|
5160
5374
|
function subtotalText(rowsIn) {
|
|
5161
5375
|
const parts = [];
|
|
5162
5376
|
for (const c of ordered) {
|
|
@@ -5183,7 +5397,7 @@ function Datatable({
|
|
|
5183
5397
|
if (agg === "max") return Math.max(...nums);
|
|
5184
5398
|
return null;
|
|
5185
5399
|
}
|
|
5186
|
-
const displayItems =
|
|
5400
|
+
const displayItems = React36__namespace.default.useMemo(() => {
|
|
5187
5401
|
if (!activeGroupBy.length) return null;
|
|
5188
5402
|
const build = (rowsIn, depth, prefix) => {
|
|
5189
5403
|
if (depth >= activeGroupBy.length) return rowsIn.map((row) => ({ kind: "leaf", row }));
|
|
@@ -5225,7 +5439,7 @@ function Datatable({
|
|
|
5225
5439
|
return { top, bottom };
|
|
5226
5440
|
});
|
|
5227
5441
|
}
|
|
5228
|
-
|
|
5442
|
+
React36__namespace.default.useEffect(() => {
|
|
5229
5443
|
if (!rowPinning) return;
|
|
5230
5444
|
const measure = () => {
|
|
5231
5445
|
if (theadRef.current) setHeadH(theadRef.current.offsetHeight || 41);
|
|
@@ -5239,12 +5453,12 @@ function Datatable({
|
|
|
5239
5453
|
const pinnedTopRows = canPinRows ? pinnedRows.top.map((k) => leafRows.find((r, i) => keyOf(r, i) === k)).filter(Boolean) : [];
|
|
5240
5454
|
const pinnedBottomRows = canPinRows ? pinnedRows.bottom.map((k) => leafRows.find((r, i) => keyOf(r, i) === k)).filter(Boolean) : [];
|
|
5241
5455
|
const middleRows = canPinRows ? leafRows.filter((r, i) => !pinSideOf(keyOf(r, i))) : leafRows;
|
|
5242
|
-
const keyIndex =
|
|
5456
|
+
const keyIndex = React36__namespace.default.useMemo(() => {
|
|
5243
5457
|
const m = /* @__PURE__ */ new Map();
|
|
5244
5458
|
leafRows.forEach((r, i) => m.set(keyOf(r, i), i));
|
|
5245
5459
|
return m;
|
|
5246
5460
|
}, [leafRows]);
|
|
5247
|
-
const keyIndexMid =
|
|
5461
|
+
const keyIndexMid = React36__namespace.default.useMemo(() => {
|
|
5248
5462
|
const m = /* @__PURE__ */ new Map();
|
|
5249
5463
|
middleRows.forEach((r, i) => m.set(keyOf(r, keyIndex.get(keyOf(r)) ?? i), i));
|
|
5250
5464
|
return m;
|
|
@@ -5329,7 +5543,7 @@ function Datatable({
|
|
|
5329
5543
|
setReorderMsg("Reorder cancelled.");
|
|
5330
5544
|
}
|
|
5331
5545
|
}
|
|
5332
|
-
|
|
5546
|
+
React36__namespace.default.useEffect(() => {
|
|
5333
5547
|
if (rowFocusRef.current == null) return;
|
|
5334
5548
|
const key = rowFocusRef.current;
|
|
5335
5549
|
rowFocusRef.current = null;
|
|
@@ -5341,7 +5555,7 @@ function Datatable({
|
|
|
5341
5555
|
});
|
|
5342
5556
|
const estRowH = rowHeight ?? (density === "compact" ? 36 : density === "comfortable" ? 56 : 44);
|
|
5343
5557
|
const virtualizing = virtualized && !paginated && !activeGroupBy.length && !loading;
|
|
5344
|
-
|
|
5558
|
+
React36__namespace.default.useEffect(() => {
|
|
5345
5559
|
if (!virtualizing) return;
|
|
5346
5560
|
const el = scrollRef.current;
|
|
5347
5561
|
if (!el) return;
|
|
@@ -5351,13 +5565,13 @@ function Datatable({
|
|
|
5351
5565
|
if (ro) ro.observe(el);
|
|
5352
5566
|
return () => ro && ro.disconnect();
|
|
5353
5567
|
}, [virtualizing, height]);
|
|
5354
|
-
const onScrollVirtual =
|
|
5568
|
+
const onScrollVirtual = React36__namespace.default.useCallback((e) => {
|
|
5355
5569
|
setScrollTop(e.currentTarget.scrollTop);
|
|
5356
5570
|
}, []);
|
|
5357
5571
|
const vh = viewportH || (typeof height === "number" ? height : 440);
|
|
5358
|
-
const rowHRef =
|
|
5359
|
-
const [measureTick, setMeasureTick] =
|
|
5360
|
-
const offsets =
|
|
5572
|
+
const rowHRef = React36__namespace.default.useRef(/* @__PURE__ */ new Map());
|
|
5573
|
+
const [measureTick, setMeasureTick] = React36__namespace.default.useState(0);
|
|
5574
|
+
const offsets = React36__namespace.default.useMemo(() => {
|
|
5361
5575
|
if (!virtualizing) return null;
|
|
5362
5576
|
const total = middleRows.length;
|
|
5363
5577
|
const arr = new Float64Array(total + 1);
|
|
@@ -5367,7 +5581,7 @@ function Datatable({
|
|
|
5367
5581
|
}
|
|
5368
5582
|
return arr;
|
|
5369
5583
|
}, [virtualizing, middleRows, estRowH, measureTick]);
|
|
5370
|
-
const vWindow =
|
|
5584
|
+
const vWindow = React36__namespace.default.useMemo(() => {
|
|
5371
5585
|
if (!virtualizing || !offsets) return null;
|
|
5372
5586
|
const total = middleRows.length;
|
|
5373
5587
|
const totalH = offsets[total];
|
|
@@ -5396,7 +5610,7 @@ function Datatable({
|
|
|
5396
5610
|
if (start > end) start = end;
|
|
5397
5611
|
return { start, end, padTop: offsets[start], padBottom: Math.max(0, totalH - offsets[end]) };
|
|
5398
5612
|
}, [virtualizing, offsets, middleRows.length, vh, scrollTop, overscan]);
|
|
5399
|
-
|
|
5613
|
+
React36__namespace.default.useLayoutEffect(() => {
|
|
5400
5614
|
if (!virtualizing) return;
|
|
5401
5615
|
const el = scrollRef.current;
|
|
5402
5616
|
if (!el) return;
|
|
@@ -5411,9 +5625,9 @@ function Datatable({
|
|
|
5411
5625
|
}
|
|
5412
5626
|
if (changed) setMeasureTick((t) => t + 1);
|
|
5413
5627
|
});
|
|
5414
|
-
const onServerChangeRef =
|
|
5628
|
+
const onServerChangeRef = React36__namespace.default.useRef(onServerChange);
|
|
5415
5629
|
onServerChangeRef.current = onServerChange;
|
|
5416
|
-
|
|
5630
|
+
React36__namespace.default.useEffect(() => {
|
|
5417
5631
|
if (!serverMode) return;
|
|
5418
5632
|
const t = setTimeout(() => {
|
|
5419
5633
|
onServerChangeRef.current?.({
|
|
@@ -5448,7 +5662,7 @@ function Datatable({
|
|
|
5448
5662
|
return n;
|
|
5449
5663
|
});
|
|
5450
5664
|
}
|
|
5451
|
-
const movableMidFields =
|
|
5665
|
+
const movableMidFields = React36__namespace.default.useMemo(
|
|
5452
5666
|
() => ordered.filter((c) => !pins.left.includes(c.field) && !pins.right.includes(c.field) && c.reorderable !== false).map((c) => c.field),
|
|
5453
5667
|
[ordered, pins]
|
|
5454
5668
|
);
|
|
@@ -5479,7 +5693,7 @@ function Datatable({
|
|
|
5479
5693
|
}
|
|
5480
5694
|
return [...set].sort((a, b) => a.localeCompare(b)).map((v) => ({ value: v, label: v }));
|
|
5481
5695
|
}
|
|
5482
|
-
const [resizing, setResizing] =
|
|
5696
|
+
const [resizing, setResizing] = React36__namespace.default.useState(false);
|
|
5483
5697
|
function startResize(e, field) {
|
|
5484
5698
|
e.preventDefault();
|
|
5485
5699
|
e.stopPropagation();
|
|
@@ -5586,7 +5800,7 @@ function Datatable({
|
|
|
5586
5800
|
if (!agg) return null;
|
|
5587
5801
|
if (aggregationValues && col.field in aggregationValues) {
|
|
5588
5802
|
const pre = aggregationValues[col.field];
|
|
5589
|
-
if (pre && typeof pre === "object" && !
|
|
5803
|
+
if (pre && typeof pre === "object" && !React36__namespace.default.isValidElement(pre)) {
|
|
5590
5804
|
if (typeof agg === "string" && agg in pre) return pre[agg];
|
|
5591
5805
|
} else {
|
|
5592
5806
|
return pre;
|
|
@@ -5704,14 +5918,14 @@ function Datatable({
|
|
|
5704
5918
|
focusCell(r, c);
|
|
5705
5919
|
}
|
|
5706
5920
|
}
|
|
5707
|
-
|
|
5921
|
+
React36__namespace.default.useEffect(() => {
|
|
5708
5922
|
setFocus((f) => ({ r: Math.min(f.r, Math.max(0, leafRows.length - 1)), c: Math.min(f.c, Math.max(0, ordered.length - 1)) }));
|
|
5709
5923
|
}, [leafRows.length, ordered.length, page]);
|
|
5710
|
-
const selectedRows =
|
|
5924
|
+
const selectedRows = React36__namespace.default.useMemo(() => rows.filter((r, i) => selected.has(keyOf(r, i))), [rows, selected]);
|
|
5711
5925
|
function clearSelection() {
|
|
5712
5926
|
setSelected(/* @__PURE__ */ new Set());
|
|
5713
5927
|
}
|
|
5714
|
-
const [editing, setEditing] =
|
|
5928
|
+
const [editing, setEditing] = React36__namespace.default.useState(null);
|
|
5715
5929
|
const isColEditable = (c) => c.type !== "actions" && (c.editable ?? (editMode && c.editable !== false));
|
|
5716
5930
|
function beginEdit(rowK, col, row) {
|
|
5717
5931
|
if (!isColEditable(col)) return;
|
|
@@ -5746,17 +5960,17 @@ function Datatable({
|
|
|
5746
5960
|
cancelEdit();
|
|
5747
5961
|
}
|
|
5748
5962
|
}
|
|
5749
|
-
const batchEditableCols =
|
|
5963
|
+
const batchEditableCols = React36__namespace.default.useMemo(
|
|
5750
5964
|
() => cols.filter((c) => c.type !== "actions" && (c.editable ?? (editMode && c.editable !== false))),
|
|
5751
5965
|
[cols, editMode]
|
|
5752
5966
|
);
|
|
5753
|
-
const [batchEdit, setBatchEdit] =
|
|
5967
|
+
const [batchEdit, setBatchEdit] = React36__namespace.default.useState(null);
|
|
5754
5968
|
const [batchEditPos, openBatchEdit, closeBatchEdit] = useFloating();
|
|
5755
5969
|
function openBatchEditor(el) {
|
|
5756
5970
|
setBatchEdit({ fields: {}, values: {} });
|
|
5757
5971
|
openBatchEdit(el, "left", 320);
|
|
5758
5972
|
}
|
|
5759
|
-
|
|
5973
|
+
React36__namespace.default.useEffect(() => {
|
|
5760
5974
|
if (!batchEdit) return;
|
|
5761
5975
|
const close = () => {
|
|
5762
5976
|
setBatchEdit(null);
|
|
@@ -5775,7 +5989,7 @@ function Datatable({
|
|
|
5775
5989
|
document.removeEventListener("keydown", onKey);
|
|
5776
5990
|
};
|
|
5777
5991
|
}, [batchEdit]);
|
|
5778
|
-
|
|
5992
|
+
React36__namespace.default.useEffect(() => {
|
|
5779
5993
|
if (batchEdit && selected.size === 0) {
|
|
5780
5994
|
setBatchEdit(null);
|
|
5781
5995
|
closeBatchEdit();
|
|
@@ -5812,7 +6026,7 @@ function Datatable({
|
|
|
5812
6026
|
setBatchEdit(null);
|
|
5813
6027
|
closeBatchEdit();
|
|
5814
6028
|
}
|
|
5815
|
-
|
|
6029
|
+
React36__namespace.default.useEffect(() => {
|
|
5816
6030
|
if (!editing) return;
|
|
5817
6031
|
const onDown = (e) => {
|
|
5818
6032
|
if (e.target.closest(".twc-dt__editor-wrap") || e.target.closest(".twc-pop")) return;
|
|
@@ -7335,23 +7549,24 @@ function DatePicker({
|
|
|
7335
7549
|
}) {
|
|
7336
7550
|
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS3);
|
|
7337
7551
|
const __twcStyles1 = useScopedStyles("twc-datepicker-styles", DATEPICKER_CSS);
|
|
7338
|
-
const autoId =
|
|
7552
|
+
const autoId = React36__namespace.default.useId();
|
|
7339
7553
|
const fieldId = id || autoId;
|
|
7340
7554
|
const descId = `${fieldId}-desc`;
|
|
7341
7555
|
const invalid = Boolean(error);
|
|
7342
|
-
const [internal, setInternal] =
|
|
7556
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
7343
7557
|
const selected = value !== void 0 ? value : internal;
|
|
7344
|
-
const [open, setOpen] =
|
|
7345
|
-
const [view, setView] =
|
|
7346
|
-
const [mode, setMode] =
|
|
7347
|
-
const [focusDate, setFocusDate] =
|
|
7348
|
-
const [
|
|
7349
|
-
const
|
|
7350
|
-
const
|
|
7351
|
-
const
|
|
7352
|
-
const
|
|
7558
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
7559
|
+
const [view, setView] = React36__namespace.default.useState(selected || /* @__PURE__ */ new Date());
|
|
7560
|
+
const [mode, setMode] = React36__namespace.default.useState("days");
|
|
7561
|
+
const [focusDate, setFocusDate] = React36__namespace.default.useState(null);
|
|
7562
|
+
const [focusMonth, setFocusMonth] = React36__namespace.default.useState(null);
|
|
7563
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
7564
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
7565
|
+
const triggerRef = React36__namespace.default.useRef(null);
|
|
7566
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
7567
|
+
const gridRef = React36__namespace.default.useRef(null);
|
|
7353
7568
|
const POP_W = 280;
|
|
7354
|
-
const place =
|
|
7569
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
7355
7570
|
const el = triggerRef.current;
|
|
7356
7571
|
if (!el) return;
|
|
7357
7572
|
const r = el.getBoundingClientRect();
|
|
@@ -7362,7 +7577,7 @@ function DatePicker({
|
|
|
7362
7577
|
left = Math.max(8, left);
|
|
7363
7578
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
7364
7579
|
}, []);
|
|
7365
|
-
|
|
7580
|
+
React36__namespace.default.useEffect(() => {
|
|
7366
7581
|
if (!open) return void 0;
|
|
7367
7582
|
place();
|
|
7368
7583
|
const onMove = () => place();
|
|
@@ -7373,7 +7588,7 @@ function DatePicker({
|
|
|
7373
7588
|
window.removeEventListener("resize", onMove);
|
|
7374
7589
|
};
|
|
7375
7590
|
}, [open, place]);
|
|
7376
|
-
|
|
7591
|
+
React36__namespace.default.useEffect(() => {
|
|
7377
7592
|
if (!open) return;
|
|
7378
7593
|
setView(selected || /* @__PURE__ */ new Date());
|
|
7379
7594
|
setMode("days");
|
|
@@ -7393,21 +7608,10 @@ function DatePicker({
|
|
|
7393
7608
|
document.removeEventListener("keydown", onKey);
|
|
7394
7609
|
};
|
|
7395
7610
|
}, [open]);
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
id2 = setTimeout(() => gridRef.current?.querySelector('[tabindex="0"]')?.focus({ preventScroll: true }), 30);
|
|
7401
|
-
} else if (prevOpen.current && !open) {
|
|
7402
|
-
const ae = typeof document !== "undefined" ? document.activeElement : null;
|
|
7403
|
-
if (!ae || ae === document.body) triggerRef.current?.focus();
|
|
7404
|
-
}
|
|
7405
|
-
prevOpen.current = open;
|
|
7406
|
-
return () => clearTimeout(id2);
|
|
7407
|
-
}, [open]);
|
|
7408
|
-
const months = React25__namespace.default.useMemo(() => locale === void 0 ? MONTHS : monthNames(locale), [locale]);
|
|
7409
|
-
const monthsShort = React25__namespace.default.useMemo(() => locale === void 0 ? MONTHS.map((n) => n.slice(0, 3)) : monthShortNames(locale), [locale]);
|
|
7410
|
-
const dows = React25__namespace.default.useMemo(
|
|
7611
|
+
useFocusTrap(popRef, open && !!coords, { initialFocus: () => gridRef.current?.querySelector('[tabindex="0"]') });
|
|
7612
|
+
const months = React36__namespace.default.useMemo(() => locale === void 0 ? MONTHS : monthNames(locale), [locale]);
|
|
7613
|
+
const monthsShort = React36__namespace.default.useMemo(() => locale === void 0 ? MONTHS.map((n) => n.slice(0, 3)) : monthShortNames(locale), [locale]);
|
|
7614
|
+
const dows = React36__namespace.default.useMemo(
|
|
7411
7615
|
() => locale === void 0 ? Array.from({ length: 7 }, (_, i) => DOW[(i + weekStartsOn) % 7]) : weekdayNames(locale, weekStartsOn),
|
|
7412
7616
|
[locale, weekStartsOn]
|
|
7413
7617
|
);
|
|
@@ -7435,10 +7639,34 @@ function DatePicker({
|
|
|
7435
7639
|
};
|
|
7436
7640
|
const cells = Array.from({ length: 42 }, (_, i) => new Date(gridStart.getFullYear(), gridStart.getMonth(), gridStart.getDate() + i));
|
|
7437
7641
|
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);
|
|
7438
|
-
|
|
7642
|
+
React36__namespace.default.useEffect(() => {
|
|
7439
7643
|
if (!open || mode !== "days" || !focusDate) return;
|
|
7440
7644
|
gridRef.current?.querySelector(`[data-key="${keyOf(focusDate)}"]`)?.focus();
|
|
7441
7645
|
}, [focusDate, open, mode]);
|
|
7646
|
+
React36__namespace.default.useEffect(() => {
|
|
7647
|
+
if (!open || mode !== "months" || focusMonth == null) return;
|
|
7648
|
+
gridRef.current?.querySelector(`[data-mo="${focusMonth}"]`)?.focus();
|
|
7649
|
+
}, [focusMonth, open, mode]);
|
|
7650
|
+
const onMonthsKeyDown = (e) => {
|
|
7651
|
+
const cur = focusMonth == null ? m : focusMonth;
|
|
7652
|
+
let next;
|
|
7653
|
+
if (e.key === "ArrowRight") next = cur + 1;
|
|
7654
|
+
else if (e.key === "ArrowLeft") next = cur - 1;
|
|
7655
|
+
else if (e.key === "ArrowDown") next = cur + 3;
|
|
7656
|
+
else if (e.key === "ArrowUp") next = cur - 3;
|
|
7657
|
+
else if (e.key === "Home") next = 0;
|
|
7658
|
+
else if (e.key === "End") next = 11;
|
|
7659
|
+
else return;
|
|
7660
|
+
e.preventDefault();
|
|
7661
|
+
if (next < 0) {
|
|
7662
|
+
setView(new Date(y - 1, 0, 1));
|
|
7663
|
+
next += 12;
|
|
7664
|
+
} else if (next > 11) {
|
|
7665
|
+
setView(new Date(y + 1, 0, 1));
|
|
7666
|
+
next -= 12;
|
|
7667
|
+
}
|
|
7668
|
+
setFocusMonth(next);
|
|
7669
|
+
};
|
|
7442
7670
|
const onGridKeyDown = (e) => {
|
|
7443
7671
|
const btn = e.target.closest?.("[data-key]");
|
|
7444
7672
|
if (!btn) return;
|
|
@@ -7519,12 +7747,16 @@ function DatePicker({
|
|
|
7519
7747
|
className: "twc-dp__pop",
|
|
7520
7748
|
ref: popRef,
|
|
7521
7749
|
role: "dialog",
|
|
7750
|
+
"aria-modal": "true",
|
|
7522
7751
|
"aria-label": "Choose date",
|
|
7523
7752
|
style: { position: "fixed", left: coords.left, right: "auto", top: coords.top, bottom: coords.bottom, zIndex: "var(--z-tooltip)" },
|
|
7524
7753
|
children: [
|
|
7525
7754
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-dp__head", children: [
|
|
7526
7755
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-dp__nav", "aria-label": "Previous", onClick: () => setView(mode === "months" ? new Date(y - 1, m, 1) : new Date(y, m - 1, 1)), children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m15 18-6-6 6-6" }) }) }),
|
|
7527
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-dp__title", onClick: () =>
|
|
7756
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-dp__title", onClick: () => {
|
|
7757
|
+
if (mode === "days") setFocusMonth(m);
|
|
7758
|
+
setMode(mode === "days" ? "months" : "days");
|
|
7759
|
+
}, children: mode === "days" ? `${months[m]} ${y}` : y }),
|
|
7528
7760
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-dp__sr", "aria-live": "polite", children: mode === "days" ? `${months[m]} ${y}` : y }),
|
|
7529
7761
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-dp__nav", "aria-label": "Next", onClick: () => setView(mode === "months" ? new Date(y + 1, m, 1) : new Date(y, m + 1, 1)), children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m9 18 6-6-6-6" }) }) })
|
|
7530
7762
|
] }),
|
|
@@ -7552,11 +7784,14 @@ function DatePicker({
|
|
|
7552
7784
|
i
|
|
7553
7785
|
);
|
|
7554
7786
|
})
|
|
7555
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-dp__months", children: monthsShort.map((name, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7787
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-dp__months", ref: gridRef, onKeyDown: onMonthsKeyDown, role: "grid", children: monthsShort.map((name, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7556
7788
|
"button",
|
|
7557
7789
|
{
|
|
7558
7790
|
type: "button",
|
|
7559
7791
|
className: "twc-dp__mo",
|
|
7792
|
+
role: "gridcell",
|
|
7793
|
+
"data-mo": i,
|
|
7794
|
+
tabIndex: i === (focusMonth ?? m) ? 0 : -1,
|
|
7560
7795
|
"data-selected": selected && selected.getFullYear() === y && selected.getMonth() === i || void 0,
|
|
7561
7796
|
onClick: () => {
|
|
7562
7797
|
setView(new Date(y, i, 1));
|
|
@@ -7663,23 +7898,25 @@ function DateRangePicker({
|
|
|
7663
7898
|
}) {
|
|
7664
7899
|
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS4);
|
|
7665
7900
|
const __twcStyles1 = useScopedStyles("twc-drp-styles", RANGE_CSS);
|
|
7666
|
-
const [internal, setInternal] =
|
|
7901
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
7667
7902
|
const range = value !== void 0 ? value : internal;
|
|
7668
|
-
const [open, setOpen] =
|
|
7669
|
-
const [view, setView] =
|
|
7670
|
-
const [hover, setHover] =
|
|
7671
|
-
const [
|
|
7672
|
-
const
|
|
7673
|
-
const
|
|
7674
|
-
const
|
|
7675
|
-
const
|
|
7903
|
+
const [open, setOpen] = React36__namespace.default.useState(false);
|
|
7904
|
+
const [view, setView] = React36__namespace.default.useState(range.start || /* @__PURE__ */ new Date());
|
|
7905
|
+
const [hover, setHover] = React36__namespace.default.useState(null);
|
|
7906
|
+
const [focusDate, setFocusDate] = React36__namespace.default.useState(null);
|
|
7907
|
+
const [coords, setCoords] = React36__namespace.default.useState(null);
|
|
7908
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
7909
|
+
const triggerRef = React36__namespace.default.useRef(null);
|
|
7910
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
7911
|
+
const gridRef = React36__namespace.default.useRef(null);
|
|
7912
|
+
const labelId = React36__namespace.default.useId();
|
|
7676
7913
|
const descId = `${labelId}-desc`;
|
|
7677
7914
|
const invalid = Boolean(error);
|
|
7678
|
-
|
|
7915
|
+
React36__namespace.default.useEffect(() => {
|
|
7679
7916
|
if (disabled) setOpen(false);
|
|
7680
7917
|
}, [disabled]);
|
|
7681
7918
|
const POP_W = 420;
|
|
7682
|
-
const place =
|
|
7919
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
7683
7920
|
const el = triggerRef.current;
|
|
7684
7921
|
if (!el) return;
|
|
7685
7922
|
const r = el.getBoundingClientRect();
|
|
@@ -7690,7 +7927,7 @@ function DateRangePicker({
|
|
|
7690
7927
|
left = Math.max(8, left);
|
|
7691
7928
|
setCoords({ left, top: flip ? void 0 : Math.round(r.bottom + 6), bottom: flip ? Math.round(vh - r.top + 6) : void 0 });
|
|
7692
7929
|
}, []);
|
|
7693
|
-
|
|
7930
|
+
React36__namespace.default.useEffect(() => {
|
|
7694
7931
|
if (!open) return void 0;
|
|
7695
7932
|
place();
|
|
7696
7933
|
const onMove = () => place();
|
|
@@ -7701,7 +7938,7 @@ function DateRangePicker({
|
|
|
7701
7938
|
window.removeEventListener("resize", onMove);
|
|
7702
7939
|
};
|
|
7703
7940
|
}, [open, place]);
|
|
7704
|
-
|
|
7941
|
+
React36__namespace.default.useEffect(() => {
|
|
7705
7942
|
if (!open) return;
|
|
7706
7943
|
const onDown = (e) => {
|
|
7707
7944
|
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
@@ -7722,7 +7959,52 @@ function DateRangePicker({
|
|
|
7722
7959
|
if (value === void 0) setInternal(r);
|
|
7723
7960
|
onChange?.(r);
|
|
7724
7961
|
};
|
|
7962
|
+
useFocusTrap(popRef, open && !!coords, { initialFocus: () => gridRef.current?.querySelector('[tabindex="0"]') });
|
|
7725
7963
|
const outOfRange = (d) => min && ymd(d) < ymd(min) || max && ymd(d) > ymd(max) || Boolean(disabledDate && disabledDate(d));
|
|
7964
|
+
const sameDay2 = (a, b) => a && b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
7965
|
+
const keyOf = (d) => `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
|
|
7966
|
+
const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
|
|
7967
|
+
const addMonths = (d, n) => {
|
|
7968
|
+
const last = new Date(d.getFullYear(), d.getMonth() + n + 1, 0);
|
|
7969
|
+
return new Date(last.getFullYear(), last.getMonth(), Math.min(d.getDate(), last.getDate()));
|
|
7970
|
+
};
|
|
7971
|
+
React36__namespace.default.useEffect(() => {
|
|
7972
|
+
if (!open) {
|
|
7973
|
+
setFocusDate(null);
|
|
7974
|
+
setHover(null);
|
|
7975
|
+
}
|
|
7976
|
+
}, [open]);
|
|
7977
|
+
React36__namespace.default.useEffect(() => {
|
|
7978
|
+
if (!open || !focusDate) return;
|
|
7979
|
+
gridRef.current?.querySelector(`[data-key="${keyOf(focusDate)}"]`)?.focus();
|
|
7980
|
+
}, [focusDate, open]);
|
|
7981
|
+
const onGridKeyDown = (e) => {
|
|
7982
|
+
const btn = e.target.closest && e.target.closest("[data-key]");
|
|
7983
|
+
if (!btn) return;
|
|
7984
|
+
const [fy, fm, fd] = btn.getAttribute("data-key").split("-").map(Number);
|
|
7985
|
+
const cur = new Date(fy, fm, fd);
|
|
7986
|
+
let step;
|
|
7987
|
+
if (e.key === "ArrowLeft") step = (d) => addDays(d, -1);
|
|
7988
|
+
else if (e.key === "ArrowRight") step = (d) => addDays(d, 1);
|
|
7989
|
+
else if (e.key === "ArrowUp") step = (d) => addDays(d, -7);
|
|
7990
|
+
else if (e.key === "ArrowDown") step = (d) => addDays(d, 7);
|
|
7991
|
+
else if (e.key === "Home") step = (d) => addDays(d, -((d.getDay() - weekStartsOn + 7) % 7));
|
|
7992
|
+
else if (e.key === "End") step = (d) => addDays(d, 6 - (d.getDay() - weekStartsOn + 7) % 7);
|
|
7993
|
+
else if (e.key === "PageUp") step = (d) => addMonths(d, -1);
|
|
7994
|
+
else if (e.key === "PageDown") step = (d) => addMonths(d, 1);
|
|
7995
|
+
else return;
|
|
7996
|
+
e.preventDefault();
|
|
7997
|
+
let next = step(cur), guard = 0;
|
|
7998
|
+
while (outOfRange(next) && guard < 366) {
|
|
7999
|
+
next = step(next);
|
|
8000
|
+
guard += 1;
|
|
8001
|
+
}
|
|
8002
|
+
if (outOfRange(next)) return;
|
|
8003
|
+
setFocusDate(next);
|
|
8004
|
+
setHover(next);
|
|
8005
|
+
if (next.getFullYear() !== view.getFullYear() || next.getMonth() !== view.getMonth()) setView(new Date(next.getFullYear(), next.getMonth(), 1));
|
|
8006
|
+
};
|
|
8007
|
+
const tabbableDate = focusDate || range.start || /* @__PURE__ */ new Date();
|
|
7726
8008
|
const clickDay = (d) => {
|
|
7727
8009
|
if (outOfRange(d)) return;
|
|
7728
8010
|
if (!range.start || range.start && range.end) {
|
|
@@ -7741,8 +8023,8 @@ function DateRangePicker({
|
|
|
7741
8023
|
setView(start);
|
|
7742
8024
|
setOpen(false);
|
|
7743
8025
|
};
|
|
7744
|
-
const months =
|
|
7745
|
-
const dows =
|
|
8026
|
+
const months = React36__namespace.default.useMemo(() => locale === void 0 ? MONTHS2 : monthNames2(locale), [locale]);
|
|
8027
|
+
const dows = React36__namespace.default.useMemo(
|
|
7746
8028
|
() => locale === void 0 ? Array.from({ length: 7 }, (_, i) => DOW2[(i + weekStartsOn) % 7]) : weekdayNames2(locale, weekStartsOn),
|
|
7747
8029
|
[locale, weekStartsOn]
|
|
7748
8030
|
);
|
|
@@ -7812,6 +8094,7 @@ function DateRangePicker({
|
|
|
7812
8094
|
className: "twc-drp__pop",
|
|
7813
8095
|
ref: popRef,
|
|
7814
8096
|
role: "dialog",
|
|
8097
|
+
"aria-modal": "true",
|
|
7815
8098
|
"aria-label": "Choose date range",
|
|
7816
8099
|
style: { position: "fixed", left: coords.left, right: "auto", top: coords.top, bottom: coords.bottom, zIndex: "var(--z-tooltip)" },
|
|
7817
8100
|
children: [
|
|
@@ -7831,7 +8114,7 @@ function DateRangePicker({
|
|
|
7831
8114
|
] }),
|
|
7832
8115
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-drp__nav", "aria-label": "Next month", onClick: () => setView(new Date(y, m + 1, 1)), children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m9 18 6-6-6-6" }) }) })
|
|
7833
8116
|
] }),
|
|
7834
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-drp__grid", children: [
|
|
8117
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-drp__grid", ref: gridRef, onKeyDown: onGridKeyDown, role: "grid", children: [
|
|
7835
8118
|
dows.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-drp__dow", children: d }, i)),
|
|
7836
8119
|
Array.from({ length: 42 }).map((_, i) => {
|
|
7837
8120
|
const d = new Date(gridStart.getFullYear(), gridStart.getMonth(), gridStart.getDate() + i);
|
|
@@ -7843,6 +8126,8 @@ function DateRangePicker({
|
|
|
7843
8126
|
className: "twc-drp__day",
|
|
7844
8127
|
"data-outside": outside || void 0,
|
|
7845
8128
|
disabled: outOfRange(d) || void 0,
|
|
8129
|
+
"data-key": keyOf(d),
|
|
8130
|
+
tabIndex: sameDay2(d, tabbableDate) ? 0 : -1,
|
|
7846
8131
|
"data-in": inRange(t) || void 0,
|
|
7847
8132
|
"data-edge": edgeOf(t) || void 0,
|
|
7848
8133
|
"aria-pressed": !!edgeOf(t),
|
|
@@ -7929,14 +8214,14 @@ function Dialog({
|
|
|
7929
8214
|
className = "",
|
|
7930
8215
|
...rest
|
|
7931
8216
|
}) {
|
|
7932
|
-
const autoId =
|
|
8217
|
+
const autoId = React36__namespace.default.useId();
|
|
7933
8218
|
const titleId = `${autoId}-title`;
|
|
7934
8219
|
const descId = `${autoId}-desc`;
|
|
7935
|
-
const dialogRef =
|
|
8220
|
+
const dialogRef = React36__namespace.default.useRef(null);
|
|
7936
8221
|
const __twcStyles = useScopedStyles("twc-dialog-styles", DIALOG_CSS);
|
|
7937
8222
|
const renderPortal = usePortal();
|
|
7938
|
-
const [mounted, setMounted] =
|
|
7939
|
-
|
|
8223
|
+
const [mounted, setMounted] = React36__namespace.default.useState(open);
|
|
8224
|
+
React36__namespace.default.useEffect(() => {
|
|
7940
8225
|
if (open) {
|
|
7941
8226
|
setMounted(true);
|
|
7942
8227
|
return;
|
|
@@ -7947,7 +8232,7 @@ function Dialog({
|
|
|
7947
8232
|
useScrollLock(open);
|
|
7948
8233
|
useInertBackground(dialogRef, open && mounted);
|
|
7949
8234
|
useFocusTrap(dialogRef, open && mounted);
|
|
7950
|
-
|
|
8235
|
+
React36__namespace.default.useEffect(() => {
|
|
7951
8236
|
if (!open) return void 0;
|
|
7952
8237
|
const onKey = (e) => {
|
|
7953
8238
|
if (e.key === "Escape") {
|
|
@@ -8094,14 +8379,14 @@ function Drawer({
|
|
|
8094
8379
|
style,
|
|
8095
8380
|
...rest
|
|
8096
8381
|
}) {
|
|
8097
|
-
const autoId =
|
|
8382
|
+
const autoId = React36__namespace.default.useId();
|
|
8098
8383
|
const titleId = `${autoId}-title`;
|
|
8099
8384
|
const descId = `${autoId}-desc`;
|
|
8100
|
-
const panelRef =
|
|
8385
|
+
const panelRef = React36__namespace.default.useRef(null);
|
|
8101
8386
|
const __twcStyles = useScopedStyles("twc-drawer-styles", DRAWER_CSS);
|
|
8102
8387
|
const renderPortal = usePortal();
|
|
8103
|
-
const [mounted, setMounted] =
|
|
8104
|
-
|
|
8388
|
+
const [mounted, setMounted] = React36__namespace.default.useState(open);
|
|
8389
|
+
React36__namespace.default.useEffect(() => {
|
|
8105
8390
|
if (open) {
|
|
8106
8391
|
setMounted(true);
|
|
8107
8392
|
return;
|
|
@@ -8112,7 +8397,7 @@ function Drawer({
|
|
|
8112
8397
|
useScrollLock(open);
|
|
8113
8398
|
useInertBackground(panelRef, open && mounted);
|
|
8114
8399
|
useFocusTrap(panelRef, open && mounted);
|
|
8115
|
-
|
|
8400
|
+
React36__namespace.default.useEffect(() => {
|
|
8116
8401
|
if (!open) return void 0;
|
|
8117
8402
|
const onKey = (e) => {
|
|
8118
8403
|
if (e.key === "Escape") {
|
|
@@ -8201,11 +8486,11 @@ function Field({
|
|
|
8201
8486
|
...rest
|
|
8202
8487
|
}) {
|
|
8203
8488
|
const __twcStyles = useScopedStyles("twc-field-styles", FIELD_CSS5);
|
|
8204
|
-
const autoId =
|
|
8489
|
+
const autoId = React36__namespace.default.useId();
|
|
8205
8490
|
const fieldId = id || autoId;
|
|
8206
8491
|
const descId = `${fieldId}-desc`;
|
|
8207
8492
|
const hasMsg = Boolean(error || hint);
|
|
8208
|
-
const control =
|
|
8493
|
+
const control = React36__namespace.default.isValidElement(children) ? React36__namespace.default.cloneElement(children, {
|
|
8209
8494
|
"aria-describedby": [children.props["aria-describedby"], hasMsg ? descId : null].filter(Boolean).join(" ") || void 0,
|
|
8210
8495
|
"aria-invalid": children.props["aria-invalid"] !== void 0 ? children.props["aria-invalid"] : error ? true : void 0
|
|
8211
8496
|
}) : children;
|
|
@@ -8297,11 +8582,11 @@ function FileUpload({
|
|
|
8297
8582
|
...rest
|
|
8298
8583
|
}) {
|
|
8299
8584
|
const __twcStyles = useScopedStyles("twc-upload-styles", UPLOAD_CSS);
|
|
8300
|
-
const [internal, setInternal] =
|
|
8585
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
8301
8586
|
const files = value !== void 0 ? value : internal;
|
|
8302
|
-
const [drag, setDrag] =
|
|
8303
|
-
const inputRef =
|
|
8304
|
-
const autoId =
|
|
8587
|
+
const [drag, setDrag] = React36__namespace.default.useState(false);
|
|
8588
|
+
const inputRef = React36__namespace.default.useRef(null);
|
|
8589
|
+
const autoId = React36__namespace.default.useId();
|
|
8305
8590
|
const fieldId = id || autoId;
|
|
8306
8591
|
const descId = `${fieldId}-desc`;
|
|
8307
8592
|
const invalid = Boolean(error);
|
|
@@ -8524,15 +8809,15 @@ function Kanban({
|
|
|
8524
8809
|
...rest
|
|
8525
8810
|
}) {
|
|
8526
8811
|
const __twcStyles = useScopedStyles("twc-kanban-styles", KANBAN_CSS);
|
|
8527
|
-
const [internal, setInternal] =
|
|
8812
|
+
const [internal, setInternal] = React36__namespace.default.useState(cards ?? defaultCards ?? []);
|
|
8528
8813
|
const items = cards !== void 0 ? cards : internal;
|
|
8529
|
-
const [drag, setDrag] =
|
|
8530
|
-
const [overCol, setOverCol] =
|
|
8531
|
-
const [grab, setGrab] =
|
|
8532
|
-
const [announce, setAnnounce] =
|
|
8533
|
-
const rootRef =
|
|
8534
|
-
const focusIdRef =
|
|
8535
|
-
|
|
8814
|
+
const [drag, setDrag] = React36__namespace.default.useState(null);
|
|
8815
|
+
const [overCol, setOverCol] = React36__namespace.default.useState(null);
|
|
8816
|
+
const [grab, setGrab] = React36__namespace.default.useState(null);
|
|
8817
|
+
const [announce, setAnnounce] = React36__namespace.default.useState("");
|
|
8818
|
+
const rootRef = React36__namespace.default.useRef(null);
|
|
8819
|
+
const focusIdRef = React36__namespace.default.useRef(null);
|
|
8820
|
+
React36__namespace.default.useEffect(() => {
|
|
8536
8821
|
if (focusIdRef.current == null) return void 0;
|
|
8537
8822
|
const raf = requestAnimationFrame(() => {
|
|
8538
8823
|
const id = focusIdRef.current;
|
|
@@ -8681,7 +8966,7 @@ var LIST_CSS = `
|
|
|
8681
8966
|
`;
|
|
8682
8967
|
function List({ items, plain = false, emptyMessage, className = "", ...rest }) {
|
|
8683
8968
|
const __twcStyles = useScopedStyles("twc-list-styles", LIST_CSS);
|
|
8684
|
-
const
|
|
8969
|
+
const safeHref13 = (url) => {
|
|
8685
8970
|
if (url == null) return void 0;
|
|
8686
8971
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
8687
8972
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -8693,7 +8978,7 @@ function List({ items, plain = false, emptyMessage, className = "", ...rest }) {
|
|
|
8693
8978
|
/* @__PURE__ */ jsxRuntime.jsxs("ul", { className: `twc-list ${className}`, role: "list", "data-plain": plain || void 0, ...rest, children: [
|
|
8694
8979
|
__twcStyles,
|
|
8695
8980
|
items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("li", { role: "presentation", style: { display: "contents" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-list__empty", children: emptyMessage ?? "Nothing here yet" }) }) : items.map((it, i) => {
|
|
8696
|
-
const href =
|
|
8981
|
+
const href = safeHref13(it.href);
|
|
8697
8982
|
const interactive = Boolean(it.onClick || href);
|
|
8698
8983
|
const Tag2 = href ? "a" : interactive ? "button" : "div";
|
|
8699
8984
|
const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -8749,7 +9034,7 @@ button.twc-navbar__brand, a.twc-navbar__brand { cursor: pointer; }
|
|
|
8749
9034
|
.twc-navbar__menu-btn { display: inline-grid; }
|
|
8750
9035
|
}
|
|
8751
9036
|
`;
|
|
8752
|
-
function
|
|
9037
|
+
function safeHref5(url) {
|
|
8753
9038
|
if (url == null) return void 0;
|
|
8754
9039
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
8755
9040
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -8772,9 +9057,9 @@ function Navbar({
|
|
|
8772
9057
|
return /* @__PURE__ */ jsxRuntime.jsxs("header", { className: `twc-navbar ${className}`, "data-sticky": sticky || void 0, ...rest, children: [
|
|
8773
9058
|
__twcStyles,
|
|
8774
9059
|
onMenuClick ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-navbar__menu-btn", "aria-expanded": menuOpen, "aria-controls": menuControls, "aria-label": menuOpen ? "Close menu" : "Open menu", onClick: onMenuClick, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 6h16M4 12h16M4 18h16" }) }) }) : null,
|
|
8775
|
-
brand ? brandHref ? /* @__PURE__ */ jsxRuntime.jsx("a", { className: "twc-navbar__brand", href:
|
|
9060
|
+
brand ? brandHref ? /* @__PURE__ */ jsxRuntime.jsx("a", { className: "twc-navbar__brand", href: safeHref5(brandHref), children: brand }) : onBrandClick ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-navbar__brand", onClick: onBrandClick, children: brand }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-navbar__brand", children: brand }) : null,
|
|
8776
9061
|
/* @__PURE__ */ jsxRuntime.jsx("nav", { className: "twc-navbar__links", "aria-label": navLabel, children: links.map((l, i) => {
|
|
8777
|
-
const href =
|
|
9062
|
+
const href = safeHref5(l.href);
|
|
8778
9063
|
const inner = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8779
9064
|
l.icon,
|
|
8780
9065
|
l.label
|
|
@@ -8842,21 +9127,21 @@ function Popover({
|
|
|
8842
9127
|
...rest
|
|
8843
9128
|
}) {
|
|
8844
9129
|
const __twcStyles = useScopedStyles("twc-popover-styles", POPOVER_CSS);
|
|
8845
|
-
const [openState, setOpenState] =
|
|
8846
|
-
const [render, setRender] =
|
|
8847
|
-
const [pos, setPos] =
|
|
8848
|
-
const wrapRef =
|
|
8849
|
-
const popRef =
|
|
8850
|
-
const popId =
|
|
9130
|
+
const [openState, setOpenState] = React36__namespace.default.useState(defaultOpen);
|
|
9131
|
+
const [render, setRender] = React36__namespace.default.useState(false);
|
|
9132
|
+
const [pos, setPos] = React36__namespace.default.useState(null);
|
|
9133
|
+
const wrapRef = React36__namespace.default.useRef(null);
|
|
9134
|
+
const popRef = React36__namespace.default.useRef(null);
|
|
9135
|
+
const popId = React36__namespace.default.useId();
|
|
8851
9136
|
const controlled = openProp !== void 0;
|
|
8852
9137
|
const open = controlled ? !!openProp : openState;
|
|
8853
|
-
const openRef =
|
|
9138
|
+
const openRef = React36__namespace.default.useRef(open);
|
|
8854
9139
|
openRef.current = open;
|
|
8855
|
-
const controlledRef =
|
|
9140
|
+
const controlledRef = React36__namespace.default.useRef(controlled);
|
|
8856
9141
|
controlledRef.current = controlled;
|
|
8857
|
-
const onOpenChangeRef =
|
|
9142
|
+
const onOpenChangeRef = React36__namespace.default.useRef(onOpenChange);
|
|
8858
9143
|
onOpenChangeRef.current = onOpenChange;
|
|
8859
|
-
const setOpen =
|
|
9144
|
+
const setOpen = React36__namespace.default.useCallback((next) => {
|
|
8860
9145
|
const value = typeof next === "function" ? next(openRef.current) : next;
|
|
8861
9146
|
if (value === openRef.current) return;
|
|
8862
9147
|
if (!controlledRef.current) setOpenState(value);
|
|
@@ -8864,7 +9149,7 @@ function Popover({
|
|
|
8864
9149
|
}, []);
|
|
8865
9150
|
const toggle = () => setOpen((o) => !o);
|
|
8866
9151
|
const RD = { createPortal: typeof reactDom.createPortal === "function" ? reactDom.createPortal : typeof window !== "undefined" && window.ReactDOM && window.ReactDOM.createPortal };
|
|
8867
|
-
const place =
|
|
9152
|
+
const place = React36__namespace.default.useCallback(() => {
|
|
8868
9153
|
const t = wrapRef.current;
|
|
8869
9154
|
if (!t) return;
|
|
8870
9155
|
const r = t.getBoundingClientRect();
|
|
@@ -8901,7 +9186,7 @@ function Popover({
|
|
|
8901
9186
|
arrow = { top: Math.min(Math.max(cy - top - 5.5, 8), ph - 18), [onRight ? "left" : "right"]: -6 };
|
|
8902
9187
|
setPos({ top, left, width: w, flip: false, arrow });
|
|
8903
9188
|
}, [placement, align, width]);
|
|
8904
|
-
|
|
9189
|
+
React36__namespace.default.useEffect(() => {
|
|
8905
9190
|
if (!open) return;
|
|
8906
9191
|
place();
|
|
8907
9192
|
const onMove = () => place();
|
|
@@ -8924,7 +9209,7 @@ function Popover({
|
|
|
8924
9209
|
document.removeEventListener("keydown", onKey);
|
|
8925
9210
|
};
|
|
8926
9211
|
}, [open, place]);
|
|
8927
|
-
|
|
9212
|
+
React36__namespace.default.useEffect(() => {
|
|
8928
9213
|
if (open) {
|
|
8929
9214
|
setRender(true);
|
|
8930
9215
|
return;
|
|
@@ -8932,12 +9217,12 @@ function Popover({
|
|
|
8932
9217
|
const t = setTimeout(() => setRender(false), 170);
|
|
8933
9218
|
return () => clearTimeout(t);
|
|
8934
9219
|
}, [open]);
|
|
8935
|
-
|
|
9220
|
+
React36__namespace.default.useEffect(() => {
|
|
8936
9221
|
if (render && open) place();
|
|
8937
9222
|
}, [render, place]);
|
|
8938
|
-
const restoreRef =
|
|
8939
|
-
const needFocusRef =
|
|
8940
|
-
|
|
9223
|
+
const restoreRef = React36__namespace.default.useRef(null);
|
|
9224
|
+
const needFocusRef = React36__namespace.default.useRef(false);
|
|
9225
|
+
React36__namespace.default.useEffect(() => {
|
|
8941
9226
|
if (open) {
|
|
8942
9227
|
restoreRef.current = document.activeElement;
|
|
8943
9228
|
needFocusRef.current = true;
|
|
@@ -8972,7 +9257,7 @@ function Popover({
|
|
|
8972
9257
|
]
|
|
8973
9258
|
}
|
|
8974
9259
|
) : null;
|
|
8975
|
-
const triggerEl =
|
|
9260
|
+
const triggerEl = React36__namespace.default.isValidElement(trigger) ? React36__namespace.default.cloneElement(trigger, {
|
|
8976
9261
|
onClick: (e) => {
|
|
8977
9262
|
trigger.props.onClick?.(e);
|
|
8978
9263
|
toggle();
|
|
@@ -9015,7 +9300,7 @@ function Progress({
|
|
|
9015
9300
|
className = "",
|
|
9016
9301
|
...rest
|
|
9017
9302
|
}) {
|
|
9018
|
-
const labelId =
|
|
9303
|
+
const labelId = React36__namespace.default.useId();
|
|
9019
9304
|
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...restProps } = rest;
|
|
9020
9305
|
const __twcStyles = useScopedStyles("twc-progress-styles", `
|
|
9021
9306
|
.twc-progress-wrap { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-sans); }
|
|
@@ -9138,7 +9423,7 @@ function Radio({
|
|
|
9138
9423
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
9139
9424
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
9140
9425
|
`);
|
|
9141
|
-
const autoId =
|
|
9426
|
+
const autoId = React36__namespace.default.useId();
|
|
9142
9427
|
const fieldId = id || autoId;
|
|
9143
9428
|
const errId = `${fieldId}-error`;
|
|
9144
9429
|
const invalid = Boolean(error);
|
|
@@ -9208,13 +9493,13 @@ function RadioGroup({
|
|
|
9208
9493
|
...rest
|
|
9209
9494
|
}) {
|
|
9210
9495
|
const __twcStyles = useScopedStyles("twc-radio-group-styles", RADIO_GROUP_CSS);
|
|
9211
|
-
const autoId =
|
|
9496
|
+
const autoId = React36__namespace.default.useId();
|
|
9212
9497
|
const fieldId = id || autoId;
|
|
9213
9498
|
const labelId = `${fieldId}-label`;
|
|
9214
9499
|
const descId = `${fieldId}-desc`;
|
|
9215
9500
|
const groupName = name || `${fieldId}-name`;
|
|
9216
9501
|
const invalid = Boolean(error);
|
|
9217
|
-
const [internal, setInternal] =
|
|
9502
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
9218
9503
|
const current = value !== void 0 ? value : internal;
|
|
9219
9504
|
const select = (v) => {
|
|
9220
9505
|
if (value === void 0) setInternal(v);
|
|
@@ -9235,10 +9520,10 @@ function RadioGroup({
|
|
|
9235
9520
|
tone
|
|
9236
9521
|
},
|
|
9237
9522
|
o.value
|
|
9238
|
-
)) :
|
|
9239
|
-
if (!
|
|
9523
|
+
)) : React36__namespace.default.Children.map(children, (child) => {
|
|
9524
|
+
if (!React36__namespace.default.isValidElement(child)) return child;
|
|
9240
9525
|
const v = child.props.value;
|
|
9241
|
-
return
|
|
9526
|
+
return React36__namespace.default.cloneElement(child, {
|
|
9242
9527
|
name: child.props.name ?? groupName,
|
|
9243
9528
|
checked: child.props.checked ?? current === v,
|
|
9244
9529
|
onChange: child.props.onChange ?? (() => select(v)),
|
|
@@ -9318,12 +9603,12 @@ function Rating({
|
|
|
9318
9603
|
...rest
|
|
9319
9604
|
}) {
|
|
9320
9605
|
const __twcStyles = useScopedStyles("twc-rating-styles", RATING_CSS);
|
|
9321
|
-
const [internal, setInternal] =
|
|
9322
|
-
const [hover, setHover] =
|
|
9606
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue);
|
|
9607
|
+
const [hover, setHover] = React36__namespace.default.useState(0);
|
|
9323
9608
|
const val = value !== void 0 ? value : internal;
|
|
9324
9609
|
const shown = hover || val;
|
|
9325
9610
|
const interactive = !readOnly && !disabled;
|
|
9326
|
-
const btnRefs =
|
|
9611
|
+
const btnRefs = React36__namespace.default.useRef([]);
|
|
9327
9612
|
const tabStar = Math.min(count, Math.max(1, Math.round(val) || 1));
|
|
9328
9613
|
const fmt = (v) => format ? format(v) : Number.isInteger(v) ? String(v) : v.toFixed(1);
|
|
9329
9614
|
if (process.env.NODE_ENV !== "production" && interactive && !Number.isInteger(val)) {
|
|
@@ -9510,24 +9795,24 @@ function Sidebar({
|
|
|
9510
9795
|
...rest
|
|
9511
9796
|
}) {
|
|
9512
9797
|
const __twcStyles = useScopedStyles("twc-sidebar-styles", SIDEBAR_CSS);
|
|
9513
|
-
const navId =
|
|
9514
|
-
const panelRef =
|
|
9798
|
+
const navId = React36__namespace.default.useId();
|
|
9799
|
+
const panelRef = React36__namespace.default.useRef(null);
|
|
9515
9800
|
const renderPortal = usePortal();
|
|
9516
|
-
const [internal, setInternal] =
|
|
9801
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultCollapsed);
|
|
9517
9802
|
const collapsed = collapsedProp !== void 0 ? collapsedProp : internal;
|
|
9518
9803
|
const toggle = () => {
|
|
9519
9804
|
const next = !collapsed;
|
|
9520
9805
|
if (collapsedProp === void 0) setInternal(next);
|
|
9521
9806
|
onCollapsedChange?.(next);
|
|
9522
9807
|
};
|
|
9523
|
-
const [openInternal, setOpenInternal] =
|
|
9808
|
+
const [openInternal, setOpenInternal] = React36__namespace.default.useState(defaultOpen);
|
|
9524
9809
|
const open = openProp !== void 0 ? openProp : openInternal;
|
|
9525
9810
|
const setOpen = (next) => {
|
|
9526
9811
|
if (openProp === void 0) setOpenInternal(next);
|
|
9527
9812
|
onOpenChange?.(next);
|
|
9528
9813
|
};
|
|
9529
|
-
const [mounted, setMounted] =
|
|
9530
|
-
|
|
9814
|
+
const [mounted, setMounted] = React36__namespace.default.useState(open);
|
|
9815
|
+
React36__namespace.default.useEffect(() => {
|
|
9531
9816
|
if (!overlay) return void 0;
|
|
9532
9817
|
if (open) {
|
|
9533
9818
|
setMounted(true);
|
|
@@ -9536,7 +9821,7 @@ function Sidebar({
|
|
|
9536
9821
|
const t = setTimeout(() => setMounted(false), 170);
|
|
9537
9822
|
return () => clearTimeout(t);
|
|
9538
9823
|
}, [overlay, open]);
|
|
9539
|
-
|
|
9824
|
+
React36__namespace.default.useEffect(() => {
|
|
9540
9825
|
if (!overlay || !open) return void 0;
|
|
9541
9826
|
const prev = document.body.style.overflow;
|
|
9542
9827
|
document.body.style.overflow = "hidden";
|
|
@@ -9545,7 +9830,7 @@ function Sidebar({
|
|
|
9545
9830
|
};
|
|
9546
9831
|
}, [overlay, open]);
|
|
9547
9832
|
useFocusTrap(panelRef, overlay && open && mounted);
|
|
9548
|
-
|
|
9833
|
+
React36__namespace.default.useEffect(() => {
|
|
9549
9834
|
if (!overlay || !open) return void 0;
|
|
9550
9835
|
const onKey = (e) => {
|
|
9551
9836
|
if (e.key === "Escape") {
|
|
@@ -9557,13 +9842,13 @@ function Sidebar({
|
|
|
9557
9842
|
document.addEventListener("keydown", onKey);
|
|
9558
9843
|
return () => document.removeEventListener("keydown", onKey);
|
|
9559
9844
|
}, [overlay, open, openProp, onOpenChange]);
|
|
9560
|
-
const
|
|
9845
|
+
const safeHref13 = (url) => {
|
|
9561
9846
|
if (url == null) return void 0;
|
|
9562
9847
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
9563
9848
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
9564
9849
|
};
|
|
9565
9850
|
const renderItem = (it, i) => {
|
|
9566
|
-
const href =
|
|
9851
|
+
const href = safeHref13(it.href);
|
|
9567
9852
|
const labelStr = typeof it.label === "string" ? it.label : void 0;
|
|
9568
9853
|
const inner = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9569
9854
|
it.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-sidebar__ic", "aria-hidden": "true", children: it.icon }) : labelStr != null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-sidebar__ic twc-sidebar__ic--initial", "aria-hidden": "true", children: labelStr.charAt(0) }) : null,
|
|
@@ -9597,7 +9882,7 @@ function Sidebar({
|
|
|
9597
9882
|
const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9598
9883
|
__twcStyles,
|
|
9599
9884
|
brand ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-sidebar__head", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "twc-sidebar__brand", children: brand }) }) : null,
|
|
9600
|
-
/* @__PURE__ */ jsxRuntime.jsx("nav", { id: navId, className: "twc-sidebar__nav", "aria-label": navLabel, children: groups.map((g, gi) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9885
|
+
/* @__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: [
|
|
9601
9886
|
g.section != null ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-sidebar__section", id: g.sid, children: g.section }) : null,
|
|
9602
9887
|
/* @__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)) })
|
|
9603
9888
|
] }, gi)) }),
|
|
@@ -9766,10 +10051,10 @@ function Slider({
|
|
|
9766
10051
|
return Math.min(max, Math.max(min, Math.round(stepped * 1e6) / 1e6));
|
|
9767
10052
|
};
|
|
9768
10053
|
const __twcStyles = useScopedStyles("twc-slider-styles", SLIDER_CSS);
|
|
9769
|
-
const autoId =
|
|
10054
|
+
const autoId = React36__namespace.default.useId();
|
|
9770
10055
|
const fieldId = id || autoId;
|
|
9771
10056
|
const isRange = range || Array.isArray(value) || Array.isArray(defaultValue);
|
|
9772
|
-
const [internal, setInternal] =
|
|
10057
|
+
const [internal, setInternal] = React36__namespace.default.useState(() => {
|
|
9773
10058
|
if (isRange) {
|
|
9774
10059
|
const dv = Array.isArray(defaultValue) ? defaultValue : [min, max];
|
|
9775
10060
|
return [clampSnap(dv[0]), clampSnap(dv[1])];
|
|
@@ -9779,8 +10064,8 @@ function Slider({
|
|
|
9779
10064
|
const rawVal = value !== void 0 ? value : internal;
|
|
9780
10065
|
const clampedVals = (isRange ? [Number(rawVal[0]), Number(rawVal[1])] : [Number(rawVal)]).map((v) => Math.min(max, Math.max(min, Number.isFinite(v) ? v : min)));
|
|
9781
10066
|
const indices = isRange ? [0, 1] : [0];
|
|
9782
|
-
const trackRef =
|
|
9783
|
-
const [dragging, setDragging] =
|
|
10067
|
+
const trackRef = React36__namespace.default.useRef(null);
|
|
10068
|
+
const [dragging, setDragging] = React36__namespace.default.useState(false);
|
|
9784
10069
|
const fmt = (v) => formatValue ? formatValue(v) : v.toFixed(decimals);
|
|
9785
10070
|
const valueTextFor = (v) => {
|
|
9786
10071
|
if (getAriaValueText) return getAriaValueText(v);
|
|
@@ -9811,8 +10096,8 @@ function Slider({
|
|
|
9811
10096
|
const ratio = Math.min(1, Math.max(0, (clientX - r.left) / r.width));
|
|
9812
10097
|
return clampSnap(min + ratio * (max - min));
|
|
9813
10098
|
};
|
|
9814
|
-
const dragCleanupRef =
|
|
9815
|
-
|
|
10099
|
+
const dragCleanupRef = React36__namespace.default.useRef(null);
|
|
10100
|
+
React36__namespace.default.useEffect(() => () => dragCleanupRef.current?.(), []);
|
|
9816
10101
|
function onPointerDown(e) {
|
|
9817
10102
|
if (disabled) return;
|
|
9818
10103
|
e.preventDefault();
|
|
@@ -10043,7 +10328,7 @@ function Stepper({
|
|
|
10043
10328
|
...rest
|
|
10044
10329
|
}) {
|
|
10045
10330
|
const __twcStyles = useScopedStyles("twc-stepper-styles", STEPPER_CSS);
|
|
10046
|
-
const [activeInternal, setActiveInternal] =
|
|
10331
|
+
const [activeInternal, setActiveInternal] = React36__namespace.default.useState(defaultActive);
|
|
10047
10332
|
const active = activeProp !== void 0 ? activeProp : activeInternal;
|
|
10048
10333
|
const handleStep = (i) => {
|
|
10049
10334
|
if (activeProp === void 0) setActiveInternal(i);
|
|
@@ -10175,7 +10460,7 @@ function Switch({
|
|
|
10175
10460
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
10176
10461
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
10177
10462
|
`);
|
|
10178
|
-
const autoId =
|
|
10463
|
+
const autoId = React36__namespace.default.useId();
|
|
10179
10464
|
const fieldId = id || autoId;
|
|
10180
10465
|
const errId = `${fieldId}-error`;
|
|
10181
10466
|
const invalid = Boolean(error);
|
|
@@ -10278,14 +10563,14 @@ function Table({
|
|
|
10278
10563
|
...rest
|
|
10279
10564
|
}) {
|
|
10280
10565
|
const __twcStyles = useScopedStyles("twc-table-styles", TABLE_CSS);
|
|
10281
|
-
const cols =
|
|
10566
|
+
const cols = React36__namespace.default.useMemo(
|
|
10282
10567
|
() => (columns || []).map((c) => ({ ...c, header: c.headerName, render: c.renderCell })),
|
|
10283
10568
|
[columns]
|
|
10284
10569
|
);
|
|
10285
10570
|
const dataRows = rowsProp || [];
|
|
10286
|
-
const [internalSort, setInternalSort] =
|
|
10571
|
+
const [internalSort, setInternalSort] = React36__namespace.default.useState(defaultSort || { field: null, dir: "asc" });
|
|
10287
10572
|
const sort = (sortProp !== void 0 ? sortProp : internalSort) || { field: null, dir: "asc" };
|
|
10288
|
-
const rows =
|
|
10573
|
+
const rows = React36__namespace.default.useMemo(() => {
|
|
10289
10574
|
if (!sortable || !sort.field) return dataRows;
|
|
10290
10575
|
const col = cols.find((c) => c.field === sort.field);
|
|
10291
10576
|
if (!col) return dataRows;
|
|
@@ -10432,15 +10717,15 @@ function Tabs({
|
|
|
10432
10717
|
}) {
|
|
10433
10718
|
const vertical = orientation === "vertical";
|
|
10434
10719
|
const __twcStyles = useScopedStyles("twc-tabs-styles", TABS_CSS);
|
|
10435
|
-
const [internal, setInternal] =
|
|
10720
|
+
const [internal, setInternal] = React36__namespace.default.useState(defaultValue ?? items[0]?.value);
|
|
10436
10721
|
const active = value ?? internal;
|
|
10437
|
-
const listRef =
|
|
10438
|
-
const [ind, setInd] =
|
|
10439
|
-
const baseId =
|
|
10722
|
+
const listRef = React36__namespace.default.useRef(null);
|
|
10723
|
+
const [ind, setInd] = React36__namespace.default.useState({ left: 0, width: 0, top: 0, height: 0 });
|
|
10724
|
+
const baseId = React36__namespace.default.useId();
|
|
10440
10725
|
const tabIdAt = (i) => `${baseId}-tab-${i}`;
|
|
10441
10726
|
const panelId = `${baseId}-panel`;
|
|
10442
10727
|
const activeIndex = items.findIndex((it) => it.value === active);
|
|
10443
|
-
const updateIndicator =
|
|
10728
|
+
const updateIndicator = React36__namespace.default.useCallback(() => {
|
|
10444
10729
|
const list = listRef.current;
|
|
10445
10730
|
if (!list) return;
|
|
10446
10731
|
const el = list.querySelector('[data-active="true"]');
|
|
@@ -10449,10 +10734,10 @@ function Tabs({
|
|
|
10449
10734
|
if (!vertical) el.scrollIntoView?.({ inline: "nearest", block: "nearest" });
|
|
10450
10735
|
}
|
|
10451
10736
|
}, [vertical]);
|
|
10452
|
-
|
|
10737
|
+
React36__namespace.default.useEffect(() => {
|
|
10453
10738
|
updateIndicator();
|
|
10454
10739
|
}, [active, updateIndicator, items, orientation]);
|
|
10455
|
-
|
|
10740
|
+
React36__namespace.default.useEffect(() => {
|
|
10456
10741
|
const r = () => updateIndicator();
|
|
10457
10742
|
window.addEventListener("resize", r);
|
|
10458
10743
|
if (typeof document !== "undefined" && document.fonts && document.fonts.ready) {
|
|
@@ -10597,7 +10882,7 @@ function Tag({
|
|
|
10597
10882
|
}, "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
|
|
10598
10883
|
] });
|
|
10599
10884
|
}
|
|
10600
|
-
var useIso = typeof document !== "undefined" ?
|
|
10885
|
+
var useIso = typeof document !== "undefined" ? React36__namespace.default.useLayoutEffect : React36__namespace.default.useEffect;
|
|
10601
10886
|
var TEXTAREA_CSS = `
|
|
10602
10887
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
10603
10888
|
.twc-field__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); display: flex; gap: 4px; align-items: center; }
|
|
@@ -10633,7 +10918,7 @@ var TEXTAREA_CSS = `
|
|
|
10633
10918
|
.twc-field__count { margin-inline-start: auto; font-size: var(--text-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; flex: none; }
|
|
10634
10919
|
.twc-field__count[data-danger="true"] { color: var(--color-danger-subtle-fg); }
|
|
10635
10920
|
`;
|
|
10636
|
-
var Textarea =
|
|
10921
|
+
var Textarea = React36__namespace.default.forwardRef(function Textarea2({
|
|
10637
10922
|
label,
|
|
10638
10923
|
hint,
|
|
10639
10924
|
error,
|
|
@@ -10651,19 +10936,19 @@ var Textarea = React25__namespace.default.forwardRef(function Textarea2({
|
|
|
10651
10936
|
...rest
|
|
10652
10937
|
}, ref) {
|
|
10653
10938
|
const __twcStyles = useScopedStyles("twc-textarea-styles", TEXTAREA_CSS);
|
|
10654
|
-
const autoId =
|
|
10939
|
+
const autoId = React36__namespace.default.useId();
|
|
10655
10940
|
const fieldId = id || autoId;
|
|
10656
10941
|
const descId = `${fieldId}-desc`;
|
|
10657
10942
|
const countId = `${fieldId}-count`;
|
|
10658
10943
|
const invalid = Boolean(error);
|
|
10659
|
-
const innerRef =
|
|
10944
|
+
const innerRef = React36__namespace.default.useRef(null);
|
|
10660
10945
|
const setRef = (el) => {
|
|
10661
10946
|
innerRef.current = el;
|
|
10662
10947
|
if (typeof ref === "function") ref(el);
|
|
10663
10948
|
else if (ref) ref.current = el;
|
|
10664
10949
|
};
|
|
10665
10950
|
const countControlled = rest.value !== void 0;
|
|
10666
|
-
const [len2, setLen] =
|
|
10951
|
+
const [len2, setLen] = React36__namespace.default.useState(() => String(rest.defaultValue ?? "").length);
|
|
10667
10952
|
const count = countControlled ? String(rest.value ?? "").length : len2;
|
|
10668
10953
|
const max = rest.maxLength;
|
|
10669
10954
|
const showCounter = showCount && max != null;
|
|
@@ -10841,19 +11126,19 @@ function Toast({
|
|
|
10841
11126
|
}) {
|
|
10842
11127
|
const resolvedTone = tone === "neutral" ? "default" : tone;
|
|
10843
11128
|
const __twcStyles = useScopedStyles("twc-toast-styles", TOAST_CSS);
|
|
10844
|
-
const onCloseRef =
|
|
10845
|
-
|
|
11129
|
+
const onCloseRef = React36__namespace.default.useRef(onClose);
|
|
11130
|
+
React36__namespace.default.useEffect(() => {
|
|
10846
11131
|
onCloseRef.current = onClose;
|
|
10847
11132
|
}, [onClose]);
|
|
10848
|
-
const timer =
|
|
10849
|
-
const stop =
|
|
10850
|
-
const start =
|
|
11133
|
+
const timer = React36__namespace.default.useRef();
|
|
11134
|
+
const stop = React36__namespace.default.useCallback(() => clearTimeout(timer.current), []);
|
|
11135
|
+
const start = React36__namespace.default.useCallback(() => {
|
|
10851
11136
|
stop();
|
|
10852
11137
|
if (duration && duration !== Infinity && onCloseRef.current) {
|
|
10853
11138
|
timer.current = setTimeout(() => onCloseRef.current && onCloseRef.current(), duration);
|
|
10854
11139
|
}
|
|
10855
11140
|
}, [duration, stop]);
|
|
10856
|
-
|
|
11141
|
+
React36__namespace.default.useEffect(() => {
|
|
10857
11142
|
start();
|
|
10858
11143
|
return stop;
|
|
10859
11144
|
}, [start, stop]);
|
|
@@ -10898,30 +11183,30 @@ function Toast({
|
|
|
10898
11183
|
}
|
|
10899
11184
|
function ToastViewport({ children, limit, className = "", ...rest }) {
|
|
10900
11185
|
const __twcStyles = useScopedStyles("twc-toast-styles", TOAST_CSS);
|
|
10901
|
-
const shown = limit && limit > 0 ?
|
|
11186
|
+
const shown = limit && limit > 0 ? React36__namespace.default.Children.toArray(children).slice(-limit) : children;
|
|
10902
11187
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-toast-viewport ${className}`, role: "region", "aria-label": "Notifications", ...rest, children: [
|
|
10903
11188
|
__twcStyles,
|
|
10904
11189
|
shown
|
|
10905
11190
|
] });
|
|
10906
11191
|
}
|
|
10907
|
-
var ToastContext =
|
|
11192
|
+
var ToastContext = React36__namespace.default.createContext(null);
|
|
10908
11193
|
function useToast() {
|
|
10909
|
-
const ctx =
|
|
11194
|
+
const ctx = React36__namespace.default.useContext(ToastContext);
|
|
10910
11195
|
if (!ctx) throw new Error("useToast must be used within a <ToastProvider>.");
|
|
10911
11196
|
return ctx;
|
|
10912
11197
|
}
|
|
10913
11198
|
function ToastProvider({ children, limit = 4, duration = 4500, ...viewportProps }) {
|
|
10914
|
-
const [toasts, setToasts] =
|
|
10915
|
-
const idRef =
|
|
10916
|
-
const limitRef =
|
|
10917
|
-
|
|
11199
|
+
const [toasts, setToasts] = React36__namespace.default.useState([]);
|
|
11200
|
+
const idRef = React36__namespace.default.useRef(0);
|
|
11201
|
+
const limitRef = React36__namespace.default.useRef(limit);
|
|
11202
|
+
React36__namespace.default.useEffect(() => {
|
|
10918
11203
|
limitRef.current = limit;
|
|
10919
11204
|
}, [limit]);
|
|
10920
|
-
const dismiss =
|
|
11205
|
+
const dismiss = React36__namespace.default.useCallback((id) => {
|
|
10921
11206
|
setToasts((s) => s.filter((t) => t.id !== id));
|
|
10922
11207
|
}, []);
|
|
10923
|
-
const clear =
|
|
10924
|
-
const api =
|
|
11208
|
+
const clear = React36__namespace.default.useCallback(() => setToasts([]), []);
|
|
11209
|
+
const api = React36__namespace.default.useMemo(() => {
|
|
10925
11210
|
const push = (opts) => {
|
|
10926
11211
|
const id = idRef.current += 1;
|
|
10927
11212
|
const next = typeof opts === "string" ? { title: opts } : opts && typeof opts === "object" ? opts : {};
|
|
@@ -10942,7 +11227,7 @@ function ToastProvider({ children, limit = 4, duration = 4500, ...viewportProps
|
|
|
10942
11227
|
toast.show = withTone("default");
|
|
10943
11228
|
return { toast, dismiss, clear };
|
|
10944
11229
|
}, [dismiss, clear]);
|
|
10945
|
-
const value =
|
|
11230
|
+
const value = React36__namespace.default.useMemo(() => ({ ...api, toasts }), [api, toasts]);
|
|
10946
11231
|
return /* @__PURE__ */ jsxRuntime.jsxs(ToastContext.Provider, { value, children: [
|
|
10947
11232
|
children,
|
|
10948
11233
|
/* @__PURE__ */ jsxRuntime.jsx(ToastViewport, { limit, ...viewportProps, children: toasts.map((t) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -11050,13 +11335,13 @@ function TreeView({
|
|
|
11050
11335
|
}) {
|
|
11051
11336
|
const nodes = items;
|
|
11052
11337
|
const __twcStyles = useScopedStyles("twc-tree-styles", TREE_CSS);
|
|
11053
|
-
const [expInternal, setExpInternal] =
|
|
11338
|
+
const [expInternal, setExpInternal] = React36__namespace.default.useState(() => new Set(defaultExpanded));
|
|
11054
11339
|
const expanded = expandedProp !== void 0 ? new Set(expandedProp) : expInternal;
|
|
11055
|
-
const [selInternal, setSelInternal] =
|
|
11340
|
+
const [selInternal, setSelInternal] = React36__namespace.default.useState(defaultSelectedId);
|
|
11056
11341
|
const selectedId = selectedProp !== void 0 ? selectedProp : selInternal;
|
|
11057
|
-
const [focusId, setFocusId] =
|
|
11058
|
-
const rowRefs =
|
|
11059
|
-
const taRef =
|
|
11342
|
+
const [focusId, setFocusId] = React36__namespace.default.useState(null);
|
|
11343
|
+
const rowRefs = React36__namespace.default.useRef(/* @__PURE__ */ new Map());
|
|
11344
|
+
const taRef = React36__namespace.default.useRef({ str: "", t: 0 });
|
|
11060
11345
|
const toggle = (id) => {
|
|
11061
11346
|
const n = new Set(expanded);
|
|
11062
11347
|
n.has(id) ? n.delete(id) : n.add(id);
|
|
@@ -11188,7 +11473,7 @@ function AppShell({
|
|
|
11188
11473
|
...rest
|
|
11189
11474
|
}) {
|
|
11190
11475
|
const __twcStyles = useScopedStyles("twc-shell-styles", SHELL_CSS);
|
|
11191
|
-
const wiredSidebar =
|
|
11476
|
+
const wiredSidebar = React36__namespace.default.isValidElement(sidebar) && (sidebarOpen !== void 0 || onSidebarOpenChange !== void 0) ? React36__namespace.default.cloneElement(sidebar, {
|
|
11192
11477
|
overlay: sidebar.props.overlay !== void 0 ? sidebar.props.overlay : true,
|
|
11193
11478
|
open: sidebar.props.open !== void 0 ? sidebar.props.open : sidebarOpen,
|
|
11194
11479
|
onOpenChange: sidebar.props.onOpenChange !== void 0 ? sidebar.props.onOpenChange : onSidebarOpenChange
|
|
@@ -11218,12 +11503,12 @@ function bgValue(bg) {
|
|
|
11218
11503
|
if (BG[bg]) return `var(${BG[bg]})`;
|
|
11219
11504
|
return String(bg).startsWith("--") ? `var(${bg})` : bg;
|
|
11220
11505
|
}
|
|
11221
|
-
function
|
|
11506
|
+
function safeHref6(url) {
|
|
11222
11507
|
if (url == null) return void 0;
|
|
11223
11508
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
11224
11509
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
11225
11510
|
}
|
|
11226
|
-
|
|
11511
|
+
var Box = React36__namespace.default.forwardRef(function Box2({
|
|
11227
11512
|
as: Tag2 = "div",
|
|
11228
11513
|
p,
|
|
11229
11514
|
px,
|
|
@@ -11247,7 +11532,7 @@ function Box({
|
|
|
11247
11532
|
style,
|
|
11248
11533
|
children,
|
|
11249
11534
|
...rest
|
|
11250
|
-
}) {
|
|
11535
|
+
}, ref) {
|
|
11251
11536
|
const s = {
|
|
11252
11537
|
paddingTop: sp(pt ?? py ?? p),
|
|
11253
11538
|
paddingRight: sp(pr ?? px ?? p),
|
|
@@ -11263,16 +11548,17 @@ function Box({
|
|
|
11263
11548
|
boxShadow: shadow ? `var(--shadow-${shadow})` : void 0,
|
|
11264
11549
|
...style
|
|
11265
11550
|
};
|
|
11266
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
11267
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Tag2, { className: `twc-box ${className}`.trim(), style: s, ...rest, children });
|
|
11268
|
-
}
|
|
11551
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref6(rest.href);
|
|
11552
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tag2, { ref, className: `twc-box ${className}`.trim(), style: s, ...rest, children });
|
|
11553
|
+
});
|
|
11554
|
+
Box.displayName = "Box";
|
|
11269
11555
|
var SIZES = { sm: 640, md: 768, lg: 1024, xl: 1280, full: "100%" };
|
|
11270
|
-
function
|
|
11556
|
+
function safeHref7(url) {
|
|
11271
11557
|
if (url == null) return void 0;
|
|
11272
11558
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
11273
11559
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
11274
11560
|
}
|
|
11275
|
-
|
|
11561
|
+
var Container = React36__namespace.default.forwardRef(function Container2({
|
|
11276
11562
|
as: Tag2 = "div",
|
|
11277
11563
|
size = "lg",
|
|
11278
11564
|
padded = true,
|
|
@@ -11280,12 +11566,13 @@ function Container({
|
|
|
11280
11566
|
style,
|
|
11281
11567
|
children,
|
|
11282
11568
|
...rest
|
|
11283
|
-
}) {
|
|
11569
|
+
}, ref) {
|
|
11284
11570
|
const max = SIZES[size] ?? size;
|
|
11285
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
11571
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref7(rest.href);
|
|
11286
11572
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11287
11573
|
Tag2,
|
|
11288
11574
|
{
|
|
11575
|
+
ref,
|
|
11289
11576
|
className: `twc-container ${className}`.trim(),
|
|
11290
11577
|
style: {
|
|
11291
11578
|
width: "100%",
|
|
@@ -11298,7 +11585,8 @@ function Container({
|
|
|
11298
11585
|
children
|
|
11299
11586
|
}
|
|
11300
11587
|
);
|
|
11301
|
-
}
|
|
11588
|
+
});
|
|
11589
|
+
Container.displayName = "Container";
|
|
11302
11590
|
function space(v) {
|
|
11303
11591
|
if (v == null) return void 0;
|
|
11304
11592
|
if (typeof v === "number") return `var(--space-${String(v).replace(".", "-")})`;
|
|
@@ -11308,12 +11596,12 @@ function len(v) {
|
|
|
11308
11596
|
return typeof v === "number" ? `${v}px` : v;
|
|
11309
11597
|
}
|
|
11310
11598
|
var BP = { sm: 640, md: 768, lg: 1024, xl: 1280 };
|
|
11311
|
-
function
|
|
11599
|
+
function safeHref8(url) {
|
|
11312
11600
|
if (url == null) return void 0;
|
|
11313
11601
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
11314
11602
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
11315
11603
|
}
|
|
11316
|
-
|
|
11604
|
+
var Grid = React36__namespace.default.forwardRef(function Grid2({
|
|
11317
11605
|
as: Tag2 = "div",
|
|
11318
11606
|
columns,
|
|
11319
11607
|
minChildWidth,
|
|
@@ -11328,9 +11616,9 @@ function Grid({
|
|
|
11328
11616
|
style,
|
|
11329
11617
|
children,
|
|
11330
11618
|
...rest
|
|
11331
|
-
}) {
|
|
11619
|
+
}, ref) {
|
|
11332
11620
|
const responsive = columns != null && typeof columns === "object";
|
|
11333
|
-
const uid =
|
|
11621
|
+
const uid = React36__namespace.default.useId();
|
|
11334
11622
|
const gridId = responsive ? `g${uid.replace(/[^a-zA-Z0-9]/g, "")}` : null;
|
|
11335
11623
|
let css = "";
|
|
11336
11624
|
if (responsive) {
|
|
@@ -11344,10 +11632,11 @@ function Grid({
|
|
|
11344
11632
|
}
|
|
11345
11633
|
const __twcStyles = useScopedStyles(gridId ? `twc-grid-${gridId}` : "twc-grid", css);
|
|
11346
11634
|
const templateColumns = minChildWidth ? `repeat(auto-fill, minmax(min(${len(minChildWidth)}, 100%), 1fr))` : responsive ? `repeat(var(--twc-grid-cols, ${columns.base ?? 1}), minmax(0, 1fr))` : `repeat(${columns || 1}, minmax(0, 1fr))`;
|
|
11347
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
11635
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref8(rest.href);
|
|
11348
11636
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11349
11637
|
Tag2,
|
|
11350
11638
|
{
|
|
11639
|
+
ref,
|
|
11351
11640
|
className: `twc-grid ${className}`.trim(),
|
|
11352
11641
|
"data-twc-grid-id": gridId || void 0,
|
|
11353
11642
|
style: {
|
|
@@ -11368,18 +11657,19 @@ function Grid({
|
|
|
11368
11657
|
]
|
|
11369
11658
|
}
|
|
11370
11659
|
);
|
|
11371
|
-
}
|
|
11660
|
+
});
|
|
11661
|
+
Grid.displayName = "Grid";
|
|
11372
11662
|
function space2(v) {
|
|
11373
11663
|
if (v == null) return void 0;
|
|
11374
11664
|
if (typeof v === "number") return `var(--space-${String(v).replace(".", "-")})`;
|
|
11375
11665
|
return v;
|
|
11376
11666
|
}
|
|
11377
|
-
function
|
|
11667
|
+
function safeHref9(url) {
|
|
11378
11668
|
if (url == null) return void 0;
|
|
11379
11669
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
11380
11670
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
11381
11671
|
}
|
|
11382
|
-
|
|
11672
|
+
var Stack = React36__namespace.default.forwardRef(function Stack2({
|
|
11383
11673
|
as: Tag2 = "div",
|
|
11384
11674
|
direction = "column",
|
|
11385
11675
|
gap = 4,
|
|
@@ -11399,12 +11689,13 @@ function Stack({
|
|
|
11399
11689
|
style,
|
|
11400
11690
|
children,
|
|
11401
11691
|
...rest
|
|
11402
|
-
}) {
|
|
11403
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
11404
|
-
const kids = divider != null ?
|
|
11692
|
+
}, ref) {
|
|
11693
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref9(rest.href);
|
|
11694
|
+
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;
|
|
11405
11695
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11406
11696
|
Tag2,
|
|
11407
11697
|
{
|
|
11698
|
+
ref,
|
|
11408
11699
|
className: `twc-stack ${className}`.trim(),
|
|
11409
11700
|
style: {
|
|
11410
11701
|
display: inline ? "inline-flex" : "flex",
|
|
@@ -11424,7 +11715,8 @@ function Stack({
|
|
|
11424
11715
|
children: kids
|
|
11425
11716
|
}
|
|
11426
11717
|
);
|
|
11427
|
-
}
|
|
11718
|
+
});
|
|
11719
|
+
Stack.displayName = "Stack";
|
|
11428
11720
|
var CODE_CSS = `
|
|
11429
11721
|
.twc-code {
|
|
11430
11722
|
font-family: var(--font-mono); font-size: 0.875em;
|
|
@@ -11448,7 +11740,7 @@ var CODE_CSS = `
|
|
|
11448
11740
|
.twc-code__copy:focus-visible { outline: none; box-shadow: var(--ring); }
|
|
11449
11741
|
.twc-code__copy svg { width: 15px; height: 15px; display: block; }
|
|
11450
11742
|
`;
|
|
11451
|
-
function
|
|
11743
|
+
function safeHref10(url) {
|
|
11452
11744
|
if (url == null) return void 0;
|
|
11453
11745
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
11454
11746
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -11465,11 +11757,11 @@ function Code({
|
|
|
11465
11757
|
}) {
|
|
11466
11758
|
const __twcStyles = useScopedStyles("twc-code-styles", CODE_CSS);
|
|
11467
11759
|
const Tag2 = as ?? (block ? "pre" : "code");
|
|
11468
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
11469
|
-
const rootRef =
|
|
11470
|
-
const [copied, setCopied] =
|
|
11471
|
-
const timerRef =
|
|
11472
|
-
|
|
11760
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref10(rest.href);
|
|
11761
|
+
const rootRef = React36__namespace.default.useRef(null);
|
|
11762
|
+
const [copied, setCopied] = React36__namespace.default.useState(false);
|
|
11763
|
+
const timerRef = React36__namespace.default.useRef(null);
|
|
11764
|
+
React36__namespace.default.useEffect(() => () => clearTimeout(timerRef.current), []);
|
|
11473
11765
|
const doCopy = () => {
|
|
11474
11766
|
if (typeof navigator === "undefined" || !navigator.clipboard) return;
|
|
11475
11767
|
const text = typeof children === "string" ? children : rootRef.current?.textContent ?? "";
|
|
@@ -11490,12 +11782,12 @@ function Code({
|
|
|
11490
11782
|
] });
|
|
11491
11783
|
}
|
|
11492
11784
|
var LEVEL_SIZE = { 1: "4xl", 2: "2xl", 3: "xl", 4: "lg", 5: "base", 6: "sm" };
|
|
11493
|
-
function
|
|
11785
|
+
function safeHref11(url) {
|
|
11494
11786
|
if (url == null) return void 0;
|
|
11495
11787
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
11496
11788
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
11497
11789
|
}
|
|
11498
|
-
|
|
11790
|
+
var Heading = React36__namespace.default.forwardRef(function Heading2({
|
|
11499
11791
|
as,
|
|
11500
11792
|
level = 2,
|
|
11501
11793
|
size,
|
|
@@ -11507,13 +11799,14 @@ function Heading({
|
|
|
11507
11799
|
style,
|
|
11508
11800
|
children,
|
|
11509
11801
|
...rest
|
|
11510
|
-
}) {
|
|
11802
|
+
}, ref) {
|
|
11511
11803
|
const Tag2 = as || `h${level}`;
|
|
11512
11804
|
const sz = size || (display ? "display" : LEVEL_SIZE[level]) || "2xl";
|
|
11513
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
11805
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref11(rest.href);
|
|
11514
11806
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11515
11807
|
Tag2,
|
|
11516
11808
|
{
|
|
11809
|
+
ref,
|
|
11517
11810
|
className: `twc-heading ${className}`.trim(),
|
|
11518
11811
|
style: {
|
|
11519
11812
|
margin: 0,
|
|
@@ -11531,7 +11824,8 @@ function Heading({
|
|
|
11531
11824
|
children
|
|
11532
11825
|
}
|
|
11533
11826
|
);
|
|
11534
|
-
}
|
|
11827
|
+
});
|
|
11828
|
+
Heading.displayName = "Heading";
|
|
11535
11829
|
var TONE = {
|
|
11536
11830
|
default: "--color-text",
|
|
11537
11831
|
muted: "--color-text-muted",
|
|
@@ -11547,12 +11841,12 @@ var TONE = {
|
|
|
11547
11841
|
// Adopt the surrounding color (e.g. inside a solid Button/Badge/Alert or a link).
|
|
11548
11842
|
inherit: "inherit"
|
|
11549
11843
|
};
|
|
11550
|
-
function
|
|
11844
|
+
function safeHref12(url) {
|
|
11551
11845
|
if (url == null) return void 0;
|
|
11552
11846
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
11553
11847
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
11554
11848
|
}
|
|
11555
|
-
|
|
11849
|
+
var Text = React36__namespace.default.forwardRef(function Text2({
|
|
11556
11850
|
as: Tag2 = "p",
|
|
11557
11851
|
size = "base",
|
|
11558
11852
|
tone = "default",
|
|
@@ -11564,12 +11858,13 @@ function Text({
|
|
|
11564
11858
|
style,
|
|
11565
11859
|
children,
|
|
11566
11860
|
...rest
|
|
11567
|
-
}) {
|
|
11568
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
11861
|
+
}, ref) {
|
|
11862
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref12(rest.href);
|
|
11569
11863
|
const toneToken = TONE[tone] || TONE.default;
|
|
11570
11864
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11571
11865
|
Tag2,
|
|
11572
11866
|
{
|
|
11867
|
+
ref,
|
|
11573
11868
|
className: `twc-text ${className}`.trim(),
|
|
11574
11869
|
style: {
|
|
11575
11870
|
margin: 0,
|
|
@@ -11586,47 +11881,48 @@ function Text({
|
|
|
11586
11881
|
children
|
|
11587
11882
|
}
|
|
11588
11883
|
);
|
|
11589
|
-
}
|
|
11884
|
+
});
|
|
11885
|
+
Text.displayName = "Text";
|
|
11590
11886
|
var canUseDOM2 = typeof window !== "undefined" && typeof document !== "undefined";
|
|
11591
|
-
var useIsomorphicLayoutEffect = canUseDOM2 ?
|
|
11887
|
+
var useIsomorphicLayoutEffect = canUseDOM2 ? React36__namespace.default.useLayoutEffect : React36__namespace.default.useEffect;
|
|
11592
11888
|
function useMounted() {
|
|
11593
|
-
const [mounted, setMounted] =
|
|
11594
|
-
|
|
11889
|
+
const [mounted, setMounted] = React36__namespace.default.useState(false);
|
|
11890
|
+
React36__namespace.default.useEffect(() => {
|
|
11595
11891
|
setMounted(true);
|
|
11596
11892
|
}, []);
|
|
11597
11893
|
return mounted;
|
|
11598
11894
|
}
|
|
11599
11895
|
function usePrevious(value) {
|
|
11600
|
-
const ref =
|
|
11601
|
-
|
|
11896
|
+
const ref = React36__namespace.default.useRef(void 0);
|
|
11897
|
+
React36__namespace.default.useEffect(() => {
|
|
11602
11898
|
ref.current = value;
|
|
11603
11899
|
}, [value]);
|
|
11604
11900
|
return ref.current;
|
|
11605
11901
|
}
|
|
11606
11902
|
function useToggle(initial = false) {
|
|
11607
|
-
const [on, setOn] =
|
|
11608
|
-
const toggle =
|
|
11903
|
+
const [on, setOn] = React36__namespace.default.useState(initial);
|
|
11904
|
+
const toggle = React36__namespace.default.useCallback((next) => {
|
|
11609
11905
|
setOn((prev) => typeof next === "boolean" ? next : !prev);
|
|
11610
11906
|
}, []);
|
|
11611
11907
|
return [on, toggle, setOn];
|
|
11612
11908
|
}
|
|
11613
11909
|
function useDisclosure(initial = false) {
|
|
11614
|
-
const [open, setOpen] =
|
|
11615
|
-
const onOpen =
|
|
11616
|
-
const onClose =
|
|
11617
|
-
const onToggle =
|
|
11910
|
+
const [open, setOpen] = React36__namespace.default.useState(initial);
|
|
11911
|
+
const onOpen = React36__namespace.default.useCallback(() => setOpen(true), []);
|
|
11912
|
+
const onClose = React36__namespace.default.useCallback(() => setOpen(false), []);
|
|
11913
|
+
const onToggle = React36__namespace.default.useCallback(() => setOpen((p) => !p), []);
|
|
11618
11914
|
return { open, onOpen, onClose, onToggle, setOpen };
|
|
11619
11915
|
}
|
|
11620
11916
|
function useControllableState({ value, defaultValue, onChange } = {}) {
|
|
11621
11917
|
const isControlled = value !== void 0;
|
|
11622
|
-
const [uncontrolled, setUncontrolled] =
|
|
11918
|
+
const [uncontrolled, setUncontrolled] = React36__namespace.default.useState(defaultValue);
|
|
11623
11919
|
const current = isControlled ? value : uncontrolled;
|
|
11624
|
-
const ref =
|
|
11920
|
+
const ref = React36__namespace.default.useRef({ current, isControlled, onChange });
|
|
11625
11921
|
useIsomorphicLayoutEffect(() => {
|
|
11626
11922
|
ref.current = { current, isControlled, onChange };
|
|
11627
11923
|
});
|
|
11628
|
-
const wasControlled =
|
|
11629
|
-
|
|
11924
|
+
const wasControlled = React36__namespace.default.useRef(isControlled);
|
|
11925
|
+
React36__namespace.default.useEffect(() => {
|
|
11630
11926
|
if (wasControlled.current !== isControlled) {
|
|
11631
11927
|
warnOnce(
|
|
11632
11928
|
"useControllableState:switch",
|
|
@@ -11635,7 +11931,7 @@ function useControllableState({ value, defaultValue, onChange } = {}) {
|
|
|
11635
11931
|
wasControlled.current = isControlled;
|
|
11636
11932
|
}
|
|
11637
11933
|
});
|
|
11638
|
-
const setValue =
|
|
11934
|
+
const setValue = React36__namespace.default.useCallback((next) => {
|
|
11639
11935
|
const { current: cur, isControlled: ctrl, onChange: cb } = ref.current;
|
|
11640
11936
|
const resolved = typeof next === "function" ? next(cur) : next;
|
|
11641
11937
|
if (resolved === cur) return;
|
|
@@ -11646,7 +11942,7 @@ function useControllableState({ value, defaultValue, onChange } = {}) {
|
|
|
11646
11942
|
}
|
|
11647
11943
|
function useMediaQuery(query, { defaultValue = false, initializeWithValue = false } = {}) {
|
|
11648
11944
|
const get = () => canUseDOM2 ? window.matchMedia(query).matches : defaultValue;
|
|
11649
|
-
const [matches3, setMatches] =
|
|
11945
|
+
const [matches3, setMatches] = React36__namespace.default.useState(initializeWithValue ? get : defaultValue);
|
|
11650
11946
|
useIsomorphicLayoutEffect(() => {
|
|
11651
11947
|
if (!canUseDOM2) return void 0;
|
|
11652
11948
|
const mql = window.matchMedia(query);
|
|
@@ -11662,7 +11958,7 @@ function usePrefersReducedMotion() {
|
|
|
11662
11958
|
}
|
|
11663
11959
|
function useColorScheme({ storageKey = "twico-theme", attribute = "class", element, disableTransitionsOnChange = true } = {}) {
|
|
11664
11960
|
const getTarget = () => element || (canUseDOM2 ? document.documentElement : null);
|
|
11665
|
-
const firstApply =
|
|
11961
|
+
const firstApply = React36__namespace.default.useRef(true);
|
|
11666
11962
|
const read = () => {
|
|
11667
11963
|
if (!canUseDOM2) return "light";
|
|
11668
11964
|
try {
|
|
@@ -11672,8 +11968,8 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
11672
11968
|
}
|
|
11673
11969
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
11674
11970
|
};
|
|
11675
|
-
const [theme, setThemeState] =
|
|
11676
|
-
const apply =
|
|
11971
|
+
const [theme, setThemeState] = React36__namespace.default.useState(read);
|
|
11972
|
+
const apply = React36__namespace.default.useCallback(
|
|
11677
11973
|
(t) => {
|
|
11678
11974
|
const target = getTarget();
|
|
11679
11975
|
if (!target) return;
|
|
@@ -11699,11 +11995,11 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
11699
11995
|
useIsomorphicLayoutEffect(() => {
|
|
11700
11996
|
apply(theme);
|
|
11701
11997
|
}, [theme, apply]);
|
|
11702
|
-
const themeRef =
|
|
11998
|
+
const themeRef = React36__namespace.default.useRef(theme);
|
|
11703
11999
|
useIsomorphicLayoutEffect(() => {
|
|
11704
12000
|
themeRef.current = theme;
|
|
11705
12001
|
}, [theme]);
|
|
11706
|
-
const setTheme =
|
|
12002
|
+
const setTheme = React36__namespace.default.useCallback(
|
|
11707
12003
|
(t) => {
|
|
11708
12004
|
setThemeState(t);
|
|
11709
12005
|
try {
|
|
@@ -11714,10 +12010,10 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
11714
12010
|
},
|
|
11715
12011
|
[storageKey]
|
|
11716
12012
|
);
|
|
11717
|
-
const toggle =
|
|
12013
|
+
const toggle = React36__namespace.default.useCallback(() => {
|
|
11718
12014
|
setTheme(themeRef.current === "dark" ? "light" : "dark");
|
|
11719
12015
|
}, [setTheme]);
|
|
11720
|
-
|
|
12016
|
+
React36__namespace.default.useEffect(() => {
|
|
11721
12017
|
if (!canUseDOM2) return void 0;
|
|
11722
12018
|
const sync = () => setThemeState(read());
|
|
11723
12019
|
const onStorage = (e) => {
|
|
@@ -11733,14 +12029,14 @@ function useColorScheme({ storageKey = "twico-theme", attribute = "class", eleme
|
|
|
11733
12029
|
return { theme, setTheme, toggle, isDark: theme === "dark" };
|
|
11734
12030
|
}
|
|
11735
12031
|
function useEventListener(eventName, handler, element, options) {
|
|
11736
|
-
const saved =
|
|
12032
|
+
const saved = React36__namespace.default.useRef(handler);
|
|
11737
12033
|
useIsomorphicLayoutEffect(() => {
|
|
11738
12034
|
saved.current = handler;
|
|
11739
12035
|
}, [handler]);
|
|
11740
12036
|
const capture = typeof options === "boolean" ? options : options && options.capture;
|
|
11741
12037
|
const passive = typeof options === "object" && options ? options.passive : void 0;
|
|
11742
12038
|
const once = typeof options === "object" && options ? options.once : void 0;
|
|
11743
|
-
|
|
12039
|
+
React36__namespace.default.useEffect(() => {
|
|
11744
12040
|
const target = element && element.current || element || (canUseDOM2 ? window : null);
|
|
11745
12041
|
if (!target || !target.addEventListener) return void 0;
|
|
11746
12042
|
const opts = typeof options === "boolean" ? options : { capture, passive, once };
|
|
@@ -11750,11 +12046,11 @@ function useEventListener(eventName, handler, element, options) {
|
|
|
11750
12046
|
}, [eventName, element, capture, passive, once]);
|
|
11751
12047
|
}
|
|
11752
12048
|
function useClickOutside(ref, handler, events = ["mousedown", "touchstart"]) {
|
|
11753
|
-
const saved =
|
|
12049
|
+
const saved = React36__namespace.default.useRef(handler);
|
|
11754
12050
|
useIsomorphicLayoutEffect(() => {
|
|
11755
12051
|
saved.current = handler;
|
|
11756
12052
|
}, [handler]);
|
|
11757
|
-
|
|
12053
|
+
React36__namespace.default.useEffect(() => {
|
|
11758
12054
|
if (!canUseDOM2) return void 0;
|
|
11759
12055
|
const listener = (e) => {
|
|
11760
12056
|
const el = ref && ref.current;
|
|
@@ -11789,8 +12085,8 @@ function useLocalStorage(key, initialValue) {
|
|
|
11789
12085
|
return initialValue;
|
|
11790
12086
|
}
|
|
11791
12087
|
};
|
|
11792
|
-
const [stored, setStored] =
|
|
11793
|
-
const setValue =
|
|
12088
|
+
const [stored, setStored] = React36__namespace.default.useState(read);
|
|
12089
|
+
const setValue = React36__namespace.default.useCallback(
|
|
11794
12090
|
(value) => {
|
|
11795
12091
|
setStored((prev) => {
|
|
11796
12092
|
const next = typeof value === "function" ? value(prev) : value;
|
|
@@ -11806,8 +12102,8 @@ function useLocalStorage(key, initialValue) {
|
|
|
11806
12102
|
return [stored, setValue];
|
|
11807
12103
|
}
|
|
11808
12104
|
function useCopyToClipboard(timeout = 1500) {
|
|
11809
|
-
const [copied, setCopied] =
|
|
11810
|
-
const copy =
|
|
12105
|
+
const [copied, setCopied] = React36__namespace.default.useState(false);
|
|
12106
|
+
const copy = React36__namespace.default.useCallback(async (text) => {
|
|
11811
12107
|
if (!canUseDOM2 || !navigator.clipboard) {
|
|
11812
12108
|
setCopied(false);
|
|
11813
12109
|
return false;
|
|
@@ -11821,7 +12117,7 @@ function useCopyToClipboard(timeout = 1500) {
|
|
|
11821
12117
|
return false;
|
|
11822
12118
|
}
|
|
11823
12119
|
}, []);
|
|
11824
|
-
|
|
12120
|
+
React36__namespace.default.useEffect(() => {
|
|
11825
12121
|
if (!copied) return void 0;
|
|
11826
12122
|
const t = setTimeout(() => setCopied(false), timeout);
|
|
11827
12123
|
return () => clearTimeout(t);
|
|
@@ -11829,23 +12125,23 @@ function useCopyToClipboard(timeout = 1500) {
|
|
|
11829
12125
|
return { copied, copy };
|
|
11830
12126
|
}
|
|
11831
12127
|
function useDebouncedValue(value, delay = 200) {
|
|
11832
|
-
const [debounced, setDebounced] =
|
|
11833
|
-
|
|
12128
|
+
const [debounced, setDebounced] = React36__namespace.default.useState(value);
|
|
12129
|
+
React36__namespace.default.useEffect(() => {
|
|
11834
12130
|
const t = setTimeout(() => setDebounced(value), delay);
|
|
11835
12131
|
return () => clearTimeout(t);
|
|
11836
12132
|
}, [value, delay]);
|
|
11837
12133
|
return debounced;
|
|
11838
12134
|
}
|
|
11839
12135
|
function useDebouncedCallback(callback, delay = 200) {
|
|
11840
|
-
const saved =
|
|
11841
|
-
const timer =
|
|
12136
|
+
const saved = React36__namespace.default.useRef(callback);
|
|
12137
|
+
const timer = React36__namespace.default.useRef(null);
|
|
11842
12138
|
useIsomorphicLayoutEffect(() => {
|
|
11843
12139
|
saved.current = callback;
|
|
11844
12140
|
}, [callback]);
|
|
11845
|
-
|
|
12141
|
+
React36__namespace.default.useEffect(() => () => {
|
|
11846
12142
|
if (timer.current) clearTimeout(timer.current);
|
|
11847
12143
|
}, []);
|
|
11848
|
-
return
|
|
12144
|
+
return React36__namespace.default.useCallback(
|
|
11849
12145
|
(...args) => {
|
|
11850
12146
|
if (timer.current) clearTimeout(timer.current);
|
|
11851
12147
|
timer.current = setTimeout(() => saved.current(...args), delay);
|
|
@@ -11854,33 +12150,33 @@ function useDebouncedCallback(callback, delay = 200) {
|
|
|
11854
12150
|
);
|
|
11855
12151
|
}
|
|
11856
12152
|
function useInterval(callback, delay) {
|
|
11857
|
-
const saved =
|
|
12153
|
+
const saved = React36__namespace.default.useRef(callback);
|
|
11858
12154
|
useIsomorphicLayoutEffect(() => {
|
|
11859
12155
|
saved.current = callback;
|
|
11860
12156
|
}, [callback]);
|
|
11861
|
-
|
|
12157
|
+
React36__namespace.default.useEffect(() => {
|
|
11862
12158
|
if (delay == null) return void 0;
|
|
11863
12159
|
const id = setInterval(() => saved.current(), delay);
|
|
11864
12160
|
return () => clearInterval(id);
|
|
11865
12161
|
}, [delay]);
|
|
11866
12162
|
}
|
|
11867
12163
|
function useTimeout(callback, delay) {
|
|
11868
|
-
const saved =
|
|
12164
|
+
const saved = React36__namespace.default.useRef(callback);
|
|
11869
12165
|
useIsomorphicLayoutEffect(() => {
|
|
11870
12166
|
saved.current = callback;
|
|
11871
12167
|
}, [callback]);
|
|
11872
|
-
|
|
12168
|
+
React36__namespace.default.useEffect(() => {
|
|
11873
12169
|
if (delay == null) return void 0;
|
|
11874
12170
|
const id = setTimeout(() => saved.current(), delay);
|
|
11875
12171
|
return () => clearTimeout(id);
|
|
11876
12172
|
}, [delay]);
|
|
11877
12173
|
}
|
|
11878
12174
|
function useWindowSize() {
|
|
11879
|
-
const [size, setSize] =
|
|
12175
|
+
const [size, setSize] = React36__namespace.default.useState(() => ({
|
|
11880
12176
|
width: canUseDOM2 ? window.innerWidth : 0,
|
|
11881
12177
|
height: canUseDOM2 ? window.innerHeight : 0
|
|
11882
12178
|
}));
|
|
11883
|
-
|
|
12179
|
+
React36__namespace.default.useEffect(() => {
|
|
11884
12180
|
if (!canUseDOM2) return void 0;
|
|
11885
12181
|
const onResize = () => setSize({ width: window.innerWidth, height: window.innerHeight });
|
|
11886
12182
|
onResize();
|
|
@@ -11890,8 +12186,8 @@ function useWindowSize() {
|
|
|
11890
12186
|
return size;
|
|
11891
12187
|
}
|
|
11892
12188
|
function useHover(ref) {
|
|
11893
|
-
const [hovered, setHovered] =
|
|
11894
|
-
|
|
12189
|
+
const [hovered, setHovered] = React36__namespace.default.useState(false);
|
|
12190
|
+
React36__namespace.default.useEffect(() => {
|
|
11895
12191
|
const el = ref && ref.current;
|
|
11896
12192
|
if (!el) return void 0;
|
|
11897
12193
|
const on = () => setHovered(true);
|
|
@@ -11907,8 +12203,8 @@ function useHover(ref) {
|
|
|
11907
12203
|
}
|
|
11908
12204
|
function useIntersectionObserver(ref, options = {}) {
|
|
11909
12205
|
const { root = null, rootMargin = "0px", threshold = 0 } = options;
|
|
11910
|
-
const [entry, setEntry] =
|
|
11911
|
-
|
|
12206
|
+
const [entry, setEntry] = React36__namespace.default.useState(null);
|
|
12207
|
+
React36__namespace.default.useEffect(() => {
|
|
11912
12208
|
const el = ref && ref.current;
|
|
11913
12209
|
if (!canUseDOM2 || !el || typeof IntersectionObserver === "undefined") return void 0;
|
|
11914
12210
|
const obs = new IntersectionObserver(([e]) => setEntry(e), { root, rootMargin, threshold });
|
|
@@ -11918,7 +12214,7 @@ function useIntersectionObserver(ref, options = {}) {
|
|
|
11918
12214
|
return entry;
|
|
11919
12215
|
}
|
|
11920
12216
|
function useId(prefix = "twc") {
|
|
11921
|
-
const raw =
|
|
12217
|
+
const raw = React36__namespace.default.useId();
|
|
11922
12218
|
return prefix ? `${prefix}-${raw.replace(/:/g, "")}` : raw;
|
|
11923
12219
|
}
|
|
11924
12220
|
var useFocusTrap2 = useFocusTrap;
|
|
@@ -11927,6 +12223,7 @@ var useScrollLock2 = useScrollLock;
|
|
|
11927
12223
|
|
|
11928
12224
|
exports.Accordion = Accordion;
|
|
11929
12225
|
exports.Alert = Alert;
|
|
12226
|
+
exports.Anchor = Anchor;
|
|
11930
12227
|
exports.AppShell = AppShell;
|
|
11931
12228
|
exports.Avatar = Avatar;
|
|
11932
12229
|
exports.AvatarMenu = AvatarMenu;
|
|
@@ -11940,6 +12237,7 @@ exports.Chart = Chart;
|
|
|
11940
12237
|
exports.Checkbox = Checkbox;
|
|
11941
12238
|
exports.Code = Code;
|
|
11942
12239
|
exports.ColorPicker = ColorPicker;
|
|
12240
|
+
exports.ColorSchemeScript = ColorSchemeScript;
|
|
11943
12241
|
exports.Combobox = Combobox;
|
|
11944
12242
|
exports.CommandPalette = CommandPalette;
|
|
11945
12243
|
exports.Container = Container;
|
|
@@ -11954,17 +12252,23 @@ exports.Drawer = Drawer;
|
|
|
11954
12252
|
exports.EmptyState = EmptyState;
|
|
11955
12253
|
exports.Field = Field;
|
|
11956
12254
|
exports.FileUpload = FileUpload;
|
|
12255
|
+
exports.Form = Form;
|
|
11957
12256
|
exports.Grid = Grid;
|
|
11958
12257
|
exports.Heading = Heading;
|
|
11959
12258
|
exports.IconButton = IconButton;
|
|
12259
|
+
exports.Image = Image;
|
|
11960
12260
|
exports.Input = Input;
|
|
11961
12261
|
exports.Kanban = Kanban;
|
|
12262
|
+
exports.Kbd = Kbd;
|
|
12263
|
+
exports.Label = Label;
|
|
11962
12264
|
exports.List = List;
|
|
11963
12265
|
exports.Menu = Menu;
|
|
11964
12266
|
exports.MultiSelect = MultiSelect;
|
|
11965
12267
|
exports.Navbar = Navbar;
|
|
11966
12268
|
exports.Pagination = Pagination;
|
|
11967
12269
|
exports.Popover = Popover;
|
|
12270
|
+
exports.Portal = Portal;
|
|
12271
|
+
exports.Pre = Pre;
|
|
11968
12272
|
exports.Progress = Progress;
|
|
11969
12273
|
exports.Radio = Radio;
|
|
11970
12274
|
exports.RadioGroup = RadioGroup;
|
|
@@ -11983,12 +12287,17 @@ exports.Tabs = Tabs;
|
|
|
11983
12287
|
exports.Tag = Tag;
|
|
11984
12288
|
exports.Text = Text;
|
|
11985
12289
|
exports.Textarea = Textarea;
|
|
12290
|
+
exports.ThemeProvider = ThemeProvider;
|
|
11986
12291
|
exports.Timeline = Timeline;
|
|
11987
12292
|
exports.Toast = Toast;
|
|
11988
12293
|
exports.ToastProvider = ToastProvider;
|
|
11989
12294
|
exports.ToastViewport = ToastViewport;
|
|
11990
12295
|
exports.Tooltip = Tooltip;
|
|
11991
12296
|
exports.TreeView = TreeView;
|
|
12297
|
+
exports.TwicoProvider = TwicoProvider;
|
|
12298
|
+
exports.VisuallyHidden = VisuallyHidden;
|
|
12299
|
+
exports.createTheme = createTheme;
|
|
12300
|
+
exports.getColorSchemeScript = getColorSchemeScript;
|
|
11992
12301
|
exports.runDatatableQuery = runDatatableQuery;
|
|
11993
12302
|
exports.useClickOutside = useClickOutside;
|
|
11994
12303
|
exports.useColorScheme = useColorScheme;
|