@kjun-ui/react 0.8.0 → 0.9.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.cjs CHANGED
@@ -233,6 +233,10 @@ function installLayerKeyboard(document2, state, keyupFallback = false) {
233
233
  var import_react2 = require("react");
234
234
 
235
235
  // shared/package-runtime/layer-state.ts
236
+ function chooseReturnTarget(chosen, fallback2) {
237
+ if (chosen === false) return void 0;
238
+ return chosen && chosen.isConnected !== false ? chosen : fallback2;
239
+ }
236
240
  function createLayerState() {
237
241
  const entries = /* @__PURE__ */ new Map(), listeners = /* @__PURE__ */ new Set();
238
242
  const restoredFocus = /* @__PURE__ */ new WeakSet();
@@ -253,6 +257,7 @@ function createLayerState() {
253
257
  return !layer.blocked && (layer.kind === "window" ? ((_a = topWindow()) == null ? void 0 : _a.id) === layer.id : ((_b = topWindow()) == null ? void 0 : _b.id) === layer.owner);
254
258
  };
255
259
  const top = () => [...entries.values()].filter(active).sort((a, b) => a.order - b.order).at(-1);
260
+ const topPopup = () => [...entries.values()].filter((layer) => layer.kind !== "tooltip" && active(layer)).sort((a, b) => a.order - b.order).at(-1);
256
261
  function dismiss(layer) {
257
262
  if (layer.closeRequested) return;
258
263
  layer.closeRequested = true;
@@ -272,6 +277,7 @@ function createLayerState() {
272
277
  entries,
273
278
  topWindow,
274
279
  top,
280
+ topPopup,
275
281
  windowOf,
276
282
  isRestoredFocus(target) {
277
283
  return !!target && restoredFocus.has(target);
@@ -415,21 +421,31 @@ function focusTrigger(target) {
415
421
  }
416
422
  return target;
417
423
  }
418
- function restoreFocus(target, state, id) {
424
+ function restoreFocus(target, state, id, fallback2) {
425
+ const usable = (item) => (item == null ? void 0 : item.isConnected) !== false && !(typeof HTMLElement !== "undefined" && item instanceof HTMLElement && item.closest("[inert]"));
419
426
  const restore = () => {
420
- var _a, _b, _c, _d;
427
+ var _a, _b, _c, _d, _e;
421
428
  if (state.entries.has(id)) return;
422
- if ((target == null ? void 0 : target.isConnected) !== false && !(typeof HTMLElement !== "undefined" && target instanceof HTMLElement && target.closest("[inert]"))) (_a = target == null ? void 0 : target.focus) == null ? void 0 : _a.call(target, { preventScroll: true });
423
- else (_d = (_c = (_b = state.topWindow()) == null ? void 0 : _b.root) == null ? void 0 : _c.focus) == null ? void 0 : _d.call(_c, { preventScroll: true });
429
+ if (usable(target)) (_a = target == null ? void 0 : target.focus) == null ? void 0 : _a.call(target, { preventScroll: true });
430
+ else if (fallback2 && fallback2 !== target && usable(fallback2)) (_b = fallback2.focus) == null ? void 0 : _b.call(fallback2, { preventScroll: true });
431
+ else (_e = (_d = (_c = state.topWindow()) == null ? void 0 : _c.root) == null ? void 0 : _d.focus) == null ? void 0 : _e.call(_d, { preventScroll: true });
424
432
  };
425
433
  if (typeof requestAnimationFrame !== "undefined") requestAnimationFrame(restore);
426
434
  else queueMicrotask(restore);
427
435
  }
428
- function useLayer(open, present, kind, close, trigger) {
436
+ function useLayer(open, present, kind, close, trigger, returnFocus) {
429
437
  var _a;
430
438
  const state = useLayerState(), parent = (0, import_react2.useContext)(LayerScope), id = (0, import_react2.useId)();
431
439
  const callback = (0, import_react2.useRef)(close);
432
440
  callback.current = close;
441
+ const returnRef = (0, import_react2.useRef)(returnFocus);
442
+ returnRef.current = returnFocus;
443
+ const fallbackFocus = (0, import_react2.useRef)(null);
444
+ const removeLayer = () => {
445
+ const removed = state.remove(id, currentFocus());
446
+ if (removed) fallbackFocus.current = removed;
447
+ return removed && returnRef.current ? chooseReturnTarget(returnRef.current(), removed) : removed;
448
+ };
433
449
  const openingFocus = (0, import_react2.useRef)(null);
434
450
  const wasOpen = (0, import_react2.useRef)(false);
435
451
  const pendingFocus = (0, import_react2.useRef)(null);
@@ -441,17 +457,17 @@ function useLayer(open, present, kind, close, trigger) {
441
457
  state.open(id, kind, parent, () => callback.current(), focusTrigger(trigger == null ? void 0 : trigger.current) || openingFocus.current);
442
458
  } else if (kind === "window" && present) state.markClosing(id);
443
459
  else if (kind !== "window" || !present) {
444
- const target = state.remove(id, currentFocus());
460
+ const target = removeLayer();
445
461
  if (target) pendingFocus.current = target;
446
462
  if (!present && pendingFocus.current) {
447
- restoreFocus(pendingFocus.current, state, id);
463
+ restoreFocus(pendingFocus.current, state, id, fallbackFocus.current);
448
464
  pendingFocus.current = null;
449
465
  }
450
466
  }
451
467
  }, [open, present, state, id, kind, parent, trigger]);
452
468
  (0, import_react2.useLayoutEffect)(() => () => {
453
- const target = state.remove(id, currentFocus());
454
- if (target || pendingFocus.current) restoreFocus(target || pendingFocus.current, state, id);
469
+ const target = removeLayer();
470
+ if (target || pendingFocus.current) restoreFocus(target || pendingFocus.current, state, id, fallbackFocus.current);
455
471
  }, [state, id]);
456
472
  const entry = state.entries.get(id);
457
473
  return {
@@ -2283,7 +2299,8 @@ function KjunRadioGroup({
2283
2299
  style: {
2284
2300
  display: "flex",
2285
2301
  flexDirection: direction === "vertical" ? "column" : "row",
2286
- flexWrap: "wrap",
2302
+ // A wrapping column would split into extra columns whenever the group's height is fixed.
2303
+ flexWrap: direction === "vertical" ? "nowrap" : "wrap",
2287
2304
  gap: direction === "vertical" ? import_tokens16.tokens.dimension.value8 : import_tokens16.tokens.dimension.value16
2288
2305
  },
2289
2306
  children: children || options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -2488,10 +2505,11 @@ function FloatingPanel({
2488
2505
  maxHeight,
2489
2506
  field = false,
2490
2507
  flip = true,
2491
- nonModal = false
2508
+ nonModal = false,
2509
+ returnFocus
2492
2510
  }) {
2493
2511
  const motion = usePresence(open, useReducedMotion(), import_tokens17.tokens.motion.popupExit);
2494
- const layer = useLayer(open, motion.present, "popup", () => onOpenChange(false), triggerRef);
2512
+ const layer = useLayer(open, motion.present, "popup", () => onOpenChange(false), triggerRef, returnFocus);
2495
2513
  const container = useKjunPortalContainer();
2496
2514
  const panel = (0, import_react23.useRef)(null);
2497
2515
  (0, import_react23.useEffect)(() => {
@@ -2556,6 +2574,7 @@ function KjunPopover({
2556
2574
  focusOnOpen = false,
2557
2575
  ariaLabel,
2558
2576
  placement = "bottom",
2577
+ returnFocus,
2559
2578
  trigger,
2560
2579
  children
2561
2580
  }) {
@@ -2566,6 +2585,7 @@ function KjunPopover({
2566
2585
  const focusContent = (0, import_react24.useCallback)((node) => {
2567
2586
  if (node && focusOnMount.current) node.focus();
2568
2587
  }, []);
2588
+ const resolveReturn = returnFocus === void 0 ? void 0 : () => typeof returnFocus === "function" ? returnFocus() : returnFocus instanceof HTMLElement ? returnFocus : returnFocus.current;
2569
2589
  const change = (v) => {
2570
2590
  setInternal(v);
2571
2591
  onOpenChange == null ? void 0 : onOpenChange(v);
@@ -2602,6 +2622,7 @@ function KjunPopover({
2602
2622
  matchTriggerWidth,
2603
2623
  maxHeight,
2604
2624
  flip,
2625
+ returnFocus: resolveReturn,
2605
2626
  children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2606
2627
  import_react_aria_components4.Dialog,
2607
2628
  {
@@ -2981,6 +3002,17 @@ function nextOptionValue(value, option, key, multiple) {
2981
3002
  if (!multiple) return id;
2982
3003
  return Array.isArray(value) && value.includes(id) ? value.filter((item) => item !== id) : [...Array.isArray(value) ? value : [], id];
2983
3004
  }
3005
+ function optionMatchRank(option, query2, labelKey, searchKeys = []) {
3006
+ const needle = query2.trim().toLocaleLowerCase();
3007
+ if (!needle) return 0;
3008
+ const label = optionLabel(option, labelKey).toLocaleLowerCase();
3009
+ if (label.startsWith(needle)) return 0;
3010
+ if (label.includes(needle)) return 1;
3011
+ return typeof option === "object" && searchKeys.some((key) => {
3012
+ var _a;
3013
+ return String((_a = option[key]) != null ? _a : "").toLocaleLowerCase().includes(needle);
3014
+ }) ? 2 : -1;
3015
+ }
2984
3016
  function selectOptions({
2985
3017
  options,
2986
3018
  value,
@@ -2990,10 +3022,13 @@ function selectOptions({
2990
3022
  pageSize,
2991
3023
  limit,
2992
3024
  loading,
2993
- multiple
3025
+ multiple,
3026
+ filterFn,
3027
+ searchKeys = []
2994
3028
  }) {
2995
3029
  const selected = (option) => optionSelected(value, option, valueKey);
2996
- const matching = options.map((option, index) => ({ option, key: optionKey(option, valueKey, index) })).filter(({ option }) => optionLabel(option, labelKey).toLocaleLowerCase().includes(query2.trim().toLocaleLowerCase()));
3030
+ const indexed = options.map((option, index) => ({ option, key: optionKey(option, valueKey, index) }));
3031
+ const matching = filterFn ? indexed.filter(({ option }) => filterFn(option, query2)) : indexed.map((item, index) => ({ item, index, rank: optionMatchRank(item.option, query2, labelKey, searchKeys) })).filter(({ rank }) => rank >= 0).sort((a, b) => a.rank - b.rank || a.index - b.index).map(({ item }) => item);
2997
3032
  const visible = loading ? [] : pageSize > 0 ? matching.slice(0, limit) : matching;
2998
3033
  const selectedOption = options.find(selected);
2999
3034
  const label = multiple && Array.isArray(value) && value.length > 1 ? `${value.length}\uAC1C \uC120\uD0DD\uB428` : selectedOption !== void 0 ? optionLabel(selectedOption, labelKey) : "";
@@ -3592,7 +3627,9 @@ function KjunSelect({
3592
3627
  onChange,
3593
3628
  onOpenChange,
3594
3629
  onSearch,
3595
- onClear
3630
+ onClear,
3631
+ filterFn,
3632
+ searchKeys
3596
3633
  }) {
3597
3634
  const { open, query: query2, limit, session, changeOpen, search, showMore } = useSelectState(controlled, disabled, optionPageSize, onOpenChange);
3598
3635
  const composition = useCompositionGuard();
@@ -3618,7 +3655,9 @@ function KjunSelect({
3618
3655
  pageSize: optionPageSize,
3619
3656
  limit,
3620
3657
  loading,
3621
- multiple
3658
+ multiple,
3659
+ filterFn,
3660
+ searchKeys
3622
3661
  });
3623
3662
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
3624
3663
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "kjun-select-shell", children: [
@@ -4434,7 +4473,7 @@ function KjunRefreshButton({
4434
4473
  }) {
4435
4474
  var _a;
4436
4475
  const reduced = useReducedMotion();
4437
- const label = ariaLabel || [targetName, "\uC0C8\uB85C\uACE0\uCE68"].filter(Boolean).join(" ");
4476
+ const label = ariaLabel || [targetName, mode === "text" ? text : "\uC0C8\uB85C\uACE0\uCE68"].filter(Boolean).join(" ");
4438
4477
  const hint = (_a = tooltip != null ? tooltip : title) != null ? _a : mode === "icon" ? label : "";
4439
4478
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(KjunTooltip, { content: props.disabled || props.loading ? "" : hint, placement: tooltipPlacement, delay: tooltipDelay, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4440
4479
  KjunButton,
@@ -4574,13 +4613,14 @@ function KjunDataState({
4574
4613
  }) {
4575
4614
  const state = useQueryDisplay(query2), blockingError = query2.error && !(state.usesQueryState && state.hasCurrentResult), visibleRefreshError = refreshError || (state.usesQueryState && state.hasCurrentResult ? query2.error : null), concealed = state.initialLoading || !!blockingError || empty, padding = import_tokens26.tokens.extensions.state.padding[size], revealed = useLoadingReveal(state.initialLoading, loadingDelay);
4576
4615
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "kjun-data-state", "aria-busy": !!query2.loading || refreshing, children: [
4577
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: (refreshing || state.queryRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "kjun-data-status", role: "status", children: [
4616
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "kjun-data-status-slot", children: (refreshing || state.queryRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "kjun-data-status", role: "status", children: [
4578
4617
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KjunSpinner, { size: "xs" }),
4579
4618
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: refreshingText })
4580
4619
  ] }) }),
4581
4620
  state.initialLoading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4582
4621
  "div",
4583
4622
  {
4623
+ className: "kjun-data-loading-block",
4584
4624
  role: revealed ? "status" : void 0,
4585
4625
  "aria-label": revealed ? loadingText : void 0,
4586
4626
  "aria-hidden": revealed ? void 0 : true,
@@ -4590,11 +4630,11 @@ function KjunDataState({
4590
4630
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { children: loadingText })
4591
4631
  ] }))
4592
4632
  }
4593
- ) : blockingError ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "kjun-state-actions", style: { paddingBlock: padding }, children: errorContent || /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KjunAlert, { type: "danger", title: "\uC624\uB958 \uBC1C\uC0DD", actions: onRetry && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KjunButton, { variant: "secondary", onClick: onRetry, children: retryText }), children: query2.error }) }) : empty ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "kjun-data-empty kjun-state-actions", style: { paddingBlock: padding }, children: emptyContent || /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KjunEmpty, { text: emptyText, icon: emptyIcon, children: emptyActionText && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KjunButton, { onClick: onEmptyAction, children: emptyActionText }) }) }) : null,
4633
+ ) : blockingError ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "kjun-data-error kjun-state-actions", style: { paddingBlock: padding }, children: errorContent || /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KjunAlert, { type: "danger", title: "\uC624\uB958 \uBC1C\uC0DD", actions: onRetry && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KjunButton, { variant: "secondary", onClick: onRetry, children: retryText }), children: query2.error }) }) : empty ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "kjun-data-empty kjun-state-actions", style: { paddingBlock: padding }, children: emptyContent || /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KjunEmpty, { text: emptyText, icon: emptyIcon, children: emptyActionText && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KjunButton, { onClick: onEmptyAction, children: emptyActionText }) }) }) : null,
4594
4634
  (!concealed || preserveContent && state.hasQueryResult) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4595
4635
  "div",
4596
4636
  {
4597
- className: concealed ? "kjun-data-concealed" : void 0,
4637
+ className: "kjun-data-content" + (concealed ? " kjun-data-concealed" : ""),
4598
4638
  "aria-hidden": concealed || void 0,
4599
4639
  inert: concealed || void 0,
4600
4640
  style: {
@@ -4654,6 +4694,9 @@ function chartSkeletonCount(value) {
4654
4694
  function chartMatrixMuted(row, column) {
4655
4695
  return (row + column + 2) % 3 === 0;
4656
4696
  }
4697
+ function chartSkeletonKind(kind) {
4698
+ return kind === "donut" || kind === "matrix" ? kind : "frame";
4699
+ }
4657
4700
 
4658
4701
  // packages/react/src/market-skeleton.tsx
4659
4702
  var import_tokens28 = require("@kjun-ui/tokens");
@@ -4772,7 +4815,7 @@ function KjunFormSkeleton({
4772
4815
  );
4773
4816
  }
4774
4817
  function KjunChartSkeleton({
4775
- kind = "frame",
4818
+ kind: requestedKind = "frame",
4776
4819
  height = import_tokens29.tokens.extensions.chartSkeleton.height,
4777
4820
  loadingText = "\uCC28\uD2B8\uB97C \uBD88\uB7EC\uC624\uB294 \uC911",
4778
4821
  skeleton = true,
@@ -4780,7 +4823,7 @@ function KjunChartSkeleton({
4780
4823
  rows = 8,
4781
4824
  columns = 14
4782
4825
  }) {
4783
- const revealed = useLoadingReveal(true, loadingDelay), status = revealed && loadingText ? "status" : void 0, rowCount = chartSkeletonCount(rows), columnCount = chartSkeletonCount(columns);
4826
+ const kind = chartSkeletonKind(requestedKind), revealed = useLoadingReveal(true, loadingDelay), status = revealed && loadingText ? "status" : void 0, rowCount = chartSkeletonCount(rows), columnCount = chartSkeletonCount(columns);
4784
4827
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4785
4828
  "div",
4786
4829
  {
@@ -5365,9 +5408,18 @@ function tablePresentation(props, mobile) {
5365
5408
  }
5366
5409
  };
5367
5410
  }
5411
+ var warnedFormats = /* @__PURE__ */ new Set();
5412
+ function columnFormat(column) {
5413
+ if (typeof column.format === "function") return column.format;
5414
+ if (column.format != null && !warnedFormats.has(column.key)) {
5415
+ warnedFormats.add(column.key);
5416
+ console.warn(`KJUN Table: ${column.key} \uC5F4\uC758 format\uC740 \uD568\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4.`);
5417
+ }
5418
+ return void 0;
5419
+ }
5368
5420
  function tableCellValue(props, column, row, index) {
5369
5421
  const value = getValue(row, column.key);
5370
- const body = props.renderCell ? props.renderCell(value, column, row, index) : column.render ? column.render(value, row, index) : column.format ? column.format(value, row) : props.formatValue ? props.formatValue(value, column, row) : value == null ? "-" : typeof value === "number" && column.type === "number" ? new Intl.NumberFormat().format(value) : String(value);
5422
+ const body = props.renderCell ? props.renderCell(value, column, row, index) : column.render ? column.render(value, row, index) : columnFormat(column) ? columnFormat(column)(value, row) : props.formatValue ? props.formatValue(value, column, row) : value == null ? "-" : typeof value === "number" && column.type === "number" ? new Intl.NumberFormat().format(value) : String(value);
5371
5423
  return { value, body };
5372
5424
  }
5373
5425
 
package/dist/index.js CHANGED
@@ -119,6 +119,10 @@ function installLayerKeyboard(document2, state, keyupFallback = false) {
119
119
  import { createContext as createContext2, useContext as useContext2, useId, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
120
120
 
121
121
  // shared/package-runtime/layer-state.ts
122
+ function chooseReturnTarget(chosen, fallback2) {
123
+ if (chosen === false) return void 0;
124
+ return chosen && chosen.isConnected !== false ? chosen : fallback2;
125
+ }
122
126
  function createLayerState() {
123
127
  const entries = /* @__PURE__ */ new Map(), listeners = /* @__PURE__ */ new Set();
124
128
  const restoredFocus = /* @__PURE__ */ new WeakSet();
@@ -139,6 +143,7 @@ function createLayerState() {
139
143
  return !layer.blocked && (layer.kind === "window" ? ((_a = topWindow()) == null ? void 0 : _a.id) === layer.id : ((_b = topWindow()) == null ? void 0 : _b.id) === layer.owner);
140
144
  };
141
145
  const top = () => [...entries.values()].filter(active).sort((a, b) => a.order - b.order).at(-1);
146
+ const topPopup = () => [...entries.values()].filter((layer) => layer.kind !== "tooltip" && active(layer)).sort((a, b) => a.order - b.order).at(-1);
142
147
  function dismiss(layer) {
143
148
  if (layer.closeRequested) return;
144
149
  layer.closeRequested = true;
@@ -158,6 +163,7 @@ function createLayerState() {
158
163
  entries,
159
164
  topWindow,
160
165
  top,
166
+ topPopup,
161
167
  windowOf,
162
168
  isRestoredFocus(target) {
163
169
  return !!target && restoredFocus.has(target);
@@ -301,21 +307,31 @@ function focusTrigger(target) {
301
307
  }
302
308
  return target;
303
309
  }
304
- function restoreFocus(target, state, id) {
310
+ function restoreFocus(target, state, id, fallback2) {
311
+ const usable = (item) => (item == null ? void 0 : item.isConnected) !== false && !(typeof HTMLElement !== "undefined" && item instanceof HTMLElement && item.closest("[inert]"));
305
312
  const restore = () => {
306
- var _a, _b, _c, _d;
313
+ var _a, _b, _c, _d, _e;
307
314
  if (state.entries.has(id)) return;
308
- if ((target == null ? void 0 : target.isConnected) !== false && !(typeof HTMLElement !== "undefined" && target instanceof HTMLElement && target.closest("[inert]"))) (_a = target == null ? void 0 : target.focus) == null ? void 0 : _a.call(target, { preventScroll: true });
309
- else (_d = (_c = (_b = state.topWindow()) == null ? void 0 : _b.root) == null ? void 0 : _c.focus) == null ? void 0 : _d.call(_c, { preventScroll: true });
315
+ if (usable(target)) (_a = target == null ? void 0 : target.focus) == null ? void 0 : _a.call(target, { preventScroll: true });
316
+ else if (fallback2 && fallback2 !== target && usable(fallback2)) (_b = fallback2.focus) == null ? void 0 : _b.call(fallback2, { preventScroll: true });
317
+ else (_e = (_d = (_c = state.topWindow()) == null ? void 0 : _c.root) == null ? void 0 : _d.focus) == null ? void 0 : _e.call(_d, { preventScroll: true });
310
318
  };
311
319
  if (typeof requestAnimationFrame !== "undefined") requestAnimationFrame(restore);
312
320
  else queueMicrotask(restore);
313
321
  }
314
- function useLayer(open, present, kind, close, trigger) {
322
+ function useLayer(open, present, kind, close, trigger, returnFocus) {
315
323
  var _a;
316
324
  const state = useLayerState(), parent = useContext2(LayerScope), id = useId();
317
325
  const callback = useRef(close);
318
326
  callback.current = close;
327
+ const returnRef = useRef(returnFocus);
328
+ returnRef.current = returnFocus;
329
+ const fallbackFocus = useRef(null);
330
+ const removeLayer = () => {
331
+ const removed = state.remove(id, currentFocus());
332
+ if (removed) fallbackFocus.current = removed;
333
+ return removed && returnRef.current ? chooseReturnTarget(returnRef.current(), removed) : removed;
334
+ };
319
335
  const openingFocus = useRef(null);
320
336
  const wasOpen = useRef(false);
321
337
  const pendingFocus = useRef(null);
@@ -327,17 +343,17 @@ function useLayer(open, present, kind, close, trigger) {
327
343
  state.open(id, kind, parent, () => callback.current(), focusTrigger(trigger == null ? void 0 : trigger.current) || openingFocus.current);
328
344
  } else if (kind === "window" && present) state.markClosing(id);
329
345
  else if (kind !== "window" || !present) {
330
- const target = state.remove(id, currentFocus());
346
+ const target = removeLayer();
331
347
  if (target) pendingFocus.current = target;
332
348
  if (!present && pendingFocus.current) {
333
- restoreFocus(pendingFocus.current, state, id);
349
+ restoreFocus(pendingFocus.current, state, id, fallbackFocus.current);
334
350
  pendingFocus.current = null;
335
351
  }
336
352
  }
337
353
  }, [open, present, state, id, kind, parent, trigger]);
338
354
  useLayoutEffect(() => () => {
339
- const target = state.remove(id, currentFocus());
340
- if (target || pendingFocus.current) restoreFocus(target || pendingFocus.current, state, id);
355
+ const target = removeLayer();
356
+ if (target || pendingFocus.current) restoreFocus(target || pendingFocus.current, state, id, fallbackFocus.current);
341
357
  }, [state, id]);
342
358
  const entry = state.entries.get(id);
343
359
  return {
@@ -2214,7 +2230,8 @@ function KjunRadioGroup({
2214
2230
  style: {
2215
2231
  display: "flex",
2216
2232
  flexDirection: direction === "vertical" ? "column" : "row",
2217
- flexWrap: "wrap",
2233
+ // A wrapping column would split into extra columns whenever the group's height is fixed.
2234
+ flexWrap: direction === "vertical" ? "nowrap" : "wrap",
2218
2235
  gap: direction === "vertical" ? tokens12.dimension.value8 : tokens12.dimension.value16
2219
2236
  },
2220
2237
  children: children || options.map((option) => /* @__PURE__ */ jsx12(
@@ -2419,10 +2436,11 @@ function FloatingPanel({
2419
2436
  maxHeight,
2420
2437
  field = false,
2421
2438
  flip = true,
2422
- nonModal = false
2439
+ nonModal = false,
2440
+ returnFocus
2423
2441
  }) {
2424
2442
  const motion = usePresence(open, useReducedMotion(), tokens13.motion.popupExit);
2425
- const layer = useLayer(open, motion.present, "popup", () => onOpenChange(false), triggerRef);
2443
+ const layer = useLayer(open, motion.present, "popup", () => onOpenChange(false), triggerRef, returnFocus);
2426
2444
  const container = useKjunPortalContainer();
2427
2445
  const panel = useRef13(null);
2428
2446
  useEffect5(() => {
@@ -2487,6 +2505,7 @@ function KjunPopover({
2487
2505
  focusOnOpen = false,
2488
2506
  ariaLabel,
2489
2507
  placement = "bottom",
2508
+ returnFocus,
2490
2509
  trigger,
2491
2510
  children
2492
2511
  }) {
@@ -2497,6 +2516,7 @@ function KjunPopover({
2497
2516
  const focusContent = useCallback2((node) => {
2498
2517
  if (node && focusOnMount.current) node.focus();
2499
2518
  }, []);
2519
+ const resolveReturn = returnFocus === void 0 ? void 0 : () => typeof returnFocus === "function" ? returnFocus() : returnFocus instanceof HTMLElement ? returnFocus : returnFocus.current;
2500
2520
  const change = (v) => {
2501
2521
  setInternal(v);
2502
2522
  onOpenChange == null ? void 0 : onOpenChange(v);
@@ -2533,6 +2553,7 @@ function KjunPopover({
2533
2553
  matchTriggerWidth,
2534
2554
  maxHeight,
2535
2555
  flip,
2556
+ returnFocus: resolveReturn,
2536
2557
  children: /* @__PURE__ */ jsxs10(
2537
2558
  Dialog2,
2538
2559
  {
@@ -2912,6 +2933,17 @@ function nextOptionValue(value, option, key, multiple) {
2912
2933
  if (!multiple) return id;
2913
2934
  return Array.isArray(value) && value.includes(id) ? value.filter((item) => item !== id) : [...Array.isArray(value) ? value : [], id];
2914
2935
  }
2936
+ function optionMatchRank(option, query2, labelKey, searchKeys = []) {
2937
+ const needle = query2.trim().toLocaleLowerCase();
2938
+ if (!needle) return 0;
2939
+ const label = optionLabel(option, labelKey).toLocaleLowerCase();
2940
+ if (label.startsWith(needle)) return 0;
2941
+ if (label.includes(needle)) return 1;
2942
+ return typeof option === "object" && searchKeys.some((key) => {
2943
+ var _a;
2944
+ return String((_a = option[key]) != null ? _a : "").toLocaleLowerCase().includes(needle);
2945
+ }) ? 2 : -1;
2946
+ }
2915
2947
  function selectOptions({
2916
2948
  options,
2917
2949
  value,
@@ -2921,10 +2953,13 @@ function selectOptions({
2921
2953
  pageSize,
2922
2954
  limit,
2923
2955
  loading,
2924
- multiple
2956
+ multiple,
2957
+ filterFn,
2958
+ searchKeys = []
2925
2959
  }) {
2926
2960
  const selected = (option) => optionSelected(value, option, valueKey);
2927
- const matching = options.map((option, index) => ({ option, key: optionKey(option, valueKey, index) })).filter(({ option }) => optionLabel(option, labelKey).toLocaleLowerCase().includes(query2.trim().toLocaleLowerCase()));
2961
+ const indexed = options.map((option, index) => ({ option, key: optionKey(option, valueKey, index) }));
2962
+ const matching = filterFn ? indexed.filter(({ option }) => filterFn(option, query2)) : indexed.map((item, index) => ({ item, index, rank: optionMatchRank(item.option, query2, labelKey, searchKeys) })).filter(({ rank }) => rank >= 0).sort((a, b) => a.rank - b.rank || a.index - b.index).map(({ item }) => item);
2928
2963
  const visible = loading ? [] : pageSize > 0 ? matching.slice(0, limit) : matching;
2929
2964
  const selectedOption = options.find(selected);
2930
2965
  const label = multiple && Array.isArray(value) && value.length > 1 ? `${value.length}\uAC1C \uC120\uD0DD\uB428` : selectedOption !== void 0 ? optionLabel(selectedOption, labelKey) : "";
@@ -3535,7 +3570,9 @@ function KjunSelect({
3535
3570
  onChange,
3536
3571
  onOpenChange,
3537
3572
  onSearch,
3538
- onClear
3573
+ onClear,
3574
+ filterFn,
3575
+ searchKeys
3539
3576
  }) {
3540
3577
  const { open, query: query2, limit, session, changeOpen, search, showMore } = useSelectState(controlled, disabled, optionPageSize, onOpenChange);
3541
3578
  const composition = useCompositionGuard();
@@ -3561,7 +3598,9 @@ function KjunSelect({
3561
3598
  pageSize: optionPageSize,
3562
3599
  limit,
3563
3600
  loading,
3564
- multiple
3601
+ multiple,
3602
+ filterFn,
3603
+ searchKeys
3565
3604
  });
3566
3605
  return /* @__PURE__ */ jsxs15(Fragment5, { children: [
3567
3606
  /* @__PURE__ */ jsxs15("div", { className: "kjun-select-shell", children: [
@@ -4393,7 +4432,7 @@ function KjunRefreshButton({
4393
4432
  }) {
4394
4433
  var _a;
4395
4434
  const reduced = useReducedMotion();
4396
- const label = ariaLabel || [targetName, "\uC0C8\uB85C\uACE0\uCE68"].filter(Boolean).join(" ");
4435
+ const label = ariaLabel || [targetName, mode === "text" ? text : "\uC0C8\uB85C\uACE0\uCE68"].filter(Boolean).join(" ");
4397
4436
  const hint = (_a = tooltip != null ? tooltip : title) != null ? _a : mode === "icon" ? label : "";
4398
4437
  return /* @__PURE__ */ jsx23(KjunTooltip, { content: props.disabled || props.loading ? "" : hint, placement: tooltipPlacement, delay: tooltipDelay, children: /* @__PURE__ */ jsx23(
4399
4438
  KjunButton,
@@ -4538,13 +4577,14 @@ function KjunDataState({
4538
4577
  }) {
4539
4578
  const state = useQueryDisplay(query2), blockingError = query2.error && !(state.usesQueryState && state.hasCurrentResult), visibleRefreshError = refreshError || (state.usesQueryState && state.hasCurrentResult ? query2.error : null), concealed = state.initialLoading || !!blockingError || empty, padding = tokens22.extensions.state.padding[size], revealed = useLoadingReveal(state.initialLoading, loadingDelay);
4540
4579
  return /* @__PURE__ */ jsxs18("div", { className: "kjun-data-state", "aria-busy": !!query2.loading || refreshing, children: [
4541
- /* @__PURE__ */ jsx24("div", { children: (refreshing || state.queryRefreshing) && /* @__PURE__ */ jsxs18("div", { className: "kjun-data-status", role: "status", children: [
4580
+ /* @__PURE__ */ jsx24("div", { className: "kjun-data-status-slot", children: (refreshing || state.queryRefreshing) && /* @__PURE__ */ jsxs18("div", { className: "kjun-data-status", role: "status", children: [
4542
4581
  /* @__PURE__ */ jsx24(KjunSpinner, { size: "xs" }),
4543
4582
  /* @__PURE__ */ jsx24("span", { children: refreshingText })
4544
4583
  ] }) }),
4545
4584
  state.initialLoading ? /* @__PURE__ */ jsx24(
4546
4585
  "div",
4547
4586
  {
4587
+ className: "kjun-data-loading-block",
4548
4588
  role: revealed ? "status" : void 0,
4549
4589
  "aria-label": revealed ? loadingText : void 0,
4550
4590
  "aria-hidden": revealed ? void 0 : true,
@@ -4554,11 +4594,11 @@ function KjunDataState({
4554
4594
  /* @__PURE__ */ jsx24("p", { children: loadingText })
4555
4595
  ] }))
4556
4596
  }
4557
- ) : blockingError ? /* @__PURE__ */ jsx24("div", { className: "kjun-state-actions", style: { paddingBlock: padding }, children: errorContent || /* @__PURE__ */ jsx24(KjunAlert, { type: "danger", title: "\uC624\uB958 \uBC1C\uC0DD", actions: onRetry && /* @__PURE__ */ jsx24(KjunButton, { variant: "secondary", onClick: onRetry, children: retryText }), children: query2.error }) }) : empty ? /* @__PURE__ */ jsx24("div", { className: "kjun-data-empty kjun-state-actions", style: { paddingBlock: padding }, children: emptyContent || /* @__PURE__ */ jsx24(KjunEmpty, { text: emptyText, icon: emptyIcon, children: emptyActionText && /* @__PURE__ */ jsx24(KjunButton, { onClick: onEmptyAction, children: emptyActionText }) }) }) : null,
4597
+ ) : blockingError ? /* @__PURE__ */ jsx24("div", { className: "kjun-data-error kjun-state-actions", style: { paddingBlock: padding }, children: errorContent || /* @__PURE__ */ jsx24(KjunAlert, { type: "danger", title: "\uC624\uB958 \uBC1C\uC0DD", actions: onRetry && /* @__PURE__ */ jsx24(KjunButton, { variant: "secondary", onClick: onRetry, children: retryText }), children: query2.error }) }) : empty ? /* @__PURE__ */ jsx24("div", { className: "kjun-data-empty kjun-state-actions", style: { paddingBlock: padding }, children: emptyContent || /* @__PURE__ */ jsx24(KjunEmpty, { text: emptyText, icon: emptyIcon, children: emptyActionText && /* @__PURE__ */ jsx24(KjunButton, { onClick: onEmptyAction, children: emptyActionText }) }) }) : null,
4558
4598
  (!concealed || preserveContent && state.hasQueryResult) && /* @__PURE__ */ jsx24(
4559
4599
  "div",
4560
4600
  {
4561
- className: concealed ? "kjun-data-concealed" : void 0,
4601
+ className: "kjun-data-content" + (concealed ? " kjun-data-concealed" : ""),
4562
4602
  "aria-hidden": concealed || void 0,
4563
4603
  inert: concealed || void 0,
4564
4604
  style: {
@@ -4618,6 +4658,9 @@ function chartSkeletonCount(value) {
4618
4658
  function chartMatrixMuted(row, column) {
4619
4659
  return (row + column + 2) % 3 === 0;
4620
4660
  }
4661
+ function chartSkeletonKind(kind) {
4662
+ return kind === "donut" || kind === "matrix" ? kind : "frame";
4663
+ }
4621
4664
 
4622
4665
  // packages/react/src/market-skeleton.tsx
4623
4666
  import { tokens as tokens24 } from "@kjun-ui/tokens";
@@ -4736,7 +4779,7 @@ function KjunFormSkeleton({
4736
4779
  );
4737
4780
  }
4738
4781
  function KjunChartSkeleton({
4739
- kind = "frame",
4782
+ kind: requestedKind = "frame",
4740
4783
  height = tokens25.extensions.chartSkeleton.height,
4741
4784
  loadingText = "\uCC28\uD2B8\uB97C \uBD88\uB7EC\uC624\uB294 \uC911",
4742
4785
  skeleton = true,
@@ -4744,7 +4787,7 @@ function KjunChartSkeleton({
4744
4787
  rows = 8,
4745
4788
  columns = 14
4746
4789
  }) {
4747
- const revealed = useLoadingReveal(true, loadingDelay), status = revealed && loadingText ? "status" : void 0, rowCount = chartSkeletonCount(rows), columnCount = chartSkeletonCount(columns);
4790
+ const kind = chartSkeletonKind(requestedKind), revealed = useLoadingReveal(true, loadingDelay), status = revealed && loadingText ? "status" : void 0, rowCount = chartSkeletonCount(rows), columnCount = chartSkeletonCount(columns);
4748
4791
  return /* @__PURE__ */ jsx27(
4749
4792
  "div",
4750
4793
  {
@@ -5331,9 +5374,18 @@ function tablePresentation(props, mobile) {
5331
5374
  }
5332
5375
  };
5333
5376
  }
5377
+ var warnedFormats = /* @__PURE__ */ new Set();
5378
+ function columnFormat(column) {
5379
+ if (typeof column.format === "function") return column.format;
5380
+ if (column.format != null && !warnedFormats.has(column.key)) {
5381
+ warnedFormats.add(column.key);
5382
+ console.warn(`KJUN Table: ${column.key} \uC5F4\uC758 format\uC740 \uD568\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4.`);
5383
+ }
5384
+ return void 0;
5385
+ }
5334
5386
  function tableCellValue(props, column, row, index) {
5335
5387
  const value = getValue(row, column.key);
5336
- const body = props.renderCell ? props.renderCell(value, column, row, index) : column.render ? column.render(value, row, index) : column.format ? column.format(value, row) : props.formatValue ? props.formatValue(value, column, row) : value == null ? "-" : typeof value === "number" && column.type === "number" ? new Intl.NumberFormat().format(value) : String(value);
5388
+ const body = props.renderCell ? props.renderCell(value, column, row, index) : column.render ? column.render(value, row, index) : columnFormat(column) ? columnFormat(column)(value, row) : props.formatValue ? props.formatValue(value, column, row) : value == null ? "-" : typeof value === "number" && column.type === "number" ? new Intl.NumberFormat().format(value) : String(value);
5337
5389
  return { value, body };
5338
5390
  }
5339
5391
 
package/dist/styles.css CHANGED
@@ -3100,6 +3100,8 @@
3100
3100
  height: 100%;
3101
3101
  }
3102
3102
  .kjun-chart-skeleton-donut {
3103
+ /* The hole is 80% − 2 × thickness only in border-box, whatever the app's reset. */
3104
+ box-sizing: border-box;
3103
3105
  height: 80%;
3104
3106
  aspect-ratio: 1;
3105
3107
  border: var(--_kjun-extension-chart-skeleton-donut-thickness) solid var(--_kjun-color-skeleton);
@@ -3135,7 +3137,7 @@
3135
3137
 
3136
3138
  .kjun-chart-skeleton-status { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:var(--_kjun-extension-skeleton-gap); pointer-events:none; }
3137
3139
  .kjun-chart-skeleton-status>span { max-width:90%; padding:var(--_kjun-geometry-dimension-value4) var(--_kjun-geometry-dimension-value12); border-radius:var(--_kjun-geometry-radius-radius6); font-size:var(--_kjun-type-body-size); text-align:center; overflow-wrap:anywhere; background:var(--_kjun-color-surface); color:var(--_kjun-color-text-secondary); line-height: var(--_kjun-type-body-line); font-weight: var(--_kjun-type-body-weight); letter-spacing: var(--_kjun-type-body-tracking); border:var(--_kjun-border-default-width) solid var(--_kjun-color-chart-grid); }
3138
- .kjun-chart-skeleton[data-kjun-chart-kind="donut"] .kjun-chart-skeleton-status>span { border:0; max-width:calc(80cqh - 2 * var(--_kjun-extension-chart-skeleton-donut-thickness)); }
3140
+ .kjun-chart-skeleton[data-kjun-chart-kind="donut"] .kjun-chart-skeleton-status>span { box-sizing:border-box; border:0; max-width:calc(80cqh - 2 * var(--_kjun-extension-chart-skeleton-donut-thickness)); }
3139
3141
 
3140
3142
  .kjun-data-status > .kjun-spinner { flex-shrink: 0; }
3141
3143
  .kjun-data-status > span:last-child { min-width: 0; overflow-wrap: anywhere; }
@@ -1,6 +1,6 @@
1
1
  import { type CSSProperties, type ReactNode, type RefObject } from "react";
2
2
  export type Placement = "top" | "bottom" | "left" | "right" | "bottom-start" | "bottom-end" | "top-start" | "top-end";
3
- export declare function FloatingPanel({ open, onOpenChange, triggerRef, children, placement, className, matchTriggerWidth, maxHeight, field, flip, nonModal, }: {
3
+ export declare function FloatingPanel({ open, onOpenChange, triggerRef, children, placement, className, matchTriggerWidth, maxHeight, field, flip, nonModal, returnFocus, }: {
4
4
  open: boolean;
5
5
  onOpenChange: (v: boolean) => void;
6
6
  triggerRef: RefObject<HTMLElement | null>;
@@ -12,4 +12,5 @@ export declare function FloatingPanel({ open, onOpenChange, triggerRef, children
12
12
  field?: boolean;
13
13
  flip?: boolean;
14
14
  nonModal?: boolean;
15
+ returnFocus?: () => HTMLElement | null | false | undefined;
15
16
  }): import("react/jsx-runtime").JSX.Element | null;
@@ -1,6 +1,6 @@
1
1
  import { type CSSProperties, type ReactNode, type RefObject } from "react";
2
2
  export type Placement = "top" | "bottom" | "left" | "right" | "bottom-start" | "bottom-end" | "top-start" | "top-end";
3
- export declare function FloatingPanel({ open, onOpenChange, triggerRef, children, placement, className, matchTriggerWidth, maxHeight, field, flip, nonModal, }: {
3
+ export declare function FloatingPanel({ open, onOpenChange, triggerRef, children, placement, className, matchTriggerWidth, maxHeight, field, flip, nonModal, returnFocus, }: {
4
4
  open: boolean;
5
5
  onOpenChange: (v: boolean) => void;
6
6
  triggerRef: RefObject<HTMLElement | null>;
@@ -12,4 +12,5 @@ export declare function FloatingPanel({ open, onOpenChange, triggerRef, children
12
12
  field?: boolean;
13
13
  flip?: boolean;
14
14
  nonModal?: boolean;
15
+ returnFocus?: () => HTMLElement | null | false | undefined;
15
16
  }): import("react/jsx-runtime").JSX.Element | null;
@@ -1,4 +1,4 @@
1
- import { type CSSProperties, type ReactNode } from "react";
1
+ import { type CSSProperties, type ReactNode, type RefObject } from "react";
2
2
  export interface KjunPopoverProps {
3
3
  noPadding?: boolean;
4
4
  open?: boolean;
@@ -10,10 +10,12 @@ export interface KjunPopoverProps {
10
10
  focusOnOpen?: boolean;
11
11
  ariaLabel?: string;
12
12
  placement?: "top" | "bottom" | "left" | "right";
13
+ /** Where focus goes when the Popover closes. Defaults to the trigger, also when the target is gone. */
14
+ returnFocus?: HTMLElement | RefObject<HTMLElement | null> | (() => HTMLElement | null);
13
15
  trigger: ReactNode | ((open: boolean) => ReactNode);
14
16
  children: ReactNode | ((close: () => void) => ReactNode);
15
17
  }
16
- export declare function KjunPopover({ noPadding, open: controlled, onOpenChange, manualTrigger, matchTriggerWidth, maxHeight, flip, focusOnOpen, ariaLabel, placement, trigger, children, }: KjunPopoverProps): import("react/jsx-runtime").JSX.Element;
18
+ export declare function KjunPopover({ noPadding, open: controlled, onOpenChange, manualTrigger, matchTriggerWidth, maxHeight, flip, focusOnOpen, ariaLabel, placement, returnFocus, trigger, children, }: KjunPopoverProps): import("react/jsx-runtime").JSX.Element;
17
19
  export interface KjunTooltipProps {
18
20
  content?: string;
19
21
  placement?: "top" | "bottom" | "left" | "right";
@@ -1,4 +1,4 @@
1
- import { type CSSProperties, type ReactNode } from "react";
1
+ import { type CSSProperties, type ReactNode, type RefObject } from "react";
2
2
  export interface KjunPopoverProps {
3
3
  noPadding?: boolean;
4
4
  open?: boolean;
@@ -10,10 +10,12 @@ export interface KjunPopoverProps {
10
10
  focusOnOpen?: boolean;
11
11
  ariaLabel?: string;
12
12
  placement?: "top" | "bottom" | "left" | "right";
13
+ /** Where focus goes when the Popover closes. Defaults to the trigger, also when the target is gone. */
14
+ returnFocus?: HTMLElement | RefObject<HTMLElement | null> | (() => HTMLElement | null);
13
15
  trigger: ReactNode | ((open: boolean) => ReactNode);
14
16
  children: ReactNode | ((close: () => void) => ReactNode);
15
17
  }
16
- export declare function KjunPopover({ noPadding, open: controlled, onOpenChange, manualTrigger, matchTriggerWidth, maxHeight, flip, focusOnOpen, ariaLabel, placement, trigger, children, }: KjunPopoverProps): import("react/jsx-runtime").JSX.Element;
18
+ export declare function KjunPopover({ noPadding, open: controlled, onOpenChange, manualTrigger, matchTriggerWidth, maxHeight, flip, focusOnOpen, ariaLabel, placement, returnFocus, trigger, children, }: KjunPopoverProps): import("react/jsx-runtime").JSX.Element;
17
19
  export interface KjunTooltipProps {
18
20
  content?: string;
19
21
  placement?: "top" | "bottom" | "left" | "right";
@@ -25,6 +25,10 @@ export interface KjunSelectProps<T extends SelectOption = SelectOption> {
25
25
  onChange?: (v: OptionValue | OptionValue[] | null) => void;
26
26
  onOpenChange?: (v: boolean) => void;
27
27
  onSearch?: (v: string) => void;
28
+ /** Replaces the default ranked label/searchKeys match; results keep the original order. */
29
+ filterFn?: (option: T, query: string) => boolean;
30
+ /** Extra option fields searched after the label. */
31
+ searchKeys?: string[];
28
32
  onClear?: () => void;
29
33
  }
30
- export declare function KjunSelect<T extends SelectOption = SelectOption>({ value, options, placeholder, ariaLabel, labelKey, valueKey, size, disabled, searchable, open: controlled, loading, searchPlaceholder, optionPageSize, clearable, multiple, error, menuHeader, renderOption, renderSelected, onValueChange, onChange, onOpenChange, onSearch, onClear, }: KjunSelectProps<T>): import("react/jsx-runtime").JSX.Element;
34
+ export declare function KjunSelect<T extends SelectOption = SelectOption>({ value, options, placeholder, ariaLabel, labelKey, valueKey, size, disabled, searchable, open: controlled, loading, searchPlaceholder, optionPageSize, clearable, multiple, error, menuHeader, renderOption, renderSelected, onValueChange, onChange, onOpenChange, onSearch, onClear, filterFn, searchKeys, }: KjunSelectProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -25,6 +25,10 @@ export interface KjunSelectProps<T extends SelectOption = SelectOption> {
25
25
  onChange?: (v: OptionValue | OptionValue[] | null) => void;
26
26
  onOpenChange?: (v: boolean) => void;
27
27
  onSearch?: (v: string) => void;
28
+ /** Replaces the default ranked label/searchKeys match; results keep the original order. */
29
+ filterFn?: (option: T, query: string) => boolean;
30
+ /** Extra option fields searched after the label. */
31
+ searchKeys?: string[];
28
32
  onClear?: () => void;
29
33
  }
30
- export declare function KjunSelect<T extends SelectOption = SelectOption>({ value, options, placeholder, ariaLabel, labelKey, valueKey, size, disabled, searchable, open: controlled, loading, searchPlaceholder, optionPageSize, clearable, multiple, error, menuHeader, renderOption, renderSelected, onValueChange, onChange, onOpenChange, onSearch, onClear, }: KjunSelectProps<T>): import("react/jsx-runtime").JSX.Element;
34
+ export declare function KjunSelect<T extends SelectOption = SelectOption>({ value, options, placeholder, ariaLabel, labelKey, valueKey, size, disabled, searchable, open: controlled, loading, searchPlaceholder, optionPageSize, clearable, multiple, error, menuHeader, renderOption, renderSelected, onValueChange, onChange, onOpenChange, onSearch, onClear, filterFn, searchKeys, }: KjunSelectProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -28,6 +28,6 @@ export interface KjunChartSkeletonProps {
28
28
  rows?: number;
29
29
  columns?: number;
30
30
  }
31
- export declare function KjunChartSkeleton({ kind, height, loadingText, skeleton, loadingDelay, rows, columns, }: KjunChartSkeletonProps): import("react/jsx-runtime").JSX.Element;
31
+ export declare function KjunChartSkeleton({ kind: requestedKind, height, loadingText, skeleton, loadingDelay, rows, columns, }: KjunChartSkeletonProps): import("react/jsx-runtime").JSX.Element;
32
32
  export { KjunMarketTableSkeleton } from "./market-skeleton.cjs";
33
33
  export type { KjunMarketTableSkeletonProps } from "./market-skeleton.cjs";
@@ -28,6 +28,6 @@ export interface KjunChartSkeletonProps {
28
28
  rows?: number;
29
29
  columns?: number;
30
30
  }
31
- export declare function KjunChartSkeleton({ kind, height, loadingText, skeleton, loadingDelay, rows, columns, }: KjunChartSkeletonProps): import("react/jsx-runtime").JSX.Element;
31
+ export declare function KjunChartSkeleton({ kind: requestedKind, height, loadingText, skeleton, loadingDelay, rows, columns, }: KjunChartSkeletonProps): import("react/jsx-runtime").JSX.Element;
32
32
  export { KjunMarketTableSkeleton } from "./market-skeleton.js";
33
33
  export type { KjunMarketTableSkeletonProps } from "./market-skeleton.js";
@@ -8,5 +8,9 @@ export declare const chartSkeletonMaxCount = 100;
8
8
  export declare function chartSkeletonCount(value: number): number;
9
9
  /** Every third diagonal cell is drawn at the pending opacity so the matrix reads as a heatmap. */
10
10
  export declare function chartMatrixMuted(row: number, column: number): boolean;
11
- /** Inner diameter of the donut ring, which is 80% of the skeleton height. */
11
+ /** Donut ring diameter as a share of the skeleton height; data-state.css repeats it as 80% and 80cqh. */
12
+ export declare const chartDonutRatio = 0.8;
13
+ /** Inner diameter of the donut ring. */
12
14
  export declare function chartDonutHole(height: number, thickness: number): number;
15
+ /** Kinds removed in 0.8.0 (line, bar, candle, grid) or any other value draw, and are named, frame. */
16
+ export declare function chartSkeletonKind(kind: unknown): KjunChartSkeletonKind;
@@ -8,5 +8,9 @@ export declare const chartSkeletonMaxCount = 100;
8
8
  export declare function chartSkeletonCount(value: number): number;
9
9
  /** Every third diagonal cell is drawn at the pending opacity so the matrix reads as a heatmap. */
10
10
  export declare function chartMatrixMuted(row: number, column: number): boolean;
11
- /** Inner diameter of the donut ring, which is 80% of the skeleton height. */
11
+ /** Donut ring diameter as a share of the skeleton height; data-state.css repeats it as 80% and 80cqh. */
12
+ export declare const chartDonutRatio = 0.8;
13
+ /** Inner diameter of the donut ring. */
12
14
  export declare function chartDonutHole(height: number, thickness: number): number;
15
+ /** Kinds removed in 0.8.0 (line, bar, candle, grid) or any other value draw, and are named, frame. */
16
+ export declare function chartSkeletonKind(kind: unknown): KjunChartSkeletonKind;
@@ -6,6 +6,8 @@ export interface FocusTarget {
6
6
  }) => void;
7
7
  isConnected?: boolean;
8
8
  }
9
+ /** A caller-chosen return target wins while it is still in the document; false means the caller moves focus itself. */
10
+ export declare function chooseReturnTarget(chosen: FocusTarget | null | false | undefined, fallback: FocusTarget | null | undefined): FocusTarget | null | undefined;
9
11
  export interface LayerEntry {
10
12
  id: string;
11
13
  kind: LayerKind;
@@ -24,6 +26,7 @@ export declare function createLayerState(): {
24
26
  entries: Map<string, LayerEntry>;
25
27
  topWindow: () => LayerEntry | undefined;
26
28
  top: () => LayerEntry | undefined;
29
+ topPopup: () => LayerEntry | undefined;
27
30
  windowOf: (id?: string) => string | undefined;
28
31
  isRestoredFocus(target?: FocusTarget | null): boolean;
29
32
  clearRestoredFocus(target?: FocusTarget | null): void;
@@ -6,6 +6,8 @@ export interface FocusTarget {
6
6
  }) => void;
7
7
  isConnected?: boolean;
8
8
  }
9
+ /** A caller-chosen return target wins while it is still in the document; false means the caller moves focus itself. */
10
+ export declare function chooseReturnTarget(chosen: FocusTarget | null | false | undefined, fallback: FocusTarget | null | undefined): FocusTarget | null | undefined;
9
11
  export interface LayerEntry {
10
12
  id: string;
11
13
  kind: LayerKind;
@@ -24,6 +26,7 @@ export declare function createLayerState(): {
24
26
  entries: Map<string, LayerEntry>;
25
27
  topWindow: () => LayerEntry | undefined;
26
28
  top: () => LayerEntry | undefined;
29
+ topPopup: () => LayerEntry | undefined;
27
30
  windowOf: (id?: string) => string | undefined;
28
31
  isRestoredFocus(target?: FocusTarget | null): boolean;
29
32
  clearRestoredFocus(target?: FocusTarget | null): void;
@@ -8,7 +8,9 @@ export declare const optionDisabled: (option: SelectOption) => boolean;
8
8
  export declare function optionKey(option: SelectOption, key: string, index: number): string;
9
9
  export declare function optionSelected(value: OptionValue | OptionValue[] | null, option: SelectOption, key: string): boolean;
10
10
  export declare function nextOptionValue(value: OptionValue | OptionValue[] | null, option: SelectOption, key: string, multiple: boolean): OptionValue | OptionValue[];
11
- export declare function selectOptions<T extends SelectOption>({ options, value, labelKey, valueKey, query, pageSize, limit, loading, multiple, }: {
11
+ /** 0 label starts with the query, 1 label contains it, 2 a searchKeys field contains it, -1 no match; an empty query matches as 0. */
12
+ export declare function optionMatchRank(option: SelectOption, query: string, labelKey: string, searchKeys?: readonly string[]): 0 | 1 | -1 | 2;
13
+ export declare function selectOptions<T extends SelectOption>({ options, value, labelKey, valueKey, query, pageSize, limit, loading, multiple, filterFn, searchKeys, }: {
12
14
  options: T[];
13
15
  value: OptionValue | OptionValue[] | null;
14
16
  labelKey: string;
@@ -18,6 +20,8 @@ export declare function selectOptions<T extends SelectOption>({ options, value,
18
20
  limit: number;
19
21
  loading: boolean;
20
22
  multiple: boolean;
23
+ filterFn?: (option: T, query: string) => boolean;
24
+ searchKeys?: readonly string[];
21
25
  }): {
22
26
  selected: (option: T) => boolean;
23
27
  matching: {
@@ -8,7 +8,9 @@ export declare const optionDisabled: (option: SelectOption) => boolean;
8
8
  export declare function optionKey(option: SelectOption, key: string, index: number): string;
9
9
  export declare function optionSelected(value: OptionValue | OptionValue[] | null, option: SelectOption, key: string): boolean;
10
10
  export declare function nextOptionValue(value: OptionValue | OptionValue[] | null, option: SelectOption, key: string, multiple: boolean): OptionValue | OptionValue[];
11
- export declare function selectOptions<T extends SelectOption>({ options, value, labelKey, valueKey, query, pageSize, limit, loading, multiple, }: {
11
+ /** 0 label starts with the query, 1 label contains it, 2 a searchKeys field contains it, -1 no match; an empty query matches as 0. */
12
+ export declare function optionMatchRank(option: SelectOption, query: string, labelKey: string, searchKeys?: readonly string[]): 0 | 1 | -1 | 2;
13
+ export declare function selectOptions<T extends SelectOption>({ options, value, labelKey, valueKey, query, pageSize, limit, loading, multiple, filterFn, searchKeys, }: {
12
14
  options: T[];
13
15
  value: OptionValue | OptionValue[] | null;
14
16
  labelKey: string;
@@ -18,6 +20,8 @@ export declare function selectOptions<T extends SelectOption>({ options, value,
18
20
  limit: number;
19
21
  loading: boolean;
20
22
  multiple: boolean;
23
+ filterFn?: (option: T, query: string) => boolean;
24
+ searchKeys?: readonly string[];
21
25
  }): {
22
26
  selected: (option: T) => boolean;
23
27
  matching: {
@@ -11,6 +11,10 @@ export declare function tablePresentation<Row extends object>(props: TableProps<
11
11
  sections: TableCardSection[];
12
12
  columnsForSection(row: Row, section: TableCardSection): TableColumn<Row>[];
13
13
  };
14
+ export declare function columnFormat<Format>(column: {
15
+ key: string;
16
+ format?: Format;
17
+ }): Format | undefined;
14
18
  export declare function tableCellValue<Row extends object>(props: TableProps<Row, unknown>, column: TableColumn<Row>, row: Row, index: number): {
15
19
  value: unknown;
16
20
  body: ReactNode;
@@ -11,6 +11,10 @@ export declare function tablePresentation<Row extends object>(props: TableProps<
11
11
  sections: TableCardSection[];
12
12
  columnsForSection(row: Row, section: TableCardSection): TableColumn<Row>[];
13
13
  };
14
+ export declare function columnFormat<Format>(column: {
15
+ key: string;
16
+ format?: Format;
17
+ }): Format | undefined;
14
18
  export declare function tableCellValue<Row extends object>(props: TableProps<Row, unknown>, column: TableColumn<Row>, row: Row, index: number): {
15
19
  value: unknown;
16
20
  body: ReactNode;
@@ -9,6 +9,7 @@ export declare function useLayerState(): {
9
9
  entries: Map<string, import("./layer-state.cjs").LayerEntry>;
10
10
  topWindow: () => import("./layer-state.cjs").LayerEntry | undefined;
11
11
  top: () => import("./layer-state.cjs").LayerEntry | undefined;
12
+ topPopup: () => import("./layer-state.cjs").LayerEntry | undefined;
12
13
  windowOf: (id?: string) => string | undefined;
13
14
  isRestoredFocus(target?: FocusTarget | null): boolean;
14
15
  clearRestoredFocus(target?: FocusTarget | null): void;
@@ -36,12 +37,13 @@ export declare function useActiveLayerScope(): boolean;
36
37
  export declare function focusTrigger(target: FocusTarget | null | undefined): FocusTarget | HTMLElement | null | undefined;
37
38
  export declare function useLayer(open: boolean, present: boolean, kind: LayerKind, close: () => void, trigger?: {
38
39
  current: FocusTarget | null;
39
- }): {
40
+ }, returnFocus?: () => FocusTarget | null | false | undefined): {
40
41
  id: string;
41
42
  state: {
42
43
  entries: Map<string, import("./layer-state.cjs").LayerEntry>;
43
44
  topWindow: () => import("./layer-state.cjs").LayerEntry | undefined;
44
45
  top: () => import("./layer-state.cjs").LayerEntry | undefined;
46
+ topPopup: () => import("./layer-state.cjs").LayerEntry | undefined;
45
47
  windowOf: (id?: string) => string | undefined;
46
48
  isRestoredFocus(target?: FocusTarget | null): boolean;
47
49
  clearRestoredFocus(target?: FocusTarget | null): void;
@@ -9,6 +9,7 @@ export declare function useLayerState(): {
9
9
  entries: Map<string, import("./layer-state.js").LayerEntry>;
10
10
  topWindow: () => import("./layer-state.js").LayerEntry | undefined;
11
11
  top: () => import("./layer-state.js").LayerEntry | undefined;
12
+ topPopup: () => import("./layer-state.js").LayerEntry | undefined;
12
13
  windowOf: (id?: string) => string | undefined;
13
14
  isRestoredFocus(target?: FocusTarget | null): boolean;
14
15
  clearRestoredFocus(target?: FocusTarget | null): void;
@@ -36,12 +37,13 @@ export declare function useActiveLayerScope(): boolean;
36
37
  export declare function focusTrigger(target: FocusTarget | null | undefined): FocusTarget | HTMLElement | null | undefined;
37
38
  export declare function useLayer(open: boolean, present: boolean, kind: LayerKind, close: () => void, trigger?: {
38
39
  current: FocusTarget | null;
39
- }): {
40
+ }, returnFocus?: () => FocusTarget | null | false | undefined): {
40
41
  id: string;
41
42
  state: {
42
43
  entries: Map<string, import("./layer-state.js").LayerEntry>;
43
44
  topWindow: () => import("./layer-state.js").LayerEntry | undefined;
44
45
  top: () => import("./layer-state.js").LayerEntry | undefined;
46
+ topPopup: () => import("./layer-state.js").LayerEntry | undefined;
45
47
  windowOf: (id?: string) => string | undefined;
46
48
  isRestoredFocus(target?: FocusTarget | null): boolean;
47
49
  clearRestoredFocus(target?: FocusTarget | null): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kjun-ui/react",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://ui.kjun.dev",
6
6
  "repository": {
@@ -41,9 +41,9 @@
41
41
  "./package.json": "./package.json"
42
42
  },
43
43
  "dependencies": {
44
- "@kjun-ui/tokens": "0.8.0",
44
+ "@kjun-ui/tokens": "0.9.0",
45
45
  "react-aria-components": "1.21.1",
46
- "@kjun-ui/icons": "0.8.0"
46
+ "@kjun-ui/icons": "0.9.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "react": "^19.2.3",