@kjun-ui/react 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +305 -240
- package/dist/index.js +210 -145
- package/dist/styles.css +1 -1
- package/dist/types/packages/react/src/collapse.d.cts +3 -1
- package/dist/types/packages/react/src/collapse.d.ts +3 -1
- package/dist/types/packages/react/src/combobox.d.cts +6 -2
- package/dist/types/packages/react/src/combobox.d.ts +6 -2
- package/dist/types/packages/react/src/drawer.d.cts +3 -1
- package/dist/types/packages/react/src/drawer.d.ts +3 -1
- package/dist/types/packages/react/src/dropdown.d.cts +4 -2
- package/dist/types/packages/react/src/dropdown.d.ts +4 -2
- package/dist/types/packages/react/src/floating-panel.d.cts +3 -0
- package/dist/types/packages/react/src/floating-panel.d.ts +3 -0
- package/dist/types/packages/react/src/list.d.cts +5 -1
- package/dist/types/packages/react/src/list.d.ts +5 -1
- package/dist/types/packages/react/src/modal.d.cts +3 -1
- package/dist/types/packages/react/src/modal.d.ts +3 -1
- package/dist/types/packages/react/src/navigation.d.cts +7 -1
- package/dist/types/packages/react/src/navigation.d.ts +7 -1
- package/dist/types/packages/react/src/select-control.d.cts +4 -1
- package/dist/types/packages/react/src/select-control.d.ts +4 -1
- package/dist/types/shared/package-runtime/nested-controls.d.cts +2 -0
- package/dist/types/shared/package-runtime/nested-controls.d.ts +2 -0
- package/dist/types/shared/package-runtime/use-after-close.d.cts +6 -0
- package/dist/types/shared/package-runtime/use-after-close.d.ts +6 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1358,14 +1358,33 @@ var KjunInput = (0, import_react9.forwardRef)(
|
|
|
1358
1358
|
}
|
|
1359
1359
|
);
|
|
1360
1360
|
|
|
1361
|
+
// shared/package-runtime/use-after-close.ts
|
|
1362
|
+
var import_react10 = require("react");
|
|
1363
|
+
function useAfterCloseRef(open, onAfterClose) {
|
|
1364
|
+
const state = (0, import_react10.useRef)({ open, mounted: false, callback: onAfterClose });
|
|
1365
|
+
state.current.open = open;
|
|
1366
|
+
state.current.callback = onAfterClose;
|
|
1367
|
+
return (0, import_react10.useCallback)((node) => {
|
|
1368
|
+
const current = state.current;
|
|
1369
|
+
if (node) current.mounted = true;
|
|
1370
|
+
else if (current.mounted) {
|
|
1371
|
+
current.mounted = false;
|
|
1372
|
+
queueMicrotask(() => {
|
|
1373
|
+
var _a;
|
|
1374
|
+
if (!current.open && !current.mounted) (_a = current.callback) == null ? void 0 : _a.call(current);
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
}, []);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1361
1380
|
// shared/package-runtime/use-presence.ts
|
|
1362
1381
|
var import_tokens8 = require("@kjun-ui/tokens");
|
|
1363
|
-
var
|
|
1382
|
+
var import_react11 = require("react");
|
|
1364
1383
|
function usePresence(open, reduced, exitDuration = import_tokens8.tokens.motion.layerExit) {
|
|
1365
|
-
const [retained, setRetained] = (0,
|
|
1366
|
-
const [active, setActive] = (0,
|
|
1367
|
-
const mounted = (0,
|
|
1368
|
-
(0,
|
|
1384
|
+
const [retained, setRetained] = (0, import_react11.useState)(open);
|
|
1385
|
+
const [active, setActive] = (0, import_react11.useState)(false);
|
|
1386
|
+
const mounted = (0, import_react11.useRef)(false);
|
|
1387
|
+
(0, import_react11.useLayoutEffect)(() => {
|
|
1369
1388
|
let first = 0, second = 0, timer;
|
|
1370
1389
|
if (open) {
|
|
1371
1390
|
setRetained(true);
|
|
@@ -1393,7 +1412,7 @@ function usePresence(open, reduced, exitDuration = import_tokens8.tokens.motion.
|
|
|
1393
1412
|
}
|
|
1394
1413
|
|
|
1395
1414
|
// packages/react/src/use-reduced-motion.ts
|
|
1396
|
-
var
|
|
1415
|
+
var import_react12 = require("react");
|
|
1397
1416
|
var query = "(prefers-reduced-motion: reduce)";
|
|
1398
1417
|
function subscribe(notify) {
|
|
1399
1418
|
const media = window.matchMedia(query);
|
|
@@ -1401,12 +1420,12 @@ function subscribe(notify) {
|
|
|
1401
1420
|
return () => media.removeEventListener("change", notify);
|
|
1402
1421
|
}
|
|
1403
1422
|
function useReducedMotion() {
|
|
1404
|
-
return (0,
|
|
1423
|
+
return (0, import_react12.useSyncExternalStore)(subscribe, () => window.matchMedia(query).matches, () => true);
|
|
1405
1424
|
}
|
|
1406
1425
|
|
|
1407
1426
|
// packages/react/src/modal.tsx
|
|
1408
1427
|
var import_tokens9 = require("@kjun-ui/tokens");
|
|
1409
|
-
var
|
|
1428
|
+
var import_react14 = require("react");
|
|
1410
1429
|
|
|
1411
1430
|
// shared/package-runtime/form-actions.ts
|
|
1412
1431
|
function formActionsNeedStack(width, widths, gap) {
|
|
@@ -1459,17 +1478,17 @@ function observeFormActions(root) {
|
|
|
1459
1478
|
var import_react_aria_components2 = require("react-aria-components");
|
|
1460
1479
|
|
|
1461
1480
|
// packages/react/src/overlay-host.tsx
|
|
1462
|
-
var
|
|
1463
|
-
var FeedbackOverlayContext = (0,
|
|
1481
|
+
var import_react13 = require("react");
|
|
1482
|
+
var FeedbackOverlayContext = (0, import_react13.createContext)(
|
|
1464
1483
|
null
|
|
1465
1484
|
);
|
|
1466
1485
|
function FeedbackLayerOutlet() {
|
|
1467
1486
|
var _a;
|
|
1468
|
-
const layers = useLayerState(), scope = (0,
|
|
1487
|
+
const layers = useLayerState(), scope = (0, import_react13.useContext)(LayerScope);
|
|
1469
1488
|
const entry = scope ? layers.entries.get(scope) : void 0;
|
|
1470
1489
|
const active = !!entry && layers.isActive(entry.id), order = (_a = entry == null ? void 0 : entry.order) != null ? _a : 0;
|
|
1471
|
-
const host = (0,
|
|
1472
|
-
(0,
|
|
1490
|
+
const host = (0, import_react13.useContext)(FeedbackOverlayContext), id = "kjun-" + (0, import_react13.useId)(), register = host == null ? void 0 : host.register;
|
|
1491
|
+
(0, import_react13.useLayoutEffect)(() => active ? register == null ? void 0 : register(id, order) : void 0, [register, id, active, order]);
|
|
1473
1492
|
return (host == null ? void 0 : host.top) === id ? host.render() : null;
|
|
1474
1493
|
}
|
|
1475
1494
|
|
|
@@ -1492,8 +1511,8 @@ function KjunFormActions({
|
|
|
1492
1511
|
const m = useKjunMessages();
|
|
1493
1512
|
cancelText != null ? cancelText : cancelText = m.cancel;
|
|
1494
1513
|
confirmText != null ? confirmText : confirmText = m.save;
|
|
1495
|
-
const ref = (0,
|
|
1496
|
-
(0,
|
|
1514
|
+
const ref = (0, import_react14.useRef)(null);
|
|
1515
|
+
(0, import_react14.useLayoutEffect)(() => observeFormActions(ref.current), []);
|
|
1497
1516
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "kjun-form-actions", ref, children: [
|
|
1498
1517
|
showCancel && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1499
1518
|
KjunButton,
|
|
@@ -1522,6 +1541,7 @@ function KjunModal({
|
|
|
1522
1541
|
open,
|
|
1523
1542
|
onOpenChange,
|
|
1524
1543
|
onClose,
|
|
1544
|
+
onAfterClose,
|
|
1525
1545
|
onCancel,
|
|
1526
1546
|
onConfirm,
|
|
1527
1547
|
title = "",
|
|
@@ -1550,8 +1570,9 @@ function KjunModal({
|
|
|
1550
1570
|
confirmText != null ? confirmText : confirmText = m.confirm;
|
|
1551
1571
|
cancelText != null ? cancelText : cancelText = m.cancel;
|
|
1552
1572
|
const motion = usePresence(open, useReducedMotion());
|
|
1573
|
+
const afterCloseRef = useAfterCloseRef(open, onAfterClose);
|
|
1553
1574
|
const portalContainer = useKjunPortalContainer();
|
|
1554
|
-
const id = "kjun-" + (0,
|
|
1575
|
+
const id = "kjun-" + (0, import_react14.useId)();
|
|
1555
1576
|
const explicitLabel = ariaLabel == null ? void 0 : ariaLabel.trim();
|
|
1556
1577
|
const heading = header || title;
|
|
1557
1578
|
const labelledByHeading = showHeader && !explicitLabel && (typeof heading === "string" ? !!heading.trim() : !!heading);
|
|
@@ -1567,6 +1588,7 @@ function KjunModal({
|
|
|
1567
1588
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LayerScope.Provider, { value: layer.id, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1568
1589
|
import_react_aria_components2.ModalOverlay,
|
|
1569
1590
|
{
|
|
1591
|
+
ref: afterCloseRef,
|
|
1570
1592
|
style: { zIndex: layer.zIndex },
|
|
1571
1593
|
isOpen: motion.present && layer.active,
|
|
1572
1594
|
isExiting: motion.present && !layer.active,
|
|
@@ -1654,12 +1676,12 @@ function KjunModal({
|
|
|
1654
1676
|
}
|
|
1655
1677
|
|
|
1656
1678
|
// shared/package-runtime/content-presence.ts
|
|
1657
|
-
var
|
|
1679
|
+
var import_react15 = require("react");
|
|
1658
1680
|
function hasContent(node) {
|
|
1659
1681
|
if (node == null || typeof node === "boolean") return false;
|
|
1660
1682
|
if (typeof node === "string") return node.trim().length > 0;
|
|
1661
1683
|
if (Array.isArray(node)) return node.some(hasContent);
|
|
1662
|
-
if ((0,
|
|
1684
|
+
if ((0, import_react15.isValidElement)(node) && node.type === import_react15.Fragment)
|
|
1663
1685
|
return hasContent(node.props.children);
|
|
1664
1686
|
return true;
|
|
1665
1687
|
}
|
|
@@ -1692,11 +1714,9 @@ function progressCircle(size, percentage) {
|
|
|
1692
1714
|
}
|
|
1693
1715
|
|
|
1694
1716
|
// packages/react/src/display.tsx
|
|
1695
|
-
var
|
|
1717
|
+
var import_react17 = require("react");
|
|
1696
1718
|
|
|
1697
|
-
//
|
|
1698
|
-
var import_react15 = require("react");
|
|
1699
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1719
|
+
// shared/package-runtime/nested-controls.ts
|
|
1700
1720
|
var interactive = 'button, a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
1701
1721
|
function developmentMode3() {
|
|
1702
1722
|
try {
|
|
@@ -1705,6 +1725,13 @@ function developmentMode3() {
|
|
|
1705
1725
|
return false;
|
|
1706
1726
|
}
|
|
1707
1727
|
}
|
|
1728
|
+
function warnNestedControls(root, message) {
|
|
1729
|
+
if (developmentMode3() && (root == null ? void 0 : root.querySelector(interactive))) console.warn(message);
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
// packages/react/src/card.tsx
|
|
1733
|
+
var import_react16 = require("react");
|
|
1734
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1708
1735
|
function KjunCard({
|
|
1709
1736
|
title,
|
|
1710
1737
|
subtitle,
|
|
@@ -1729,11 +1756,9 @@ function KjunCard({
|
|
|
1729
1756
|
onKeyDown,
|
|
1730
1757
|
...props
|
|
1731
1758
|
}) {
|
|
1732
|
-
const root = (0,
|
|
1733
|
-
(0,
|
|
1734
|
-
|
|
1735
|
-
if (pressable && developmentMode3() && ((_a = root.current) == null ? void 0 : _a.querySelector(interactive)))
|
|
1736
|
-
console.warn("KJUN Card: a pressable card contains buttons or links; move them out or drop pressable.");
|
|
1759
|
+
const root = (0, import_react16.useRef)(null);
|
|
1760
|
+
(0, import_react16.useEffect)(() => {
|
|
1761
|
+
if (pressable) warnNestedControls(root.current, "KJUN Card: a pressable card contains buttons or links; move them out or drop pressable.");
|
|
1737
1762
|
}, [pressable]);
|
|
1738
1763
|
const press = pressable ? {
|
|
1739
1764
|
role: "button",
|
|
@@ -1893,7 +1918,7 @@ function KjunAlert({
|
|
|
1893
1918
|
onClose
|
|
1894
1919
|
}) {
|
|
1895
1920
|
const m = useKjunMessages();
|
|
1896
|
-
const [visible, setVisible] = (0,
|
|
1921
|
+
const [visible, setVisible] = (0, import_react17.useState)(true);
|
|
1897
1922
|
if (!visible) return null;
|
|
1898
1923
|
const tone = variant || (type === "error" ? "danger" : type), small = size === "sm";
|
|
1899
1924
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
@@ -2120,7 +2145,7 @@ function KjunSkeleton({
|
|
|
2120
2145
|
}
|
|
2121
2146
|
|
|
2122
2147
|
// packages/react/src/layout-primitives.tsx
|
|
2123
|
-
var
|
|
2148
|
+
var import_react18 = require("react");
|
|
2124
2149
|
|
|
2125
2150
|
// shared/package-runtime/layout-primitives.ts
|
|
2126
2151
|
var numeric = /^(number|display)/;
|
|
@@ -2132,7 +2157,7 @@ var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
|
2132
2157
|
var join = (...names) => names.filter(Boolean).join(" ");
|
|
2133
2158
|
function KjunText({ variant = "body", tone = "default", as, align, maxLines, className, style, children, ...rest }) {
|
|
2134
2159
|
const lines = maxLines && maxLines > 0 ? Math.floor(maxLines) : void 0;
|
|
2135
|
-
return (0,
|
|
2160
|
+
return (0, import_react18.createElement)(as != null ? as : defaultTextTag(variant), {
|
|
2136
2161
|
...rest,
|
|
2137
2162
|
className: join("kjun-text", textTypeClass(variant), className),
|
|
2138
2163
|
// 안에 넣은 링크·강조 같은 앱 요소는 KJUN 리셋을 받지 않는다.
|
|
@@ -2144,7 +2169,7 @@ function KjunText({ variant = "body", tone = "default", as, align, maxLines, cla
|
|
|
2144
2169
|
}, children);
|
|
2145
2170
|
}
|
|
2146
2171
|
function KjunStack({ gap = "md", align = "stretch", as = "div", className, style, children, ...rest }) {
|
|
2147
|
-
return (0,
|
|
2172
|
+
return (0, import_react18.createElement)(as, {
|
|
2148
2173
|
...rest,
|
|
2149
2174
|
className: className || void 0,
|
|
2150
2175
|
style,
|
|
@@ -2171,13 +2196,13 @@ function KjunInline({ gap = "sm", align = "center", justify = "start", wrap = tr
|
|
|
2171
2196
|
}
|
|
2172
2197
|
|
|
2173
2198
|
// shared/package-runtime/feedback-dialog.ts
|
|
2174
|
-
var
|
|
2199
|
+
var import_react19 = require("react");
|
|
2175
2200
|
function useFeedbackDialog(controller, request, messages = kjunMessagesKo) {
|
|
2176
2201
|
const options = request.options;
|
|
2177
|
-
const [value, setValue] = (0,
|
|
2178
|
-
const [error, setError] = (0,
|
|
2179
|
-
const [busy, setBusy] = (0,
|
|
2180
|
-
const working = (0,
|
|
2202
|
+
const [value, setValue] = (0, import_react19.useState)(options.initialValue || "");
|
|
2203
|
+
const [error, setError] = (0, import_react19.useState)("");
|
|
2204
|
+
const [busy, setBusy] = (0, import_react19.useState)(false);
|
|
2205
|
+
const working = (0, import_react19.useRef)(false);
|
|
2181
2206
|
const active = () => {
|
|
2182
2207
|
var _a;
|
|
2183
2208
|
return ((_a = controller.getSnapshot().current) == null ? void 0 : _a.id) === request.id;
|
|
@@ -2220,11 +2245,11 @@ function useFeedbackDialog(controller, request, messages = kjunMessagesKo) {
|
|
|
2220
2245
|
|
|
2221
2246
|
// shared/package-runtime/feedback-motion.ts
|
|
2222
2247
|
var import_tokens12 = require("@kjun-ui/tokens");
|
|
2223
|
-
var
|
|
2248
|
+
var import_react20 = require("react");
|
|
2224
2249
|
function usePresentedToasts(toasts, reduced) {
|
|
2225
|
-
const [items, setItems] = (0,
|
|
2226
|
-
const removals = (0,
|
|
2227
|
-
(0,
|
|
2250
|
+
const [items, setItems] = (0, import_react20.useState)([]);
|
|
2251
|
+
const removals = (0, import_react20.useRef)(/* @__PURE__ */ new Map());
|
|
2252
|
+
(0, import_react20.useLayoutEffect)(() => {
|
|
2228
2253
|
const ids = new Set(toasts.map((toast) => toast.id));
|
|
2229
2254
|
setItems((previous) => {
|
|
2230
2255
|
const old = new Map(previous.map((item) => [item.toast.id, item]));
|
|
@@ -2246,15 +2271,15 @@ function usePresentedToasts(toasts, reduced) {
|
|
|
2246
2271
|
removals.current.clear();
|
|
2247
2272
|
}
|
|
2248
2273
|
}, [toasts, reduced]);
|
|
2249
|
-
(0,
|
|
2274
|
+
(0, import_react20.useLayoutEffect)(() => () => {
|
|
2250
2275
|
for (const timer of removals.current.values()) clearTimeout(timer);
|
|
2251
2276
|
removals.current.clear();
|
|
2252
2277
|
}, []);
|
|
2253
2278
|
return items;
|
|
2254
2279
|
}
|
|
2255
2280
|
function usePresentedRequest(current, reduced) {
|
|
2256
|
-
const [request, setRequest] = (0,
|
|
2257
|
-
(0,
|
|
2281
|
+
const [request, setRequest] = (0, import_react20.useState)(current);
|
|
2282
|
+
(0, import_react20.useLayoutEffect)(() => {
|
|
2258
2283
|
if (!request || request.id === (current == null ? void 0 : current.id) || reduced) {
|
|
2259
2284
|
setRequest(current);
|
|
2260
2285
|
return;
|
|
@@ -2266,15 +2291,15 @@ function usePresentedRequest(current, reduced) {
|
|
|
2266
2291
|
}
|
|
2267
2292
|
|
|
2268
2293
|
// packages/react/src/feedback-context.ts
|
|
2269
|
-
var
|
|
2270
|
-
var KjunFeedbackContext = (0,
|
|
2294
|
+
var import_react21 = require("react");
|
|
2295
|
+
var KjunFeedbackContext = (0, import_react21.createContext)(null);
|
|
2271
2296
|
function useOptionalKjunFeedback() {
|
|
2272
|
-
return (0,
|
|
2297
|
+
return (0, import_react21.useContext)(KjunFeedbackContext);
|
|
2273
2298
|
}
|
|
2274
2299
|
|
|
2275
2300
|
// packages/react/src/toast-stack.tsx
|
|
2276
2301
|
var import_tokens14 = require("@kjun-ui/tokens");
|
|
2277
|
-
var
|
|
2302
|
+
var import_react23 = require("react");
|
|
2278
2303
|
|
|
2279
2304
|
// shared/package-runtime/toast-layout.ts
|
|
2280
2305
|
var import_tokens13 = require("@kjun-ui/tokens");
|
|
@@ -2336,16 +2361,16 @@ function createToastLayout() {
|
|
|
2336
2361
|
}
|
|
2337
2362
|
|
|
2338
2363
|
// packages/react/src/toast.tsx
|
|
2339
|
-
var
|
|
2364
|
+
var import_react22 = require("react");
|
|
2340
2365
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2341
2366
|
function ToastView({
|
|
2342
2367
|
toast,
|
|
2343
2368
|
controller
|
|
2344
2369
|
}) {
|
|
2345
2370
|
const m = useKjunMessages();
|
|
2346
|
-
const previous = (0,
|
|
2347
|
-
const reasons = (0,
|
|
2348
|
-
(0,
|
|
2371
|
+
const previous = (0, import_react22.useRef)(null);
|
|
2372
|
+
const reasons = (0, import_react22.useRef)({ hover: /* @__PURE__ */ Symbol("hover"), focus: /* @__PURE__ */ Symbol("focus") }).current;
|
|
2373
|
+
(0, import_react22.useEffect)(() => {
|
|
2349
2374
|
previous.current = document.activeElement;
|
|
2350
2375
|
return () => {
|
|
2351
2376
|
controller.resumeToast(toast.id, reasons.hover);
|
|
@@ -2440,10 +2465,10 @@ function ToastView({
|
|
|
2440
2465
|
// packages/react/src/toast-stack.tsx
|
|
2441
2466
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2442
2467
|
function ToastSurface({ item, controller }) {
|
|
2443
|
-
const ref = (0,
|
|
2444
|
-
const current = (0,
|
|
2445
|
-
const entryFinished = (0,
|
|
2446
|
-
(0,
|
|
2468
|
+
const ref = (0, import_react23.useRef)(null), reduced = useReducedMotion();
|
|
2469
|
+
const current = (0, import_react23.useRef)(null);
|
|
2470
|
+
const entryFinished = (0, import_react23.useRef)(false);
|
|
2471
|
+
(0, import_react23.useLayoutEffect)(() => {
|
|
2447
2472
|
var _a, _b;
|
|
2448
2473
|
const el = ref.current;
|
|
2449
2474
|
if (!el) return;
|
|
@@ -2477,12 +2502,12 @@ function ToastSurface({ item, controller }) {
|
|
|
2477
2502
|
function ToastStack({ items, controller }) {
|
|
2478
2503
|
var _a;
|
|
2479
2504
|
const layers = useLayerState();
|
|
2480
|
-
const root = (0,
|
|
2505
|
+
const root = (0, import_react23.useRef)(null), layout = (0, import_react23.useRef)(createToastLayout());
|
|
2481
2506
|
const reduced = useReducedMotion();
|
|
2482
|
-
(0,
|
|
2507
|
+
(0, import_react23.useLayoutEffect)(() => {
|
|
2483
2508
|
if (root.current) layout.current.update(root.current, reduced);
|
|
2484
2509
|
});
|
|
2485
|
-
(0,
|
|
2510
|
+
(0, import_react23.useLayoutEffect)(() => () => layout.current.destroy(), []);
|
|
2486
2511
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: root, className: "kjun-toast-stack", style: { zIndex: layers.zIndex((_a = layers.topWindow()) == null ? void 0 : _a.id, "toast") }, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2487
2512
|
"div",
|
|
2488
2513
|
{
|
|
@@ -2497,7 +2522,7 @@ function ToastStack({ items, controller }) {
|
|
|
2497
2522
|
|
|
2498
2523
|
// packages/react/src/feedback.tsx
|
|
2499
2524
|
var import_tokens15 = require("@kjun-ui/tokens");
|
|
2500
|
-
var
|
|
2525
|
+
var import_react24 = require("react");
|
|
2501
2526
|
var import_tokens16 = require("@kjun-ui/tokens");
|
|
2502
2527
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2503
2528
|
function useKjunFeedback() {
|
|
@@ -2549,11 +2574,11 @@ function FeedbackDialog({
|
|
|
2549
2574
|
}
|
|
2550
2575
|
function KjunFeedbackProvider({ children, controller: controllerProp }) {
|
|
2551
2576
|
var _a;
|
|
2552
|
-
const [owned] = (0,
|
|
2577
|
+
const [owned] = (0, import_react24.useState)(() => controllerProp ? void 0 : (0, import_tokens15.createFeedbackController)());
|
|
2553
2578
|
const controller = controllerProp ? (0, import_tokens15.feedbackControllerOf)(controllerProp) : owned;
|
|
2554
|
-
(0,
|
|
2555
|
-
const life = (0,
|
|
2556
|
-
const snapshot = (0,
|
|
2579
|
+
(0, import_react24.useEffect)(() => controller.attach(), [controller]);
|
|
2580
|
+
const life = (0, import_react24.useRef)(0);
|
|
2581
|
+
const snapshot = (0, import_react24.useSyncExternalStore)(
|
|
2557
2582
|
controller.subscribe,
|
|
2558
2583
|
controller.getSnapshot,
|
|
2559
2584
|
controller.getSnapshot
|
|
@@ -2561,7 +2586,7 @@ function KjunFeedbackProvider({ children, controller: controllerProp }) {
|
|
|
2561
2586
|
const reduced = useReducedMotion();
|
|
2562
2587
|
const toasts = usePresentedToasts(snapshot.toasts, reduced);
|
|
2563
2588
|
const dialog = usePresentedRequest(snapshot.current, reduced);
|
|
2564
|
-
(0,
|
|
2589
|
+
(0, import_react24.useEffect)(() => {
|
|
2565
2590
|
const version = ++life.current;
|
|
2566
2591
|
return () => {
|
|
2567
2592
|
queueMicrotask(() => {
|
|
@@ -2569,8 +2594,8 @@ function KjunFeedbackProvider({ children, controller: controllerProp }) {
|
|
|
2569
2594
|
});
|
|
2570
2595
|
};
|
|
2571
2596
|
}, [controller]);
|
|
2572
|
-
const [layers, setLayers] = (0,
|
|
2573
|
-
const register = (0,
|
|
2597
|
+
const [layers, setLayers] = (0, import_react24.useState)([]);
|
|
2598
|
+
const register = (0, import_react24.useCallback)((id, order) => {
|
|
2574
2599
|
setLayers((current) => [...current, { id, order }]);
|
|
2575
2600
|
return () => setLayers((current) => current.filter((value) => value.id !== id));
|
|
2576
2601
|
}, []);
|
|
@@ -2599,11 +2624,11 @@ function KjunFeedbackProvider({ children, controller: controllerProp }) {
|
|
|
2599
2624
|
|
|
2600
2625
|
// packages/react/src/controls.tsx
|
|
2601
2626
|
var import_tokens18 = require("@kjun-ui/tokens");
|
|
2602
|
-
var
|
|
2627
|
+
var import_react26 = require("react");
|
|
2603
2628
|
var import_react_aria_components3 = require("react-aria-components");
|
|
2604
2629
|
|
|
2605
2630
|
// packages/react/src/use-selection-indicator.ts
|
|
2606
|
-
var
|
|
2631
|
+
var import_react25 = require("react");
|
|
2607
2632
|
|
|
2608
2633
|
// shared/package-runtime/selection-indicator.ts
|
|
2609
2634
|
var import_tokens17 = require("@kjun-ui/tokens");
|
|
@@ -2675,11 +2700,11 @@ function selectionIndicator(root, marker, tabs = false) {
|
|
|
2675
2700
|
|
|
2676
2701
|
// packages/react/src/use-selection-indicator.ts
|
|
2677
2702
|
function useSelectionIndicator(tabs = false) {
|
|
2678
|
-
const group = (0,
|
|
2679
|
-
const indicator = (0,
|
|
2680
|
-
const sync = (0,
|
|
2703
|
+
const group = (0, import_react25.useRef)(null);
|
|
2704
|
+
const indicator = (0, import_react25.useRef)(null);
|
|
2705
|
+
const sync = (0, import_react25.useRef)(() => {
|
|
2681
2706
|
});
|
|
2682
|
-
(0,
|
|
2707
|
+
(0, import_react25.useLayoutEffect)(() => {
|
|
2683
2708
|
const root = group.current, marker = indicator.current;
|
|
2684
2709
|
if (!root || !marker) return;
|
|
2685
2710
|
const handle = selectionIndicator(root, marker, tabs);
|
|
@@ -2690,7 +2715,7 @@ function useSelectionIndicator(tabs = false) {
|
|
|
2690
2715
|
};
|
|
2691
2716
|
};
|
|
2692
2717
|
}, [tabs]);
|
|
2693
|
-
(0,
|
|
2718
|
+
(0, import_react25.useLayoutEffect)(() => sync.current());
|
|
2694
2719
|
return { group, indicator };
|
|
2695
2720
|
}
|
|
2696
2721
|
|
|
@@ -2764,9 +2789,9 @@ function KjunSwitch({
|
|
|
2764
2789
|
onChange
|
|
2765
2790
|
}) {
|
|
2766
2791
|
const field = useKjunField();
|
|
2767
|
-
const descriptionId = "kjun-" + (0,
|
|
2792
|
+
const descriptionId = "kjun-" + (0, import_react26.useId)().replace(/:/g, "") + "-description";
|
|
2768
2793
|
const invalid = !!(field == null ? void 0 : field.error), required = !!(field == null ? void 0 : field.required);
|
|
2769
|
-
const markInput = (0,
|
|
2794
|
+
const markInput = (0, import_react26.useCallback)((input) => {
|
|
2770
2795
|
if (!input) return;
|
|
2771
2796
|
if (invalid) input.setAttribute("aria-invalid", "true");
|
|
2772
2797
|
else input.removeAttribute("aria-invalid");
|
|
@@ -2802,7 +2827,7 @@ function KjunSwitch({
|
|
|
2802
2827
|
}
|
|
2803
2828
|
);
|
|
2804
2829
|
}
|
|
2805
|
-
var RadioContext = (0,
|
|
2830
|
+
var RadioContext = (0, import_react26.createContext)(null);
|
|
2806
2831
|
function KjunRadio({
|
|
2807
2832
|
value,
|
|
2808
2833
|
val,
|
|
@@ -2814,7 +2839,7 @@ function KjunRadio({
|
|
|
2814
2839
|
onValueChange,
|
|
2815
2840
|
onChange
|
|
2816
2841
|
}) {
|
|
2817
|
-
const group = (0,
|
|
2842
|
+
const group = (0, import_react26.useContext)(RadioContext), selected = (group ? group.value : value) === val;
|
|
2818
2843
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "kjun-choice" + (disabled ? " kjun-choice--disabled" : ""), children: [
|
|
2819
2844
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2820
2845
|
"input",
|
|
@@ -2853,7 +2878,7 @@ function KjunRadioGroup({
|
|
|
2853
2878
|
onValueChange,
|
|
2854
2879
|
onChange
|
|
2855
2880
|
}) {
|
|
2856
|
-
const name = "kjun-" + (0,
|
|
2881
|
+
const name = "kjun-" + (0, import_react26.useId)();
|
|
2857
2882
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2858
2883
|
RadioContext.Provider,
|
|
2859
2884
|
{
|
|
@@ -2891,7 +2916,7 @@ function KjunRadioGroup({
|
|
|
2891
2916
|
}
|
|
2892
2917
|
);
|
|
2893
2918
|
}
|
|
2894
|
-
var KjunTextarea = (0,
|
|
2919
|
+
var KjunTextarea = (0, import_react26.forwardRef)(
|
|
2895
2920
|
function KjunTextarea2({
|
|
2896
2921
|
value,
|
|
2897
2922
|
size = "md",
|
|
@@ -3065,7 +3090,7 @@ function KjunFilterGroup({
|
|
|
3065
3090
|
|
|
3066
3091
|
// packages/react/src/floating-panel.tsx
|
|
3067
3092
|
var import_tokens19 = require("@kjun-ui/tokens");
|
|
3068
|
-
var
|
|
3093
|
+
var import_react27 = require("react");
|
|
3069
3094
|
var import_react_aria_components4 = require("react-aria-components");
|
|
3070
3095
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3071
3096
|
function FloatingPanel({
|
|
@@ -3086,8 +3111,8 @@ function FloatingPanel({
|
|
|
3086
3111
|
const motion = usePresence(open, useReducedMotion(), import_tokens19.tokens.motion.popupExit);
|
|
3087
3112
|
const layer = useLayer(open, motion.present, "popup", () => onOpenChange(false), triggerRef, returnFocus);
|
|
3088
3113
|
const container = useKjunPortalContainer();
|
|
3089
|
-
const panel = (0,
|
|
3090
|
-
(0,
|
|
3114
|
+
const panel = (0, import_react27.useRef)(null);
|
|
3115
|
+
(0, import_react27.useEffect)(() => {
|
|
3091
3116
|
var _a;
|
|
3092
3117
|
const document2 = (_a = triggerRef.current) == null ? void 0 : _a.ownerDocument;
|
|
3093
3118
|
if (!open || nonModal || !document2 || layer.keyboardManaged) return;
|
|
@@ -3134,10 +3159,11 @@ function FloatingPanel({
|
|
|
3134
3159
|
}
|
|
3135
3160
|
) });
|
|
3136
3161
|
}
|
|
3162
|
+
var resolveFocusReturn = (target) => target === void 0 ? void 0 : () => typeof target === "function" ? target() : target instanceof HTMLElement ? target : target.current;
|
|
3137
3163
|
|
|
3138
3164
|
// packages/react/src/popover.tsx
|
|
3139
3165
|
var import_tokens20 = require("@kjun-ui/tokens");
|
|
3140
|
-
var
|
|
3166
|
+
var import_react28 = require("react");
|
|
3141
3167
|
var import_react_aria_components5 = require("react-aria-components");
|
|
3142
3168
|
|
|
3143
3169
|
// shared/package-runtime/popover-nonmodal.ts
|
|
@@ -3219,20 +3245,20 @@ function KjunPopover({
|
|
|
3219
3245
|
children
|
|
3220
3246
|
}) {
|
|
3221
3247
|
const m = useKjunMessages();
|
|
3222
|
-
const [internal, setInternal] = (0,
|
|
3248
|
+
const [internal, setInternal] = (0, import_react28.useState)(false), open = controlled != null ? controlled : internal, ref = (0, import_react28.useRef)(null), id = "kjun-" + (0, import_react28.useId)();
|
|
3223
3249
|
const expanded = usePopupExpanded(open, ref);
|
|
3224
|
-
const focusOnMount = (0,
|
|
3250
|
+
const focusOnMount = (0, import_react28.useRef)(focusOnOpen);
|
|
3225
3251
|
focusOnMount.current = focusOnOpen;
|
|
3226
|
-
const focusContent = (0,
|
|
3252
|
+
const focusContent = (0, import_react28.useCallback)((node) => {
|
|
3227
3253
|
if (node && focusOnMount.current) node.focus();
|
|
3228
3254
|
}, []);
|
|
3229
|
-
const resolveReturn =
|
|
3255
|
+
const resolveReturn = resolveFocusReturn(returnFocus);
|
|
3230
3256
|
const change = (v) => {
|
|
3231
3257
|
setInternal(v);
|
|
3232
3258
|
onOpenChange == null ? void 0 : onOpenChange(v);
|
|
3233
3259
|
};
|
|
3234
|
-
const skipReturn = (0,
|
|
3235
|
-
(0,
|
|
3260
|
+
const skipReturn = (0, import_react28.useRef)(false);
|
|
3261
|
+
(0, import_react28.useEffect)(() => {
|
|
3236
3262
|
if (!open || modal) return;
|
|
3237
3263
|
skipReturn.current = false;
|
|
3238
3264
|
return installNonModalPopover({
|
|
@@ -3311,7 +3337,7 @@ function KjunTooltip({
|
|
|
3311
3337
|
children
|
|
3312
3338
|
}) {
|
|
3313
3339
|
const container = useKjunPortalContainer();
|
|
3314
|
-
const [internal, setInternal] = (0,
|
|
3340
|
+
const [internal, setInternal] = (0, import_react28.useState)(false), open = controlled != null ? controlled : internal;
|
|
3315
3341
|
const setOpen = (value) => {
|
|
3316
3342
|
setInternal(value);
|
|
3317
3343
|
onOpenChange == null ? void 0 : onOpenChange(value);
|
|
@@ -3338,10 +3364,10 @@ function KjunTooltip({
|
|
|
3338
3364
|
|
|
3339
3365
|
// packages/react/src/dropdown.tsx
|
|
3340
3366
|
var import_tokens21 = require("@kjun-ui/tokens");
|
|
3341
|
-
var
|
|
3367
|
+
var import_react29 = require("react");
|
|
3342
3368
|
var import_react_aria_components6 = require("react-aria-components");
|
|
3343
3369
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3344
|
-
var DropdownContext = (0,
|
|
3370
|
+
var DropdownContext = (0, import_react29.createContext)(null);
|
|
3345
3371
|
function KjunDropdown({
|
|
3346
3372
|
disabled = false,
|
|
3347
3373
|
placement = "bottom-start",
|
|
@@ -3351,12 +3377,13 @@ function KjunDropdown({
|
|
|
3351
3377
|
trigger,
|
|
3352
3378
|
children,
|
|
3353
3379
|
onOpen,
|
|
3354
|
-
onClose
|
|
3380
|
+
onClose,
|
|
3381
|
+
returnFocus
|
|
3355
3382
|
}) {
|
|
3356
|
-
const [open, setOpen] = (0,
|
|
3357
|
-
const menuFocusCleanup = (0,
|
|
3383
|
+
const [open, setOpen] = (0, import_react29.useState)(false), currentOpen = (0, import_react29.useRef)(false), ref = (0, import_react29.useRef)(null), id = "kjun-" + (0, import_react29.useId)();
|
|
3384
|
+
const menuFocusCleanup = (0, import_react29.useRef)(() => {
|
|
3358
3385
|
});
|
|
3359
|
-
const bindMenu = (0,
|
|
3386
|
+
const bindMenu = (0, import_react29.useCallback)((menu) => {
|
|
3360
3387
|
menuFocusCleanup.current();
|
|
3361
3388
|
menuFocusCleanup.current = () => {
|
|
3362
3389
|
};
|
|
@@ -3378,19 +3405,19 @@ function KjunDropdown({
|
|
|
3378
3405
|
};
|
|
3379
3406
|
}, []);
|
|
3380
3407
|
let control = trigger;
|
|
3381
|
-
while ((0,
|
|
3408
|
+
while ((0, import_react29.isValidElement)(control) && control.type === KjunTooltip)
|
|
3382
3409
|
control = control.props.children;
|
|
3383
|
-
const unavailable = disabled || (0,
|
|
3384
|
-
const controlId = triggerId || (0,
|
|
3410
|
+
const unavailable = disabled || (0, import_react29.isValidElement)(control) && !!(control.props.disabled || control.props.loading);
|
|
3411
|
+
const controlId = triggerId || (0, import_react29.isValidElement)(control) && control.props.id || id;
|
|
3385
3412
|
const popupId = menuId || id + "-menu";
|
|
3386
3413
|
const bindTrigger = (node) => {
|
|
3387
|
-
if (!(0,
|
|
3414
|
+
if (!(0, import_react29.isValidElement)(node)) return node;
|
|
3388
3415
|
if (node.type === KjunTooltip) {
|
|
3389
3416
|
const tooltip = node;
|
|
3390
|
-
return (0,
|
|
3417
|
+
return (0, import_react29.cloneElement)(tooltip, {}, bindTrigger(tooltip.props.children));
|
|
3391
3418
|
}
|
|
3392
3419
|
const button = node;
|
|
3393
|
-
return (0,
|
|
3420
|
+
return (0, import_react29.cloneElement)(button, {
|
|
3394
3421
|
id: controlId,
|
|
3395
3422
|
"aria-haspopup": "menu",
|
|
3396
3423
|
"aria-expanded": open,
|
|
@@ -3407,7 +3434,7 @@ function KjunDropdown({
|
|
|
3407
3434
|
if (value) onOpen == null ? void 0 : onOpen();
|
|
3408
3435
|
else onClose == null ? void 0 : onClose();
|
|
3409
3436
|
};
|
|
3410
|
-
(0,
|
|
3437
|
+
(0, import_react29.useEffect)(() => {
|
|
3411
3438
|
if (unavailable) change(false);
|
|
3412
3439
|
}, [unavailable]);
|
|
3413
3440
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(DropdownContext.Provider, { value: () => change(false), children: [
|
|
@@ -3431,6 +3458,7 @@ function KjunDropdown({
|
|
|
3431
3458
|
{
|
|
3432
3459
|
open,
|
|
3433
3460
|
onOpenChange: change,
|
|
3461
|
+
returnFocus: resolveFocusReturn(returnFocus),
|
|
3434
3462
|
triggerRef: ref,
|
|
3435
3463
|
placement,
|
|
3436
3464
|
className: "kjun-dropdown",
|
|
@@ -3460,8 +3488,8 @@ function KjunDropdownItem({
|
|
|
3460
3488
|
children,
|
|
3461
3489
|
onClick
|
|
3462
3490
|
}) {
|
|
3463
|
-
const close = (0,
|
|
3464
|
-
const node = (0,
|
|
3491
|
+
const close = (0, import_react29.useContext)(DropdownContext);
|
|
3492
|
+
const node = (0, import_react29.useCallback)((element) => {
|
|
3465
3493
|
if (!element) return;
|
|
3466
3494
|
if (selected === null) {
|
|
3467
3495
|
element.setAttribute("role", "menuitem");
|
|
@@ -3519,7 +3547,7 @@ function KjunMenuButton({
|
|
|
3519
3547
|
...props
|
|
3520
3548
|
}) {
|
|
3521
3549
|
const m = useKjunMessages();
|
|
3522
|
-
const [open, setOpen] = (0,
|
|
3550
|
+
const [open, setOpen] = (0, import_react29.useState)(false);
|
|
3523
3551
|
const button = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3524
3552
|
KjunButton,
|
|
3525
3553
|
{
|
|
@@ -3588,6 +3616,7 @@ function KjunDrawer({
|
|
|
3588
3616
|
footer,
|
|
3589
3617
|
children,
|
|
3590
3618
|
onClose,
|
|
3619
|
+
onAfterClose,
|
|
3591
3620
|
ariaLabel,
|
|
3592
3621
|
safeAreaTop = 0,
|
|
3593
3622
|
safeAreaBottom = 0,
|
|
@@ -3595,6 +3624,7 @@ function KjunDrawer({
|
|
|
3595
3624
|
}) {
|
|
3596
3625
|
const m = useKjunMessages();
|
|
3597
3626
|
const motion = usePresence(open, useReducedMotion(), import_tokens22.tokens.motion.layerExit);
|
|
3627
|
+
const afterCloseRef = useAfterCloseRef(open, onAfterClose);
|
|
3598
3628
|
const container = useKjunPortalContainer();
|
|
3599
3629
|
const close = () => {
|
|
3600
3630
|
if (!open) return;
|
|
@@ -3608,6 +3638,7 @@ function KjunDrawer({
|
|
|
3608
3638
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(LayerScope.Provider, { value: layer.id, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3609
3639
|
import_react_aria_components7.ModalOverlay,
|
|
3610
3640
|
{
|
|
3641
|
+
ref: afterCloseRef,
|
|
3611
3642
|
style: { zIndex: layer.zIndex, ...drawerOverlayVars({ safeAreaTop, safeAreaBottom, maxHeight }) },
|
|
3612
3643
|
isOpen: motion.present && layer.active,
|
|
3613
3644
|
isExiting: motion.present && !layer.active,
|
|
@@ -3674,7 +3705,7 @@ function KjunDrawer({
|
|
|
3674
3705
|
}
|
|
3675
3706
|
|
|
3676
3707
|
// shared/package-runtime/combobox.ts
|
|
3677
|
-
var
|
|
3708
|
+
var import_react30 = require("react");
|
|
3678
3709
|
|
|
3679
3710
|
// shared/package-runtime/options.ts
|
|
3680
3711
|
var optionValue = (option, key = "value") => typeof option === "object" ? option[key] : option;
|
|
@@ -3752,10 +3783,10 @@ function useComboboxModel({
|
|
|
3752
3783
|
}) {
|
|
3753
3784
|
const selected = options.find((option) => optionValue(option, valueKey) === value);
|
|
3754
3785
|
const selectedLabel = selected !== void 0 ? optionLabel(selected, labelKey) : "";
|
|
3755
|
-
const [query2, setQuery] = (0,
|
|
3756
|
-
const [open, setOpen] = (0,
|
|
3757
|
-
(0,
|
|
3758
|
-
(0,
|
|
3786
|
+
const [query2, setQuery] = (0, import_react30.useState)(selectedLabel);
|
|
3787
|
+
const [open, setOpen] = (0, import_react30.useState)(false);
|
|
3788
|
+
(0, import_react30.useEffect)(() => setQuery(selectedLabel), [value, selectedLabel]);
|
|
3789
|
+
(0, import_react30.useEffect)(() => {
|
|
3759
3790
|
if (disabled) setOpen(false);
|
|
3760
3791
|
}, [disabled]);
|
|
3761
3792
|
const change = (next) => {
|
|
@@ -3788,7 +3819,7 @@ function useComboboxModel({
|
|
|
3788
3819
|
}
|
|
3789
3820
|
|
|
3790
3821
|
// packages/react/src/combobox.tsx
|
|
3791
|
-
var
|
|
3822
|
+
var import_react31 = require("react");
|
|
3792
3823
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3793
3824
|
function KjunCombobox({
|
|
3794
3825
|
value,
|
|
@@ -3807,7 +3838,8 @@ function KjunCombobox({
|
|
|
3807
3838
|
onValueChange,
|
|
3808
3839
|
onChange,
|
|
3809
3840
|
onSearch,
|
|
3810
|
-
onClear
|
|
3841
|
+
onClear,
|
|
3842
|
+
returnFocus
|
|
3811
3843
|
}) {
|
|
3812
3844
|
const m = useKjunMessages();
|
|
3813
3845
|
placeholder != null ? placeholder : placeholder = m.searchOrSelect;
|
|
@@ -3843,7 +3875,8 @@ function KjunCombobox({
|
|
|
3843
3875
|
renderOption,
|
|
3844
3876
|
onValueChange: (v) => model.search(v, true),
|
|
3845
3877
|
onSelect: model.select,
|
|
3846
|
-
onClear: model.clear
|
|
3878
|
+
onClear: model.clear,
|
|
3879
|
+
returnFocus: resolveFocusReturn(returnFocus)
|
|
3847
3880
|
}
|
|
3848
3881
|
);
|
|
3849
3882
|
}
|
|
@@ -3868,16 +3901,17 @@ function SearchField({
|
|
|
3868
3901
|
onValueChange,
|
|
3869
3902
|
onSelect,
|
|
3870
3903
|
onClear,
|
|
3871
|
-
onEnter
|
|
3904
|
+
onEnter,
|
|
3905
|
+
returnFocus
|
|
3872
3906
|
}) {
|
|
3873
3907
|
const m = useKjunMessages();
|
|
3874
3908
|
const composition = useCompositionGuard();
|
|
3875
|
-
const clearing = (0,
|
|
3876
|
-
const ref = (0,
|
|
3909
|
+
const clearing = (0, import_react31.useRef)(false);
|
|
3910
|
+
const ref = (0, import_react31.useRef)(null), [highlighted, setActive] = (0, import_react31.useState)(-1), id = "kjun-" + (0, import_react31.useId)();
|
|
3877
3911
|
const focusGuard = usePopupFocusGuard(ref);
|
|
3878
3912
|
const active = !disabled && !loading && highlighted >= 0 && highlighted < options.length && !optionDisabled(options[highlighted]) ? highlighted : -1;
|
|
3879
|
-
(0,
|
|
3880
|
-
(0,
|
|
3913
|
+
(0, import_react31.useEffect)(() => setActive(-1), [value, options.length]);
|
|
3914
|
+
(0, import_react31.useEffect)(() => {
|
|
3881
3915
|
if (!open) return;
|
|
3882
3916
|
const leaveField = (event) => {
|
|
3883
3917
|
var _a, _b, _c;
|
|
@@ -3887,16 +3921,16 @@ function SearchField({
|
|
|
3887
3921
|
document.addEventListener("focusin", leaveField);
|
|
3888
3922
|
return () => document.removeEventListener("focusin", leaveField);
|
|
3889
3923
|
}, [open, onOpenChange, id]);
|
|
3890
|
-
(0,
|
|
3924
|
+
(0, import_react31.useEffect)(() => {
|
|
3891
3925
|
if (highlighted !== active) setActive(-1);
|
|
3892
3926
|
}, [highlighted, active]);
|
|
3893
3927
|
const available = options.map((o, i) => optionDisabled(o) ? -1 : i).filter((i) => i >= 0);
|
|
3894
3928
|
const select = (o) => {
|
|
3895
|
-
var _a;
|
|
3929
|
+
var _a, _b;
|
|
3896
3930
|
if (o === void 0 || disabled || loading || optionDisabled(o)) return;
|
|
3897
3931
|
onSelect(o);
|
|
3898
3932
|
onOpenChange(false);
|
|
3899
|
-
(_a = ref.current) == null ? void 0 :
|
|
3933
|
+
(_b = (_a = returnFocus == null ? void 0 : returnFocus()) != null ? _a : ref.current) == null ? void 0 : _b.focus();
|
|
3900
3934
|
};
|
|
3901
3935
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
3902
3936
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
@@ -3944,7 +3978,7 @@ function SearchField({
|
|
|
3944
3978
|
onCompositionStart: composition.onCompositionStart,
|
|
3945
3979
|
onCompositionEnd: composition.onCompositionEnd,
|
|
3946
3980
|
onKeyDown: (e) => {
|
|
3947
|
-
var _a, _b, _c, _d;
|
|
3981
|
+
var _a, _b, _c, _d, _e;
|
|
3948
3982
|
if (composition.isComposing(e)) return;
|
|
3949
3983
|
let next = active;
|
|
3950
3984
|
if (e.key === "ArrowDown") {
|
|
@@ -3967,10 +4001,11 @@ function SearchField({
|
|
|
3967
4001
|
e.preventDefault();
|
|
3968
4002
|
e.stopPropagation();
|
|
3969
4003
|
onOpenChange(false);
|
|
4004
|
+
(_d = returnFocus == null ? void 0 : returnFocus()) == null ? void 0 : _d.focus();
|
|
3970
4005
|
}
|
|
3971
4006
|
setActive(next);
|
|
3972
4007
|
if (next >= 0)
|
|
3973
|
-
(
|
|
4008
|
+
(_e = document.getElementById(id + "-" + next)) == null ? void 0 : _e.scrollIntoView({ block: "nearest" });
|
|
3974
4009
|
}
|
|
3975
4010
|
}
|
|
3976
4011
|
),
|
|
@@ -4020,7 +4055,7 @@ function SearchField({
|
|
|
4020
4055
|
|
|
4021
4056
|
// packages/react/src/date-picker.tsx
|
|
4022
4057
|
var import_tokens23 = require("@kjun-ui/tokens");
|
|
4023
|
-
var
|
|
4058
|
+
var import_react32 = require("react");
|
|
4024
4059
|
var import_jsx_runtime20 = (
|
|
4025
4060
|
// The drawn calendar icon matches Native; the transparent browser indicator sits on top of it
|
|
4026
4061
|
// (sized by these variables) so clicking the icon still opens the browser picker.
|
|
@@ -4040,7 +4075,7 @@ function KjunDatePicker({
|
|
|
4040
4075
|
}) {
|
|
4041
4076
|
const scope = useKjunMessageScope();
|
|
4042
4077
|
placeholder != null ? placeholder : placeholder = scope.messages.datePlaceholder;
|
|
4043
|
-
const [focus, setFocus] = (0,
|
|
4078
|
+
const [focus, setFocus] = (0, import_react32.useState)(false);
|
|
4044
4079
|
const clear = clearable && !!value && !props.disabled && !props.readOnly;
|
|
4045
4080
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "kjun-date-picker", style: {
|
|
4046
4081
|
position: "relative",
|
|
@@ -4106,10 +4141,10 @@ function KjunDatePicker({
|
|
|
4106
4141
|
}
|
|
4107
4142
|
|
|
4108
4143
|
// packages/react/src/search-input.tsx
|
|
4109
|
-
var
|
|
4144
|
+
var import_react34 = require("react");
|
|
4110
4145
|
|
|
4111
4146
|
// shared/package-runtime/search-input.ts
|
|
4112
|
-
var
|
|
4147
|
+
var import_react33 = require("react");
|
|
4113
4148
|
function useSearchInputModel({
|
|
4114
4149
|
value,
|
|
4115
4150
|
disabled = false,
|
|
@@ -4119,20 +4154,20 @@ function useSearchInputModel({
|
|
|
4119
4154
|
onValueChange,
|
|
4120
4155
|
onSearchError
|
|
4121
4156
|
}, open) {
|
|
4122
|
-
const [query2, setQuery] = (0,
|
|
4157
|
+
const [query2, setQuery] = (0, import_react33.useState)(value), [options, setOptions] = (0, import_react33.useState)([]), [loading, setLoading] = (0, import_react33.useState)(false), [failed, setFailed] = (0, import_react33.useState)(false), version = (0, import_react33.useRef)(0), notify = (0, import_react33.useRef)(onSearchError);
|
|
4123
4158
|
notify.current = onSearchError;
|
|
4124
|
-
const timer = (0,
|
|
4125
|
-
const notifyValue = (0,
|
|
4159
|
+
const timer = (0, import_react33.useRef)(void 0);
|
|
4160
|
+
const notifyValue = (0, import_react33.useRef)(onValueChange);
|
|
4126
4161
|
notifyValue.current = onValueChange;
|
|
4127
|
-
(0,
|
|
4162
|
+
(0, import_react33.useLayoutEffect)(() => {
|
|
4128
4163
|
clearTimeout(timer.current);
|
|
4129
4164
|
setQuery(value);
|
|
4130
4165
|
}, [value]);
|
|
4131
|
-
(0,
|
|
4166
|
+
(0, import_react33.useLayoutEffect)(() => {
|
|
4132
4167
|
clearTimeout(timer.current);
|
|
4133
4168
|
return () => clearTimeout(timer.current);
|
|
4134
4169
|
}, [disabled, debounce, !!loadOptions]);
|
|
4135
|
-
(0,
|
|
4170
|
+
(0, import_react33.useEffect)(() => {
|
|
4136
4171
|
const current = ++version.current, abort = new AbortController();
|
|
4137
4172
|
setFailed(false);
|
|
4138
4173
|
if (!loadOptions || !open || disabled || query2.length < minChars) {
|
|
@@ -4223,7 +4258,7 @@ function KjunSearchInput({
|
|
|
4223
4258
|
placeholder != null ? placeholder : placeholder = m.search;
|
|
4224
4259
|
emptyText != null ? emptyText : emptyText = m.noResults;
|
|
4225
4260
|
errorText != null ? errorText : errorText = m.searchFailed;
|
|
4226
|
-
const [open, setOpen] = (0,
|
|
4261
|
+
const [open, setOpen] = (0, import_react34.useState)(false);
|
|
4227
4262
|
const model = useSearchInputModel({ value, disabled, debounce, loadOptions, minChars, onValueChange, onSearchError }, open);
|
|
4228
4263
|
const { query: query2, options, loading, failed } = model;
|
|
4229
4264
|
const update = (value2) => {
|
|
@@ -4286,20 +4321,20 @@ function KjunSearchInput({
|
|
|
4286
4321
|
|
|
4287
4322
|
// packages/react/src/select-control.tsx
|
|
4288
4323
|
var import_tokens24 = require("@kjun-ui/tokens");
|
|
4289
|
-
var
|
|
4324
|
+
var import_react37 = require("react");
|
|
4290
4325
|
var import_react_aria_components8 = require("react-aria-components");
|
|
4291
4326
|
|
|
4292
4327
|
// shared/package-runtime/select.ts
|
|
4293
|
-
var
|
|
4328
|
+
var import_react35 = require("react");
|
|
4294
4329
|
function useSelectState(controlled, disabled, pageSize, onOpenChange) {
|
|
4295
|
-
const [internal, setInternal] = (0,
|
|
4296
|
-
const [query2, setQuery] = (0,
|
|
4297
|
-
const [limit, setLimit] = (0,
|
|
4298
|
-
const [session, setSession] = (0,
|
|
4330
|
+
const [internal, setInternal] = (0, import_react35.useState)(false);
|
|
4331
|
+
const [query2, setQuery] = (0, import_react35.useState)("");
|
|
4332
|
+
const [limit, setLimit] = (0, import_react35.useState)(pageSize);
|
|
4333
|
+
const [session, setSession] = (0, import_react35.useState)(0);
|
|
4299
4334
|
const isControlled = typeof controlled === "boolean";
|
|
4300
4335
|
const open = !disabled && (isControlled ? controlled : internal);
|
|
4301
|
-
const previousOpen = (0,
|
|
4302
|
-
(0,
|
|
4336
|
+
const previousOpen = (0, import_react35.useRef)(open);
|
|
4337
|
+
(0, import_react35.useEffect)(() => {
|
|
4303
4338
|
if (disabled && !isControlled) setInternal(false);
|
|
4304
4339
|
if (previousOpen.current && !open) {
|
|
4305
4340
|
setQuery("");
|
|
@@ -4308,7 +4343,7 @@ function useSelectState(controlled, disabled, pageSize, onOpenChange) {
|
|
|
4308
4343
|
}
|
|
4309
4344
|
previousOpen.current = open;
|
|
4310
4345
|
}, [open, disabled, isControlled, pageSize]);
|
|
4311
|
-
(0,
|
|
4346
|
+
(0, import_react35.useEffect)(() => {
|
|
4312
4347
|
setLimit(pageSize);
|
|
4313
4348
|
}, [pageSize]);
|
|
4314
4349
|
const changeOpen = (next) => {
|
|
@@ -4324,8 +4359,8 @@ function useSelectState(controlled, disabled, pageSize, onOpenChange) {
|
|
|
4324
4359
|
}
|
|
4325
4360
|
|
|
4326
4361
|
// packages/react/src/compound-control.ts
|
|
4327
|
-
var
|
|
4328
|
-
var CompoundControlContext = (0,
|
|
4362
|
+
var import_react36 = require("react");
|
|
4363
|
+
var CompoundControlContext = (0, import_react36.createContext)(null);
|
|
4329
4364
|
|
|
4330
4365
|
// packages/react/src/select-control.tsx
|
|
4331
4366
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
@@ -4357,24 +4392,25 @@ function KjunSelect({
|
|
|
4357
4392
|
onSearch,
|
|
4358
4393
|
onClear,
|
|
4359
4394
|
filterFn,
|
|
4360
|
-
searchKeys
|
|
4395
|
+
searchKeys,
|
|
4396
|
+
returnFocus
|
|
4361
4397
|
}) {
|
|
4362
4398
|
const m = useKjunMessages();
|
|
4363
4399
|
placeholder != null ? placeholder : placeholder = m.select;
|
|
4364
4400
|
searchPlaceholder != null ? searchPlaceholder : searchPlaceholder = m.search;
|
|
4365
4401
|
const { open, query: query2, limit, session, changeOpen, search, showMore } = useSelectState(controlled, disabled, optionPageSize, onOpenChange);
|
|
4366
4402
|
const composition = useCompositionGuard();
|
|
4367
|
-
const ref = (0,
|
|
4368
|
-
const segment = (0,
|
|
4403
|
+
const ref = (0, import_react37.useRef)(null), menu = (0, import_react37.useRef)(null), field = useKjunField(), id = "kjun-" + (0, import_react37.useId)();
|
|
4404
|
+
const segment = (0, import_react37.useContext)(CompoundControlContext) !== null;
|
|
4369
4405
|
const spec = import_tokens24.tokens.input[size];
|
|
4370
4406
|
const expanded = usePopupExpanded(open, ref);
|
|
4371
4407
|
const registerControl = field == null ? void 0 : field.setControlId;
|
|
4372
|
-
(0,
|
|
4408
|
+
(0, import_react37.useEffect)(() => {
|
|
4373
4409
|
if (!registerControl || !triggerId) return;
|
|
4374
4410
|
registerControl(triggerId);
|
|
4375
4411
|
return () => registerControl(void 0);
|
|
4376
4412
|
}, [registerControl, triggerId]);
|
|
4377
|
-
(0,
|
|
4413
|
+
(0, import_react37.useEffect)(() => {
|
|
4378
4414
|
var _a, _b;
|
|
4379
4415
|
if (open && searchable) (_b = (_a = menu.current) == null ? void 0 : _a.querySelector("input")) == null ? void 0 : _b.focus({ preventScroll: true });
|
|
4380
4416
|
if (!open) composition.onCompositionEnd();
|
|
@@ -4466,6 +4502,7 @@ function KjunSelect({
|
|
|
4466
4502
|
{
|
|
4467
4503
|
field: true,
|
|
4468
4504
|
open,
|
|
4505
|
+
returnFocus: resolveFocusReturn(returnFocus),
|
|
4469
4506
|
onOpenChange: changeOpen,
|
|
4470
4507
|
triggerRef: ref,
|
|
4471
4508
|
placement: "bottom-start",
|
|
@@ -4565,17 +4602,19 @@ var import_tokens26 = require("@kjun-ui/tokens");
|
|
|
4565
4602
|
|
|
4566
4603
|
// packages/react/src/collapse.tsx
|
|
4567
4604
|
var import_tokens25 = require("@kjun-ui/tokens");
|
|
4568
|
-
var
|
|
4605
|
+
var import_react38 = require("react");
|
|
4569
4606
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
4570
|
-
function Collapse({ open, children }) {
|
|
4607
|
+
function Collapse({ open, keepMounted = false, children }) {
|
|
4571
4608
|
const reduced = useReducedMotion();
|
|
4572
|
-
const [retained, setRetained] = (0,
|
|
4573
|
-
const root = (0,
|
|
4574
|
-
const animation = (0,
|
|
4575
|
-
const previous = (0,
|
|
4576
|
-
const interrupted = (0,
|
|
4577
|
-
const
|
|
4578
|
-
|
|
4609
|
+
const [retained, setRetained] = (0, import_react38.useState)(open);
|
|
4610
|
+
const root = (0, import_react38.useRef)(null), body = (0, import_react38.useRef)(null);
|
|
4611
|
+
const animation = (0, import_react38.useRef)(null);
|
|
4612
|
+
const previous = (0, import_react38.useRef)(open);
|
|
4613
|
+
const interrupted = (0, import_react38.useRef)(null);
|
|
4614
|
+
const opened = (0, import_react38.useRef)(open);
|
|
4615
|
+
if (open) opened.current = true;
|
|
4616
|
+
const present = open || retained || keepMounted && opened.current;
|
|
4617
|
+
(0, import_react38.useLayoutEffect)(() => {
|
|
4579
4618
|
const el = root.current, inner = body.current;
|
|
4580
4619
|
if (!el || !inner) return;
|
|
4581
4620
|
let disposed = false;
|
|
@@ -4630,10 +4669,10 @@ function Collapse({ open, children }) {
|
|
|
4630
4669
|
}
|
|
4631
4670
|
|
|
4632
4671
|
// shared/package-runtime/navigation.ts
|
|
4633
|
-
var
|
|
4672
|
+
var import_react39 = require("react");
|
|
4634
4673
|
function useInitialTab(value, candidate, change) {
|
|
4635
|
-
const requested = (0,
|
|
4636
|
-
(0,
|
|
4674
|
+
const requested = (0, import_react39.useRef)(/* @__PURE__ */ new Set());
|
|
4675
|
+
(0, import_react39.useEffect)(() => {
|
|
4637
4676
|
if (value !== "") {
|
|
4638
4677
|
requested.current.clear();
|
|
4639
4678
|
return;
|
|
@@ -4644,8 +4683,8 @@ function useInitialTab(value, candidate, change) {
|
|
|
4644
4683
|
}, [value, candidate, change]);
|
|
4645
4684
|
}
|
|
4646
4685
|
function useAccordionState(multiple) {
|
|
4647
|
-
const [opened, setOpened] = (0,
|
|
4648
|
-
(0,
|
|
4686
|
+
const [opened, setOpened] = (0, import_react39.useState)(/* @__PURE__ */ new Set());
|
|
4687
|
+
(0, import_react39.useEffect)(() => {
|
|
4649
4688
|
if (!multiple) setOpened((previous) => previous.size > 1 ? new Set([...previous].slice(-1)) : previous);
|
|
4650
4689
|
}, [multiple]);
|
|
4651
4690
|
return {
|
|
@@ -4729,7 +4768,7 @@ function manageTabList(list, select, keyboard = true) {
|
|
|
4729
4768
|
}
|
|
4730
4769
|
|
|
4731
4770
|
// packages/react/src/navigation.tsx
|
|
4732
|
-
var
|
|
4771
|
+
var import_react40 = require("react");
|
|
4733
4772
|
var import_react_aria_components9 = require("react-aria-components");
|
|
4734
4773
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
4735
4774
|
function KjunTabs({
|
|
@@ -4748,33 +4787,33 @@ function KjunTabs({
|
|
|
4748
4787
|
const m = useKjunMessages();
|
|
4749
4788
|
ariaLabel != null ? ariaLabel : ariaLabel = m.tabs;
|
|
4750
4789
|
const { group, indicator } = useSelectionIndicator(true);
|
|
4751
|
-
const panes =
|
|
4752
|
-
|
|
4790
|
+
const panes = import_react40.Children.toArray(children).filter(
|
|
4791
|
+
import_react40.isValidElement
|
|
4753
4792
|
);
|
|
4754
4793
|
const tabs = items.length ? items : panes.filter((child) => child.type === KjunTabPane).map((child) => child.props);
|
|
4755
|
-
(0,
|
|
4794
|
+
(0, import_react40.useLayoutEffect)(() => {
|
|
4756
4795
|
var _a2;
|
|
4757
4796
|
const list = (_a2 = group.current) == null ? void 0 : _a2.querySelector('[role="tablist"]');
|
|
4758
4797
|
if (list) return manageTabList(list, () => {
|
|
4759
4798
|
}, false);
|
|
4760
4799
|
}, [group]);
|
|
4761
|
-
(0,
|
|
4800
|
+
(0, import_react40.useLayoutEffect)(() => {
|
|
4762
4801
|
var _a2;
|
|
4763
4802
|
const panelNames = new Set(panes.filter((child) => child.type === KjunTabPane).map((child) => child.props.name));
|
|
4764
4803
|
for (const tab of ((_a2 = group.current) == null ? void 0 : _a2.querySelectorAll('[role="tab"]')) || []) {
|
|
4765
4804
|
if (!panelNames.has(tab.dataset.tabName)) tab.removeAttribute("aria-controls");
|
|
4766
4805
|
}
|
|
4767
4806
|
});
|
|
4768
|
-
const timer = (0,
|
|
4769
|
-
const menuState = (0,
|
|
4807
|
+
const timer = (0, import_react40.useRef)(void 0), press = (0, import_react40.useRef)(null);
|
|
4808
|
+
const menuState = (0, import_react40.useRef)({ tabs, onTabMenu });
|
|
4770
4809
|
menuState.current = { tabs, onTabMenu };
|
|
4771
4810
|
const canOpenMenu = (name) => !!menuState.current.onTabMenu && menuState.current.tabs.some((tab) => tab.name === name && !tab.disabled);
|
|
4772
4811
|
const clear = () => {
|
|
4773
4812
|
clearTimeout(timer.current);
|
|
4774
4813
|
press.current = null;
|
|
4775
4814
|
};
|
|
4776
|
-
(0,
|
|
4777
|
-
(0,
|
|
4815
|
+
(0, import_react40.useEffect)(() => clear, []);
|
|
4816
|
+
(0, import_react40.useLayoutEffect)(() => {
|
|
4778
4817
|
if (press.current && !canOpenMenu(press.current.name)) clear();
|
|
4779
4818
|
}, [tabs, onTabMenu]);
|
|
4780
4819
|
const change = (name) => {
|
|
@@ -4871,7 +4910,7 @@ function KjunTabPane({ name, children }) {
|
|
|
4871
4910
|
}
|
|
4872
4911
|
);
|
|
4873
4912
|
}
|
|
4874
|
-
var AccordionContext = (0,
|
|
4913
|
+
var AccordionContext = (0, import_react40.createContext)(null);
|
|
4875
4914
|
function KjunAccordion({
|
|
4876
4915
|
multiple = false,
|
|
4877
4916
|
tone = "card",
|
|
@@ -4891,12 +4930,30 @@ function KjunAccordionItem({
|
|
|
4891
4930
|
defaultOpen = false,
|
|
4892
4931
|
disabled = false,
|
|
4893
4932
|
header,
|
|
4933
|
+
open: openProp,
|
|
4934
|
+
onOpenChange,
|
|
4935
|
+
keepMounted = false,
|
|
4894
4936
|
children
|
|
4895
4937
|
}) {
|
|
4896
|
-
const
|
|
4897
|
-
(0,
|
|
4938
|
+
const controlled = openProp !== void 0, context = (0, import_react40.useContext)(AccordionContext), group = controlled ? null : context, id = "kjun-" + (0, import_react40.useId)(), [own, setOwn] = (0, import_react40.useState)(defaultOpen), open = controlled ? openProp : group ? group.opened.has(id) : own;
|
|
4939
|
+
(0, import_react40.useEffect)(() => {
|
|
4898
4940
|
return group == null ? void 0 : group.register(id, defaultOpen);
|
|
4899
4941
|
}, []);
|
|
4942
|
+
const reported = (0, import_react40.useRef)(open), notify = (0, import_react40.useRef)(onOpenChange), registering = (0, import_react40.useRef)(!!group && defaultOpen);
|
|
4943
|
+
notify.current = onOpenChange;
|
|
4944
|
+
(0, import_react40.useEffect)(() => {
|
|
4945
|
+
var _a;
|
|
4946
|
+
if (registering.current) {
|
|
4947
|
+
if (open) {
|
|
4948
|
+
registering.current = false;
|
|
4949
|
+
reported.current = open;
|
|
4950
|
+
}
|
|
4951
|
+
return;
|
|
4952
|
+
}
|
|
4953
|
+
if (controlled || reported.current === open) return;
|
|
4954
|
+
reported.current = open;
|
|
4955
|
+
(_a = notify.current) == null ? void 0 : _a.call(notify, open);
|
|
4956
|
+
}, [open, controlled]);
|
|
4900
4957
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "kjun-accordion-item", children: [
|
|
4901
4958
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4902
4959
|
"button",
|
|
@@ -4907,7 +4964,10 @@ function KjunAccordionItem({
|
|
|
4907
4964
|
"aria-expanded": open,
|
|
4908
4965
|
"aria-controls": id + "-panel",
|
|
4909
4966
|
className: "kjun-accordion-trigger",
|
|
4910
|
-
onClick: () =>
|
|
4967
|
+
onClick: () => {
|
|
4968
|
+
registering.current = false;
|
|
4969
|
+
controlled ? onOpenChange == null ? void 0 : onOpenChange(!open) : group ? group.toggle(id) : setOwn(!own);
|
|
4970
|
+
},
|
|
4911
4971
|
children: [
|
|
4912
4972
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "kjun-accordion-heading", children: header || title }),
|
|
4913
4973
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
@@ -4922,7 +4982,7 @@ function KjunAccordionItem({
|
|
|
4922
4982
|
]
|
|
4923
4983
|
}
|
|
4924
4984
|
),
|
|
4925
|
-
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Collapse, { open, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4985
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Collapse, { open, keepMounted, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4926
4986
|
"div",
|
|
4927
4987
|
{
|
|
4928
4988
|
role: "region",
|
|
@@ -4947,7 +5007,7 @@ function KjunBreadcrumb({
|
|
|
4947
5007
|
" ",
|
|
4948
5008
|
item.label
|
|
4949
5009
|
] });
|
|
4950
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
5010
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react40.Fragment, { children: [
|
|
4951
5011
|
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KjunIcon, { name: "chevron-right", size: import_tokens26.tokens.extensions.breadcrumb.separatorSize }),
|
|
4952
5012
|
" ",
|
|
4953
5013
|
item.to && i < items.length - 1 ? (renderLink == null ? void 0 : renderLink(item, label)) || /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("a", { href: item.to, children: label }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "aria-current": i === items.length - 1 ? "page" : void 0, children: label })
|
|
@@ -5049,7 +5109,7 @@ function KjunPagination({
|
|
|
5049
5109
|
|
|
5050
5110
|
// packages/react/src/actions.tsx
|
|
5051
5111
|
var import_tokens27 = require("@kjun-ui/tokens");
|
|
5052
|
-
var
|
|
5112
|
+
var import_react41 = require("react");
|
|
5053
5113
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
5054
5114
|
function KjunIconToggle({
|
|
5055
5115
|
active = false,
|
|
@@ -5069,7 +5129,7 @@ function KjunIconToggle({
|
|
|
5069
5129
|
onToggle
|
|
5070
5130
|
}) {
|
|
5071
5131
|
var _a;
|
|
5072
|
-
const navigation = (0,
|
|
5132
|
+
const navigation = (0, import_react41.useContext)(TopNavigationContext);
|
|
5073
5133
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(KjunTooltip, { content: disabled || loading ? "" : tooltip != null ? tooltip : ariaLabel, placement: tooltipPlacement, delay: tooltipDelay, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5074
5134
|
"button",
|
|
5075
5135
|
{
|
|
@@ -5131,8 +5191,8 @@ function KjunCopyButton({
|
|
|
5131
5191
|
const m = useKjunMessages();
|
|
5132
5192
|
successText != null ? successText : successText = m.copied;
|
|
5133
5193
|
const feedback = useOptionalKjunFeedback();
|
|
5134
|
-
const [copied, setCopied] = (0,
|
|
5135
|
-
(0,
|
|
5194
|
+
const [copied, setCopied] = (0, import_react41.useState)(false), [failed, setFailed] = (0, import_react41.useState)(false), busy = (0, import_react41.useRef)(false), timer = (0, import_react41.useRef)(void 0), mounted = (0, import_react41.useRef)(true);
|
|
5195
|
+
(0, import_react41.useEffect)(() => {
|
|
5136
5196
|
mounted.current = true;
|
|
5137
5197
|
return () => {
|
|
5138
5198
|
mounted.current = false;
|
|
@@ -5263,7 +5323,7 @@ function KjunExternalLink({
|
|
|
5263
5323
|
) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "aria-label": name, children: body });
|
|
5264
5324
|
}
|
|
5265
5325
|
function KjunScrollFade({ children }) {
|
|
5266
|
-
const ref = (0,
|
|
5326
|
+
const ref = (0, import_react41.useRef)(null), [edges, setEdges] = (0, import_react41.useState)({ left: false, right: false });
|
|
5267
5327
|
const update = () => {
|
|
5268
5328
|
const el = ref.current;
|
|
5269
5329
|
if (el)
|
|
@@ -5275,7 +5335,7 @@ function KjunScrollFade({ children }) {
|
|
|
5275
5335
|
return prev.left === next.left && prev.right === next.right ? prev : next;
|
|
5276
5336
|
});
|
|
5277
5337
|
};
|
|
5278
|
-
(0,
|
|
5338
|
+
(0, import_react41.useEffect)(() => {
|
|
5279
5339
|
update();
|
|
5280
5340
|
const observer = new ResizeObserver(update);
|
|
5281
5341
|
if (ref.current) {
|
|
@@ -5299,13 +5359,13 @@ function KjunScrollFade({ children }) {
|
|
|
5299
5359
|
|
|
5300
5360
|
// packages/react/src/data-state.tsx
|
|
5301
5361
|
var import_tokens28 = require("@kjun-ui/tokens");
|
|
5302
|
-
var
|
|
5362
|
+
var import_react43 = require("react");
|
|
5303
5363
|
|
|
5304
5364
|
// shared/package-runtime/use-loading-reveal.ts
|
|
5305
|
-
var
|
|
5365
|
+
var import_react42 = require("react");
|
|
5306
5366
|
function useLoadingReveal(active, delay = 0) {
|
|
5307
|
-
const [revealed, setRevealed] = (0,
|
|
5308
|
-
(0,
|
|
5367
|
+
const [revealed, setRevealed] = (0, import_react42.useState)(false);
|
|
5368
|
+
(0, import_react42.useEffect)(() => {
|
|
5309
5369
|
setRevealed(false);
|
|
5310
5370
|
if (!active || delay <= 0) return;
|
|
5311
5371
|
const timer = setTimeout(() => setRevealed(true), delay);
|
|
@@ -5318,7 +5378,7 @@ function useLoadingReveal(active, delay = 0) {
|
|
|
5318
5378
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
5319
5379
|
function useQueryDisplay(props) {
|
|
5320
5380
|
var _a;
|
|
5321
|
-
const [state, setState] = (0,
|
|
5381
|
+
const [state, setState] = (0, import_react43.useState)(() => (0, import_tokens28.initialQueryDisplay)(props));
|
|
5322
5382
|
let next = state;
|
|
5323
5383
|
if (state.queryKey !== ((_a = props.queryKey) != null ? _a : null) || state.resultKey !== props.resultKey || state.loading !== !!props.loading) {
|
|
5324
5384
|
next = (0, import_tokens28.advanceQueryDisplay)(state, props);
|
|
@@ -5392,7 +5452,7 @@ function KjunDataState({
|
|
|
5392
5452
|
visibleRefreshError && !state.initialLoading && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "kjun-data-warning kjun-state-actions", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(KjunAlert, { type: "warning", size: "sm", actions: onRetry && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(KjunButton, { variant: "secondary", onClick: onRetry, children: retryText }), children: m.refreshError(String(visibleRefreshError)) }) })
|
|
5393
5453
|
] });
|
|
5394
5454
|
}
|
|
5395
|
-
var KjunErrorBoundary = class extends
|
|
5455
|
+
var KjunErrorBoundary = class extends import_react43.Component {
|
|
5396
5456
|
constructor() {
|
|
5397
5457
|
super(...arguments);
|
|
5398
5458
|
this.state = { error: false };
|
|
@@ -5629,13 +5689,13 @@ function KjunChartSkeleton({
|
|
|
5629
5689
|
|
|
5630
5690
|
// packages/react/src/financial-display.tsx
|
|
5631
5691
|
var import_tokens34 = require("@kjun-ui/tokens");
|
|
5632
|
-
var
|
|
5692
|
+
var import_react45 = require("react");
|
|
5633
5693
|
|
|
5634
5694
|
// packages/react/src/number-display.tsx
|
|
5635
5695
|
var import_tokens33 = require("@kjun-ui/tokens");
|
|
5636
5696
|
|
|
5637
5697
|
// shared/package-runtime/use-number-motion.ts
|
|
5638
|
-
var
|
|
5698
|
+
var import_react44 = require("react");
|
|
5639
5699
|
|
|
5640
5700
|
// shared/package-runtime/number-motion.ts
|
|
5641
5701
|
var import_tokens32 = require("@kjun-ui/tokens");
|
|
@@ -5681,14 +5741,14 @@ function createNumberMotion(apply) {
|
|
|
5681
5741
|
|
|
5682
5742
|
// shared/package-runtime/use-number-motion.ts
|
|
5683
5743
|
function useNumberMotion(value, animated, fromPrevious, reduced) {
|
|
5684
|
-
const [display, setDisplay] = (0,
|
|
5685
|
-
const motion = (0,
|
|
5744
|
+
const [display, setDisplay] = (0, import_react44.useState)(typeof value === "string" || fromPrevious || !animated || reduced ? value : 0);
|
|
5745
|
+
const motion = (0, import_react44.useRef)(null);
|
|
5686
5746
|
if (!motion.current) motion.current = createNumberMotion(setDisplay);
|
|
5687
|
-
(0,
|
|
5747
|
+
(0, import_react44.useLayoutEffect)(() => {
|
|
5688
5748
|
if (!motion.current) motion.current = createNumberMotion(setDisplay);
|
|
5689
5749
|
motion.current.update(value, animated, fromPrevious, reduced);
|
|
5690
5750
|
}, [value, animated, fromPrevious, reduced]);
|
|
5691
|
-
(0,
|
|
5751
|
+
(0, import_react44.useLayoutEffect)(() => () => {
|
|
5692
5752
|
var _a;
|
|
5693
5753
|
(_a = motion.current) == null ? void 0 : _a.cancel();
|
|
5694
5754
|
motion.current = null;
|
|
@@ -5966,7 +6026,7 @@ function KjunSparkline({
|
|
|
5966
6026
|
stretch = false,
|
|
5967
6027
|
ariaLabel
|
|
5968
6028
|
}) {
|
|
5969
|
-
const id = "kjun-" + (0,
|
|
6029
|
+
const id = "kjun-" + (0, import_react45.useId)().replace(/:/g, ""), values = data.filter(Number.isFinite), min = Math.min(...values), max = Math.max(...values), range = max - min || 1, points = values.map(
|
|
5970
6030
|
(v, i) => `${2 + i / Math.max(1, values.length - 1) * (width - 4)},${2 + height - 4 - (v - min) / range * (height - 4)}`
|
|
5971
6031
|
).join(" "), change = values.length > 1 ? values[values.length - 1] - values[0] : 0, line = color || `var(--_kjun-color-${change === 0 ? "text-tertiary" : semantic === "status" ? change > 0 ? "success" : "danger" : change > 0 ? "price-up" : "price-down"})`;
|
|
5972
6032
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
@@ -6014,7 +6074,7 @@ function KjunSparkline({
|
|
|
6014
6074
|
|
|
6015
6075
|
// shared/package-runtime/table.ts
|
|
6016
6076
|
var import_tokens35 = require("@kjun-ui/tokens");
|
|
6017
|
-
var
|
|
6077
|
+
var import_react46 = require("react");
|
|
6018
6078
|
|
|
6019
6079
|
// shared/package-runtime/table-model.ts
|
|
6020
6080
|
function getValue(row, key) {
|
|
@@ -6058,11 +6118,11 @@ function useTableModel(props) {
|
|
|
6058
6118
|
expandSingle = false,
|
|
6059
6119
|
onExpandedRowsChange
|
|
6060
6120
|
} = props;
|
|
6061
|
-
const [internalSort, setSort] = (0,
|
|
6121
|
+
const [internalSort, setSort] = (0, import_react46.useState)({
|
|
6062
6122
|
key: "",
|
|
6063
6123
|
order: "asc"
|
|
6064
|
-
}), [internalExpanded, setExpanded] = (0,
|
|
6065
|
-
(0,
|
|
6124
|
+
}), [internalExpanded, setExpanded] = (0, import_react46.useState)([]), [search, setSearch] = (0, import_react46.useState)(""), timer = (0, import_react46.useRef)(void 0);
|
|
6125
|
+
(0, import_react46.useEffect)(() => () => clearTimeout(timer.current), []);
|
|
6066
6126
|
const sort = props.sort === void 0 ? internalSort : (_a = props.sort) != null ? _a : { key: "", order: "asc" };
|
|
6067
6127
|
const rows = sortTableRows(data, sort, { sortable, sortMode });
|
|
6068
6128
|
const key = (row, index = 0) => tableRowKey(row, rowKey, index);
|
|
@@ -6211,10 +6271,10 @@ function TableToolbar({
|
|
|
6211
6271
|
|
|
6212
6272
|
// packages/react/src/table-grid.tsx
|
|
6213
6273
|
var import_tokens38 = require("@kjun-ui/tokens");
|
|
6214
|
-
var
|
|
6274
|
+
var import_react48 = require("react");
|
|
6215
6275
|
|
|
6216
6276
|
// packages/react/src/table-check.tsx
|
|
6217
|
-
var
|
|
6277
|
+
var import_react47 = require("react");
|
|
6218
6278
|
|
|
6219
6279
|
// shared/package-runtime/component-icons.ts
|
|
6220
6280
|
var import_minus = __toESM(require("@kjun-ui/icons/icons/minus"), 1);
|
|
@@ -6223,7 +6283,7 @@ var componentIcons = { minus: import_minus.default };
|
|
|
6223
6283
|
// packages/react/src/table-check.tsx
|
|
6224
6284
|
var import_tokens37 = require("@kjun-ui/tokens");
|
|
6225
6285
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6226
|
-
var TableCheck = (0,
|
|
6286
|
+
var TableCheck = (0, import_react47.forwardRef)(
|
|
6227
6287
|
function TableCheck2(props, ref) {
|
|
6228
6288
|
const size = import_tokens37.tokens.extensions.checkbox.iconSizes.sm;
|
|
6229
6289
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(IconFallbacks, { icons: componentIcons, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("span", { className: "kjun-table-check", children: [
|
|
@@ -6312,7 +6372,7 @@ function TableGrid({ initialLoading, skeletonRows, skeletonHidden, state, onRowC
|
|
|
6312
6372
|
className: "kjun-table-empty",
|
|
6313
6373
|
children: emptyContent || emptyText
|
|
6314
6374
|
}
|
|
6315
|
-
) }) : state.rows.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
6375
|
+
) }) : state.rows.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_react48.Fragment, { children: [
|
|
6316
6376
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
6317
6377
|
"tr",
|
|
6318
6378
|
{
|
|
@@ -6456,7 +6516,7 @@ function TableCards({
|
|
|
6456
6516
|
}
|
|
6457
6517
|
|
|
6458
6518
|
// packages/react/src/table-view.tsx
|
|
6459
|
-
var
|
|
6519
|
+
var import_react49 = require("react");
|
|
6460
6520
|
var import_tokens39 = require("@kjun-ui/tokens");
|
|
6461
6521
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
6462
6522
|
function KjunTable(props) {
|
|
@@ -6487,8 +6547,8 @@ function KjunTable(props) {
|
|
|
6487
6547
|
onRowClick,
|
|
6488
6548
|
onRetry
|
|
6489
6549
|
} = props;
|
|
6490
|
-
const state = useTableModel2(props), query2 = useQueryDisplay(props), revealed = useLoadingReveal(query2.initialLoading, skeleton ? loadingDelay : 0), [mobile, setMobile] = (0,
|
|
6491
|
-
(0,
|
|
6550
|
+
const state = useTableModel2(props), query2 = useQueryDisplay(props), revealed = useLoadingReveal(query2.initialLoading, skeleton ? loadingDelay : 0), [mobile, setMobile] = (0, import_react49.useState)(false);
|
|
6551
|
+
(0, import_react49.useEffect)(() => {
|
|
6492
6552
|
const media = matchMedia(`(width < ${import_tokens39.tokens.table.mobileBreakpoint}px)`);
|
|
6493
6553
|
const update = () => setMobile(media.matches);
|
|
6494
6554
|
update();
|
|
@@ -6854,7 +6914,7 @@ function KjunKpiRow({
|
|
|
6854
6914
|
var import_tokens41 = require("@kjun-ui/tokens");
|
|
6855
6915
|
|
|
6856
6916
|
// shared/package-runtime/market-cards.ts
|
|
6857
|
-
var
|
|
6917
|
+
var import_react50 = require("react");
|
|
6858
6918
|
function useMarketCardsModel(props, persistence) {
|
|
6859
6919
|
const {
|
|
6860
6920
|
columns,
|
|
@@ -6870,8 +6930,8 @@ function useMarketCardsModel(props, persistence) {
|
|
|
6870
6930
|
sortKey: c.sortable ? metricConfig[c.key].sortKey : null,
|
|
6871
6931
|
isDefaultSort: c.defaultSort
|
|
6872
6932
|
}));
|
|
6873
|
-
const [key, setKey] = (0,
|
|
6874
|
-
const mounted = (0,
|
|
6933
|
+
const [key, setKey] = (0, import_react50.useState)(""), restoreSignature = JSON.stringify([storageNamespace, pills]);
|
|
6934
|
+
const mounted = (0, import_react50.useRef)("");
|
|
6875
6935
|
const save = (key2) => {
|
|
6876
6936
|
var _a;
|
|
6877
6937
|
try {
|
|
@@ -6879,7 +6939,7 @@ function useMarketCardsModel(props, persistence) {
|
|
|
6879
6939
|
} catch (e) {
|
|
6880
6940
|
}
|
|
6881
6941
|
};
|
|
6882
|
-
(0,
|
|
6942
|
+
(0, import_react50.useEffect)(() => {
|
|
6883
6943
|
var _a, _b;
|
|
6884
6944
|
if (mounted.current === restoreSignature) return;
|
|
6885
6945
|
mounted.current = restoreSignature;
|
|
@@ -7214,7 +7274,7 @@ function watchTrailingOverflow(element, onChange) {
|
|
|
7214
7274
|
}
|
|
7215
7275
|
|
|
7216
7276
|
// packages/react/src/market-table.tsx
|
|
7217
|
-
var
|
|
7277
|
+
var import_react51 = require("react");
|
|
7218
7278
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
7219
7279
|
function KjunMarketTable(props) {
|
|
7220
7280
|
const m = useKjunMessages();
|
|
@@ -7236,8 +7296,8 @@ function KjunMarketTable(props) {
|
|
|
7236
7296
|
formatMetric,
|
|
7237
7297
|
renderCell
|
|
7238
7298
|
} = props;
|
|
7239
|
-
const scroller = (0,
|
|
7240
|
-
(0,
|
|
7299
|
+
const scroller = (0, import_react51.useRef)(null), [fadeEnd, setFadeEnd] = (0, import_react51.useState)(false);
|
|
7300
|
+
(0, import_react51.useEffect)(() => scroller.current ? watchTrailingOverflow(scroller.current, setFadeEnd) : void 0, [rows, columns]);
|
|
7241
7301
|
const render = (row, col) => {
|
|
7242
7302
|
const value = getValue(row, col.key), stale = !!getValue(row, "stale");
|
|
7243
7303
|
if (cellLoading(row, col))
|
|
@@ -7427,26 +7487,31 @@ function KjunMarketTable(props) {
|
|
|
7427
7487
|
|
|
7428
7488
|
// packages/react/src/list.tsx
|
|
7429
7489
|
var import_tokens45 = require("@kjun-ui/tokens");
|
|
7430
|
-
var
|
|
7490
|
+
var import_react52 = require("react");
|
|
7431
7491
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
7432
|
-
function KjunListRow({ title, description, leading, trailing, actions, href, disabled = false, destructive = false, chevron = false, onClick }) {
|
|
7492
|
+
function KjunListRow({ title, description, leading, trailing, actions, href, disabled = false, destructive = false, chevron = false, onClick, ariaLabel, children }) {
|
|
7493
|
+
const content = (0, import_react52.useRef)(null), pressable = !!(href || onClick);
|
|
7494
|
+
(0, import_react52.useEffect)(() => {
|
|
7495
|
+
if (pressable) warnNestedControls(content.current, "KJUN ListRow: a pressable row's content contains buttons or links; move them to actions.");
|
|
7496
|
+
}, [pressable]);
|
|
7433
7497
|
const contents = /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
|
|
7434
7498
|
leading && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-list-leading", children: leading }),
|
|
7435
7499
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("span", { className: "kjun-list-body", children: [
|
|
7436
7500
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-list-title", children: title }),
|
|
7437
|
-
description && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-list-description", children: description })
|
|
7501
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-list-description", children: description }),
|
|
7502
|
+
hasContent(children) && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { ref: content, className: "kjun-list-content", children })
|
|
7438
7503
|
] }),
|
|
7439
7504
|
trailing && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-list-trailing", children: trailing }),
|
|
7440
7505
|
chevron && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(KjunIcon, { name: "chevron-right", className: "kjun-list-chevron", size: import_tokens45.tokens.iconSizes.default })
|
|
7441
7506
|
] });
|
|
7442
|
-
const main = href ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("a", { className: "kjun-list-main", href: disabled ? void 0 : href, "aria-disabled": disabled || void 0, onClick: disabled ? (e) => e.preventDefault() : onClick, children: contents }) : onClick ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { className: "kjun-list-main", type: "button", disabled, onClick, children: contents }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "kjun-list-main", children: contents });
|
|
7507
|
+
const main = href ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("a", { className: "kjun-list-main", href: disabled ? void 0 : href, "aria-label": ariaLabel, "aria-disabled": disabled || void 0, onClick: disabled ? (e) => e.preventDefault() : onClick, children: contents }) : onClick ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { className: "kjun-list-main", type: "button", "aria-label": ariaLabel, disabled, onClick, children: contents }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "kjun-list-main", children: contents });
|
|
7443
7508
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("li", { className: "kjun-list-row", "data-destructive": destructive || void 0, children: [
|
|
7444
7509
|
main,
|
|
7445
7510
|
actions && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "kjun-list-actions", "data-disabled": disabled || void 0, inert: disabled || void 0, children: actions })
|
|
7446
7511
|
] });
|
|
7447
7512
|
}
|
|
7448
7513
|
function KjunListSection({ title, description, actions, children, ariaLabel, surface = true, divider = true, density = "default" }) {
|
|
7449
|
-
const id = "kjun-" + (0,
|
|
7514
|
+
const id = "kjun-" + (0, import_react52.useId)();
|
|
7450
7515
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "kjun-list-section", "data-surface": surface ? void 0 : "false", "aria-labelledby": title ? id : void 0, "aria-label": title ? void 0 : ariaLabel, children: [
|
|
7451
7516
|
(title || description || actions) && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "kjun-list-heading", children: [
|
|
7452
7517
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
|
|
@@ -7506,14 +7571,14 @@ function KjunBottomActionBar({ description, children, safeAreaBottom = 0, keyboa
|
|
|
7506
7571
|
}
|
|
7507
7572
|
|
|
7508
7573
|
// packages/react/src/media.tsx
|
|
7509
|
-
var
|
|
7574
|
+
var import_react53 = require("react");
|
|
7510
7575
|
var import_tokens47 = require("@kjun-ui/tokens");
|
|
7511
7576
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
7512
7577
|
function KjunImage({ src, alt, decorative = false, aspectRatio = 1, fit = "cover", fallback: fallback2, lazy = true, onLoad, onError }) {
|
|
7513
|
-
const current = (0,
|
|
7578
|
+
const current = (0, import_react53.useRef)({ src, version: 0 });
|
|
7514
7579
|
if (current.current.src !== src) current.current = { src, version: current.current.version + 1 };
|
|
7515
7580
|
const version = current.current.version;
|
|
7516
|
-
const [result, setResult] = (0,
|
|
7581
|
+
const [result, setResult] = (0, import_react53.useState)({ version, state: "loading" });
|
|
7517
7582
|
const state = result.version === version ? result.state : "loading";
|
|
7518
7583
|
const failed = !src || state === "error";
|
|
7519
7584
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "kjun-image", style: { aspectRatio: aspectRatio > 0 ? aspectRatio : 1 }, "data-state": failed ? "error" : state, children: [
|
|
@@ -7565,7 +7630,7 @@ function KjunFab({ icon, ariaLabel, disabled = false, safeAreaBottom = 0, offset
|
|
|
7565
7630
|
}
|
|
7566
7631
|
|
|
7567
7632
|
// packages/react/src/range-input.tsx
|
|
7568
|
-
var
|
|
7633
|
+
var import_react54 = require("react");
|
|
7569
7634
|
var import_react_aria_components10 = require("react-aria-components");
|
|
7570
7635
|
var import_tokens50 = require("@kjun-ui/tokens");
|
|
7571
7636
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
@@ -7575,10 +7640,10 @@ function RangeInput({ value, min = 0, max = 100, step = 1, disabled = false, lab
|
|
|
7575
7640
|
const domain = (0, import_tokens50.createSliderDomain)(min, max, step);
|
|
7576
7641
|
const list = Array.isArray(value) ? value : [value];
|
|
7577
7642
|
const valid = domain.valid && (!Array.isArray(value) || value.length === 2) && list.every((v) => domain.accepts(v)) && (list.length === 1 || list[0] <= list[1]);
|
|
7578
|
-
const latest = (0,
|
|
7643
|
+
const latest = (0, import_react54.useRef)(value);
|
|
7579
7644
|
latest.current = value;
|
|
7580
|
-
const active = (0,
|
|
7581
|
-
(0,
|
|
7645
|
+
const active = (0, import_react54.useRef)(false);
|
|
7646
|
+
(0, import_react54.useEffect)(() => {
|
|
7582
7647
|
if (!valid) console.warn("KJUN Slider: \uBC94\uC704\xB7step\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
|
|
7583
7648
|
}, [valid]);
|
|
7584
7649
|
const change = (next) => {
|
|
@@ -7615,7 +7680,7 @@ function KjunRangeSlider(props) {
|
|
|
7615
7680
|
}
|
|
7616
7681
|
|
|
7617
7682
|
// packages/react/src/quantity-stepper.tsx
|
|
7618
|
-
var
|
|
7683
|
+
var import_react55 = require("react");
|
|
7619
7684
|
var import_tokens51 = require("@kjun-ui/tokens");
|
|
7620
7685
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
7621
7686
|
function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, disabled = false, error = false, size = "md", block = false, id, ariaLabel, onValueChange, onChangeCommit, onInvalidInput }) {
|
|
@@ -7624,15 +7689,15 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
|
|
|
7624
7689
|
const buttonStyle = { width: import_tokens51.tokens.input[size].height, padding: 0 };
|
|
7625
7690
|
const domain = (0, import_tokens51.createNumberDomain)({ min, max, step, precision });
|
|
7626
7691
|
const valid = domain.valid && domain.accepts(value), blocked = disabled || !valid;
|
|
7627
|
-
const [draft, setDraft] = (0,
|
|
7692
|
+
const [draft, setDraft] = (0, import_react55.useState)(String(value));
|
|
7628
7693
|
const field = useKjunField();
|
|
7629
|
-
const composing = (0,
|
|
7630
|
-
(0,
|
|
7694
|
+
const composing = (0, import_react55.useRef)(false), dirty = (0, import_react55.useRef)(false), accepted = (0, import_react55.useRef)(value);
|
|
7695
|
+
(0, import_react55.useEffect)(() => {
|
|
7631
7696
|
setDraft(String(value));
|
|
7632
7697
|
accepted.current = value;
|
|
7633
7698
|
dirty.current = false;
|
|
7634
7699
|
}, [value, precision, min, max, step]);
|
|
7635
|
-
(0,
|
|
7700
|
+
(0, import_react55.useEffect)(() => {
|
|
7636
7701
|
if (!valid) console.warn("KJUN QuantityStepper: \uBC94\uC704\xB7step\xB7\uC815\uBC00\uB3C4\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
|
|
7637
7702
|
}, [valid]);
|
|
7638
7703
|
const emit = (next) => {
|
|
@@ -7707,18 +7772,18 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
|
|
|
7707
7772
|
}
|
|
7708
7773
|
|
|
7709
7774
|
// packages/react/src/time-picker.tsx
|
|
7710
|
-
var
|
|
7775
|
+
var import_react56 = require("react");
|
|
7711
7776
|
var import_tokens52 = require("@kjun-ui/tokens");
|
|
7712
7777
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
7713
7778
|
function KjunTimePicker({ value, precision = "minute", min, max, minuteStep = 1, secondStep = 1, disabled = false, error = false, clearable = true, size = "md", ariaLabel, onValueChange, onChangeCommit }) {
|
|
7714
7779
|
const m = useKjunMessages();
|
|
7715
7780
|
ariaLabel != null ? ariaLabel : ariaLabel = m.time;
|
|
7716
|
-
const root = (0,
|
|
7717
|
-
const field = useKjunField(), uid = (0,
|
|
7781
|
+
const root = (0, import_react56.useRef)(null);
|
|
7782
|
+
const field = useKjunField(), uid = (0, import_react56.useId)();
|
|
7718
7783
|
const fieldId = (field == null ? void 0 : field.id) || `kjun-time-${uid}`;
|
|
7719
|
-
const domain = (0,
|
|
7784
|
+
const domain = (0, import_react56.useMemo)(() => (0, import_tokens52.createTimeDomain)({ precision, min, max, minuteStep, secondStep }), [precision, min, max, minuteStep, secondStep]);
|
|
7720
7785
|
const valid = domain.valid && domain.accepts(value);
|
|
7721
|
-
(0,
|
|
7786
|
+
(0, import_react56.useEffect)(() => {
|
|
7722
7787
|
if (!valid) console.warn("KJUN TimePicker: \uC2DC\uAC01 \uBC94\uC704\xB7\uAC04\uACA9\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
|
|
7723
7788
|
}, [valid]);
|
|
7724
7789
|
const change = (next) => {
|
|
@@ -7732,7 +7797,7 @@ function KjunTimePicker({ value, precision = "minute", min, max, minuteStep = 1,
|
|
|
7732
7797
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(CompoundControlContext.Provider, { value: size, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "kjun-time-segments", children: [m.hour, m.minute, m.second].slice(0, precision === "second" ? 3 : 2).map((label, index) => {
|
|
7733
7798
|
const segmentId = index === 0 ? fieldId : `${fieldId}-${index}`;
|
|
7734
7799
|
const labelId = `${fieldId}-segment-${index}`;
|
|
7735
|
-
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
7800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_react56.Fragment, { children: [
|
|
7736
7801
|
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "kjun-time-separator", "aria-hidden": true, children: ":" }),
|
|
7737
7802
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(FieldContext.Provider, { value: { ...field, id: segmentId, labelId: (field == null ? void 0 : field.labelId) ? `${field.labelId} ${labelId}` : void 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "kjun-time-segment", children: [
|
|
7738
7803
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { id: labelId, className: "kjun-sr-only", "aria-hidden": true, children: label }),
|