@kjun-ui/react 0.9.0 → 0.10.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
@@ -26,9 +26,23 @@ function mergeIcons(parent, own) {
26
26
  function withFallbackIcons(registry, fallbacks) {
27
27
  return mergeIcons(fallbacks, registry);
28
28
  }
29
+ var warnedIcons = /* @__PURE__ */ new Set();
30
+ function developmentMode() {
31
+ try {
32
+ return true;
33
+ } catch (e) {
34
+ return false;
35
+ }
36
+ }
37
+ function warnMissingIcon(name) {
38
+ if (!developmentMode() || warnedIcons.has(name)) return;
39
+ warnedIcons.add(name);
40
+ console.warn(`KJUN Icon: "${name}" \uC544\uC774\uCF58\uC774 \uB4F1\uB85D\uB418\uC9C0 \uC54A\uC544 help-circle\uB85C \uB300\uC2E0\uD569\uB2C8\uB2E4. @kjun-ui/icons/icons/${name}\uB97C import\uD574 KjunProvider\uC758 icons\uC5D0 \uB4F1\uB85D\uD558\uC138\uC694.`);
41
+ }
29
42
  function resolveIcon(registry, name, filled = false) {
30
43
  var _a;
31
44
  const definition = Object.prototype.hasOwnProperty.call(registry, name) ? registry[name] : void 0;
45
+ if (!definition && name) warnMissingIcon(name);
32
46
  const filledNodes = filled && (definition == null ? void 0 : definition.filled);
33
47
  return { nodes: filledNodes || (definition == null ? void 0 : definition.outline) || ((_a = registry["help-circle"]) == null ? void 0 : _a.outline) || defaultIcons["help-circle"].outline, filled: !!filledNodes };
34
48
  }
@@ -588,6 +602,7 @@ var KjunButton = forwardRef(
588
602
  style,
589
603
  onClick,
590
604
  type = "button",
605
+ wrap = false,
591
606
  ...rest
592
607
  } = props;
593
608
  const size = useActionSize(props.size, declaredSize);
@@ -616,6 +631,7 @@ var KjunButton = forwardRef(
616
631
  "data-variant": variant,
617
632
  "data-size": size,
618
633
  "data-disabled": disabled,
634
+ "data-wrap": wrap || void 0,
619
635
  "aria-label": ariaLabel || rest["aria-label"],
620
636
  disabled: disabled || busy,
621
637
  "aria-busy": busy || void 0,
@@ -629,7 +645,7 @@ var KjunButton = forwardRef(
629
645
  ...typeStyle(tokens3.button.typography[size]),
630
646
  borderRadius: tokens3.button.radii[size],
631
647
  gap: hasContent2 ? tokens3.button.contentGaps[size] : 0,
632
- ...navigation ? {
648
+ ...navigation || wrap ? {
633
649
  height: "auto",
634
650
  maxWidth: "100%",
635
651
  paddingBlock: Math.max(0, (height - contentHeight) / 2)
@@ -670,6 +686,14 @@ var KjunButton = forwardRef(
670
686
 
671
687
  // packages/react/src/input.tsx
672
688
  import { tokens as tokens4 } from "@kjun-ui/tokens";
689
+
690
+ // shared/package-runtime/aria-ids.ts
691
+ function mergeIds(...lists) {
692
+ const ids = [...new Set(lists.flatMap((list) => (list != null ? list : "").split(/\s+/)).filter(Boolean))];
693
+ return ids.length ? ids.join(" ") : void 0;
694
+ }
695
+
696
+ // packages/react/src/input.tsx
673
697
  import {
674
698
  createContext as createContext6,
675
699
  forwardRef as forwardRef2,
@@ -707,26 +731,30 @@ function KjunFormGroup({
707
731
  required = false,
708
732
  error = "",
709
733
  hint = "",
734
+ labelHidden = false,
710
735
  children
711
736
  }) {
712
737
  const uid = useId2().replace(/:/g, "");
713
738
  const fieldId = id || "kjun-field-" + uid;
714
739
  const labelId = label ? fieldId + "-label" : void 0;
715
- const describedBy = error ? fieldId + "-error" : hint ? fieldId + "-hint" : void 0;
740
+ const hintId = hint ? fieldId + "-hint" : void 0, errorId = error ? fieldId + "-error" : void 0;
741
+ const describedBy = mergeIds(hintId, errorId);
742
+ const [controlId, setControlId] = useState4();
716
743
  return /* @__PURE__ */ jsx5(
717
744
  FieldContext.Provider,
718
745
  {
719
- value: { id: fieldId, labelId, describedBy, error, required },
746
+ value: { id: fieldId, labelId, describedBy, error, required, setControlId },
720
747
  children: /* @__PURE__ */ jsxs3("div", { className: "kjun-form-group", children: [
721
- label && /* @__PURE__ */ jsxs3("label", { className: "kjun-form-label", id: labelId, htmlFor: fieldId, children: [
748
+ label && /* @__PURE__ */ jsxs3("label", { className: "kjun-form-label" + (labelHidden ? " kjun-sr-only" : ""), id: labelId, htmlFor: controlId || fieldId, children: [
722
749
  label,
723
750
  required && /* @__PURE__ */ jsx5("span", { style: { color: "var(--_kjun-color-danger)" }, children: " *" })
724
751
  ] }),
725
752
  children,
726
- error ? /* @__PURE__ */ jsxs3("p", { id: describedBy, className: "kjun-form-error", role: "alert", children: [
753
+ hint && /* @__PURE__ */ jsx5("p", { id: hintId, className: "kjun-form-hint", children: hint }),
754
+ error && /* @__PURE__ */ jsxs3("p", { id: errorId, className: "kjun-form-error", role: "alert", children: [
727
755
  /* @__PURE__ */ jsx5(KjunIcon, { name: "alert-circle", size: tokens4.extensions.form.messageIconSize }),
728
756
  error
729
- ] }) : hint ? /* @__PURE__ */ jsx5("p", { id: describedBy, className: "kjun-form-hint", children: hint }) : null
757
+ ] })
730
758
  ] })
731
759
  }
732
760
  );
@@ -784,11 +812,7 @@ var KjunInput = forwardRef2(
784
812
  const showError = !!errorMessage && !(field == null ? void 0 : field.error);
785
813
  const invalid = !!(error || errorMessage || (field == null ? void 0 : field.error));
786
814
  const ownErrorId = "kjun-input-error-" + uid;
787
- const describedBy = [
788
- props["aria-describedby"],
789
- field == null ? void 0 : field.describedBy,
790
- showError ? ownErrorId : void 0
791
- ].filter(Boolean).join(" ") || void 0;
815
+ const describedBy = mergeIds(props["aria-describedby"], field == null ? void 0 : field.describedBy, showError ? ownErrorId : void 0);
792
816
  return /* @__PURE__ */ jsxs3("div", { style: { minWidth: 0 }, children: [
793
817
  /* @__PURE__ */ jsxs3("div", { className: "kjun-input-wrap", "data-disabled": disabled || void 0, children: [
794
818
  (prefix || prefixIcon) && /* @__PURE__ */ jsx5(
@@ -1196,6 +1220,13 @@ function hasContent(node) {
1196
1220
  return true;
1197
1221
  }
1198
1222
 
1223
+ // shared/package-runtime/alert-live.ts
1224
+ function alertRole(tone, live) {
1225
+ if (live === "off") return void 0;
1226
+ if (live) return live === "assertive" ? "alert" : "status";
1227
+ return tone === "danger" ? "alert" : "status";
1228
+ }
1229
+
1199
1230
  // packages/react/src/display.tsx
1200
1231
  import { tokens as tokens7 } from "@kjun-ui/tokens";
1201
1232
  import {
@@ -1353,6 +1384,7 @@ function KjunAlert({
1353
1384
  size = "md",
1354
1385
  title,
1355
1386
  closable = false,
1387
+ live,
1356
1388
  children,
1357
1389
  actions,
1358
1390
  onClose
@@ -1363,7 +1395,7 @@ function KjunAlert({
1363
1395
  return /* @__PURE__ */ jsxs6(
1364
1396
  "div",
1365
1397
  {
1366
- role: tone === "danger" ? "alert" : "status",
1398
+ role: alertRole(tone, live),
1367
1399
  className: "kjun-alert",
1368
1400
  "data-size": small ? "sm" : "md",
1369
1401
  style: {
@@ -1972,6 +2004,7 @@ import { tokens as tokens12 } from "@kjun-ui/tokens";
1972
2004
  import {
1973
2005
  createContext as createContext9,
1974
2006
  forwardRef as forwardRef3,
2007
+ useCallback as useCallback2,
1975
2008
  useContext as useContext9,
1976
2009
  useId as useId5
1977
2010
  } from "react";
@@ -2100,12 +2133,17 @@ function KjunCheckbox({
2100
2133
  onChange
2101
2134
  }) {
2102
2135
  const checked = Array.isArray(value) ? value.includes(val) : value;
2136
+ const field = useKjunField();
2103
2137
  return /* @__PURE__ */ jsxs9(
2104
2138
  AriaCheckbox,
2105
2139
  {
2106
2140
  isSelected: checked,
2107
2141
  isDisabled: disabled,
2108
2142
  "aria-label": ariaLabel,
2143
+ "aria-describedby": field == null ? void 0 : field.describedBy,
2144
+ isInvalid: !!(field == null ? void 0 : field.error),
2145
+ isRequired: field == null ? void 0 : field.required,
2146
+ validationBehavior: "aria",
2109
2147
  className: "kjun-choice" + (disabled ? " kjun-choice--disabled" : ""),
2110
2148
  onChange: (next) => {
2111
2149
  const result = Array.isArray(value) ? next ? [...value, val] : value.filter((v) => v !== val) : next;
@@ -2135,12 +2173,23 @@ function KjunSwitch({
2135
2173
  onValueChange,
2136
2174
  onChange
2137
2175
  }) {
2176
+ const field = useKjunField();
2177
+ const invalid = !!(field == null ? void 0 : field.error), required = !!(field == null ? void 0 : field.required);
2178
+ const markInput = useCallback2((input) => {
2179
+ if (!input) return;
2180
+ if (invalid) input.setAttribute("aria-invalid", "true");
2181
+ else input.removeAttribute("aria-invalid");
2182
+ if (required) input.setAttribute("aria-required", "true");
2183
+ else input.removeAttribute("aria-required");
2184
+ }, [invalid, required]);
2138
2185
  return /* @__PURE__ */ jsxs9(
2139
2186
  AriaSwitch,
2140
2187
  {
2141
2188
  isSelected: value,
2142
2189
  isDisabled: disabled,
2143
2190
  "aria-label": ariaLabel || label,
2191
+ "aria-describedby": field == null ? void 0 : field.describedBy,
2192
+ inputRef: markInput,
2144
2193
  className: "kjun-choice" + (disabled ? " kjun-choice--disabled" : ""),
2145
2194
  onChange: (next) => {
2146
2195
  onValueChange == null ? void 0 : onValueChange(next);
@@ -2276,7 +2325,7 @@ var KjunTextarea = forwardRef3(
2276
2325
  required: (_a = props.required) != null ? _a : field == null ? void 0 : field.required,
2277
2326
  "aria-label": ariaLabel || props["aria-label"],
2278
2327
  "aria-labelledby": props["aria-labelledby"] || (field == null ? void 0 : field.labelId),
2279
- "aria-describedby": props["aria-describedby"] || (field == null ? void 0 : field.describedBy),
2328
+ "aria-describedby": mergeIds(props["aria-describedby"], field == null ? void 0 : field.describedBy),
2280
2329
  "aria-invalid": error || !!(field == null ? void 0 : field.error) || void 0,
2281
2330
  className: "kjun-input kjun-textarea " + className,
2282
2331
  style: {
@@ -2437,6 +2486,7 @@ function FloatingPanel({
2437
2486
  field = false,
2438
2487
  flip = true,
2439
2488
  nonModal = false,
2489
+ ownsDismiss = false,
2440
2490
  returnFocus
2441
2491
  }) {
2442
2492
  const motion = usePresence(open, useReducedMotion(), tokens13.motion.popupExit);
@@ -2468,7 +2518,9 @@ function FloatingPanel({
2468
2518
  isNonModal: nonModal,
2469
2519
  isKeyboardDismissDisabled: layer.keyboardManaged,
2470
2520
  isOpen: motion.present,
2471
- onOpenChange,
2521
+ onOpenChange: ownsDismiss && layer.keyboardManaged ? (next) => {
2522
+ if (next) onOpenChange(next);
2523
+ } : onOpenChange,
2472
2524
  triggerRef,
2473
2525
  UNSTABLE_portalContainer: container,
2474
2526
  placement: placement.replace("-", " "),
@@ -2491,8 +2543,69 @@ function FloatingPanel({
2491
2543
 
2492
2544
  // packages/react/src/popover.tsx
2493
2545
  import { tokens as tokens14 } from "@kjun-ui/tokens";
2494
- import { useCallback as useCallback2, useId as useId6, useRef as useRef14, useState as useState10 } from "react";
2546
+ import { useCallback as useCallback3, useEffect as useEffect6, useId as useId6, useRef as useRef14, useState as useState10 } from "react";
2495
2547
  import { Dialog as Dialog2, Focusable, OverlayArrow, Tooltip, TooltipTrigger } from "react-aria-components";
2548
+
2549
+ // shared/package-runtime/popover-nonmodal.ts
2550
+ var tabbableSelector = 'button,input,select,textarea,[href],[tabindex]:not([tabindex="-1"])';
2551
+ function tabbable(element) {
2552
+ return element.tabIndex >= 0 && !element.disabled && element.getClientRects().length > 0 && !element.closest("[inert]");
2553
+ }
2554
+ function tabbables(root) {
2555
+ return [...root.querySelectorAll(tabbableSelector)].filter(tabbable);
2556
+ }
2557
+ function nextTabbableAfter(trigger, skip) {
2558
+ var _a;
2559
+ return (_a = tabbables(trigger.ownerDocument).find((element) => !trigger.contains(element) && !(skip == null ? void 0 : skip.contains(element)) && !!(trigger.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_FOLLOWING))) != null ? _a : null;
2560
+ }
2561
+ function installNonModalPopover({ panel, trigger, close }) {
2562
+ var _a, _b;
2563
+ const doc = (_a = trigger()) == null ? void 0 : _a.ownerDocument;
2564
+ if (!doc) return () => {
2565
+ };
2566
+ const inside = (node) => {
2567
+ var _a2, _b2;
2568
+ if (!(node instanceof Node)) return false;
2569
+ const element = node instanceof Element ? node : node.parentElement;
2570
+ return !!(((_a2 = panel()) == null ? void 0 : _a2.contains(node)) || ((_b2 = trigger()) == null ? void 0 : _b2.contains(node)) || (element == null ? void 0 : element.closest(".kjun-floating")));
2571
+ };
2572
+ const onKeyDown = (event) => {
2573
+ var _a2, _b2, _c;
2574
+ const root = panel(), opener = trigger();
2575
+ if (event.key !== "Tab" || !root || !opener || !root.contains(event.target)) return;
2576
+ const items = tabbables(root), first = items[0], last = items.at(-1);
2577
+ if (event.shiftKey && (event.target === first || event.target === root || !first)) {
2578
+ event.preventDefault();
2579
+ event.stopPropagation();
2580
+ ((_a2 = tabbables(opener)[0]) != null ? _a2 : opener).focus();
2581
+ } else if (!event.shiftKey && (event.target === last || !last)) {
2582
+ event.preventDefault();
2583
+ event.stopPropagation();
2584
+ const next = (_c = (_b2 = nextTabbableAfter(opener, root)) != null ? _b2 : tabbables(opener)[0]) != null ? _c : opener;
2585
+ close();
2586
+ let frames = 0;
2587
+ const moveOn = () => {
2588
+ if (root.isConnected && frames++ < 60) requestAnimationFrame(moveOn);
2589
+ else next.focus();
2590
+ };
2591
+ moveOn();
2592
+ }
2593
+ };
2594
+ const onOutside = (event) => {
2595
+ if (!inside(event.target)) close();
2596
+ };
2597
+ const view = (_b = doc.defaultView) != null ? _b : window;
2598
+ view.addEventListener("keydown", onKeyDown, true);
2599
+ doc.addEventListener("focusin", onOutside, true);
2600
+ doc.addEventListener("pointerdown", onOutside, true);
2601
+ return () => {
2602
+ view.removeEventListener("keydown", onKeyDown, true);
2603
+ doc.removeEventListener("focusin", onOutside, true);
2604
+ doc.removeEventListener("pointerdown", onOutside, true);
2605
+ };
2606
+ }
2607
+
2608
+ // packages/react/src/popover.tsx
2496
2609
  import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
2497
2610
  function KjunPopover({
2498
2611
  noPadding = false,
@@ -2506,6 +2619,8 @@ function KjunPopover({
2506
2619
  ariaLabel,
2507
2620
  placement = "bottom",
2508
2621
  returnFocus,
2622
+ header,
2623
+ modal = true,
2509
2624
  trigger,
2510
2625
  children
2511
2626
  }) {
@@ -2513,7 +2628,7 @@ function KjunPopover({
2513
2628
  const expanded = usePopupExpanded(open, ref);
2514
2629
  const focusOnMount = useRef14(focusOnOpen);
2515
2630
  focusOnMount.current = focusOnOpen;
2516
- const focusContent = useCallback2((node) => {
2631
+ const focusContent = useCallback3((node) => {
2517
2632
  if (node && focusOnMount.current) node.focus();
2518
2633
  }, []);
2519
2634
  const resolveReturn = returnFocus === void 0 ? void 0 : () => typeof returnFocus === "function" ? returnFocus() : returnFocus instanceof HTMLElement ? returnFocus : returnFocus.current;
@@ -2521,6 +2636,23 @@ function KjunPopover({
2521
2636
  setInternal(v);
2522
2637
  onOpenChange == null ? void 0 : onOpenChange(v);
2523
2638
  };
2639
+ const skipReturn = useRef14(false);
2640
+ useEffect6(() => {
2641
+ if (!open || modal) return;
2642
+ skipReturn.current = false;
2643
+ return installNonModalPopover({
2644
+ panel: () => {
2645
+ var _a, _b;
2646
+ return (_b = (_a = document.getElementById(id)) == null ? void 0 : _a.closest(".kjun-floating")) != null ? _b : null;
2647
+ },
2648
+ trigger: () => ref.current,
2649
+ close: () => {
2650
+ skipReturn.current = true;
2651
+ change(false);
2652
+ }
2653
+ });
2654
+ });
2655
+ const content = /* @__PURE__ */ jsx14("div", { className: "kjun-popover-content", "data-no-padding": noPadding, children: typeof children === "function" ? children(() => change(false)) : children });
2524
2656
  return /* @__PURE__ */ jsxs10(Fragment3, { children: [
2525
2657
  /* @__PURE__ */ jsx14(
2526
2658
  "div",
@@ -2548,26 +2680,29 @@ function KjunPopover({
2548
2680
  open,
2549
2681
  onOpenChange: change,
2550
2682
  triggerRef: ref,
2551
- className: "kjun-content-popover",
2683
+ className: "kjun-content-popover" + (header != null ? " kjun-popover-has-header" : ""),
2552
2684
  placement,
2553
2685
  matchTriggerWidth,
2554
2686
  maxHeight,
2555
2687
  flip,
2556
- returnFocus: resolveReturn,
2557
- children: /* @__PURE__ */ jsxs10(
2558
- Dialog2,
2559
- {
2688
+ returnFocus: () => skipReturn.current ? false : resolveReturn == null ? void 0 : resolveReturn(),
2689
+ nonModal: !modal,
2690
+ ownsDismiss: !modal,
2691
+ children: (() => {
2692
+ const dialogProps = {
2560
2693
  id,
2561
- "aria-label": ariaLabel || "\uC0C1\uC138 \uC815\uBCF4",
2694
+ "aria-label": header != null && !ariaLabel ? void 0 : ariaLabel || "\uC0C1\uC138 \uC815\uBCF4",
2695
+ "aria-labelledby": header != null && !ariaLabel ? id + "-header" : void 0,
2562
2696
  className: "kjun-popover-dialog",
2563
- style: { maxHeight: maxHeight != null ? maxHeight : `min(60vh, ${tokens14.extensions.floating.maxHeight}px)`, overflowY: "auto" },
2564
- ref: focusContent,
2565
- children: [
2566
- /* @__PURE__ */ jsx14("div", { className: "kjun-popover-content", "data-no-padding": noPadding, children: typeof children === "function" ? children(() => change(false)) : children }),
2567
- /* @__PURE__ */ jsx14(FeedbackLayerOutlet, {})
2568
- ]
2569
- }
2570
- )
2697
+ style: { maxHeight: maxHeight != null ? maxHeight : `min(60vh, ${tokens14.extensions.floating.maxHeight}px)`, overflowY: header != null ? void 0 : "auto" }
2698
+ };
2699
+ const body = /* @__PURE__ */ jsxs10(Fragment3, { children: [
2700
+ header != null && /* @__PURE__ */ jsx14("div", { id: id + "-header", className: "kjun-popover-header", children: header }),
2701
+ header != null ? /* @__PURE__ */ jsx14("div", { className: "kjun-popover-body", children: content }) : content,
2702
+ /* @__PURE__ */ jsx14(FeedbackLayerOutlet, {})
2703
+ ] });
2704
+ return modal ? /* @__PURE__ */ jsx14(Dialog2, { ...dialogProps, ref: focusContent, children: body }) : /* @__PURE__ */ jsx14("section", { ...dialogProps, role: "dialog", tabIndex: -1, ref: focusContent, children: body });
2705
+ })()
2571
2706
  }
2572
2707
  )
2573
2708
  ] });
@@ -2576,10 +2711,16 @@ function KjunTooltip({
2576
2711
  content = "",
2577
2712
  placement = "top",
2578
2713
  delay = 0,
2714
+ open: controlled,
2715
+ onOpenChange,
2579
2716
  children
2580
2717
  }) {
2581
2718
  const container = useKjunPortalContainer();
2582
- const [open, setOpen] = useState10(false);
2719
+ const [internal, setInternal] = useState10(false), open = controlled != null ? controlled : internal;
2720
+ const setOpen = (value) => {
2721
+ setInternal(value);
2722
+ onOpenChange == null ? void 0 : onOpenChange(value);
2723
+ };
2583
2724
  const layer = useLayer(open, open, "tooltip", () => setOpen(false));
2584
2725
  return /* @__PURE__ */ jsxs10(TooltipTrigger, { isOpen: open && !layer.blocked, onOpenChange: setOpen, delay, closeDelay: 0, isDisabled: !content || !layer.scopeActive, children: [
2585
2726
  /* @__PURE__ */ jsx14(Focusable, { children }),
@@ -2602,7 +2743,7 @@ function KjunTooltip({
2602
2743
 
2603
2744
  // packages/react/src/dropdown.tsx
2604
2745
  import { tokens as tokens15 } from "@kjun-ui/tokens";
2605
- import { cloneElement, createContext as createContext10, isValidElement as isValidElement2, useCallback as useCallback3, useContext as useContext10, useEffect as useEffect6, useId as useId7, useRef as useRef15, useState as useState11 } from "react";
2746
+ import { cloneElement, createContext as createContext10, isValidElement as isValidElement2, useCallback as useCallback4, useContext as useContext10, useEffect as useEffect7, useId as useId7, useRef as useRef15, useState as useState11 } from "react";
2606
2747
  import { Menu, MenuItem, Separator } from "react-aria-components";
2607
2748
  import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
2608
2749
  var DropdownContext = createContext10(null);
@@ -2620,7 +2761,7 @@ function KjunDropdown({
2620
2761
  const [open, setOpen] = useState11(false), currentOpen = useRef15(false), ref = useRef15(null), id = "kjun-" + useId7();
2621
2762
  const menuFocusCleanup = useRef15(() => {
2622
2763
  });
2623
- const bindMenu = useCallback3((menu) => {
2764
+ const bindMenu = useCallback4((menu) => {
2624
2765
  menuFocusCleanup.current();
2625
2766
  menuFocusCleanup.current = () => {
2626
2767
  };
@@ -2630,7 +2771,7 @@ function KjunDropdown({
2630
2771
  cancelAnimationFrame(frame);
2631
2772
  frame = requestAnimationFrame(() => {
2632
2773
  if (!currentOpen.current || !menu.isConnected || menu.ownerDocument.activeElement !== menu || menu.closest('[inert], [aria-hidden="true"]')) return;
2633
- const item = menu.querySelector('[data-focused="true"]:not([data-disabled])') || menu.querySelector('[role="menuitem"]:not([data-disabled])');
2774
+ const item = menu.querySelector('[data-focused="true"]:not([data-disabled])') || menu.querySelector(':is([role="menuitem"], [role="menuitemradio"]):not([data-disabled])');
2634
2775
  item == null ? void 0 : item.focus({ preventScroll: true });
2635
2776
  });
2636
2777
  };
@@ -2671,7 +2812,7 @@ function KjunDropdown({
2671
2812
  if (value) onOpen == null ? void 0 : onOpen();
2672
2813
  else onClose == null ? void 0 : onClose();
2673
2814
  };
2674
- useEffect6(() => {
2815
+ useEffect7(() => {
2675
2816
  if (unavailable) change(false);
2676
2817
  }, [unavailable]);
2677
2818
  return /* @__PURE__ */ jsxs11(DropdownContext.Provider, { value: () => change(false), children: [
@@ -2725,9 +2866,20 @@ function KjunDropdownItem({
2725
2866
  onClick
2726
2867
  }) {
2727
2868
  const close = useContext10(DropdownContext);
2869
+ const node = useCallback4((element) => {
2870
+ if (!element) return;
2871
+ if (selected === null) {
2872
+ element.setAttribute("role", "menuitem");
2873
+ element.removeAttribute("aria-checked");
2874
+ return;
2875
+ }
2876
+ element.setAttribute("role", "menuitemradio");
2877
+ element.setAttribute("aria-checked", String(selected));
2878
+ }, [selected]);
2728
2879
  return /* @__PURE__ */ jsxs11(
2729
2880
  MenuItem,
2730
2881
  {
2882
+ ref: node,
2731
2883
  id,
2732
2884
  textValue: textValue || (typeof children === "string" ? children : void 0),
2733
2885
  isDisabled: disabled,
@@ -2911,7 +3063,7 @@ function KjunDrawer({
2911
3063
  }
2912
3064
 
2913
3065
  // shared/package-runtime/combobox.ts
2914
- import { useEffect as useEffect7, useState as useState12 } from "react";
3066
+ import { useEffect as useEffect8, useState as useState12 } from "react";
2915
3067
 
2916
3068
  // shared/package-runtime/options.ts
2917
3069
  var optionValue = (option, key = "value") => typeof option === "object" ? option[key] : option;
@@ -2990,8 +3142,8 @@ function useComboboxModel({
2990
3142
  const selectedLabel = selected !== void 0 ? optionLabel(selected, labelKey) : "";
2991
3143
  const [query2, setQuery] = useState12(selectedLabel);
2992
3144
  const [open, setOpen] = useState12(false);
2993
- useEffect7(() => setQuery(selectedLabel), [value, selectedLabel]);
2994
- useEffect7(() => {
3145
+ useEffect8(() => setQuery(selectedLabel), [value, selectedLabel]);
3146
+ useEffect8(() => {
2995
3147
  if (disabled) setOpen(false);
2996
3148
  }, [disabled]);
2997
3149
  const change = (next) => {
@@ -3025,7 +3177,7 @@ function useComboboxModel({
3025
3177
 
3026
3178
  // packages/react/src/combobox.tsx
3027
3179
  import {
3028
- useEffect as useEffect8,
3180
+ useEffect as useEffect9,
3029
3181
  useId as useId8,
3030
3182
  useRef as useRef16,
3031
3183
  useState as useState13
@@ -3113,8 +3265,8 @@ function SearchField({
3113
3265
  const ref = useRef16(null), [highlighted, setActive] = useState13(-1), id = "kjun-" + useId8();
3114
3266
  const focusGuard = usePopupFocusGuard(ref);
3115
3267
  const active = !disabled && !loading && highlighted >= 0 && highlighted < options.length && !optionDisabled(options[highlighted]) ? highlighted : -1;
3116
- useEffect8(() => setActive(-1), [value, options.length]);
3117
- useEffect8(() => {
3268
+ useEffect9(() => setActive(-1), [value, options.length]);
3269
+ useEffect9(() => {
3118
3270
  if (!open) return;
3119
3271
  const leaveField = (event) => {
3120
3272
  var _a, _b, _c;
@@ -3124,7 +3276,7 @@ function SearchField({
3124
3276
  document.addEventListener("focusin", leaveField);
3125
3277
  return () => document.removeEventListener("focusin", leaveField);
3126
3278
  }, [open, onOpenChange, id]);
3127
- useEffect8(() => {
3279
+ useEffect9(() => {
3128
3280
  if (highlighted !== active) setActive(-1);
3129
3281
  }, [highlighted, active]);
3130
3282
  const available = options.map((o, i) => optionDisabled(o) ? -1 : i).filter((i) => i >= 0);
@@ -3325,7 +3477,7 @@ function KjunDatePicker({
3325
3477
  import { useState as useState16 } from "react";
3326
3478
 
3327
3479
  // shared/package-runtime/search-input.ts
3328
- import { useEffect as useEffect9, useLayoutEffect as useLayoutEffect10, useRef as useRef17, useState as useState15 } from "react";
3480
+ import { useEffect as useEffect10, useLayoutEffect as useLayoutEffect10, useRef as useRef17, useState as useState15 } from "react";
3329
3481
  function useSearchInputModel({
3330
3482
  value,
3331
3483
  disabled = false,
@@ -3348,7 +3500,7 @@ function useSearchInputModel({
3348
3500
  clearTimeout(timer.current);
3349
3501
  return () => clearTimeout(timer.current);
3350
3502
  }, [disabled, debounce, !!loadOptions]);
3351
- useEffect9(() => {
3503
+ useEffect10(() => {
3352
3504
  const current = ++version.current, abort = new AbortController();
3353
3505
  setFailed(false);
3354
3506
  if (!loadOptions || !open || disabled || query2.length < minChars) {
@@ -3502,12 +3654,12 @@ import {
3502
3654
  useId as useId9,
3503
3655
  useContext as useContext11,
3504
3656
  useRef as useRef19,
3505
- useEffect as useEffect11
3657
+ useEffect as useEffect12
3506
3658
  } from "react";
3507
3659
  import { ListBox, ListBoxItem } from "react-aria-components";
3508
3660
 
3509
3661
  // shared/package-runtime/select.ts
3510
- import { useEffect as useEffect10, useRef as useRef18, useState as useState17 } from "react";
3662
+ import { useEffect as useEffect11, useRef as useRef18, useState as useState17 } from "react";
3511
3663
  function useSelectState(controlled, disabled, pageSize, onOpenChange) {
3512
3664
  const [internal, setInternal] = useState17(false);
3513
3665
  const [query2, setQuery] = useState17("");
@@ -3516,7 +3668,7 @@ function useSelectState(controlled, disabled, pageSize, onOpenChange) {
3516
3668
  const isControlled = typeof controlled === "boolean";
3517
3669
  const open = !disabled && (isControlled ? controlled : internal);
3518
3670
  const previousOpen = useRef18(open);
3519
- useEffect10(() => {
3671
+ useEffect11(() => {
3520
3672
  if (disabled && !isControlled) setInternal(false);
3521
3673
  if (previousOpen.current && !open) {
3522
3674
  setQuery("");
@@ -3525,7 +3677,7 @@ function useSelectState(controlled, disabled, pageSize, onOpenChange) {
3525
3677
  }
3526
3678
  previousOpen.current = open;
3527
3679
  }, [open, disabled, isControlled, pageSize]);
3528
- useEffect10(() => {
3680
+ useEffect11(() => {
3529
3681
  setLimit(pageSize);
3530
3682
  }, [pageSize]);
3531
3683
  const changeOpen = (next) => {
@@ -3552,6 +3704,8 @@ function KjunSelect({
3552
3704
  placeholder = "\uC120\uD0DD",
3553
3705
  ariaLabel,
3554
3706
  labelKey = "label",
3707
+ id: triggerId,
3708
+ ariaDescribedBy,
3555
3709
  valueKey = "value",
3556
3710
  size = "md",
3557
3711
  disabled = false,
@@ -3580,7 +3734,13 @@ function KjunSelect({
3580
3734
  const segment = useContext11(CompoundControlContext) !== null;
3581
3735
  const spec = tokens18.input[size];
3582
3736
  const expanded = usePopupExpanded(open, ref);
3583
- useEffect11(() => {
3737
+ const registerControl = field == null ? void 0 : field.setControlId;
3738
+ useEffect12(() => {
3739
+ if (!registerControl || !triggerId) return;
3740
+ registerControl(triggerId);
3741
+ return () => registerControl(void 0);
3742
+ }, [registerControl, triggerId]);
3743
+ useEffect12(() => {
3584
3744
  var _a, _b;
3585
3745
  if (open && searchable) (_b = (_a = menu.current) == null ? void 0 : _a.querySelector("input")) == null ? void 0 : _b.focus({ preventScroll: true });
3586
3746
  if (!open) composition.onCompositionEnd();
@@ -3608,7 +3768,7 @@ function KjunSelect({
3608
3768
  "button",
3609
3769
  {
3610
3770
  ref,
3611
- id: field == null ? void 0 : field.id,
3771
+ id: triggerId != null ? triggerId : field == null ? void 0 : field.id,
3612
3772
  type: "button",
3613
3773
  className: "kjun-input kjun-select-trigger",
3614
3774
  "data-time-segment": segment || void 0,
@@ -3616,9 +3776,9 @@ function KjunSelect({
3616
3776
  "aria-haspopup": "listbox",
3617
3777
  "aria-controls": expanded ? id : void 0,
3618
3778
  "aria-expanded": expanded,
3619
- "aria-label": ariaLabel || placeholder,
3779
+ "aria-label": ariaLabel || (triggerId || field ? void 0 : placeholder),
3620
3780
  "aria-labelledby": field == null ? void 0 : field.labelId,
3621
- "aria-describedby": field == null ? void 0 : field.describedBy,
3781
+ "aria-describedby": mergeIds(ariaDescribedBy, field == null ? void 0 : field.describedBy),
3622
3782
  "aria-invalid": error || !!(field == null ? void 0 : field.error) || void 0,
3623
3783
  style: {
3624
3784
  height: spec.height,
@@ -3835,10 +3995,10 @@ function Collapse({ open, children }) {
3835
3995
  }
3836
3996
 
3837
3997
  // shared/package-runtime/navigation.ts
3838
- import { useEffect as useEffect12, useRef as useRef21, useState as useState19 } from "react";
3998
+ import { useEffect as useEffect13, useRef as useRef21, useState as useState19 } from "react";
3839
3999
  function useInitialTab(value, candidate, change) {
3840
4000
  const requested = useRef21(/* @__PURE__ */ new Set());
3841
- useEffect12(() => {
4001
+ useEffect13(() => {
3842
4002
  if (value !== "") {
3843
4003
  requested.current.clear();
3844
4004
  return;
@@ -3850,7 +4010,7 @@ function useInitialTab(value, candidate, change) {
3850
4010
  }
3851
4011
  function useAccordionState(multiple) {
3852
4012
  const [opened, setOpened] = useState19(/* @__PURE__ */ new Set());
3853
- useEffect12(() => {
4013
+ useEffect13(() => {
3854
4014
  if (!multiple) setOpened((previous) => previous.size > 1 ? new Set([...previous].slice(-1)) : previous);
3855
4015
  }, [multiple]);
3856
4016
  return {
@@ -3940,7 +4100,7 @@ import {
3940
4100
  Fragment as Fragment6,
3941
4101
  isValidElement as isValidElement3,
3942
4102
  useContext as useContext12,
3943
- useEffect as useEffect13,
4103
+ useEffect as useEffect14,
3944
4104
  useLayoutEffect as useLayoutEffect12,
3945
4105
  useId as useId10,
3946
4106
  useRef as useRef22,
@@ -3987,7 +4147,7 @@ function KjunTabs({
3987
4147
  clearTimeout(timer.current);
3988
4148
  press.current = null;
3989
4149
  };
3990
- useEffect13(() => clear, []);
4150
+ useEffect14(() => clear, []);
3991
4151
  useLayoutEffect12(() => {
3992
4152
  if (press.current && !canOpenMenu(press.current.name)) clear();
3993
4153
  }, [tabs, onTabMenu]);
@@ -4108,7 +4268,7 @@ function KjunAccordionItem({
4108
4268
  children
4109
4269
  }) {
4110
4270
  const group = useContext12(AccordionContext), id = "kjun-" + useId10(), [own, setOwn] = useState20(defaultOpen), open = group ? group.opened.has(id) : own;
4111
- useEffect13(() => {
4271
+ useEffect14(() => {
4112
4272
  return group == null ? void 0 : group.register(id, defaultOpen);
4113
4273
  }, []);
4114
4274
  return /* @__PURE__ */ jsxs16("div", { className: "kjun-accordion-item", children: [
@@ -4270,7 +4430,7 @@ function KjunPagination({
4270
4430
  import { tokens as tokens21 } from "@kjun-ui/tokens";
4271
4431
  import {
4272
4432
  useContext as useContext13,
4273
- useEffect as useEffect14,
4433
+ useEffect as useEffect15,
4274
4434
  useRef as useRef23,
4275
4435
  useState as useState21
4276
4436
  } from "react";
@@ -4354,7 +4514,7 @@ function KjunCopyButton({
4354
4514
  }) {
4355
4515
  const feedback = useOptionalKjunFeedback();
4356
4516
  const [copied, setCopied] = useState21(false), [failed, setFailed] = useState21(false), busy = useRef23(false), timer = useRef23(void 0), mounted = useRef23(true);
4357
- useEffect14(() => {
4517
+ useEffect15(() => {
4358
4518
  mounted.current = true;
4359
4519
  return () => {
4360
4520
  mounted.current = false;
@@ -4494,7 +4654,7 @@ function KjunScrollFade({ children }) {
4494
4654
  return prev.left === next.left && prev.right === next.right ? prev : next;
4495
4655
  });
4496
4656
  };
4497
- useEffect14(() => {
4657
+ useEffect15(() => {
4498
4658
  update();
4499
4659
  const observer = new ResizeObserver(update);
4500
4660
  if (ref.current) {
@@ -4526,10 +4686,10 @@ import {
4526
4686
  import { Component, useState as useState23 } from "react";
4527
4687
 
4528
4688
  // shared/package-runtime/use-loading-reveal.ts
4529
- import { useEffect as useEffect15, useState as useState22 } from "react";
4689
+ import { useEffect as useEffect16, useState as useState22 } from "react";
4530
4690
  function useLoadingReveal(active, delay = 0) {
4531
4691
  const [revealed, setRevealed] = useState22(false);
4532
- useEffect15(() => {
4692
+ useEffect16(() => {
4533
4693
  setRevealed(false);
4534
4694
  if (!active || delay <= 0) return;
4535
4695
  const timer = setTimeout(() => setRevealed(true), delay);
@@ -5253,7 +5413,7 @@ function KjunSparkline({
5253
5413
 
5254
5414
  // shared/package-runtime/table.ts
5255
5415
  import { nextTableSort } from "@kjun-ui/tokens";
5256
- import { useEffect as useEffect16, useRef as useRef25, useState as useState25 } from "react";
5416
+ import { useEffect as useEffect17, useRef as useRef25, useState as useState25 } from "react";
5257
5417
 
5258
5418
  // shared/package-runtime/table-model.ts
5259
5419
  function getValue(row, key) {
@@ -5301,7 +5461,7 @@ function useTableModel(props) {
5301
5461
  key: "",
5302
5462
  order: "asc"
5303
5463
  }), [internalExpanded, setExpanded] = useState25([]), [search, setSearch] = useState25(""), timer = useRef25(void 0);
5304
- useEffect16(() => () => clearTimeout(timer.current), []);
5464
+ useEffect17(() => () => clearTimeout(timer.current), []);
5305
5465
  const sort = props.sort === void 0 ? internalSort : (_a = props.sort) != null ? _a : { key: "", order: "asc" };
5306
5466
  const rows = sortTableRows(data, sort, { sortable, sortMode });
5307
5467
  const key = (row, index = 0) => tableRowKey(row, rowKey, index);
@@ -5408,7 +5568,7 @@ function TableToolbar({
5408
5568
  selectable && selected.length > 0 && /* @__PURE__ */ jsxs24(
5409
5569
  "div",
5410
5570
  {
5411
- role: "toolbar",
5571
+ role: "group",
5412
5572
  "aria-label": "\uC120\uD0DD \uC791\uC5C5",
5413
5573
  className: "kjun-table-selection",
5414
5574
  children: [
@@ -5696,7 +5856,7 @@ function TableCards({
5696
5856
  }
5697
5857
 
5698
5858
  // packages/react/src/table-view.tsx
5699
- import { useEffect as useEffect17, useState as useState26 } from "react";
5859
+ import { useEffect as useEffect18, useState as useState26 } from "react";
5700
5860
  import { isComposingKey as isComposingKey4, tokens as tokens32 } from "@kjun-ui/tokens";
5701
5861
  import { jsx as jsx34, jsxs as jsxs28 } from "react/jsx-runtime";
5702
5862
  function KjunTable(props) {
@@ -5727,7 +5887,7 @@ function KjunTable(props) {
5727
5887
  onRetry
5728
5888
  } = props;
5729
5889
  const state = useTableModel2(props), query2 = useQueryDisplay(props), revealed = useLoadingReveal(query2.initialLoading, skeleton ? loadingDelay : 0), [mobile, setMobile] = useState26(false);
5730
- useEffect17(() => {
5890
+ useEffect18(() => {
5731
5891
  const media = matchMedia(`(width < ${tokens32.table.mobileBreakpoint}px)`);
5732
5892
  const update = () => setMobile(media.matches);
5733
5893
  update();
@@ -6093,7 +6253,7 @@ function KjunKpiRow({
6093
6253
  import { tokens as tokens34 } from "@kjun-ui/tokens";
6094
6254
 
6095
6255
  // shared/package-runtime/market-cards.ts
6096
- import { useEffect as useEffect18, useRef as useRef26, useState as useState27 } from "react";
6256
+ import { useEffect as useEffect19, useRef as useRef26, useState as useState27 } from "react";
6097
6257
  function useMarketCardsModel(props, persistence) {
6098
6258
  const {
6099
6259
  columns,
@@ -6118,7 +6278,7 @@ function useMarketCardsModel(props, persistence) {
6118
6278
  } catch (e) {
6119
6279
  }
6120
6280
  };
6121
- useEffect18(() => {
6281
+ useEffect19(() => {
6122
6282
  var _a, _b;
6123
6283
  if (mounted.current === restoreSignature) return;
6124
6284
  mounted.current = restoreSignature;
@@ -6454,7 +6614,7 @@ function watchTrailingOverflow(element, onChange) {
6454
6614
  }
6455
6615
 
6456
6616
  // packages/react/src/market-table.tsx
6457
- import { useEffect as useEffect19, useRef as useRef27, useState as useState28 } from "react";
6617
+ import { useEffect as useEffect20, useRef as useRef27, useState as useState28 } from "react";
6458
6618
  import { jsx as jsx40, jsxs as jsxs34 } from "react/jsx-runtime";
6459
6619
  function KjunMarketTable(props) {
6460
6620
  const {
@@ -6476,7 +6636,7 @@ function KjunMarketTable(props) {
6476
6636
  renderCell
6477
6637
  } = props;
6478
6638
  const scroller = useRef27(null), [fadeEnd, setFadeEnd] = useState28(false);
6479
- useEffect19(() => scroller.current ? watchTrailingOverflow(scroller.current, setFadeEnd) : void 0, [rows, columns]);
6639
+ useEffect20(() => scroller.current ? watchTrailingOverflow(scroller.current, setFadeEnd) : void 0, [rows, columns]);
6480
6640
  const render = (row, col) => {
6481
6641
  const value = getValue(row, col.key), stale = !!getValue(row, "stale");
6482
6642
  if (cellLoading(row, col))
@@ -6785,7 +6945,7 @@ function KjunChip({ label, icon, removable = false, disabled = false, size = "md
6785
6945
  }
6786
6946
 
6787
6947
  // packages/react/src/range-input.tsx
6788
- import { useEffect as useEffect20, useRef as useRef29 } from "react";
6948
+ import { useEffect as useEffect21, useRef as useRef29 } from "react";
6789
6949
  import { Slider, SliderTrack, SliderThumb, Label, SliderOutput } from "react-aria-components";
6790
6950
  import { createSliderDomain } from "@kjun-ui/tokens";
6791
6951
  import { Fragment as Fragment18, jsx as jsx45, jsxs as jsxs39 } from "react/jsx-runtime";
@@ -6797,7 +6957,7 @@ function RangeInput({ value, min = 0, max = 100, step = 1, disabled = false, lab
6797
6957
  const latest = useRef29(value);
6798
6958
  latest.current = value;
6799
6959
  const active = useRef29(false);
6800
- useEffect20(() => {
6960
+ useEffect21(() => {
6801
6961
  if (!valid) console.warn("KJUN Slider: \uBC94\uC704\xB7step\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
6802
6962
  }, [valid]);
6803
6963
  const change = (next) => {
@@ -6834,7 +6994,7 @@ function KjunRangeSlider(props) {
6834
6994
  }
6835
6995
 
6836
6996
  // packages/react/src/quantity-stepper.tsx
6837
- import { useEffect as useEffect21, useRef as useRef30, useState as useState30 } from "react";
6997
+ import { useEffect as useEffect22, useRef as useRef30, useState as useState30 } from "react";
6838
6998
  import { createNumberDomain, quantityKeyAction, tokens as tokens41 } from "@kjun-ui/tokens";
6839
6999
  import { jsx as jsx46, jsxs as jsxs40 } from "react/jsx-runtime";
6840
7000
  function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, disabled = false, error = false, size = "md", block = false, id, ariaLabel, onValueChange, onChangeCommit, onInvalidInput }) {
@@ -6845,12 +7005,12 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
6845
7005
  const [draft, setDraft] = useState30(String(value));
6846
7006
  const field = useKjunField();
6847
7007
  const composing = useRef30(false), dirty = useRef30(false), accepted = useRef30(value);
6848
- useEffect21(() => {
7008
+ useEffect22(() => {
6849
7009
  setDraft(String(value));
6850
7010
  accepted.current = value;
6851
7011
  dirty.current = false;
6852
7012
  }, [value, precision, min, max, step]);
6853
- useEffect21(() => {
7013
+ useEffect22(() => {
6854
7014
  if (!valid) console.warn("KJUN QuantityStepper: \uBC94\uC704\xB7step\xB7\uC815\uBC00\uB3C4\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
6855
7015
  }, [valid]);
6856
7016
  const emit = (next) => {
@@ -6925,7 +7085,7 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
6925
7085
  }
6926
7086
 
6927
7087
  // packages/react/src/time-picker.tsx
6928
- import { Fragment as Fragment19, useEffect as useEffect22, useId as useId13, useMemo as useMemo2, useRef as useRef31 } from "react";
7088
+ import { Fragment as Fragment19, useEffect as useEffect23, useId as useId13, useMemo as useMemo2, useRef as useRef31 } from "react";
6929
7089
  import { createTimeDomain } from "@kjun-ui/tokens";
6930
7090
  import { jsx as jsx47, jsxs as jsxs41 } from "react/jsx-runtime";
6931
7091
  function KjunTimePicker({ value, precision = "minute", min, max, minuteStep = 1, secondStep = 1, disabled = false, error = false, clearable = true, size = "md", ariaLabel = "\uC2DC\uAC04", onValueChange, onChangeCommit }) {
@@ -6934,7 +7094,7 @@ function KjunTimePicker({ value, precision = "minute", min, max, minuteStep = 1,
6934
7094
  const fieldId = (field == null ? void 0 : field.id) || `kjun-time-${uid}`;
6935
7095
  const domain = useMemo2(() => createTimeDomain({ precision, min, max, minuteStep, secondStep }), [precision, min, max, minuteStep, secondStep]);
6936
7096
  const valid = domain.valid && domain.accepts(value);
6937
- useEffect22(() => {
7097
+ useEffect23(() => {
6938
7098
  if (!valid) console.warn("KJUN TimePicker: \uC2DC\uAC01 \uBC94\uC704\xB7\uAC04\uACA9\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
6939
7099
  }, [valid]);
6940
7100
  const change = (next) => {