@kjun-ui/react 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1258,13 +1258,32 @@ var KjunInput = forwardRef2(
1258
1258
  }
1259
1259
  );
1260
1260
 
1261
+ // shared/package-runtime/use-after-close.ts
1262
+ import { useCallback, useEffect as useEffect3, useRef as useRef5 } from "react";
1263
+ function useAfterCloseRef(open, onAfterClose) {
1264
+ const state = useRef5({ open, mounted: false, callback: onAfterClose });
1265
+ state.current.open = open;
1266
+ state.current.callback = onAfterClose;
1267
+ return useCallback((node) => {
1268
+ const current = state.current;
1269
+ if (node) current.mounted = true;
1270
+ else if (current.mounted) {
1271
+ current.mounted = false;
1272
+ queueMicrotask(() => {
1273
+ var _a;
1274
+ if (!current.open && !current.mounted) (_a = current.callback) == null ? void 0 : _a.call(current);
1275
+ });
1276
+ }
1277
+ }, []);
1278
+ }
1279
+
1261
1280
  // shared/package-runtime/use-presence.ts
1262
1281
  import { tokens as tokens5 } from "@kjun-ui/tokens";
1263
- import { useLayoutEffect as useLayoutEffect4, useRef as useRef5, useState as useState5 } from "react";
1282
+ import { useLayoutEffect as useLayoutEffect4, useRef as useRef6, useState as useState5 } from "react";
1264
1283
  function usePresence(open, reduced, exitDuration = tokens5.motion.layerExit) {
1265
1284
  const [retained, setRetained] = useState5(open);
1266
1285
  const [active, setActive] = useState5(false);
1267
- const mounted = useRef5(false);
1286
+ const mounted = useRef6(false);
1268
1287
  useLayoutEffect4(() => {
1269
1288
  let first = 0, second = 0, timer;
1270
1289
  if (open) {
@@ -1306,7 +1325,7 @@ function useReducedMotion() {
1306
1325
 
1307
1326
  // packages/react/src/modal.tsx
1308
1327
  import { tokens as tokens6 } from "@kjun-ui/tokens";
1309
- import { useId as useId4, useLayoutEffect as useLayoutEffect6, useRef as useRef6 } from "react";
1328
+ import { useId as useId4, useLayoutEffect as useLayoutEffect6, useRef as useRef7 } from "react";
1310
1329
 
1311
1330
  // shared/package-runtime/form-actions.ts
1312
1331
  function formActionsNeedStack(width, widths, gap) {
@@ -1397,7 +1416,7 @@ function KjunFormActions({
1397
1416
  const m = useKjunMessages();
1398
1417
  cancelText != null ? cancelText : cancelText = m.cancel;
1399
1418
  confirmText != null ? confirmText : confirmText = m.save;
1400
- const ref = useRef6(null);
1419
+ const ref = useRef7(null);
1401
1420
  useLayoutEffect6(() => observeFormActions(ref.current), []);
1402
1421
  return /* @__PURE__ */ jsxs4("div", { className: "kjun-form-actions", ref, children: [
1403
1422
  showCancel && /* @__PURE__ */ jsx7(
@@ -1427,6 +1446,7 @@ function KjunModal({
1427
1446
  open,
1428
1447
  onOpenChange,
1429
1448
  onClose,
1449
+ onAfterClose,
1430
1450
  onCancel,
1431
1451
  onConfirm,
1432
1452
  title = "",
@@ -1455,6 +1475,7 @@ function KjunModal({
1455
1475
  confirmText != null ? confirmText : confirmText = m.confirm;
1456
1476
  cancelText != null ? cancelText : cancelText = m.cancel;
1457
1477
  const motion = usePresence(open, useReducedMotion());
1478
+ const afterCloseRef = useAfterCloseRef(open, onAfterClose);
1458
1479
  const portalContainer = useKjunPortalContainer();
1459
1480
  const id = "kjun-" + useId4();
1460
1481
  const explicitLabel = ariaLabel == null ? void 0 : ariaLabel.trim();
@@ -1472,6 +1493,7 @@ function KjunModal({
1472
1493
  return /* @__PURE__ */ jsx7(LayerScope.Provider, { value: layer.id, children: /* @__PURE__ */ jsx7(
1473
1494
  ModalOverlay,
1474
1495
  {
1496
+ ref: afterCloseRef,
1475
1497
  style: { zIndex: layer.zIndex },
1476
1498
  isOpen: motion.present && layer.active,
1477
1499
  isExiting: motion.present && !layer.active,
@@ -1601,9 +1623,7 @@ import {
1601
1623
  useState as useState6
1602
1624
  } from "react";
1603
1625
 
1604
- // packages/react/src/card.tsx
1605
- import { useEffect as useEffect3, useRef as useRef7 } from "react";
1606
- import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1626
+ // shared/package-runtime/nested-controls.ts
1607
1627
  var interactive = 'button, a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
1608
1628
  function developmentMode3() {
1609
1629
  try {
@@ -1612,6 +1632,13 @@ function developmentMode3() {
1612
1632
  return false;
1613
1633
  }
1614
1634
  }
1635
+ function warnNestedControls(root, message) {
1636
+ if (developmentMode3() && (root == null ? void 0 : root.querySelector(interactive))) console.warn(message);
1637
+ }
1638
+
1639
+ // packages/react/src/card.tsx
1640
+ import { useEffect as useEffect4, useRef as useRef8 } from "react";
1641
+ import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1615
1642
  function KjunCard({
1616
1643
  title,
1617
1644
  subtitle,
@@ -1636,11 +1663,9 @@ function KjunCard({
1636
1663
  onKeyDown,
1637
1664
  ...props
1638
1665
  }) {
1639
- const root = useRef7(null);
1640
- useEffect3(() => {
1641
- var _a;
1642
- if (pressable && developmentMode3() && ((_a = root.current) == null ? void 0 : _a.querySelector(interactive)))
1643
- console.warn("KJUN Card: a pressable card contains buttons or links; move them out or drop pressable.");
1666
+ const root = useRef8(null);
1667
+ useEffect4(() => {
1668
+ if (pressable) warnNestedControls(root.current, "KJUN Card: a pressable card contains buttons or links; move them out or drop pressable.");
1644
1669
  }, [pressable]);
1645
1670
  const press = pressable ? {
1646
1671
  role: "button",
@@ -2078,13 +2103,13 @@ function KjunInline({ gap = "sm", align = "center", justify = "start", wrap = tr
2078
2103
  }
2079
2104
 
2080
2105
  // shared/package-runtime/feedback-dialog.ts
2081
- import { useRef as useRef8, useState as useState7 } from "react";
2106
+ import { useRef as useRef9, useState as useState7 } from "react";
2082
2107
  function useFeedbackDialog(controller, request, messages = kjunMessagesKo) {
2083
2108
  const options = request.options;
2084
2109
  const [value, setValue] = useState7(options.initialValue || "");
2085
2110
  const [error, setError] = useState7("");
2086
2111
  const [busy, setBusy] = useState7(false);
2087
- const working = useRef8(false);
2112
+ const working = useRef9(false);
2088
2113
  const active = () => {
2089
2114
  var _a;
2090
2115
  return ((_a = controller.getSnapshot().current) == null ? void 0 : _a.id) === request.id;
@@ -2127,10 +2152,10 @@ function useFeedbackDialog(controller, request, messages = kjunMessagesKo) {
2127
2152
 
2128
2153
  // shared/package-runtime/feedback-motion.ts
2129
2154
  import { tokens as tokens9 } from "@kjun-ui/tokens";
2130
- import { useLayoutEffect as useLayoutEffect7, useRef as useRef9, useState as useState8 } from "react";
2155
+ import { useLayoutEffect as useLayoutEffect7, useRef as useRef10, useState as useState8 } from "react";
2131
2156
  function usePresentedToasts(toasts, reduced) {
2132
2157
  const [items, setItems] = useState8([]);
2133
- const removals = useRef9(/* @__PURE__ */ new Map());
2158
+ const removals = useRef10(/* @__PURE__ */ new Map());
2134
2159
  useLayoutEffect7(() => {
2135
2160
  const ids = new Set(toasts.map((toast) => toast.id));
2136
2161
  setItems((previous) => {
@@ -2181,7 +2206,7 @@ function useOptionalKjunFeedback() {
2181
2206
 
2182
2207
  // packages/react/src/toast-stack.tsx
2183
2208
  import { tokens as tokens11 } from "@kjun-ui/tokens";
2184
- import { useLayoutEffect as useLayoutEffect8, useRef as useRef11 } from "react";
2209
+ import { useLayoutEffect as useLayoutEffect8, useRef as useRef12 } from "react";
2185
2210
 
2186
2211
  // shared/package-runtime/toast-layout.ts
2187
2212
  import { tokens as tokens10 } from "@kjun-ui/tokens";
@@ -2243,16 +2268,16 @@ function createToastLayout() {
2243
2268
  }
2244
2269
 
2245
2270
  // packages/react/src/toast.tsx
2246
- import { useEffect as useEffect4, useRef as useRef10 } from "react";
2271
+ import { useEffect as useEffect5, useRef as useRef11 } from "react";
2247
2272
  import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
2248
2273
  function ToastView({
2249
2274
  toast,
2250
2275
  controller
2251
2276
  }) {
2252
2277
  const m = useKjunMessages();
2253
- const previous = useRef10(null);
2254
- const reasons = useRef10({ hover: /* @__PURE__ */ Symbol("hover"), focus: /* @__PURE__ */ Symbol("focus") }).current;
2255
- useEffect4(() => {
2278
+ const previous = useRef11(null);
2279
+ const reasons = useRef11({ hover: /* @__PURE__ */ Symbol("hover"), focus: /* @__PURE__ */ Symbol("focus") }).current;
2280
+ useEffect5(() => {
2256
2281
  previous.current = document.activeElement;
2257
2282
  return () => {
2258
2283
  controller.resumeToast(toast.id, reasons.hover);
@@ -2347,9 +2372,9 @@ function ToastView({
2347
2372
  // packages/react/src/toast-stack.tsx
2348
2373
  import { jsx as jsx12 } from "react/jsx-runtime";
2349
2374
  function ToastSurface({ item, controller }) {
2350
- const ref = useRef11(null), reduced = useReducedMotion();
2351
- const current = useRef11(null);
2352
- const entryFinished = useRef11(false);
2375
+ const ref = useRef12(null), reduced = useReducedMotion();
2376
+ const current = useRef12(null);
2377
+ const entryFinished = useRef12(false);
2353
2378
  useLayoutEffect8(() => {
2354
2379
  var _a, _b;
2355
2380
  const el = ref.current;
@@ -2384,7 +2409,7 @@ function ToastSurface({ item, controller }) {
2384
2409
  function ToastStack({ items, controller }) {
2385
2410
  var _a;
2386
2411
  const layers = useLayerState();
2387
- const root = useRef11(null), layout = useRef11(createToastLayout());
2412
+ const root = useRef12(null), layout = useRef12(createToastLayout());
2388
2413
  const reduced = useReducedMotion();
2389
2414
  useLayoutEffect8(() => {
2390
2415
  if (root.current) layout.current.update(root.current, reduced);
@@ -2408,9 +2433,9 @@ import {
2408
2433
  feedbackControllerOf
2409
2434
  } from "@kjun-ui/tokens";
2410
2435
  import {
2411
- useCallback,
2412
- useEffect as useEffect5,
2413
- useRef as useRef12,
2436
+ useCallback as useCallback2,
2437
+ useEffect as useEffect6,
2438
+ useRef as useRef13,
2414
2439
  useState as useState9,
2415
2440
  useSyncExternalStore as useSyncExternalStore3
2416
2441
  } from "react";
@@ -2467,8 +2492,8 @@ function KjunFeedbackProvider({ children, controller: controllerProp }) {
2467
2492
  var _a;
2468
2493
  const [owned] = useState9(() => controllerProp ? void 0 : createFeedbackController());
2469
2494
  const controller = controllerProp ? feedbackControllerOf(controllerProp) : owned;
2470
- useEffect5(() => controller.attach(), [controller]);
2471
- const life = useRef12(0);
2495
+ useEffect6(() => controller.attach(), [controller]);
2496
+ const life = useRef13(0);
2472
2497
  const snapshot = useSyncExternalStore3(
2473
2498
  controller.subscribe,
2474
2499
  controller.getSnapshot,
@@ -2477,7 +2502,7 @@ function KjunFeedbackProvider({ children, controller: controllerProp }) {
2477
2502
  const reduced = useReducedMotion();
2478
2503
  const toasts = usePresentedToasts(snapshot.toasts, reduced);
2479
2504
  const dialog = usePresentedRequest(snapshot.current, reduced);
2480
- useEffect5(() => {
2505
+ useEffect6(() => {
2481
2506
  const version = ++life.current;
2482
2507
  return () => {
2483
2508
  queueMicrotask(() => {
@@ -2486,7 +2511,7 @@ function KjunFeedbackProvider({ children, controller: controllerProp }) {
2486
2511
  };
2487
2512
  }, [controller]);
2488
2513
  const [layers, setLayers] = useState9([]);
2489
- const register = useCallback((id, order) => {
2514
+ const register = useCallback2((id, order) => {
2490
2515
  setLayers((current) => [...current, { id, order }]);
2491
2516
  return () => setLayers((current) => current.filter((value) => value.id !== id));
2492
2517
  }, []);
@@ -2518,7 +2543,7 @@ import { tokens as tokens13 } from "@kjun-ui/tokens";
2518
2543
  import {
2519
2544
  createContext as createContext10,
2520
2545
  forwardRef as forwardRef3,
2521
- useCallback as useCallback2,
2546
+ useCallback as useCallback3,
2522
2547
  useContext as useContext10,
2523
2548
  useId as useId5
2524
2549
  } from "react";
@@ -2528,7 +2553,7 @@ import {
2528
2553
  } from "react-aria-components";
2529
2554
 
2530
2555
  // packages/react/src/use-selection-indicator.ts
2531
- import { useLayoutEffect as useLayoutEffect9, useRef as useRef13 } from "react";
2556
+ import { useLayoutEffect as useLayoutEffect9, useRef as useRef14 } from "react";
2532
2557
 
2533
2558
  // shared/package-runtime/selection-indicator.ts
2534
2559
  import { tokens as tokens12 } from "@kjun-ui/tokens";
@@ -2600,9 +2625,9 @@ function selectionIndicator(root, marker, tabs = false) {
2600
2625
 
2601
2626
  // packages/react/src/use-selection-indicator.ts
2602
2627
  function useSelectionIndicator(tabs = false) {
2603
- const group = useRef13(null);
2604
- const indicator = useRef13(null);
2605
- const sync = useRef13(() => {
2628
+ const group = useRef14(null);
2629
+ const indicator = useRef14(null);
2630
+ const sync = useRef14(() => {
2606
2631
  });
2607
2632
  useLayoutEffect9(() => {
2608
2633
  const root = group.current, marker = indicator.current;
@@ -2691,7 +2716,7 @@ function KjunSwitch({
2691
2716
  const field = useKjunField();
2692
2717
  const descriptionId = "kjun-" + useId5().replace(/:/g, "") + "-description";
2693
2718
  const invalid = !!(field == null ? void 0 : field.error), required = !!(field == null ? void 0 : field.required);
2694
- const markInput = useCallback2((input) => {
2719
+ const markInput = useCallback3((input) => {
2695
2720
  if (!input) return;
2696
2721
  if (invalid) input.setAttribute("aria-invalid", "true");
2697
2722
  else input.removeAttribute("aria-invalid");
@@ -2990,7 +3015,7 @@ function KjunFilterGroup({
2990
3015
 
2991
3016
  // packages/react/src/floating-panel.tsx
2992
3017
  import { isComposingKey as isComposingKey3, tokens as tokens14 } from "@kjun-ui/tokens";
2993
- import { useEffect as useEffect6, useRef as useRef14 } from "react";
3018
+ import { useEffect as useEffect7, useRef as useRef15 } from "react";
2994
3019
  import { Popover as AriaPopover } from "react-aria-components";
2995
3020
  import { jsx as jsx15 } from "react/jsx-runtime";
2996
3021
  function FloatingPanel({
@@ -3011,8 +3036,8 @@ function FloatingPanel({
3011
3036
  const motion = usePresence(open, useReducedMotion(), tokens14.motion.popupExit);
3012
3037
  const layer = useLayer(open, motion.present, "popup", () => onOpenChange(false), triggerRef, returnFocus);
3013
3038
  const container = useKjunPortalContainer();
3014
- const panel = useRef14(null);
3015
- useEffect6(() => {
3039
+ const panel = useRef15(null);
3040
+ useEffect7(() => {
3016
3041
  var _a;
3017
3042
  const document2 = (_a = triggerRef.current) == null ? void 0 : _a.ownerDocument;
3018
3043
  if (!open || nonModal || !document2 || layer.keyboardManaged) return;
@@ -3059,10 +3084,11 @@ function FloatingPanel({
3059
3084
  }
3060
3085
  ) });
3061
3086
  }
3087
+ var resolveFocusReturn = (target) => target === void 0 ? void 0 : () => typeof target === "function" ? target() : target instanceof HTMLElement ? target : target.current;
3062
3088
 
3063
3089
  // packages/react/src/popover.tsx
3064
3090
  import { tokens as tokens15 } from "@kjun-ui/tokens";
3065
- import { useCallback as useCallback3, useEffect as useEffect7, useId as useId6, useRef as useRef15, useState as useState10 } from "react";
3091
+ import { useCallback as useCallback4, useEffect as useEffect8, useId as useId6, useRef as useRef16, useState as useState10 } from "react";
3066
3092
  import { Dialog as Dialog2, Focusable, OverlayArrow, Tooltip, TooltipTrigger } from "react-aria-components";
3067
3093
 
3068
3094
  // shared/package-runtime/popover-nonmodal.ts
@@ -3144,20 +3170,20 @@ function KjunPopover({
3144
3170
  children
3145
3171
  }) {
3146
3172
  const m = useKjunMessages();
3147
- const [internal, setInternal] = useState10(false), open = controlled != null ? controlled : internal, ref = useRef15(null), id = "kjun-" + useId6();
3173
+ const [internal, setInternal] = useState10(false), open = controlled != null ? controlled : internal, ref = useRef16(null), id = "kjun-" + useId6();
3148
3174
  const expanded = usePopupExpanded(open, ref);
3149
- const focusOnMount = useRef15(focusOnOpen);
3175
+ const focusOnMount = useRef16(focusOnOpen);
3150
3176
  focusOnMount.current = focusOnOpen;
3151
- const focusContent = useCallback3((node) => {
3177
+ const focusContent = useCallback4((node) => {
3152
3178
  if (node && focusOnMount.current) node.focus();
3153
3179
  }, []);
3154
- const resolveReturn = returnFocus === void 0 ? void 0 : () => typeof returnFocus === "function" ? returnFocus() : returnFocus instanceof HTMLElement ? returnFocus : returnFocus.current;
3180
+ const resolveReturn = resolveFocusReturn(returnFocus);
3155
3181
  const change = (v) => {
3156
3182
  setInternal(v);
3157
3183
  onOpenChange == null ? void 0 : onOpenChange(v);
3158
3184
  };
3159
- const skipReturn = useRef15(false);
3160
- useEffect7(() => {
3185
+ const skipReturn = useRef16(false);
3186
+ useEffect8(() => {
3161
3187
  if (!open || modal) return;
3162
3188
  skipReturn.current = false;
3163
3189
  return installNonModalPopover({
@@ -3263,7 +3289,7 @@ function KjunTooltip({
3263
3289
 
3264
3290
  // packages/react/src/dropdown.tsx
3265
3291
  import { tokens as tokens16 } from "@kjun-ui/tokens";
3266
- import { cloneElement, createContext as createContext11, isValidElement as isValidElement2, useCallback as useCallback4, useContext as useContext11, useEffect as useEffect8, useId as useId7, useRef as useRef16, useState as useState11 } from "react";
3292
+ import { cloneElement, createContext as createContext11, isValidElement as isValidElement2, useCallback as useCallback5, useContext as useContext11, useEffect as useEffect9, useId as useId7, useRef as useRef17, useState as useState11 } from "react";
3267
3293
  import { Menu, MenuItem, Separator } from "react-aria-components";
3268
3294
  import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
3269
3295
  var DropdownContext = createContext11(null);
@@ -3276,12 +3302,13 @@ function KjunDropdown({
3276
3302
  trigger,
3277
3303
  children,
3278
3304
  onOpen,
3279
- onClose
3305
+ onClose,
3306
+ returnFocus
3280
3307
  }) {
3281
- const [open, setOpen] = useState11(false), currentOpen = useRef16(false), ref = useRef16(null), id = "kjun-" + useId7();
3282
- const menuFocusCleanup = useRef16(() => {
3308
+ const [open, setOpen] = useState11(false), currentOpen = useRef17(false), ref = useRef17(null), id = "kjun-" + useId7();
3309
+ const menuFocusCleanup = useRef17(() => {
3283
3310
  });
3284
- const bindMenu = useCallback4((menu) => {
3311
+ const bindMenu = useCallback5((menu) => {
3285
3312
  menuFocusCleanup.current();
3286
3313
  menuFocusCleanup.current = () => {
3287
3314
  };
@@ -3332,7 +3359,7 @@ function KjunDropdown({
3332
3359
  if (value) onOpen == null ? void 0 : onOpen();
3333
3360
  else onClose == null ? void 0 : onClose();
3334
3361
  };
3335
- useEffect8(() => {
3362
+ useEffect9(() => {
3336
3363
  if (unavailable) change(false);
3337
3364
  }, [unavailable]);
3338
3365
  return /* @__PURE__ */ jsxs11(DropdownContext.Provider, { value: () => change(false), children: [
@@ -3356,6 +3383,7 @@ function KjunDropdown({
3356
3383
  {
3357
3384
  open,
3358
3385
  onOpenChange: change,
3386
+ returnFocus: resolveFocusReturn(returnFocus),
3359
3387
  triggerRef: ref,
3360
3388
  placement,
3361
3389
  className: "kjun-dropdown",
@@ -3386,7 +3414,7 @@ function KjunDropdownItem({
3386
3414
  onClick
3387
3415
  }) {
3388
3416
  const close = useContext11(DropdownContext);
3389
- const node = useCallback4((element) => {
3417
+ const node = useCallback5((element) => {
3390
3418
  if (!element) return;
3391
3419
  if (selected === null) {
3392
3420
  element.setAttribute("role", "menuitem");
@@ -3513,6 +3541,7 @@ function KjunDrawer({
3513
3541
  footer,
3514
3542
  children,
3515
3543
  onClose,
3544
+ onAfterClose,
3516
3545
  ariaLabel,
3517
3546
  safeAreaTop = 0,
3518
3547
  safeAreaBottom = 0,
@@ -3520,6 +3549,7 @@ function KjunDrawer({
3520
3549
  }) {
3521
3550
  const m = useKjunMessages();
3522
3551
  const motion = usePresence(open, useReducedMotion(), tokens17.motion.layerExit);
3552
+ const afterCloseRef = useAfterCloseRef(open, onAfterClose);
3523
3553
  const container = useKjunPortalContainer();
3524
3554
  const close = () => {
3525
3555
  if (!open) return;
@@ -3533,6 +3563,7 @@ function KjunDrawer({
3533
3563
  return /* @__PURE__ */ jsx18(LayerScope.Provider, { value: layer.id, children: /* @__PURE__ */ jsx18(
3534
3564
  ModalOverlay2,
3535
3565
  {
3566
+ ref: afterCloseRef,
3536
3567
  style: { zIndex: layer.zIndex, ...drawerOverlayVars({ safeAreaTop, safeAreaBottom, maxHeight }) },
3537
3568
  isOpen: motion.present && layer.active,
3538
3569
  isExiting: motion.present && !layer.active,
@@ -3599,7 +3630,7 @@ function KjunDrawer({
3599
3630
  }
3600
3631
 
3601
3632
  // shared/package-runtime/combobox.ts
3602
- import { useEffect as useEffect9, useState as useState12 } from "react";
3633
+ import { useEffect as useEffect10, useState as useState12 } from "react";
3603
3634
 
3604
3635
  // shared/package-runtime/options.ts
3605
3636
  var optionValue = (option, key = "value") => typeof option === "object" ? option[key] : option;
@@ -3679,8 +3710,8 @@ function useComboboxModel({
3679
3710
  const selectedLabel = selected !== void 0 ? optionLabel(selected, labelKey) : "";
3680
3711
  const [query2, setQuery] = useState12(selectedLabel);
3681
3712
  const [open, setOpen] = useState12(false);
3682
- useEffect9(() => setQuery(selectedLabel), [value, selectedLabel]);
3683
- useEffect9(() => {
3713
+ useEffect10(() => setQuery(selectedLabel), [value, selectedLabel]);
3714
+ useEffect10(() => {
3684
3715
  if (disabled) setOpen(false);
3685
3716
  }, [disabled]);
3686
3717
  const change = (next) => {
@@ -3714,9 +3745,9 @@ function useComboboxModel({
3714
3745
 
3715
3746
  // packages/react/src/combobox.tsx
3716
3747
  import {
3717
- useEffect as useEffect10,
3748
+ useEffect as useEffect11,
3718
3749
  useId as useId8,
3719
- useRef as useRef17,
3750
+ useRef as useRef18,
3720
3751
  useState as useState13
3721
3752
  } from "react";
3722
3753
  import { Fragment as Fragment5, jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
@@ -3737,7 +3768,8 @@ function KjunCombobox({
3737
3768
  onValueChange,
3738
3769
  onChange,
3739
3770
  onSearch,
3740
- onClear
3771
+ onClear,
3772
+ returnFocus
3741
3773
  }) {
3742
3774
  const m = useKjunMessages();
3743
3775
  placeholder != null ? placeholder : placeholder = m.searchOrSelect;
@@ -3773,7 +3805,8 @@ function KjunCombobox({
3773
3805
  renderOption,
3774
3806
  onValueChange: (v) => model.search(v, true),
3775
3807
  onSelect: model.select,
3776
- onClear: model.clear
3808
+ onClear: model.clear,
3809
+ returnFocus: resolveFocusReturn(returnFocus)
3777
3810
  }
3778
3811
  );
3779
3812
  }
@@ -3798,16 +3831,17 @@ function SearchField({
3798
3831
  onValueChange,
3799
3832
  onSelect,
3800
3833
  onClear,
3801
- onEnter
3834
+ onEnter,
3835
+ returnFocus
3802
3836
  }) {
3803
3837
  const m = useKjunMessages();
3804
3838
  const composition = useCompositionGuard();
3805
- const clearing = useRef17(false);
3806
- const ref = useRef17(null), [highlighted, setActive] = useState13(-1), id = "kjun-" + useId8();
3839
+ const clearing = useRef18(false);
3840
+ const ref = useRef18(null), [highlighted, setActive] = useState13(-1), id = "kjun-" + useId8();
3807
3841
  const focusGuard = usePopupFocusGuard(ref);
3808
3842
  const active = !disabled && !loading && highlighted >= 0 && highlighted < options.length && !optionDisabled(options[highlighted]) ? highlighted : -1;
3809
- useEffect10(() => setActive(-1), [value, options.length]);
3810
- useEffect10(() => {
3843
+ useEffect11(() => setActive(-1), [value, options.length]);
3844
+ useEffect11(() => {
3811
3845
  if (!open) return;
3812
3846
  const leaveField = (event) => {
3813
3847
  var _a, _b, _c;
@@ -3817,16 +3851,16 @@ function SearchField({
3817
3851
  document.addEventListener("focusin", leaveField);
3818
3852
  return () => document.removeEventListener("focusin", leaveField);
3819
3853
  }, [open, onOpenChange, id]);
3820
- useEffect10(() => {
3854
+ useEffect11(() => {
3821
3855
  if (highlighted !== active) setActive(-1);
3822
3856
  }, [highlighted, active]);
3823
3857
  const available = options.map((o, i) => optionDisabled(o) ? -1 : i).filter((i) => i >= 0);
3824
3858
  const select = (o) => {
3825
- var _a;
3859
+ var _a, _b;
3826
3860
  if (o === void 0 || disabled || loading || optionDisabled(o)) return;
3827
3861
  onSelect(o);
3828
3862
  onOpenChange(false);
3829
- (_a = ref.current) == null ? void 0 : _a.focus();
3863
+ (_b = (_a = returnFocus == null ? void 0 : returnFocus()) != null ? _a : ref.current) == null ? void 0 : _b.focus();
3830
3864
  };
3831
3865
  return /* @__PURE__ */ jsxs13(Fragment5, { children: [
3832
3866
  /* @__PURE__ */ jsx19(
@@ -3874,7 +3908,7 @@ function SearchField({
3874
3908
  onCompositionStart: composition.onCompositionStart,
3875
3909
  onCompositionEnd: composition.onCompositionEnd,
3876
3910
  onKeyDown: (e) => {
3877
- var _a, _b, _c, _d;
3911
+ var _a, _b, _c, _d, _e;
3878
3912
  if (composition.isComposing(e)) return;
3879
3913
  let next = active;
3880
3914
  if (e.key === "ArrowDown") {
@@ -3897,10 +3931,11 @@ function SearchField({
3897
3931
  e.preventDefault();
3898
3932
  e.stopPropagation();
3899
3933
  onOpenChange(false);
3934
+ (_d = returnFocus == null ? void 0 : returnFocus()) == null ? void 0 : _d.focus();
3900
3935
  }
3901
3936
  setActive(next);
3902
3937
  if (next >= 0)
3903
- (_d = document.getElementById(id + "-" + next)) == null ? void 0 : _d.scrollIntoView({ block: "nearest" });
3938
+ (_e = document.getElementById(id + "-" + next)) == null ? void 0 : _e.scrollIntoView({ block: "nearest" });
3904
3939
  }
3905
3940
  }
3906
3941
  ),
@@ -4041,7 +4076,7 @@ function KjunDatePicker({
4041
4076
  import { useState as useState16 } from "react";
4042
4077
 
4043
4078
  // shared/package-runtime/search-input.ts
4044
- import { useEffect as useEffect11, useLayoutEffect as useLayoutEffect10, useRef as useRef18, useState as useState15 } from "react";
4079
+ import { useEffect as useEffect12, useLayoutEffect as useLayoutEffect10, useRef as useRef19, useState as useState15 } from "react";
4045
4080
  function useSearchInputModel({
4046
4081
  value,
4047
4082
  disabled = false,
@@ -4051,10 +4086,10 @@ function useSearchInputModel({
4051
4086
  onValueChange,
4052
4087
  onSearchError
4053
4088
  }, open) {
4054
- const [query2, setQuery] = useState15(value), [options, setOptions] = useState15([]), [loading, setLoading] = useState15(false), [failed, setFailed] = useState15(false), version = useRef18(0), notify = useRef18(onSearchError);
4089
+ const [query2, setQuery] = useState15(value), [options, setOptions] = useState15([]), [loading, setLoading] = useState15(false), [failed, setFailed] = useState15(false), version = useRef19(0), notify = useRef19(onSearchError);
4055
4090
  notify.current = onSearchError;
4056
- const timer = useRef18(void 0);
4057
- const notifyValue = useRef18(onValueChange);
4091
+ const timer = useRef19(void 0);
4092
+ const notifyValue = useRef19(onValueChange);
4058
4093
  notifyValue.current = onValueChange;
4059
4094
  useLayoutEffect10(() => {
4060
4095
  clearTimeout(timer.current);
@@ -4064,7 +4099,7 @@ function useSearchInputModel({
4064
4099
  clearTimeout(timer.current);
4065
4100
  return () => clearTimeout(timer.current);
4066
4101
  }, [disabled, debounce, !!loadOptions]);
4067
- useEffect11(() => {
4102
+ useEffect12(() => {
4068
4103
  const current = ++version.current, abort = new AbortController();
4069
4104
  setFailed(false);
4070
4105
  if (!loadOptions || !open || disabled || query2.length < minChars) {
@@ -4221,13 +4256,13 @@ import { tokens as tokens19 } from "@kjun-ui/tokens";
4221
4256
  import {
4222
4257
  useId as useId9,
4223
4258
  useContext as useContext12,
4224
- useRef as useRef20,
4225
- useEffect as useEffect13
4259
+ useRef as useRef21,
4260
+ useEffect as useEffect14
4226
4261
  } from "react";
4227
4262
  import { ListBox, ListBoxItem } from "react-aria-components";
4228
4263
 
4229
4264
  // shared/package-runtime/select.ts
4230
- import { useEffect as useEffect12, useRef as useRef19, useState as useState17 } from "react";
4265
+ import { useEffect as useEffect13, useRef as useRef20, useState as useState17 } from "react";
4231
4266
  function useSelectState(controlled, disabled, pageSize, onOpenChange) {
4232
4267
  const [internal, setInternal] = useState17(false);
4233
4268
  const [query2, setQuery] = useState17("");
@@ -4235,8 +4270,8 @@ function useSelectState(controlled, disabled, pageSize, onOpenChange) {
4235
4270
  const [session, setSession] = useState17(0);
4236
4271
  const isControlled = typeof controlled === "boolean";
4237
4272
  const open = !disabled && (isControlled ? controlled : internal);
4238
- const previousOpen = useRef19(open);
4239
- useEffect12(() => {
4273
+ const previousOpen = useRef20(open);
4274
+ useEffect13(() => {
4240
4275
  if (disabled && !isControlled) setInternal(false);
4241
4276
  if (previousOpen.current && !open) {
4242
4277
  setQuery("");
@@ -4245,7 +4280,7 @@ function useSelectState(controlled, disabled, pageSize, onOpenChange) {
4245
4280
  }
4246
4281
  previousOpen.current = open;
4247
4282
  }, [open, disabled, isControlled, pageSize]);
4248
- useEffect12(() => {
4283
+ useEffect13(() => {
4249
4284
  setLimit(pageSize);
4250
4285
  }, [pageSize]);
4251
4286
  const changeOpen = (next) => {
@@ -4294,24 +4329,25 @@ function KjunSelect({
4294
4329
  onSearch,
4295
4330
  onClear,
4296
4331
  filterFn,
4297
- searchKeys
4332
+ searchKeys,
4333
+ returnFocus
4298
4334
  }) {
4299
4335
  const m = useKjunMessages();
4300
4336
  placeholder != null ? placeholder : placeholder = m.select;
4301
4337
  searchPlaceholder != null ? searchPlaceholder : searchPlaceholder = m.search;
4302
4338
  const { open, query: query2, limit, session, changeOpen, search, showMore } = useSelectState(controlled, disabled, optionPageSize, onOpenChange);
4303
4339
  const composition = useCompositionGuard();
4304
- const ref = useRef20(null), menu = useRef20(null), field = useKjunField(), id = "kjun-" + useId9();
4340
+ const ref = useRef21(null), menu = useRef21(null), field = useKjunField(), id = "kjun-" + useId9();
4305
4341
  const segment = useContext12(CompoundControlContext) !== null;
4306
4342
  const spec = tokens19.input[size];
4307
4343
  const expanded = usePopupExpanded(open, ref);
4308
4344
  const registerControl = field == null ? void 0 : field.setControlId;
4309
- useEffect13(() => {
4345
+ useEffect14(() => {
4310
4346
  if (!registerControl || !triggerId) return;
4311
4347
  registerControl(triggerId);
4312
4348
  return () => registerControl(void 0);
4313
4349
  }, [registerControl, triggerId]);
4314
- useEffect13(() => {
4350
+ useEffect14(() => {
4315
4351
  var _a, _b;
4316
4352
  if (open && searchable) (_b = (_a = menu.current) == null ? void 0 : _a.querySelector("input")) == null ? void 0 : _b.focus({ preventScroll: true });
4317
4353
  if (!open) composition.onCompositionEnd();
@@ -4403,6 +4439,7 @@ function KjunSelect({
4403
4439
  {
4404
4440
  field: true,
4405
4441
  open,
4442
+ returnFocus: resolveFocusReturn(returnFocus),
4406
4443
  onOpenChange: changeOpen,
4407
4444
  triggerRef: ref,
4408
4445
  placement: "bottom-start",
@@ -4502,16 +4539,18 @@ import { tokens as tokens21 } from "@kjun-ui/tokens";
4502
4539
 
4503
4540
  // packages/react/src/collapse.tsx
4504
4541
  import { tokens as tokens20 } from "@kjun-ui/tokens";
4505
- import { useLayoutEffect as useLayoutEffect11, useRef as useRef21, useState as useState18 } from "react";
4542
+ import { useLayoutEffect as useLayoutEffect11, useRef as useRef22, useState as useState18 } from "react";
4506
4543
  import { jsx as jsx23 } from "react/jsx-runtime";
4507
- function Collapse({ open, children }) {
4544
+ function Collapse({ open, keepMounted = false, children }) {
4508
4545
  const reduced = useReducedMotion();
4509
4546
  const [retained, setRetained] = useState18(open);
4510
- const root = useRef21(null), body = useRef21(null);
4511
- const animation = useRef21(null);
4512
- const previous = useRef21(open);
4513
- const interrupted = useRef21(null);
4514
- const present = open || retained;
4547
+ const root = useRef22(null), body = useRef22(null);
4548
+ const animation = useRef22(null);
4549
+ const previous = useRef22(open);
4550
+ const interrupted = useRef22(null);
4551
+ const opened = useRef22(open);
4552
+ if (open) opened.current = true;
4553
+ const present = open || retained || keepMounted && opened.current;
4515
4554
  useLayoutEffect11(() => {
4516
4555
  const el = root.current, inner = body.current;
4517
4556
  if (!el || !inner) return;
@@ -4567,10 +4606,10 @@ function Collapse({ open, children }) {
4567
4606
  }
4568
4607
 
4569
4608
  // shared/package-runtime/navigation.ts
4570
- import { useEffect as useEffect14, useRef as useRef22, useState as useState19 } from "react";
4609
+ import { useEffect as useEffect15, useRef as useRef23, useState as useState19 } from "react";
4571
4610
  function useInitialTab(value, candidate, change) {
4572
- const requested = useRef22(/* @__PURE__ */ new Set());
4573
- useEffect14(() => {
4611
+ const requested = useRef23(/* @__PURE__ */ new Set());
4612
+ useEffect15(() => {
4574
4613
  if (value !== "") {
4575
4614
  requested.current.clear();
4576
4615
  return;
@@ -4582,7 +4621,7 @@ function useInitialTab(value, candidate, change) {
4582
4621
  }
4583
4622
  function useAccordionState(multiple) {
4584
4623
  const [opened, setOpened] = useState19(/* @__PURE__ */ new Set());
4585
- useEffect14(() => {
4624
+ useEffect15(() => {
4586
4625
  if (!multiple) setOpened((previous) => previous.size > 1 ? new Set([...previous].slice(-1)) : previous);
4587
4626
  }, [multiple]);
4588
4627
  return {
@@ -4672,10 +4711,10 @@ import {
4672
4711
  Fragment as Fragment7,
4673
4712
  isValidElement as isValidElement3,
4674
4713
  useContext as useContext13,
4675
- useEffect as useEffect15,
4714
+ useEffect as useEffect16,
4676
4715
  useLayoutEffect as useLayoutEffect12,
4677
4716
  useId as useId10,
4678
- useRef as useRef23,
4717
+ useRef as useRef24,
4679
4718
  useState as useState20
4680
4719
  } from "react";
4681
4720
  import { Tab, TabList, TabPanel, Tabs } from "react-aria-components";
@@ -4713,15 +4752,15 @@ function KjunTabs({
4713
4752
  if (!panelNames.has(tab.dataset.tabName)) tab.removeAttribute("aria-controls");
4714
4753
  }
4715
4754
  });
4716
- const timer = useRef23(void 0), press = useRef23(null);
4717
- const menuState = useRef23({ tabs, onTabMenu });
4755
+ const timer = useRef24(void 0), press = useRef24(null);
4756
+ const menuState = useRef24({ tabs, onTabMenu });
4718
4757
  menuState.current = { tabs, onTabMenu };
4719
4758
  const canOpenMenu = (name) => !!menuState.current.onTabMenu && menuState.current.tabs.some((tab) => tab.name === name && !tab.disabled);
4720
4759
  const clear = () => {
4721
4760
  clearTimeout(timer.current);
4722
4761
  press.current = null;
4723
4762
  };
4724
- useEffect15(() => clear, []);
4763
+ useEffect16(() => clear, []);
4725
4764
  useLayoutEffect12(() => {
4726
4765
  if (press.current && !canOpenMenu(press.current.name)) clear();
4727
4766
  }, [tabs, onTabMenu]);
@@ -4839,12 +4878,30 @@ function KjunAccordionItem({
4839
4878
  defaultOpen = false,
4840
4879
  disabled = false,
4841
4880
  header,
4881
+ open: openProp,
4882
+ onOpenChange,
4883
+ keepMounted = false,
4842
4884
  children
4843
4885
  }) {
4844
- const group = useContext13(AccordionContext), id = "kjun-" + useId10(), [own, setOwn] = useState20(defaultOpen), open = group ? group.opened.has(id) : own;
4845
- useEffect15(() => {
4886
+ const controlled = openProp !== void 0, context = useContext13(AccordionContext), group = controlled ? null : context, id = "kjun-" + useId10(), [own, setOwn] = useState20(defaultOpen), open = controlled ? openProp : group ? group.opened.has(id) : own;
4887
+ useEffect16(() => {
4846
4888
  return group == null ? void 0 : group.register(id, defaultOpen);
4847
4889
  }, []);
4890
+ const reported = useRef24(open), notify = useRef24(onOpenChange), registering = useRef24(!!group && defaultOpen);
4891
+ notify.current = onOpenChange;
4892
+ useEffect16(() => {
4893
+ var _a;
4894
+ if (registering.current) {
4895
+ if (open) {
4896
+ registering.current = false;
4897
+ reported.current = open;
4898
+ }
4899
+ return;
4900
+ }
4901
+ if (controlled || reported.current === open) return;
4902
+ reported.current = open;
4903
+ (_a = notify.current) == null ? void 0 : _a.call(notify, open);
4904
+ }, [open, controlled]);
4848
4905
  return /* @__PURE__ */ jsxs16("div", { className: "kjun-accordion-item", children: [
4849
4906
  /* @__PURE__ */ jsxs16(
4850
4907
  "button",
@@ -4855,7 +4912,10 @@ function KjunAccordionItem({
4855
4912
  "aria-expanded": open,
4856
4913
  "aria-controls": id + "-panel",
4857
4914
  className: "kjun-accordion-trigger",
4858
- onClick: () => group ? group.toggle(id) : setOwn(!own),
4915
+ onClick: () => {
4916
+ registering.current = false;
4917
+ controlled ? onOpenChange == null ? void 0 : onOpenChange(!open) : group ? group.toggle(id) : setOwn(!own);
4918
+ },
4859
4919
  children: [
4860
4920
  /* @__PURE__ */ jsx24("span", { className: "kjun-accordion-heading", children: header || title }),
4861
4921
  /* @__PURE__ */ jsx24(
@@ -4870,7 +4930,7 @@ function KjunAccordionItem({
4870
4930
  ]
4871
4931
  }
4872
4932
  ),
4873
- /* @__PURE__ */ jsx24(Collapse, { open, children: /* @__PURE__ */ jsx24(
4933
+ /* @__PURE__ */ jsx24(Collapse, { open, keepMounted, children: /* @__PURE__ */ jsx24(
4874
4934
  "div",
4875
4935
  {
4876
4936
  role: "region",
@@ -4999,8 +5059,8 @@ function KjunPagination({
4999
5059
  import { tokens as tokens22 } from "@kjun-ui/tokens";
5000
5060
  import {
5001
5061
  useContext as useContext14,
5002
- useEffect as useEffect16,
5003
- useRef as useRef24,
5062
+ useEffect as useEffect17,
5063
+ useRef as useRef25,
5004
5064
  useState as useState21
5005
5065
  } from "react";
5006
5066
  import { Fragment as Fragment9, jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
@@ -5084,8 +5144,8 @@ function KjunCopyButton({
5084
5144
  const m = useKjunMessages();
5085
5145
  successText != null ? successText : successText = m.copied;
5086
5146
  const feedback = useOptionalKjunFeedback();
5087
- const [copied, setCopied] = useState21(false), [failed, setFailed] = useState21(false), busy = useRef24(false), timer = useRef24(void 0), mounted = useRef24(true);
5088
- useEffect16(() => {
5147
+ const [copied, setCopied] = useState21(false), [failed, setFailed] = useState21(false), busy = useRef25(false), timer = useRef25(void 0), mounted = useRef25(true);
5148
+ useEffect17(() => {
5089
5149
  mounted.current = true;
5090
5150
  return () => {
5091
5151
  mounted.current = false;
@@ -5216,7 +5276,7 @@ function KjunExternalLink({
5216
5276
  ) : /* @__PURE__ */ jsx25("span", { "aria-label": name, children: body });
5217
5277
  }
5218
5278
  function KjunScrollFade({ children }) {
5219
- const ref = useRef24(null), [edges, setEdges] = useState21({ left: false, right: false });
5279
+ const ref = useRef25(null), [edges, setEdges] = useState21({ left: false, right: false });
5220
5280
  const update = () => {
5221
5281
  const el = ref.current;
5222
5282
  if (el)
@@ -5228,7 +5288,7 @@ function KjunScrollFade({ children }) {
5228
5288
  return prev.left === next.left && prev.right === next.right ? prev : next;
5229
5289
  });
5230
5290
  };
5231
- useEffect16(() => {
5291
+ useEffect17(() => {
5232
5292
  update();
5233
5293
  const observer = new ResizeObserver(update);
5234
5294
  if (ref.current) {
@@ -5260,10 +5320,10 @@ import {
5260
5320
  import { Component, useState as useState23 } from "react";
5261
5321
 
5262
5322
  // shared/package-runtime/use-loading-reveal.ts
5263
- import { useEffect as useEffect17, useState as useState22 } from "react";
5323
+ import { useEffect as useEffect18, useState as useState22 } from "react";
5264
5324
  function useLoadingReveal(active, delay = 0) {
5265
5325
  const [revealed, setRevealed] = useState22(false);
5266
- useEffect17(() => {
5326
+ useEffect18(() => {
5267
5327
  setRevealed(false);
5268
5328
  if (!active || delay <= 0) return;
5269
5329
  const timer = setTimeout(() => setRevealed(true), delay);
@@ -5595,7 +5655,7 @@ import {
5595
5655
  import { tokens as tokens28 } from "@kjun-ui/tokens";
5596
5656
 
5597
5657
  // shared/package-runtime/use-number-motion.ts
5598
- import { useLayoutEffect as useLayoutEffect13, useRef as useRef25, useState as useState24 } from "react";
5658
+ import { useLayoutEffect as useLayoutEffect13, useRef as useRef26, useState as useState24 } from "react";
5599
5659
 
5600
5660
  // shared/package-runtime/number-motion.ts
5601
5661
  import { tokens as tokens27 } from "@kjun-ui/tokens";
@@ -5642,7 +5702,7 @@ function createNumberMotion(apply) {
5642
5702
  // shared/package-runtime/use-number-motion.ts
5643
5703
  function useNumberMotion(value, animated, fromPrevious, reduced) {
5644
5704
  const [display, setDisplay] = useState24(typeof value === "string" || fromPrevious || !animated || reduced ? value : 0);
5645
- const motion = useRef25(null);
5705
+ const motion = useRef26(null);
5646
5706
  if (!motion.current) motion.current = createNumberMotion(setDisplay);
5647
5707
  useLayoutEffect13(() => {
5648
5708
  if (!motion.current) motion.current = createNumberMotion(setDisplay);
@@ -5974,7 +6034,7 @@ function KjunSparkline({
5974
6034
 
5975
6035
  // shared/package-runtime/table.ts
5976
6036
  import { nextTableSort } from "@kjun-ui/tokens";
5977
- import { useEffect as useEffect18, useRef as useRef26, useState as useState25 } from "react";
6037
+ import { useEffect as useEffect19, useRef as useRef27, useState as useState25 } from "react";
5978
6038
 
5979
6039
  // shared/package-runtime/table-model.ts
5980
6040
  function getValue(row, key) {
@@ -6021,8 +6081,8 @@ function useTableModel(props) {
6021
6081
  const [internalSort, setSort] = useState25({
6022
6082
  key: "",
6023
6083
  order: "asc"
6024
- }), [internalExpanded, setExpanded] = useState25([]), [search, setSearch] = useState25(""), timer = useRef26(void 0);
6025
- useEffect18(() => () => clearTimeout(timer.current), []);
6084
+ }), [internalExpanded, setExpanded] = useState25([]), [search, setSearch] = useState25(""), timer = useRef27(void 0);
6085
+ useEffect19(() => () => clearTimeout(timer.current), []);
6026
6086
  const sort = props.sort === void 0 ? internalSort : (_a = props.sort) != null ? _a : { key: "", order: "asc" };
6027
6087
  const rows = sortTableRows(data, sort, { sortable, sortMode });
6028
6088
  const key = (row, index = 0) => tableRowKey(row, rowKey, index);
@@ -6416,7 +6476,7 @@ function TableCards({
6416
6476
  }
6417
6477
 
6418
6478
  // packages/react/src/table-view.tsx
6419
- import { useEffect as useEffect19, useState as useState26 } from "react";
6479
+ import { useEffect as useEffect20, useState as useState26 } from "react";
6420
6480
  import { isComposingKey as isComposingKey4, tokens as tokens33 } from "@kjun-ui/tokens";
6421
6481
  import { jsx as jsx36, jsxs as jsxs28 } from "react/jsx-runtime";
6422
6482
  function KjunTable(props) {
@@ -6448,7 +6508,7 @@ function KjunTable(props) {
6448
6508
  onRetry
6449
6509
  } = props;
6450
6510
  const state = useTableModel2(props), query2 = useQueryDisplay(props), revealed = useLoadingReveal(query2.initialLoading, skeleton ? loadingDelay : 0), [mobile, setMobile] = useState26(false);
6451
- useEffect19(() => {
6511
+ useEffect20(() => {
6452
6512
  const media = matchMedia(`(width < ${tokens33.table.mobileBreakpoint}px)`);
6453
6513
  const update = () => setMobile(media.matches);
6454
6514
  update();
@@ -6814,7 +6874,7 @@ function KjunKpiRow({
6814
6874
  import { tokens as tokens35 } from "@kjun-ui/tokens";
6815
6875
 
6816
6876
  // shared/package-runtime/market-cards.ts
6817
- import { useEffect as useEffect20, useRef as useRef27, useState as useState27 } from "react";
6877
+ import { useEffect as useEffect21, useRef as useRef28, useState as useState27 } from "react";
6818
6878
  function useMarketCardsModel(props, persistence) {
6819
6879
  const {
6820
6880
  columns,
@@ -6831,7 +6891,7 @@ function useMarketCardsModel(props, persistence) {
6831
6891
  isDefaultSort: c.defaultSort
6832
6892
  }));
6833
6893
  const [key, setKey] = useState27(""), restoreSignature = JSON.stringify([storageNamespace, pills]);
6834
- const mounted = useRef27("");
6894
+ const mounted = useRef28("");
6835
6895
  const save = (key2) => {
6836
6896
  var _a;
6837
6897
  try {
@@ -6839,7 +6899,7 @@ function useMarketCardsModel(props, persistence) {
6839
6899
  } catch (e) {
6840
6900
  }
6841
6901
  };
6842
- useEffect20(() => {
6902
+ useEffect21(() => {
6843
6903
  var _a, _b;
6844
6904
  if (mounted.current === restoreSignature) return;
6845
6905
  mounted.current = restoreSignature;
@@ -7174,7 +7234,7 @@ function watchTrailingOverflow(element, onChange) {
7174
7234
  }
7175
7235
 
7176
7236
  // packages/react/src/market-table.tsx
7177
- import { useEffect as useEffect21, useRef as useRef28, useState as useState28 } from "react";
7237
+ import { useEffect as useEffect22, useRef as useRef29, useState as useState28 } from "react";
7178
7238
  import { jsx as jsx42, jsxs as jsxs34 } from "react/jsx-runtime";
7179
7239
  function KjunMarketTable(props) {
7180
7240
  const m = useKjunMessages();
@@ -7196,8 +7256,8 @@ function KjunMarketTable(props) {
7196
7256
  formatMetric,
7197
7257
  renderCell
7198
7258
  } = props;
7199
- const scroller = useRef28(null), [fadeEnd, setFadeEnd] = useState28(false);
7200
- useEffect21(() => scroller.current ? watchTrailingOverflow(scroller.current, setFadeEnd) : void 0, [rows, columns]);
7259
+ const scroller = useRef29(null), [fadeEnd, setFadeEnd] = useState28(false);
7260
+ useEffect22(() => scroller.current ? watchTrailingOverflow(scroller.current, setFadeEnd) : void 0, [rows, columns]);
7201
7261
  const render = (row, col) => {
7202
7262
  const value = getValue(row, col.key), stale = !!getValue(row, "stale");
7203
7263
  if (cellLoading(row, col))
@@ -7387,19 +7447,24 @@ function KjunMarketTable(props) {
7387
7447
 
7388
7448
  // packages/react/src/list.tsx
7389
7449
  import { tokens as tokens39 } from "@kjun-ui/tokens";
7390
- import { useId as useId12 } from "react";
7450
+ import { useEffect as useEffect23, useId as useId12, useRef as useRef30 } from "react";
7391
7451
  import { Fragment as Fragment18, jsx as jsx43, jsxs as jsxs35 } from "react/jsx-runtime";
7392
- function KjunListRow({ title, description, leading, trailing, actions, href, disabled = false, destructive = false, chevron = false, onClick }) {
7452
+ function KjunListRow({ title, description, leading, trailing, actions, href, disabled = false, destructive = false, chevron = false, onClick, ariaLabel, children }) {
7453
+ const content = useRef30(null), pressable = !!(href || onClick);
7454
+ useEffect23(() => {
7455
+ if (pressable) warnNestedControls(content.current, "KJUN ListRow: a pressable row's content contains buttons or links; move them to actions.");
7456
+ }, [pressable]);
7393
7457
  const contents = /* @__PURE__ */ jsxs35(Fragment18, { children: [
7394
7458
  leading && /* @__PURE__ */ jsx43("span", { className: "kjun-list-leading", children: leading }),
7395
7459
  /* @__PURE__ */ jsxs35("span", { className: "kjun-list-body", children: [
7396
7460
  /* @__PURE__ */ jsx43("span", { className: "kjun-list-title", children: title }),
7397
- description && /* @__PURE__ */ jsx43("span", { className: "kjun-list-description", children: description })
7461
+ description && /* @__PURE__ */ jsx43("span", { className: "kjun-list-description", children: description }),
7462
+ hasContent(children) && /* @__PURE__ */ jsx43("span", { ref: content, className: "kjun-list-content", children })
7398
7463
  ] }),
7399
7464
  trailing && /* @__PURE__ */ jsx43("span", { className: "kjun-list-trailing", children: trailing }),
7400
7465
  chevron && /* @__PURE__ */ jsx43(KjunIcon, { name: "chevron-right", className: "kjun-list-chevron", size: tokens39.iconSizes.default })
7401
7466
  ] });
7402
- const main = href ? /* @__PURE__ */ jsx43("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__ */ jsx43("button", { className: "kjun-list-main", type: "button", disabled, onClick, children: contents }) : /* @__PURE__ */ jsx43("div", { className: "kjun-list-main", children: contents });
7467
+ const main = href ? /* @__PURE__ */ jsx43("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__ */ jsx43("button", { className: "kjun-list-main", type: "button", "aria-label": ariaLabel, disabled, onClick, children: contents }) : /* @__PURE__ */ jsx43("div", { className: "kjun-list-main", children: contents });
7403
7468
  return /* @__PURE__ */ jsxs35("li", { className: "kjun-list-row", "data-destructive": destructive || void 0, children: [
7404
7469
  main,
7405
7470
  actions && /* @__PURE__ */ jsx43("div", { className: "kjun-list-actions", "data-disabled": disabled || void 0, inert: disabled || void 0, children: actions })
@@ -7466,11 +7531,11 @@ function KjunBottomActionBar({ description, children, safeAreaBottom = 0, keyboa
7466
7531
  }
7467
7532
 
7468
7533
  // packages/react/src/media.tsx
7469
- import { useRef as useRef29, useState as useState29 } from "react";
7534
+ import { useRef as useRef31, useState as useState29 } from "react";
7470
7535
  import { tokens as tokens41 } from "@kjun-ui/tokens";
7471
7536
  import { jsx as jsx45, jsxs as jsxs37 } from "react/jsx-runtime";
7472
7537
  function KjunImage({ src, alt, decorative = false, aspectRatio = 1, fit = "cover", fallback: fallback2, lazy = true, onLoad, onError }) {
7473
- const current = useRef29({ src, version: 0 });
7538
+ const current = useRef31({ src, version: 0 });
7474
7539
  if (current.current.src !== src) current.current = { src, version: current.current.version + 1 };
7475
7540
  const version = current.current.version;
7476
7541
  const [result, setResult] = useState29({ version, state: "loading" });
@@ -7525,7 +7590,7 @@ function KjunFab({ icon, ariaLabel, disabled = false, safeAreaBottom = 0, offset
7525
7590
  }
7526
7591
 
7527
7592
  // packages/react/src/range-input.tsx
7528
- import { useEffect as useEffect22, useRef as useRef30 } from "react";
7593
+ import { useEffect as useEffect24, useRef as useRef32 } from "react";
7529
7594
  import { Slider, SliderTrack, SliderThumb, Label, SliderOutput } from "react-aria-components";
7530
7595
  import { createSliderDomain } from "@kjun-ui/tokens";
7531
7596
  import { Fragment as Fragment19, jsx as jsx48, jsxs as jsxs39 } from "react/jsx-runtime";
@@ -7535,10 +7600,10 @@ function RangeInput({ value, min = 0, max = 100, step = 1, disabled = false, lab
7535
7600
  const domain = createSliderDomain(min, max, step);
7536
7601
  const list = Array.isArray(value) ? value : [value];
7537
7602
  const valid = domain.valid && (!Array.isArray(value) || value.length === 2) && list.every((v) => domain.accepts(v)) && (list.length === 1 || list[0] <= list[1]);
7538
- const latest = useRef30(value);
7603
+ const latest = useRef32(value);
7539
7604
  latest.current = value;
7540
- const active = useRef30(false);
7541
- useEffect22(() => {
7605
+ const active = useRef32(false);
7606
+ useEffect24(() => {
7542
7607
  if (!valid) console.warn("KJUN Slider: \uBC94\uC704\xB7step\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
7543
7608
  }, [valid]);
7544
7609
  const change = (next) => {
@@ -7575,7 +7640,7 @@ function KjunRangeSlider(props) {
7575
7640
  }
7576
7641
 
7577
7642
  // packages/react/src/quantity-stepper.tsx
7578
- import { useEffect as useEffect23, useRef as useRef31, useState as useState30 } from "react";
7643
+ import { useEffect as useEffect25, useRef as useRef33, useState as useState30 } from "react";
7579
7644
  import { createNumberDomain, quantityKeyAction, tokens as tokens44 } from "@kjun-ui/tokens";
7580
7645
  import { jsx as jsx49, jsxs as jsxs40 } from "react/jsx-runtime";
7581
7646
  function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, disabled = false, error = false, size = "md", block = false, id, ariaLabel, onValueChange, onChangeCommit, onInvalidInput }) {
@@ -7586,13 +7651,13 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
7586
7651
  const valid = domain.valid && domain.accepts(value), blocked = disabled || !valid;
7587
7652
  const [draft, setDraft] = useState30(String(value));
7588
7653
  const field = useKjunField();
7589
- const composing = useRef31(false), dirty = useRef31(false), accepted = useRef31(value);
7590
- useEffect23(() => {
7654
+ const composing = useRef33(false), dirty = useRef33(false), accepted = useRef33(value);
7655
+ useEffect25(() => {
7591
7656
  setDraft(String(value));
7592
7657
  accepted.current = value;
7593
7658
  dirty.current = false;
7594
7659
  }, [value, precision, min, max, step]);
7595
- useEffect23(() => {
7660
+ useEffect25(() => {
7596
7661
  if (!valid) console.warn("KJUN QuantityStepper: \uBC94\uC704\xB7step\xB7\uC815\uBC00\uB3C4\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
7597
7662
  }, [valid]);
7598
7663
  const emit = (next) => {
@@ -7667,18 +7732,18 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
7667
7732
  }
7668
7733
 
7669
7734
  // packages/react/src/time-picker.tsx
7670
- import { Fragment as Fragment20, useEffect as useEffect24, useId as useId13, useMemo as useMemo3, useRef as useRef32 } from "react";
7735
+ import { Fragment as Fragment20, useEffect as useEffect26, useId as useId13, useMemo as useMemo3, useRef as useRef34 } from "react";
7671
7736
  import { createTimeDomain } from "@kjun-ui/tokens";
7672
7737
  import { jsx as jsx50, jsxs as jsxs41 } from "react/jsx-runtime";
7673
7738
  function KjunTimePicker({ value, precision = "minute", min, max, minuteStep = 1, secondStep = 1, disabled = false, error = false, clearable = true, size = "md", ariaLabel, onValueChange, onChangeCommit }) {
7674
7739
  const m = useKjunMessages();
7675
7740
  ariaLabel != null ? ariaLabel : ariaLabel = m.time;
7676
- const root = useRef32(null);
7741
+ const root = useRef34(null);
7677
7742
  const field = useKjunField(), uid = useId13();
7678
7743
  const fieldId = (field == null ? void 0 : field.id) || `kjun-time-${uid}`;
7679
7744
  const domain = useMemo3(() => createTimeDomain({ precision, min, max, minuteStep, secondStep }), [precision, min, max, minuteStep, secondStep]);
7680
7745
  const valid = domain.valid && domain.accepts(value);
7681
- useEffect24(() => {
7746
+ useEffect26(() => {
7682
7747
  if (!valid) console.warn("KJUN TimePicker: \uC2DC\uAC01 \uBC94\uC704\xB7\uAC04\uACA9\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
7683
7748
  }, [valid]);
7684
7749
  const change = (next) => {