@bigtablet/design-system 3.21.0 → 3.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +10 -1
- package/dist/index.js +374 -222
- package/dist/vanilla/bigtablet.min.js +12 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import './index.css';
|
|
3
|
-
import * as
|
|
3
|
+
import * as React20 from 'react';
|
|
4
4
|
import { createContext, useState, useRef, useCallback, useEffect, useMemo, useContext, useId, Fragment, useImperativeHandle, useLayoutEffect } from 'react';
|
|
5
5
|
import { useSpring, animated } from '@react-spring/web';
|
|
6
6
|
import { ChevronDown, ChevronRight, Globe, ChevronLeft, EyeOff, Eye, ArrowUp, ArrowDown, ArrowUpDown, Search, XCircle, AlertTriangle, CheckCircle2, Info, Bell, Check, Image, X, TriangleAlert } from 'lucide-react';
|
|
@@ -58,11 +58,11 @@ function registerOverlay(onEscape) {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
function useOverlayEscape(active, onEscape) {
|
|
61
|
-
const handlerRef =
|
|
62
|
-
|
|
61
|
+
const handlerRef = React20.useRef(onEscape);
|
|
62
|
+
React20.useEffect(() => {
|
|
63
63
|
handlerRef.current = onEscape;
|
|
64
64
|
});
|
|
65
|
-
|
|
65
|
+
React20.useEffect(() => {
|
|
66
66
|
if (!active) return;
|
|
67
67
|
return registerOverlay(() => handlerRef.current());
|
|
68
68
|
}, [active]);
|
|
@@ -71,6 +71,11 @@ function useOverlayEscape(active, onEscape) {
|
|
|
71
71
|
// src/utils/scroll-lock.ts
|
|
72
72
|
var COUNTER = "openModals";
|
|
73
73
|
var PREV_OVERFLOW = "originalOverflow";
|
|
74
|
+
var PREV_OVERFLOW_X = "originalOverflowX";
|
|
75
|
+
var PREV_OVERFLOW_Y = "originalOverflowY";
|
|
76
|
+
var PREV_HTML_OVERFLOW = "originalHtmlOverflow";
|
|
77
|
+
var PREV_HTML_OVERFLOW_X = "originalHtmlOverflowX";
|
|
78
|
+
var PREV_HTML_OVERFLOW_Y = "originalHtmlOverflowY";
|
|
74
79
|
var PREV_GUTTER = "originalScrollbarGutter";
|
|
75
80
|
var PREV_PADDING_RIGHT = "originalPaddingRight";
|
|
76
81
|
var PREV_SCROLLBAR_WIDTH_VAR = "originalScrollbarWidthVar";
|
|
@@ -101,6 +106,11 @@ function lockBodyScroll() {
|
|
|
101
106
|
if (open === 0) {
|
|
102
107
|
const inset = measureViewportInset();
|
|
103
108
|
body.dataset[PREV_OVERFLOW] = body.style.overflow;
|
|
109
|
+
body.dataset[PREV_OVERFLOW_X] = body.style.overflowX;
|
|
110
|
+
body.dataset[PREV_OVERFLOW_Y] = body.style.overflowY;
|
|
111
|
+
body.dataset[PREV_HTML_OVERFLOW] = html.style.overflow;
|
|
112
|
+
body.dataset[PREV_HTML_OVERFLOW_X] = html.style.overflowX;
|
|
113
|
+
body.dataset[PREV_HTML_OVERFLOW_Y] = html.style.overflowY;
|
|
104
114
|
body.dataset[PREV_GUTTER] = html.style.scrollbarGutter;
|
|
105
115
|
body.dataset[PREV_PADDING_RIGHT] = body.style.paddingRight;
|
|
106
116
|
body.dataset[PREV_SCROLLBAR_WIDTH_VAR] = html.style.getPropertyValue(SCROLLBAR_WIDTH_VAR);
|
|
@@ -108,6 +118,7 @@ function lockBodyScroll() {
|
|
|
108
118
|
html.style.setProperty(SCROLLBAR_WIDTH_VAR, `${inset}px`);
|
|
109
119
|
}
|
|
110
120
|
body.style.overflow = "hidden";
|
|
121
|
+
html.style.overflow = "hidden";
|
|
111
122
|
if (inset > 0) {
|
|
112
123
|
html.style.scrollbarGutter = "auto";
|
|
113
124
|
const current = Number.parseFloat(window.getComputedStyle(body).paddingRight) || 0;
|
|
@@ -128,12 +139,22 @@ function unlockBodyScroll() {
|
|
|
128
139
|
const remaining = Number.parseInt(body.dataset[COUNTER] || "1", 10) - 1;
|
|
129
140
|
if (remaining <= 0) {
|
|
130
141
|
body.style.overflow = body.dataset[PREV_OVERFLOW] || "";
|
|
142
|
+
body.style.overflowX = body.dataset[PREV_OVERFLOW_X] || "";
|
|
143
|
+
body.style.overflowY = body.dataset[PREV_OVERFLOW_Y] || "";
|
|
144
|
+
html.style.overflow = body.dataset[PREV_HTML_OVERFLOW] || "";
|
|
145
|
+
html.style.overflowX = body.dataset[PREV_HTML_OVERFLOW_X] || "";
|
|
146
|
+
html.style.overflowY = body.dataset[PREV_HTML_OVERFLOW_Y] || "";
|
|
131
147
|
body.style.paddingRight = body.dataset[PREV_PADDING_RIGHT] || "";
|
|
132
148
|
html.style.scrollbarGutter = body.dataset[PREV_GUTTER] || "";
|
|
133
149
|
html.removeAttribute(LOCKED_ATTR);
|
|
134
150
|
restoreScrollbarWidthVar(html, body);
|
|
135
151
|
delete body.dataset[COUNTER];
|
|
136
152
|
delete body.dataset[PREV_OVERFLOW];
|
|
153
|
+
delete body.dataset[PREV_OVERFLOW_X];
|
|
154
|
+
delete body.dataset[PREV_OVERFLOW_Y];
|
|
155
|
+
delete body.dataset[PREV_HTML_OVERFLOW];
|
|
156
|
+
delete body.dataset[PREV_HTML_OVERFLOW_X];
|
|
157
|
+
delete body.dataset[PREV_HTML_OVERFLOW_Y];
|
|
137
158
|
delete body.dataset[PREV_GUTTER];
|
|
138
159
|
delete body.dataset[PREV_PADDING_RIGHT];
|
|
139
160
|
delete body.dataset[PREV_SCROLLBAR_WIDTH_VAR];
|
|
@@ -248,7 +269,7 @@ function useAnchoredPosition({
|
|
|
248
269
|
gap,
|
|
249
270
|
padding
|
|
250
271
|
}) {
|
|
251
|
-
const [state, setState] =
|
|
272
|
+
const [state, setState] = React20.useState({
|
|
252
273
|
x: 0,
|
|
253
274
|
y: 0,
|
|
254
275
|
placement,
|
|
@@ -318,8 +339,8 @@ var FOCUSABLE_SELECTORS = [
|
|
|
318
339
|
'[tabindex]:not([tabindex="-1"])'
|
|
319
340
|
].join(", ");
|
|
320
341
|
function useFocusTrap(containerRef, isActive) {
|
|
321
|
-
const previousActiveElement =
|
|
322
|
-
|
|
342
|
+
const previousActiveElement = React20.useRef(null);
|
|
343
|
+
React20.useEffect(() => {
|
|
323
344
|
if (!isActive) return;
|
|
324
345
|
const container = containerRef.current;
|
|
325
346
|
if (!container) return;
|
|
@@ -358,9 +379,9 @@ function useFocusTrap(containerRef, isActive) {
|
|
|
358
379
|
}
|
|
359
380
|
}
|
|
360
381
|
};
|
|
361
|
-
|
|
382
|
+
container.addEventListener("keydown", handleKeyDown2);
|
|
362
383
|
return () => {
|
|
363
|
-
|
|
384
|
+
container.removeEventListener("keydown", handleKeyDown2);
|
|
364
385
|
if (wasTabIndexAdded) {
|
|
365
386
|
container.removeAttribute("tabindex");
|
|
366
387
|
}
|
|
@@ -369,8 +390,8 @@ function useFocusTrap(containerRef, isActive) {
|
|
|
369
390
|
}, [isActive, containerRef]);
|
|
370
391
|
}
|
|
371
392
|
function useIsMounted() {
|
|
372
|
-
const [mounted, setMounted] =
|
|
373
|
-
|
|
393
|
+
const [mounted, setMounted] = React20.useState(false);
|
|
394
|
+
React20.useEffect(() => {
|
|
374
395
|
setMounted(true);
|
|
375
396
|
}, []);
|
|
376
397
|
return mounted;
|
|
@@ -404,13 +425,13 @@ function getServerSnapshot() {
|
|
|
404
425
|
return false;
|
|
405
426
|
}
|
|
406
427
|
function useReducedMotion() {
|
|
407
|
-
return
|
|
428
|
+
return React20.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
408
429
|
}
|
|
409
430
|
function useSpringHover({
|
|
410
431
|
scale = 1.02,
|
|
411
432
|
lift = -2
|
|
412
433
|
} = {}) {
|
|
413
|
-
const [hovered, setHovered] =
|
|
434
|
+
const [hovered, setHovered] = React20.useState(false);
|
|
414
435
|
const reduced = useReducedMotion();
|
|
415
436
|
const style = useSpring({
|
|
416
437
|
transform: hovered ? `translateY(${lift}px) scale(${scale})` : "translateY(0px) scale(1)",
|
|
@@ -471,6 +492,7 @@ function useListboxPopup({
|
|
|
471
492
|
}) {
|
|
472
493
|
const [isOpen, setIsOpen] = useState(false);
|
|
473
494
|
const [activeIndex, setActiveIndex] = useState(-1);
|
|
495
|
+
const pendingActiveRef = useRef(null);
|
|
474
496
|
const wrapperRef = useRef(null);
|
|
475
497
|
const triggerRef = useRef(null);
|
|
476
498
|
const listRef = useRef(null);
|
|
@@ -480,6 +502,7 @@ function useListboxPopup({
|
|
|
480
502
|
if (returnFocusOnClose) triggerRef.current?.focus();
|
|
481
503
|
}, [returnFocusOnClose]);
|
|
482
504
|
useEffect(() => {
|
|
505
|
+
if (!isOpen) return;
|
|
483
506
|
const handleOutsideClick = (event) => {
|
|
484
507
|
const target = event.target;
|
|
485
508
|
if (wrapperRef.current?.contains(target) || panelRef.current?.contains(target)) return;
|
|
@@ -487,7 +510,7 @@ function useListboxPopup({
|
|
|
487
510
|
};
|
|
488
511
|
document.addEventListener("mousedown", handleOutsideClick);
|
|
489
512
|
return () => document.removeEventListener("mousedown", handleOutsideClick);
|
|
490
|
-
}, []);
|
|
513
|
+
}, [isOpen]);
|
|
491
514
|
const moveActive = useCallback(
|
|
492
515
|
(dir) => {
|
|
493
516
|
if (items.length === 0) return;
|
|
@@ -543,11 +566,13 @@ function useListboxPopup({
|
|
|
543
566
|
break;
|
|
544
567
|
case "Home":
|
|
545
568
|
event.preventDefault();
|
|
569
|
+
if (!isOpen) pendingActiveRef.current = firstEnabled();
|
|
546
570
|
setIsOpen(true);
|
|
547
571
|
setActiveIndex(firstEnabled());
|
|
548
572
|
break;
|
|
549
573
|
case "End":
|
|
550
574
|
event.preventDefault();
|
|
575
|
+
if (!isOpen) pendingActiveRef.current = lastEnabled();
|
|
551
576
|
setIsOpen(true);
|
|
552
577
|
setActiveIndex(lastEnabled());
|
|
553
578
|
break;
|
|
@@ -592,9 +617,23 @@ function useListboxPopup({
|
|
|
592
617
|
);
|
|
593
618
|
useEffect(() => {
|
|
594
619
|
if (!isOpen) return;
|
|
620
|
+
const pending = pendingActiveRef.current;
|
|
621
|
+
pendingActiveRef.current = null;
|
|
622
|
+
if (pending !== null && pending >= 0) {
|
|
623
|
+
setActiveIndex(pending);
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
595
626
|
const preferred = initialActiveIndex?.(items) ?? -1;
|
|
596
627
|
setActiveIndex(preferred >= 0 ? preferred : items.findIndex((o) => !o.disabled));
|
|
597
|
-
}, [isOpen
|
|
628
|
+
}, [isOpen]);
|
|
629
|
+
useEffect(() => {
|
|
630
|
+
if (!isOpen) return;
|
|
631
|
+
setActiveIndex((current) => {
|
|
632
|
+
if (current >= 0 && current < items.length && !items[current]?.disabled) return current;
|
|
633
|
+
const preferred = initialActiveIndex?.(items) ?? -1;
|
|
634
|
+
return preferred >= 0 ? preferred : items.findIndex((o) => !o.disabled);
|
|
635
|
+
});
|
|
636
|
+
}, [isOpen, items, initialActiveIndex]);
|
|
598
637
|
useEffect(() => {
|
|
599
638
|
if (!isOpen || activeIndex < 0) return;
|
|
600
639
|
const list = listRef.current;
|
|
@@ -663,19 +702,19 @@ var Accordion = ({
|
|
|
663
702
|
...props
|
|
664
703
|
}) => {
|
|
665
704
|
const isControlled = controlledKeys !== void 0;
|
|
666
|
-
const [internalKeys, setInternalKeys] =
|
|
705
|
+
const [internalKeys, setInternalKeys] = React20.useState(defaultOpenKeys);
|
|
667
706
|
const open = isControlled ? controlledKeys ?? [] : internalKeys;
|
|
668
|
-
const idPrefix =
|
|
707
|
+
const idPrefix = React20.useId();
|
|
669
708
|
const toggle = (key) => {
|
|
670
709
|
const isOpen = open.includes(key);
|
|
671
710
|
const next = isOpen ? open.filter((k) => k !== key) : multiple ? [...open, key] : [key];
|
|
672
711
|
if (!isControlled) setInternalKeys(next);
|
|
673
712
|
(onValueChange ?? onChange)?.(next);
|
|
674
713
|
};
|
|
675
|
-
return /* @__PURE__ */ jsx("div", { className: cn("accordion", className), ...props, children: items.map((item) => {
|
|
714
|
+
return /* @__PURE__ */ jsx("div", { className: cn("accordion", className), ...props, children: items.map((item, index) => {
|
|
676
715
|
const isOpen = open.includes(item.key);
|
|
677
|
-
const headerId = `${idPrefix}-${
|
|
678
|
-
const panelId = `${idPrefix}-${
|
|
716
|
+
const headerId = `${idPrefix}-${index}-header`;
|
|
717
|
+
const panelId = `${idPrefix}-${index}-panel`;
|
|
679
718
|
return /* @__PURE__ */ jsxs("div", { className: cn("accordion_item", isOpen && "accordion_item_open"), children: [
|
|
680
719
|
/* @__PURE__ */ jsx("h3", { className: "accordion_header", children: /* @__PURE__ */ jsxs(
|
|
681
720
|
"button",
|
|
@@ -731,8 +770,8 @@ var Avatar = ({
|
|
|
731
770
|
style,
|
|
732
771
|
...props
|
|
733
772
|
}) => {
|
|
734
|
-
const [
|
|
735
|
-
const showImage = src &&
|
|
773
|
+
const [failedSrc, setFailedSrc] = React20.useState(null);
|
|
774
|
+
const showImage = src && failedSrc !== src;
|
|
736
775
|
const initials = getInitials(name);
|
|
737
776
|
return /* @__PURE__ */ jsx(
|
|
738
777
|
"span",
|
|
@@ -745,7 +784,7 @@ var Avatar = ({
|
|
|
745
784
|
...props,
|
|
746
785
|
children: showImage ? (
|
|
747
786
|
// biome-ignore lint/performance/noImgElement: DS is framework-agnostic - consumers wrap with next/image
|
|
748
|
-
/* @__PURE__ */ jsx("img", { src, alt: name, onError: () =>
|
|
787
|
+
/* @__PURE__ */ jsx("img", { src, alt: name, onError: () => setFailedSrc(src ?? null), className: "avatar_image" })
|
|
749
788
|
) : /* @__PURE__ */ jsx("span", { className: "avatar_initials", "aria-hidden": "true", children: initials })
|
|
750
789
|
}
|
|
751
790
|
);
|
|
@@ -1199,11 +1238,11 @@ var Breadcrumb = ({
|
|
|
1199
1238
|
};
|
|
1200
1239
|
var MENU_GAP = 4;
|
|
1201
1240
|
var Menu = ({ items, trigger, align = "start" }) => {
|
|
1202
|
-
const [open, setOpen] =
|
|
1203
|
-
const wrapperRef =
|
|
1204
|
-
const menuRef =
|
|
1205
|
-
const itemRefs =
|
|
1206
|
-
const menuId =
|
|
1241
|
+
const [open, setOpen] = React20.useState(false);
|
|
1242
|
+
const wrapperRef = React20.useRef(null);
|
|
1243
|
+
const menuRef = React20.useRef(null);
|
|
1244
|
+
const itemRefs = React20.useRef([]);
|
|
1245
|
+
const menuId = React20.useId();
|
|
1207
1246
|
const pos = useAnchoredPosition({
|
|
1208
1247
|
open,
|
|
1209
1248
|
anchorRef: wrapperRef,
|
|
@@ -1213,7 +1252,7 @@ var Menu = ({ items, trigger, align = "start" }) => {
|
|
|
1213
1252
|
gap: MENU_GAP,
|
|
1214
1253
|
padding: 8
|
|
1215
1254
|
});
|
|
1216
|
-
|
|
1255
|
+
React20.useEffect(() => {
|
|
1217
1256
|
if (!open || !pos.ready || !pos.anchorHidden) return;
|
|
1218
1257
|
const focusInMenu = !!menuRef.current?.contains(document.activeElement);
|
|
1219
1258
|
setOpen(false);
|
|
@@ -1225,7 +1264,7 @@ var Menu = ({ items, trigger, align = "start" }) => {
|
|
|
1225
1264
|
visible: open,
|
|
1226
1265
|
from: pos.placement === "top" ? `translateY(${MENU_GAP}px)` : `translateY(-${MENU_GAP}px)`
|
|
1227
1266
|
});
|
|
1228
|
-
|
|
1267
|
+
React20.useEffect(() => {
|
|
1229
1268
|
if (!open) return;
|
|
1230
1269
|
const handleClick = (e) => {
|
|
1231
1270
|
const target = e.target;
|
|
@@ -1242,7 +1281,7 @@ var Menu = ({ items, trigger, align = "start" }) => {
|
|
|
1242
1281
|
document.removeEventListener("keydown", handleEsc);
|
|
1243
1282
|
};
|
|
1244
1283
|
}, [open]);
|
|
1245
|
-
|
|
1284
|
+
React20.useEffect(() => {
|
|
1246
1285
|
const active = document.activeElement;
|
|
1247
1286
|
if (!open || active && itemRefs.current.includes(active)) return;
|
|
1248
1287
|
const first = items.findIndex((it) => !it.disabled);
|
|
@@ -1289,7 +1328,7 @@ var Menu = ({ items, trigger, align = "start" }) => {
|
|
|
1289
1328
|
break;
|
|
1290
1329
|
}
|
|
1291
1330
|
};
|
|
1292
|
-
const triggerWithProps =
|
|
1331
|
+
const triggerWithProps = React20.cloneElement(
|
|
1293
1332
|
trigger,
|
|
1294
1333
|
{
|
|
1295
1334
|
onClick: () => setOpen((o) => !o),
|
|
@@ -1336,6 +1375,7 @@ var Menu = ({ items, trigger, align = "start" }) => {
|
|
|
1336
1375
|
),
|
|
1337
1376
|
onClick: () => {
|
|
1338
1377
|
if (item.disabled) return;
|
|
1378
|
+
wrapperRef.current?.querySelector("[aria-haspopup]")?.focus();
|
|
1339
1379
|
item.onSelect?.();
|
|
1340
1380
|
setOpen(false);
|
|
1341
1381
|
},
|
|
@@ -1387,7 +1427,9 @@ var NavBar = ({
|
|
|
1387
1427
|
mo.observe(links, {
|
|
1388
1428
|
subtree: true,
|
|
1389
1429
|
attributes: true,
|
|
1390
|
-
attributeFilter: ["class", "aria-current"]
|
|
1430
|
+
attributeFilter: ["class", "aria-current"],
|
|
1431
|
+
childList: true,
|
|
1432
|
+
characterData: true
|
|
1391
1433
|
});
|
|
1392
1434
|
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : null;
|
|
1393
1435
|
ro?.observe(links);
|
|
@@ -1498,11 +1540,13 @@ var LocaleSwitcher = ({ locale }) => {
|
|
|
1498
1540
|
wrapperRef.current?.querySelector("[aria-haspopup]")?.focus();
|
|
1499
1541
|
break;
|
|
1500
1542
|
case "Tab":
|
|
1543
|
+
wrapperRef.current?.querySelector("[aria-haspopup]")?.focus();
|
|
1501
1544
|
setOpen(false);
|
|
1502
1545
|
break;
|
|
1503
1546
|
}
|
|
1504
1547
|
};
|
|
1505
1548
|
const handleSelect = (value) => {
|
|
1549
|
+
wrapperRef.current?.querySelector("[aria-haspopup]")?.focus();
|
|
1506
1550
|
(locale.onValueChange ?? locale.onChange)?.(value);
|
|
1507
1551
|
setOpen(false);
|
|
1508
1552
|
};
|
|
@@ -1578,9 +1622,9 @@ var Sidebar = ({
|
|
|
1578
1622
|
const t = useLocaleText();
|
|
1579
1623
|
const toggleLabel = toggleLabelProp ?? t("sidebar.toggle");
|
|
1580
1624
|
const isControlled = collapsedProp !== void 0;
|
|
1581
|
-
const [internalCollapsed, setInternalCollapsed] =
|
|
1625
|
+
const [internalCollapsed, setInternalCollapsed] = React20.useState(defaultCollapsed);
|
|
1582
1626
|
const collapsed = isControlled ? collapsedProp : internalCollapsed;
|
|
1583
|
-
const toggle =
|
|
1627
|
+
const toggle = React20.useCallback(() => {
|
|
1584
1628
|
const next = !collapsed;
|
|
1585
1629
|
if (!isControlled) setInternalCollapsed(next);
|
|
1586
1630
|
onCollapsedChange?.(next);
|
|
@@ -1682,9 +1726,9 @@ var SidebarSection = ({ label, className, children, ...props }) => {
|
|
|
1682
1726
|
children
|
|
1683
1727
|
] });
|
|
1684
1728
|
};
|
|
1685
|
-
var TabsContext =
|
|
1729
|
+
var TabsContext = React20.createContext(null);
|
|
1686
1730
|
function useTabsContext() {
|
|
1687
|
-
const ctx =
|
|
1731
|
+
const ctx = React20.useContext(TabsContext);
|
|
1688
1732
|
if (!ctx) {
|
|
1689
1733
|
throw new Error(
|
|
1690
1734
|
'[Bigtablet DS] <Tab>, <TabList>, <TabPanel>\uC740 \uBC18\uB4DC\uC2DC <Tabs> \uC548\uC5D0 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4.\n\n\uC62C\uBC14\uB978 \uC0AC\uC6A9 \uC608:\n <Tabs defaultValue="a">\n <TabList>\n <Tab value="a">A</Tab>\n </TabList>\n <TabPanel value="a">...</TabPanel>\n </Tabs>'
|
|
@@ -1703,18 +1747,18 @@ var Tabs = ({
|
|
|
1703
1747
|
...props
|
|
1704
1748
|
}) => {
|
|
1705
1749
|
const isControlled = controlledValue !== void 0;
|
|
1706
|
-
const [internalValue, setInternalValue] =
|
|
1750
|
+
const [internalValue, setInternalValue] = React20.useState(defaultValue);
|
|
1707
1751
|
const value = isControlled ? controlledValue : internalValue;
|
|
1708
|
-
const setValue =
|
|
1752
|
+
const setValue = React20.useCallback(
|
|
1709
1753
|
(v) => {
|
|
1710
1754
|
if (!isControlled) setInternalValue(v);
|
|
1711
1755
|
onValueChange?.(v);
|
|
1712
1756
|
},
|
|
1713
1757
|
[isControlled, onValueChange]
|
|
1714
1758
|
);
|
|
1715
|
-
const orderRef =
|
|
1716
|
-
const [firstTabValue, setFirstTabValue] =
|
|
1717
|
-
const registerTab =
|
|
1759
|
+
const orderRef = React20.useRef([]);
|
|
1760
|
+
const [firstTabValue, setFirstTabValue] = React20.useState();
|
|
1761
|
+
const registerTab = React20.useCallback((v) => {
|
|
1718
1762
|
if (!orderRef.current.includes(v)) {
|
|
1719
1763
|
orderRef.current = [...orderRef.current, v];
|
|
1720
1764
|
setFirstTabValue(orderRef.current[0]);
|
|
@@ -1724,8 +1768,8 @@ var Tabs = ({
|
|
|
1724
1768
|
setFirstTabValue(orderRef.current[0]);
|
|
1725
1769
|
};
|
|
1726
1770
|
}, []);
|
|
1727
|
-
const idPrefix =
|
|
1728
|
-
const ctx =
|
|
1771
|
+
const idPrefix = React20.useId();
|
|
1772
|
+
const ctx = React20.useMemo(
|
|
1729
1773
|
() => ({ value, setValue, variant, size, idPrefix, registerTab, firstTabValue }),
|
|
1730
1774
|
[value, setValue, variant, size, idPrefix, registerTab, firstTabValue]
|
|
1731
1775
|
);
|
|
@@ -1740,9 +1784,9 @@ var Tabs = ({
|
|
|
1740
1784
|
};
|
|
1741
1785
|
var TabList = ({ ariaLabel, className, children, ...props }) => {
|
|
1742
1786
|
const { variant } = useTabsContext();
|
|
1743
|
-
const listRef =
|
|
1744
|
-
const [indicator, setIndicator] =
|
|
1745
|
-
const [hasMounted, setHasMounted] =
|
|
1787
|
+
const listRef = React20.useRef(null);
|
|
1788
|
+
const [indicator, setIndicator] = React20.useState(null);
|
|
1789
|
+
const [hasMounted, setHasMounted] = React20.useState(false);
|
|
1746
1790
|
useSafeLayoutEffect(() => {
|
|
1747
1791
|
const list = listRef.current;
|
|
1748
1792
|
if (!list) return;
|
|
@@ -1760,7 +1804,9 @@ var TabList = ({ ariaLabel, className, children, ...props }) => {
|
|
|
1760
1804
|
mo.observe(list, {
|
|
1761
1805
|
subtree: true,
|
|
1762
1806
|
attributes: true,
|
|
1763
|
-
attributeFilter: ["aria-selected"]
|
|
1807
|
+
attributeFilter: ["aria-selected"],
|
|
1808
|
+
childList: true,
|
|
1809
|
+
characterData: true
|
|
1764
1810
|
});
|
|
1765
1811
|
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : null;
|
|
1766
1812
|
ro?.observe(list);
|
|
@@ -1805,7 +1851,7 @@ var Tab = ({ value, className, children, onClick, onKeyDown, ...props }) => {
|
|
|
1805
1851
|
const panelId = `${ctx.idPrefix}-panel-${value}`;
|
|
1806
1852
|
const tabId = `${ctx.idPrefix}-tab-${value}`;
|
|
1807
1853
|
const { registerTab } = ctx;
|
|
1808
|
-
|
|
1854
|
+
React20.useEffect(() => registerTab(value), [registerTab, value]);
|
|
1809
1855
|
const handleClick = (e) => {
|
|
1810
1856
|
ctx.setValue(value);
|
|
1811
1857
|
onClick?.(e);
|
|
@@ -1891,15 +1937,15 @@ var Popover = ({
|
|
|
1891
1937
|
className
|
|
1892
1938
|
}) => {
|
|
1893
1939
|
const isControlled = openProp !== void 0;
|
|
1894
|
-
const [internalOpen, setInternalOpen] =
|
|
1940
|
+
const [internalOpen, setInternalOpen] = React20.useState(defaultOpen);
|
|
1895
1941
|
const open = isControlled ? openProp : internalOpen;
|
|
1896
|
-
const [shouldRender, setShouldRender] =
|
|
1942
|
+
const [shouldRender, setShouldRender] = React20.useState(open ?? false);
|
|
1897
1943
|
if (open && !shouldRender) setShouldRender(true);
|
|
1898
|
-
const wrapperRef =
|
|
1899
|
-
const positionRef =
|
|
1900
|
-
const popoverRef =
|
|
1901
|
-
const popoverId =
|
|
1902
|
-
const setOpen =
|
|
1944
|
+
const wrapperRef = React20.useRef(null);
|
|
1945
|
+
const positionRef = React20.useRef(null);
|
|
1946
|
+
const popoverRef = React20.useRef(null);
|
|
1947
|
+
const popoverId = React20.useId();
|
|
1948
|
+
const setOpen = React20.useCallback(
|
|
1903
1949
|
(next) => {
|
|
1904
1950
|
if (!isControlled) setInternalOpen(next);
|
|
1905
1951
|
onOpenChange?.(next);
|
|
@@ -1932,7 +1978,7 @@ var Popover = ({
|
|
|
1932
1978
|
onExitComplete: () => setShouldRender(false)
|
|
1933
1979
|
});
|
|
1934
1980
|
useFocusTrap(popoverRef, open);
|
|
1935
|
-
|
|
1981
|
+
React20.useEffect(() => {
|
|
1936
1982
|
if (!open) return;
|
|
1937
1983
|
const handleClick = (e) => {
|
|
1938
1984
|
const target = e.target;
|
|
@@ -1946,7 +1992,7 @@ var Popover = ({
|
|
|
1946
1992
|
useOverlayEscape(open, () => {
|
|
1947
1993
|
setOpen(false);
|
|
1948
1994
|
});
|
|
1949
|
-
const triggerWithProps =
|
|
1995
|
+
const triggerWithProps = React20.cloneElement(
|
|
1950
1996
|
trigger,
|
|
1951
1997
|
{
|
|
1952
1998
|
onClick: (e) => {
|
|
@@ -2005,30 +2051,30 @@ var Tooltip = ({
|
|
|
2005
2051
|
disabled = false,
|
|
2006
2052
|
children
|
|
2007
2053
|
}) => {
|
|
2008
|
-
const [open, setOpen] =
|
|
2009
|
-
const [shouldRender, setShouldRender] =
|
|
2054
|
+
const [open, setOpen] = React20.useState(false);
|
|
2055
|
+
const [shouldRender, setShouldRender] = React20.useState(false);
|
|
2010
2056
|
if (open && !shouldRender) setShouldRender(true);
|
|
2011
|
-
const timerRef =
|
|
2012
|
-
const tooltipId =
|
|
2013
|
-
const wrapperRef =
|
|
2014
|
-
const positionRef =
|
|
2057
|
+
const timerRef = React20.useRef(null);
|
|
2058
|
+
const tooltipId = React20.useId();
|
|
2059
|
+
const wrapperRef = React20.useRef(null);
|
|
2060
|
+
const positionRef = React20.useRef(null);
|
|
2015
2061
|
const HIDE_DELAY = 120;
|
|
2016
|
-
const show =
|
|
2062
|
+
const show = React20.useCallback(() => {
|
|
2017
2063
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
2018
2064
|
timerRef.current = setTimeout(() => setOpen(true), delay);
|
|
2019
2065
|
}, [delay]);
|
|
2020
|
-
const hideNow =
|
|
2066
|
+
const hideNow = React20.useCallback(() => {
|
|
2021
2067
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
2022
2068
|
setOpen(false);
|
|
2023
2069
|
}, []);
|
|
2024
|
-
const hide =
|
|
2070
|
+
const hide = React20.useCallback(() => {
|
|
2025
2071
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
2026
2072
|
timerRef.current = setTimeout(() => setOpen(false), HIDE_DELAY);
|
|
2027
2073
|
}, []);
|
|
2028
|
-
const cancelHide =
|
|
2074
|
+
const cancelHide = React20.useCallback(() => {
|
|
2029
2075
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
2030
2076
|
}, []);
|
|
2031
|
-
|
|
2077
|
+
React20.useEffect(() => {
|
|
2032
2078
|
return () => {
|
|
2033
2079
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
2034
2080
|
};
|
|
@@ -2042,7 +2088,7 @@ var Tooltip = ({
|
|
|
2042
2088
|
gap: TOOLTIP_GAP,
|
|
2043
2089
|
padding: 8
|
|
2044
2090
|
});
|
|
2045
|
-
|
|
2091
|
+
React20.useEffect(() => {
|
|
2046
2092
|
if (open && pos.ready && pos.anchorHidden) hideNow();
|
|
2047
2093
|
}, [open, pos.ready, pos.anchorHidden, hideNow]);
|
|
2048
2094
|
const fromTransform = (() => {
|
|
@@ -2064,7 +2110,7 @@ var Tooltip = ({
|
|
|
2064
2110
|
});
|
|
2065
2111
|
const child = children;
|
|
2066
2112
|
const childProps = child.props;
|
|
2067
|
-
const trigger =
|
|
2113
|
+
const trigger = React20.cloneElement(child, {
|
|
2068
2114
|
onMouseEnter: (e) => {
|
|
2069
2115
|
childProps.onMouseEnter?.(e);
|
|
2070
2116
|
show();
|
|
@@ -2903,20 +2949,18 @@ var TextField = ({
|
|
|
2903
2949
|
const clearLabel = clearLabelProp ?? t("textField.clear");
|
|
2904
2950
|
const generatedId = useId();
|
|
2905
2951
|
const field = useFieldControl();
|
|
2906
|
-
const inputId =
|
|
2907
|
-
const helperId = supportingText ? `${
|
|
2908
|
-
const describedBy = field?.describedBy
|
|
2952
|
+
const inputId = field?.inputId ?? id ?? generatedId;
|
|
2953
|
+
const helperId = supportingText ? `${generatedId}-help` : void 0;
|
|
2954
|
+
const describedBy = [field?.describedBy, helperId, props["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
2909
2955
|
const isControlled = value !== void 0;
|
|
2910
2956
|
const applyTransform = (nextValue) => transformValue ? transformValue(nextValue) : nextValue;
|
|
2911
2957
|
const [innerValue, setInnerValue] = useState(() => applyTransform(value ?? defaultValue ?? ""));
|
|
2912
2958
|
const isComposingRef = useRef(false);
|
|
2913
2959
|
const lastEmittedValueRef = useRef(innerValue);
|
|
2914
|
-
const
|
|
2915
|
-
if (isControlled &&
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
setInnerValue(nextValue);
|
|
2919
|
-
lastEmittedValueRef.current = nextValue;
|
|
2960
|
+
const nextControlledValue = applyTransform(value ?? "");
|
|
2961
|
+
if (isControlled && !isComposingRef.current && nextControlledValue !== innerValue) {
|
|
2962
|
+
setInnerValue(nextControlledValue);
|
|
2963
|
+
lastEmittedValueRef.current = nextControlledValue;
|
|
2920
2964
|
}
|
|
2921
2965
|
const emit = useCallback(
|
|
2922
2966
|
(nextValue) => {
|
|
@@ -2988,14 +3032,14 @@ var TextField = ({
|
|
|
2988
3032
|
children: /* @__PURE__ */ jsx(
|
|
2989
3033
|
"input",
|
|
2990
3034
|
{
|
|
3035
|
+
...props,
|
|
2991
3036
|
id: inputId,
|
|
2992
3037
|
ref,
|
|
2993
3038
|
className: cn("text_field_input", identifier && "text_field_input_identifier"),
|
|
2994
|
-
"aria-invalid": isError,
|
|
3039
|
+
"aria-invalid": field ? isError : props["aria-invalid"] ?? isError,
|
|
2995
3040
|
"aria-describedby": describedBy,
|
|
2996
|
-
"aria-required": field
|
|
2997
|
-
"aria-label": !showLabel ? label : void 0,
|
|
2998
|
-
...props,
|
|
3041
|
+
"aria-required": field ? field.required || void 0 : props["aria-required"],
|
|
3042
|
+
"aria-label": (!showLabel ? label : void 0) ?? props["aria-label"],
|
|
2999
3043
|
type: resolvedType,
|
|
3000
3044
|
value: innerValue,
|
|
3001
3045
|
onCompositionStart: () => {
|
|
@@ -3141,7 +3185,7 @@ var Pagination = ({
|
|
|
3141
3185
|
const emit = onPageChange ?? onChange;
|
|
3142
3186
|
const prevDisabled = page <= 1;
|
|
3143
3187
|
const nextDisabled = page >= totalPages;
|
|
3144
|
-
const items =
|
|
3188
|
+
const items = React20.useMemo(() => getPaginationItems(page, totalPages), [page, totalPages]);
|
|
3145
3189
|
return /* @__PURE__ */ jsxs("nav", { className: "pagination", "aria-label": navLabel, children: [
|
|
3146
3190
|
/* @__PURE__ */ jsx(
|
|
3147
3191
|
"button",
|
|
@@ -3221,12 +3265,12 @@ var Checkbox = ({
|
|
|
3221
3265
|
ref,
|
|
3222
3266
|
...props
|
|
3223
3267
|
}) => {
|
|
3224
|
-
const inputRef =
|
|
3225
|
-
|
|
3268
|
+
const inputRef = React20.useRef(null);
|
|
3269
|
+
React20.useImperativeHandle(
|
|
3226
3270
|
ref,
|
|
3227
3271
|
() => inputRef.current
|
|
3228
3272
|
);
|
|
3229
|
-
|
|
3273
|
+
React20.useEffect(() => {
|
|
3230
3274
|
if (!inputRef.current) return;
|
|
3231
3275
|
inputRef.current.indeterminate = Boolean(indeterminate);
|
|
3232
3276
|
}, [indeterminate]);
|
|
@@ -3248,7 +3292,7 @@ var Checkbox = ({
|
|
|
3248
3292
|
id: field?.inputId ?? props.id,
|
|
3249
3293
|
"aria-describedby": field?.describedBy ?? props["aria-describedby"],
|
|
3250
3294
|
"aria-required": field?.required || void 0,
|
|
3251
|
-
"aria-invalid": error || void 0
|
|
3295
|
+
"aria-invalid": error || (field ? field.invalid || void 0 : props["aria-invalid"])
|
|
3252
3296
|
}
|
|
3253
3297
|
),
|
|
3254
3298
|
/* @__PURE__ */ jsx("span", { className: "checkbox_state_layer", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "checkbox_icon" }) }),
|
|
@@ -3290,11 +3334,38 @@ var Table = ({
|
|
|
3290
3334
|
stickyHeader && "table_sticky_header",
|
|
3291
3335
|
className
|
|
3292
3336
|
);
|
|
3337
|
+
const wrapperRef = React20.useRef(null);
|
|
3338
|
+
useSafeLayoutEffect(() => {
|
|
3339
|
+
const el = wrapperRef.current;
|
|
3340
|
+
if (!el) return;
|
|
3341
|
+
const sync = () => {
|
|
3342
|
+
const scrolls = el.scrollWidth > el.clientWidth || el.scrollHeight > el.clientHeight;
|
|
3343
|
+
if (scrolls) el.setAttribute("tabindex", "0");
|
|
3344
|
+
else el.removeAttribute("tabindex");
|
|
3345
|
+
};
|
|
3346
|
+
sync();
|
|
3347
|
+
const resizeObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(sync);
|
|
3348
|
+
resizeObserver?.observe(el);
|
|
3349
|
+
const mutationObserver = typeof MutationObserver === "undefined" ? null : new MutationObserver(() => {
|
|
3350
|
+
sync();
|
|
3351
|
+
});
|
|
3352
|
+
mutationObserver?.observe(el, {
|
|
3353
|
+
childList: true,
|
|
3354
|
+
subtree: true,
|
|
3355
|
+
characterData: true,
|
|
3356
|
+
attributes: true,
|
|
3357
|
+
attributeFilter: ["style", "class"]
|
|
3358
|
+
});
|
|
3359
|
+
return () => {
|
|
3360
|
+
resizeObserver?.disconnect();
|
|
3361
|
+
mutationObserver?.disconnect();
|
|
3362
|
+
};
|
|
3363
|
+
}, []);
|
|
3293
3364
|
const isEmpty = !isLoading && data.length === 0;
|
|
3294
3365
|
const getRowKey = (item, index) => rowKey?.(item) ?? String(index);
|
|
3295
3366
|
const allRowKeys = selectable ? data.map((item, index) => getRowKey(item, index)) : [];
|
|
3296
|
-
const rowClickHintId =
|
|
3297
|
-
const selectedSet =
|
|
3367
|
+
const rowClickHintId = React20.useId();
|
|
3368
|
+
const selectedSet = React20.useMemo(() => new Set(selectedKeys ?? []), [selectedKeys]);
|
|
3298
3369
|
const selectedCount = allRowKeys.filter((key) => selectedSet.has(key)).length;
|
|
3299
3370
|
const isAllSelected = allRowKeys.length > 0 && selectedCount === allRowKeys.length;
|
|
3300
3371
|
const isSomeSelected = selectedCount > 0 && !isAllSelected;
|
|
@@ -3312,7 +3383,7 @@ var Table = ({
|
|
|
3312
3383
|
const next = sort?.key !== key ? { key, direction: "asc" } : sort.direction === "asc" ? { key, direction: "desc" } : void 0;
|
|
3313
3384
|
onSortChange?.(next);
|
|
3314
3385
|
};
|
|
3315
|
-
return /* @__PURE__ */ jsxs("div", { className: wrapperClassName, children: [
|
|
3386
|
+
return /* @__PURE__ */ jsxs("div", { ref: wrapperRef, className: wrapperClassName, children: [
|
|
3316
3387
|
/* @__PURE__ */ jsxs("table", { className: "table", "aria-label": ariaLabel, "aria-busy": isLoading || void 0, children: [
|
|
3317
3388
|
/* @__PURE__ */ jsx("thead", { className: "table_thead", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
3318
3389
|
selectable && /* @__PURE__ */ jsx("th", { scope: "col", className: "table_th table_th_checkbox", children: /* @__PURE__ */ jsx(
|
|
@@ -3484,6 +3555,17 @@ var DataView = ({
|
|
|
3484
3555
|
const selectionBarId = useId();
|
|
3485
3556
|
const selectable = !!selectionActions?.length;
|
|
3486
3557
|
const rows = query.data ?? [];
|
|
3558
|
+
const hasPagination = !!pagination;
|
|
3559
|
+
const needsSelectionPrune = selectable && !hasPagination;
|
|
3560
|
+
const visibleKeySignature = needsSelectionPrune ? JSON.stringify(rows.map(rowKey)) : "";
|
|
3561
|
+
useEffect(() => {
|
|
3562
|
+
if (!needsSelectionPrune) return;
|
|
3563
|
+
const visible = new Set(rows.map(rowKey));
|
|
3564
|
+
setSelectedKeys((prev) => {
|
|
3565
|
+
const next = prev.filter((key) => visible.has(key));
|
|
3566
|
+
return next.length === prev.length ? prev : next;
|
|
3567
|
+
});
|
|
3568
|
+
}, [visibleKeySignature, needsSelectionPrune]);
|
|
3487
3569
|
const showEmpty = !query.isLoading && !query.error && rows.length === 0;
|
|
3488
3570
|
if (query.error) {
|
|
3489
3571
|
return /* @__PURE__ */ jsx("div", { className: cn("data_view", className), ...props, children: /* @__PURE__ */ jsx(
|
|
@@ -3735,25 +3817,44 @@ var MediaCard = ({
|
|
|
3735
3817
|
] });
|
|
3736
3818
|
};
|
|
3737
3819
|
var Prose = ({ size = "md", className, children, ref, ...props }) => {
|
|
3738
|
-
const rootRef =
|
|
3739
|
-
|
|
3820
|
+
const rootRef = React20.useRef(null);
|
|
3821
|
+
React20.useImperativeHandle(ref, () => rootRef.current, []);
|
|
3740
3822
|
useSafeLayoutEffect(() => {
|
|
3741
3823
|
const root = rootRef.current;
|
|
3742
3824
|
if (!root) return;
|
|
3743
|
-
const
|
|
3825
|
+
const hasResizeObserver = typeof ResizeObserver !== "undefined";
|
|
3826
|
+
const observed = /* @__PURE__ */ new Set();
|
|
3827
|
+
let resizeObserver = null;
|
|
3744
3828
|
const sync = () => {
|
|
3829
|
+
const targets = new Set(root.querySelectorAll("pre, table"));
|
|
3830
|
+
for (const el of observed) {
|
|
3831
|
+
if (targets.has(el)) continue;
|
|
3832
|
+
resizeObserver?.unobserve(el);
|
|
3833
|
+
observed.delete(el);
|
|
3834
|
+
}
|
|
3745
3835
|
for (const el of targets) {
|
|
3746
3836
|
if (el.scrollWidth > el.clientWidth) el.setAttribute("tabindex", "0");
|
|
3747
3837
|
else el.removeAttribute("tabindex");
|
|
3838
|
+
if (resizeObserver && !observed.has(el)) {
|
|
3839
|
+
resizeObserver.observe(el);
|
|
3840
|
+
observed.add(el);
|
|
3841
|
+
}
|
|
3748
3842
|
}
|
|
3749
3843
|
};
|
|
3844
|
+
if (hasResizeObserver) {
|
|
3845
|
+
resizeObserver = new ResizeObserver(sync);
|
|
3846
|
+
resizeObserver.observe(root);
|
|
3847
|
+
}
|
|
3750
3848
|
sync();
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
return () =>
|
|
3756
|
-
|
|
3849
|
+
const mutationObserver = typeof MutationObserver === "undefined" ? null : new MutationObserver(() => {
|
|
3850
|
+
sync();
|
|
3851
|
+
});
|
|
3852
|
+
mutationObserver?.observe(root, { childList: true, subtree: true, characterData: true });
|
|
3853
|
+
return () => {
|
|
3854
|
+
resizeObserver?.disconnect();
|
|
3855
|
+
mutationObserver?.disconnect();
|
|
3856
|
+
};
|
|
3857
|
+
}, []);
|
|
3757
3858
|
return /* @__PURE__ */ jsx("div", { ref: rootRef, className: cn("prose", `prose_size_${size}`, className), ...props, children });
|
|
3758
3859
|
};
|
|
3759
3860
|
Prose.displayName = "Prose";
|
|
@@ -3781,6 +3882,9 @@ var AlertProvider = ({ children }) => {
|
|
|
3781
3882
|
const handleClose = useCallback(() => {
|
|
3782
3883
|
setAlertState((prev) => ({ ...prev, isOpen: false }));
|
|
3783
3884
|
}, []);
|
|
3885
|
+
const handleExited = useCallback(() => {
|
|
3886
|
+
setAlertState((prev) => prev.isOpen ? prev : { isOpen: false });
|
|
3887
|
+
}, []);
|
|
3784
3888
|
const handleConfirm = useCallback(() => {
|
|
3785
3889
|
alertState.onConfirm?.();
|
|
3786
3890
|
handleClose();
|
|
@@ -3797,7 +3901,8 @@ var AlertProvider = ({ children }) => {
|
|
|
3797
3901
|
...alertState,
|
|
3798
3902
|
onConfirm: handleConfirm,
|
|
3799
3903
|
onCancel: handleCancel,
|
|
3800
|
-
onClose: handleClose
|
|
3904
|
+
onClose: handleClose,
|
|
3905
|
+
onExited: handleExited
|
|
3801
3906
|
}
|
|
3802
3907
|
)
|
|
3803
3908
|
] });
|
|
@@ -3816,15 +3921,17 @@ var AlertModal = ({
|
|
|
3816
3921
|
closeOnOverlay = true,
|
|
3817
3922
|
onConfirm,
|
|
3818
3923
|
onCancel,
|
|
3819
|
-
onClose
|
|
3924
|
+
onClose,
|
|
3925
|
+
onExited
|
|
3820
3926
|
}) => {
|
|
3821
3927
|
const t = useLocaleText();
|
|
3822
3928
|
const confirmText = confirmTextProp ?? t("alert.confirm");
|
|
3823
3929
|
const cancelText = cancelTextProp ?? t("alert.cancel");
|
|
3824
3930
|
const dismiss = onCancel ?? onClose;
|
|
3825
|
-
const panelRef =
|
|
3826
|
-
const
|
|
3827
|
-
const
|
|
3931
|
+
const panelRef = React20.useRef(null);
|
|
3932
|
+
const pressedOverlayRef = React20.useRef(false);
|
|
3933
|
+
const titleId = React20.useId();
|
|
3934
|
+
const messageId = React20.useId();
|
|
3828
3935
|
const [shouldRender, setShouldRender] = useState(isOpen);
|
|
3829
3936
|
useFocusTrap(panelRef, isOpen);
|
|
3830
3937
|
useOverlayEscape(isOpen, () => dismiss());
|
|
@@ -3836,7 +3943,9 @@ var AlertModal = ({
|
|
|
3836
3943
|
immediate: reduced,
|
|
3837
3944
|
config: OVERLAY_SPRING_CONFIG,
|
|
3838
3945
|
onRest: (result) => {
|
|
3839
|
-
if (
|
|
3946
|
+
if (isOpen || !result.finished) return;
|
|
3947
|
+
setShouldRender(false);
|
|
3948
|
+
onExited?.();
|
|
3840
3949
|
}
|
|
3841
3950
|
});
|
|
3842
3951
|
const panelStyle = useSpring({
|
|
@@ -3848,7 +3957,7 @@ var AlertModal = ({
|
|
|
3848
3957
|
immediate: reduced,
|
|
3849
3958
|
config: OVERLAY_SPRING_CONFIG
|
|
3850
3959
|
});
|
|
3851
|
-
|
|
3960
|
+
React20.useEffect(() => {
|
|
3852
3961
|
if (!shouldRender) return;
|
|
3853
3962
|
lockBodyScroll();
|
|
3854
3963
|
return () => {
|
|
@@ -3866,7 +3975,15 @@ var AlertModal = ({
|
|
|
3866
3975
|
className: "alert_overlay",
|
|
3867
3976
|
style: overlayStyle,
|
|
3868
3977
|
role: "presentation",
|
|
3869
|
-
|
|
3978
|
+
onPointerDown: (e) => {
|
|
3979
|
+
pressedOverlayRef.current = e.target === e.currentTarget;
|
|
3980
|
+
},
|
|
3981
|
+
onClick: (e) => {
|
|
3982
|
+
if (!closeOnOverlay) return;
|
|
3983
|
+
if (e.target !== e.currentTarget) return;
|
|
3984
|
+
if (!pressedOverlayRef.current) return;
|
|
3985
|
+
dismiss();
|
|
3986
|
+
},
|
|
3870
3987
|
children: /* @__PURE__ */ jsxs(
|
|
3871
3988
|
animated.div,
|
|
3872
3989
|
{
|
|
@@ -3923,7 +4040,7 @@ var LinearProgress = ({
|
|
|
3923
4040
|
{
|
|
3924
4041
|
className: cn("linear_progress", className),
|
|
3925
4042
|
role: "progressbar",
|
|
3926
|
-
"aria-valuenow":
|
|
4043
|
+
"aria-valuenow": clampedStep,
|
|
3927
4044
|
"aria-valuemin": 0,
|
|
3928
4045
|
"aria-valuemax": totalSteps,
|
|
3929
4046
|
...props,
|
|
@@ -3959,7 +4076,7 @@ var Spinner = ({ size = 24, ariaLabel: ariaLabelProp }) => {
|
|
|
3959
4076
|
}
|
|
3960
4077
|
);
|
|
3961
4078
|
};
|
|
3962
|
-
var ToastContext =
|
|
4079
|
+
var ToastContext = React20.createContext(null);
|
|
3963
4080
|
var VARIANT_ICONS = {
|
|
3964
4081
|
success: /* @__PURE__ */ jsx(CheckCircle2, { size: iconSize.md }),
|
|
3965
4082
|
error: /* @__PURE__ */ jsx(XCircle, { size: iconSize.md }),
|
|
@@ -3968,9 +4085,9 @@ var VARIANT_ICONS = {
|
|
|
3968
4085
|
default: /* @__PURE__ */ jsx(Bell, { size: iconSize.md })
|
|
3969
4086
|
};
|
|
3970
4087
|
var ToastItemComponent = ({ item, onRemove, closeAriaLabel }) => {
|
|
3971
|
-
const [visible, setVisible] =
|
|
3972
|
-
const closingRef =
|
|
3973
|
-
const rootRef =
|
|
4088
|
+
const [visible, setVisible] = React20.useState(true);
|
|
4089
|
+
const closingRef = React20.useRef(false);
|
|
4090
|
+
const rootRef = React20.useRef(null);
|
|
3974
4091
|
const style = useSpringPresence({
|
|
3975
4092
|
visible,
|
|
3976
4093
|
from: "translateX(20px)",
|
|
@@ -3990,7 +4107,7 @@ var ToastItemComponent = ({ item, onRemove, closeAriaLabel }) => {
|
|
|
3990
4107
|
onRemove(item.id);
|
|
3991
4108
|
}
|
|
3992
4109
|
});
|
|
3993
|
-
const close =
|
|
4110
|
+
const close = React20.useCallback(() => {
|
|
3994
4111
|
if (closingRef.current) return;
|
|
3995
4112
|
closingRef.current = true;
|
|
3996
4113
|
setVisible(false);
|
|
@@ -4019,6 +4136,7 @@ var ToastItemComponent = ({ item, onRemove, closeAriaLabel }) => {
|
|
|
4019
4136
|
}
|
|
4020
4137
|
);
|
|
4021
4138
|
};
|
|
4139
|
+
var toastSeq = 0;
|
|
4022
4140
|
var ToastProvider = ({
|
|
4023
4141
|
children,
|
|
4024
4142
|
maxCount = 5,
|
|
@@ -4028,19 +4146,19 @@ var ToastProvider = ({
|
|
|
4028
4146
|
const t = useLocaleText();
|
|
4029
4147
|
const closeAriaLabel = closeAriaLabelProp ?? t("toast.close");
|
|
4030
4148
|
const regionLabel = regionLabelProp ?? t("toast.region");
|
|
4031
|
-
const [toasts, setToasts] =
|
|
4149
|
+
const [toasts, setToasts] = React20.useState([]);
|
|
4032
4150
|
const isMounted = useIsMounted();
|
|
4033
|
-
const addToast =
|
|
4151
|
+
const addToast = React20.useCallback(
|
|
4034
4152
|
(message, variant, duration = 3e3) => {
|
|
4035
|
-
const id =
|
|
4153
|
+
const id = `toast_${++toastSeq}`;
|
|
4036
4154
|
setToasts((prev) => [{ id, message, variant, duration }, ...prev].slice(0, maxCount));
|
|
4037
4155
|
},
|
|
4038
4156
|
[maxCount]
|
|
4039
4157
|
);
|
|
4040
|
-
const removeToast =
|
|
4158
|
+
const removeToast = React20.useCallback((id) => {
|
|
4041
4159
|
setToasts((prev) => prev.filter((t2) => t2.id !== id));
|
|
4042
4160
|
}, []);
|
|
4043
|
-
const contextValue =
|
|
4161
|
+
const contextValue = React20.useMemo(() => ({ addToast }), [addToast]);
|
|
4044
4162
|
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: contextValue, children: [
|
|
4045
4163
|
children,
|
|
4046
4164
|
isMounted && createPortal(
|
|
@@ -4178,6 +4296,10 @@ var Combobox = ({
|
|
|
4178
4296
|
});
|
|
4179
4297
|
const { isOpen, setIsOpen, close, activeIndex, setActiveIndex } = popup;
|
|
4180
4298
|
closeRef.current = close;
|
|
4299
|
+
const onSearchRef = useRef(onSearch);
|
|
4300
|
+
useEffect(() => {
|
|
4301
|
+
onSearchRef.current = onSearch;
|
|
4302
|
+
});
|
|
4181
4303
|
useEffect(() => {
|
|
4182
4304
|
if (!isOpen) return;
|
|
4183
4305
|
if (query === "") {
|
|
@@ -4190,7 +4312,7 @@ var Combobox = ({
|
|
|
4190
4312
|
const seq = ++requestSeq.current;
|
|
4191
4313
|
setIsLoading(true);
|
|
4192
4314
|
const timer = setTimeout(() => {
|
|
4193
|
-
|
|
4315
|
+
onSearchRef.current(query).then((result) => {
|
|
4194
4316
|
if (seq !== requestSeq.current) return;
|
|
4195
4317
|
setOptions(result);
|
|
4196
4318
|
setHasSearched(true);
|
|
@@ -4204,7 +4326,7 @@ var Combobox = ({
|
|
|
4204
4326
|
});
|
|
4205
4327
|
}, debounceMs);
|
|
4206
4328
|
return () => clearTimeout(timer);
|
|
4207
|
-
}, [query, isOpen, debounceMs
|
|
4329
|
+
}, [query, isOpen, debounceMs]);
|
|
4208
4330
|
const rootClassName = cn(
|
|
4209
4331
|
"combobox",
|
|
4210
4332
|
`combobox_size_${size}`,
|
|
@@ -4641,9 +4763,9 @@ var DatePicker = ({
|
|
|
4641
4763
|
const minDateSrFormat = minDateSrFormatProp ?? t("datePicker.minDateSr");
|
|
4642
4764
|
const selectableRangeUntilTodaySrText = selectableRangeUntilTodaySrTextProp ?? t("datePicker.rangeUntilTodaySr");
|
|
4643
4765
|
const field = useFieldControl();
|
|
4644
|
-
const groupId =
|
|
4645
|
-
const constraintId =
|
|
4646
|
-
const { todayYear, todayMonth, todayDay } =
|
|
4766
|
+
const groupId = React20.useId();
|
|
4767
|
+
const constraintId = React20.useId();
|
|
4768
|
+
const { todayYear, todayMonth, todayDay } = React20.useMemo(() => {
|
|
4647
4769
|
const now = /* @__PURE__ */ new Date();
|
|
4648
4770
|
return {
|
|
4649
4771
|
todayYear: now.getFullYear(),
|
|
@@ -4652,7 +4774,7 @@ var DatePicker = ({
|
|
|
4652
4774
|
};
|
|
4653
4775
|
}, []);
|
|
4654
4776
|
const endYear = endYearProp ?? todayYear + 10;
|
|
4655
|
-
const parsed =
|
|
4777
|
+
const parsed = React20.useMemo(() => {
|
|
4656
4778
|
if (!value) return { year: 0, month: 0, day: 0 };
|
|
4657
4779
|
const [y, m, d] = value.split("-").map(Number);
|
|
4658
4780
|
return {
|
|
@@ -4661,7 +4783,7 @@ var DatePicker = ({
|
|
|
4661
4783
|
day: d || 0
|
|
4662
4784
|
};
|
|
4663
4785
|
}, [value]);
|
|
4664
|
-
const min =
|
|
4786
|
+
const min = React20.useMemo(() => {
|
|
4665
4787
|
if (!minDate) return { year: 0, month: 0, day: 0 };
|
|
4666
4788
|
const [y, m, d] = minDate.split("-").map(Number);
|
|
4667
4789
|
return {
|
|
@@ -4674,56 +4796,79 @@ var DatePicker = ({
|
|
|
4674
4796
|
const maxYear = selectableRange === "until-today" ? todayYear : endYear;
|
|
4675
4797
|
const minMonth = min.year > 0 && year === min.year ? Math.min(12, Math.max(1, min.month)) : 1;
|
|
4676
4798
|
const maxMonth = selectableRange === "until-today" && year === todayYear ? todayMonth : 12;
|
|
4677
|
-
const
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
min.year > 0 && min.month > 0 &&
|
|
4682
|
-
|
|
4799
|
+
const dayBoundsFor = React20.useCallback(
|
|
4800
|
+
(yy, mm) => {
|
|
4801
|
+
if (!yy || !mm) return { min: 1, max: 31 };
|
|
4802
|
+
const daysInMonth = getDaysInMonth(yy, mm);
|
|
4803
|
+
const lo = min.year > 0 && min.month > 0 && yy === min.year && mm === min.month ? Math.min(daysInMonth, Math.max(1, min.day)) : 1;
|
|
4804
|
+
const hi = selectableRange === "until-today" && yy === todayYear && mm === todayMonth ? Math.min(daysInMonth, todayDay) : daysInMonth;
|
|
4805
|
+
return { min: lo, max: hi };
|
|
4806
|
+
},
|
|
4807
|
+
[min.year, min.month, min.day, selectableRange, todayYear, todayMonth, todayDay]
|
|
4683
4808
|
);
|
|
4684
|
-
const maxDay =
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
}
|
|
4690
|
-
return daysInMonth;
|
|
4691
|
-
}, [year, month, selectableRange, todayYear, todayMonth, todayDay]);
|
|
4809
|
+
const { min: minDay, max: maxDay } = React20.useMemo(
|
|
4810
|
+
() => dayBoundsFor(year, month),
|
|
4811
|
+
[dayBoundsFor, year, month]
|
|
4812
|
+
);
|
|
4813
|
+
const hasSelectableDay = maxDay >= minDay;
|
|
4692
4814
|
const minYear = min.year > 0 ? Math.max(startYear, min.year) : startYear;
|
|
4693
|
-
const yearOptions =
|
|
4694
|
-
() => range2(minYear,
|
|
4815
|
+
const yearOptions = React20.useMemo(
|
|
4816
|
+
() => range2(minYear, maxYear).map((y) => ({
|
|
4695
4817
|
value: String(y),
|
|
4696
4818
|
label: String(y)
|
|
4697
4819
|
})),
|
|
4698
4820
|
[minYear, maxYear]
|
|
4699
4821
|
);
|
|
4700
|
-
const monthOptions =
|
|
4701
|
-
() => range2(minMonth,
|
|
4822
|
+
const monthOptions = React20.useMemo(
|
|
4823
|
+
() => range2(minMonth, maxMonth).filter((m) => {
|
|
4824
|
+
const bounds = dayBoundsFor(year, m);
|
|
4825
|
+
return bounds.max >= bounds.min;
|
|
4826
|
+
}).map((m) => ({
|
|
4702
4827
|
value: String(m),
|
|
4703
4828
|
label: pad(m)
|
|
4704
4829
|
})),
|
|
4705
|
-
[minMonth, maxMonth]
|
|
4830
|
+
[minMonth, maxMonth, dayBoundsFor, year]
|
|
4706
4831
|
);
|
|
4707
|
-
const dayOptions =
|
|
4708
|
-
() => range2(minDay,
|
|
4832
|
+
const dayOptions = React20.useMemo(
|
|
4833
|
+
() => hasSelectableDay ? range2(minDay, maxDay).map((d) => ({
|
|
4709
4834
|
value: String(d),
|
|
4710
4835
|
label: pad(d)
|
|
4711
|
-
})),
|
|
4712
|
-
[minDay, maxDay]
|
|
4836
|
+
})) : [],
|
|
4837
|
+
[minDay, maxDay, hasSelectableDay]
|
|
4838
|
+
);
|
|
4839
|
+
const withinRange = React20.useCallback(
|
|
4840
|
+
(yy, mm, dd) => {
|
|
4841
|
+
const point = yy * 1e4 + mm * 100 + dd;
|
|
4842
|
+
if (min.year > 0) {
|
|
4843
|
+
const floor = min.year * 1e4 + Math.max(1, min.month) * 100 + Math.max(1, min.day);
|
|
4844
|
+
if (point < floor) return false;
|
|
4845
|
+
}
|
|
4846
|
+
if (selectableRange === "until-today") {
|
|
4847
|
+
const ceiling = todayYear * 1e4 + todayMonth * 100 + todayDay;
|
|
4848
|
+
if (point > ceiling) return false;
|
|
4849
|
+
}
|
|
4850
|
+
return true;
|
|
4851
|
+
},
|
|
4852
|
+
[min.year, min.month, min.day, selectableRange, todayYear, todayMonth, todayDay]
|
|
4713
4853
|
);
|
|
4714
|
-
const emit =
|
|
4854
|
+
const emit = React20.useCallback(
|
|
4715
4855
|
(yy, mm, dd) => {
|
|
4716
4856
|
const cb = onValueChange ?? onChange;
|
|
4717
4857
|
if (mode === "year-month") {
|
|
4858
|
+
const monthBounds = dayBoundsFor(yy, mm);
|
|
4859
|
+
if (monthBounds.max < monthBounds.min) return;
|
|
4718
4860
|
cb?.(`${yy}-${pad(mm)}`);
|
|
4719
4861
|
return;
|
|
4720
4862
|
}
|
|
4721
|
-
const
|
|
4863
|
+
const bounds = dayBoundsFor(yy, mm);
|
|
4864
|
+
if (bounds.max < bounds.min) return;
|
|
4865
|
+
const safeDay = Math.min(Math.max(dd ?? bounds.min, bounds.min), bounds.max);
|
|
4866
|
+
if (!withinRange(yy, mm, safeDay)) return;
|
|
4722
4867
|
cb?.(`${yy}-${pad(mm)}-${pad(safeDay)}`);
|
|
4723
4868
|
},
|
|
4724
|
-
[mode, onValueChange, onChange]
|
|
4869
|
+
[mode, onValueChange, onChange, dayBoundsFor, withinRange]
|
|
4725
4870
|
);
|
|
4726
|
-
const handleYearChange =
|
|
4871
|
+
const handleYearChange = React20.useCallback(
|
|
4727
4872
|
(raw) => {
|
|
4728
4873
|
if (!raw) return;
|
|
4729
4874
|
const newYear = Number(raw);
|
|
@@ -4740,14 +4885,14 @@ var DatePicker = ({
|
|
|
4740
4885
|
},
|
|
4741
4886
|
[month, day, min.year, min.month, selectableRange, todayYear, todayMonth, emit]
|
|
4742
4887
|
);
|
|
4743
|
-
const handleMonthChange =
|
|
4888
|
+
const handleMonthChange = React20.useCallback(
|
|
4744
4889
|
(raw) => {
|
|
4745
4890
|
if (!raw || !year) return;
|
|
4746
4891
|
emit(year, Number(raw), day || void 0);
|
|
4747
4892
|
},
|
|
4748
4893
|
[year, day, emit]
|
|
4749
4894
|
);
|
|
4750
|
-
const handleDayChange =
|
|
4895
|
+
const handleDayChange = React20.useCallback(
|
|
4751
4896
|
(raw) => {
|
|
4752
4897
|
if (!raw || !year || !month) return;
|
|
4753
4898
|
emit(year, month, Number(raw));
|
|
@@ -4909,13 +5054,13 @@ var FileInput = ({
|
|
|
4909
5054
|
}) => {
|
|
4910
5055
|
const t = useLocaleText();
|
|
4911
5056
|
const label = labelProp ?? t("fileInput.label");
|
|
4912
|
-
const generatedInputId =
|
|
4913
|
-
const helperId =
|
|
5057
|
+
const generatedInputId = React20.useId();
|
|
5058
|
+
const helperId = React20.useId();
|
|
4914
5059
|
const field = useFieldControl();
|
|
4915
5060
|
const inputId = field?.inputId ?? generatedInputId;
|
|
4916
|
-
const inputRef =
|
|
4917
|
-
const [previewUrls, setPreviewUrls] =
|
|
4918
|
-
const previewUrlsRef =
|
|
5061
|
+
const inputRef = React20.useRef(null);
|
|
5062
|
+
const [previewUrls, setPreviewUrls] = React20.useState([]);
|
|
5063
|
+
const previewUrlsRef = React20.useRef([]);
|
|
4919
5064
|
const isPreviewVariant = variant === "preview";
|
|
4920
5065
|
const showPreview = isPreviewVariant || preview;
|
|
4921
5066
|
const handleChange = (e) => {
|
|
@@ -4956,7 +5101,7 @@ var FileInput = ({
|
|
|
4956
5101
|
}
|
|
4957
5102
|
onFiles?.(null);
|
|
4958
5103
|
};
|
|
4959
|
-
|
|
5104
|
+
React20.useEffect(() => {
|
|
4960
5105
|
return () => {
|
|
4961
5106
|
for (const url of previewUrlsRef.current) {
|
|
4962
5107
|
URL.revokeObjectURL(url);
|
|
@@ -4982,7 +5127,7 @@ var FileInput = ({
|
|
|
4982
5127
|
className: "file_input_control",
|
|
4983
5128
|
disabled,
|
|
4984
5129
|
accept: isPreviewVariant ? accept ?? "image/*" : accept,
|
|
4985
|
-
"aria-describedby": field?.describedBy
|
|
5130
|
+
"aria-describedby": [field?.describedBy, supportingText ? helperId : void 0].filter(Boolean).join(" ") || void 0,
|
|
4986
5131
|
"aria-invalid": field?.invalid || void 0,
|
|
4987
5132
|
onChange: handleChange
|
|
4988
5133
|
}
|
|
@@ -5270,6 +5415,7 @@ function ImageCropper({
|
|
|
5270
5415
|
"aria-labelledby": field?.labelId,
|
|
5271
5416
|
"aria-label": field?.labelId ? void 0 : label,
|
|
5272
5417
|
"aria-describedby": [field?.describedBy, hintId].filter(Boolean).join(" "),
|
|
5418
|
+
"aria-invalid": field?.invalid || void 0,
|
|
5273
5419
|
tabIndex: imageSize ? 0 : -1,
|
|
5274
5420
|
onPointerDown: handlePointerDown,
|
|
5275
5421
|
onPointerMove: handlePointerMove,
|
|
@@ -5362,12 +5508,13 @@ var OtpInput = ({
|
|
|
5362
5508
|
}) => {
|
|
5363
5509
|
const t = useLocaleText();
|
|
5364
5510
|
const ariaLabel = ariaLabelProp ?? t("otpInput.label");
|
|
5365
|
-
const inputsRef =
|
|
5366
|
-
const isTypingRef =
|
|
5367
|
-
|
|
5511
|
+
const inputsRef = React20.useRef([]);
|
|
5512
|
+
const isTypingRef = React20.useRef(false);
|
|
5513
|
+
const typingTimerRef = React20.useRef(void 0);
|
|
5514
|
+
React20.useEffect(() => {
|
|
5368
5515
|
if (autoFocus) inputsRef.current[0]?.focus();
|
|
5369
5516
|
}, [autoFocus]);
|
|
5370
|
-
const digits =
|
|
5517
|
+
const digits = React20.useMemo(() => {
|
|
5371
5518
|
const chars = value.split("").slice(0, length);
|
|
5372
5519
|
while (chars.length < length) chars.push("");
|
|
5373
5520
|
return chars;
|
|
@@ -5396,11 +5543,13 @@ var OtpInput = ({
|
|
|
5396
5543
|
if (nextDigit && index < length - 1) {
|
|
5397
5544
|
isTypingRef.current = true;
|
|
5398
5545
|
focusInput(index + 1);
|
|
5399
|
-
|
|
5546
|
+
clearTimeout(typingTimerRef.current);
|
|
5547
|
+
typingTimerRef.current = setTimeout(() => {
|
|
5400
5548
|
isTypingRef.current = false;
|
|
5401
5549
|
}, 50);
|
|
5402
5550
|
}
|
|
5403
5551
|
};
|
|
5552
|
+
React20.useEffect(() => () => clearTimeout(typingTimerRef.current), []);
|
|
5404
5553
|
const handleFocus = (index) => {
|
|
5405
5554
|
if (isTypingRef.current) return;
|
|
5406
5555
|
const firstEmpty = digits.indexOf("");
|
|
@@ -5444,7 +5593,7 @@ var OtpInput = ({
|
|
|
5444
5593
|
focusInput(nextIndex);
|
|
5445
5594
|
};
|
|
5446
5595
|
const rootClassName = cn("otp_input", className);
|
|
5447
|
-
const supportingId =
|
|
5596
|
+
const supportingId = React20.useId();
|
|
5448
5597
|
const field = useFieldControl();
|
|
5449
5598
|
return (
|
|
5450
5599
|
// biome-ignore lint/a11y/useSemanticElements: <fieldset> would force border/legend styles; role=group is the WAI-ARIA equivalent for OTP grouping
|
|
@@ -5475,7 +5624,7 @@ var OtpInput = ({
|
|
|
5475
5624
|
disabled,
|
|
5476
5625
|
"aria-label": t("otpInput.digit", { index: i + 1 }),
|
|
5477
5626
|
"aria-invalid": error || field?.invalid || void 0,
|
|
5478
|
-
"aria-describedby": field?.describedBy
|
|
5627
|
+
"aria-describedby": [field?.describedBy, supportingText ? supportingId : void 0].filter(Boolean).join(" ") || void 0,
|
|
5479
5628
|
className: cn(
|
|
5480
5629
|
"otp_input_box",
|
|
5481
5630
|
error && "otp_input_box_error",
|
|
@@ -5498,9 +5647,9 @@ var OtpInput = ({
|
|
|
5498
5647
|
);
|
|
5499
5648
|
};
|
|
5500
5649
|
OtpInput.displayName = "OtpInput";
|
|
5501
|
-
var RadioGroupContext =
|
|
5650
|
+
var RadioGroupContext = React20.createContext(null);
|
|
5502
5651
|
function useRadioGroupContext() {
|
|
5503
|
-
return
|
|
5652
|
+
return React20.useContext(RadioGroupContext);
|
|
5504
5653
|
}
|
|
5505
5654
|
var RadioGroup = ({
|
|
5506
5655
|
value: controlledValue,
|
|
@@ -5518,22 +5667,22 @@ var RadioGroup = ({
|
|
|
5518
5667
|
...props
|
|
5519
5668
|
}) => {
|
|
5520
5669
|
const isControlled = controlledValue !== void 0;
|
|
5521
|
-
const [internalValue, setInternalValue] =
|
|
5670
|
+
const [internalValue, setInternalValue] = React20.useState(defaultValue);
|
|
5522
5671
|
const value = isControlled ? controlledValue : internalValue;
|
|
5523
|
-
const generatedName =
|
|
5672
|
+
const generatedName = React20.useId();
|
|
5524
5673
|
const name = nameProp ?? generatedName;
|
|
5525
|
-
const idPrefix =
|
|
5674
|
+
const idPrefix = React20.useId();
|
|
5526
5675
|
const field = useFieldControl();
|
|
5527
5676
|
const labelId = label ? `${idPrefix}-label` : void 0;
|
|
5528
5677
|
const helperId = supportingText ? `${idPrefix}-help` : void 0;
|
|
5529
|
-
const onChange =
|
|
5678
|
+
const onChange = React20.useCallback(
|
|
5530
5679
|
(next) => {
|
|
5531
5680
|
if (!isControlled) setInternalValue(next);
|
|
5532
5681
|
onValueChange?.(next);
|
|
5533
5682
|
},
|
|
5534
5683
|
[isControlled, onValueChange]
|
|
5535
5684
|
);
|
|
5536
|
-
const ctx =
|
|
5685
|
+
const ctx = React20.useMemo(
|
|
5537
5686
|
() => ({ name, value, onChange, size, disabled }),
|
|
5538
5687
|
[name, value, onChange, size, disabled]
|
|
5539
5688
|
);
|
|
@@ -5594,17 +5743,18 @@ var Radio = ({
|
|
|
5594
5743
|
/* @__PURE__ */ jsx(
|
|
5595
5744
|
"input",
|
|
5596
5745
|
{
|
|
5746
|
+
...props,
|
|
5597
5747
|
ref,
|
|
5598
5748
|
type: "radio",
|
|
5599
5749
|
className: "radio_input",
|
|
5600
5750
|
id: field?.inputId ?? props.id,
|
|
5601
5751
|
"aria-describedby": field?.describedBy ?? props["aria-describedby"],
|
|
5752
|
+
"aria-invalid": field ? field.invalid || void 0 : props["aria-invalid"],
|
|
5602
5753
|
value,
|
|
5603
5754
|
name,
|
|
5604
5755
|
disabled,
|
|
5605
5756
|
checked: resolvedChecked,
|
|
5606
|
-
onChange: handleChange
|
|
5607
|
-
...props
|
|
5757
|
+
onChange: handleChange
|
|
5608
5758
|
}
|
|
5609
5759
|
),
|
|
5610
5760
|
/* @__PURE__ */ jsx("span", { className: "radio_state_layer", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "radio_dot" }) }),
|
|
@@ -5787,9 +5937,9 @@ var Textarea = ({
|
|
|
5787
5937
|
}) => {
|
|
5788
5938
|
const generatedId = useId();
|
|
5789
5939
|
const field = useFieldControl();
|
|
5790
|
-
const inputId =
|
|
5791
|
-
const helperId = supportingText ? `${
|
|
5792
|
-
const describedBy = field?.describedBy
|
|
5940
|
+
const inputId = field?.inputId ?? id ?? generatedId;
|
|
5941
|
+
const helperId = supportingText ? `${generatedId}-help` : void 0;
|
|
5942
|
+
const describedBy = [field?.describedBy, helperId, props["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
5793
5943
|
const isControlled = value !== void 0;
|
|
5794
5944
|
const applyTransform = (nextValue) => transformValue ? transformValue(nextValue) : nextValue;
|
|
5795
5945
|
const [innerValue, setInnerValue] = useState(() => applyTransform(value ?? defaultValue ?? ""));
|
|
@@ -5797,12 +5947,10 @@ var Textarea = ({
|
|
|
5797
5947
|
const innerRef = useRef(null);
|
|
5798
5948
|
const lastEmittedValueRef = useRef(innerValue);
|
|
5799
5949
|
const autoGrow = minRows !== void 0 || maxRows !== void 0;
|
|
5800
|
-
const
|
|
5801
|
-
if (isControlled &&
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
setInnerValue(nextValue);
|
|
5805
|
-
lastEmittedValueRef.current = nextValue;
|
|
5950
|
+
const nextControlledValue = applyTransform(value ?? "");
|
|
5951
|
+
if (isControlled && !isComposingRef.current && nextControlledValue !== innerValue) {
|
|
5952
|
+
setInnerValue(nextControlledValue);
|
|
5953
|
+
lastEmittedValueRef.current = nextControlledValue;
|
|
5806
5954
|
}
|
|
5807
5955
|
const setRefs = useCallback(
|
|
5808
5956
|
(node) => {
|
|
@@ -5848,17 +5996,17 @@ var Textarea = ({
|
|
|
5848
5996
|
/* @__PURE__ */ jsx("div", { className: "textarea_input_wrap", children: /* @__PURE__ */ jsx(
|
|
5849
5997
|
"textarea",
|
|
5850
5998
|
{
|
|
5999
|
+
...props,
|
|
5851
6000
|
id: inputId,
|
|
5852
6001
|
ref: setRefs,
|
|
5853
6002
|
className: "textarea_input",
|
|
5854
6003
|
style: { resize: autoGrow ? "none" : resize },
|
|
5855
6004
|
rows: autoGrow ? minRows ?? rows : rows,
|
|
5856
6005
|
maxLength,
|
|
5857
|
-
"aria-invalid": !!error ||
|
|
6006
|
+
"aria-invalid": field ? !!error || field.invalid : props["aria-invalid"] ?? !!error,
|
|
5858
6007
|
"aria-describedby": describedBy,
|
|
5859
|
-
"aria-required": field
|
|
5860
|
-
"aria-label": !showLabel ? label : void 0,
|
|
5861
|
-
...props,
|
|
6008
|
+
"aria-required": field ? field.required || void 0 : props["aria-required"],
|
|
6009
|
+
"aria-label": (!showLabel ? label : void 0) ?? props["aria-label"],
|
|
5862
6010
|
value: innerValue,
|
|
5863
6011
|
onCompositionStart: () => {
|
|
5864
6012
|
isComposingRef.current = true;
|
|
@@ -5913,14 +6061,14 @@ var TimePicker = ({
|
|
|
5913
6061
|
const hourLabel = hourLabelProp ?? t("timePicker.hour");
|
|
5914
6062
|
const minuteLabel = minuteLabelProp ?? t("timePicker.minute");
|
|
5915
6063
|
const field = useFieldControl();
|
|
5916
|
-
const groupId =
|
|
5917
|
-
const constraintId =
|
|
6064
|
+
const groupId = React20.useId();
|
|
6065
|
+
const constraintId = React20.useId();
|
|
5918
6066
|
const min = toMinutes(minTime) ?? 0;
|
|
5919
6067
|
const max = toMinutes(maxTime) ?? 23 * 60 + 59;
|
|
5920
6068
|
const parsed = toMinutes(value);
|
|
5921
6069
|
const hour = parsed === null ? null : Math.floor(parsed / 60);
|
|
5922
6070
|
const minute = parsed === null ? null : parsed % 60;
|
|
5923
|
-
const hourOptions =
|
|
6071
|
+
const hourOptions = React20.useMemo(() => {
|
|
5924
6072
|
const first = Math.floor(min / 60);
|
|
5925
6073
|
const last = Math.floor(max / 60);
|
|
5926
6074
|
return Array.from({ length: Math.max(0, last - first + 1) }, (_, i) => {
|
|
@@ -5928,7 +6076,7 @@ var TimePicker = ({
|
|
|
5928
6076
|
return { value: String(h), label: pad2(h) };
|
|
5929
6077
|
});
|
|
5930
6078
|
}, [min, max]);
|
|
5931
|
-
const minuteOptions =
|
|
6079
|
+
const minuteOptions = React20.useMemo(() => {
|
|
5932
6080
|
if (hour === null) return [];
|
|
5933
6081
|
const step = Math.max(1, Math.floor(minuteStep));
|
|
5934
6082
|
return Array.from({ length: Math.ceil(60 / step) }, (_, i) => i * step).filter((m) => m < 60).filter((m) => hour * 60 + m >= min && hour * 60 + m <= max).map((m) => ({ value: String(m), label: pad2(m) }));
|
|
@@ -6015,7 +6163,7 @@ var Toggle = ({
|
|
|
6015
6163
|
...props
|
|
6016
6164
|
}) => {
|
|
6017
6165
|
const isControlled = checked !== void 0;
|
|
6018
|
-
const [innerChecked, setInnerChecked] =
|
|
6166
|
+
const [innerChecked, setInnerChecked] = React20.useState(!!defaultChecked);
|
|
6019
6167
|
const isOn = isControlled ? !!checked : innerChecked;
|
|
6020
6168
|
const handleToggle = (e) => {
|
|
6021
6169
|
props.onClick?.(e);
|
|
@@ -6041,6 +6189,7 @@ var Toggle = ({
|
|
|
6041
6189
|
"aria-checked": isOn,
|
|
6042
6190
|
id: field?.inputId ?? props.id,
|
|
6043
6191
|
"aria-describedby": field?.describedBy ?? props["aria-describedby"],
|
|
6192
|
+
"aria-invalid": field ? field.invalid || void 0 : props["aria-invalid"],
|
|
6044
6193
|
"aria-labelledby": field?.labelId,
|
|
6045
6194
|
"aria-label": field?.labelId ? void 0 : ariaLabel,
|
|
6046
6195
|
disabled,
|
|
@@ -6092,15 +6241,15 @@ var Drawer = ({
|
|
|
6092
6241
|
}) => {
|
|
6093
6242
|
const t = useLocaleText();
|
|
6094
6243
|
const closeLabel = closeLabelProp ?? t("drawer.close");
|
|
6095
|
-
const lastContentRef =
|
|
6244
|
+
const lastContentRef = React20.useRef({ children, title, footer });
|
|
6096
6245
|
if (open) lastContentRef.current = { children, title, footer };
|
|
6097
6246
|
const content = open ? { children, title, footer } : lastContentRef.current;
|
|
6098
6247
|
const overlayDismissible = dismissible ?? closeOnOverlay;
|
|
6099
6248
|
const escapeDismissible = dismissible ?? true;
|
|
6100
|
-
const panelRef =
|
|
6101
|
-
const pressedOverlayRef =
|
|
6102
|
-
const titleId =
|
|
6103
|
-
const [shouldRender, setShouldRender] =
|
|
6249
|
+
const panelRef = React20.useRef(null);
|
|
6250
|
+
const pressedOverlayRef = React20.useRef(false);
|
|
6251
|
+
const titleId = React20.useId();
|
|
6252
|
+
const [shouldRender, setShouldRender] = React20.useState(open);
|
|
6104
6253
|
const reduced = useReducedMotion();
|
|
6105
6254
|
const isMounted = useIsMounted();
|
|
6106
6255
|
useFocusTrap(panelRef, open && isMounted);
|
|
@@ -6108,10 +6257,13 @@ var Drawer = ({
|
|
|
6108
6257
|
if (escapeDismissible) onClose?.();
|
|
6109
6258
|
});
|
|
6110
6259
|
if (open && !shouldRender) setShouldRender(true);
|
|
6111
|
-
const overlayStyle =
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6260
|
+
const overlayStyle = useSpring({
|
|
6261
|
+
...springEnterFrom(reduced),
|
|
6262
|
+
to: { opacity: open ? 1 : 0 },
|
|
6263
|
+
immediate: reduced,
|
|
6264
|
+
config: OVERLAY_SPRING_CONFIG,
|
|
6265
|
+
onRest: (result) => {
|
|
6266
|
+
if (open || !result.finished) return;
|
|
6115
6267
|
setShouldRender(false);
|
|
6116
6268
|
onExited?.();
|
|
6117
6269
|
}
|
|
@@ -6124,7 +6276,7 @@ var Drawer = ({
|
|
|
6124
6276
|
immediate: reduced,
|
|
6125
6277
|
config: { tension: 280, friction: 28, clamp: !open }
|
|
6126
6278
|
});
|
|
6127
|
-
|
|
6279
|
+
React20.useEffect(() => {
|
|
6128
6280
|
if (!shouldRender) return;
|
|
6129
6281
|
lockBodyScroll();
|
|
6130
6282
|
return () => {
|
|
@@ -6202,15 +6354,15 @@ var Modal = ({
|
|
|
6202
6354
|
}) => {
|
|
6203
6355
|
const t = useLocaleText();
|
|
6204
6356
|
const closeLabel = closeLabelProp ?? t("modal.close");
|
|
6205
|
-
const lastContentRef =
|
|
6357
|
+
const lastContentRef = React20.useRef({ children, title, description, footer });
|
|
6206
6358
|
if (open) lastContentRef.current = { children, title, description, footer };
|
|
6207
6359
|
const content = open ? { children, title, description, footer } : lastContentRef.current;
|
|
6208
6360
|
const overlayDismissible = dismissible ?? closeOnOverlay;
|
|
6209
6361
|
const escapeDismissible = dismissible ?? true;
|
|
6210
|
-
const panelRef =
|
|
6211
|
-
const pressedOverlayRef =
|
|
6212
|
-
const titleId =
|
|
6213
|
-
const [shouldRender, setShouldRender] =
|
|
6362
|
+
const panelRef = React20.useRef(null);
|
|
6363
|
+
const pressedOverlayRef = React20.useRef(false);
|
|
6364
|
+
const titleId = React20.useId();
|
|
6365
|
+
const [shouldRender, setShouldRender] = React20.useState(open);
|
|
6214
6366
|
const isMounted = useIsMounted();
|
|
6215
6367
|
useFocusTrap(panelRef, open && isMounted);
|
|
6216
6368
|
useOverlayEscape(open && isMounted, () => {
|
|
@@ -6238,7 +6390,7 @@ var Modal = ({
|
|
|
6238
6390
|
immediate: reduced,
|
|
6239
6391
|
config: OVERLAY_SPRING_CONFIG
|
|
6240
6392
|
});
|
|
6241
|
-
|
|
6393
|
+
React20.useEffect(() => {
|
|
6242
6394
|
if (!shouldRender) return;
|
|
6243
6395
|
lockBodyScroll();
|
|
6244
6396
|
return () => {
|
|
@@ -6300,9 +6452,9 @@ var Modal = ({
|
|
|
6300
6452
|
document.body
|
|
6301
6453
|
);
|
|
6302
6454
|
};
|
|
6303
|
-
var ThemeContext =
|
|
6455
|
+
var ThemeContext = React20.createContext(null);
|
|
6304
6456
|
var useTheme = () => {
|
|
6305
|
-
const ctx =
|
|
6457
|
+
const ctx = React20.useContext(ThemeContext);
|
|
6306
6458
|
if (!ctx) {
|
|
6307
6459
|
throw new Error(
|
|
6308
6460
|
'[Bigtablet DS] useTheme\uB294 <ThemeProvider> \uC548\uC5D0\uC11C\uB9CC \uC0AC\uC6A9 \uAC00\uB2A5\uD569\uB2C8\uB2E4.\n\n\uC571 \uCD5C\uC0C1\uB2E8\uC5D0 <ThemeProvider>\uB85C \uAC10\uC2F8\uC8FC\uC138\uC694:\n <ThemeProvider mode="system">\n <YourApp />\n </ThemeProvider>'
|
|
@@ -6326,15 +6478,15 @@ var ThemeProvider = ({
|
|
|
6326
6478
|
targetSelector,
|
|
6327
6479
|
children
|
|
6328
6480
|
}) => {
|
|
6329
|
-
const [mode, setModeState] =
|
|
6330
|
-
const [systemDark, setSystemDark] =
|
|
6331
|
-
|
|
6481
|
+
const [mode, setModeState] = React20.useState(defaultMode);
|
|
6482
|
+
const [systemDark, setSystemDark] = React20.useState(false);
|
|
6483
|
+
React20.useEffect(() => {
|
|
6332
6484
|
setModeState(readStored(storageKey) ?? defaultMode);
|
|
6333
6485
|
if (isClient) {
|
|
6334
6486
|
setSystemDark(window.matchMedia("(prefers-color-scheme: dark)").matches);
|
|
6335
6487
|
}
|
|
6336
6488
|
}, [storageKey, defaultMode]);
|
|
6337
|
-
|
|
6489
|
+
React20.useEffect(() => {
|
|
6338
6490
|
if (!isClient) return;
|
|
6339
6491
|
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
6340
6492
|
const handler = (e) => setSystemDark(e.matches);
|
|
@@ -6342,7 +6494,7 @@ var ThemeProvider = ({
|
|
|
6342
6494
|
return () => mq.removeEventListener("change", handler);
|
|
6343
6495
|
}, []);
|
|
6344
6496
|
const resolved = mode === "system" ? systemDark ? "dark" : "light" : mode;
|
|
6345
|
-
|
|
6497
|
+
React20.useEffect(() => {
|
|
6346
6498
|
if (!isClient) return;
|
|
6347
6499
|
const target = targetSelector ? document.querySelector(targetSelector) : document.documentElement;
|
|
6348
6500
|
if (!target) return;
|
|
@@ -6352,7 +6504,7 @@ var ThemeProvider = ({
|
|
|
6352
6504
|
target.setAttribute("data-theme", mode);
|
|
6353
6505
|
}
|
|
6354
6506
|
}, [mode, targetSelector]);
|
|
6355
|
-
const setMode =
|
|
6507
|
+
const setMode = React20.useCallback(
|
|
6356
6508
|
(next) => {
|
|
6357
6509
|
setModeState(next);
|
|
6358
6510
|
if (storageKey && isClient) {
|
|
@@ -6364,7 +6516,7 @@ var ThemeProvider = ({
|
|
|
6364
6516
|
},
|
|
6365
6517
|
[storageKey]
|
|
6366
6518
|
);
|
|
6367
|
-
const value =
|
|
6519
|
+
const value = React20.useMemo(
|
|
6368
6520
|
() => ({ mode, resolved, setMode }),
|
|
6369
6521
|
[mode, resolved, setMode]
|
|
6370
6522
|
);
|