@kjun-ui/react 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/index.cjs +391 -258
  2. package/dist/index.js +305 -172
  3. package/dist/styles.css +26 -3
  4. package/dist/types/packages/react/src/collapse.d.cts +3 -1
  5. package/dist/types/packages/react/src/collapse.d.ts +3 -1
  6. package/dist/types/packages/react/src/combobox.d.cts +6 -2
  7. package/dist/types/packages/react/src/combobox.d.ts +6 -2
  8. package/dist/types/packages/react/src/drawer.d.cts +3 -1
  9. package/dist/types/packages/react/src/drawer.d.ts +3 -1
  10. package/dist/types/packages/react/src/dropdown.d.cts +4 -2
  11. package/dist/types/packages/react/src/dropdown.d.ts +4 -2
  12. package/dist/types/packages/react/src/floating-panel.d.cts +8 -1
  13. package/dist/types/packages/react/src/floating-panel.d.ts +8 -1
  14. package/dist/types/packages/react/src/list.d.cts +9 -2
  15. package/dist/types/packages/react/src/list.d.ts +9 -2
  16. package/dist/types/packages/react/src/modal.d.cts +3 -1
  17. package/dist/types/packages/react/src/modal.d.ts +3 -1
  18. package/dist/types/packages/react/src/navigation.d.cts +7 -1
  19. package/dist/types/packages/react/src/navigation.d.ts +7 -1
  20. package/dist/types/packages/react/src/popover.d.cts +12 -3
  21. package/dist/types/packages/react/src/popover.d.ts +12 -3
  22. package/dist/types/packages/react/src/select-control.d.cts +4 -1
  23. package/dist/types/packages/react/src/select-control.d.ts +4 -1
  24. package/dist/types/shared/package-runtime/anchor-rect.d.cts +17 -0
  25. package/dist/types/shared/package-runtime/anchor-rect.d.ts +17 -0
  26. package/dist/types/shared/package-runtime/nested-controls.d.cts +2 -0
  27. package/dist/types/shared/package-runtime/nested-controls.d.ts +2 -0
  28. package/dist/types/shared/package-runtime/use-after-close.d.cts +6 -0
  29. package/dist/types/shared/package-runtime/use-after-close.d.ts +6 -0
  30. package/package.json +3 -3
package/dist/index.cjs CHANGED
@@ -1358,14 +1358,33 @@ var KjunInput = (0, import_react9.forwardRef)(
1358
1358
  }
1359
1359
  );
1360
1360
 
1361
+ // shared/package-runtime/use-after-close.ts
1362
+ var import_react10 = require("react");
1363
+ function useAfterCloseRef(open, onAfterClose) {
1364
+ const state = (0, import_react10.useRef)({ open, mounted: false, callback: onAfterClose });
1365
+ state.current.open = open;
1366
+ state.current.callback = onAfterClose;
1367
+ return (0, import_react10.useCallback)((node) => {
1368
+ const current = state.current;
1369
+ if (node) current.mounted = true;
1370
+ else if (current.mounted) {
1371
+ current.mounted = false;
1372
+ queueMicrotask(() => {
1373
+ var _a;
1374
+ if (!current.open && !current.mounted) (_a = current.callback) == null ? void 0 : _a.call(current);
1375
+ });
1376
+ }
1377
+ }, []);
1378
+ }
1379
+
1361
1380
  // shared/package-runtime/use-presence.ts
1362
1381
  var import_tokens8 = require("@kjun-ui/tokens");
1363
- var import_react10 = require("react");
1382
+ var import_react11 = require("react");
1364
1383
  function usePresence(open, reduced, exitDuration = import_tokens8.tokens.motion.layerExit) {
1365
- const [retained, setRetained] = (0, import_react10.useState)(open);
1366
- const [active, setActive] = (0, import_react10.useState)(false);
1367
- const mounted = (0, import_react10.useRef)(false);
1368
- (0, import_react10.useLayoutEffect)(() => {
1384
+ const [retained, setRetained] = (0, import_react11.useState)(open);
1385
+ const [active, setActive] = (0, import_react11.useState)(false);
1386
+ const mounted = (0, import_react11.useRef)(false);
1387
+ (0, import_react11.useLayoutEffect)(() => {
1369
1388
  let first = 0, second = 0, timer;
1370
1389
  if (open) {
1371
1390
  setRetained(true);
@@ -1393,7 +1412,7 @@ function usePresence(open, reduced, exitDuration = import_tokens8.tokens.motion.
1393
1412
  }
1394
1413
 
1395
1414
  // packages/react/src/use-reduced-motion.ts
1396
- var import_react11 = require("react");
1415
+ var import_react12 = require("react");
1397
1416
  var query = "(prefers-reduced-motion: reduce)";
1398
1417
  function subscribe(notify) {
1399
1418
  const media = window.matchMedia(query);
@@ -1401,12 +1420,12 @@ function subscribe(notify) {
1401
1420
  return () => media.removeEventListener("change", notify);
1402
1421
  }
1403
1422
  function useReducedMotion() {
1404
- return (0, import_react11.useSyncExternalStore)(subscribe, () => window.matchMedia(query).matches, () => true);
1423
+ return (0, import_react12.useSyncExternalStore)(subscribe, () => window.matchMedia(query).matches, () => true);
1405
1424
  }
1406
1425
 
1407
1426
  // packages/react/src/modal.tsx
1408
1427
  var import_tokens9 = require("@kjun-ui/tokens");
1409
- var import_react13 = require("react");
1428
+ var import_react14 = require("react");
1410
1429
 
1411
1430
  // shared/package-runtime/form-actions.ts
1412
1431
  function formActionsNeedStack(width, widths, gap) {
@@ -1459,17 +1478,17 @@ function observeFormActions(root) {
1459
1478
  var import_react_aria_components2 = require("react-aria-components");
1460
1479
 
1461
1480
  // packages/react/src/overlay-host.tsx
1462
- var import_react12 = require("react");
1463
- var FeedbackOverlayContext = (0, import_react12.createContext)(
1481
+ var import_react13 = require("react");
1482
+ var FeedbackOverlayContext = (0, import_react13.createContext)(
1464
1483
  null
1465
1484
  );
1466
1485
  function FeedbackLayerOutlet() {
1467
1486
  var _a;
1468
- const layers = useLayerState(), scope = (0, import_react12.useContext)(LayerScope);
1487
+ const layers = useLayerState(), scope = (0, import_react13.useContext)(LayerScope);
1469
1488
  const entry = scope ? layers.entries.get(scope) : void 0;
1470
1489
  const active = !!entry && layers.isActive(entry.id), order = (_a = entry == null ? void 0 : entry.order) != null ? _a : 0;
1471
- const host = (0, import_react12.useContext)(FeedbackOverlayContext), id = "kjun-" + (0, import_react12.useId)(), register = host == null ? void 0 : host.register;
1472
- (0, import_react12.useLayoutEffect)(() => active ? register == null ? void 0 : register(id, order) : void 0, [register, id, active, order]);
1490
+ const host = (0, import_react13.useContext)(FeedbackOverlayContext), id = "kjun-" + (0, import_react13.useId)(), register = host == null ? void 0 : host.register;
1491
+ (0, import_react13.useLayoutEffect)(() => active ? register == null ? void 0 : register(id, order) : void 0, [register, id, active, order]);
1473
1492
  return (host == null ? void 0 : host.top) === id ? host.render() : null;
1474
1493
  }
1475
1494
 
@@ -1492,8 +1511,8 @@ function KjunFormActions({
1492
1511
  const m = useKjunMessages();
1493
1512
  cancelText != null ? cancelText : cancelText = m.cancel;
1494
1513
  confirmText != null ? confirmText : confirmText = m.save;
1495
- const ref = (0, import_react13.useRef)(null);
1496
- (0, import_react13.useLayoutEffect)(() => observeFormActions(ref.current), []);
1514
+ const ref = (0, import_react14.useRef)(null);
1515
+ (0, import_react14.useLayoutEffect)(() => observeFormActions(ref.current), []);
1497
1516
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "kjun-form-actions", ref, children: [
1498
1517
  showCancel && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1499
1518
  KjunButton,
@@ -1522,6 +1541,7 @@ function KjunModal({
1522
1541
  open,
1523
1542
  onOpenChange,
1524
1543
  onClose,
1544
+ onAfterClose,
1525
1545
  onCancel,
1526
1546
  onConfirm,
1527
1547
  title = "",
@@ -1550,8 +1570,9 @@ function KjunModal({
1550
1570
  confirmText != null ? confirmText : confirmText = m.confirm;
1551
1571
  cancelText != null ? cancelText : cancelText = m.cancel;
1552
1572
  const motion = usePresence(open, useReducedMotion());
1573
+ const afterCloseRef = useAfterCloseRef(open, onAfterClose);
1553
1574
  const portalContainer = useKjunPortalContainer();
1554
- const id = "kjun-" + (0, import_react13.useId)();
1575
+ const id = "kjun-" + (0, import_react14.useId)();
1555
1576
  const explicitLabel = ariaLabel == null ? void 0 : ariaLabel.trim();
1556
1577
  const heading = header || title;
1557
1578
  const labelledByHeading = showHeader && !explicitLabel && (typeof heading === "string" ? !!heading.trim() : !!heading);
@@ -1567,6 +1588,7 @@ function KjunModal({
1567
1588
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LayerScope.Provider, { value: layer.id, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1568
1589
  import_react_aria_components2.ModalOverlay,
1569
1590
  {
1591
+ ref: afterCloseRef,
1570
1592
  style: { zIndex: layer.zIndex },
1571
1593
  isOpen: motion.present && layer.active,
1572
1594
  isExiting: motion.present && !layer.active,
@@ -1654,12 +1676,12 @@ function KjunModal({
1654
1676
  }
1655
1677
 
1656
1678
  // shared/package-runtime/content-presence.ts
1657
- var import_react14 = require("react");
1679
+ var import_react15 = require("react");
1658
1680
  function hasContent(node) {
1659
1681
  if (node == null || typeof node === "boolean") return false;
1660
1682
  if (typeof node === "string") return node.trim().length > 0;
1661
1683
  if (Array.isArray(node)) return node.some(hasContent);
1662
- if ((0, import_react14.isValidElement)(node) && node.type === import_react14.Fragment)
1684
+ if ((0, import_react15.isValidElement)(node) && node.type === import_react15.Fragment)
1663
1685
  return hasContent(node.props.children);
1664
1686
  return true;
1665
1687
  }
@@ -1692,11 +1714,9 @@ function progressCircle(size, percentage) {
1692
1714
  }
1693
1715
 
1694
1716
  // packages/react/src/display.tsx
1695
- var import_react16 = require("react");
1717
+ var import_react17 = require("react");
1696
1718
 
1697
- // packages/react/src/card.tsx
1698
- var import_react15 = require("react");
1699
- var import_jsx_runtime8 = require("react/jsx-runtime");
1719
+ // shared/package-runtime/nested-controls.ts
1700
1720
  var interactive = 'button, a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
1701
1721
  function developmentMode3() {
1702
1722
  try {
@@ -1705,6 +1725,13 @@ function developmentMode3() {
1705
1725
  return false;
1706
1726
  }
1707
1727
  }
1728
+ function warnNestedControls(root, message) {
1729
+ if (developmentMode3() && (root == null ? void 0 : root.querySelector(interactive))) console.warn(message);
1730
+ }
1731
+
1732
+ // packages/react/src/card.tsx
1733
+ var import_react16 = require("react");
1734
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1708
1735
  function KjunCard({
1709
1736
  title,
1710
1737
  subtitle,
@@ -1729,11 +1756,9 @@ function KjunCard({
1729
1756
  onKeyDown,
1730
1757
  ...props
1731
1758
  }) {
1732
- const root = (0, import_react15.useRef)(null);
1733
- (0, import_react15.useEffect)(() => {
1734
- var _a;
1735
- if (pressable && developmentMode3() && ((_a = root.current) == null ? void 0 : _a.querySelector(interactive)))
1736
- console.warn("KJUN Card: a pressable card contains buttons or links; move them out or drop pressable.");
1759
+ const root = (0, import_react16.useRef)(null);
1760
+ (0, import_react16.useEffect)(() => {
1761
+ if (pressable) warnNestedControls(root.current, "KJUN Card: a pressable card contains buttons or links; move them out or drop pressable.");
1737
1762
  }, [pressable]);
1738
1763
  const press = pressable ? {
1739
1764
  role: "button",
@@ -1893,7 +1918,7 @@ function KjunAlert({
1893
1918
  onClose
1894
1919
  }) {
1895
1920
  const m = useKjunMessages();
1896
- const [visible, setVisible] = (0, import_react16.useState)(true);
1921
+ const [visible, setVisible] = (0, import_react17.useState)(true);
1897
1922
  if (!visible) return null;
1898
1923
  const tone = variant || (type === "error" ? "danger" : type), small = size === "sm";
1899
1924
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
@@ -2120,7 +2145,7 @@ function KjunSkeleton({
2120
2145
  }
2121
2146
 
2122
2147
  // packages/react/src/layout-primitives.tsx
2123
- var import_react17 = require("react");
2148
+ var import_react18 = require("react");
2124
2149
 
2125
2150
  // shared/package-runtime/layout-primitives.ts
2126
2151
  var numeric = /^(number|display)/;
@@ -2132,7 +2157,7 @@ var import_jsx_runtime10 = require("react/jsx-runtime");
2132
2157
  var join = (...names) => names.filter(Boolean).join(" ");
2133
2158
  function KjunText({ variant = "body", tone = "default", as, align, maxLines, className, style, children, ...rest }) {
2134
2159
  const lines = maxLines && maxLines > 0 ? Math.floor(maxLines) : void 0;
2135
- return (0, import_react17.createElement)(as != null ? as : defaultTextTag(variant), {
2160
+ return (0, import_react18.createElement)(as != null ? as : defaultTextTag(variant), {
2136
2161
  ...rest,
2137
2162
  className: join("kjun-text", textTypeClass(variant), className),
2138
2163
  // 안에 넣은 링크·강조 같은 앱 요소는 KJUN 리셋을 받지 않는다.
@@ -2144,7 +2169,7 @@ function KjunText({ variant = "body", tone = "default", as, align, maxLines, cla
2144
2169
  }, children);
2145
2170
  }
2146
2171
  function KjunStack({ gap = "md", align = "stretch", as = "div", className, style, children, ...rest }) {
2147
- return (0, import_react17.createElement)(as, {
2172
+ return (0, import_react18.createElement)(as, {
2148
2173
  ...rest,
2149
2174
  className: className || void 0,
2150
2175
  style,
@@ -2171,13 +2196,13 @@ function KjunInline({ gap = "sm", align = "center", justify = "start", wrap = tr
2171
2196
  }
2172
2197
 
2173
2198
  // shared/package-runtime/feedback-dialog.ts
2174
- var import_react18 = require("react");
2199
+ var import_react19 = require("react");
2175
2200
  function useFeedbackDialog(controller, request, messages = kjunMessagesKo) {
2176
2201
  const options = request.options;
2177
- const [value, setValue] = (0, import_react18.useState)(options.initialValue || "");
2178
- const [error, setError] = (0, import_react18.useState)("");
2179
- const [busy, setBusy] = (0, import_react18.useState)(false);
2180
- const working = (0, import_react18.useRef)(false);
2202
+ const [value, setValue] = (0, import_react19.useState)(options.initialValue || "");
2203
+ const [error, setError] = (0, import_react19.useState)("");
2204
+ const [busy, setBusy] = (0, import_react19.useState)(false);
2205
+ const working = (0, import_react19.useRef)(false);
2181
2206
  const active = () => {
2182
2207
  var _a;
2183
2208
  return ((_a = controller.getSnapshot().current) == null ? void 0 : _a.id) === request.id;
@@ -2220,11 +2245,11 @@ function useFeedbackDialog(controller, request, messages = kjunMessagesKo) {
2220
2245
 
2221
2246
  // shared/package-runtime/feedback-motion.ts
2222
2247
  var import_tokens12 = require("@kjun-ui/tokens");
2223
- var import_react19 = require("react");
2248
+ var import_react20 = require("react");
2224
2249
  function usePresentedToasts(toasts, reduced) {
2225
- const [items, setItems] = (0, import_react19.useState)([]);
2226
- const removals = (0, import_react19.useRef)(/* @__PURE__ */ new Map());
2227
- (0, import_react19.useLayoutEffect)(() => {
2250
+ const [items, setItems] = (0, import_react20.useState)([]);
2251
+ const removals = (0, import_react20.useRef)(/* @__PURE__ */ new Map());
2252
+ (0, import_react20.useLayoutEffect)(() => {
2228
2253
  const ids = new Set(toasts.map((toast) => toast.id));
2229
2254
  setItems((previous) => {
2230
2255
  const old = new Map(previous.map((item) => [item.toast.id, item]));
@@ -2246,15 +2271,15 @@ function usePresentedToasts(toasts, reduced) {
2246
2271
  removals.current.clear();
2247
2272
  }
2248
2273
  }, [toasts, reduced]);
2249
- (0, import_react19.useLayoutEffect)(() => () => {
2274
+ (0, import_react20.useLayoutEffect)(() => () => {
2250
2275
  for (const timer of removals.current.values()) clearTimeout(timer);
2251
2276
  removals.current.clear();
2252
2277
  }, []);
2253
2278
  return items;
2254
2279
  }
2255
2280
  function usePresentedRequest(current, reduced) {
2256
- const [request, setRequest] = (0, import_react19.useState)(current);
2257
- (0, import_react19.useLayoutEffect)(() => {
2281
+ const [request, setRequest] = (0, import_react20.useState)(current);
2282
+ (0, import_react20.useLayoutEffect)(() => {
2258
2283
  if (!request || request.id === (current == null ? void 0 : current.id) || reduced) {
2259
2284
  setRequest(current);
2260
2285
  return;
@@ -2266,15 +2291,15 @@ function usePresentedRequest(current, reduced) {
2266
2291
  }
2267
2292
 
2268
2293
  // packages/react/src/feedback-context.ts
2269
- var import_react20 = require("react");
2270
- var KjunFeedbackContext = (0, import_react20.createContext)(null);
2294
+ var import_react21 = require("react");
2295
+ var KjunFeedbackContext = (0, import_react21.createContext)(null);
2271
2296
  function useOptionalKjunFeedback() {
2272
- return (0, import_react20.useContext)(KjunFeedbackContext);
2297
+ return (0, import_react21.useContext)(KjunFeedbackContext);
2273
2298
  }
2274
2299
 
2275
2300
  // packages/react/src/toast-stack.tsx
2276
2301
  var import_tokens14 = require("@kjun-ui/tokens");
2277
- var import_react22 = require("react");
2302
+ var import_react23 = require("react");
2278
2303
 
2279
2304
  // shared/package-runtime/toast-layout.ts
2280
2305
  var import_tokens13 = require("@kjun-ui/tokens");
@@ -2336,16 +2361,16 @@ function createToastLayout() {
2336
2361
  }
2337
2362
 
2338
2363
  // packages/react/src/toast.tsx
2339
- var import_react21 = require("react");
2364
+ var import_react22 = require("react");
2340
2365
  var import_jsx_runtime11 = require("react/jsx-runtime");
2341
2366
  function ToastView({
2342
2367
  toast,
2343
2368
  controller
2344
2369
  }) {
2345
2370
  const m = useKjunMessages();
2346
- const previous = (0, import_react21.useRef)(null);
2347
- const reasons = (0, import_react21.useRef)({ hover: /* @__PURE__ */ Symbol("hover"), focus: /* @__PURE__ */ Symbol("focus") }).current;
2348
- (0, import_react21.useEffect)(() => {
2371
+ const previous = (0, import_react22.useRef)(null);
2372
+ const reasons = (0, import_react22.useRef)({ hover: /* @__PURE__ */ Symbol("hover"), focus: /* @__PURE__ */ Symbol("focus") }).current;
2373
+ (0, import_react22.useEffect)(() => {
2349
2374
  previous.current = document.activeElement;
2350
2375
  return () => {
2351
2376
  controller.resumeToast(toast.id, reasons.hover);
@@ -2440,10 +2465,10 @@ function ToastView({
2440
2465
  // packages/react/src/toast-stack.tsx
2441
2466
  var import_jsx_runtime12 = require("react/jsx-runtime");
2442
2467
  function ToastSurface({ item, controller }) {
2443
- const ref = (0, import_react22.useRef)(null), reduced = useReducedMotion();
2444
- const current = (0, import_react22.useRef)(null);
2445
- const entryFinished = (0, import_react22.useRef)(false);
2446
- (0, import_react22.useLayoutEffect)(() => {
2468
+ const ref = (0, import_react23.useRef)(null), reduced = useReducedMotion();
2469
+ const current = (0, import_react23.useRef)(null);
2470
+ const entryFinished = (0, import_react23.useRef)(false);
2471
+ (0, import_react23.useLayoutEffect)(() => {
2447
2472
  var _a, _b;
2448
2473
  const el = ref.current;
2449
2474
  if (!el) return;
@@ -2477,12 +2502,12 @@ function ToastSurface({ item, controller }) {
2477
2502
  function ToastStack({ items, controller }) {
2478
2503
  var _a;
2479
2504
  const layers = useLayerState();
2480
- const root = (0, import_react22.useRef)(null), layout = (0, import_react22.useRef)(createToastLayout());
2505
+ const root = (0, import_react23.useRef)(null), layout = (0, import_react23.useRef)(createToastLayout());
2481
2506
  const reduced = useReducedMotion();
2482
- (0, import_react22.useLayoutEffect)(() => {
2507
+ (0, import_react23.useLayoutEffect)(() => {
2483
2508
  if (root.current) layout.current.update(root.current, reduced);
2484
2509
  });
2485
- (0, import_react22.useLayoutEffect)(() => () => layout.current.destroy(), []);
2510
+ (0, import_react23.useLayoutEffect)(() => () => layout.current.destroy(), []);
2486
2511
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: root, className: "kjun-toast-stack", style: { zIndex: layers.zIndex((_a = layers.topWindow()) == null ? void 0 : _a.id, "toast") }, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2487
2512
  "div",
2488
2513
  {
@@ -2497,7 +2522,7 @@ function ToastStack({ items, controller }) {
2497
2522
 
2498
2523
  // packages/react/src/feedback.tsx
2499
2524
  var import_tokens15 = require("@kjun-ui/tokens");
2500
- var import_react23 = require("react");
2525
+ var import_react24 = require("react");
2501
2526
  var import_tokens16 = require("@kjun-ui/tokens");
2502
2527
  var import_jsx_runtime13 = require("react/jsx-runtime");
2503
2528
  function useKjunFeedback() {
@@ -2549,11 +2574,11 @@ function FeedbackDialog({
2549
2574
  }
2550
2575
  function KjunFeedbackProvider({ children, controller: controllerProp }) {
2551
2576
  var _a;
2552
- const [owned] = (0, import_react23.useState)(() => controllerProp ? void 0 : (0, import_tokens15.createFeedbackController)());
2577
+ const [owned] = (0, import_react24.useState)(() => controllerProp ? void 0 : (0, import_tokens15.createFeedbackController)());
2553
2578
  const controller = controllerProp ? (0, import_tokens15.feedbackControllerOf)(controllerProp) : owned;
2554
- (0, import_react23.useEffect)(() => controller.attach(), [controller]);
2555
- const life = (0, import_react23.useRef)(0);
2556
- const snapshot = (0, import_react23.useSyncExternalStore)(
2579
+ (0, import_react24.useEffect)(() => controller.attach(), [controller]);
2580
+ const life = (0, import_react24.useRef)(0);
2581
+ const snapshot = (0, import_react24.useSyncExternalStore)(
2557
2582
  controller.subscribe,
2558
2583
  controller.getSnapshot,
2559
2584
  controller.getSnapshot
@@ -2561,7 +2586,7 @@ function KjunFeedbackProvider({ children, controller: controllerProp }) {
2561
2586
  const reduced = useReducedMotion();
2562
2587
  const toasts = usePresentedToasts(snapshot.toasts, reduced);
2563
2588
  const dialog = usePresentedRequest(snapshot.current, reduced);
2564
- (0, import_react23.useEffect)(() => {
2589
+ (0, import_react24.useEffect)(() => {
2565
2590
  const version = ++life.current;
2566
2591
  return () => {
2567
2592
  queueMicrotask(() => {
@@ -2569,8 +2594,8 @@ function KjunFeedbackProvider({ children, controller: controllerProp }) {
2569
2594
  });
2570
2595
  };
2571
2596
  }, [controller]);
2572
- const [layers, setLayers] = (0, import_react23.useState)([]);
2573
- const register = (0, import_react23.useCallback)((id, order) => {
2597
+ const [layers, setLayers] = (0, import_react24.useState)([]);
2598
+ const register = (0, import_react24.useCallback)((id, order) => {
2574
2599
  setLayers((current) => [...current, { id, order }]);
2575
2600
  return () => setLayers((current) => current.filter((value) => value.id !== id));
2576
2601
  }, []);
@@ -2599,11 +2624,11 @@ function KjunFeedbackProvider({ children, controller: controllerProp }) {
2599
2624
 
2600
2625
  // packages/react/src/controls.tsx
2601
2626
  var import_tokens18 = require("@kjun-ui/tokens");
2602
- var import_react25 = require("react");
2627
+ var import_react26 = require("react");
2603
2628
  var import_react_aria_components3 = require("react-aria-components");
2604
2629
 
2605
2630
  // packages/react/src/use-selection-indicator.ts
2606
- var import_react24 = require("react");
2631
+ var import_react25 = require("react");
2607
2632
 
2608
2633
  // shared/package-runtime/selection-indicator.ts
2609
2634
  var import_tokens17 = require("@kjun-ui/tokens");
@@ -2675,11 +2700,11 @@ function selectionIndicator(root, marker, tabs = false) {
2675
2700
 
2676
2701
  // packages/react/src/use-selection-indicator.ts
2677
2702
  function useSelectionIndicator(tabs = false) {
2678
- const group = (0, import_react24.useRef)(null);
2679
- const indicator = (0, import_react24.useRef)(null);
2680
- const sync = (0, import_react24.useRef)(() => {
2703
+ const group = (0, import_react25.useRef)(null);
2704
+ const indicator = (0, import_react25.useRef)(null);
2705
+ const sync = (0, import_react25.useRef)(() => {
2681
2706
  });
2682
- (0, import_react24.useLayoutEffect)(() => {
2707
+ (0, import_react25.useLayoutEffect)(() => {
2683
2708
  const root = group.current, marker = indicator.current;
2684
2709
  if (!root || !marker) return;
2685
2710
  const handle = selectionIndicator(root, marker, tabs);
@@ -2690,7 +2715,7 @@ function useSelectionIndicator(tabs = false) {
2690
2715
  };
2691
2716
  };
2692
2717
  }, [tabs]);
2693
- (0, import_react24.useLayoutEffect)(() => sync.current());
2718
+ (0, import_react25.useLayoutEffect)(() => sync.current());
2694
2719
  return { group, indicator };
2695
2720
  }
2696
2721
 
@@ -2764,9 +2789,9 @@ function KjunSwitch({
2764
2789
  onChange
2765
2790
  }) {
2766
2791
  const field = useKjunField();
2767
- const descriptionId = "kjun-" + (0, import_react25.useId)().replace(/:/g, "") + "-description";
2792
+ const descriptionId = "kjun-" + (0, import_react26.useId)().replace(/:/g, "") + "-description";
2768
2793
  const invalid = !!(field == null ? void 0 : field.error), required = !!(field == null ? void 0 : field.required);
2769
- const markInput = (0, import_react25.useCallback)((input) => {
2794
+ const markInput = (0, import_react26.useCallback)((input) => {
2770
2795
  if (!input) return;
2771
2796
  if (invalid) input.setAttribute("aria-invalid", "true");
2772
2797
  else input.removeAttribute("aria-invalid");
@@ -2802,7 +2827,7 @@ function KjunSwitch({
2802
2827
  }
2803
2828
  );
2804
2829
  }
2805
- var RadioContext = (0, import_react25.createContext)(null);
2830
+ var RadioContext = (0, import_react26.createContext)(null);
2806
2831
  function KjunRadio({
2807
2832
  value,
2808
2833
  val,
@@ -2814,7 +2839,7 @@ function KjunRadio({
2814
2839
  onValueChange,
2815
2840
  onChange
2816
2841
  }) {
2817
- const group = (0, import_react25.useContext)(RadioContext), selected = (group ? group.value : value) === val;
2842
+ const group = (0, import_react26.useContext)(RadioContext), selected = (group ? group.value : value) === val;
2818
2843
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "kjun-choice" + (disabled ? " kjun-choice--disabled" : ""), children: [
2819
2844
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2820
2845
  "input",
@@ -2853,7 +2878,7 @@ function KjunRadioGroup({
2853
2878
  onValueChange,
2854
2879
  onChange
2855
2880
  }) {
2856
- const name = "kjun-" + (0, import_react25.useId)();
2881
+ const name = "kjun-" + (0, import_react26.useId)();
2857
2882
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2858
2883
  RadioContext.Provider,
2859
2884
  {
@@ -2891,7 +2916,7 @@ function KjunRadioGroup({
2891
2916
  }
2892
2917
  );
2893
2918
  }
2894
- var KjunTextarea = (0, import_react25.forwardRef)(
2919
+ var KjunTextarea = (0, import_react26.forwardRef)(
2895
2920
  function KjunTextarea2({
2896
2921
  value,
2897
2922
  size = "md",
@@ -3065,7 +3090,7 @@ function KjunFilterGroup({
3065
3090
 
3066
3091
  // packages/react/src/floating-panel.tsx
3067
3092
  var import_tokens19 = require("@kjun-ui/tokens");
3068
- var import_react26 = require("react");
3093
+ var import_react27 = require("react");
3069
3094
  var import_react_aria_components4 = require("react-aria-components");
3070
3095
  var import_jsx_runtime15 = require("react/jsx-runtime");
3071
3096
  function FloatingPanel({
@@ -3081,13 +3106,15 @@ function FloatingPanel({
3081
3106
  flip = true,
3082
3107
  nonModal = false,
3083
3108
  ownsDismiss = false,
3084
- returnFocus
3109
+ returnFocus,
3110
+ repositionKey = 0,
3111
+ inside
3085
3112
  }) {
3086
3113
  const motion = usePresence(open, useReducedMotion(), import_tokens19.tokens.motion.popupExit);
3087
3114
  const layer = useLayer(open, motion.present, "popup", () => onOpenChange(false), triggerRef, returnFocus);
3088
3115
  const container = useKjunPortalContainer();
3089
- const panel = (0, import_react26.useRef)(null);
3090
- (0, import_react26.useEffect)(() => {
3116
+ const panel = (0, import_react27.useRef)(null);
3117
+ (0, import_react27.useEffect)(() => {
3091
3118
  var _a;
3092
3119
  const document2 = (_a = triggerRef.current) == null ? void 0 : _a.ownerDocument;
3093
3120
  if (!open || nonModal || !document2 || layer.keyboardManaged) return;
@@ -3116,12 +3143,17 @@ function FloatingPanel({
3116
3143
  if (next) onOpenChange(next);
3117
3144
  } : onOpenChange,
3118
3145
  triggerRef,
3146
+ shouldCloseOnInteractOutside: inside ? (element) => {
3147
+ var _a;
3148
+ return !((_a = inside.current) == null ? void 0 : _a.contains(element));
3149
+ } : void 0,
3119
3150
  UNSTABLE_portalContainer: container,
3120
3151
  placement: placement.replace("-", " "),
3121
3152
  shouldFlip: flip,
3122
3153
  maxHeight: typeof maxHeight === "number" ? maxHeight : maxHeight == null ? field ? import_tokens19.tokens.extensions.menu.listMaxHeight : import_tokens19.tokens.extensions.floating.maxHeight : void 0,
3123
3154
  offset: field ? import_tokens19.tokens.extensions.floating.fieldGap : import_tokens19.tokens.extensions.floating.anchorGap,
3124
3155
  containerPadding: import_tokens19.tokens.extensions.floating.viewportInset,
3156
+ crossOffset: repositionKey % 2 ? 1e-3 : 0,
3125
3157
  className: "kjun-scope kjun-floating " + className,
3126
3158
  "data-motion": "popup",
3127
3159
  "data-motion-open": String(motion.active),
@@ -3134,10 +3166,36 @@ function FloatingPanel({
3134
3166
  }
3135
3167
  ) });
3136
3168
  }
3169
+ var resolveFocusReturn = (target) => target === void 0 ? void 0 : () => typeof target === "function" ? target() : target instanceof HTMLElement ? target : target.current;
3170
+
3171
+ // shared/package-runtime/anchor-rect.ts
3172
+ function place(element, rect) {
3173
+ var _a, _b;
3174
+ const next = [rect.x, rect.y, (_a = rect.width) != null ? _a : 0, (_b = rect.height) != null ? _b : 0].map((value) => value + "px");
3175
+ const style = element.style;
3176
+ if (style.left === next[0] && style.top === next[1] && style.width === next[2] && style.height === next[3]) return false;
3177
+ [style.left, style.top, style.width, style.height] = next;
3178
+ return true;
3179
+ }
3180
+ function followAnchor(element, source, moved) {
3181
+ let frame = 0, stopped = false;
3182
+ const step = () => {
3183
+ const current = source();
3184
+ const rect = typeof current === "function" ? current() : current;
3185
+ if (rect && place(element, rect)) moved();
3186
+ if (!stopped && typeof current === "function") frame = requestAnimationFrame(step);
3187
+ };
3188
+ step();
3189
+ return () => {
3190
+ stopped = true;
3191
+ cancelAnimationFrame(frame);
3192
+ };
3193
+ }
3194
+ var anchorStyle = { position: "fixed", pointerEvents: "none", visibility: "hidden" };
3137
3195
 
3138
3196
  // packages/react/src/popover.tsx
3139
3197
  var import_tokens20 = require("@kjun-ui/tokens");
3140
- var import_react27 = require("react");
3198
+ var import_react28 = require("react");
3141
3199
  var import_react_aria_components5 = require("react-aria-components");
3142
3200
 
3143
3201
  // shared/package-runtime/popover-nonmodal.ts
@@ -3215,24 +3273,36 @@ function KjunPopover({
3215
3273
  returnFocus,
3216
3274
  header,
3217
3275
  modal = true,
3276
+ anchorRect,
3218
3277
  trigger,
3219
3278
  children
3220
3279
  }) {
3221
3280
  const m = useKjunMessages();
3222
- const [internal, setInternal] = (0, import_react27.useState)(false), open = controlled != null ? controlled : internal, ref = (0, import_react27.useRef)(null), id = "kjun-" + (0, import_react27.useId)();
3281
+ const [internal, setInternal] = (0, import_react28.useState)(false), open = controlled != null ? controlled : internal, ref = (0, import_react28.useRef)(null), id = "kjun-" + (0, import_react28.useId)();
3223
3282
  const expanded = usePopupExpanded(open, ref);
3224
- const focusOnMount = (0, import_react27.useRef)(focusOnOpen);
3283
+ const focusOnMount = (0, import_react28.useRef)(focusOnOpen);
3225
3284
  focusOnMount.current = focusOnOpen;
3226
- const focusContent = (0, import_react27.useCallback)((node) => {
3285
+ const focusContent = (0, import_react28.useCallback)((node) => {
3227
3286
  if (node && focusOnMount.current) node.focus();
3228
3287
  }, []);
3229
- const resolveReturn = returnFocus === void 0 ? void 0 : () => typeof returnFocus === "function" ? returnFocus() : returnFocus instanceof HTMLElement ? returnFocus : returnFocus.current;
3288
+ const resolveReturn = resolveFocusReturn(returnFocus);
3289
+ const anchor = (0, import_react28.useRef)(null), anchorSource = (0, import_react28.useRef)(anchorRect), opener = (0, import_react28.useRef)(null);
3290
+ anchorSource.current = anchorRect;
3291
+ const [reposition, setReposition] = (0, import_react28.useState)(0);
3292
+ const anchored = anchorRect !== void 0;
3293
+ const wasOpen = (0, import_react28.useRef)(false);
3294
+ if (open && !wasOpen.current && typeof document !== "undefined") opener.current = document.activeElement;
3295
+ wasOpen.current = open;
3296
+ (0, import_react28.useLayoutEffect)(() => {
3297
+ if (!open || !anchored || !anchor.current) return;
3298
+ return followAnchor(anchor.current, () => anchorSource.current, () => setReposition((n) => n + 1));
3299
+ }, [open, anchored, typeof anchorRect === "function" ? anchorRect : anchorRect && `${anchorRect.x},${anchorRect.y},${anchorRect.width},${anchorRect.height}`]);
3230
3300
  const change = (v) => {
3231
3301
  setInternal(v);
3232
3302
  onOpenChange == null ? void 0 : onOpenChange(v);
3233
3303
  };
3234
- const skipReturn = (0, import_react27.useRef)(false);
3235
- (0, import_react27.useEffect)(() => {
3304
+ const skipReturn = (0, import_react28.useRef)(false);
3305
+ (0, import_react28.useEffect)(() => {
3236
3306
  if (!open || modal) return;
3237
3307
  skipReturn.current = false;
3238
3308
  return installNonModalPopover({
@@ -3249,7 +3319,8 @@ function KjunPopover({
3249
3319
  });
3250
3320
  const content = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "kjun-popover-content", "data-no-padding": noPadding, children: typeof children === "function" ? children(() => change(false)) : children });
3251
3321
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
3252
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3322
+ anchored && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { ref: anchor, "aria-hidden": "true", style: anchorStyle }),
3323
+ (!anchored || trigger != null) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3253
3324
  "div",
3254
3325
  {
3255
3326
  ref,
@@ -3274,13 +3345,18 @@ function KjunPopover({
3274
3345
  {
3275
3346
  open,
3276
3347
  onOpenChange: change,
3277
- triggerRef: ref,
3348
+ triggerRef: anchored ? anchor : ref,
3349
+ inside: anchored ? ref : void 0,
3350
+ repositionKey: reposition,
3278
3351
  className: "kjun-content-popover" + (header != null ? " kjun-popover-has-header" : ""),
3279
3352
  placement,
3280
3353
  matchTriggerWidth,
3281
3354
  maxHeight,
3282
3355
  flip,
3283
- returnFocus: () => skipReturn.current ? false : resolveReturn == null ? void 0 : resolveReturn(),
3356
+ returnFocus: () => {
3357
+ var _a;
3358
+ return skipReturn.current ? false : (_a = resolveReturn == null ? void 0 : resolveReturn()) != null ? _a : anchored && trigger == null ? opener.current : void 0;
3359
+ },
3284
3360
  nonModal: !modal,
3285
3361
  ownsDismiss: !modal,
3286
3362
  children: (() => {
@@ -3304,6 +3380,9 @@ function KjunPopover({
3304
3380
  }
3305
3381
  function KjunTooltip({
3306
3382
  content = "",
3383
+ title,
3384
+ align,
3385
+ width,
3307
3386
  placement = "top",
3308
3387
  delay = 0,
3309
3388
  open: controlled,
@@ -3311,25 +3390,29 @@ function KjunTooltip({
3311
3390
  children
3312
3391
  }) {
3313
3392
  const container = useKjunPortalContainer();
3314
- const [internal, setInternal] = (0, import_react27.useState)(false), open = controlled != null ? controlled : internal;
3393
+ const [internal, setInternal] = (0, import_react28.useState)(false), open = controlled != null ? controlled : internal;
3315
3394
  const setOpen = (value) => {
3316
3395
  setInternal(value);
3317
3396
  onOpenChange == null ? void 0 : onOpenChange(value);
3318
3397
  };
3319
3398
  const layer = useLayer(open, open, "tooltip", () => setOpen(false));
3320
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react_aria_components5.TooltipTrigger, { isOpen: open && !layer.blocked, onOpenChange: setOpen, delay, closeDelay: 0, isDisabled: !content || !layer.scopeActive, children: [
3399
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react_aria_components5.TooltipTrigger, { isOpen: open && !layer.blocked && !!(content || title), onOpenChange: setOpen, delay, closeDelay: 0, isDisabled: !content && !title || !layer.scopeActive, children: [
3321
3400
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_aria_components5.Focusable, { children }),
3322
3401
  container !== null && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
3323
3402
  import_react_aria_components5.Tooltip,
3324
3403
  {
3325
- style: { zIndex: layer.zIndex },
3404
+ style: { zIndex: layer.zIndex, ...width ? { maxWidth: `var(--_kjun-extension-tooltip-max-widths-${width})` } : {} },
3405
+ "data-align": align,
3326
3406
  UNSTABLE_portalContainer: container,
3327
3407
  placement,
3328
3408
  offset: import_tokens20.tokens.extensions.floating.anchorGap,
3329
3409
  className: "kjun-scope kjun-tooltip",
3330
3410
  children: [
3331
3411
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_aria_components5.OverlayArrow, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("svg", { width: import_tokens20.tokens.extensions.tooltip.arrowSize, height: import_tokens20.tokens.extensions.tooltip.arrowSize, viewBox: "0 0 8 8", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M0 0L4 4L8 0", fill: "currentColor" }) }) }),
3332
- content
3412
+ title ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
3413
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "kjun-tooltip-title", children: title }),
3414
+ content && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "kjun-tooltip-body", children: content })
3415
+ ] }) : content
3333
3416
  ]
3334
3417
  }
3335
3418
  )
@@ -3338,10 +3421,10 @@ function KjunTooltip({
3338
3421
 
3339
3422
  // packages/react/src/dropdown.tsx
3340
3423
  var import_tokens21 = require("@kjun-ui/tokens");
3341
- var import_react28 = require("react");
3424
+ var import_react29 = require("react");
3342
3425
  var import_react_aria_components6 = require("react-aria-components");
3343
3426
  var import_jsx_runtime17 = require("react/jsx-runtime");
3344
- var DropdownContext = (0, import_react28.createContext)(null);
3427
+ var DropdownContext = (0, import_react29.createContext)(null);
3345
3428
  function KjunDropdown({
3346
3429
  disabled = false,
3347
3430
  placement = "bottom-start",
@@ -3351,12 +3434,13 @@ function KjunDropdown({
3351
3434
  trigger,
3352
3435
  children,
3353
3436
  onOpen,
3354
- onClose
3437
+ onClose,
3438
+ returnFocus
3355
3439
  }) {
3356
- const [open, setOpen] = (0, import_react28.useState)(false), currentOpen = (0, import_react28.useRef)(false), ref = (0, import_react28.useRef)(null), id = "kjun-" + (0, import_react28.useId)();
3357
- const menuFocusCleanup = (0, import_react28.useRef)(() => {
3440
+ const [open, setOpen] = (0, import_react29.useState)(false), currentOpen = (0, import_react29.useRef)(false), ref = (0, import_react29.useRef)(null), id = "kjun-" + (0, import_react29.useId)();
3441
+ const menuFocusCleanup = (0, import_react29.useRef)(() => {
3358
3442
  });
3359
- const bindMenu = (0, import_react28.useCallback)((menu) => {
3443
+ const bindMenu = (0, import_react29.useCallback)((menu) => {
3360
3444
  menuFocusCleanup.current();
3361
3445
  menuFocusCleanup.current = () => {
3362
3446
  };
@@ -3378,19 +3462,19 @@ function KjunDropdown({
3378
3462
  };
3379
3463
  }, []);
3380
3464
  let control = trigger;
3381
- while ((0, import_react28.isValidElement)(control) && control.type === KjunTooltip)
3465
+ while ((0, import_react29.isValidElement)(control) && control.type === KjunTooltip)
3382
3466
  control = control.props.children;
3383
- const unavailable = disabled || (0, import_react28.isValidElement)(control) && !!(control.props.disabled || control.props.loading);
3384
- const controlId = triggerId || (0, import_react28.isValidElement)(control) && control.props.id || id;
3467
+ const unavailable = disabled || (0, import_react29.isValidElement)(control) && !!(control.props.disabled || control.props.loading);
3468
+ const controlId = triggerId || (0, import_react29.isValidElement)(control) && control.props.id || id;
3385
3469
  const popupId = menuId || id + "-menu";
3386
3470
  const bindTrigger = (node) => {
3387
- if (!(0, import_react28.isValidElement)(node)) return node;
3471
+ if (!(0, import_react29.isValidElement)(node)) return node;
3388
3472
  if (node.type === KjunTooltip) {
3389
3473
  const tooltip = node;
3390
- return (0, import_react28.cloneElement)(tooltip, {}, bindTrigger(tooltip.props.children));
3474
+ return (0, import_react29.cloneElement)(tooltip, {}, bindTrigger(tooltip.props.children));
3391
3475
  }
3392
3476
  const button = node;
3393
- return (0, import_react28.cloneElement)(button, {
3477
+ return (0, import_react29.cloneElement)(button, {
3394
3478
  id: controlId,
3395
3479
  "aria-haspopup": "menu",
3396
3480
  "aria-expanded": open,
@@ -3407,7 +3491,7 @@ function KjunDropdown({
3407
3491
  if (value) onOpen == null ? void 0 : onOpen();
3408
3492
  else onClose == null ? void 0 : onClose();
3409
3493
  };
3410
- (0, import_react28.useEffect)(() => {
3494
+ (0, import_react29.useEffect)(() => {
3411
3495
  if (unavailable) change(false);
3412
3496
  }, [unavailable]);
3413
3497
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(DropdownContext.Provider, { value: () => change(false), children: [
@@ -3431,6 +3515,7 @@ function KjunDropdown({
3431
3515
  {
3432
3516
  open,
3433
3517
  onOpenChange: change,
3518
+ returnFocus: resolveFocusReturn(returnFocus),
3434
3519
  triggerRef: ref,
3435
3520
  placement,
3436
3521
  className: "kjun-dropdown",
@@ -3460,8 +3545,8 @@ function KjunDropdownItem({
3460
3545
  children,
3461
3546
  onClick
3462
3547
  }) {
3463
- const close = (0, import_react28.useContext)(DropdownContext);
3464
- const node = (0, import_react28.useCallback)((element) => {
3548
+ const close = (0, import_react29.useContext)(DropdownContext);
3549
+ const node = (0, import_react29.useCallback)((element) => {
3465
3550
  if (!element) return;
3466
3551
  if (selected === null) {
3467
3552
  element.setAttribute("role", "menuitem");
@@ -3519,7 +3604,7 @@ function KjunMenuButton({
3519
3604
  ...props
3520
3605
  }) {
3521
3606
  const m = useKjunMessages();
3522
- const [open, setOpen] = (0, import_react28.useState)(false);
3607
+ const [open, setOpen] = (0, import_react29.useState)(false);
3523
3608
  const button = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3524
3609
  KjunButton,
3525
3610
  {
@@ -3588,6 +3673,7 @@ function KjunDrawer({
3588
3673
  footer,
3589
3674
  children,
3590
3675
  onClose,
3676
+ onAfterClose,
3591
3677
  ariaLabel,
3592
3678
  safeAreaTop = 0,
3593
3679
  safeAreaBottom = 0,
@@ -3595,6 +3681,7 @@ function KjunDrawer({
3595
3681
  }) {
3596
3682
  const m = useKjunMessages();
3597
3683
  const motion = usePresence(open, useReducedMotion(), import_tokens22.tokens.motion.layerExit);
3684
+ const afterCloseRef = useAfterCloseRef(open, onAfterClose);
3598
3685
  const container = useKjunPortalContainer();
3599
3686
  const close = () => {
3600
3687
  if (!open) return;
@@ -3608,6 +3695,7 @@ function KjunDrawer({
3608
3695
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(LayerScope.Provider, { value: layer.id, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3609
3696
  import_react_aria_components7.ModalOverlay,
3610
3697
  {
3698
+ ref: afterCloseRef,
3611
3699
  style: { zIndex: layer.zIndex, ...drawerOverlayVars({ safeAreaTop, safeAreaBottom, maxHeight }) },
3612
3700
  isOpen: motion.present && layer.active,
3613
3701
  isExiting: motion.present && !layer.active,
@@ -3674,7 +3762,7 @@ function KjunDrawer({
3674
3762
  }
3675
3763
 
3676
3764
  // shared/package-runtime/combobox.ts
3677
- var import_react29 = require("react");
3765
+ var import_react30 = require("react");
3678
3766
 
3679
3767
  // shared/package-runtime/options.ts
3680
3768
  var optionValue = (option, key = "value") => typeof option === "object" ? option[key] : option;
@@ -3752,10 +3840,10 @@ function useComboboxModel({
3752
3840
  }) {
3753
3841
  const selected = options.find((option) => optionValue(option, valueKey) === value);
3754
3842
  const selectedLabel = selected !== void 0 ? optionLabel(selected, labelKey) : "";
3755
- const [query2, setQuery] = (0, import_react29.useState)(selectedLabel);
3756
- const [open, setOpen] = (0, import_react29.useState)(false);
3757
- (0, import_react29.useEffect)(() => setQuery(selectedLabel), [value, selectedLabel]);
3758
- (0, import_react29.useEffect)(() => {
3843
+ const [query2, setQuery] = (0, import_react30.useState)(selectedLabel);
3844
+ const [open, setOpen] = (0, import_react30.useState)(false);
3845
+ (0, import_react30.useEffect)(() => setQuery(selectedLabel), [value, selectedLabel]);
3846
+ (0, import_react30.useEffect)(() => {
3759
3847
  if (disabled) setOpen(false);
3760
3848
  }, [disabled]);
3761
3849
  const change = (next) => {
@@ -3788,7 +3876,7 @@ function useComboboxModel({
3788
3876
  }
3789
3877
 
3790
3878
  // packages/react/src/combobox.tsx
3791
- var import_react30 = require("react");
3879
+ var import_react31 = require("react");
3792
3880
  var import_jsx_runtime19 = require("react/jsx-runtime");
3793
3881
  function KjunCombobox({
3794
3882
  value,
@@ -3807,7 +3895,8 @@ function KjunCombobox({
3807
3895
  onValueChange,
3808
3896
  onChange,
3809
3897
  onSearch,
3810
- onClear
3898
+ onClear,
3899
+ returnFocus
3811
3900
  }) {
3812
3901
  const m = useKjunMessages();
3813
3902
  placeholder != null ? placeholder : placeholder = m.searchOrSelect;
@@ -3843,7 +3932,8 @@ function KjunCombobox({
3843
3932
  renderOption,
3844
3933
  onValueChange: (v) => model.search(v, true),
3845
3934
  onSelect: model.select,
3846
- onClear: model.clear
3935
+ onClear: model.clear,
3936
+ returnFocus: resolveFocusReturn(returnFocus)
3847
3937
  }
3848
3938
  );
3849
3939
  }
@@ -3868,16 +3958,17 @@ function SearchField({
3868
3958
  onValueChange,
3869
3959
  onSelect,
3870
3960
  onClear,
3871
- onEnter
3961
+ onEnter,
3962
+ returnFocus
3872
3963
  }) {
3873
3964
  const m = useKjunMessages();
3874
3965
  const composition = useCompositionGuard();
3875
- const clearing = (0, import_react30.useRef)(false);
3876
- const ref = (0, import_react30.useRef)(null), [highlighted, setActive] = (0, import_react30.useState)(-1), id = "kjun-" + (0, import_react30.useId)();
3966
+ const clearing = (0, import_react31.useRef)(false);
3967
+ const ref = (0, import_react31.useRef)(null), [highlighted, setActive] = (0, import_react31.useState)(-1), id = "kjun-" + (0, import_react31.useId)();
3877
3968
  const focusGuard = usePopupFocusGuard(ref);
3878
3969
  const active = !disabled && !loading && highlighted >= 0 && highlighted < options.length && !optionDisabled(options[highlighted]) ? highlighted : -1;
3879
- (0, import_react30.useEffect)(() => setActive(-1), [value, options.length]);
3880
- (0, import_react30.useEffect)(() => {
3970
+ (0, import_react31.useEffect)(() => setActive(-1), [value, options.length]);
3971
+ (0, import_react31.useEffect)(() => {
3881
3972
  if (!open) return;
3882
3973
  const leaveField = (event) => {
3883
3974
  var _a, _b, _c;
@@ -3887,16 +3978,16 @@ function SearchField({
3887
3978
  document.addEventListener("focusin", leaveField);
3888
3979
  return () => document.removeEventListener("focusin", leaveField);
3889
3980
  }, [open, onOpenChange, id]);
3890
- (0, import_react30.useEffect)(() => {
3981
+ (0, import_react31.useEffect)(() => {
3891
3982
  if (highlighted !== active) setActive(-1);
3892
3983
  }, [highlighted, active]);
3893
3984
  const available = options.map((o, i) => optionDisabled(o) ? -1 : i).filter((i) => i >= 0);
3894
3985
  const select = (o) => {
3895
- var _a;
3986
+ var _a, _b;
3896
3987
  if (o === void 0 || disabled || loading || optionDisabled(o)) return;
3897
3988
  onSelect(o);
3898
3989
  onOpenChange(false);
3899
- (_a = ref.current) == null ? void 0 : _a.focus();
3990
+ (_b = (_a = returnFocus == null ? void 0 : returnFocus()) != null ? _a : ref.current) == null ? void 0 : _b.focus();
3900
3991
  };
3901
3992
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
3902
3993
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
@@ -3944,7 +4035,7 @@ function SearchField({
3944
4035
  onCompositionStart: composition.onCompositionStart,
3945
4036
  onCompositionEnd: composition.onCompositionEnd,
3946
4037
  onKeyDown: (e) => {
3947
- var _a, _b, _c, _d;
4038
+ var _a, _b, _c, _d, _e;
3948
4039
  if (composition.isComposing(e)) return;
3949
4040
  let next = active;
3950
4041
  if (e.key === "ArrowDown") {
@@ -3967,10 +4058,11 @@ function SearchField({
3967
4058
  e.preventDefault();
3968
4059
  e.stopPropagation();
3969
4060
  onOpenChange(false);
4061
+ (_d = returnFocus == null ? void 0 : returnFocus()) == null ? void 0 : _d.focus();
3970
4062
  }
3971
4063
  setActive(next);
3972
4064
  if (next >= 0)
3973
- (_d = document.getElementById(id + "-" + next)) == null ? void 0 : _d.scrollIntoView({ block: "nearest" });
4065
+ (_e = document.getElementById(id + "-" + next)) == null ? void 0 : _e.scrollIntoView({ block: "nearest" });
3974
4066
  }
3975
4067
  }
3976
4068
  ),
@@ -4020,7 +4112,7 @@ function SearchField({
4020
4112
 
4021
4113
  // packages/react/src/date-picker.tsx
4022
4114
  var import_tokens23 = require("@kjun-ui/tokens");
4023
- var import_react31 = require("react");
4115
+ var import_react32 = require("react");
4024
4116
  var import_jsx_runtime20 = (
4025
4117
  // The drawn calendar icon matches Native; the transparent browser indicator sits on top of it
4026
4118
  // (sized by these variables) so clicking the icon still opens the browser picker.
@@ -4040,7 +4132,7 @@ function KjunDatePicker({
4040
4132
  }) {
4041
4133
  const scope = useKjunMessageScope();
4042
4134
  placeholder != null ? placeholder : placeholder = scope.messages.datePlaceholder;
4043
- const [focus, setFocus] = (0, import_react31.useState)(false);
4135
+ const [focus, setFocus] = (0, import_react32.useState)(false);
4044
4136
  const clear = clearable && !!value && !props.disabled && !props.readOnly;
4045
4137
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "kjun-date-picker", style: {
4046
4138
  position: "relative",
@@ -4106,10 +4198,10 @@ function KjunDatePicker({
4106
4198
  }
4107
4199
 
4108
4200
  // packages/react/src/search-input.tsx
4109
- var import_react33 = require("react");
4201
+ var import_react34 = require("react");
4110
4202
 
4111
4203
  // shared/package-runtime/search-input.ts
4112
- var import_react32 = require("react");
4204
+ var import_react33 = require("react");
4113
4205
  function useSearchInputModel({
4114
4206
  value,
4115
4207
  disabled = false,
@@ -4119,20 +4211,20 @@ function useSearchInputModel({
4119
4211
  onValueChange,
4120
4212
  onSearchError
4121
4213
  }, open) {
4122
- const [query2, setQuery] = (0, import_react32.useState)(value), [options, setOptions] = (0, import_react32.useState)([]), [loading, setLoading] = (0, import_react32.useState)(false), [failed, setFailed] = (0, import_react32.useState)(false), version = (0, import_react32.useRef)(0), notify = (0, import_react32.useRef)(onSearchError);
4214
+ const [query2, setQuery] = (0, import_react33.useState)(value), [options, setOptions] = (0, import_react33.useState)([]), [loading, setLoading] = (0, import_react33.useState)(false), [failed, setFailed] = (0, import_react33.useState)(false), version = (0, import_react33.useRef)(0), notify = (0, import_react33.useRef)(onSearchError);
4123
4215
  notify.current = onSearchError;
4124
- const timer = (0, import_react32.useRef)(void 0);
4125
- const notifyValue = (0, import_react32.useRef)(onValueChange);
4216
+ const timer = (0, import_react33.useRef)(void 0);
4217
+ const notifyValue = (0, import_react33.useRef)(onValueChange);
4126
4218
  notifyValue.current = onValueChange;
4127
- (0, import_react32.useLayoutEffect)(() => {
4219
+ (0, import_react33.useLayoutEffect)(() => {
4128
4220
  clearTimeout(timer.current);
4129
4221
  setQuery(value);
4130
4222
  }, [value]);
4131
- (0, import_react32.useLayoutEffect)(() => {
4223
+ (0, import_react33.useLayoutEffect)(() => {
4132
4224
  clearTimeout(timer.current);
4133
4225
  return () => clearTimeout(timer.current);
4134
4226
  }, [disabled, debounce, !!loadOptions]);
4135
- (0, import_react32.useEffect)(() => {
4227
+ (0, import_react33.useEffect)(() => {
4136
4228
  const current = ++version.current, abort = new AbortController();
4137
4229
  setFailed(false);
4138
4230
  if (!loadOptions || !open || disabled || query2.length < minChars) {
@@ -4223,7 +4315,7 @@ function KjunSearchInput({
4223
4315
  placeholder != null ? placeholder : placeholder = m.search;
4224
4316
  emptyText != null ? emptyText : emptyText = m.noResults;
4225
4317
  errorText != null ? errorText : errorText = m.searchFailed;
4226
- const [open, setOpen] = (0, import_react33.useState)(false);
4318
+ const [open, setOpen] = (0, import_react34.useState)(false);
4227
4319
  const model = useSearchInputModel({ value, disabled, debounce, loadOptions, minChars, onValueChange, onSearchError }, open);
4228
4320
  const { query: query2, options, loading, failed } = model;
4229
4321
  const update = (value2) => {
@@ -4286,20 +4378,20 @@ function KjunSearchInput({
4286
4378
 
4287
4379
  // packages/react/src/select-control.tsx
4288
4380
  var import_tokens24 = require("@kjun-ui/tokens");
4289
- var import_react36 = require("react");
4381
+ var import_react37 = require("react");
4290
4382
  var import_react_aria_components8 = require("react-aria-components");
4291
4383
 
4292
4384
  // shared/package-runtime/select.ts
4293
- var import_react34 = require("react");
4385
+ var import_react35 = require("react");
4294
4386
  function useSelectState(controlled, disabled, pageSize, onOpenChange) {
4295
- const [internal, setInternal] = (0, import_react34.useState)(false);
4296
- const [query2, setQuery] = (0, import_react34.useState)("");
4297
- const [limit, setLimit] = (0, import_react34.useState)(pageSize);
4298
- const [session, setSession] = (0, import_react34.useState)(0);
4387
+ const [internal, setInternal] = (0, import_react35.useState)(false);
4388
+ const [query2, setQuery] = (0, import_react35.useState)("");
4389
+ const [limit, setLimit] = (0, import_react35.useState)(pageSize);
4390
+ const [session, setSession] = (0, import_react35.useState)(0);
4299
4391
  const isControlled = typeof controlled === "boolean";
4300
4392
  const open = !disabled && (isControlled ? controlled : internal);
4301
- const previousOpen = (0, import_react34.useRef)(open);
4302
- (0, import_react34.useEffect)(() => {
4393
+ const previousOpen = (0, import_react35.useRef)(open);
4394
+ (0, import_react35.useEffect)(() => {
4303
4395
  if (disabled && !isControlled) setInternal(false);
4304
4396
  if (previousOpen.current && !open) {
4305
4397
  setQuery("");
@@ -4308,7 +4400,7 @@ function useSelectState(controlled, disabled, pageSize, onOpenChange) {
4308
4400
  }
4309
4401
  previousOpen.current = open;
4310
4402
  }, [open, disabled, isControlled, pageSize]);
4311
- (0, import_react34.useEffect)(() => {
4403
+ (0, import_react35.useEffect)(() => {
4312
4404
  setLimit(pageSize);
4313
4405
  }, [pageSize]);
4314
4406
  const changeOpen = (next) => {
@@ -4324,8 +4416,8 @@ function useSelectState(controlled, disabled, pageSize, onOpenChange) {
4324
4416
  }
4325
4417
 
4326
4418
  // packages/react/src/compound-control.ts
4327
- var import_react35 = require("react");
4328
- var CompoundControlContext = (0, import_react35.createContext)(null);
4419
+ var import_react36 = require("react");
4420
+ var CompoundControlContext = (0, import_react36.createContext)(null);
4329
4421
 
4330
4422
  // packages/react/src/select-control.tsx
4331
4423
  var import_jsx_runtime22 = require("react/jsx-runtime");
@@ -4357,24 +4449,25 @@ function KjunSelect({
4357
4449
  onSearch,
4358
4450
  onClear,
4359
4451
  filterFn,
4360
- searchKeys
4452
+ searchKeys,
4453
+ returnFocus
4361
4454
  }) {
4362
4455
  const m = useKjunMessages();
4363
4456
  placeholder != null ? placeholder : placeholder = m.select;
4364
4457
  searchPlaceholder != null ? searchPlaceholder : searchPlaceholder = m.search;
4365
4458
  const { open, query: query2, limit, session, changeOpen, search, showMore } = useSelectState(controlled, disabled, optionPageSize, onOpenChange);
4366
4459
  const composition = useCompositionGuard();
4367
- const ref = (0, import_react36.useRef)(null), menu = (0, import_react36.useRef)(null), field = useKjunField(), id = "kjun-" + (0, import_react36.useId)();
4368
- const segment = (0, import_react36.useContext)(CompoundControlContext) !== null;
4460
+ const ref = (0, import_react37.useRef)(null), menu = (0, import_react37.useRef)(null), field = useKjunField(), id = "kjun-" + (0, import_react37.useId)();
4461
+ const segment = (0, import_react37.useContext)(CompoundControlContext) !== null;
4369
4462
  const spec = import_tokens24.tokens.input[size];
4370
4463
  const expanded = usePopupExpanded(open, ref);
4371
4464
  const registerControl = field == null ? void 0 : field.setControlId;
4372
- (0, import_react36.useEffect)(() => {
4465
+ (0, import_react37.useEffect)(() => {
4373
4466
  if (!registerControl || !triggerId) return;
4374
4467
  registerControl(triggerId);
4375
4468
  return () => registerControl(void 0);
4376
4469
  }, [registerControl, triggerId]);
4377
- (0, import_react36.useEffect)(() => {
4470
+ (0, import_react37.useEffect)(() => {
4378
4471
  var _a, _b;
4379
4472
  if (open && searchable) (_b = (_a = menu.current) == null ? void 0 : _a.querySelector("input")) == null ? void 0 : _b.focus({ preventScroll: true });
4380
4473
  if (!open) composition.onCompositionEnd();
@@ -4466,6 +4559,7 @@ function KjunSelect({
4466
4559
  {
4467
4560
  field: true,
4468
4561
  open,
4562
+ returnFocus: resolveFocusReturn(returnFocus),
4469
4563
  onOpenChange: changeOpen,
4470
4564
  triggerRef: ref,
4471
4565
  placement: "bottom-start",
@@ -4565,17 +4659,19 @@ var import_tokens26 = require("@kjun-ui/tokens");
4565
4659
 
4566
4660
  // packages/react/src/collapse.tsx
4567
4661
  var import_tokens25 = require("@kjun-ui/tokens");
4568
- var import_react37 = require("react");
4662
+ var import_react38 = require("react");
4569
4663
  var import_jsx_runtime23 = require("react/jsx-runtime");
4570
- function Collapse({ open, children }) {
4664
+ function Collapse({ open, keepMounted = false, children }) {
4571
4665
  const reduced = useReducedMotion();
4572
- const [retained, setRetained] = (0, import_react37.useState)(open);
4573
- const root = (0, import_react37.useRef)(null), body = (0, import_react37.useRef)(null);
4574
- const animation = (0, import_react37.useRef)(null);
4575
- const previous = (0, import_react37.useRef)(open);
4576
- const interrupted = (0, import_react37.useRef)(null);
4577
- const present = open || retained;
4578
- (0, import_react37.useLayoutEffect)(() => {
4666
+ const [retained, setRetained] = (0, import_react38.useState)(open);
4667
+ const root = (0, import_react38.useRef)(null), body = (0, import_react38.useRef)(null);
4668
+ const animation = (0, import_react38.useRef)(null);
4669
+ const previous = (0, import_react38.useRef)(open);
4670
+ const interrupted = (0, import_react38.useRef)(null);
4671
+ const opened = (0, import_react38.useRef)(open);
4672
+ if (open) opened.current = true;
4673
+ const present = open || retained || keepMounted && opened.current;
4674
+ (0, import_react38.useLayoutEffect)(() => {
4579
4675
  const el = root.current, inner = body.current;
4580
4676
  if (!el || !inner) return;
4581
4677
  let disposed = false;
@@ -4630,10 +4726,10 @@ function Collapse({ open, children }) {
4630
4726
  }
4631
4727
 
4632
4728
  // shared/package-runtime/navigation.ts
4633
- var import_react38 = require("react");
4729
+ var import_react39 = require("react");
4634
4730
  function useInitialTab(value, candidate, change) {
4635
- const requested = (0, import_react38.useRef)(/* @__PURE__ */ new Set());
4636
- (0, import_react38.useEffect)(() => {
4731
+ const requested = (0, import_react39.useRef)(/* @__PURE__ */ new Set());
4732
+ (0, import_react39.useEffect)(() => {
4637
4733
  if (value !== "") {
4638
4734
  requested.current.clear();
4639
4735
  return;
@@ -4644,8 +4740,8 @@ function useInitialTab(value, candidate, change) {
4644
4740
  }, [value, candidate, change]);
4645
4741
  }
4646
4742
  function useAccordionState(multiple) {
4647
- const [opened, setOpened] = (0, import_react38.useState)(/* @__PURE__ */ new Set());
4648
- (0, import_react38.useEffect)(() => {
4743
+ const [opened, setOpened] = (0, import_react39.useState)(/* @__PURE__ */ new Set());
4744
+ (0, import_react39.useEffect)(() => {
4649
4745
  if (!multiple) setOpened((previous) => previous.size > 1 ? new Set([...previous].slice(-1)) : previous);
4650
4746
  }, [multiple]);
4651
4747
  return {
@@ -4729,7 +4825,7 @@ function manageTabList(list, select, keyboard = true) {
4729
4825
  }
4730
4826
 
4731
4827
  // packages/react/src/navigation.tsx
4732
- var import_react39 = require("react");
4828
+ var import_react40 = require("react");
4733
4829
  var import_react_aria_components9 = require("react-aria-components");
4734
4830
  var import_jsx_runtime24 = require("react/jsx-runtime");
4735
4831
  function KjunTabs({
@@ -4748,33 +4844,33 @@ function KjunTabs({
4748
4844
  const m = useKjunMessages();
4749
4845
  ariaLabel != null ? ariaLabel : ariaLabel = m.tabs;
4750
4846
  const { group, indicator } = useSelectionIndicator(true);
4751
- const panes = import_react39.Children.toArray(children).filter(
4752
- import_react39.isValidElement
4847
+ const panes = import_react40.Children.toArray(children).filter(
4848
+ import_react40.isValidElement
4753
4849
  );
4754
4850
  const tabs = items.length ? items : panes.filter((child) => child.type === KjunTabPane).map((child) => child.props);
4755
- (0, import_react39.useLayoutEffect)(() => {
4851
+ (0, import_react40.useLayoutEffect)(() => {
4756
4852
  var _a2;
4757
4853
  const list = (_a2 = group.current) == null ? void 0 : _a2.querySelector('[role="tablist"]');
4758
4854
  if (list) return manageTabList(list, () => {
4759
4855
  }, false);
4760
4856
  }, [group]);
4761
- (0, import_react39.useLayoutEffect)(() => {
4857
+ (0, import_react40.useLayoutEffect)(() => {
4762
4858
  var _a2;
4763
4859
  const panelNames = new Set(panes.filter((child) => child.type === KjunTabPane).map((child) => child.props.name));
4764
4860
  for (const tab of ((_a2 = group.current) == null ? void 0 : _a2.querySelectorAll('[role="tab"]')) || []) {
4765
4861
  if (!panelNames.has(tab.dataset.tabName)) tab.removeAttribute("aria-controls");
4766
4862
  }
4767
4863
  });
4768
- const timer = (0, import_react39.useRef)(void 0), press = (0, import_react39.useRef)(null);
4769
- const menuState = (0, import_react39.useRef)({ tabs, onTabMenu });
4864
+ const timer = (0, import_react40.useRef)(void 0), press = (0, import_react40.useRef)(null);
4865
+ const menuState = (0, import_react40.useRef)({ tabs, onTabMenu });
4770
4866
  menuState.current = { tabs, onTabMenu };
4771
4867
  const canOpenMenu = (name) => !!menuState.current.onTabMenu && menuState.current.tabs.some((tab) => tab.name === name && !tab.disabled);
4772
4868
  const clear = () => {
4773
4869
  clearTimeout(timer.current);
4774
4870
  press.current = null;
4775
4871
  };
4776
- (0, import_react39.useEffect)(() => clear, []);
4777
- (0, import_react39.useLayoutEffect)(() => {
4872
+ (0, import_react40.useEffect)(() => clear, []);
4873
+ (0, import_react40.useLayoutEffect)(() => {
4778
4874
  if (press.current && !canOpenMenu(press.current.name)) clear();
4779
4875
  }, [tabs, onTabMenu]);
4780
4876
  const change = (name) => {
@@ -4871,7 +4967,7 @@ function KjunTabPane({ name, children }) {
4871
4967
  }
4872
4968
  );
4873
4969
  }
4874
- var AccordionContext = (0, import_react39.createContext)(null);
4970
+ var AccordionContext = (0, import_react40.createContext)(null);
4875
4971
  function KjunAccordion({
4876
4972
  multiple = false,
4877
4973
  tone = "card",
@@ -4891,12 +4987,30 @@ function KjunAccordionItem({
4891
4987
  defaultOpen = false,
4892
4988
  disabled = false,
4893
4989
  header,
4990
+ open: openProp,
4991
+ onOpenChange,
4992
+ keepMounted = false,
4894
4993
  children
4895
4994
  }) {
4896
- const group = (0, import_react39.useContext)(AccordionContext), id = "kjun-" + (0, import_react39.useId)(), [own, setOwn] = (0, import_react39.useState)(defaultOpen), open = group ? group.opened.has(id) : own;
4897
- (0, import_react39.useEffect)(() => {
4995
+ const controlled = openProp !== void 0, context = (0, import_react40.useContext)(AccordionContext), group = controlled ? null : context, id = "kjun-" + (0, import_react40.useId)(), [own, setOwn] = (0, import_react40.useState)(defaultOpen), open = controlled ? openProp : group ? group.opened.has(id) : own;
4996
+ (0, import_react40.useEffect)(() => {
4898
4997
  return group == null ? void 0 : group.register(id, defaultOpen);
4899
4998
  }, []);
4999
+ const reported = (0, import_react40.useRef)(open), notify = (0, import_react40.useRef)(onOpenChange), registering = (0, import_react40.useRef)(!!group && defaultOpen);
5000
+ notify.current = onOpenChange;
5001
+ (0, import_react40.useEffect)(() => {
5002
+ var _a;
5003
+ if (registering.current) {
5004
+ if (open) {
5005
+ registering.current = false;
5006
+ reported.current = open;
5007
+ }
5008
+ return;
5009
+ }
5010
+ if (controlled || reported.current === open) return;
5011
+ reported.current = open;
5012
+ (_a = notify.current) == null ? void 0 : _a.call(notify, open);
5013
+ }, [open, controlled]);
4900
5014
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "kjun-accordion-item", children: [
4901
5015
  /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
4902
5016
  "button",
@@ -4907,7 +5021,10 @@ function KjunAccordionItem({
4907
5021
  "aria-expanded": open,
4908
5022
  "aria-controls": id + "-panel",
4909
5023
  className: "kjun-accordion-trigger",
4910
- onClick: () => group ? group.toggle(id) : setOwn(!own),
5024
+ onClick: () => {
5025
+ registering.current = false;
5026
+ controlled ? onOpenChange == null ? void 0 : onOpenChange(!open) : group ? group.toggle(id) : setOwn(!own);
5027
+ },
4911
5028
  children: [
4912
5029
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "kjun-accordion-heading", children: header || title }),
4913
5030
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
@@ -4922,7 +5039,7 @@ function KjunAccordionItem({
4922
5039
  ]
4923
5040
  }
4924
5041
  ),
4925
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Collapse, { open, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5042
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Collapse, { open, keepMounted, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4926
5043
  "div",
4927
5044
  {
4928
5045
  role: "region",
@@ -4947,7 +5064,7 @@ function KjunBreadcrumb({
4947
5064
  " ",
4948
5065
  item.label
4949
5066
  ] });
4950
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react39.Fragment, { children: [
5067
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react40.Fragment, { children: [
4951
5068
  i > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KjunIcon, { name: "chevron-right", size: import_tokens26.tokens.extensions.breadcrumb.separatorSize }),
4952
5069
  " ",
4953
5070
  item.to && i < items.length - 1 ? (renderLink == null ? void 0 : renderLink(item, label)) || /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("a", { href: item.to, children: label }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "aria-current": i === items.length - 1 ? "page" : void 0, children: label })
@@ -5049,7 +5166,7 @@ function KjunPagination({
5049
5166
 
5050
5167
  // packages/react/src/actions.tsx
5051
5168
  var import_tokens27 = require("@kjun-ui/tokens");
5052
- var import_react40 = require("react");
5169
+ var import_react41 = require("react");
5053
5170
  var import_jsx_runtime25 = require("react/jsx-runtime");
5054
5171
  function KjunIconToggle({
5055
5172
  active = false,
@@ -5069,7 +5186,7 @@ function KjunIconToggle({
5069
5186
  onToggle
5070
5187
  }) {
5071
5188
  var _a;
5072
- const navigation = (0, import_react40.useContext)(TopNavigationContext);
5189
+ const navigation = (0, import_react41.useContext)(TopNavigationContext);
5073
5190
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(KjunTooltip, { content: disabled || loading ? "" : tooltip != null ? tooltip : ariaLabel, placement: tooltipPlacement, delay: tooltipDelay, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5074
5191
  "button",
5075
5192
  {
@@ -5131,8 +5248,8 @@ function KjunCopyButton({
5131
5248
  const m = useKjunMessages();
5132
5249
  successText != null ? successText : successText = m.copied;
5133
5250
  const feedback = useOptionalKjunFeedback();
5134
- const [copied, setCopied] = (0, import_react40.useState)(false), [failed, setFailed] = (0, import_react40.useState)(false), busy = (0, import_react40.useRef)(false), timer = (0, import_react40.useRef)(void 0), mounted = (0, import_react40.useRef)(true);
5135
- (0, import_react40.useEffect)(() => {
5251
+ const [copied, setCopied] = (0, import_react41.useState)(false), [failed, setFailed] = (0, import_react41.useState)(false), busy = (0, import_react41.useRef)(false), timer = (0, import_react41.useRef)(void 0), mounted = (0, import_react41.useRef)(true);
5252
+ (0, import_react41.useEffect)(() => {
5136
5253
  mounted.current = true;
5137
5254
  return () => {
5138
5255
  mounted.current = false;
@@ -5263,7 +5380,7 @@ function KjunExternalLink({
5263
5380
  ) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "aria-label": name, children: body });
5264
5381
  }
5265
5382
  function KjunScrollFade({ children }) {
5266
- const ref = (0, import_react40.useRef)(null), [edges, setEdges] = (0, import_react40.useState)({ left: false, right: false });
5383
+ const ref = (0, import_react41.useRef)(null), [edges, setEdges] = (0, import_react41.useState)({ left: false, right: false });
5267
5384
  const update = () => {
5268
5385
  const el = ref.current;
5269
5386
  if (el)
@@ -5275,7 +5392,7 @@ function KjunScrollFade({ children }) {
5275
5392
  return prev.left === next.left && prev.right === next.right ? prev : next;
5276
5393
  });
5277
5394
  };
5278
- (0, import_react40.useEffect)(() => {
5395
+ (0, import_react41.useEffect)(() => {
5279
5396
  update();
5280
5397
  const observer = new ResizeObserver(update);
5281
5398
  if (ref.current) {
@@ -5299,13 +5416,13 @@ function KjunScrollFade({ children }) {
5299
5416
 
5300
5417
  // packages/react/src/data-state.tsx
5301
5418
  var import_tokens28 = require("@kjun-ui/tokens");
5302
- var import_react42 = require("react");
5419
+ var import_react43 = require("react");
5303
5420
 
5304
5421
  // shared/package-runtime/use-loading-reveal.ts
5305
- var import_react41 = require("react");
5422
+ var import_react42 = require("react");
5306
5423
  function useLoadingReveal(active, delay = 0) {
5307
- const [revealed, setRevealed] = (0, import_react41.useState)(false);
5308
- (0, import_react41.useEffect)(() => {
5424
+ const [revealed, setRevealed] = (0, import_react42.useState)(false);
5425
+ (0, import_react42.useEffect)(() => {
5309
5426
  setRevealed(false);
5310
5427
  if (!active || delay <= 0) return;
5311
5428
  const timer = setTimeout(() => setRevealed(true), delay);
@@ -5318,7 +5435,7 @@ function useLoadingReveal(active, delay = 0) {
5318
5435
  var import_jsx_runtime26 = require("react/jsx-runtime");
5319
5436
  function useQueryDisplay(props) {
5320
5437
  var _a;
5321
- const [state, setState] = (0, import_react42.useState)(() => (0, import_tokens28.initialQueryDisplay)(props));
5438
+ const [state, setState] = (0, import_react43.useState)(() => (0, import_tokens28.initialQueryDisplay)(props));
5322
5439
  let next = state;
5323
5440
  if (state.queryKey !== ((_a = props.queryKey) != null ? _a : null) || state.resultKey !== props.resultKey || state.loading !== !!props.loading) {
5324
5441
  next = (0, import_tokens28.advanceQueryDisplay)(state, props);
@@ -5392,7 +5509,7 @@ function KjunDataState({
5392
5509
  visibleRefreshError && !state.initialLoading && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "kjun-data-warning kjun-state-actions", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(KjunAlert, { type: "warning", size: "sm", actions: onRetry && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(KjunButton, { variant: "secondary", onClick: onRetry, children: retryText }), children: m.refreshError(String(visibleRefreshError)) }) })
5393
5510
  ] });
5394
5511
  }
5395
- var KjunErrorBoundary = class extends import_react42.Component {
5512
+ var KjunErrorBoundary = class extends import_react43.Component {
5396
5513
  constructor() {
5397
5514
  super(...arguments);
5398
5515
  this.state = { error: false };
@@ -5629,13 +5746,13 @@ function KjunChartSkeleton({
5629
5746
 
5630
5747
  // packages/react/src/financial-display.tsx
5631
5748
  var import_tokens34 = require("@kjun-ui/tokens");
5632
- var import_react44 = require("react");
5749
+ var import_react45 = require("react");
5633
5750
 
5634
5751
  // packages/react/src/number-display.tsx
5635
5752
  var import_tokens33 = require("@kjun-ui/tokens");
5636
5753
 
5637
5754
  // shared/package-runtime/use-number-motion.ts
5638
- var import_react43 = require("react");
5755
+ var import_react44 = require("react");
5639
5756
 
5640
5757
  // shared/package-runtime/number-motion.ts
5641
5758
  var import_tokens32 = require("@kjun-ui/tokens");
@@ -5681,14 +5798,14 @@ function createNumberMotion(apply) {
5681
5798
 
5682
5799
  // shared/package-runtime/use-number-motion.ts
5683
5800
  function useNumberMotion(value, animated, fromPrevious, reduced) {
5684
- const [display, setDisplay] = (0, import_react43.useState)(typeof value === "string" || fromPrevious || !animated || reduced ? value : 0);
5685
- const motion = (0, import_react43.useRef)(null);
5801
+ const [display, setDisplay] = (0, import_react44.useState)(typeof value === "string" || fromPrevious || !animated || reduced ? value : 0);
5802
+ const motion = (0, import_react44.useRef)(null);
5686
5803
  if (!motion.current) motion.current = createNumberMotion(setDisplay);
5687
- (0, import_react43.useLayoutEffect)(() => {
5804
+ (0, import_react44.useLayoutEffect)(() => {
5688
5805
  if (!motion.current) motion.current = createNumberMotion(setDisplay);
5689
5806
  motion.current.update(value, animated, fromPrevious, reduced);
5690
5807
  }, [value, animated, fromPrevious, reduced]);
5691
- (0, import_react43.useLayoutEffect)(() => () => {
5808
+ (0, import_react44.useLayoutEffect)(() => () => {
5692
5809
  var _a;
5693
5810
  (_a = motion.current) == null ? void 0 : _a.cancel();
5694
5811
  motion.current = null;
@@ -5966,7 +6083,7 @@ function KjunSparkline({
5966
6083
  stretch = false,
5967
6084
  ariaLabel
5968
6085
  }) {
5969
- const id = "kjun-" + (0, import_react44.useId)().replace(/:/g, ""), values = data.filter(Number.isFinite), min = Math.min(...values), max = Math.max(...values), range = max - min || 1, points = values.map(
6086
+ const id = "kjun-" + (0, import_react45.useId)().replace(/:/g, ""), values = data.filter(Number.isFinite), min = Math.min(...values), max = Math.max(...values), range = max - min || 1, points = values.map(
5970
6087
  (v, i) => `${2 + i / Math.max(1, values.length - 1) * (width - 4)},${2 + height - 4 - (v - min) / range * (height - 4)}`
5971
6088
  ).join(" "), change = values.length > 1 ? values[values.length - 1] - values[0] : 0, line = color || `var(--_kjun-color-${change === 0 ? "text-tertiary" : semantic === "status" ? change > 0 ? "success" : "danger" : change > 0 ? "price-up" : "price-down"})`;
5972
6089
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
@@ -6014,7 +6131,7 @@ function KjunSparkline({
6014
6131
 
6015
6132
  // shared/package-runtime/table.ts
6016
6133
  var import_tokens35 = require("@kjun-ui/tokens");
6017
- var import_react45 = require("react");
6134
+ var import_react46 = require("react");
6018
6135
 
6019
6136
  // shared/package-runtime/table-model.ts
6020
6137
  function getValue(row, key) {
@@ -6058,11 +6175,11 @@ function useTableModel(props) {
6058
6175
  expandSingle = false,
6059
6176
  onExpandedRowsChange
6060
6177
  } = props;
6061
- const [internalSort, setSort] = (0, import_react45.useState)({
6178
+ const [internalSort, setSort] = (0, import_react46.useState)({
6062
6179
  key: "",
6063
6180
  order: "asc"
6064
- }), [internalExpanded, setExpanded] = (0, import_react45.useState)([]), [search, setSearch] = (0, import_react45.useState)(""), timer = (0, import_react45.useRef)(void 0);
6065
- (0, import_react45.useEffect)(() => () => clearTimeout(timer.current), []);
6181
+ }), [internalExpanded, setExpanded] = (0, import_react46.useState)([]), [search, setSearch] = (0, import_react46.useState)(""), timer = (0, import_react46.useRef)(void 0);
6182
+ (0, import_react46.useEffect)(() => () => clearTimeout(timer.current), []);
6066
6183
  const sort = props.sort === void 0 ? internalSort : (_a = props.sort) != null ? _a : { key: "", order: "asc" };
6067
6184
  const rows = sortTableRows(data, sort, { sortable, sortMode });
6068
6185
  const key = (row, index = 0) => tableRowKey(row, rowKey, index);
@@ -6211,10 +6328,10 @@ function TableToolbar({
6211
6328
 
6212
6329
  // packages/react/src/table-grid.tsx
6213
6330
  var import_tokens38 = require("@kjun-ui/tokens");
6214
- var import_react47 = require("react");
6331
+ var import_react48 = require("react");
6215
6332
 
6216
6333
  // packages/react/src/table-check.tsx
6217
- var import_react46 = require("react");
6334
+ var import_react47 = require("react");
6218
6335
 
6219
6336
  // shared/package-runtime/component-icons.ts
6220
6337
  var import_minus = __toESM(require("@kjun-ui/icons/icons/minus"), 1);
@@ -6223,7 +6340,7 @@ var componentIcons = { minus: import_minus.default };
6223
6340
  // packages/react/src/table-check.tsx
6224
6341
  var import_tokens37 = require("@kjun-ui/tokens");
6225
6342
  var import_jsx_runtime33 = require("react/jsx-runtime");
6226
- var TableCheck = (0, import_react46.forwardRef)(
6343
+ var TableCheck = (0, import_react47.forwardRef)(
6227
6344
  function TableCheck2(props, ref) {
6228
6345
  const size = import_tokens37.tokens.extensions.checkbox.iconSizes.sm;
6229
6346
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(IconFallbacks, { icons: componentIcons, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("span", { className: "kjun-table-check", children: [
@@ -6312,7 +6429,7 @@ function TableGrid({ initialLoading, skeletonRows, skeletonHidden, state, onRowC
6312
6429
  className: "kjun-table-empty",
6313
6430
  children: emptyContent || emptyText
6314
6431
  }
6315
- ) }) : state.rows.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_react47.Fragment, { children: [
6432
+ ) }) : state.rows.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_react48.Fragment, { children: [
6316
6433
  /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
6317
6434
  "tr",
6318
6435
  {
@@ -6456,7 +6573,7 @@ function TableCards({
6456
6573
  }
6457
6574
 
6458
6575
  // packages/react/src/table-view.tsx
6459
- var import_react48 = require("react");
6576
+ var import_react49 = require("react");
6460
6577
  var import_tokens39 = require("@kjun-ui/tokens");
6461
6578
  var import_jsx_runtime36 = require("react/jsx-runtime");
6462
6579
  function KjunTable(props) {
@@ -6487,8 +6604,8 @@ function KjunTable(props) {
6487
6604
  onRowClick,
6488
6605
  onRetry
6489
6606
  } = props;
6490
- const state = useTableModel2(props), query2 = useQueryDisplay(props), revealed = useLoadingReveal(query2.initialLoading, skeleton ? loadingDelay : 0), [mobile, setMobile] = (0, import_react48.useState)(false);
6491
- (0, import_react48.useEffect)(() => {
6607
+ const state = useTableModel2(props), query2 = useQueryDisplay(props), revealed = useLoadingReveal(query2.initialLoading, skeleton ? loadingDelay : 0), [mobile, setMobile] = (0, import_react49.useState)(false);
6608
+ (0, import_react49.useEffect)(() => {
6492
6609
  const media = matchMedia(`(width < ${import_tokens39.tokens.table.mobileBreakpoint}px)`);
6493
6610
  const update = () => setMobile(media.matches);
6494
6611
  update();
@@ -6854,7 +6971,7 @@ function KjunKpiRow({
6854
6971
  var import_tokens41 = require("@kjun-ui/tokens");
6855
6972
 
6856
6973
  // shared/package-runtime/market-cards.ts
6857
- var import_react49 = require("react");
6974
+ var import_react50 = require("react");
6858
6975
  function useMarketCardsModel(props, persistence) {
6859
6976
  const {
6860
6977
  columns,
@@ -6870,8 +6987,8 @@ function useMarketCardsModel(props, persistence) {
6870
6987
  sortKey: c.sortable ? metricConfig[c.key].sortKey : null,
6871
6988
  isDefaultSort: c.defaultSort
6872
6989
  }));
6873
- const [key, setKey] = (0, import_react49.useState)(""), restoreSignature = JSON.stringify([storageNamespace, pills]);
6874
- const mounted = (0, import_react49.useRef)("");
6990
+ const [key, setKey] = (0, import_react50.useState)(""), restoreSignature = JSON.stringify([storageNamespace, pills]);
6991
+ const mounted = (0, import_react50.useRef)("");
6875
6992
  const save = (key2) => {
6876
6993
  var _a;
6877
6994
  try {
@@ -6879,7 +6996,7 @@ function useMarketCardsModel(props, persistence) {
6879
6996
  } catch (e) {
6880
6997
  }
6881
6998
  };
6882
- (0, import_react49.useEffect)(() => {
6999
+ (0, import_react50.useEffect)(() => {
6883
7000
  var _a, _b;
6884
7001
  if (mounted.current === restoreSignature) return;
6885
7002
  mounted.current = restoreSignature;
@@ -7214,7 +7331,7 @@ function watchTrailingOverflow(element, onChange) {
7214
7331
  }
7215
7332
 
7216
7333
  // packages/react/src/market-table.tsx
7217
- var import_react50 = require("react");
7334
+ var import_react51 = require("react");
7218
7335
  var import_jsx_runtime42 = require("react/jsx-runtime");
7219
7336
  function KjunMarketTable(props) {
7220
7337
  const m = useKjunMessages();
@@ -7236,8 +7353,8 @@ function KjunMarketTable(props) {
7236
7353
  formatMetric,
7237
7354
  renderCell
7238
7355
  } = props;
7239
- const scroller = (0, import_react50.useRef)(null), [fadeEnd, setFadeEnd] = (0, import_react50.useState)(false);
7240
- (0, import_react50.useEffect)(() => scroller.current ? watchTrailingOverflow(scroller.current, setFadeEnd) : void 0, [rows, columns]);
7356
+ const scroller = (0, import_react51.useRef)(null), [fadeEnd, setFadeEnd] = (0, import_react51.useState)(false);
7357
+ (0, import_react51.useEffect)(() => scroller.current ? watchTrailingOverflow(scroller.current, setFadeEnd) : void 0, [rows, columns]);
7241
7358
  const render = (row, col) => {
7242
7359
  const value = getValue(row, col.key), stale = !!getValue(row, "stale");
7243
7360
  if (cellLoading(row, col))
@@ -7427,36 +7544,52 @@ function KjunMarketTable(props) {
7427
7544
 
7428
7545
  // packages/react/src/list.tsx
7429
7546
  var import_tokens45 = require("@kjun-ui/tokens");
7430
- var import_react51 = require("react");
7547
+ var import_react52 = require("react");
7431
7548
  var import_jsx_runtime43 = require("react/jsx-runtime");
7432
- function KjunListRow({ title, description, leading, trailing, actions, href, disabled = false, destructive = false, chevron = false, onClick }) {
7549
+ function KjunListRow({ title, description, leading, trailing, actions, href, disabled = false, destructive = false, chevron = false, onClick, ariaLabel, children }) {
7550
+ const content = (0, import_react52.useRef)(null), pressable = !!(href || onClick);
7551
+ (0, import_react52.useEffect)(() => {
7552
+ if (pressable) warnNestedControls(content.current, "KJUN ListRow: a pressable row's content contains buttons or links; move them to actions.");
7553
+ }, [pressable]);
7433
7554
  const contents = /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
7434
7555
  leading && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-list-leading", children: leading }),
7435
7556
  /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("span", { className: "kjun-list-body", children: [
7436
7557
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-list-title", children: title }),
7437
- description && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-list-description", children: description })
7558
+ description && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-list-description", children: description }),
7559
+ hasContent(children) && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { ref: content, className: "kjun-list-content", children })
7438
7560
  ] }),
7439
7561
  trailing && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-list-trailing", children: trailing }),
7440
7562
  chevron && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(KjunIcon, { name: "chevron-right", className: "kjun-list-chevron", size: import_tokens45.tokens.iconSizes.default })
7441
7563
  ] });
7442
- const main = href ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("a", { className: "kjun-list-main", href: disabled ? void 0 : href, "aria-disabled": disabled || void 0, onClick: disabled ? (e) => e.preventDefault() : onClick, children: contents }) : onClick ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { className: "kjun-list-main", type: "button", disabled, onClick, children: contents }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "kjun-list-main", children: contents });
7564
+ const main = href ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("a", { className: "kjun-list-main", href: disabled ? void 0 : href, "aria-label": ariaLabel, "aria-disabled": disabled || void 0, onClick: disabled ? (e) => e.preventDefault() : onClick, children: contents }) : onClick ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { className: "kjun-list-main", type: "button", "aria-label": ariaLabel, disabled, onClick, children: contents }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "kjun-list-main", children: contents });
7443
7565
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("li", { className: "kjun-list-row", "data-destructive": destructive || void 0, children: [
7444
7566
  main,
7445
7567
  actions && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "kjun-list-actions", "data-disabled": disabled || void 0, inert: disabled || void 0, children: actions })
7446
7568
  ] });
7447
7569
  }
7448
- function KjunListSection({ title, description, actions, children, ariaLabel, surface = true, divider = true, density = "default" }) {
7449
- const id = "kjun-" + (0, import_react51.useId)();
7450
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "kjun-list-section", "data-surface": surface ? void 0 : "false", "aria-labelledby": title ? id : void 0, "aria-label": title ? void 0 : ariaLabel, children: [
7451
- (title || description || actions) && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "kjun-list-heading", children: [
7452
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
7453
- title && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("h3", { id, children: title }),
7454
- description && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { children: description })
7455
- ] }),
7456
- actions
7457
- ] }),
7458
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("ul", { className: "kjun-list", "aria-label": ariaLabel || title, "data-divider": divider ? void 0 : "false", "data-density": density === "compact" ? "compact" : void 0, children })
7459
- ] });
7570
+ function KjunListSection({ title, description, actions, children, ariaLabel, surface = true, divider = true, density = "default", radius = "none" }) {
7571
+ const id = "kjun-" + (0, import_react52.useId)();
7572
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
7573
+ "section",
7574
+ {
7575
+ className: "kjun-list-section",
7576
+ "data-surface": surface ? void 0 : "false",
7577
+ "data-radius": radius === "none" ? void 0 : radius,
7578
+ style: radius === "none" ? void 0 : { borderRadius: `var(--_kjun-geometry-card-radii-${radius})` },
7579
+ "aria-labelledby": title ? id : void 0,
7580
+ "aria-label": title ? void 0 : ariaLabel,
7581
+ children: [
7582
+ (title || description || actions) && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "kjun-list-heading", children: [
7583
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
7584
+ title && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("h3", { id, children: title }),
7585
+ description && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { children: description })
7586
+ ] }),
7587
+ actions
7588
+ ] }),
7589
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("ul", { className: "kjun-list", "aria-label": ariaLabel || title, "data-divider": divider ? void 0 : "false", "data-density": density === "compact" ? "compact" : void 0, children })
7590
+ ]
7591
+ }
7592
+ );
7460
7593
  }
7461
7594
  function KjunListItem({ children }) {
7462
7595
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("li", { className: "kjun-list-item", children });
@@ -7506,14 +7639,14 @@ function KjunBottomActionBar({ description, children, safeAreaBottom = 0, keyboa
7506
7639
  }
7507
7640
 
7508
7641
  // packages/react/src/media.tsx
7509
- var import_react52 = require("react");
7642
+ var import_react53 = require("react");
7510
7643
  var import_tokens47 = require("@kjun-ui/tokens");
7511
7644
  var import_jsx_runtime45 = require("react/jsx-runtime");
7512
7645
  function KjunImage({ src, alt, decorative = false, aspectRatio = 1, fit = "cover", fallback: fallback2, lazy = true, onLoad, onError }) {
7513
- const current = (0, import_react52.useRef)({ src, version: 0 });
7646
+ const current = (0, import_react53.useRef)({ src, version: 0 });
7514
7647
  if (current.current.src !== src) current.current = { src, version: current.current.version + 1 };
7515
7648
  const version = current.current.version;
7516
- const [result, setResult] = (0, import_react52.useState)({ version, state: "loading" });
7649
+ const [result, setResult] = (0, import_react53.useState)({ version, state: "loading" });
7517
7650
  const state = result.version === version ? result.state : "loading";
7518
7651
  const failed = !src || state === "error";
7519
7652
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "kjun-image", style: { aspectRatio: aspectRatio > 0 ? aspectRatio : 1 }, "data-state": failed ? "error" : state, children: [
@@ -7565,7 +7698,7 @@ function KjunFab({ icon, ariaLabel, disabled = false, safeAreaBottom = 0, offset
7565
7698
  }
7566
7699
 
7567
7700
  // packages/react/src/range-input.tsx
7568
- var import_react53 = require("react");
7701
+ var import_react54 = require("react");
7569
7702
  var import_react_aria_components10 = require("react-aria-components");
7570
7703
  var import_tokens50 = require("@kjun-ui/tokens");
7571
7704
  var import_jsx_runtime48 = require("react/jsx-runtime");
@@ -7575,10 +7708,10 @@ function RangeInput({ value, min = 0, max = 100, step = 1, disabled = false, lab
7575
7708
  const domain = (0, import_tokens50.createSliderDomain)(min, max, step);
7576
7709
  const list = Array.isArray(value) ? value : [value];
7577
7710
  const valid = domain.valid && (!Array.isArray(value) || value.length === 2) && list.every((v) => domain.accepts(v)) && (list.length === 1 || list[0] <= list[1]);
7578
- const latest = (0, import_react53.useRef)(value);
7711
+ const latest = (0, import_react54.useRef)(value);
7579
7712
  latest.current = value;
7580
- const active = (0, import_react53.useRef)(false);
7581
- (0, import_react53.useEffect)(() => {
7713
+ const active = (0, import_react54.useRef)(false);
7714
+ (0, import_react54.useEffect)(() => {
7582
7715
  if (!valid) console.warn("KJUN Slider: \uBC94\uC704\xB7step\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
7583
7716
  }, [valid]);
7584
7717
  const change = (next) => {
@@ -7615,7 +7748,7 @@ function KjunRangeSlider(props) {
7615
7748
  }
7616
7749
 
7617
7750
  // packages/react/src/quantity-stepper.tsx
7618
- var import_react54 = require("react");
7751
+ var import_react55 = require("react");
7619
7752
  var import_tokens51 = require("@kjun-ui/tokens");
7620
7753
  var import_jsx_runtime49 = require("react/jsx-runtime");
7621
7754
  function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, disabled = false, error = false, size = "md", block = false, id, ariaLabel, onValueChange, onChangeCommit, onInvalidInput }) {
@@ -7624,15 +7757,15 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
7624
7757
  const buttonStyle = { width: import_tokens51.tokens.input[size].height, padding: 0 };
7625
7758
  const domain = (0, import_tokens51.createNumberDomain)({ min, max, step, precision });
7626
7759
  const valid = domain.valid && domain.accepts(value), blocked = disabled || !valid;
7627
- const [draft, setDraft] = (0, import_react54.useState)(String(value));
7760
+ const [draft, setDraft] = (0, import_react55.useState)(String(value));
7628
7761
  const field = useKjunField();
7629
- const composing = (0, import_react54.useRef)(false), dirty = (0, import_react54.useRef)(false), accepted = (0, import_react54.useRef)(value);
7630
- (0, import_react54.useEffect)(() => {
7762
+ const composing = (0, import_react55.useRef)(false), dirty = (0, import_react55.useRef)(false), accepted = (0, import_react55.useRef)(value);
7763
+ (0, import_react55.useEffect)(() => {
7631
7764
  setDraft(String(value));
7632
7765
  accepted.current = value;
7633
7766
  dirty.current = false;
7634
7767
  }, [value, precision, min, max, step]);
7635
- (0, import_react54.useEffect)(() => {
7768
+ (0, import_react55.useEffect)(() => {
7636
7769
  if (!valid) console.warn("KJUN QuantityStepper: \uBC94\uC704\xB7step\xB7\uC815\uBC00\uB3C4\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
7637
7770
  }, [valid]);
7638
7771
  const emit = (next) => {
@@ -7707,18 +7840,18 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
7707
7840
  }
7708
7841
 
7709
7842
  // packages/react/src/time-picker.tsx
7710
- var import_react55 = require("react");
7843
+ var import_react56 = require("react");
7711
7844
  var import_tokens52 = require("@kjun-ui/tokens");
7712
7845
  var import_jsx_runtime50 = require("react/jsx-runtime");
7713
7846
  function KjunTimePicker({ value, precision = "minute", min, max, minuteStep = 1, secondStep = 1, disabled = false, error = false, clearable = true, size = "md", ariaLabel, onValueChange, onChangeCommit }) {
7714
7847
  const m = useKjunMessages();
7715
7848
  ariaLabel != null ? ariaLabel : ariaLabel = m.time;
7716
- const root = (0, import_react55.useRef)(null);
7717
- const field = useKjunField(), uid = (0, import_react55.useId)();
7849
+ const root = (0, import_react56.useRef)(null);
7850
+ const field = useKjunField(), uid = (0, import_react56.useId)();
7718
7851
  const fieldId = (field == null ? void 0 : field.id) || `kjun-time-${uid}`;
7719
- const domain = (0, import_react55.useMemo)(() => (0, import_tokens52.createTimeDomain)({ precision, min, max, minuteStep, secondStep }), [precision, min, max, minuteStep, secondStep]);
7852
+ const domain = (0, import_react56.useMemo)(() => (0, import_tokens52.createTimeDomain)({ precision, min, max, minuteStep, secondStep }), [precision, min, max, minuteStep, secondStep]);
7720
7853
  const valid = domain.valid && domain.accepts(value);
7721
- (0, import_react55.useEffect)(() => {
7854
+ (0, import_react56.useEffect)(() => {
7722
7855
  if (!valid) console.warn("KJUN TimePicker: \uC2DC\uAC01 \uBC94\uC704\xB7\uAC04\uACA9\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
7723
7856
  }, [valid]);
7724
7857
  const change = (next) => {
@@ -7732,7 +7865,7 @@ function KjunTimePicker({ value, precision = "minute", min, max, minuteStep = 1,
7732
7865
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(CompoundControlContext.Provider, { value: size, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "kjun-time-segments", children: [m.hour, m.minute, m.second].slice(0, precision === "second" ? 3 : 2).map((label, index) => {
7733
7866
  const segmentId = index === 0 ? fieldId : `${fieldId}-${index}`;
7734
7867
  const labelId = `${fieldId}-segment-${index}`;
7735
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_react55.Fragment, { children: [
7868
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_react56.Fragment, { children: [
7736
7869
  index > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "kjun-time-separator", "aria-hidden": true, children: ":" }),
7737
7870
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(FieldContext.Provider, { value: { ...field, id: segmentId, labelId: (field == null ? void 0 : field.labelId) ? `${field.labelId} ${labelId}` : void 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "kjun-time-segment", children: [
7738
7871
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { id: labelId, className: "kjun-sr-only", "aria-hidden": true, children: label }),