@kjun-ui/react 0.8.1 → 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.cjs +262 -54
- package/dist/index.js +308 -99
- package/dist/styles.css +30 -19
- package/dist/types/packages/react/src/button.d.cts +2 -0
- package/dist/types/packages/react/src/button.d.ts +2 -0
- package/dist/types/packages/react/src/display.d.cts +4 -1
- package/dist/types/packages/react/src/display.d.ts +4 -1
- package/dist/types/packages/react/src/floating-panel.d.cts +4 -1
- package/dist/types/packages/react/src/floating-panel.d.ts +4 -1
- package/dist/types/packages/react/src/input.d.cts +5 -1
- package/dist/types/packages/react/src/input.d.ts +5 -1
- package/dist/types/packages/react/src/popover.d.cts +12 -3
- package/dist/types/packages/react/src/popover.d.ts +12 -3
- package/dist/types/packages/react/src/select-control.d.cts +9 -1
- package/dist/types/packages/react/src/select-control.d.ts +9 -1
- package/dist/types/shared/package-runtime/alert-live.d.cts +3 -0
- package/dist/types/shared/package-runtime/alert-live.d.ts +3 -0
- package/dist/types/shared/package-runtime/aria-ids.d.cts +4 -0
- package/dist/types/shared/package-runtime/aria-ids.d.ts +4 -0
- package/dist/types/shared/package-runtime/layer-state.d.cts +3 -0
- package/dist/types/shared/package-runtime/layer-state.d.ts +3 -0
- package/dist/types/shared/package-runtime/options.d.cts +5 -1
- package/dist/types/shared/package-runtime/options.d.ts +5 -1
- package/dist/types/shared/package-runtime/popover-nonmodal.d.cts +12 -0
- package/dist/types/shared/package-runtime/popover-nonmodal.d.ts +12 -0
- package/dist/types/shared/package-runtime/table-presentation.d.cts +4 -0
- package/dist/types/shared/package-runtime/table-presentation.d.ts +4 -0
- package/dist/types/shared/package-runtime/use-layer.d.cts +3 -1
- package/dist/types/shared/package-runtime/use-layer.d.ts +3 -1
- package/package.json +3 -3
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
|
}
|
|
@@ -119,6 +133,10 @@ function installLayerKeyboard(document2, state, keyupFallback = false) {
|
|
|
119
133
|
import { createContext as createContext2, useContext as useContext2, useId, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
120
134
|
|
|
121
135
|
// shared/package-runtime/layer-state.ts
|
|
136
|
+
function chooseReturnTarget(chosen, fallback2) {
|
|
137
|
+
if (chosen === false) return void 0;
|
|
138
|
+
return chosen && chosen.isConnected !== false ? chosen : fallback2;
|
|
139
|
+
}
|
|
122
140
|
function createLayerState() {
|
|
123
141
|
const entries = /* @__PURE__ */ new Map(), listeners = /* @__PURE__ */ new Set();
|
|
124
142
|
const restoredFocus = /* @__PURE__ */ new WeakSet();
|
|
@@ -139,6 +157,7 @@ function createLayerState() {
|
|
|
139
157
|
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
158
|
};
|
|
141
159
|
const top = () => [...entries.values()].filter(active).sort((a, b) => a.order - b.order).at(-1);
|
|
160
|
+
const topPopup = () => [...entries.values()].filter((layer) => layer.kind !== "tooltip" && active(layer)).sort((a, b) => a.order - b.order).at(-1);
|
|
142
161
|
function dismiss(layer) {
|
|
143
162
|
if (layer.closeRequested) return;
|
|
144
163
|
layer.closeRequested = true;
|
|
@@ -158,6 +177,7 @@ function createLayerState() {
|
|
|
158
177
|
entries,
|
|
159
178
|
topWindow,
|
|
160
179
|
top,
|
|
180
|
+
topPopup,
|
|
161
181
|
windowOf,
|
|
162
182
|
isRestoredFocus(target) {
|
|
163
183
|
return !!target && restoredFocus.has(target);
|
|
@@ -301,21 +321,31 @@ function focusTrigger(target) {
|
|
|
301
321
|
}
|
|
302
322
|
return target;
|
|
303
323
|
}
|
|
304
|
-
function restoreFocus(target, state, id) {
|
|
324
|
+
function restoreFocus(target, state, id, fallback2) {
|
|
325
|
+
const usable = (item) => (item == null ? void 0 : item.isConnected) !== false && !(typeof HTMLElement !== "undefined" && item instanceof HTMLElement && item.closest("[inert]"));
|
|
305
326
|
const restore = () => {
|
|
306
|
-
var _a, _b, _c, _d;
|
|
327
|
+
var _a, _b, _c, _d, _e;
|
|
307
328
|
if (state.entries.has(id)) return;
|
|
308
|
-
if ((target
|
|
309
|
-
else (
|
|
329
|
+
if (usable(target)) (_a = target == null ? void 0 : target.focus) == null ? void 0 : _a.call(target, { preventScroll: true });
|
|
330
|
+
else if (fallback2 && fallback2 !== target && usable(fallback2)) (_b = fallback2.focus) == null ? void 0 : _b.call(fallback2, { preventScroll: true });
|
|
331
|
+
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
332
|
};
|
|
311
333
|
if (typeof requestAnimationFrame !== "undefined") requestAnimationFrame(restore);
|
|
312
334
|
else queueMicrotask(restore);
|
|
313
335
|
}
|
|
314
|
-
function useLayer(open, present, kind, close, trigger) {
|
|
336
|
+
function useLayer(open, present, kind, close, trigger, returnFocus) {
|
|
315
337
|
var _a;
|
|
316
338
|
const state = useLayerState(), parent = useContext2(LayerScope), id = useId();
|
|
317
339
|
const callback = useRef(close);
|
|
318
340
|
callback.current = close;
|
|
341
|
+
const returnRef = useRef(returnFocus);
|
|
342
|
+
returnRef.current = returnFocus;
|
|
343
|
+
const fallbackFocus = useRef(null);
|
|
344
|
+
const removeLayer = () => {
|
|
345
|
+
const removed = state.remove(id, currentFocus());
|
|
346
|
+
if (removed) fallbackFocus.current = removed;
|
|
347
|
+
return removed && returnRef.current ? chooseReturnTarget(returnRef.current(), removed) : removed;
|
|
348
|
+
};
|
|
319
349
|
const openingFocus = useRef(null);
|
|
320
350
|
const wasOpen = useRef(false);
|
|
321
351
|
const pendingFocus = useRef(null);
|
|
@@ -327,17 +357,17 @@ function useLayer(open, present, kind, close, trigger) {
|
|
|
327
357
|
state.open(id, kind, parent, () => callback.current(), focusTrigger(trigger == null ? void 0 : trigger.current) || openingFocus.current);
|
|
328
358
|
} else if (kind === "window" && present) state.markClosing(id);
|
|
329
359
|
else if (kind !== "window" || !present) {
|
|
330
|
-
const target =
|
|
360
|
+
const target = removeLayer();
|
|
331
361
|
if (target) pendingFocus.current = target;
|
|
332
362
|
if (!present && pendingFocus.current) {
|
|
333
|
-
restoreFocus(pendingFocus.current, state, id);
|
|
363
|
+
restoreFocus(pendingFocus.current, state, id, fallbackFocus.current);
|
|
334
364
|
pendingFocus.current = null;
|
|
335
365
|
}
|
|
336
366
|
}
|
|
337
367
|
}, [open, present, state, id, kind, parent, trigger]);
|
|
338
368
|
useLayoutEffect(() => () => {
|
|
339
|
-
const target =
|
|
340
|
-
if (target || pendingFocus.current) restoreFocus(target || pendingFocus.current, state, id);
|
|
369
|
+
const target = removeLayer();
|
|
370
|
+
if (target || pendingFocus.current) restoreFocus(target || pendingFocus.current, state, id, fallbackFocus.current);
|
|
341
371
|
}, [state, id]);
|
|
342
372
|
const entry = state.entries.get(id);
|
|
343
373
|
return {
|
|
@@ -572,6 +602,7 @@ var KjunButton = forwardRef(
|
|
|
572
602
|
style,
|
|
573
603
|
onClick,
|
|
574
604
|
type = "button",
|
|
605
|
+
wrap = false,
|
|
575
606
|
...rest
|
|
576
607
|
} = props;
|
|
577
608
|
const size = useActionSize(props.size, declaredSize);
|
|
@@ -600,6 +631,7 @@ var KjunButton = forwardRef(
|
|
|
600
631
|
"data-variant": variant,
|
|
601
632
|
"data-size": size,
|
|
602
633
|
"data-disabled": disabled,
|
|
634
|
+
"data-wrap": wrap || void 0,
|
|
603
635
|
"aria-label": ariaLabel || rest["aria-label"],
|
|
604
636
|
disabled: disabled || busy,
|
|
605
637
|
"aria-busy": busy || void 0,
|
|
@@ -613,7 +645,7 @@ var KjunButton = forwardRef(
|
|
|
613
645
|
...typeStyle(tokens3.button.typography[size]),
|
|
614
646
|
borderRadius: tokens3.button.radii[size],
|
|
615
647
|
gap: hasContent2 ? tokens3.button.contentGaps[size] : 0,
|
|
616
|
-
...navigation ? {
|
|
648
|
+
...navigation || wrap ? {
|
|
617
649
|
height: "auto",
|
|
618
650
|
maxWidth: "100%",
|
|
619
651
|
paddingBlock: Math.max(0, (height - contentHeight) / 2)
|
|
@@ -654,6 +686,14 @@ var KjunButton = forwardRef(
|
|
|
654
686
|
|
|
655
687
|
// packages/react/src/input.tsx
|
|
656
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
|
|
657
697
|
import {
|
|
658
698
|
createContext as createContext6,
|
|
659
699
|
forwardRef as forwardRef2,
|
|
@@ -691,26 +731,30 @@ function KjunFormGroup({
|
|
|
691
731
|
required = false,
|
|
692
732
|
error = "",
|
|
693
733
|
hint = "",
|
|
734
|
+
labelHidden = false,
|
|
694
735
|
children
|
|
695
736
|
}) {
|
|
696
737
|
const uid = useId2().replace(/:/g, "");
|
|
697
738
|
const fieldId = id || "kjun-field-" + uid;
|
|
698
739
|
const labelId = label ? fieldId + "-label" : void 0;
|
|
699
|
-
const
|
|
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();
|
|
700
743
|
return /* @__PURE__ */ jsx5(
|
|
701
744
|
FieldContext.Provider,
|
|
702
745
|
{
|
|
703
|
-
value: { id: fieldId, labelId, describedBy, error, required },
|
|
746
|
+
value: { id: fieldId, labelId, describedBy, error, required, setControlId },
|
|
704
747
|
children: /* @__PURE__ */ jsxs3("div", { className: "kjun-form-group", children: [
|
|
705
|
-
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: [
|
|
706
749
|
label,
|
|
707
750
|
required && /* @__PURE__ */ jsx5("span", { style: { color: "var(--_kjun-color-danger)" }, children: " *" })
|
|
708
751
|
] }),
|
|
709
752
|
children,
|
|
710
|
-
|
|
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: [
|
|
711
755
|
/* @__PURE__ */ jsx5(KjunIcon, { name: "alert-circle", size: tokens4.extensions.form.messageIconSize }),
|
|
712
756
|
error
|
|
713
|
-
] })
|
|
757
|
+
] })
|
|
714
758
|
] })
|
|
715
759
|
}
|
|
716
760
|
);
|
|
@@ -768,11 +812,7 @@ var KjunInput = forwardRef2(
|
|
|
768
812
|
const showError = !!errorMessage && !(field == null ? void 0 : field.error);
|
|
769
813
|
const invalid = !!(error || errorMessage || (field == null ? void 0 : field.error));
|
|
770
814
|
const ownErrorId = "kjun-input-error-" + uid;
|
|
771
|
-
const describedBy = [
|
|
772
|
-
props["aria-describedby"],
|
|
773
|
-
field == null ? void 0 : field.describedBy,
|
|
774
|
-
showError ? ownErrorId : void 0
|
|
775
|
-
].filter(Boolean).join(" ") || void 0;
|
|
815
|
+
const describedBy = mergeIds(props["aria-describedby"], field == null ? void 0 : field.describedBy, showError ? ownErrorId : void 0);
|
|
776
816
|
return /* @__PURE__ */ jsxs3("div", { style: { minWidth: 0 }, children: [
|
|
777
817
|
/* @__PURE__ */ jsxs3("div", { className: "kjun-input-wrap", "data-disabled": disabled || void 0, children: [
|
|
778
818
|
(prefix || prefixIcon) && /* @__PURE__ */ jsx5(
|
|
@@ -1180,6 +1220,13 @@ function hasContent(node) {
|
|
|
1180
1220
|
return true;
|
|
1181
1221
|
}
|
|
1182
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
|
+
|
|
1183
1230
|
// packages/react/src/display.tsx
|
|
1184
1231
|
import { tokens as tokens7 } from "@kjun-ui/tokens";
|
|
1185
1232
|
import {
|
|
@@ -1337,6 +1384,7 @@ function KjunAlert({
|
|
|
1337
1384
|
size = "md",
|
|
1338
1385
|
title,
|
|
1339
1386
|
closable = false,
|
|
1387
|
+
live,
|
|
1340
1388
|
children,
|
|
1341
1389
|
actions,
|
|
1342
1390
|
onClose
|
|
@@ -1347,7 +1395,7 @@ function KjunAlert({
|
|
|
1347
1395
|
return /* @__PURE__ */ jsxs6(
|
|
1348
1396
|
"div",
|
|
1349
1397
|
{
|
|
1350
|
-
role: tone
|
|
1398
|
+
role: alertRole(tone, live),
|
|
1351
1399
|
className: "kjun-alert",
|
|
1352
1400
|
"data-size": small ? "sm" : "md",
|
|
1353
1401
|
style: {
|
|
@@ -1956,6 +2004,7 @@ import { tokens as tokens12 } from "@kjun-ui/tokens";
|
|
|
1956
2004
|
import {
|
|
1957
2005
|
createContext as createContext9,
|
|
1958
2006
|
forwardRef as forwardRef3,
|
|
2007
|
+
useCallback as useCallback2,
|
|
1959
2008
|
useContext as useContext9,
|
|
1960
2009
|
useId as useId5
|
|
1961
2010
|
} from "react";
|
|
@@ -2084,12 +2133,17 @@ function KjunCheckbox({
|
|
|
2084
2133
|
onChange
|
|
2085
2134
|
}) {
|
|
2086
2135
|
const checked = Array.isArray(value) ? value.includes(val) : value;
|
|
2136
|
+
const field = useKjunField();
|
|
2087
2137
|
return /* @__PURE__ */ jsxs9(
|
|
2088
2138
|
AriaCheckbox,
|
|
2089
2139
|
{
|
|
2090
2140
|
isSelected: checked,
|
|
2091
2141
|
isDisabled: disabled,
|
|
2092
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",
|
|
2093
2147
|
className: "kjun-choice" + (disabled ? " kjun-choice--disabled" : ""),
|
|
2094
2148
|
onChange: (next) => {
|
|
2095
2149
|
const result = Array.isArray(value) ? next ? [...value, val] : value.filter((v) => v !== val) : next;
|
|
@@ -2119,12 +2173,23 @@ function KjunSwitch({
|
|
|
2119
2173
|
onValueChange,
|
|
2120
2174
|
onChange
|
|
2121
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]);
|
|
2122
2185
|
return /* @__PURE__ */ jsxs9(
|
|
2123
2186
|
AriaSwitch,
|
|
2124
2187
|
{
|
|
2125
2188
|
isSelected: value,
|
|
2126
2189
|
isDisabled: disabled,
|
|
2127
2190
|
"aria-label": ariaLabel || label,
|
|
2191
|
+
"aria-describedby": field == null ? void 0 : field.describedBy,
|
|
2192
|
+
inputRef: markInput,
|
|
2128
2193
|
className: "kjun-choice" + (disabled ? " kjun-choice--disabled" : ""),
|
|
2129
2194
|
onChange: (next) => {
|
|
2130
2195
|
onValueChange == null ? void 0 : onValueChange(next);
|
|
@@ -2214,7 +2279,8 @@ function KjunRadioGroup({
|
|
|
2214
2279
|
style: {
|
|
2215
2280
|
display: "flex",
|
|
2216
2281
|
flexDirection: direction === "vertical" ? "column" : "row",
|
|
2217
|
-
|
|
2282
|
+
// A wrapping column would split into extra columns whenever the group's height is fixed.
|
|
2283
|
+
flexWrap: direction === "vertical" ? "nowrap" : "wrap",
|
|
2218
2284
|
gap: direction === "vertical" ? tokens12.dimension.value8 : tokens12.dimension.value16
|
|
2219
2285
|
},
|
|
2220
2286
|
children: children || options.map((option) => /* @__PURE__ */ jsx12(
|
|
@@ -2259,7 +2325,7 @@ var KjunTextarea = forwardRef3(
|
|
|
2259
2325
|
required: (_a = props.required) != null ? _a : field == null ? void 0 : field.required,
|
|
2260
2326
|
"aria-label": ariaLabel || props["aria-label"],
|
|
2261
2327
|
"aria-labelledby": props["aria-labelledby"] || (field == null ? void 0 : field.labelId),
|
|
2262
|
-
"aria-describedby": props["aria-describedby"]
|
|
2328
|
+
"aria-describedby": mergeIds(props["aria-describedby"], field == null ? void 0 : field.describedBy),
|
|
2263
2329
|
"aria-invalid": error || !!(field == null ? void 0 : field.error) || void 0,
|
|
2264
2330
|
className: "kjun-input kjun-textarea " + className,
|
|
2265
2331
|
style: {
|
|
@@ -2419,10 +2485,12 @@ function FloatingPanel({
|
|
|
2419
2485
|
maxHeight,
|
|
2420
2486
|
field = false,
|
|
2421
2487
|
flip = true,
|
|
2422
|
-
nonModal = false
|
|
2488
|
+
nonModal = false,
|
|
2489
|
+
ownsDismiss = false,
|
|
2490
|
+
returnFocus
|
|
2423
2491
|
}) {
|
|
2424
2492
|
const motion = usePresence(open, useReducedMotion(), tokens13.motion.popupExit);
|
|
2425
|
-
const layer = useLayer(open, motion.present, "popup", () => onOpenChange(false), triggerRef);
|
|
2493
|
+
const layer = useLayer(open, motion.present, "popup", () => onOpenChange(false), triggerRef, returnFocus);
|
|
2426
2494
|
const container = useKjunPortalContainer();
|
|
2427
2495
|
const panel = useRef13(null);
|
|
2428
2496
|
useEffect5(() => {
|
|
@@ -2450,7 +2518,9 @@ function FloatingPanel({
|
|
|
2450
2518
|
isNonModal: nonModal,
|
|
2451
2519
|
isKeyboardDismissDisabled: layer.keyboardManaged,
|
|
2452
2520
|
isOpen: motion.present,
|
|
2453
|
-
onOpenChange
|
|
2521
|
+
onOpenChange: ownsDismiss && layer.keyboardManaged ? (next) => {
|
|
2522
|
+
if (next) onOpenChange(next);
|
|
2523
|
+
} : onOpenChange,
|
|
2454
2524
|
triggerRef,
|
|
2455
2525
|
UNSTABLE_portalContainer: container,
|
|
2456
2526
|
placement: placement.replace("-", " "),
|
|
@@ -2473,8 +2543,69 @@ function FloatingPanel({
|
|
|
2473
2543
|
|
|
2474
2544
|
// packages/react/src/popover.tsx
|
|
2475
2545
|
import { tokens as tokens14 } from "@kjun-ui/tokens";
|
|
2476
|
-
import { useCallback as
|
|
2546
|
+
import { useCallback as useCallback3, useEffect as useEffect6, useId as useId6, useRef as useRef14, useState as useState10 } from "react";
|
|
2477
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
|
|
2478
2609
|
import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2479
2610
|
function KjunPopover({
|
|
2480
2611
|
noPadding = false,
|
|
@@ -2487,6 +2618,9 @@ function KjunPopover({
|
|
|
2487
2618
|
focusOnOpen = false,
|
|
2488
2619
|
ariaLabel,
|
|
2489
2620
|
placement = "bottom",
|
|
2621
|
+
returnFocus,
|
|
2622
|
+
header,
|
|
2623
|
+
modal = true,
|
|
2490
2624
|
trigger,
|
|
2491
2625
|
children
|
|
2492
2626
|
}) {
|
|
@@ -2494,13 +2628,31 @@ function KjunPopover({
|
|
|
2494
2628
|
const expanded = usePopupExpanded(open, ref);
|
|
2495
2629
|
const focusOnMount = useRef14(focusOnOpen);
|
|
2496
2630
|
focusOnMount.current = focusOnOpen;
|
|
2497
|
-
const focusContent =
|
|
2631
|
+
const focusContent = useCallback3((node) => {
|
|
2498
2632
|
if (node && focusOnMount.current) node.focus();
|
|
2499
2633
|
}, []);
|
|
2634
|
+
const resolveReturn = returnFocus === void 0 ? void 0 : () => typeof returnFocus === "function" ? returnFocus() : returnFocus instanceof HTMLElement ? returnFocus : returnFocus.current;
|
|
2500
2635
|
const change = (v) => {
|
|
2501
2636
|
setInternal(v);
|
|
2502
2637
|
onOpenChange == null ? void 0 : onOpenChange(v);
|
|
2503
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 });
|
|
2504
2656
|
return /* @__PURE__ */ jsxs10(Fragment3, { children: [
|
|
2505
2657
|
/* @__PURE__ */ jsx14(
|
|
2506
2658
|
"div",
|
|
@@ -2528,25 +2680,29 @@ function KjunPopover({
|
|
|
2528
2680
|
open,
|
|
2529
2681
|
onOpenChange: change,
|
|
2530
2682
|
triggerRef: ref,
|
|
2531
|
-
className: "kjun-content-popover",
|
|
2683
|
+
className: "kjun-content-popover" + (header != null ? " kjun-popover-has-header" : ""),
|
|
2532
2684
|
placement,
|
|
2533
2685
|
matchTriggerWidth,
|
|
2534
2686
|
maxHeight,
|
|
2535
2687
|
flip,
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2688
|
+
returnFocus: () => skipReturn.current ? false : resolveReturn == null ? void 0 : resolveReturn(),
|
|
2689
|
+
nonModal: !modal,
|
|
2690
|
+
ownsDismiss: !modal,
|
|
2691
|
+
children: (() => {
|
|
2692
|
+
const dialogProps = {
|
|
2539
2693
|
id,
|
|
2540
|
-
"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,
|
|
2541
2696
|
className: "kjun-popover-dialog",
|
|
2542
|
-
style: { maxHeight: maxHeight != null ? maxHeight : `min(60vh, ${tokens14.extensions.floating.maxHeight}px)`, overflowY: "auto" }
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
}
|
|
2549
|
-
|
|
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
|
+
})()
|
|
2550
2706
|
}
|
|
2551
2707
|
)
|
|
2552
2708
|
] });
|
|
@@ -2555,10 +2711,16 @@ function KjunTooltip({
|
|
|
2555
2711
|
content = "",
|
|
2556
2712
|
placement = "top",
|
|
2557
2713
|
delay = 0,
|
|
2714
|
+
open: controlled,
|
|
2715
|
+
onOpenChange,
|
|
2558
2716
|
children
|
|
2559
2717
|
}) {
|
|
2560
2718
|
const container = useKjunPortalContainer();
|
|
2561
|
-
const [
|
|
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
|
+
};
|
|
2562
2724
|
const layer = useLayer(open, open, "tooltip", () => setOpen(false));
|
|
2563
2725
|
return /* @__PURE__ */ jsxs10(TooltipTrigger, { isOpen: open && !layer.blocked, onOpenChange: setOpen, delay, closeDelay: 0, isDisabled: !content || !layer.scopeActive, children: [
|
|
2564
2726
|
/* @__PURE__ */ jsx14(Focusable, { children }),
|
|
@@ -2581,7 +2743,7 @@ function KjunTooltip({
|
|
|
2581
2743
|
|
|
2582
2744
|
// packages/react/src/dropdown.tsx
|
|
2583
2745
|
import { tokens as tokens15 } from "@kjun-ui/tokens";
|
|
2584
|
-
import { cloneElement, createContext as createContext10, isValidElement as isValidElement2, useCallback as
|
|
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";
|
|
2585
2747
|
import { Menu, MenuItem, Separator } from "react-aria-components";
|
|
2586
2748
|
import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2587
2749
|
var DropdownContext = createContext10(null);
|
|
@@ -2599,7 +2761,7 @@ function KjunDropdown({
|
|
|
2599
2761
|
const [open, setOpen] = useState11(false), currentOpen = useRef15(false), ref = useRef15(null), id = "kjun-" + useId7();
|
|
2600
2762
|
const menuFocusCleanup = useRef15(() => {
|
|
2601
2763
|
});
|
|
2602
|
-
const bindMenu =
|
|
2764
|
+
const bindMenu = useCallback4((menu) => {
|
|
2603
2765
|
menuFocusCleanup.current();
|
|
2604
2766
|
menuFocusCleanup.current = () => {
|
|
2605
2767
|
};
|
|
@@ -2609,7 +2771,7 @@ function KjunDropdown({
|
|
|
2609
2771
|
cancelAnimationFrame(frame);
|
|
2610
2772
|
frame = requestAnimationFrame(() => {
|
|
2611
2773
|
if (!currentOpen.current || !menu.isConnected || menu.ownerDocument.activeElement !== menu || menu.closest('[inert], [aria-hidden="true"]')) return;
|
|
2612
|
-
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])');
|
|
2613
2775
|
item == null ? void 0 : item.focus({ preventScroll: true });
|
|
2614
2776
|
});
|
|
2615
2777
|
};
|
|
@@ -2650,7 +2812,7 @@ function KjunDropdown({
|
|
|
2650
2812
|
if (value) onOpen == null ? void 0 : onOpen();
|
|
2651
2813
|
else onClose == null ? void 0 : onClose();
|
|
2652
2814
|
};
|
|
2653
|
-
|
|
2815
|
+
useEffect7(() => {
|
|
2654
2816
|
if (unavailable) change(false);
|
|
2655
2817
|
}, [unavailable]);
|
|
2656
2818
|
return /* @__PURE__ */ jsxs11(DropdownContext.Provider, { value: () => change(false), children: [
|
|
@@ -2704,9 +2866,20 @@ function KjunDropdownItem({
|
|
|
2704
2866
|
onClick
|
|
2705
2867
|
}) {
|
|
2706
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]);
|
|
2707
2879
|
return /* @__PURE__ */ jsxs11(
|
|
2708
2880
|
MenuItem,
|
|
2709
2881
|
{
|
|
2882
|
+
ref: node,
|
|
2710
2883
|
id,
|
|
2711
2884
|
textValue: textValue || (typeof children === "string" ? children : void 0),
|
|
2712
2885
|
isDisabled: disabled,
|
|
@@ -2890,7 +3063,7 @@ function KjunDrawer({
|
|
|
2890
3063
|
}
|
|
2891
3064
|
|
|
2892
3065
|
// shared/package-runtime/combobox.ts
|
|
2893
|
-
import { useEffect as
|
|
3066
|
+
import { useEffect as useEffect8, useState as useState12 } from "react";
|
|
2894
3067
|
|
|
2895
3068
|
// shared/package-runtime/options.ts
|
|
2896
3069
|
var optionValue = (option, key = "value") => typeof option === "object" ? option[key] : option;
|
|
@@ -2912,6 +3085,17 @@ function nextOptionValue(value, option, key, multiple) {
|
|
|
2912
3085
|
if (!multiple) return id;
|
|
2913
3086
|
return Array.isArray(value) && value.includes(id) ? value.filter((item) => item !== id) : [...Array.isArray(value) ? value : [], id];
|
|
2914
3087
|
}
|
|
3088
|
+
function optionMatchRank(option, query2, labelKey, searchKeys = []) {
|
|
3089
|
+
const needle = query2.trim().toLocaleLowerCase();
|
|
3090
|
+
if (!needle) return 0;
|
|
3091
|
+
const label = optionLabel(option, labelKey).toLocaleLowerCase();
|
|
3092
|
+
if (label.startsWith(needle)) return 0;
|
|
3093
|
+
if (label.includes(needle)) return 1;
|
|
3094
|
+
return typeof option === "object" && searchKeys.some((key) => {
|
|
3095
|
+
var _a;
|
|
3096
|
+
return String((_a = option[key]) != null ? _a : "").toLocaleLowerCase().includes(needle);
|
|
3097
|
+
}) ? 2 : -1;
|
|
3098
|
+
}
|
|
2915
3099
|
function selectOptions({
|
|
2916
3100
|
options,
|
|
2917
3101
|
value,
|
|
@@ -2921,10 +3105,13 @@ function selectOptions({
|
|
|
2921
3105
|
pageSize,
|
|
2922
3106
|
limit,
|
|
2923
3107
|
loading,
|
|
2924
|
-
multiple
|
|
3108
|
+
multiple,
|
|
3109
|
+
filterFn,
|
|
3110
|
+
searchKeys = []
|
|
2925
3111
|
}) {
|
|
2926
3112
|
const selected = (option) => optionSelected(value, option, valueKey);
|
|
2927
|
-
const
|
|
3113
|
+
const indexed = options.map((option, index) => ({ option, key: optionKey(option, valueKey, index) }));
|
|
3114
|
+
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
3115
|
const visible = loading ? [] : pageSize > 0 ? matching.slice(0, limit) : matching;
|
|
2929
3116
|
const selectedOption = options.find(selected);
|
|
2930
3117
|
const label = multiple && Array.isArray(value) && value.length > 1 ? `${value.length}\uAC1C \uC120\uD0DD\uB428` : selectedOption !== void 0 ? optionLabel(selectedOption, labelKey) : "";
|
|
@@ -2955,8 +3142,8 @@ function useComboboxModel({
|
|
|
2955
3142
|
const selectedLabel = selected !== void 0 ? optionLabel(selected, labelKey) : "";
|
|
2956
3143
|
const [query2, setQuery] = useState12(selectedLabel);
|
|
2957
3144
|
const [open, setOpen] = useState12(false);
|
|
2958
|
-
|
|
2959
|
-
|
|
3145
|
+
useEffect8(() => setQuery(selectedLabel), [value, selectedLabel]);
|
|
3146
|
+
useEffect8(() => {
|
|
2960
3147
|
if (disabled) setOpen(false);
|
|
2961
3148
|
}, [disabled]);
|
|
2962
3149
|
const change = (next) => {
|
|
@@ -2990,7 +3177,7 @@ function useComboboxModel({
|
|
|
2990
3177
|
|
|
2991
3178
|
// packages/react/src/combobox.tsx
|
|
2992
3179
|
import {
|
|
2993
|
-
useEffect as
|
|
3180
|
+
useEffect as useEffect9,
|
|
2994
3181
|
useId as useId8,
|
|
2995
3182
|
useRef as useRef16,
|
|
2996
3183
|
useState as useState13
|
|
@@ -3078,8 +3265,8 @@ function SearchField({
|
|
|
3078
3265
|
const ref = useRef16(null), [highlighted, setActive] = useState13(-1), id = "kjun-" + useId8();
|
|
3079
3266
|
const focusGuard = usePopupFocusGuard(ref);
|
|
3080
3267
|
const active = !disabled && !loading && highlighted >= 0 && highlighted < options.length && !optionDisabled(options[highlighted]) ? highlighted : -1;
|
|
3081
|
-
|
|
3082
|
-
|
|
3268
|
+
useEffect9(() => setActive(-1), [value, options.length]);
|
|
3269
|
+
useEffect9(() => {
|
|
3083
3270
|
if (!open) return;
|
|
3084
3271
|
const leaveField = (event) => {
|
|
3085
3272
|
var _a, _b, _c;
|
|
@@ -3089,7 +3276,7 @@ function SearchField({
|
|
|
3089
3276
|
document.addEventListener("focusin", leaveField);
|
|
3090
3277
|
return () => document.removeEventListener("focusin", leaveField);
|
|
3091
3278
|
}, [open, onOpenChange, id]);
|
|
3092
|
-
|
|
3279
|
+
useEffect9(() => {
|
|
3093
3280
|
if (highlighted !== active) setActive(-1);
|
|
3094
3281
|
}, [highlighted, active]);
|
|
3095
3282
|
const available = options.map((o, i) => optionDisabled(o) ? -1 : i).filter((i) => i >= 0);
|
|
@@ -3290,7 +3477,7 @@ function KjunDatePicker({
|
|
|
3290
3477
|
import { useState as useState16 } from "react";
|
|
3291
3478
|
|
|
3292
3479
|
// shared/package-runtime/search-input.ts
|
|
3293
|
-
import { useEffect as
|
|
3480
|
+
import { useEffect as useEffect10, useLayoutEffect as useLayoutEffect10, useRef as useRef17, useState as useState15 } from "react";
|
|
3294
3481
|
function useSearchInputModel({
|
|
3295
3482
|
value,
|
|
3296
3483
|
disabled = false,
|
|
@@ -3313,7 +3500,7 @@ function useSearchInputModel({
|
|
|
3313
3500
|
clearTimeout(timer.current);
|
|
3314
3501
|
return () => clearTimeout(timer.current);
|
|
3315
3502
|
}, [disabled, debounce, !!loadOptions]);
|
|
3316
|
-
|
|
3503
|
+
useEffect10(() => {
|
|
3317
3504
|
const current = ++version.current, abort = new AbortController();
|
|
3318
3505
|
setFailed(false);
|
|
3319
3506
|
if (!loadOptions || !open || disabled || query2.length < minChars) {
|
|
@@ -3467,12 +3654,12 @@ import {
|
|
|
3467
3654
|
useId as useId9,
|
|
3468
3655
|
useContext as useContext11,
|
|
3469
3656
|
useRef as useRef19,
|
|
3470
|
-
useEffect as
|
|
3657
|
+
useEffect as useEffect12
|
|
3471
3658
|
} from "react";
|
|
3472
3659
|
import { ListBox, ListBoxItem } from "react-aria-components";
|
|
3473
3660
|
|
|
3474
3661
|
// shared/package-runtime/select.ts
|
|
3475
|
-
import { useEffect as
|
|
3662
|
+
import { useEffect as useEffect11, useRef as useRef18, useState as useState17 } from "react";
|
|
3476
3663
|
function useSelectState(controlled, disabled, pageSize, onOpenChange) {
|
|
3477
3664
|
const [internal, setInternal] = useState17(false);
|
|
3478
3665
|
const [query2, setQuery] = useState17("");
|
|
@@ -3481,7 +3668,7 @@ function useSelectState(controlled, disabled, pageSize, onOpenChange) {
|
|
|
3481
3668
|
const isControlled = typeof controlled === "boolean";
|
|
3482
3669
|
const open = !disabled && (isControlled ? controlled : internal);
|
|
3483
3670
|
const previousOpen = useRef18(open);
|
|
3484
|
-
|
|
3671
|
+
useEffect11(() => {
|
|
3485
3672
|
if (disabled && !isControlled) setInternal(false);
|
|
3486
3673
|
if (previousOpen.current && !open) {
|
|
3487
3674
|
setQuery("");
|
|
@@ -3490,7 +3677,7 @@ function useSelectState(controlled, disabled, pageSize, onOpenChange) {
|
|
|
3490
3677
|
}
|
|
3491
3678
|
previousOpen.current = open;
|
|
3492
3679
|
}, [open, disabled, isControlled, pageSize]);
|
|
3493
|
-
|
|
3680
|
+
useEffect11(() => {
|
|
3494
3681
|
setLimit(pageSize);
|
|
3495
3682
|
}, [pageSize]);
|
|
3496
3683
|
const changeOpen = (next) => {
|
|
@@ -3517,6 +3704,8 @@ function KjunSelect({
|
|
|
3517
3704
|
placeholder = "\uC120\uD0DD",
|
|
3518
3705
|
ariaLabel,
|
|
3519
3706
|
labelKey = "label",
|
|
3707
|
+
id: triggerId,
|
|
3708
|
+
ariaDescribedBy,
|
|
3520
3709
|
valueKey = "value",
|
|
3521
3710
|
size = "md",
|
|
3522
3711
|
disabled = false,
|
|
@@ -3535,7 +3724,9 @@ function KjunSelect({
|
|
|
3535
3724
|
onChange,
|
|
3536
3725
|
onOpenChange,
|
|
3537
3726
|
onSearch,
|
|
3538
|
-
onClear
|
|
3727
|
+
onClear,
|
|
3728
|
+
filterFn,
|
|
3729
|
+
searchKeys
|
|
3539
3730
|
}) {
|
|
3540
3731
|
const { open, query: query2, limit, session, changeOpen, search, showMore } = useSelectState(controlled, disabled, optionPageSize, onOpenChange);
|
|
3541
3732
|
const composition = useCompositionGuard();
|
|
@@ -3543,7 +3734,13 @@ function KjunSelect({
|
|
|
3543
3734
|
const segment = useContext11(CompoundControlContext) !== null;
|
|
3544
3735
|
const spec = tokens18.input[size];
|
|
3545
3736
|
const expanded = usePopupExpanded(open, ref);
|
|
3546
|
-
|
|
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(() => {
|
|
3547
3744
|
var _a, _b;
|
|
3548
3745
|
if (open && searchable) (_b = (_a = menu.current) == null ? void 0 : _a.querySelector("input")) == null ? void 0 : _b.focus({ preventScroll: true });
|
|
3549
3746
|
if (!open) composition.onCompositionEnd();
|
|
@@ -3561,7 +3758,9 @@ function KjunSelect({
|
|
|
3561
3758
|
pageSize: optionPageSize,
|
|
3562
3759
|
limit,
|
|
3563
3760
|
loading,
|
|
3564
|
-
multiple
|
|
3761
|
+
multiple,
|
|
3762
|
+
filterFn,
|
|
3763
|
+
searchKeys
|
|
3565
3764
|
});
|
|
3566
3765
|
return /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
3567
3766
|
/* @__PURE__ */ jsxs15("div", { className: "kjun-select-shell", children: [
|
|
@@ -3569,7 +3768,7 @@ function KjunSelect({
|
|
|
3569
3768
|
"button",
|
|
3570
3769
|
{
|
|
3571
3770
|
ref,
|
|
3572
|
-
id: field == null ? void 0 : field.id,
|
|
3771
|
+
id: triggerId != null ? triggerId : field == null ? void 0 : field.id,
|
|
3573
3772
|
type: "button",
|
|
3574
3773
|
className: "kjun-input kjun-select-trigger",
|
|
3575
3774
|
"data-time-segment": segment || void 0,
|
|
@@ -3577,9 +3776,9 @@ function KjunSelect({
|
|
|
3577
3776
|
"aria-haspopup": "listbox",
|
|
3578
3777
|
"aria-controls": expanded ? id : void 0,
|
|
3579
3778
|
"aria-expanded": expanded,
|
|
3580
|
-
"aria-label": ariaLabel || placeholder,
|
|
3779
|
+
"aria-label": ariaLabel || (triggerId || field ? void 0 : placeholder),
|
|
3581
3780
|
"aria-labelledby": field == null ? void 0 : field.labelId,
|
|
3582
|
-
"aria-describedby": field == null ? void 0 : field.describedBy,
|
|
3781
|
+
"aria-describedby": mergeIds(ariaDescribedBy, field == null ? void 0 : field.describedBy),
|
|
3583
3782
|
"aria-invalid": error || !!(field == null ? void 0 : field.error) || void 0,
|
|
3584
3783
|
style: {
|
|
3585
3784
|
height: spec.height,
|
|
@@ -3796,10 +3995,10 @@ function Collapse({ open, children }) {
|
|
|
3796
3995
|
}
|
|
3797
3996
|
|
|
3798
3997
|
// shared/package-runtime/navigation.ts
|
|
3799
|
-
import { useEffect as
|
|
3998
|
+
import { useEffect as useEffect13, useRef as useRef21, useState as useState19 } from "react";
|
|
3800
3999
|
function useInitialTab(value, candidate, change) {
|
|
3801
4000
|
const requested = useRef21(/* @__PURE__ */ new Set());
|
|
3802
|
-
|
|
4001
|
+
useEffect13(() => {
|
|
3803
4002
|
if (value !== "") {
|
|
3804
4003
|
requested.current.clear();
|
|
3805
4004
|
return;
|
|
@@ -3811,7 +4010,7 @@ function useInitialTab(value, candidate, change) {
|
|
|
3811
4010
|
}
|
|
3812
4011
|
function useAccordionState(multiple) {
|
|
3813
4012
|
const [opened, setOpened] = useState19(/* @__PURE__ */ new Set());
|
|
3814
|
-
|
|
4013
|
+
useEffect13(() => {
|
|
3815
4014
|
if (!multiple) setOpened((previous) => previous.size > 1 ? new Set([...previous].slice(-1)) : previous);
|
|
3816
4015
|
}, [multiple]);
|
|
3817
4016
|
return {
|
|
@@ -3901,7 +4100,7 @@ import {
|
|
|
3901
4100
|
Fragment as Fragment6,
|
|
3902
4101
|
isValidElement as isValidElement3,
|
|
3903
4102
|
useContext as useContext12,
|
|
3904
|
-
useEffect as
|
|
4103
|
+
useEffect as useEffect14,
|
|
3905
4104
|
useLayoutEffect as useLayoutEffect12,
|
|
3906
4105
|
useId as useId10,
|
|
3907
4106
|
useRef as useRef22,
|
|
@@ -3948,7 +4147,7 @@ function KjunTabs({
|
|
|
3948
4147
|
clearTimeout(timer.current);
|
|
3949
4148
|
press.current = null;
|
|
3950
4149
|
};
|
|
3951
|
-
|
|
4150
|
+
useEffect14(() => clear, []);
|
|
3952
4151
|
useLayoutEffect12(() => {
|
|
3953
4152
|
if (press.current && !canOpenMenu(press.current.name)) clear();
|
|
3954
4153
|
}, [tabs, onTabMenu]);
|
|
@@ -4069,7 +4268,7 @@ function KjunAccordionItem({
|
|
|
4069
4268
|
children
|
|
4070
4269
|
}) {
|
|
4071
4270
|
const group = useContext12(AccordionContext), id = "kjun-" + useId10(), [own, setOwn] = useState20(defaultOpen), open = group ? group.opened.has(id) : own;
|
|
4072
|
-
|
|
4271
|
+
useEffect14(() => {
|
|
4073
4272
|
return group == null ? void 0 : group.register(id, defaultOpen);
|
|
4074
4273
|
}, []);
|
|
4075
4274
|
return /* @__PURE__ */ jsxs16("div", { className: "kjun-accordion-item", children: [
|
|
@@ -4231,7 +4430,7 @@ function KjunPagination({
|
|
|
4231
4430
|
import { tokens as tokens21 } from "@kjun-ui/tokens";
|
|
4232
4431
|
import {
|
|
4233
4432
|
useContext as useContext13,
|
|
4234
|
-
useEffect as
|
|
4433
|
+
useEffect as useEffect15,
|
|
4235
4434
|
useRef as useRef23,
|
|
4236
4435
|
useState as useState21
|
|
4237
4436
|
} from "react";
|
|
@@ -4315,7 +4514,7 @@ function KjunCopyButton({
|
|
|
4315
4514
|
}) {
|
|
4316
4515
|
const feedback = useOptionalKjunFeedback();
|
|
4317
4516
|
const [copied, setCopied] = useState21(false), [failed, setFailed] = useState21(false), busy = useRef23(false), timer = useRef23(void 0), mounted = useRef23(true);
|
|
4318
|
-
|
|
4517
|
+
useEffect15(() => {
|
|
4319
4518
|
mounted.current = true;
|
|
4320
4519
|
return () => {
|
|
4321
4520
|
mounted.current = false;
|
|
@@ -4393,7 +4592,7 @@ function KjunRefreshButton({
|
|
|
4393
4592
|
}) {
|
|
4394
4593
|
var _a;
|
|
4395
4594
|
const reduced = useReducedMotion();
|
|
4396
|
-
const label = ariaLabel || [targetName, "\uC0C8\uB85C\uACE0\uCE68"].filter(Boolean).join(" ");
|
|
4595
|
+
const label = ariaLabel || [targetName, mode === "text" ? text : "\uC0C8\uB85C\uACE0\uCE68"].filter(Boolean).join(" ");
|
|
4397
4596
|
const hint = (_a = tooltip != null ? tooltip : title) != null ? _a : mode === "icon" ? label : "";
|
|
4398
4597
|
return /* @__PURE__ */ jsx23(KjunTooltip, { content: props.disabled || props.loading ? "" : hint, placement: tooltipPlacement, delay: tooltipDelay, children: /* @__PURE__ */ jsx23(
|
|
4399
4598
|
KjunButton,
|
|
@@ -4455,7 +4654,7 @@ function KjunScrollFade({ children }) {
|
|
|
4455
4654
|
return prev.left === next.left && prev.right === next.right ? prev : next;
|
|
4456
4655
|
});
|
|
4457
4656
|
};
|
|
4458
|
-
|
|
4657
|
+
useEffect15(() => {
|
|
4459
4658
|
update();
|
|
4460
4659
|
const observer = new ResizeObserver(update);
|
|
4461
4660
|
if (ref.current) {
|
|
@@ -4487,10 +4686,10 @@ import {
|
|
|
4487
4686
|
import { Component, useState as useState23 } from "react";
|
|
4488
4687
|
|
|
4489
4688
|
// shared/package-runtime/use-loading-reveal.ts
|
|
4490
|
-
import { useEffect as
|
|
4689
|
+
import { useEffect as useEffect16, useState as useState22 } from "react";
|
|
4491
4690
|
function useLoadingReveal(active, delay = 0) {
|
|
4492
4691
|
const [revealed, setRevealed] = useState22(false);
|
|
4493
|
-
|
|
4692
|
+
useEffect16(() => {
|
|
4494
4693
|
setRevealed(false);
|
|
4495
4694
|
if (!active || delay <= 0) return;
|
|
4496
4695
|
const timer = setTimeout(() => setRevealed(true), delay);
|
|
@@ -4538,13 +4737,14 @@ function KjunDataState({
|
|
|
4538
4737
|
}) {
|
|
4539
4738
|
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
4739
|
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: [
|
|
4740
|
+
/* @__PURE__ */ jsx24("div", { className: "kjun-data-status-slot", children: (refreshing || state.queryRefreshing) && /* @__PURE__ */ jsxs18("div", { className: "kjun-data-status", role: "status", children: [
|
|
4542
4741
|
/* @__PURE__ */ jsx24(KjunSpinner, { size: "xs" }),
|
|
4543
4742
|
/* @__PURE__ */ jsx24("span", { children: refreshingText })
|
|
4544
4743
|
] }) }),
|
|
4545
4744
|
state.initialLoading ? /* @__PURE__ */ jsx24(
|
|
4546
4745
|
"div",
|
|
4547
4746
|
{
|
|
4747
|
+
className: "kjun-data-loading-block",
|
|
4548
4748
|
role: revealed ? "status" : void 0,
|
|
4549
4749
|
"aria-label": revealed ? loadingText : void 0,
|
|
4550
4750
|
"aria-hidden": revealed ? void 0 : true,
|
|
@@ -4554,11 +4754,11 @@ function KjunDataState({
|
|
|
4554
4754
|
/* @__PURE__ */ jsx24("p", { children: loadingText })
|
|
4555
4755
|
] }))
|
|
4556
4756
|
}
|
|
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,
|
|
4757
|
+
) : 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
4758
|
(!concealed || preserveContent && state.hasQueryResult) && /* @__PURE__ */ jsx24(
|
|
4559
4759
|
"div",
|
|
4560
4760
|
{
|
|
4561
|
-
className: concealed ? "kjun-data-concealed" :
|
|
4761
|
+
className: "kjun-data-content" + (concealed ? " kjun-data-concealed" : ""),
|
|
4562
4762
|
"aria-hidden": concealed || void 0,
|
|
4563
4763
|
inert: concealed || void 0,
|
|
4564
4764
|
style: {
|
|
@@ -5213,7 +5413,7 @@ function KjunSparkline({
|
|
|
5213
5413
|
|
|
5214
5414
|
// shared/package-runtime/table.ts
|
|
5215
5415
|
import { nextTableSort } from "@kjun-ui/tokens";
|
|
5216
|
-
import { useEffect as
|
|
5416
|
+
import { useEffect as useEffect17, useRef as useRef25, useState as useState25 } from "react";
|
|
5217
5417
|
|
|
5218
5418
|
// shared/package-runtime/table-model.ts
|
|
5219
5419
|
function getValue(row, key) {
|
|
@@ -5261,7 +5461,7 @@ function useTableModel(props) {
|
|
|
5261
5461
|
key: "",
|
|
5262
5462
|
order: "asc"
|
|
5263
5463
|
}), [internalExpanded, setExpanded] = useState25([]), [search, setSearch] = useState25(""), timer = useRef25(void 0);
|
|
5264
|
-
|
|
5464
|
+
useEffect17(() => () => clearTimeout(timer.current), []);
|
|
5265
5465
|
const sort = props.sort === void 0 ? internalSort : (_a = props.sort) != null ? _a : { key: "", order: "asc" };
|
|
5266
5466
|
const rows = sortTableRows(data, sort, { sortable, sortMode });
|
|
5267
5467
|
const key = (row, index = 0) => tableRowKey(row, rowKey, index);
|
|
@@ -5334,9 +5534,18 @@ function tablePresentation(props, mobile) {
|
|
|
5334
5534
|
}
|
|
5335
5535
|
};
|
|
5336
5536
|
}
|
|
5537
|
+
var warnedFormats = /* @__PURE__ */ new Set();
|
|
5538
|
+
function columnFormat(column) {
|
|
5539
|
+
if (typeof column.format === "function") return column.format;
|
|
5540
|
+
if (column.format != null && !warnedFormats.has(column.key)) {
|
|
5541
|
+
warnedFormats.add(column.key);
|
|
5542
|
+
console.warn(`KJUN Table: ${column.key} \uC5F4\uC758 format\uC740 \uD568\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4.`);
|
|
5543
|
+
}
|
|
5544
|
+
return void 0;
|
|
5545
|
+
}
|
|
5337
5546
|
function tableCellValue(props, column, row, index) {
|
|
5338
5547
|
const value = getValue(row, column.key);
|
|
5339
|
-
const body = props.renderCell ? props.renderCell(value, column, row, index) : column.render ? column.render(value, row, index) : column
|
|
5548
|
+
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);
|
|
5340
5549
|
return { value, body };
|
|
5341
5550
|
}
|
|
5342
5551
|
|
|
@@ -5359,7 +5568,7 @@ function TableToolbar({
|
|
|
5359
5568
|
selectable && selected.length > 0 && /* @__PURE__ */ jsxs24(
|
|
5360
5569
|
"div",
|
|
5361
5570
|
{
|
|
5362
|
-
role: "
|
|
5571
|
+
role: "group",
|
|
5363
5572
|
"aria-label": "\uC120\uD0DD \uC791\uC5C5",
|
|
5364
5573
|
className: "kjun-table-selection",
|
|
5365
5574
|
children: [
|
|
@@ -5647,7 +5856,7 @@ function TableCards({
|
|
|
5647
5856
|
}
|
|
5648
5857
|
|
|
5649
5858
|
// packages/react/src/table-view.tsx
|
|
5650
|
-
import { useEffect as
|
|
5859
|
+
import { useEffect as useEffect18, useState as useState26 } from "react";
|
|
5651
5860
|
import { isComposingKey as isComposingKey4, tokens as tokens32 } from "@kjun-ui/tokens";
|
|
5652
5861
|
import { jsx as jsx34, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5653
5862
|
function KjunTable(props) {
|
|
@@ -5678,7 +5887,7 @@ function KjunTable(props) {
|
|
|
5678
5887
|
onRetry
|
|
5679
5888
|
} = props;
|
|
5680
5889
|
const state = useTableModel2(props), query2 = useQueryDisplay(props), revealed = useLoadingReveal(query2.initialLoading, skeleton ? loadingDelay : 0), [mobile, setMobile] = useState26(false);
|
|
5681
|
-
|
|
5890
|
+
useEffect18(() => {
|
|
5682
5891
|
const media = matchMedia(`(width < ${tokens32.table.mobileBreakpoint}px)`);
|
|
5683
5892
|
const update = () => setMobile(media.matches);
|
|
5684
5893
|
update();
|
|
@@ -6044,7 +6253,7 @@ function KjunKpiRow({
|
|
|
6044
6253
|
import { tokens as tokens34 } from "@kjun-ui/tokens";
|
|
6045
6254
|
|
|
6046
6255
|
// shared/package-runtime/market-cards.ts
|
|
6047
|
-
import { useEffect as
|
|
6256
|
+
import { useEffect as useEffect19, useRef as useRef26, useState as useState27 } from "react";
|
|
6048
6257
|
function useMarketCardsModel(props, persistence) {
|
|
6049
6258
|
const {
|
|
6050
6259
|
columns,
|
|
@@ -6069,7 +6278,7 @@ function useMarketCardsModel(props, persistence) {
|
|
|
6069
6278
|
} catch (e) {
|
|
6070
6279
|
}
|
|
6071
6280
|
};
|
|
6072
|
-
|
|
6281
|
+
useEffect19(() => {
|
|
6073
6282
|
var _a, _b;
|
|
6074
6283
|
if (mounted.current === restoreSignature) return;
|
|
6075
6284
|
mounted.current = restoreSignature;
|
|
@@ -6405,7 +6614,7 @@ function watchTrailingOverflow(element, onChange) {
|
|
|
6405
6614
|
}
|
|
6406
6615
|
|
|
6407
6616
|
// packages/react/src/market-table.tsx
|
|
6408
|
-
import { useEffect as
|
|
6617
|
+
import { useEffect as useEffect20, useRef as useRef27, useState as useState28 } from "react";
|
|
6409
6618
|
import { jsx as jsx40, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
6410
6619
|
function KjunMarketTable(props) {
|
|
6411
6620
|
const {
|
|
@@ -6427,7 +6636,7 @@ function KjunMarketTable(props) {
|
|
|
6427
6636
|
renderCell
|
|
6428
6637
|
} = props;
|
|
6429
6638
|
const scroller = useRef27(null), [fadeEnd, setFadeEnd] = useState28(false);
|
|
6430
|
-
|
|
6639
|
+
useEffect20(() => scroller.current ? watchTrailingOverflow(scroller.current, setFadeEnd) : void 0, [rows, columns]);
|
|
6431
6640
|
const render = (row, col) => {
|
|
6432
6641
|
const value = getValue(row, col.key), stale = !!getValue(row, "stale");
|
|
6433
6642
|
if (cellLoading(row, col))
|
|
@@ -6736,7 +6945,7 @@ function KjunChip({ label, icon, removable = false, disabled = false, size = "md
|
|
|
6736
6945
|
}
|
|
6737
6946
|
|
|
6738
6947
|
// packages/react/src/range-input.tsx
|
|
6739
|
-
import { useEffect as
|
|
6948
|
+
import { useEffect as useEffect21, useRef as useRef29 } from "react";
|
|
6740
6949
|
import { Slider, SliderTrack, SliderThumb, Label, SliderOutput } from "react-aria-components";
|
|
6741
6950
|
import { createSliderDomain } from "@kjun-ui/tokens";
|
|
6742
6951
|
import { Fragment as Fragment18, jsx as jsx45, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
@@ -6748,7 +6957,7 @@ function RangeInput({ value, min = 0, max = 100, step = 1, disabled = false, lab
|
|
|
6748
6957
|
const latest = useRef29(value);
|
|
6749
6958
|
latest.current = value;
|
|
6750
6959
|
const active = useRef29(false);
|
|
6751
|
-
|
|
6960
|
+
useEffect21(() => {
|
|
6752
6961
|
if (!valid) console.warn("KJUN Slider: \uBC94\uC704\xB7step\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
|
|
6753
6962
|
}, [valid]);
|
|
6754
6963
|
const change = (next) => {
|
|
@@ -6785,7 +6994,7 @@ function KjunRangeSlider(props) {
|
|
|
6785
6994
|
}
|
|
6786
6995
|
|
|
6787
6996
|
// packages/react/src/quantity-stepper.tsx
|
|
6788
|
-
import { useEffect as
|
|
6997
|
+
import { useEffect as useEffect22, useRef as useRef30, useState as useState30 } from "react";
|
|
6789
6998
|
import { createNumberDomain, quantityKeyAction, tokens as tokens41 } from "@kjun-ui/tokens";
|
|
6790
6999
|
import { jsx as jsx46, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
6791
7000
|
function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, disabled = false, error = false, size = "md", block = false, id, ariaLabel, onValueChange, onChangeCommit, onInvalidInput }) {
|
|
@@ -6796,12 +7005,12 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
|
|
|
6796
7005
|
const [draft, setDraft] = useState30(String(value));
|
|
6797
7006
|
const field = useKjunField();
|
|
6798
7007
|
const composing = useRef30(false), dirty = useRef30(false), accepted = useRef30(value);
|
|
6799
|
-
|
|
7008
|
+
useEffect22(() => {
|
|
6800
7009
|
setDraft(String(value));
|
|
6801
7010
|
accepted.current = value;
|
|
6802
7011
|
dirty.current = false;
|
|
6803
7012
|
}, [value, precision, min, max, step]);
|
|
6804
|
-
|
|
7013
|
+
useEffect22(() => {
|
|
6805
7014
|
if (!valid) console.warn("KJUN QuantityStepper: \uBC94\uC704\xB7step\xB7\uC815\uBC00\uB3C4\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
|
|
6806
7015
|
}, [valid]);
|
|
6807
7016
|
const emit = (next) => {
|
|
@@ -6876,7 +7085,7 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
|
|
|
6876
7085
|
}
|
|
6877
7086
|
|
|
6878
7087
|
// packages/react/src/time-picker.tsx
|
|
6879
|
-
import { Fragment as Fragment19, useEffect as
|
|
7088
|
+
import { Fragment as Fragment19, useEffect as useEffect23, useId as useId13, useMemo as useMemo2, useRef as useRef31 } from "react";
|
|
6880
7089
|
import { createTimeDomain } from "@kjun-ui/tokens";
|
|
6881
7090
|
import { jsx as jsx47, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
6882
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 }) {
|
|
@@ -6885,7 +7094,7 @@ function KjunTimePicker({ value, precision = "minute", min, max, minuteStep = 1,
|
|
|
6885
7094
|
const fieldId = (field == null ? void 0 : field.id) || `kjun-time-${uid}`;
|
|
6886
7095
|
const domain = useMemo2(() => createTimeDomain({ precision, min, max, minuteStep, secondStep }), [precision, min, max, minuteStep, secondStep]);
|
|
6887
7096
|
const valid = domain.valid && domain.accepts(value);
|
|
6888
|
-
|
|
7097
|
+
useEffect23(() => {
|
|
6889
7098
|
if (!valid) console.warn("KJUN TimePicker: \uC2DC\uAC01 \uBC94\uC704\xB7\uAC04\uACA9\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
|
|
6890
7099
|
}, [valid]);
|
|
6891
7100
|
const change = (next) => {
|