@bigtablet/design-system 3.20.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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import './index.css';
3
- import * as React11 from 'react';
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 = React11.useRef(onEscape);
62
- React11.useEffect(() => {
61
+ const handlerRef = React20.useRef(onEscape);
62
+ React20.useEffect(() => {
63
63
  handlerRef.current = onEscape;
64
64
  });
65
- React11.useEffect(() => {
65
+ React20.useEffect(() => {
66
66
  if (!active) return;
67
67
  return registerOverlay(() => handlerRef.current());
68
68
  }, [active]);
@@ -71,50 +71,16 @@ 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";
77
82
  var SCROLLBAR_WIDTH_VAR = "--bt-scrollbar-width";
78
83
  var LOCKED_ATTR = "data-bt-scroll-locked";
79
- var DIM_VAR = "--bt-color-bg-overlay";
80
- var DIM_FALLBACK = "rgba(0, 0, 0, 0.5)";
81
- var PREV_BACKGROUND_COLOR = "originalBackgroundColor";
82
- var WHITE = [255, 255, 255, 1];
83
- var parseRgb = (value) => {
84
- const match = value.trim().match(/^rgba?\(([^)]+)\)$/i);
85
- if (!match) return null;
86
- const parts = match[1].split(/[\s,/]+/).filter(Boolean).map(Number);
87
- if (parts.length < 3 || parts.some(Number.isNaN)) return null;
88
- return [parts[0], parts[1], parts[2], parts.length > 3 ? parts[3] : 1];
89
- };
90
- var normalizeColor = (value) => {
91
- const direct = parseRgb(value);
92
- if (direct) return direct;
93
- const probe = document.createElement("div");
94
- probe.style.cssText = "position:fixed;top:0;left:0;width:0;height:0;visibility:hidden";
95
- probe.style.color = value;
96
- document.documentElement.appendChild(probe);
97
- const computed = window.getComputedStyle(probe).color;
98
- probe.remove();
99
- return parseRgb(computed);
100
- };
101
- var over = (top, bottom) => [
102
- Math.round(top[0] * top[3] + bottom[0] * (1 - top[3])),
103
- Math.round(top[1] * top[3] + bottom[1] * (1 - top[3])),
104
- Math.round(top[2] * top[3] + bottom[2] * (1 - top[3])),
105
- 1
106
- ];
107
- var measureCanvasColors = (html, body) => {
108
- const raw = window.getComputedStyle(html).getPropertyValue(DIM_VAR).trim() || DIM_FALLBACK;
109
- const dim = normalizeColor(raw);
110
- if (!dim || dim[3] <= 0) return null;
111
- const candidates = [
112
- parseRgb(window.getComputedStyle(html).backgroundColor),
113
- parseRgb(window.getComputedStyle(body).backgroundColor)
114
- ];
115
- const base = candidates.find((color) => color !== null && color[3] > 0) ?? WHITE;
116
- return [dim, over(base, WHITE)];
117
- };
118
84
  var measureViewportInset = () => {
119
85
  const probe = document.createElement("div");
120
86
  probe.style.cssText = "position:fixed;top:0;left:0;right:0;height:0;visibility:hidden;pointer-events:none";
@@ -124,68 +90,45 @@ var measureViewportInset = () => {
124
90
  if (width <= 0) return 0;
125
91
  return Math.max(0, window.innerWidth - width);
126
92
  };
127
- var dimProgress = /* @__PURE__ */ new Map();
128
- var canvasBase = null;
129
- var canvasDim = null;
130
- var combinedDimAlpha = (alpha) => {
131
- if (dimProgress.size === 0) return alpha;
132
- let transmitted = 1;
133
- for (const progress of dimProgress.values()) {
134
- transmitted *= 1 - alpha * progress;
93
+ var restoreScrollbarWidthVar = (html, body) => {
94
+ const prev = body.dataset[PREV_SCROLLBAR_WIDTH_VAR];
95
+ if (prev) {
96
+ html.style.setProperty(SCROLLBAR_WIDTH_VAR, prev);
97
+ } else {
98
+ html.style.removeProperty(SCROLLBAR_WIDTH_VAR);
135
99
  }
136
- return 1 - transmitted;
137
- };
138
- var paintCanvas = (html) => {
139
- if (!canvasBase || !canvasDim) return;
140
- const alpha = combinedDimAlpha(canvasDim[3]);
141
- const [r, g, b] = over([canvasDim[0], canvasDim[1], canvasDim[2], alpha], canvasBase);
142
- html.style.backgroundColor = `rgb(${r}, ${g}, ${b})`;
143
100
  };
144
- function reportOverlayDim(owner, progress) {
145
- if (typeof document === "undefined") return;
146
- dimProgress.set(owner, Math.min(1, Math.max(0, progress)));
147
- paintCanvas(document.documentElement);
148
- }
149
- function unregisterOverlayDim(owner) {
150
- if (typeof document === "undefined") return;
151
- if (!dimProgress.delete(owner)) return;
152
- paintCanvas(document.documentElement);
153
- }
154
101
  function lockBodyScroll() {
155
102
  if (typeof document === "undefined") return;
156
103
  const body = document.body;
157
104
  const html = document.documentElement;
158
105
  const open = Number.parseInt(body.dataset[COUNTER] || "0", 10);
159
106
  if (open === 0) {
160
- const scrollbarWidth = measureViewportInset();
161
- const scroller = document.scrollingElement ?? html;
162
- const documentScrolls = scroller.scrollHeight > scroller.clientHeight;
163
- const canReserveGutter = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("scrollbar-gutter: stable");
107
+ const inset = measureViewportInset();
164
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;
165
114
  body.dataset[PREV_GUTTER] = html.style.scrollbarGutter;
166
115
  body.dataset[PREV_PADDING_RIGHT] = body.style.paddingRight;
167
116
  body.dataset[PREV_SCROLLBAR_WIDTH_VAR] = html.style.getPropertyValue(SCROLLBAR_WIDTH_VAR);
168
- body.dataset[PREV_BACKGROUND_COLOR] = html.style.backgroundColor;
169
- if (scrollbarWidth > 0) {
170
- html.style.setProperty(SCROLLBAR_WIDTH_VAR, `${scrollbarWidth}px`);
117
+ if (inset > 0) {
118
+ html.style.setProperty(SCROLLBAR_WIDTH_VAR, `${inset}px`);
171
119
  }
172
- if (documentScrolls && scrollbarWidth > 0) {
173
- if (canReserveGutter) {
174
- html.style.scrollbarGutter = "stable";
175
- } else {
176
- const current = Number.parseFloat(window.getComputedStyle(body).paddingRight) || 0;
177
- body.style.paddingRight = `${current + scrollbarWidth}px`;
178
- }
179
- }
180
- if (scrollbarWidth > 0 && canReserveGutter) {
181
- const measured = measureCanvasColors(html, body);
182
- if (measured) {
183
- [canvasDim, canvasBase] = measured;
184
- paintCanvas(html);
120
+ body.style.overflow = "hidden";
121
+ html.style.overflow = "hidden";
122
+ if (inset > 0) {
123
+ html.style.scrollbarGutter = "auto";
124
+ const current = Number.parseFloat(window.getComputedStyle(body).paddingRight) || 0;
125
+ body.style.paddingRight = `${current + inset}px`;
126
+ if (measureViewportInset() > 0) {
127
+ body.style.paddingRight = body.dataset[PREV_PADDING_RIGHT] || "";
128
+ restoreScrollbarWidthVar(html, body);
185
129
  }
186
130
  }
187
131
  html.setAttribute(LOCKED_ATTR, "");
188
- body.style.overflow = "hidden";
189
132
  }
190
133
  body.dataset[COUNTER] = String(open + 1);
191
134
  }
@@ -196,25 +139,25 @@ function unlockBodyScroll() {
196
139
  const remaining = Number.parseInt(body.dataset[COUNTER] || "1", 10) - 1;
197
140
  if (remaining <= 0) {
198
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] || "";
199
147
  body.style.paddingRight = body.dataset[PREV_PADDING_RIGHT] || "";
200
148
  html.style.scrollbarGutter = body.dataset[PREV_GUTTER] || "";
201
- html.style.backgroundColor = body.dataset[PREV_BACKGROUND_COLOR] || "";
202
149
  html.removeAttribute(LOCKED_ATTR);
203
- const prevVar = body.dataset[PREV_SCROLLBAR_WIDTH_VAR];
204
- if (prevVar) {
205
- html.style.setProperty(SCROLLBAR_WIDTH_VAR, prevVar);
206
- } else {
207
- html.style.removeProperty(SCROLLBAR_WIDTH_VAR);
208
- }
150
+ restoreScrollbarWidthVar(html, body);
209
151
  delete body.dataset[COUNTER];
210
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];
211
158
  delete body.dataset[PREV_GUTTER];
212
159
  delete body.dataset[PREV_PADDING_RIGHT];
213
160
  delete body.dataset[PREV_SCROLLBAR_WIDTH_VAR];
214
- delete body.dataset[PREV_BACKGROUND_COLOR];
215
- dimProgress.clear();
216
- canvasBase = null;
217
- canvasDim = null;
218
161
  } else {
219
162
  body.dataset[COUNTER] = String(remaining);
220
163
  }
@@ -326,7 +269,7 @@ function useAnchoredPosition({
326
269
  gap,
327
270
  padding
328
271
  }) {
329
- const [state, setState] = React11.useState({
272
+ const [state, setState] = React20.useState({
330
273
  x: 0,
331
274
  y: 0,
332
275
  placement,
@@ -396,8 +339,8 @@ var FOCUSABLE_SELECTORS = [
396
339
  '[tabindex]:not([tabindex="-1"])'
397
340
  ].join(", ");
398
341
  function useFocusTrap(containerRef, isActive) {
399
- const previousActiveElement = React11.useRef(null);
400
- React11.useEffect(() => {
342
+ const previousActiveElement = React20.useRef(null);
343
+ React20.useEffect(() => {
401
344
  if (!isActive) return;
402
345
  const container = containerRef.current;
403
346
  if (!container) return;
@@ -436,9 +379,9 @@ function useFocusTrap(containerRef, isActive) {
436
379
  }
437
380
  }
438
381
  };
439
- document.addEventListener("keydown", handleKeyDown2);
382
+ container.addEventListener("keydown", handleKeyDown2);
440
383
  return () => {
441
- document.removeEventListener("keydown", handleKeyDown2);
384
+ container.removeEventListener("keydown", handleKeyDown2);
442
385
  if (wasTabIndexAdded) {
443
386
  container.removeAttribute("tabindex");
444
387
  }
@@ -447,8 +390,8 @@ function useFocusTrap(containerRef, isActive) {
447
390
  }, [isActive, containerRef]);
448
391
  }
449
392
  function useIsMounted() {
450
- const [mounted, setMounted] = React11.useState(false);
451
- React11.useEffect(() => {
393
+ const [mounted, setMounted] = React20.useState(false);
394
+ React20.useEffect(() => {
452
395
  setMounted(true);
453
396
  }, []);
454
397
  return mounted;
@@ -482,13 +425,13 @@ function getServerSnapshot() {
482
425
  return false;
483
426
  }
484
427
  function useReducedMotion() {
485
- return React11.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
428
+ return React20.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
486
429
  }
487
430
  function useSpringHover({
488
431
  scale = 1.02,
489
432
  lift = -2
490
433
  } = {}) {
491
- const [hovered, setHovered] = React11.useState(false);
434
+ const [hovered, setHovered] = React20.useState(false);
492
435
  const reduced = useReducedMotion();
493
436
  const style = useSpring({
494
437
  transform: hovered ? `translateY(${lift}px) scale(${scale})` : "translateY(0px) scale(1)",
@@ -549,6 +492,7 @@ function useListboxPopup({
549
492
  }) {
550
493
  const [isOpen, setIsOpen] = useState(false);
551
494
  const [activeIndex, setActiveIndex] = useState(-1);
495
+ const pendingActiveRef = useRef(null);
552
496
  const wrapperRef = useRef(null);
553
497
  const triggerRef = useRef(null);
554
498
  const listRef = useRef(null);
@@ -558,6 +502,7 @@ function useListboxPopup({
558
502
  if (returnFocusOnClose) triggerRef.current?.focus();
559
503
  }, [returnFocusOnClose]);
560
504
  useEffect(() => {
505
+ if (!isOpen) return;
561
506
  const handleOutsideClick = (event) => {
562
507
  const target = event.target;
563
508
  if (wrapperRef.current?.contains(target) || panelRef.current?.contains(target)) return;
@@ -565,7 +510,7 @@ function useListboxPopup({
565
510
  };
566
511
  document.addEventListener("mousedown", handleOutsideClick);
567
512
  return () => document.removeEventListener("mousedown", handleOutsideClick);
568
- }, []);
513
+ }, [isOpen]);
569
514
  const moveActive = useCallback(
570
515
  (dir) => {
571
516
  if (items.length === 0) return;
@@ -621,11 +566,13 @@ function useListboxPopup({
621
566
  break;
622
567
  case "Home":
623
568
  event.preventDefault();
569
+ if (!isOpen) pendingActiveRef.current = firstEnabled();
624
570
  setIsOpen(true);
625
571
  setActiveIndex(firstEnabled());
626
572
  break;
627
573
  case "End":
628
574
  event.preventDefault();
575
+ if (!isOpen) pendingActiveRef.current = lastEnabled();
629
576
  setIsOpen(true);
630
577
  setActiveIndex(lastEnabled());
631
578
  break;
@@ -670,9 +617,23 @@ function useListboxPopup({
670
617
  );
671
618
  useEffect(() => {
672
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
+ }
673
626
  const preferred = initialActiveIndex?.(items) ?? -1;
674
627
  setActiveIndex(preferred >= 0 ? preferred : items.findIndex((o) => !o.disabled));
675
- }, [isOpen, items]);
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]);
676
637
  useEffect(() => {
677
638
  if (!isOpen || activeIndex < 0) return;
678
639
  const list = listRef.current;
@@ -741,19 +702,19 @@ var Accordion = ({
741
702
  ...props
742
703
  }) => {
743
704
  const isControlled = controlledKeys !== void 0;
744
- const [internalKeys, setInternalKeys] = React11.useState(defaultOpenKeys);
705
+ const [internalKeys, setInternalKeys] = React20.useState(defaultOpenKeys);
745
706
  const open = isControlled ? controlledKeys ?? [] : internalKeys;
746
- const idPrefix = React11.useId();
707
+ const idPrefix = React20.useId();
747
708
  const toggle = (key) => {
748
709
  const isOpen = open.includes(key);
749
710
  const next = isOpen ? open.filter((k) => k !== key) : multiple ? [...open, key] : [key];
750
711
  if (!isControlled) setInternalKeys(next);
751
712
  (onValueChange ?? onChange)?.(next);
752
713
  };
753
- 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) => {
754
715
  const isOpen = open.includes(item.key);
755
- const headerId = `${idPrefix}-${item.key}-header`;
756
- const panelId = `${idPrefix}-${item.key}-panel`;
716
+ const headerId = `${idPrefix}-${index}-header`;
717
+ const panelId = `${idPrefix}-${index}-panel`;
757
718
  return /* @__PURE__ */ jsxs("div", { className: cn("accordion_item", isOpen && "accordion_item_open"), children: [
758
719
  /* @__PURE__ */ jsx("h3", { className: "accordion_header", children: /* @__PURE__ */ jsxs(
759
720
  "button",
@@ -809,8 +770,8 @@ var Avatar = ({
809
770
  style,
810
771
  ...props
811
772
  }) => {
812
- const [imgFailed, setImgFailed] = React11.useState(false);
813
- const showImage = src && !imgFailed;
773
+ const [failedSrc, setFailedSrc] = React20.useState(null);
774
+ const showImage = src && failedSrc !== src;
814
775
  const initials = getInitials(name);
815
776
  return /* @__PURE__ */ jsx(
816
777
  "span",
@@ -823,7 +784,7 @@ var Avatar = ({
823
784
  ...props,
824
785
  children: showImage ? (
825
786
  // biome-ignore lint/performance/noImgElement: DS is framework-agnostic - consumers wrap with next/image
826
- /* @__PURE__ */ jsx("img", { src, alt: name, onError: () => setImgFailed(true), className: "avatar_image" })
787
+ /* @__PURE__ */ jsx("img", { src, alt: name, onError: () => setFailedSrc(src ?? null), className: "avatar_image" })
827
788
  ) : /* @__PURE__ */ jsx("span", { className: "avatar_initials", "aria-hidden": "true", children: initials })
828
789
  }
829
790
  );
@@ -1277,11 +1238,11 @@ var Breadcrumb = ({
1277
1238
  };
1278
1239
  var MENU_GAP = 4;
1279
1240
  var Menu = ({ items, trigger, align = "start" }) => {
1280
- const [open, setOpen] = React11.useState(false);
1281
- const wrapperRef = React11.useRef(null);
1282
- const menuRef = React11.useRef(null);
1283
- const itemRefs = React11.useRef([]);
1284
- const menuId = React11.useId();
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();
1285
1246
  const pos = useAnchoredPosition({
1286
1247
  open,
1287
1248
  anchorRef: wrapperRef,
@@ -1291,7 +1252,7 @@ var Menu = ({ items, trigger, align = "start" }) => {
1291
1252
  gap: MENU_GAP,
1292
1253
  padding: 8
1293
1254
  });
1294
- React11.useEffect(() => {
1255
+ React20.useEffect(() => {
1295
1256
  if (!open || !pos.ready || !pos.anchorHidden) return;
1296
1257
  const focusInMenu = !!menuRef.current?.contains(document.activeElement);
1297
1258
  setOpen(false);
@@ -1303,7 +1264,7 @@ var Menu = ({ items, trigger, align = "start" }) => {
1303
1264
  visible: open,
1304
1265
  from: pos.placement === "top" ? `translateY(${MENU_GAP}px)` : `translateY(-${MENU_GAP}px)`
1305
1266
  });
1306
- React11.useEffect(() => {
1267
+ React20.useEffect(() => {
1307
1268
  if (!open) return;
1308
1269
  const handleClick = (e) => {
1309
1270
  const target = e.target;
@@ -1320,7 +1281,7 @@ var Menu = ({ items, trigger, align = "start" }) => {
1320
1281
  document.removeEventListener("keydown", handleEsc);
1321
1282
  };
1322
1283
  }, [open]);
1323
- React11.useEffect(() => {
1284
+ React20.useEffect(() => {
1324
1285
  const active = document.activeElement;
1325
1286
  if (!open || active && itemRefs.current.includes(active)) return;
1326
1287
  const first = items.findIndex((it) => !it.disabled);
@@ -1367,7 +1328,7 @@ var Menu = ({ items, trigger, align = "start" }) => {
1367
1328
  break;
1368
1329
  }
1369
1330
  };
1370
- const triggerWithProps = React11.cloneElement(
1331
+ const triggerWithProps = React20.cloneElement(
1371
1332
  trigger,
1372
1333
  {
1373
1334
  onClick: () => setOpen((o) => !o),
@@ -1414,6 +1375,7 @@ var Menu = ({ items, trigger, align = "start" }) => {
1414
1375
  ),
1415
1376
  onClick: () => {
1416
1377
  if (item.disabled) return;
1378
+ wrapperRef.current?.querySelector("[aria-haspopup]")?.focus();
1417
1379
  item.onSelect?.();
1418
1380
  setOpen(false);
1419
1381
  },
@@ -1465,7 +1427,9 @@ var NavBar = ({
1465
1427
  mo.observe(links, {
1466
1428
  subtree: true,
1467
1429
  attributes: true,
1468
- attributeFilter: ["class", "aria-current"]
1430
+ attributeFilter: ["class", "aria-current"],
1431
+ childList: true,
1432
+ characterData: true
1469
1433
  });
1470
1434
  const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : null;
1471
1435
  ro?.observe(links);
@@ -1576,11 +1540,13 @@ var LocaleSwitcher = ({ locale }) => {
1576
1540
  wrapperRef.current?.querySelector("[aria-haspopup]")?.focus();
1577
1541
  break;
1578
1542
  case "Tab":
1543
+ wrapperRef.current?.querySelector("[aria-haspopup]")?.focus();
1579
1544
  setOpen(false);
1580
1545
  break;
1581
1546
  }
1582
1547
  };
1583
1548
  const handleSelect = (value) => {
1549
+ wrapperRef.current?.querySelector("[aria-haspopup]")?.focus();
1584
1550
  (locale.onValueChange ?? locale.onChange)?.(value);
1585
1551
  setOpen(false);
1586
1552
  };
@@ -1656,9 +1622,9 @@ var Sidebar = ({
1656
1622
  const t = useLocaleText();
1657
1623
  const toggleLabel = toggleLabelProp ?? t("sidebar.toggle");
1658
1624
  const isControlled = collapsedProp !== void 0;
1659
- const [internalCollapsed, setInternalCollapsed] = React11.useState(defaultCollapsed);
1625
+ const [internalCollapsed, setInternalCollapsed] = React20.useState(defaultCollapsed);
1660
1626
  const collapsed = isControlled ? collapsedProp : internalCollapsed;
1661
- const toggle = React11.useCallback(() => {
1627
+ const toggle = React20.useCallback(() => {
1662
1628
  const next = !collapsed;
1663
1629
  if (!isControlled) setInternalCollapsed(next);
1664
1630
  onCollapsedChange?.(next);
@@ -1760,9 +1726,9 @@ var SidebarSection = ({ label, className, children, ...props }) => {
1760
1726
  children
1761
1727
  ] });
1762
1728
  };
1763
- var TabsContext = React11.createContext(null);
1729
+ var TabsContext = React20.createContext(null);
1764
1730
  function useTabsContext() {
1765
- const ctx = React11.useContext(TabsContext);
1731
+ const ctx = React20.useContext(TabsContext);
1766
1732
  if (!ctx) {
1767
1733
  throw new Error(
1768
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>'
@@ -1781,18 +1747,18 @@ var Tabs = ({
1781
1747
  ...props
1782
1748
  }) => {
1783
1749
  const isControlled = controlledValue !== void 0;
1784
- const [internalValue, setInternalValue] = React11.useState(defaultValue);
1750
+ const [internalValue, setInternalValue] = React20.useState(defaultValue);
1785
1751
  const value = isControlled ? controlledValue : internalValue;
1786
- const setValue = React11.useCallback(
1752
+ const setValue = React20.useCallback(
1787
1753
  (v) => {
1788
1754
  if (!isControlled) setInternalValue(v);
1789
1755
  onValueChange?.(v);
1790
1756
  },
1791
1757
  [isControlled, onValueChange]
1792
1758
  );
1793
- const orderRef = React11.useRef([]);
1794
- const [firstTabValue, setFirstTabValue] = React11.useState();
1795
- const registerTab = React11.useCallback((v) => {
1759
+ const orderRef = React20.useRef([]);
1760
+ const [firstTabValue, setFirstTabValue] = React20.useState();
1761
+ const registerTab = React20.useCallback((v) => {
1796
1762
  if (!orderRef.current.includes(v)) {
1797
1763
  orderRef.current = [...orderRef.current, v];
1798
1764
  setFirstTabValue(orderRef.current[0]);
@@ -1802,8 +1768,8 @@ var Tabs = ({
1802
1768
  setFirstTabValue(orderRef.current[0]);
1803
1769
  };
1804
1770
  }, []);
1805
- const idPrefix = React11.useId();
1806
- const ctx = React11.useMemo(
1771
+ const idPrefix = React20.useId();
1772
+ const ctx = React20.useMemo(
1807
1773
  () => ({ value, setValue, variant, size, idPrefix, registerTab, firstTabValue }),
1808
1774
  [value, setValue, variant, size, idPrefix, registerTab, firstTabValue]
1809
1775
  );
@@ -1818,9 +1784,9 @@ var Tabs = ({
1818
1784
  };
1819
1785
  var TabList = ({ ariaLabel, className, children, ...props }) => {
1820
1786
  const { variant } = useTabsContext();
1821
- const listRef = React11.useRef(null);
1822
- const [indicator, setIndicator] = React11.useState(null);
1823
- const [hasMounted, setHasMounted] = React11.useState(false);
1787
+ const listRef = React20.useRef(null);
1788
+ const [indicator, setIndicator] = React20.useState(null);
1789
+ const [hasMounted, setHasMounted] = React20.useState(false);
1824
1790
  useSafeLayoutEffect(() => {
1825
1791
  const list = listRef.current;
1826
1792
  if (!list) return;
@@ -1838,7 +1804,9 @@ var TabList = ({ ariaLabel, className, children, ...props }) => {
1838
1804
  mo.observe(list, {
1839
1805
  subtree: true,
1840
1806
  attributes: true,
1841
- attributeFilter: ["aria-selected"]
1807
+ attributeFilter: ["aria-selected"],
1808
+ childList: true,
1809
+ characterData: true
1842
1810
  });
1843
1811
  const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : null;
1844
1812
  ro?.observe(list);
@@ -1883,7 +1851,7 @@ var Tab = ({ value, className, children, onClick, onKeyDown, ...props }) => {
1883
1851
  const panelId = `${ctx.idPrefix}-panel-${value}`;
1884
1852
  const tabId = `${ctx.idPrefix}-tab-${value}`;
1885
1853
  const { registerTab } = ctx;
1886
- React11.useEffect(() => registerTab(value), [registerTab, value]);
1854
+ React20.useEffect(() => registerTab(value), [registerTab, value]);
1887
1855
  const handleClick = (e) => {
1888
1856
  ctx.setValue(value);
1889
1857
  onClick?.(e);
@@ -1969,15 +1937,15 @@ var Popover = ({
1969
1937
  className
1970
1938
  }) => {
1971
1939
  const isControlled = openProp !== void 0;
1972
- const [internalOpen, setInternalOpen] = React11.useState(defaultOpen);
1940
+ const [internalOpen, setInternalOpen] = React20.useState(defaultOpen);
1973
1941
  const open = isControlled ? openProp : internalOpen;
1974
- const [shouldRender, setShouldRender] = React11.useState(open ?? false);
1942
+ const [shouldRender, setShouldRender] = React20.useState(open ?? false);
1975
1943
  if (open && !shouldRender) setShouldRender(true);
1976
- const wrapperRef = React11.useRef(null);
1977
- const positionRef = React11.useRef(null);
1978
- const popoverRef = React11.useRef(null);
1979
- const popoverId = React11.useId();
1980
- const setOpen = React11.useCallback(
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(
1981
1949
  (next) => {
1982
1950
  if (!isControlled) setInternalOpen(next);
1983
1951
  onOpenChange?.(next);
@@ -2010,7 +1978,7 @@ var Popover = ({
2010
1978
  onExitComplete: () => setShouldRender(false)
2011
1979
  });
2012
1980
  useFocusTrap(popoverRef, open);
2013
- React11.useEffect(() => {
1981
+ React20.useEffect(() => {
2014
1982
  if (!open) return;
2015
1983
  const handleClick = (e) => {
2016
1984
  const target = e.target;
@@ -2024,7 +1992,7 @@ var Popover = ({
2024
1992
  useOverlayEscape(open, () => {
2025
1993
  setOpen(false);
2026
1994
  });
2027
- const triggerWithProps = React11.cloneElement(
1995
+ const triggerWithProps = React20.cloneElement(
2028
1996
  trigger,
2029
1997
  {
2030
1998
  onClick: (e) => {
@@ -2083,30 +2051,30 @@ var Tooltip = ({
2083
2051
  disabled = false,
2084
2052
  children
2085
2053
  }) => {
2086
- const [open, setOpen] = React11.useState(false);
2087
- const [shouldRender, setShouldRender] = React11.useState(false);
2054
+ const [open, setOpen] = React20.useState(false);
2055
+ const [shouldRender, setShouldRender] = React20.useState(false);
2088
2056
  if (open && !shouldRender) setShouldRender(true);
2089
- const timerRef = React11.useRef(null);
2090
- const tooltipId = React11.useId();
2091
- const wrapperRef = React11.useRef(null);
2092
- const positionRef = React11.useRef(null);
2057
+ const timerRef = React20.useRef(null);
2058
+ const tooltipId = React20.useId();
2059
+ const wrapperRef = React20.useRef(null);
2060
+ const positionRef = React20.useRef(null);
2093
2061
  const HIDE_DELAY = 120;
2094
- const show = React11.useCallback(() => {
2062
+ const show = React20.useCallback(() => {
2095
2063
  if (timerRef.current) clearTimeout(timerRef.current);
2096
2064
  timerRef.current = setTimeout(() => setOpen(true), delay);
2097
2065
  }, [delay]);
2098
- const hideNow = React11.useCallback(() => {
2066
+ const hideNow = React20.useCallback(() => {
2099
2067
  if (timerRef.current) clearTimeout(timerRef.current);
2100
2068
  setOpen(false);
2101
2069
  }, []);
2102
- const hide = React11.useCallback(() => {
2070
+ const hide = React20.useCallback(() => {
2103
2071
  if (timerRef.current) clearTimeout(timerRef.current);
2104
2072
  timerRef.current = setTimeout(() => setOpen(false), HIDE_DELAY);
2105
2073
  }, []);
2106
- const cancelHide = React11.useCallback(() => {
2074
+ const cancelHide = React20.useCallback(() => {
2107
2075
  if (timerRef.current) clearTimeout(timerRef.current);
2108
2076
  }, []);
2109
- React11.useEffect(() => {
2077
+ React20.useEffect(() => {
2110
2078
  return () => {
2111
2079
  if (timerRef.current) clearTimeout(timerRef.current);
2112
2080
  };
@@ -2120,7 +2088,7 @@ var Tooltip = ({
2120
2088
  gap: TOOLTIP_GAP,
2121
2089
  padding: 8
2122
2090
  });
2123
- React11.useEffect(() => {
2091
+ React20.useEffect(() => {
2124
2092
  if (open && pos.ready && pos.anchorHidden) hideNow();
2125
2093
  }, [open, pos.ready, pos.anchorHidden, hideNow]);
2126
2094
  const fromTransform = (() => {
@@ -2142,7 +2110,7 @@ var Tooltip = ({
2142
2110
  });
2143
2111
  const child = children;
2144
2112
  const childProps = child.props;
2145
- const trigger = React11.cloneElement(child, {
2113
+ const trigger = React20.cloneElement(child, {
2146
2114
  onMouseEnter: (e) => {
2147
2115
  childProps.onMouseEnter?.(e);
2148
2116
  show();
@@ -2981,20 +2949,18 @@ var TextField = ({
2981
2949
  const clearLabel = clearLabelProp ?? t("textField.clear");
2982
2950
  const generatedId = useId();
2983
2951
  const field = useFieldControl();
2984
- const inputId = id ?? field?.inputId ?? generatedId;
2985
- const helperId = supportingText ? `${inputId}-help` : void 0;
2986
- const describedBy = field?.describedBy ?? helperId;
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;
2987
2955
  const isControlled = value !== void 0;
2988
2956
  const applyTransform = (nextValue) => transformValue ? transformValue(nextValue) : nextValue;
2989
2957
  const [innerValue, setInnerValue] = useState(() => applyTransform(value ?? defaultValue ?? ""));
2990
2958
  const isComposingRef = useRef(false);
2991
2959
  const lastEmittedValueRef = useRef(innerValue);
2992
- const [prevValue, setPrevValue] = useState(value);
2993
- if (isControlled && value !== prevValue && !isComposingRef.current) {
2994
- setPrevValue(value);
2995
- const nextValue = applyTransform(value ?? "");
2996
- setInnerValue(nextValue);
2997
- lastEmittedValueRef.current = nextValue;
2960
+ const nextControlledValue = applyTransform(value ?? "");
2961
+ if (isControlled && !isComposingRef.current && nextControlledValue !== innerValue) {
2962
+ setInnerValue(nextControlledValue);
2963
+ lastEmittedValueRef.current = nextControlledValue;
2998
2964
  }
2999
2965
  const emit = useCallback(
3000
2966
  (nextValue) => {
@@ -3066,14 +3032,14 @@ var TextField = ({
3066
3032
  children: /* @__PURE__ */ jsx(
3067
3033
  "input",
3068
3034
  {
3035
+ ...props,
3069
3036
  id: inputId,
3070
3037
  ref,
3071
3038
  className: cn("text_field_input", identifier && "text_field_input_identifier"),
3072
- "aria-invalid": isError,
3039
+ "aria-invalid": field ? isError : props["aria-invalid"] ?? isError,
3073
3040
  "aria-describedby": describedBy,
3074
- "aria-required": field?.required || void 0,
3075
- "aria-label": !showLabel ? label : void 0,
3076
- ...props,
3041
+ "aria-required": field ? field.required || void 0 : props["aria-required"],
3042
+ "aria-label": (!showLabel ? label : void 0) ?? props["aria-label"],
3077
3043
  type: resolvedType,
3078
3044
  value: innerValue,
3079
3045
  onCompositionStart: () => {
@@ -3219,7 +3185,7 @@ var Pagination = ({
3219
3185
  const emit = onPageChange ?? onChange;
3220
3186
  const prevDisabled = page <= 1;
3221
3187
  const nextDisabled = page >= totalPages;
3222
- const items = React11.useMemo(() => getPaginationItems(page, totalPages), [page, totalPages]);
3188
+ const items = React20.useMemo(() => getPaginationItems(page, totalPages), [page, totalPages]);
3223
3189
  return /* @__PURE__ */ jsxs("nav", { className: "pagination", "aria-label": navLabel, children: [
3224
3190
  /* @__PURE__ */ jsx(
3225
3191
  "button",
@@ -3299,12 +3265,12 @@ var Checkbox = ({
3299
3265
  ref,
3300
3266
  ...props
3301
3267
  }) => {
3302
- const inputRef = React11.useRef(null);
3303
- React11.useImperativeHandle(
3268
+ const inputRef = React20.useRef(null);
3269
+ React20.useImperativeHandle(
3304
3270
  ref,
3305
3271
  () => inputRef.current
3306
3272
  );
3307
- React11.useEffect(() => {
3273
+ React20.useEffect(() => {
3308
3274
  if (!inputRef.current) return;
3309
3275
  inputRef.current.indeterminate = Boolean(indeterminate);
3310
3276
  }, [indeterminate]);
@@ -3326,7 +3292,7 @@ var Checkbox = ({
3326
3292
  id: field?.inputId ?? props.id,
3327
3293
  "aria-describedby": field?.describedBy ?? props["aria-describedby"],
3328
3294
  "aria-required": field?.required || void 0,
3329
- "aria-invalid": error || void 0
3295
+ "aria-invalid": error || (field ? field.invalid || void 0 : props["aria-invalid"])
3330
3296
  }
3331
3297
  ),
3332
3298
  /* @__PURE__ */ jsx("span", { className: "checkbox_state_layer", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "checkbox_icon" }) }),
@@ -3368,11 +3334,38 @@ var Table = ({
3368
3334
  stickyHeader && "table_sticky_header",
3369
3335
  className
3370
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
+ }, []);
3371
3364
  const isEmpty = !isLoading && data.length === 0;
3372
3365
  const getRowKey = (item, index) => rowKey?.(item) ?? String(index);
3373
3366
  const allRowKeys = selectable ? data.map((item, index) => getRowKey(item, index)) : [];
3374
- const rowClickHintId = React11.useId();
3375
- const selectedSet = React11.useMemo(() => new Set(selectedKeys ?? []), [selectedKeys]);
3367
+ const rowClickHintId = React20.useId();
3368
+ const selectedSet = React20.useMemo(() => new Set(selectedKeys ?? []), [selectedKeys]);
3376
3369
  const selectedCount = allRowKeys.filter((key) => selectedSet.has(key)).length;
3377
3370
  const isAllSelected = allRowKeys.length > 0 && selectedCount === allRowKeys.length;
3378
3371
  const isSomeSelected = selectedCount > 0 && !isAllSelected;
@@ -3390,7 +3383,7 @@ var Table = ({
3390
3383
  const next = sort?.key !== key ? { key, direction: "asc" } : sort.direction === "asc" ? { key, direction: "desc" } : void 0;
3391
3384
  onSortChange?.(next);
3392
3385
  };
3393
- return /* @__PURE__ */ jsxs("div", { className: wrapperClassName, children: [
3386
+ return /* @__PURE__ */ jsxs("div", { ref: wrapperRef, className: wrapperClassName, children: [
3394
3387
  /* @__PURE__ */ jsxs("table", { className: "table", "aria-label": ariaLabel, "aria-busy": isLoading || void 0, children: [
3395
3388
  /* @__PURE__ */ jsx("thead", { className: "table_thead", children: /* @__PURE__ */ jsxs("tr", { children: [
3396
3389
  selectable && /* @__PURE__ */ jsx("th", { scope: "col", className: "table_th table_th_checkbox", children: /* @__PURE__ */ jsx(
@@ -3562,6 +3555,17 @@ var DataView = ({
3562
3555
  const selectionBarId = useId();
3563
3556
  const selectable = !!selectionActions?.length;
3564
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]);
3565
3569
  const showEmpty = !query.isLoading && !query.error && rows.length === 0;
3566
3570
  if (query.error) {
3567
3571
  return /* @__PURE__ */ jsx("div", { className: cn("data_view", className), ...props, children: /* @__PURE__ */ jsx(
@@ -3813,25 +3817,44 @@ var MediaCard = ({
3813
3817
  ] });
3814
3818
  };
3815
3819
  var Prose = ({ size = "md", className, children, ref, ...props }) => {
3816
- const rootRef = React11.useRef(null);
3817
- React11.useImperativeHandle(ref, () => rootRef.current, []);
3820
+ const rootRef = React20.useRef(null);
3821
+ React20.useImperativeHandle(ref, () => rootRef.current, []);
3818
3822
  useSafeLayoutEffect(() => {
3819
3823
  const root = rootRef.current;
3820
3824
  if (!root) return;
3821
- const targets = Array.from(root.querySelectorAll("pre, table"));
3825
+ const hasResizeObserver = typeof ResizeObserver !== "undefined";
3826
+ const observed = /* @__PURE__ */ new Set();
3827
+ let resizeObserver = null;
3822
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
+ }
3823
3835
  for (const el of targets) {
3824
3836
  if (el.scrollWidth > el.clientWidth) el.setAttribute("tabindex", "0");
3825
3837
  else el.removeAttribute("tabindex");
3838
+ if (resizeObserver && !observed.has(el)) {
3839
+ resizeObserver.observe(el);
3840
+ observed.add(el);
3841
+ }
3826
3842
  }
3827
3843
  };
3844
+ if (hasResizeObserver) {
3845
+ resizeObserver = new ResizeObserver(sync);
3846
+ resizeObserver.observe(root);
3847
+ }
3828
3848
  sync();
3829
- if (typeof ResizeObserver === "undefined") return;
3830
- const observer = new ResizeObserver(sync);
3831
- observer.observe(root);
3832
- for (const el of targets) observer.observe(el);
3833
- return () => observer.disconnect();
3834
- }, [children]);
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
+ }, []);
3835
3858
  return /* @__PURE__ */ jsx("div", { ref: rootRef, className: cn("prose", `prose_size_${size}`, className), ...props, children });
3836
3859
  };
3837
3860
  Prose.displayName = "Prose";
@@ -3859,6 +3882,9 @@ var AlertProvider = ({ children }) => {
3859
3882
  const handleClose = useCallback(() => {
3860
3883
  setAlertState((prev) => ({ ...prev, isOpen: false }));
3861
3884
  }, []);
3885
+ const handleExited = useCallback(() => {
3886
+ setAlertState((prev) => prev.isOpen ? prev : { isOpen: false });
3887
+ }, []);
3862
3888
  const handleConfirm = useCallback(() => {
3863
3889
  alertState.onConfirm?.();
3864
3890
  handleClose();
@@ -3875,7 +3901,8 @@ var AlertProvider = ({ children }) => {
3875
3901
  ...alertState,
3876
3902
  onConfirm: handleConfirm,
3877
3903
  onCancel: handleCancel,
3878
- onClose: handleClose
3904
+ onClose: handleClose,
3905
+ onExited: handleExited
3879
3906
  }
3880
3907
  )
3881
3908
  ] });
@@ -3894,29 +3921,31 @@ var AlertModal = ({
3894
3921
  closeOnOverlay = true,
3895
3922
  onConfirm,
3896
3923
  onCancel,
3897
- onClose
3924
+ onClose,
3925
+ onExited
3898
3926
  }) => {
3899
3927
  const t = useLocaleText();
3900
3928
  const confirmText = confirmTextProp ?? t("alert.confirm");
3901
3929
  const cancelText = cancelTextProp ?? t("alert.cancel");
3902
3930
  const dismiss = onCancel ?? onClose;
3903
- const panelRef = React11.useRef(null);
3904
- const titleId = React11.useId();
3905
- const messageId = React11.useId();
3931
+ const panelRef = React20.useRef(null);
3932
+ const pressedOverlayRef = React20.useRef(false);
3933
+ const titleId = React20.useId();
3934
+ const messageId = React20.useId();
3906
3935
  const [shouldRender, setShouldRender] = useState(isOpen);
3907
3936
  useFocusTrap(panelRef, isOpen);
3908
3937
  useOverlayEscape(isOpen, () => dismiss());
3909
3938
  if (isOpen && !shouldRender) setShouldRender(true);
3910
3939
  const reduced = useReducedMotion();
3911
- const dimOwner = React11.useRef({}).current;
3912
3940
  const overlayStyle = useSpring({
3913
3941
  ...springEnterFrom(reduced),
3914
3942
  to: { opacity: isOpen ? 1 : 0 },
3915
3943
  immediate: reduced,
3916
3944
  config: OVERLAY_SPRING_CONFIG,
3917
- onChange: (result) => reportOverlayDim(dimOwner, Number(result.value.opacity)),
3918
3945
  onRest: (result) => {
3919
- if (!isOpen && result.finished) setShouldRender(false);
3946
+ if (isOpen || !result.finished) return;
3947
+ setShouldRender(false);
3948
+ onExited?.();
3920
3949
  }
3921
3950
  });
3922
3951
  const panelStyle = useSpring({
@@ -3928,13 +3957,11 @@ var AlertModal = ({
3928
3957
  immediate: reduced,
3929
3958
  config: OVERLAY_SPRING_CONFIG
3930
3959
  });
3931
- React11.useEffect(() => {
3960
+ React20.useEffect(() => {
3932
3961
  if (!shouldRender) return;
3933
- reportOverlayDim(dimOwner, reduced ? 1 : 0);
3934
3962
  lockBodyScroll();
3935
3963
  return () => {
3936
3964
  unlockBodyScroll();
3937
- unregisterOverlayDim(dimOwner);
3938
3965
  };
3939
3966
  }, [shouldRender]);
3940
3967
  if (!isOpen && !shouldRender) return null;
@@ -3948,7 +3975,15 @@ var AlertModal = ({
3948
3975
  className: "alert_overlay",
3949
3976
  style: overlayStyle,
3950
3977
  role: "presentation",
3951
- onClick: () => closeOnOverlay && dismiss(),
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
+ },
3952
3987
  children: /* @__PURE__ */ jsxs(
3953
3988
  animated.div,
3954
3989
  {
@@ -4005,7 +4040,7 @@ var LinearProgress = ({
4005
4040
  {
4006
4041
  className: cn("linear_progress", className),
4007
4042
  role: "progressbar",
4008
- "aria-valuenow": currentStep,
4043
+ "aria-valuenow": clampedStep,
4009
4044
  "aria-valuemin": 0,
4010
4045
  "aria-valuemax": totalSteps,
4011
4046
  ...props,
@@ -4041,7 +4076,7 @@ var Spinner = ({ size = 24, ariaLabel: ariaLabelProp }) => {
4041
4076
  }
4042
4077
  );
4043
4078
  };
4044
- var ToastContext = React11.createContext(null);
4079
+ var ToastContext = React20.createContext(null);
4045
4080
  var VARIANT_ICONS = {
4046
4081
  success: /* @__PURE__ */ jsx(CheckCircle2, { size: iconSize.md }),
4047
4082
  error: /* @__PURE__ */ jsx(XCircle, { size: iconSize.md }),
@@ -4050,9 +4085,9 @@ var VARIANT_ICONS = {
4050
4085
  default: /* @__PURE__ */ jsx(Bell, { size: iconSize.md })
4051
4086
  };
4052
4087
  var ToastItemComponent = ({ item, onRemove, closeAriaLabel }) => {
4053
- const [visible, setVisible] = React11.useState(true);
4054
- const closingRef = React11.useRef(false);
4055
- const rootRef = React11.useRef(null);
4088
+ const [visible, setVisible] = React20.useState(true);
4089
+ const closingRef = React20.useRef(false);
4090
+ const rootRef = React20.useRef(null);
4056
4091
  const style = useSpringPresence({
4057
4092
  visible,
4058
4093
  from: "translateX(20px)",
@@ -4072,7 +4107,7 @@ var ToastItemComponent = ({ item, onRemove, closeAriaLabel }) => {
4072
4107
  onRemove(item.id);
4073
4108
  }
4074
4109
  });
4075
- const close = React11.useCallback(() => {
4110
+ const close = React20.useCallback(() => {
4076
4111
  if (closingRef.current) return;
4077
4112
  closingRef.current = true;
4078
4113
  setVisible(false);
@@ -4101,6 +4136,7 @@ var ToastItemComponent = ({ item, onRemove, closeAriaLabel }) => {
4101
4136
  }
4102
4137
  );
4103
4138
  };
4139
+ var toastSeq = 0;
4104
4140
  var ToastProvider = ({
4105
4141
  children,
4106
4142
  maxCount = 5,
@@ -4110,19 +4146,19 @@ var ToastProvider = ({
4110
4146
  const t = useLocaleText();
4111
4147
  const closeAriaLabel = closeAriaLabelProp ?? t("toast.close");
4112
4148
  const regionLabel = regionLabelProp ?? t("toast.region");
4113
- const [toasts, setToasts] = React11.useState([]);
4149
+ const [toasts, setToasts] = React20.useState([]);
4114
4150
  const isMounted = useIsMounted();
4115
- const addToast = React11.useCallback(
4151
+ const addToast = React20.useCallback(
4116
4152
  (message, variant, duration = 3e3) => {
4117
- const id = crypto.randomUUID();
4153
+ const id = `toast_${++toastSeq}`;
4118
4154
  setToasts((prev) => [{ id, message, variant, duration }, ...prev].slice(0, maxCount));
4119
4155
  },
4120
4156
  [maxCount]
4121
4157
  );
4122
- const removeToast = React11.useCallback((id) => {
4158
+ const removeToast = React20.useCallback((id) => {
4123
4159
  setToasts((prev) => prev.filter((t2) => t2.id !== id));
4124
4160
  }, []);
4125
- const contextValue = React11.useMemo(() => ({ addToast }), [addToast]);
4161
+ const contextValue = React20.useMemo(() => ({ addToast }), [addToast]);
4126
4162
  return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: contextValue, children: [
4127
4163
  children,
4128
4164
  isMounted && createPortal(
@@ -4260,6 +4296,10 @@ var Combobox = ({
4260
4296
  });
4261
4297
  const { isOpen, setIsOpen, close, activeIndex, setActiveIndex } = popup;
4262
4298
  closeRef.current = close;
4299
+ const onSearchRef = useRef(onSearch);
4300
+ useEffect(() => {
4301
+ onSearchRef.current = onSearch;
4302
+ });
4263
4303
  useEffect(() => {
4264
4304
  if (!isOpen) return;
4265
4305
  if (query === "") {
@@ -4272,7 +4312,7 @@ var Combobox = ({
4272
4312
  const seq = ++requestSeq.current;
4273
4313
  setIsLoading(true);
4274
4314
  const timer = setTimeout(() => {
4275
- onSearch(query).then((result) => {
4315
+ onSearchRef.current(query).then((result) => {
4276
4316
  if (seq !== requestSeq.current) return;
4277
4317
  setOptions(result);
4278
4318
  setHasSearched(true);
@@ -4286,7 +4326,7 @@ var Combobox = ({
4286
4326
  });
4287
4327
  }, debounceMs);
4288
4328
  return () => clearTimeout(timer);
4289
- }, [query, isOpen, debounceMs, onSearch]);
4329
+ }, [query, isOpen, debounceMs]);
4290
4330
  const rootClassName = cn(
4291
4331
  "combobox",
4292
4332
  `combobox_size_${size}`,
@@ -4723,9 +4763,9 @@ var DatePicker = ({
4723
4763
  const minDateSrFormat = minDateSrFormatProp ?? t("datePicker.minDateSr");
4724
4764
  const selectableRangeUntilTodaySrText = selectableRangeUntilTodaySrTextProp ?? t("datePicker.rangeUntilTodaySr");
4725
4765
  const field = useFieldControl();
4726
- const groupId = React11.useId();
4727
- const constraintId = React11.useId();
4728
- const { todayYear, todayMonth, todayDay } = React11.useMemo(() => {
4766
+ const groupId = React20.useId();
4767
+ const constraintId = React20.useId();
4768
+ const { todayYear, todayMonth, todayDay } = React20.useMemo(() => {
4729
4769
  const now = /* @__PURE__ */ new Date();
4730
4770
  return {
4731
4771
  todayYear: now.getFullYear(),
@@ -4734,7 +4774,7 @@ var DatePicker = ({
4734
4774
  };
4735
4775
  }, []);
4736
4776
  const endYear = endYearProp ?? todayYear + 10;
4737
- const parsed = React11.useMemo(() => {
4777
+ const parsed = React20.useMemo(() => {
4738
4778
  if (!value) return { year: 0, month: 0, day: 0 };
4739
4779
  const [y, m, d] = value.split("-").map(Number);
4740
4780
  return {
@@ -4743,7 +4783,7 @@ var DatePicker = ({
4743
4783
  day: d || 0
4744
4784
  };
4745
4785
  }, [value]);
4746
- const min = React11.useMemo(() => {
4786
+ const min = React20.useMemo(() => {
4747
4787
  if (!minDate) return { year: 0, month: 0, day: 0 };
4748
4788
  const [y, m, d] = minDate.split("-").map(Number);
4749
4789
  return {
@@ -4756,56 +4796,79 @@ var DatePicker = ({
4756
4796
  const maxYear = selectableRange === "until-today" ? todayYear : endYear;
4757
4797
  const minMonth = min.year > 0 && year === min.year ? Math.min(12, Math.max(1, min.month)) : 1;
4758
4798
  const maxMonth = selectableRange === "until-today" && year === todayYear ? todayMonth : 12;
4759
- const minDay = Math.min(
4760
- 31,
4761
- Math.max(
4762
- 1,
4763
- min.year > 0 && min.month > 0 && year === min.year && month === min.month ? min.day : 1
4764
- )
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]
4765
4808
  );
4766
- const maxDay = React11.useMemo(() => {
4767
- if (!year || !month) return 31;
4768
- const daysInMonth = getDaysInMonth(year, month);
4769
- if (selectableRange === "until-today" && year === todayYear && month === todayMonth) {
4770
- return Math.min(daysInMonth, todayDay);
4771
- }
4772
- return daysInMonth;
4773
- }, [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;
4774
4814
  const minYear = min.year > 0 ? Math.max(startYear, min.year) : startYear;
4775
- const yearOptions = React11.useMemo(
4776
- () => range2(minYear, Math.max(minYear, maxYear)).map((y) => ({
4815
+ const yearOptions = React20.useMemo(
4816
+ () => range2(minYear, maxYear).map((y) => ({
4777
4817
  value: String(y),
4778
4818
  label: String(y)
4779
4819
  })),
4780
4820
  [minYear, maxYear]
4781
4821
  );
4782
- const monthOptions = React11.useMemo(
4783
- () => range2(minMonth, Math.max(minMonth, maxMonth)).map((m) => ({
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) => ({
4784
4827
  value: String(m),
4785
4828
  label: pad(m)
4786
4829
  })),
4787
- [minMonth, maxMonth]
4830
+ [minMonth, maxMonth, dayBoundsFor, year]
4788
4831
  );
4789
- const dayOptions = React11.useMemo(
4790
- () => range2(minDay, Math.max(minDay, maxDay)).map((d) => ({
4832
+ const dayOptions = React20.useMemo(
4833
+ () => hasSelectableDay ? range2(minDay, maxDay).map((d) => ({
4791
4834
  value: String(d),
4792
4835
  label: pad(d)
4793
- })),
4794
- [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]
4795
4853
  );
4796
- const emit = React11.useCallback(
4854
+ const emit = React20.useCallback(
4797
4855
  (yy, mm, dd) => {
4798
4856
  const cb = onValueChange ?? onChange;
4799
4857
  if (mode === "year-month") {
4858
+ const monthBounds = dayBoundsFor(yy, mm);
4859
+ if (monthBounds.max < monthBounds.min) return;
4800
4860
  cb?.(`${yy}-${pad(mm)}`);
4801
4861
  return;
4802
4862
  }
4803
- const safeDay = Math.min(dd ?? 1, getDaysInMonth(yy, mm));
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;
4804
4867
  cb?.(`${yy}-${pad(mm)}-${pad(safeDay)}`);
4805
4868
  },
4806
- [mode, onValueChange, onChange]
4869
+ [mode, onValueChange, onChange, dayBoundsFor, withinRange]
4807
4870
  );
4808
- const handleYearChange = React11.useCallback(
4871
+ const handleYearChange = React20.useCallback(
4809
4872
  (raw) => {
4810
4873
  if (!raw) return;
4811
4874
  const newYear = Number(raw);
@@ -4822,14 +4885,14 @@ var DatePicker = ({
4822
4885
  },
4823
4886
  [month, day, min.year, min.month, selectableRange, todayYear, todayMonth, emit]
4824
4887
  );
4825
- const handleMonthChange = React11.useCallback(
4888
+ const handleMonthChange = React20.useCallback(
4826
4889
  (raw) => {
4827
4890
  if (!raw || !year) return;
4828
4891
  emit(year, Number(raw), day || void 0);
4829
4892
  },
4830
4893
  [year, day, emit]
4831
4894
  );
4832
- const handleDayChange = React11.useCallback(
4895
+ const handleDayChange = React20.useCallback(
4833
4896
  (raw) => {
4834
4897
  if (!raw || !year || !month) return;
4835
4898
  emit(year, month, Number(raw));
@@ -4991,13 +5054,13 @@ var FileInput = ({
4991
5054
  }) => {
4992
5055
  const t = useLocaleText();
4993
5056
  const label = labelProp ?? t("fileInput.label");
4994
- const generatedInputId = React11.useId();
4995
- const helperId = React11.useId();
5057
+ const generatedInputId = React20.useId();
5058
+ const helperId = React20.useId();
4996
5059
  const field = useFieldControl();
4997
5060
  const inputId = field?.inputId ?? generatedInputId;
4998
- const inputRef = React11.useRef(null);
4999
- const [previewUrls, setPreviewUrls] = React11.useState([]);
5000
- const previewUrlsRef = React11.useRef([]);
5061
+ const inputRef = React20.useRef(null);
5062
+ const [previewUrls, setPreviewUrls] = React20.useState([]);
5063
+ const previewUrlsRef = React20.useRef([]);
5001
5064
  const isPreviewVariant = variant === "preview";
5002
5065
  const showPreview = isPreviewVariant || preview;
5003
5066
  const handleChange = (e) => {
@@ -5038,7 +5101,7 @@ var FileInput = ({
5038
5101
  }
5039
5102
  onFiles?.(null);
5040
5103
  };
5041
- React11.useEffect(() => {
5104
+ React20.useEffect(() => {
5042
5105
  return () => {
5043
5106
  for (const url of previewUrlsRef.current) {
5044
5107
  URL.revokeObjectURL(url);
@@ -5064,7 +5127,7 @@ var FileInput = ({
5064
5127
  className: "file_input_control",
5065
5128
  disabled,
5066
5129
  accept: isPreviewVariant ? accept ?? "image/*" : accept,
5067
- "aria-describedby": field?.describedBy ?? (supportingText ? helperId : void 0),
5130
+ "aria-describedby": [field?.describedBy, supportingText ? helperId : void 0].filter(Boolean).join(" ") || void 0,
5068
5131
  "aria-invalid": field?.invalid || void 0,
5069
5132
  onChange: handleChange
5070
5133
  }
@@ -5352,6 +5415,7 @@ function ImageCropper({
5352
5415
  "aria-labelledby": field?.labelId,
5353
5416
  "aria-label": field?.labelId ? void 0 : label,
5354
5417
  "aria-describedby": [field?.describedBy, hintId].filter(Boolean).join(" "),
5418
+ "aria-invalid": field?.invalid || void 0,
5355
5419
  tabIndex: imageSize ? 0 : -1,
5356
5420
  onPointerDown: handlePointerDown,
5357
5421
  onPointerMove: handlePointerMove,
@@ -5444,12 +5508,13 @@ var OtpInput = ({
5444
5508
  }) => {
5445
5509
  const t = useLocaleText();
5446
5510
  const ariaLabel = ariaLabelProp ?? t("otpInput.label");
5447
- const inputsRef = React11.useRef([]);
5448
- const isTypingRef = React11.useRef(false);
5449
- React11.useEffect(() => {
5511
+ const inputsRef = React20.useRef([]);
5512
+ const isTypingRef = React20.useRef(false);
5513
+ const typingTimerRef = React20.useRef(void 0);
5514
+ React20.useEffect(() => {
5450
5515
  if (autoFocus) inputsRef.current[0]?.focus();
5451
5516
  }, [autoFocus]);
5452
- const digits = React11.useMemo(() => {
5517
+ const digits = React20.useMemo(() => {
5453
5518
  const chars = value.split("").slice(0, length);
5454
5519
  while (chars.length < length) chars.push("");
5455
5520
  return chars;
@@ -5478,11 +5543,13 @@ var OtpInput = ({
5478
5543
  if (nextDigit && index < length - 1) {
5479
5544
  isTypingRef.current = true;
5480
5545
  focusInput(index + 1);
5481
- setTimeout(() => {
5546
+ clearTimeout(typingTimerRef.current);
5547
+ typingTimerRef.current = setTimeout(() => {
5482
5548
  isTypingRef.current = false;
5483
5549
  }, 50);
5484
5550
  }
5485
5551
  };
5552
+ React20.useEffect(() => () => clearTimeout(typingTimerRef.current), []);
5486
5553
  const handleFocus = (index) => {
5487
5554
  if (isTypingRef.current) return;
5488
5555
  const firstEmpty = digits.indexOf("");
@@ -5526,7 +5593,7 @@ var OtpInput = ({
5526
5593
  focusInput(nextIndex);
5527
5594
  };
5528
5595
  const rootClassName = cn("otp_input", className);
5529
- const supportingId = React11.useId();
5596
+ const supportingId = React20.useId();
5530
5597
  const field = useFieldControl();
5531
5598
  return (
5532
5599
  // biome-ignore lint/a11y/useSemanticElements: <fieldset> would force border/legend styles; role=group is the WAI-ARIA equivalent for OTP grouping
@@ -5557,7 +5624,7 @@ var OtpInput = ({
5557
5624
  disabled,
5558
5625
  "aria-label": t("otpInput.digit", { index: i + 1 }),
5559
5626
  "aria-invalid": error || field?.invalid || void 0,
5560
- "aria-describedby": field?.describedBy ?? (supportingText ? supportingId : void 0),
5627
+ "aria-describedby": [field?.describedBy, supportingText ? supportingId : void 0].filter(Boolean).join(" ") || void 0,
5561
5628
  className: cn(
5562
5629
  "otp_input_box",
5563
5630
  error && "otp_input_box_error",
@@ -5580,9 +5647,9 @@ var OtpInput = ({
5580
5647
  );
5581
5648
  };
5582
5649
  OtpInput.displayName = "OtpInput";
5583
- var RadioGroupContext = React11.createContext(null);
5650
+ var RadioGroupContext = React20.createContext(null);
5584
5651
  function useRadioGroupContext() {
5585
- return React11.useContext(RadioGroupContext);
5652
+ return React20.useContext(RadioGroupContext);
5586
5653
  }
5587
5654
  var RadioGroup = ({
5588
5655
  value: controlledValue,
@@ -5600,22 +5667,22 @@ var RadioGroup = ({
5600
5667
  ...props
5601
5668
  }) => {
5602
5669
  const isControlled = controlledValue !== void 0;
5603
- const [internalValue, setInternalValue] = React11.useState(defaultValue);
5670
+ const [internalValue, setInternalValue] = React20.useState(defaultValue);
5604
5671
  const value = isControlled ? controlledValue : internalValue;
5605
- const generatedName = React11.useId();
5672
+ const generatedName = React20.useId();
5606
5673
  const name = nameProp ?? generatedName;
5607
- const idPrefix = React11.useId();
5674
+ const idPrefix = React20.useId();
5608
5675
  const field = useFieldControl();
5609
5676
  const labelId = label ? `${idPrefix}-label` : void 0;
5610
5677
  const helperId = supportingText ? `${idPrefix}-help` : void 0;
5611
- const onChange = React11.useCallback(
5678
+ const onChange = React20.useCallback(
5612
5679
  (next) => {
5613
5680
  if (!isControlled) setInternalValue(next);
5614
5681
  onValueChange?.(next);
5615
5682
  },
5616
5683
  [isControlled, onValueChange]
5617
5684
  );
5618
- const ctx = React11.useMemo(
5685
+ const ctx = React20.useMemo(
5619
5686
  () => ({ name, value, onChange, size, disabled }),
5620
5687
  [name, value, onChange, size, disabled]
5621
5688
  );
@@ -5676,17 +5743,18 @@ var Radio = ({
5676
5743
  /* @__PURE__ */ jsx(
5677
5744
  "input",
5678
5745
  {
5746
+ ...props,
5679
5747
  ref,
5680
5748
  type: "radio",
5681
5749
  className: "radio_input",
5682
5750
  id: field?.inputId ?? props.id,
5683
5751
  "aria-describedby": field?.describedBy ?? props["aria-describedby"],
5752
+ "aria-invalid": field ? field.invalid || void 0 : props["aria-invalid"],
5684
5753
  value,
5685
5754
  name,
5686
5755
  disabled,
5687
5756
  checked: resolvedChecked,
5688
- onChange: handleChange,
5689
- ...props
5757
+ onChange: handleChange
5690
5758
  }
5691
5759
  ),
5692
5760
  /* @__PURE__ */ jsx("span", { className: "radio_state_layer", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "radio_dot" }) }),
@@ -5869,9 +5937,9 @@ var Textarea = ({
5869
5937
  }) => {
5870
5938
  const generatedId = useId();
5871
5939
  const field = useFieldControl();
5872
- const inputId = id ?? field?.inputId ?? generatedId;
5873
- const helperId = supportingText ? `${inputId}-help` : void 0;
5874
- const describedBy = field?.describedBy ?? helperId;
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;
5875
5943
  const isControlled = value !== void 0;
5876
5944
  const applyTransform = (nextValue) => transformValue ? transformValue(nextValue) : nextValue;
5877
5945
  const [innerValue, setInnerValue] = useState(() => applyTransform(value ?? defaultValue ?? ""));
@@ -5879,12 +5947,10 @@ var Textarea = ({
5879
5947
  const innerRef = useRef(null);
5880
5948
  const lastEmittedValueRef = useRef(innerValue);
5881
5949
  const autoGrow = minRows !== void 0 || maxRows !== void 0;
5882
- const [prevValue, setPrevValue] = useState(value);
5883
- if (isControlled && value !== prevValue && !isComposingRef.current) {
5884
- setPrevValue(value);
5885
- const nextValue = applyTransform(value ?? "");
5886
- setInnerValue(nextValue);
5887
- lastEmittedValueRef.current = nextValue;
5950
+ const nextControlledValue = applyTransform(value ?? "");
5951
+ if (isControlled && !isComposingRef.current && nextControlledValue !== innerValue) {
5952
+ setInnerValue(nextControlledValue);
5953
+ lastEmittedValueRef.current = nextControlledValue;
5888
5954
  }
5889
5955
  const setRefs = useCallback(
5890
5956
  (node) => {
@@ -5930,17 +5996,17 @@ var Textarea = ({
5930
5996
  /* @__PURE__ */ jsx("div", { className: "textarea_input_wrap", children: /* @__PURE__ */ jsx(
5931
5997
  "textarea",
5932
5998
  {
5999
+ ...props,
5933
6000
  id: inputId,
5934
6001
  ref: setRefs,
5935
6002
  className: "textarea_input",
5936
6003
  style: { resize: autoGrow ? "none" : resize },
5937
6004
  rows: autoGrow ? minRows ?? rows : rows,
5938
6005
  maxLength,
5939
- "aria-invalid": !!error || !!field?.invalid,
6006
+ "aria-invalid": field ? !!error || field.invalid : props["aria-invalid"] ?? !!error,
5940
6007
  "aria-describedby": describedBy,
5941
- "aria-required": field?.required || void 0,
5942
- "aria-label": !showLabel ? label : void 0,
5943
- ...props,
6008
+ "aria-required": field ? field.required || void 0 : props["aria-required"],
6009
+ "aria-label": (!showLabel ? label : void 0) ?? props["aria-label"],
5944
6010
  value: innerValue,
5945
6011
  onCompositionStart: () => {
5946
6012
  isComposingRef.current = true;
@@ -5995,14 +6061,14 @@ var TimePicker = ({
5995
6061
  const hourLabel = hourLabelProp ?? t("timePicker.hour");
5996
6062
  const minuteLabel = minuteLabelProp ?? t("timePicker.minute");
5997
6063
  const field = useFieldControl();
5998
- const groupId = React11.useId();
5999
- const constraintId = React11.useId();
6064
+ const groupId = React20.useId();
6065
+ const constraintId = React20.useId();
6000
6066
  const min = toMinutes(minTime) ?? 0;
6001
6067
  const max = toMinutes(maxTime) ?? 23 * 60 + 59;
6002
6068
  const parsed = toMinutes(value);
6003
6069
  const hour = parsed === null ? null : Math.floor(parsed / 60);
6004
6070
  const minute = parsed === null ? null : parsed % 60;
6005
- const hourOptions = React11.useMemo(() => {
6071
+ const hourOptions = React20.useMemo(() => {
6006
6072
  const first = Math.floor(min / 60);
6007
6073
  const last = Math.floor(max / 60);
6008
6074
  return Array.from({ length: Math.max(0, last - first + 1) }, (_, i) => {
@@ -6010,7 +6076,7 @@ var TimePicker = ({
6010
6076
  return { value: String(h), label: pad2(h) };
6011
6077
  });
6012
6078
  }, [min, max]);
6013
- const minuteOptions = React11.useMemo(() => {
6079
+ const minuteOptions = React20.useMemo(() => {
6014
6080
  if (hour === null) return [];
6015
6081
  const step = Math.max(1, Math.floor(minuteStep));
6016
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) }));
@@ -6097,7 +6163,7 @@ var Toggle = ({
6097
6163
  ...props
6098
6164
  }) => {
6099
6165
  const isControlled = checked !== void 0;
6100
- const [innerChecked, setInnerChecked] = React11.useState(!!defaultChecked);
6166
+ const [innerChecked, setInnerChecked] = React20.useState(!!defaultChecked);
6101
6167
  const isOn = isControlled ? !!checked : innerChecked;
6102
6168
  const handleToggle = (e) => {
6103
6169
  props.onClick?.(e);
@@ -6123,6 +6189,7 @@ var Toggle = ({
6123
6189
  "aria-checked": isOn,
6124
6190
  id: field?.inputId ?? props.id,
6125
6191
  "aria-describedby": field?.describedBy ?? props["aria-describedby"],
6192
+ "aria-invalid": field ? field.invalid || void 0 : props["aria-invalid"],
6126
6193
  "aria-labelledby": field?.labelId,
6127
6194
  "aria-label": field?.labelId ? void 0 : ariaLabel,
6128
6195
  disabled,
@@ -6174,15 +6241,15 @@ var Drawer = ({
6174
6241
  }) => {
6175
6242
  const t = useLocaleText();
6176
6243
  const closeLabel = closeLabelProp ?? t("drawer.close");
6177
- const lastContentRef = React11.useRef({ children, title, footer });
6244
+ const lastContentRef = React20.useRef({ children, title, footer });
6178
6245
  if (open) lastContentRef.current = { children, title, footer };
6179
6246
  const content = open ? { children, title, footer } : lastContentRef.current;
6180
6247
  const overlayDismissible = dismissible ?? closeOnOverlay;
6181
6248
  const escapeDismissible = dismissible ?? true;
6182
- const panelRef = React11.useRef(null);
6183
- const pressedOverlayRef = React11.useRef(false);
6184
- const titleId = React11.useId();
6185
- const [shouldRender, setShouldRender] = React11.useState(open);
6249
+ const panelRef = React20.useRef(null);
6250
+ const pressedOverlayRef = React20.useRef(false);
6251
+ const titleId = React20.useId();
6252
+ const [shouldRender, setShouldRender] = React20.useState(open);
6186
6253
  const reduced = useReducedMotion();
6187
6254
  const isMounted = useIsMounted();
6188
6255
  useFocusTrap(panelRef, open && isMounted);
@@ -6190,12 +6257,13 @@ var Drawer = ({
6190
6257
  if (escapeDismissible) onClose?.();
6191
6258
  });
6192
6259
  if (open && !shouldRender) setShouldRender(true);
6193
- const dimOwner = React11.useRef({}).current;
6194
- const overlayStyle = useSpringPresence({
6195
- visible: open,
6196
- from: "translateY(0px)",
6197
- onProgress: (progress) => reportOverlayDim(dimOwner, progress),
6198
- onExitComplete: () => {
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;
6199
6267
  setShouldRender(false);
6200
6268
  onExited?.();
6201
6269
  }
@@ -6208,13 +6276,11 @@ var Drawer = ({
6208
6276
  immediate: reduced,
6209
6277
  config: { tension: 280, friction: 28, clamp: !open }
6210
6278
  });
6211
- React11.useEffect(() => {
6279
+ React20.useEffect(() => {
6212
6280
  if (!shouldRender) return;
6213
- reportOverlayDim(dimOwner, reduced ? 1 : 0);
6214
6281
  lockBodyScroll();
6215
6282
  return () => {
6216
6283
  unlockBodyScroll();
6217
- unregisterOverlayDim(dimOwner);
6218
6284
  };
6219
6285
  }, [shouldRender]);
6220
6286
  if (!open && !shouldRender) return null;
@@ -6288,15 +6354,15 @@ var Modal = ({
6288
6354
  }) => {
6289
6355
  const t = useLocaleText();
6290
6356
  const closeLabel = closeLabelProp ?? t("modal.close");
6291
- const lastContentRef = React11.useRef({ children, title, description, footer });
6357
+ const lastContentRef = React20.useRef({ children, title, description, footer });
6292
6358
  if (open) lastContentRef.current = { children, title, description, footer };
6293
6359
  const content = open ? { children, title, description, footer } : lastContentRef.current;
6294
6360
  const overlayDismissible = dismissible ?? closeOnOverlay;
6295
6361
  const escapeDismissible = dismissible ?? true;
6296
- const panelRef = React11.useRef(null);
6297
- const pressedOverlayRef = React11.useRef(false);
6298
- const titleId = React11.useId();
6299
- const [shouldRender, setShouldRender] = React11.useState(open);
6362
+ const panelRef = React20.useRef(null);
6363
+ const pressedOverlayRef = React20.useRef(false);
6364
+ const titleId = React20.useId();
6365
+ const [shouldRender, setShouldRender] = React20.useState(open);
6300
6366
  const isMounted = useIsMounted();
6301
6367
  useFocusTrap(panelRef, open && isMounted);
6302
6368
  useOverlayEscape(open && isMounted, () => {
@@ -6304,13 +6370,11 @@ var Modal = ({
6304
6370
  });
6305
6371
  if (open && !shouldRender) setShouldRender(true);
6306
6372
  const reduced = useReducedMotion();
6307
- const dimOwner = React11.useRef({}).current;
6308
6373
  const overlayStyle = useSpring({
6309
6374
  ...springEnterFrom(reduced),
6310
6375
  to: { opacity: open ? 1 : 0 },
6311
6376
  immediate: reduced,
6312
6377
  config: OVERLAY_SPRING_CONFIG,
6313
- onChange: (result) => reportOverlayDim(dimOwner, Number(result.value.opacity)),
6314
6378
  onRest: (result) => {
6315
6379
  if (open || !result.finished) return;
6316
6380
  setShouldRender(false);
@@ -6326,13 +6390,11 @@ var Modal = ({
6326
6390
  immediate: reduced,
6327
6391
  config: OVERLAY_SPRING_CONFIG
6328
6392
  });
6329
- React11.useEffect(() => {
6393
+ React20.useEffect(() => {
6330
6394
  if (!shouldRender) return;
6331
- reportOverlayDim(dimOwner, reduced ? 1 : 0);
6332
6395
  lockBodyScroll();
6333
6396
  return () => {
6334
6397
  unlockBodyScroll();
6335
- unregisterOverlayDim(dimOwner);
6336
6398
  };
6337
6399
  }, [shouldRender]);
6338
6400
  if (!open && !shouldRender) return null;
@@ -6390,9 +6452,9 @@ var Modal = ({
6390
6452
  document.body
6391
6453
  );
6392
6454
  };
6393
- var ThemeContext = React11.createContext(null);
6455
+ var ThemeContext = React20.createContext(null);
6394
6456
  var useTheme = () => {
6395
- const ctx = React11.useContext(ThemeContext);
6457
+ const ctx = React20.useContext(ThemeContext);
6396
6458
  if (!ctx) {
6397
6459
  throw new Error(
6398
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>'
@@ -6416,15 +6478,15 @@ var ThemeProvider = ({
6416
6478
  targetSelector,
6417
6479
  children
6418
6480
  }) => {
6419
- const [mode, setModeState] = React11.useState(defaultMode);
6420
- const [systemDark, setSystemDark] = React11.useState(false);
6421
- React11.useEffect(() => {
6481
+ const [mode, setModeState] = React20.useState(defaultMode);
6482
+ const [systemDark, setSystemDark] = React20.useState(false);
6483
+ React20.useEffect(() => {
6422
6484
  setModeState(readStored(storageKey) ?? defaultMode);
6423
6485
  if (isClient) {
6424
6486
  setSystemDark(window.matchMedia("(prefers-color-scheme: dark)").matches);
6425
6487
  }
6426
6488
  }, [storageKey, defaultMode]);
6427
- React11.useEffect(() => {
6489
+ React20.useEffect(() => {
6428
6490
  if (!isClient) return;
6429
6491
  const mq = window.matchMedia("(prefers-color-scheme: dark)");
6430
6492
  const handler = (e) => setSystemDark(e.matches);
@@ -6432,7 +6494,7 @@ var ThemeProvider = ({
6432
6494
  return () => mq.removeEventListener("change", handler);
6433
6495
  }, []);
6434
6496
  const resolved = mode === "system" ? systemDark ? "dark" : "light" : mode;
6435
- React11.useEffect(() => {
6497
+ React20.useEffect(() => {
6436
6498
  if (!isClient) return;
6437
6499
  const target = targetSelector ? document.querySelector(targetSelector) : document.documentElement;
6438
6500
  if (!target) return;
@@ -6442,7 +6504,7 @@ var ThemeProvider = ({
6442
6504
  target.setAttribute("data-theme", mode);
6443
6505
  }
6444
6506
  }, [mode, targetSelector]);
6445
- const setMode = React11.useCallback(
6507
+ const setMode = React20.useCallback(
6446
6508
  (next) => {
6447
6509
  setModeState(next);
6448
6510
  if (storageKey && isClient) {
@@ -6454,7 +6516,7 @@ var ThemeProvider = ({
6454
6516
  },
6455
6517
  [storageKey]
6456
6518
  );
6457
- const value = React11.useMemo(
6519
+ const value = React20.useMemo(
6458
6520
  () => ({ mode, resolved, setMode }),
6459
6521
  [mode, resolved, setMode]
6460
6522
  );