@kjun-ui/react 0.22.0 → 0.23.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 +633 -256
- package/dist/index.js +741 -363
- package/dist/styles.css +140 -40
- package/dist/types/packages/react/src/app-navigation.d.cts +9 -3
- package/dist/types/packages/react/src/app-navigation.d.ts +9 -3
- package/dist/types/packages/react/src/button.d.cts +2 -1
- package/dist/types/packages/react/src/button.d.ts +2 -1
- package/dist/types/packages/react/src/display.d.cts +9 -4
- package/dist/types/packages/react/src/display.d.ts +9 -4
- package/dist/types/packages/react/src/dropdown.d.cts +2 -1
- package/dist/types/packages/react/src/dropdown.d.ts +2 -1
- package/dist/types/packages/react/src/input.d.cts +14 -1
- package/dist/types/packages/react/src/input.d.ts +14 -1
- package/dist/types/packages/react/src/list.d.cts +12 -6
- package/dist/types/packages/react/src/list.d.ts +12 -6
- package/dist/types/packages/react/src/market-model.d.cts +2 -0
- package/dist/types/packages/react/src/market-model.d.ts +2 -0
- package/dist/types/packages/react/src/number-input.d.cts +1 -1
- package/dist/types/packages/react/src/number-input.d.ts +1 -1
- package/dist/types/packages/react/src/side-navigation-layout-spaces.d.cts +31 -0
- package/dist/types/packages/react/src/side-navigation-layout-spaces.d.ts +31 -0
- package/dist/types/packages/react/src/side-navigation-layout.d.cts +17 -1
- package/dist/types/packages/react/src/side-navigation-layout.d.ts +17 -1
- package/dist/types/packages/react/src/split-pane.d.cts +3 -1
- package/dist/types/packages/react/src/split-pane.d.ts +3 -1
- package/dist/types/packages/react/src/steps.d.cts +3 -2
- package/dist/types/packages/react/src/steps.d.ts +3 -2
- package/dist/types/packages/react/src/table-grid.d.cts +1 -1
- package/dist/types/packages/react/src/table-grid.d.ts +1 -1
- package/dist/types/shared/package-runtime/bottom-navigation.d.cts +5 -0
- package/dist/types/shared/package-runtime/bottom-navigation.d.ts +5 -0
- package/dist/types/shared/package-runtime/field-group.d.cts +17 -0
- package/dist/types/shared/package-runtime/field-group.d.ts +17 -0
- package/dist/types/shared/package-runtime/list-row.d.cts +28 -2
- package/dist/types/shared/package-runtime/list-row.d.ts +28 -2
- package/dist/types/shared/package-runtime/menu-button.d.cts +2 -2
- package/dist/types/shared/package-runtime/menu-button.d.ts +2 -2
- package/dist/types/shared/package-runtime/messages/ko.d.cts +3 -0
- package/dist/types/shared/package-runtime/messages/ko.d.ts +3 -0
- package/dist/types/shared/package-runtime/messages-context.d.cts +3 -0
- package/dist/types/shared/package-runtime/messages-context.d.ts +3 -0
- package/dist/types/shared/package-runtime/node-text.d.cts +1 -0
- package/dist/types/shared/package-runtime/node-text.d.ts +1 -0
- package/dist/types/shared/package-runtime/number-input.d.cts +10 -0
- package/dist/types/shared/package-runtime/number-input.d.ts +10 -0
- package/dist/types/shared/package-runtime/progress-tone.d.cts +6 -0
- package/dist/types/shared/package-runtime/progress-tone.d.ts +6 -0
- package/dist/types/shared/package-runtime/side-navigation-layout.d.cts +24 -0
- package/dist/types/shared/package-runtime/side-navigation-layout.d.ts +24 -0
- package/dist/types/shared/package-runtime/steps.d.cts +18 -4
- package/dist/types/shared/package-runtime/steps.d.ts +18 -4
- package/dist/types/shared/package-runtime/table-presentation.d.cts +1 -0
- package/dist/types/shared/package-runtime/table-presentation.d.ts +1 -0
- package/dist/types/shared/package-runtime/table.d.cts +2 -0
- package/dist/types/shared/package-runtime/table.d.ts +2 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -368,6 +368,9 @@ var kjunMessagesEn = {
|
|
|
368
368
|
mainNavigation: "Main navigation",
|
|
369
369
|
collapseNavigation: "Collapse menu",
|
|
370
370
|
expandNavigation: "Expand menu",
|
|
371
|
+
spacesPanel: "Menu panel",
|
|
372
|
+
collapseSpacesPanel: "Collapse menu panel",
|
|
373
|
+
expandSpacesPanel: "Expand menu panel",
|
|
371
374
|
// The row after a side navigation group's first rows, and the row that folds them again.
|
|
372
375
|
showMoreItems: (count) => `Show ${count} more`,
|
|
373
376
|
showFewerItems: "Show less",
|
|
@@ -652,6 +655,9 @@ var kjunMessagesKo = {
|
|
|
652
655
|
mainNavigation: "\uC8FC\uC694 \uD0D0\uC0C9",
|
|
653
656
|
collapseNavigation: "\uBA54\uB274 \uC811\uAE30",
|
|
654
657
|
expandNavigation: "\uBA54\uB274 \uD3BC\uCE58\uAE30",
|
|
658
|
+
spacesPanel: "\uBA54\uB274 \uD328\uB110",
|
|
659
|
+
collapseSpacesPanel: "\uBA54\uB274 \uD328\uB110 \uC811\uAE30",
|
|
660
|
+
expandSpacesPanel: "\uBA54\uB274 \uD328\uB110 \uD3BC\uCE58\uAE30",
|
|
655
661
|
// 사이드 내비게이션 묶음의 처음 행 다음에 오는 행과, 다시 접는 행.
|
|
656
662
|
showMoreItems: (count) => `${count}\uAC1C \uB354 \uBCF4\uAE30`,
|
|
657
663
|
showFewerItems: "\uC811\uAE30",
|
|
@@ -1480,6 +1486,7 @@ var KjunButton = (0, import_react9.forwardRef)(
|
|
|
1480
1486
|
const prefixNode = prefix != null && prefix !== false, suffixNode = suffix != null && suffix !== false;
|
|
1481
1487
|
const prefixIcon = prefixNode || !!prefixName, suffixIcon = suffixNode || !!suffixName;
|
|
1482
1488
|
const iconOnly = !hasContent2 && !!(prefixIcon || suffixIcon || busy);
|
|
1489
|
+
const roundLabel = shape === "circle" && hasContent2 && !prefixIcon && !suffixIcon && !block && variant !== "link";
|
|
1483
1490
|
const navigation = (0, import_react9.useContext)(TopNavigationContext);
|
|
1484
1491
|
const height = Math.max(import_tokens8.tokens.button.heights[size], (_a = navigation == null ? void 0 : navigation.controlSize) != null ? _a : 0);
|
|
1485
1492
|
const iconSize = (_b = navigation == null ? void 0 : navigation.iconSize) != null ? _b : import_tokens8.tokens.button.iconSizes[size];
|
|
@@ -1514,12 +1521,12 @@ var KjunButton = (0, import_react9.forwardRef)(
|
|
|
1514
1521
|
minHeight: height,
|
|
1515
1522
|
width: block ? "100%" : iconOnly || shape === "circle" ? height : void 0,
|
|
1516
1523
|
// A width set by the caller (fixed square controls) wins over the label minimum.
|
|
1517
|
-
minWidth: hasContent2 && !block && (style == null ? void 0 : style.width) == null ? import_tokens8.tokens.button.minWidths[size] : void 0,
|
|
1518
|
-
padding: iconOnly ? 0 : `0 ${suffixIcon ? iconSide : paddingX}px 0 ${prefixIcon ? iconSide : paddingX}px`,
|
|
1524
|
+
minWidth: hasContent2 && !block && !roundLabel && (style == null ? void 0 : style.width) == null ? import_tokens8.tokens.button.minWidths[size] : void 0,
|
|
1525
|
+
padding: iconOnly || roundLabel ? 0 : `0 ${suffixIcon ? iconSide : paddingX}px 0 ${prefixIcon ? iconSide : paddingX}px`,
|
|
1519
1526
|
...typeStyle(import_tokens8.tokens.button.typography[size]),
|
|
1520
1527
|
borderRadius: pill ? import_tokens8.tokens.shape.pill : import_tokens8.tokens.button.radii[size],
|
|
1521
1528
|
gap: hasContent2 ? import_tokens8.tokens.button.contentGaps[size] : 0,
|
|
1522
|
-
...navigation || wrap ? {
|
|
1529
|
+
...(navigation || wrap) && !roundLabel ? {
|
|
1523
1530
|
height: "auto",
|
|
1524
1531
|
maxWidth: "100%",
|
|
1525
1532
|
paddingBlock: Math.max(0, (height - contentHeight) / 2)
|
|
@@ -1625,6 +1632,28 @@ function inputCount(value, maxLength) {
|
|
|
1625
1632
|
}
|
|
1626
1633
|
var searchLoadDelay = 300;
|
|
1627
1634
|
|
|
1635
|
+
// shared/package-runtime/field-group.ts
|
|
1636
|
+
function claimGroupField(claims, key, disabled) {
|
|
1637
|
+
const at = claims.findIndex((claim) => claim.key === key);
|
|
1638
|
+
if (at < 0) return [...claims, { key, disabled }];
|
|
1639
|
+
if (claims[at].disabled === disabled) return claims;
|
|
1640
|
+
const next = claims.slice();
|
|
1641
|
+
next[at] = { key, disabled };
|
|
1642
|
+
return next;
|
|
1643
|
+
}
|
|
1644
|
+
function releaseGroupField(claims, key) {
|
|
1645
|
+
return claims.some((claim) => claim.key === key) ? claims.filter((claim) => claim.key !== key) : claims;
|
|
1646
|
+
}
|
|
1647
|
+
function groupFieldOwner(claims) {
|
|
1648
|
+
var _a, _b;
|
|
1649
|
+
return (_b = (_a = claims.find((claim) => !claim.disabled)) != null ? _a : claims[0]) == null ? void 0 : _b.key;
|
|
1650
|
+
}
|
|
1651
|
+
function firstEnabledIndex(options, groupDisabled = false) {
|
|
1652
|
+
if (groupDisabled) return options.length ? 0 : -1;
|
|
1653
|
+
const at = options.findIndex((option) => !option.disabled);
|
|
1654
|
+
return at < 0 && options.length ? 0 : at;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1628
1657
|
// packages/react/src/input.tsx
|
|
1629
1658
|
var import_react11 = require("react");
|
|
1630
1659
|
|
|
@@ -1648,6 +1677,19 @@ function useCompositionGuard() {
|
|
|
1648
1677
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1649
1678
|
var FieldContext = (0, import_react11.createContext)(null);
|
|
1650
1679
|
var useKjunField = () => (0, import_react11.useContext)(FieldContext);
|
|
1680
|
+
function useGroupFieldId(disabled, own) {
|
|
1681
|
+
const field = (0, import_react11.useContext)(FieldContext), key = "kjun-choice-" + (0, import_react11.useId)(), group = own == null ? field == null ? void 0 : field.group : void 0;
|
|
1682
|
+
const claim = group == null ? void 0 : group.claim, release = group == null ? void 0 : group.release;
|
|
1683
|
+
(0, import_react11.useLayoutEffect)(() => {
|
|
1684
|
+
if (!claim || !release) return;
|
|
1685
|
+
claim(key, disabled);
|
|
1686
|
+
return () => release(key);
|
|
1687
|
+
}, [claim, release, key]);
|
|
1688
|
+
(0, import_react11.useLayoutEffect)(() => {
|
|
1689
|
+
claim == null ? void 0 : claim(key, disabled);
|
|
1690
|
+
}, [claim, key, disabled]);
|
|
1691
|
+
return group && group.owner === key ? field.id : own;
|
|
1692
|
+
}
|
|
1651
1693
|
function KjunFormGroup({
|
|
1652
1694
|
label,
|
|
1653
1695
|
id,
|
|
@@ -1658,6 +1700,7 @@ function KjunFormGroup({
|
|
|
1658
1700
|
labelHidden = false,
|
|
1659
1701
|
labelEnd,
|
|
1660
1702
|
className,
|
|
1703
|
+
as = "div",
|
|
1661
1704
|
children
|
|
1662
1705
|
}) {
|
|
1663
1706
|
const m = useKjunMessages();
|
|
@@ -1674,21 +1717,48 @@ function KjunFormGroup({
|
|
|
1674
1717
|
const hintId = shownHint ? fieldId + "-hint" : void 0, errorId = shownError ? fieldId + "-error" : void 0;
|
|
1675
1718
|
const describedBy = mergeIds(hintId, errorId);
|
|
1676
1719
|
const [controlId, setControlId] = (0, import_react11.useState)();
|
|
1677
|
-
const
|
|
1678
|
-
|
|
1720
|
+
const grouped = as === "fieldset", hasEnd = labelEnd != null && labelEnd !== false;
|
|
1721
|
+
const [claims, setClaims] = (0, import_react11.useState)([]);
|
|
1722
|
+
const [groupApi] = (0, import_react11.useState)(() => ({
|
|
1723
|
+
claim: (key, disabled) => setClaims((old) => claimGroupField(old, key, disabled)),
|
|
1724
|
+
release: (key) => setClaims((old) => releaseGroupField(old, key))
|
|
1725
|
+
}));
|
|
1726
|
+
const marks = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1679
1727
|
required && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "kjun-form-required", "aria-hidden": "true", children: " *" }),
|
|
1680
1728
|
optional && !required && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "kjun-form-optional", children: [
|
|
1681
1729
|
" ",
|
|
1682
1730
|
m.optional
|
|
1683
1731
|
] })
|
|
1684
1732
|
] });
|
|
1733
|
+
const labelNode = label && (grouped ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("legend", { className: "kjun-form-label" + (labelHidden || hasEnd ? " kjun-sr-only" : ""), id: labelId, children: [
|
|
1734
|
+
label,
|
|
1735
|
+
marks
|
|
1736
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "kjun-form-label" + (labelHidden ? " kjun-sr-only" : ""), id: labelId, htmlFor: controlId || fieldId, children: [
|
|
1737
|
+
label,
|
|
1738
|
+
marks
|
|
1739
|
+
] }));
|
|
1740
|
+
const shownLabel = grouped && hasEnd ? label && !labelHidden && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "kjun-form-label", "aria-hidden": "true", children: [
|
|
1741
|
+
label,
|
|
1742
|
+
marks
|
|
1743
|
+
] }) : labelNode;
|
|
1744
|
+
const Root = grouped ? "fieldset" : "div";
|
|
1685
1745
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1686
1746
|
FieldContext.Provider,
|
|
1687
1747
|
{
|
|
1688
|
-
value: {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1748
|
+
value: {
|
|
1749
|
+
id: fieldId,
|
|
1750
|
+
labelId,
|
|
1751
|
+
describedBy,
|
|
1752
|
+
error,
|
|
1753
|
+
required,
|
|
1754
|
+
setControlId,
|
|
1755
|
+
reportError,
|
|
1756
|
+
group: grouped ? { ...groupApi, owner: groupFieldOwner(claims) } : void 0
|
|
1757
|
+
},
|
|
1758
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Root, { className: className ? "kjun-form-group " + className : "kjun-form-group", "aria-describedby": grouped ? describedBy : void 0, children: [
|
|
1759
|
+
grouped && hasEnd && labelNode,
|
|
1760
|
+
hasEnd ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "kjun-form-label-row", children: [
|
|
1761
|
+
shownLabel,
|
|
1692
1762
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "kjun-form-label-end", children: labelEnd })
|
|
1693
1763
|
] }) : labelNode,
|
|
1694
1764
|
children,
|
|
@@ -2547,6 +2617,14 @@ function useSkeletonPhase(active = true) {
|
|
|
2547
2617
|
return ref;
|
|
2548
2618
|
}
|
|
2549
2619
|
|
|
2620
|
+
// shared/package-runtime/progress-tone.ts
|
|
2621
|
+
function progressColorKey(variant) {
|
|
2622
|
+
return variant === "primary" ? "brand" : variant === "neutral" ? "textTertiary" : variant;
|
|
2623
|
+
}
|
|
2624
|
+
function progressColorRole(variant) {
|
|
2625
|
+
return variant === "neutral" ? "text-tertiary" : progressColorKey(variant);
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2550
2628
|
// shared/package-runtime/nested-controls.ts
|
|
2551
2629
|
var interactive = 'button, a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
2552
2630
|
function developmentMode3() {
|
|
@@ -2662,11 +2740,16 @@ function warnListSelection({ mode, value, handled }) {
|
|
|
2662
2740
|
warnOnce("selection-single", mode === "single" && Array.isArray(value), 'selectionMode "single" takes one value (or null); a list reads as nothing chosen.', "ListSection");
|
|
2663
2741
|
warnOnce("selection-handler", mode !== "none" && !handled, "value is given without onValueChange, so pressing a row never changes the choice; pass onValueChange.", "ListSection");
|
|
2664
2742
|
}
|
|
2665
|
-
function
|
|
2743
|
+
function listSectionSurface(surface = true) {
|
|
2744
|
+
const muted = surface === "muted", painted = muted || surface === true;
|
|
2745
|
+
return { painted, muted, attribute: muted ? "muted" : painted ? void 0 : "false" };
|
|
2746
|
+
}
|
|
2747
|
+
function listSectionShape({ radius, group, variant, title, description, titleVariant, bleed: wantsBleed = false }) {
|
|
2666
2748
|
const resolved = variant != null ? variant : group === "open" ? "open" : "default", open = resolved === "open", details = resolved === "details";
|
|
2667
|
-
const
|
|
2749
|
+
const bleed = wantsBleed && !open;
|
|
2750
|
+
const corner = open || bleed ? "none" : radius != null ? radius : group === "inset" ? "lg" : "none";
|
|
2668
2751
|
const bare = !!title && (titleVariant ? titleVariant === "label" : !description);
|
|
2669
|
-
return { open, details, corner, bare, outside: corner !== "none" };
|
|
2752
|
+
return { open, details, corner, bare, outside: corner !== "none", bleed };
|
|
2670
2753
|
}
|
|
2671
2754
|
function observeListHeadingActions(actions) {
|
|
2672
2755
|
const heading = actions.parentElement;
|
|
@@ -2716,6 +2799,7 @@ function KjunCard({
|
|
|
2716
2799
|
onKeyUp,
|
|
2717
2800
|
...props
|
|
2718
2801
|
}) {
|
|
2802
|
+
var _a;
|
|
2719
2803
|
const root = (0, import_react20.useRef)(null);
|
|
2720
2804
|
const link = href !== void 0;
|
|
2721
2805
|
(0, import_react20.useEffect)(() => {
|
|
@@ -2747,7 +2831,8 @@ function KjunCard({
|
|
|
2747
2831
|
onKeyDown,
|
|
2748
2832
|
onKeyUp
|
|
2749
2833
|
} : pressable ? {
|
|
2750
|
-
role
|
|
2834
|
+
// A caller's role (radio, checkbox, switch, as in a card picker) stays; the card still presses like a button.
|
|
2835
|
+
role: (_a = props.role) != null ? _a : "button",
|
|
2751
2836
|
tabIndex: disabled ? -1 : 0,
|
|
2752
2837
|
"aria-disabled": disabled || void 0,
|
|
2753
2838
|
"aria-label": name,
|
|
@@ -2907,7 +2992,7 @@ function KjunSpinner({ size = "md", text }) {
|
|
|
2907
2992
|
] })
|
|
2908
2993
|
);
|
|
2909
2994
|
}
|
|
2910
|
-
|
|
2995
|
+
var KjunAlert = (0, import_react21.forwardRef)(function KjunAlert2({
|
|
2911
2996
|
type = "info",
|
|
2912
2997
|
variant,
|
|
2913
2998
|
size = "md",
|
|
@@ -2918,12 +3003,19 @@ function KjunAlert({
|
|
|
2918
3003
|
children,
|
|
2919
3004
|
actions,
|
|
2920
3005
|
className,
|
|
2921
|
-
onClose
|
|
2922
|
-
|
|
3006
|
+
onClose,
|
|
3007
|
+
style,
|
|
3008
|
+
...rest
|
|
3009
|
+
}, forward) {
|
|
2923
3010
|
const m = useKjunMessages();
|
|
2924
3011
|
const [visible, setVisible] = (0, import_react21.useState)(true);
|
|
2925
3012
|
const root = (0, import_react21.useRef)(null), body = (0, import_react21.useRef)(null), closing = (0, import_react21.useRef)(false);
|
|
2926
3013
|
const reduced = useReducedMotion();
|
|
3014
|
+
const attach = (0, import_react21.useCallback)((node) => {
|
|
3015
|
+
root.current = node;
|
|
3016
|
+
if (typeof forward === "function") forward(node);
|
|
3017
|
+
else if (forward) forward.current = node;
|
|
3018
|
+
}, [forward]);
|
|
2927
3019
|
const beside = !hasContent(title) && hasContent(actions);
|
|
2928
3020
|
const [wrapped, setWrapped] = (0, import_react21.useState)(false);
|
|
2929
3021
|
(0, import_react21.useLayoutEffect)(() => beside && visible ? observeAlertActions(body.current, setWrapped) : void 0, [beside, visible]);
|
|
@@ -2934,17 +3026,18 @@ function KjunAlert({
|
|
|
2934
3026
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2935
3027
|
"div",
|
|
2936
3028
|
{
|
|
2937
|
-
|
|
3029
|
+
...rest,
|
|
3030
|
+
ref: attach,
|
|
2938
3031
|
role: alertRole(tone, live),
|
|
2939
3032
|
className: className ? "kjun-alert " + className : "kjun-alert",
|
|
2940
3033
|
"data-size": scale,
|
|
2941
3034
|
"data-tone": tone,
|
|
2942
|
-
style: paint.bg ? { background: role(paint.bg) } :
|
|
3035
|
+
style: paint.bg ? { background: role(paint.bg), ...style } : style,
|
|
2943
3036
|
children: [
|
|
2944
3037
|
icon2 !== false && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "kjun-alert-icon", "data-icon": icon2 ? "custom" : void 0, style: { color: role(paint.icon) }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(KjunIcon, { name: icon2 || alertIcons[tone], filled: true, size: import_tokens26.tokens.extensions.alert.iconSizes[scale] }) }),
|
|
2945
3038
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { ref: body, className: "kjun-alert-content", children: [
|
|
2946
|
-
titled && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "kjun-alert-title", children: title }),
|
|
2947
|
-
hasContent(children) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "kjun-alert-description", children }),
|
|
3039
|
+
titled && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "kjun-alert-title", "data-kjun-content": "", children: title }),
|
|
3040
|
+
hasContent(children) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "kjun-alert-description", "data-kjun-content": "", children }),
|
|
2948
3041
|
actionBox
|
|
2949
3042
|
] }),
|
|
2950
3043
|
closable && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
@@ -2967,7 +3060,7 @@ function KjunAlert({
|
|
|
2967
3060
|
]
|
|
2968
3061
|
}
|
|
2969
3062
|
);
|
|
2970
|
-
}
|
|
3063
|
+
});
|
|
2971
3064
|
function KjunProgress({
|
|
2972
3065
|
value = 0,
|
|
2973
3066
|
indeterminate = false,
|
|
@@ -2979,15 +3072,16 @@ function KjunProgress({
|
|
|
2979
3072
|
marker,
|
|
2980
3073
|
markerLabel,
|
|
2981
3074
|
label,
|
|
3075
|
+
ariaLabel,
|
|
2982
3076
|
subLabel,
|
|
2983
3077
|
shape = "bar"
|
|
2984
3078
|
}) {
|
|
2985
3079
|
const m = useKjunMessages(), baseId = "kjun-progress-" + (0, import_react21.useId)().replace(/:/g, ""), markerId = baseId + "-marker";
|
|
2986
|
-
const labelId = label && typeof label !== "string" ? baseId + "-label" : void 0, noDataId = baseId + "-nodata";
|
|
3080
|
+
const labelId = !ariaLabel && label && typeof label !== "string" ? baseId + "-label" : void 0, noDataId = baseId + "-nodata";
|
|
2987
3081
|
const state = progressState(value, max, indeterminate);
|
|
2988
3082
|
const percentage = state === "determinate" ? progressPercent(value, max) : 0;
|
|
2989
3083
|
const text = state === "indeterminate" ? m.loadingEllipsis : state === "missing" ? "\u2014" : valueText != null ? valueText : `${percentage}%`;
|
|
2990
|
-
const name = typeof label === "string" ? label : m.progress, color = role(variant
|
|
3084
|
+
const name = ariaLabel || (typeof label === "string" ? label : m.progress), color = role(progressColorRole(variant));
|
|
2991
3085
|
const accessibility = {
|
|
2992
3086
|
role: state === "missing" ? "img" : "progressbar",
|
|
2993
3087
|
"aria-label": labelId ? void 0 : state === "missing" ? `${name}: ${m.noData}` : name,
|
|
@@ -4656,6 +4750,27 @@ function TooltipPanel(props) {
|
|
|
4656
4750
|
if (state && !state.isOpen && state.shouldSkipAnimation) return null;
|
|
4657
4751
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_aria_components4.Tooltip, { ...props });
|
|
4658
4752
|
}
|
|
4753
|
+
function useTriggerShown() {
|
|
4754
|
+
const ref = (0, import_react32.useRef)(null);
|
|
4755
|
+
const [shown, setShown] = (0, import_react32.useState)(false);
|
|
4756
|
+
(0, import_react32.useLayoutEffect)(() => {
|
|
4757
|
+
const element = ref.current;
|
|
4758
|
+
const visible = () => !element || element.getClientRects().length > 0;
|
|
4759
|
+
if (visible() || typeof ResizeObserver === "undefined") {
|
|
4760
|
+
setShown(true);
|
|
4761
|
+
return;
|
|
4762
|
+
}
|
|
4763
|
+
const observer = new ResizeObserver(() => {
|
|
4764
|
+
if (visible()) {
|
|
4765
|
+
observer.disconnect();
|
|
4766
|
+
setShown(true);
|
|
4767
|
+
}
|
|
4768
|
+
});
|
|
4769
|
+
observer.observe(element);
|
|
4770
|
+
return () => observer.disconnect();
|
|
4771
|
+
}, []);
|
|
4772
|
+
return [ref, shown];
|
|
4773
|
+
}
|
|
4659
4774
|
function KjunTooltip({
|
|
4660
4775
|
content = "",
|
|
4661
4776
|
title,
|
|
@@ -4678,8 +4793,9 @@ function KjunTooltip({
|
|
|
4678
4793
|
onOpenChange == null ? void 0 : onOpenChange(value);
|
|
4679
4794
|
};
|
|
4680
4795
|
const layer = useLayer(open, open, "tooltip", () => setOpen(false));
|
|
4796
|
+
const [trigger, shown] = useTriggerShown();
|
|
4681
4797
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_aria_components4.TooltipTrigger, { isOpen: open && !layer.blocked, onOpenChange: setOpen, delay, closeDelay: 0, isDisabled: !hasContent2 || !layer.scopeActive, children: [
|
|
4682
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_aria_components4.Focusable, { children }),
|
|
4798
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_aria_components4.Focusable, { ref: trigger, isDisabled: !shown, children }),
|
|
4683
4799
|
container !== null && hasContent2 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
4684
4800
|
TooltipPanel,
|
|
4685
4801
|
{
|
|
@@ -5033,7 +5149,7 @@ function KjunCheckbox({
|
|
|
5033
5149
|
onChange
|
|
5034
5150
|
}) {
|
|
5035
5151
|
const checked = Array.isArray(value) ? value.includes(val) : value;
|
|
5036
|
-
const field = useKjunField(), descriptionId = useDescriptionId();
|
|
5152
|
+
const field = useKjunField(), descriptionId = useDescriptionId(), inputId = useGroupFieldId(disabled, id);
|
|
5037
5153
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
5038
5154
|
import_react_aria_components5.Checkbox,
|
|
5039
5155
|
{
|
|
@@ -5042,7 +5158,7 @@ function KjunCheckbox({
|
|
|
5042
5158
|
isDisabled: disabled,
|
|
5043
5159
|
name,
|
|
5044
5160
|
value: formValue,
|
|
5045
|
-
id,
|
|
5161
|
+
id: inputId,
|
|
5046
5162
|
inputRef,
|
|
5047
5163
|
"aria-label": ariaLabel,
|
|
5048
5164
|
"aria-labelledby": namedBy(description, children || label, ariaLabel, descriptionId),
|
|
@@ -5088,7 +5204,7 @@ function KjunSwitch({
|
|
|
5088
5204
|
onValueChange,
|
|
5089
5205
|
onChange
|
|
5090
5206
|
}) {
|
|
5091
|
-
const field = useKjunField(), m = useKjunMessages();
|
|
5207
|
+
const field = useKjunField(), m = useKjunMessages(), inputId = useGroupFieldId(disabled, id);
|
|
5092
5208
|
const descriptionId = useDescriptionId(), savingId = descriptionId.replace(/-description$/, "-saving");
|
|
5093
5209
|
const invalid = !!(field == null ? void 0 : field.error), required = !!(field == null ? void 0 : field.required);
|
|
5094
5210
|
const markInput = (0, import_react35.useCallback)((input) => {
|
|
@@ -5110,7 +5226,7 @@ function KjunSwitch({
|
|
|
5110
5226
|
"data-loading": loading || void 0,
|
|
5111
5227
|
name,
|
|
5112
5228
|
value: formValue,
|
|
5113
|
-
id,
|
|
5229
|
+
id: inputId,
|
|
5114
5230
|
autoFocus,
|
|
5115
5231
|
onFocus,
|
|
5116
5232
|
onBlur,
|
|
@@ -5156,14 +5272,14 @@ function KjunRadio({
|
|
|
5156
5272
|
}) {
|
|
5157
5273
|
const group = (0, import_react35.useContext)(RadioContext), field = useKjunField(), descriptionId = useDescriptionId();
|
|
5158
5274
|
const selected = (group ? group.value : value) === val;
|
|
5159
|
-
const blocked = disabled || !!(group == null ? void 0 : group.disabled), scale = size || (group == null ? void 0 : group.size) || "md";
|
|
5275
|
+
const blocked = disabled || !!(group == null ? void 0 : group.disabled), scale = size || (group == null ? void 0 : group.size) || "md", inputId = useGroupFieldId(blocked, id);
|
|
5160
5276
|
const own = group ? null : field, invalid = group ? group.invalid : !!(field == null ? void 0 : field.error);
|
|
5161
5277
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: choiceClass(blocked), "data-invalid": invalid || void 0, children: [
|
|
5162
5278
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5163
5279
|
"input",
|
|
5164
5280
|
{
|
|
5165
5281
|
ref: inputRef,
|
|
5166
|
-
id,
|
|
5282
|
+
id: inputId,
|
|
5167
5283
|
type: "radio",
|
|
5168
5284
|
className: "kjun-sr-only",
|
|
5169
5285
|
name: (group == null ? void 0 : group.name) || name,
|
|
@@ -5261,7 +5377,9 @@ function KjunButtonGroup({
|
|
|
5261
5377
|
onValueChange,
|
|
5262
5378
|
onChange
|
|
5263
5379
|
}) {
|
|
5380
|
+
var _a;
|
|
5264
5381
|
const { group, indicator } = useSelectionIndicator();
|
|
5382
|
+
const first = firstEnabledIndex(options, disabled), groupId = useGroupFieldId(first < 0 || disabled || !!((_a = options[first]) == null ? void 0 : _a.disabled));
|
|
5265
5383
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
5266
5384
|
"div",
|
|
5267
5385
|
{
|
|
@@ -5287,11 +5405,12 @@ function KjunButtonGroup({
|
|
|
5287
5405
|
style: { borderRadius: import_tokens44.tokens.buttonGroup.itemRadii[size] }
|
|
5288
5406
|
}
|
|
5289
5407
|
),
|
|
5290
|
-
options.map((option) => {
|
|
5408
|
+
options.map((option, index) => {
|
|
5291
5409
|
const iconOnly = !!(option.iconOnly && option.icon), blocked = disabled || option.disabled;
|
|
5292
5410
|
const segment = /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
5293
5411
|
"button",
|
|
5294
5412
|
{
|
|
5413
|
+
id: index === first ? groupId : void 0,
|
|
5295
5414
|
type: "button",
|
|
5296
5415
|
"aria-pressed": value === option.value,
|
|
5297
5416
|
"aria-label": iconOnly ? option.label : void 0,
|
|
@@ -5337,8 +5456,10 @@ function KjunFilterGroup({
|
|
|
5337
5456
|
onValueChange,
|
|
5338
5457
|
onChange
|
|
5339
5458
|
}) {
|
|
5459
|
+
var _a;
|
|
5340
5460
|
const m = useKjunMessages();
|
|
5341
5461
|
const root = useFilterScroll(scroll, multiple, value);
|
|
5462
|
+
const first = firstEnabledIndex(options, disabled), groupId = useGroupFieldId(first < 0 || disabled || !!((_a = options[first]) == null ? void 0 : _a.disabled));
|
|
5342
5463
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5343
5464
|
"div",
|
|
5344
5465
|
{
|
|
@@ -5348,11 +5469,12 @@ function KjunFilterGroup({
|
|
|
5348
5469
|
className: className ? "kjun-filter-group " + className : "kjun-filter-group",
|
|
5349
5470
|
"data-scroll": scroll,
|
|
5350
5471
|
onKeyDown: groupKeydown,
|
|
5351
|
-
children: options.map((option) => {
|
|
5472
|
+
children: options.map((option, index) => {
|
|
5352
5473
|
const on = filterSelected(value, option.value, multiple), counted = option.count != null && option.count !== "";
|
|
5353
5474
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5354
5475
|
"button",
|
|
5355
5476
|
{
|
|
5477
|
+
id: index === first ? groupId : void 0,
|
|
5356
5478
|
type: "button",
|
|
5357
5479
|
className: "kjun-filter-chip",
|
|
5358
5480
|
style: { borderRadius: import_tokens44.tokens.button.radii[size] },
|
|
@@ -5703,7 +5825,7 @@ function KjunMenuButton({
|
|
|
5703
5825
|
loading,
|
|
5704
5826
|
prefixIcon: menuButtonIcon(icon2, compact, label),
|
|
5705
5827
|
suffixIcon: menuButtonChevron(chevron, compact, label, open),
|
|
5706
|
-
ariaLabel: ariaLabel || label || tooltip || m.menu,
|
|
5828
|
+
ariaLabel: ariaLabel || (typeof label === "string" ? label : void 0) || (hasContent(label) && !compact ? void 0 : tooltip || m.menu),
|
|
5707
5829
|
children: compact ? void 0 : label
|
|
5708
5830
|
}
|
|
5709
5831
|
);
|
|
@@ -10560,16 +10682,28 @@ function clampCurrent(current, count) {
|
|
|
10560
10682
|
if (!Number.isFinite(current)) return 0;
|
|
10561
10683
|
return Math.min(Math.max(0, count), Math.max(0, Math.floor(current)));
|
|
10562
10684
|
}
|
|
10563
|
-
function
|
|
10685
|
+
function stepsCurrent(items, current) {
|
|
10686
|
+
if (current !== void 0 && current !== null) return clampCurrent(current, items.length);
|
|
10687
|
+
const marked = items.findIndex((item) => item.status === "current" || item.status === "error");
|
|
10688
|
+
if (marked >= 0) return marked;
|
|
10689
|
+
const open = items.findIndex((item) => item.status !== "complete");
|
|
10690
|
+
return open < 0 ? items.length : open;
|
|
10691
|
+
}
|
|
10692
|
+
function stepStatus(index, current, currentStatus, item) {
|
|
10693
|
+
if (item == null ? void 0 : item.status) return item.status;
|
|
10564
10694
|
if (index < current) return "complete";
|
|
10565
10695
|
if (index === current) return currentStatus === "error" ? "error" : "current";
|
|
10566
10696
|
return "upcoming";
|
|
10567
10697
|
}
|
|
10568
|
-
function
|
|
10569
|
-
|
|
10570
|
-
return currentStatus === "error" ? "error" : "current";
|
|
10698
|
+
function stepsStatuses(items, current, currentStatus) {
|
|
10699
|
+
return items.map((item, i) => stepStatus(i, current, currentStatus, item));
|
|
10571
10700
|
}
|
|
10572
|
-
function
|
|
10701
|
+
function stepsRootStatus(statuses) {
|
|
10702
|
+
if (statuses.every((status) => status === "complete")) return "complete";
|
|
10703
|
+
return statuses.includes("error") ? "error" : "current";
|
|
10704
|
+
}
|
|
10705
|
+
function stepSelectable(status, selectable = "complete", disabled = false) {
|
|
10706
|
+
if (disabled) return false;
|
|
10573
10707
|
return selectable === "all" ? status === "complete" || status === "upcoming" : status === "complete";
|
|
10574
10708
|
}
|
|
10575
10709
|
function stepDetail(item, vertical) {
|
|
@@ -10612,7 +10746,7 @@ function KjunSteps({
|
|
|
10612
10746
|
(0, import_react59.useEffect)(() => {
|
|
10613
10747
|
if (count < 2 && developmentMode9()) console.warn("[KJUN] KjunSteps expects two or more items.");
|
|
10614
10748
|
}, [count]);
|
|
10615
|
-
const at =
|
|
10749
|
+
const at = stepsCurrent(items, current), statuses = stepsStatuses(items, at, currentStatus);
|
|
10616
10750
|
const vertical = orientation === "vertical";
|
|
10617
10751
|
const head = stepsHead(m, items, at);
|
|
10618
10752
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
@@ -10625,7 +10759,7 @@ function KjunSteps({
|
|
|
10625
10759
|
"data-orientation": orientation,
|
|
10626
10760
|
"data-layout": layout,
|
|
10627
10761
|
"data-count": count,
|
|
10628
|
-
"data-status": stepsRootStatus(
|
|
10762
|
+
"data-status": stepsRootStatus(statuses),
|
|
10629
10763
|
children: [
|
|
10630
10764
|
!vertical && head.item && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "kjun-steps-head", "aria-hidden": "true", children: [
|
|
10631
10765
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "kjun-steps-head-title", "aria-hidden": "true", children: head.item.label }),
|
|
@@ -10641,7 +10775,7 @@ function KjunSteps({
|
|
|
10641
10775
|
] }),
|
|
10642
10776
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("ol", { className: "kjun-steps-list", "aria-label": ariaLabel != null ? ariaLabel : m.steps, children: items.map((item, i) => {
|
|
10643
10777
|
var _a;
|
|
10644
|
-
const status =
|
|
10778
|
+
const status = statuses[i];
|
|
10645
10779
|
const detail = stepDetail(item, vertical), spoken = stepSpoken(m, i, item, status, detail);
|
|
10646
10780
|
const body = /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
|
|
10647
10781
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "kjun-steps-marker", "aria-hidden": "true", children: status === "complete" ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(KjunIcon, { name: "check" }) : status === "error" ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(KjunIcon, { name: "exclamation-mark" }) : i + 1 }),
|
|
@@ -10652,12 +10786,12 @@ function KjunSteps({
|
|
|
10652
10786
|
item.description
|
|
10653
10787
|
] })
|
|
10654
10788
|
] });
|
|
10655
|
-
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("li", { className: "kjun-steps-item", "data-status": status, "aria-current": status === "current" || status === "error" ? "step" : void 0, children: [
|
|
10789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("li", { className: "kjun-steps-item", "data-status": status, "data-disabled": item.disabled || void 0, "aria-current": status === "current" || status === "error" ? "step" : void 0, children: [
|
|
10656
10790
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("span", { className: "kjun-steps-static", children: [
|
|
10657
10791
|
body,
|
|
10658
10792
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "kjun-sr-only", children: spoken })
|
|
10659
10793
|
] }),
|
|
10660
|
-
onStepSelect && stepSelectable(status, selectable) && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("button", { type: "button", className: "kjun-steps-hit", "aria-label": spoken, onClick: () => onStepSelect(i), children: body })
|
|
10794
|
+
onStepSelect && stepSelectable(status, selectable, item.disabled) && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("button", { type: "button", className: "kjun-steps-hit", "aria-label": spoken, onClick: () => onStepSelect(i), children: body })
|
|
10661
10795
|
] }, (_a = item.key) != null ? _a : i);
|
|
10662
10796
|
}) })
|
|
10663
10797
|
]
|
|
@@ -11013,6 +11147,7 @@ function KjunSplitPane({
|
|
|
11013
11147
|
collapsed,
|
|
11014
11148
|
defaultCollapsed = false,
|
|
11015
11149
|
onCollapsedChange,
|
|
11150
|
+
secondHidden = false,
|
|
11016
11151
|
onSizeChange,
|
|
11017
11152
|
onChangeCommit,
|
|
11018
11153
|
first,
|
|
@@ -11035,7 +11170,7 @@ function KjunSplitPane({
|
|
|
11035
11170
|
foldedNow.current = folded;
|
|
11036
11171
|
const measure = () => {
|
|
11037
11172
|
const el = root.current, bar = handle.current;
|
|
11038
|
-
return el && bar ? { total: vertical ? el.clientHeight : el.clientWidth, hit: vertical ? bar.offsetHeight : bar.offsetWidth } : null;
|
|
11173
|
+
return el && bar && !secondHidden ? { total: vertical ? el.clientHeight : el.clientWidth, hit: vertical ? bar.offsetHeight : bar.offsetWidth } : null;
|
|
11039
11174
|
};
|
|
11040
11175
|
(0, import_react62.useLayoutEffect)(() => {
|
|
11041
11176
|
const el = root.current;
|
|
@@ -11049,7 +11184,7 @@ function KjunSplitPane({
|
|
|
11049
11184
|
const observer = new ResizeObserver(read);
|
|
11050
11185
|
observer.observe(el);
|
|
11051
11186
|
return () => observer.disconnect();
|
|
11052
|
-
}, [vertical]);
|
|
11187
|
+
}, [vertical, secondHidden]);
|
|
11053
11188
|
const limits = box ? splitLimits(box.total, box.hit, minSize, maxSize) : null;
|
|
11054
11189
|
const at = (now, range2 = splitLimits(now.total, now.hit, minSize, maxSize)) => foldedNow.current ? splitFoldedPx(collapsedSize, now.total, now.hit) : splitClamp(splitWantedPx(latest.current, sizeUnit, now.total, now.hit), range2);
|
|
11055
11190
|
const px = box && limits ? at(box, limits) : null;
|
|
@@ -11124,7 +11259,7 @@ function KjunSplitPane({
|
|
|
11124
11259
|
moveTo(resetPx(now), now);
|
|
11125
11260
|
commit();
|
|
11126
11261
|
};
|
|
11127
|
-
const hidden = folded && px !== null ? px === 0 : folded && splitFoldedPx(collapsedSize, Infinity, 0) === 0;
|
|
11262
|
+
const hidden = !secondHidden && (folded && px !== null ? px === 0 : folded && splitFoldedPx(collapsedSize, Infinity, 0) === 0);
|
|
11128
11263
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
11129
11264
|
"div",
|
|
11130
11265
|
{
|
|
@@ -11134,6 +11269,7 @@ function KjunSplitPane({
|
|
|
11134
11269
|
"data-direction": direction,
|
|
11135
11270
|
"data-dragging": dragging || void 0,
|
|
11136
11271
|
"data-collapsed": folded || void 0,
|
|
11272
|
+
"data-second-hidden": secondHidden || void 0,
|
|
11137
11273
|
style: { ...style, "--_kjun-split-pane-size": share, ...basis ? { "--_kjun-split-pane-basis": basis } : {} },
|
|
11138
11274
|
children: [
|
|
11139
11275
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { id: firstId, className: "kjun-split-pane-first", inert: hidden || void 0, "aria-hidden": hidden || void 0, children: first }),
|
|
@@ -11143,7 +11279,7 @@ function KjunSplitPane({
|
|
|
11143
11279
|
ref: handle,
|
|
11144
11280
|
className: "kjun-split-pane-handle",
|
|
11145
11281
|
role: "separator",
|
|
11146
|
-
tabIndex: disabled ? void 0 : 0,
|
|
11282
|
+
tabIndex: disabled || secondHidden ? void 0 : 0,
|
|
11147
11283
|
"aria-label": ariaLabel,
|
|
11148
11284
|
"aria-controls": firstId,
|
|
11149
11285
|
"aria-orientation": vertical ? "horizontal" : "vertical",
|
|
@@ -11163,7 +11299,7 @@ function KjunSplitPane({
|
|
|
11163
11299
|
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "kjun-split-pane-bar" })
|
|
11164
11300
|
}
|
|
11165
11301
|
),
|
|
11166
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "kjun-split-pane-second", children: second })
|
|
11302
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "kjun-split-pane-second", inert: secondHidden || void 0, children: second })
|
|
11167
11303
|
]
|
|
11168
11304
|
}
|
|
11169
11305
|
);
|
|
@@ -12927,7 +13063,7 @@ var TableCheck = (0, import_react73.forwardRef)(
|
|
|
12927
13063
|
// packages/react/src/table-grid.tsx
|
|
12928
13064
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
12929
13065
|
var import_react75 = require("react");
|
|
12930
|
-
function TableGrid({ columnGroups, cellSpan, mover, initialLoading, skeletonRows, skeletonHidden, state, onRowClick, selectable, checkbox, cell, expandable, expand, renderExpand, emptyContent, emptyText, visible, maxHeight, stickyHeader, sortable, compact, striped, hoverable, ariaLabel, customClass, rowKeyDown, groups, collapsed, toggleGroup, groupLabel, summary, edgeInset, stickyOffset = 0 }) {
|
|
13066
|
+
function TableGrid({ columnGroups, cellSpan, mover, initialLoading, skeletonRows, skeletonHidden, state, onRowClick, selectable, checkbox, cell, expandable, expand, renderExpand, emptyContent, emptyText, visible, maxHeight, stickyHeader, sortable, compact, striped, hoverable, ariaLabel, customClass, rowKeyDown, groups, collapsed, toggleGroup, groupLabel, summary, edgeInset, layout, stickyOffset = 0 }) {
|
|
12931
13067
|
const m = useKjunMessages();
|
|
12932
13068
|
const span = visible.length + Number(selectable) + Number(expandable) + Number(!!mover);
|
|
12933
13069
|
const headerRows = tableHeaderRows(visible, columnGroups), lone = headerRows ? 2 : void 0;
|
|
@@ -13060,7 +13196,14 @@ function TableGrid({ columnGroups, cellSpan, mover, initialLoading, skeletonRows
|
|
|
13060
13196
|
"data-hoverable": hoverable,
|
|
13061
13197
|
"data-striped": striped,
|
|
13062
13198
|
"data-edge-inset": edgeInset === "none" ? "none" : void 0,
|
|
13199
|
+
"data-layout": layout === "fixed" ? "fixed" : void 0,
|
|
13063
13200
|
children: [
|
|
13201
|
+
layout === "fixed" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("colgroup", { children: [
|
|
13202
|
+
selectable && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "kjun-table-action-cell" }),
|
|
13203
|
+
visible.map((col) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { style: { width: col.width } }, col.key)),
|
|
13204
|
+
expandable && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "kjun-table-action-cell" }),
|
|
13205
|
+
mover && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "kjun-table-action-cell kjun-table-reorder-cell" })
|
|
13206
|
+
] }),
|
|
13064
13207
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("thead", { "data-sticky": stickyHeader || void 0, style: stickyHeader ? { top: pageSticky ? stickyOffset : 0 } : void 0, children: [
|
|
13065
13208
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("tr", { children: [
|
|
13066
13209
|
selectable && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("th", { scope: "col", className: "kjun-table-action-cell", rowSpan: lone, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
@@ -13304,7 +13447,7 @@ function CardSkeleton({ layout }) {
|
|
|
13304
13447
|
] }) }),
|
|
13305
13448
|
highlight && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "kjun-table-card-highlight", children: [
|
|
13306
13449
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(KjunSkeleton, { type: "line", role: "caption", width: "20%" }),
|
|
13307
|
-
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(KjunSkeleton, { type: "line", role: "
|
|
13450
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(KjunSkeleton, { type: "line", role: "numberLg", width: "45%" })
|
|
13308
13451
|
] }),
|
|
13309
13452
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "kjun-table-card-section", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "kjun-table-card-body" + (rows ? " kjun-table-card-body--rows" : ""), children: [0, 1, 2, 3].map((field) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "kjun-table-card-field", children: [
|
|
13310
13453
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(KjunSkeleton, { type: "line", role: "caption", width: rows ? "25%" : "50%" }),
|
|
@@ -13982,6 +14125,7 @@ function KjunTable(props) {
|
|
|
13982
14125
|
hoverable,
|
|
13983
14126
|
...grouping,
|
|
13984
14127
|
edgeInset: props.edgeInset,
|
|
14128
|
+
layout: props.layout,
|
|
13985
14129
|
stickyOffset: props.stickyOffset,
|
|
13986
14130
|
sortable: props.sortable
|
|
13987
14131
|
}
|
|
@@ -14768,6 +14912,7 @@ function KjunMarketTable(props) {
|
|
|
14768
14912
|
if (cellLoading(row, col))
|
|
14769
14913
|
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(KjunSkeleton, { type: "line", width: import_tokens87.tokens.extensions.marketTable.valueSkeletonWidth });
|
|
14770
14914
|
if (renderCell) return renderCell(row, col);
|
|
14915
|
+
if (col.render) return col.render(row, col);
|
|
14771
14916
|
const kind = marketCellKind(col), context = { currency, row, column: col };
|
|
14772
14917
|
if (kind === "identity") return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(MarketIdentity, { row, props });
|
|
14773
14918
|
if (kind === "sparkline")
|
|
@@ -14921,6 +15066,22 @@ function KjunMarketTable(props) {
|
|
|
14921
15066
|
var import_tokens90 = require("@kjun-ui/tokens");
|
|
14922
15067
|
var import_react80 = require("react");
|
|
14923
15068
|
|
|
15069
|
+
// shared/package-runtime/node-text.ts
|
|
15070
|
+
function nodeText(node) {
|
|
15071
|
+
var _a;
|
|
15072
|
+
if (typeof node === "string") return node.trim() || void 0;
|
|
15073
|
+
if (typeof node === "number") return String(node);
|
|
15074
|
+
if (Array.isArray(node)) return node.map(nodeText).filter(Boolean).join(" ") || void 0;
|
|
15075
|
+
if (!node || typeof node !== "object" || !("props" in node)) return void 0;
|
|
15076
|
+
const props = (_a = node.props) != null ? _a : {};
|
|
15077
|
+
for (const name of [props.ariaLabel, props.label]) if (typeof name === "string" && name.trim()) return name.trim();
|
|
15078
|
+
if (typeof props.count === "number") {
|
|
15079
|
+
const max = typeof props.max === "number" ? props.max : 99;
|
|
15080
|
+
return props.count > 0 ? props.count > max ? max + "+" : String(props.count) : void 0;
|
|
15081
|
+
}
|
|
15082
|
+
return nodeText(props.children);
|
|
15083
|
+
}
|
|
15084
|
+
|
|
14924
15085
|
// shared/package-runtime/list-leading.ts
|
|
14925
15086
|
var import_tokens89 = require("@kjun-ui/tokens");
|
|
14926
15087
|
function listLeadingGeometry({ size, custom, background, open = false }) {
|
|
@@ -15005,14 +15166,14 @@ function KjunListRow({ title, description, badge, icon: icon2, leadingSize, icon
|
|
|
15005
15166
|
main,
|
|
15006
15167
|
(hasContent(actions) || movable) && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "kjun-list-actions", "data-disabled": disabled || void 0, inert: disabled || void 0, children: [
|
|
15007
15168
|
actions,
|
|
15008
|
-
movable && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ReorderControls, { value, name: title })
|
|
15169
|
+
movable && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ReorderControls, { value, name: nodeText(title) || ariaLabel || "" })
|
|
15009
15170
|
] }),
|
|
15010
15171
|
expandable && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { id: id + "-expanded", className: "kjun-list-expanded", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Collapse, { open: !!expanded, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "kjun-list-expanded-body", children: expandedContent }) }) })
|
|
15011
15172
|
] });
|
|
15012
15173
|
}
|
|
15013
15174
|
var ListGroupContext = (0, import_react80.createContext)(null);
|
|
15014
|
-
function KjunListSection({ title, description, badge, id: rootId, className, style, actions, children, ariaLabel, surface = true, divider: dividerProp, density = "default", radius, titleVariant, headingLevel = 3, empty: empty3, footer, loading, selectionMode = "none", value, onValueChange, variant, reorderable = false, order, onOrderChange, onReorder, reorderControls = "buttons", reorderDisabled = false, reorderDisabledText }) {
|
|
15015
|
-
const { open, details, corner, bare, outside } = listSectionShape({ radius, group: (0, import_react80.useContext)(ListGroupContext), variant, title, description, titleVariant });
|
|
15175
|
+
function KjunListSection({ title, description, badge, id: rootId, className, style, actions, children, ariaLabel, surface = true, bleed: bleedProp = false, divider: dividerProp, density = "default", radius, titleVariant, headingLevel = 3, empty: empty3, footer, loading, selectionMode = "none", value, onValueChange, variant, reorderable = false, order, onOrderChange, onReorder, reorderControls = "buttons", reorderDisabled = false, reorderDisabledText }) {
|
|
15176
|
+
const { open, details, corner, bare, outside, bleed } = listSectionShape({ radius, group: (0, import_react80.useContext)(ListGroupContext), variant, title, description, titleVariant, bleed: bleedProp });
|
|
15016
15177
|
const divider = dividerProp != null ? dividerProp : !details;
|
|
15017
15178
|
(0, import_react80.useEffect)(() => warnListSectionProps({ open, divider: dividerProp, details, compact: density === "compact" }), [open, dividerProp, details, density]);
|
|
15018
15179
|
(0, import_react80.useEffect)(() => warnListSelection({ mode: selectionMode, value, handled: !!onValueChange }), [selectionMode, Array.isArray(value), value === void 0, !!onValueChange]);
|
|
@@ -15028,7 +15189,7 @@ function KjunListSection({ title, description, badge, id: rootId, className, sty
|
|
|
15028
15189
|
const shape = (0, import_react80.useMemo)(() => ({ open, details, compact: !!compact }), [open, details, compact]);
|
|
15029
15190
|
const selection = (0, import_react80.useMemo)(() => ({ mode: selectionMode, value, onValueChange }), [selectionMode, value, onValueChange]);
|
|
15030
15191
|
const rows = hasContent(loading) ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "kjun-list-loading", children: loading }) : hasContent(children) ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("ul", { ref: setList, className: "kjun-list", role: choice ? "radiogroup" : void 0, "aria-label": ariaLabel || void 0, "aria-labelledby": ariaLabel || !title ? void 0 : hasBadge ? id + " " + id + "-badge" : id, "aria-describedby": describedBy, "data-divider": divider ? void 0 : "false", "data-density": compact, "data-variant": look, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ListSelectionContext.Provider, { value: selection, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ReorderContext.Provider, { value: reorder.context, children }) }) }) : hasContent(empty3) ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "kjun-list-empty", "data-density": compact, children: empty3 }) : null;
|
|
15031
|
-
return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ListShapeContext.Provider, { value: shape, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("section", { id: rootId, className: "kjun-list-section" + (className ? " " + className : ""), style, "data-surface": surface
|
|
15192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ListShapeContext.Provider, { value: shape, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("section", { id: rootId, className: "kjun-list-section" + (className ? " " + className : ""), style, "data-surface": listSectionSurface(surface).attribute, "data-outside": outside || void 0, "data-bleed": bleed || void 0, "data-variant": look, children: [
|
|
15032
15193
|
(title || description || hasContent(actions)) && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "kjun-list-heading", "data-bare": bare ? "" : void 0, children: [
|
|
15033
15194
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { children: [
|
|
15034
15195
|
hasBadge ? /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "kjun-list-heading-title", children: [
|
|
@@ -15039,7 +15200,7 @@ function KjunListSection({ title, description, badge, id: rootId, className, sty
|
|
|
15039
15200
|
] }),
|
|
15040
15201
|
hasContent(actions) && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { ref: setActionsBox, className: "kjun-list-heading-actions", children: actions })
|
|
15041
15202
|
] }),
|
|
15042
|
-
outside ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "kjun-list-panel", "data-surface": surface
|
|
15203
|
+
outside ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "kjun-list-panel", "data-surface": listSectionSurface(surface).attribute, style: rounded, children: rows }) : rows,
|
|
15043
15204
|
note && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { id: note, className: "kjun-list-footer", children: reorderDisabledText }),
|
|
15044
15205
|
hasFooter && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { id: id + "-footer", className: "kjun-list-footer", children: footer }),
|
|
15045
15206
|
reorderable && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "kjun-sr-only", role: "status", children: reorder.said })
|
|
@@ -15070,6 +15231,7 @@ function revealDelta(itemStart, itemEnd, viewStart, viewEnd) {
|
|
|
15070
15231
|
if (itemEnd > viewEnd) return itemEnd - viewEnd;
|
|
15071
15232
|
return 0;
|
|
15072
15233
|
}
|
|
15234
|
+
var floatingBarEdge = (offset, safeBottom) => `calc(${offset}px + ${safeBottom})`;
|
|
15073
15235
|
|
|
15074
15236
|
// shared/package-runtime/side-navigation.ts
|
|
15075
15237
|
var isSideGroup = (entry) => "items" in entry;
|
|
@@ -15348,12 +15510,12 @@ function useBottomBar() {
|
|
|
15348
15510
|
(0, import_react81.useLayoutEffect)(() => trackBottomBar(bar), [bar]);
|
|
15349
15511
|
return [setBar, bar];
|
|
15350
15512
|
}
|
|
15351
|
-
function KjunBottomNavigation({ items, value, ariaLabel, safeArea = true, keyboardVisible = false, hideOnKeyboard = true, onNavigate, onReselect, surface = true, iconStyle = "auto", showLabels = true }) {
|
|
15513
|
+
function KjunBottomNavigation({ items, value, ariaLabel, safeArea = true, keyboardVisible = false, hideOnKeyboard = true, onNavigate, onReselect, surface = true, iconStyle = "auto", showLabels = true, sticky = false }) {
|
|
15352
15514
|
const m = useKjunMessages();
|
|
15353
15515
|
ariaLabel != null ? ariaLabel : ariaLabel = m.mainNavigation;
|
|
15354
15516
|
const layout = bottomNavigationLayout(items, showLabels), [bar] = useBottomBar();
|
|
15355
15517
|
if (keyboardVisible && hideOnKeyboard) return null;
|
|
15356
|
-
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("nav", { ref: bar, className: "kjun-bottom-navigation", "data-icons": layout.hasIcons || void 0, "data-icon-style": iconStyle, "data-labels": layout.iconOnly ? "false" : void 0, "data-surface": surface ? void 0 : "false", "aria-label": ariaLabel, style: { paddingBottom: webSafeBottom(safeArea) }, children: items.map((item) => {
|
|
15518
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("nav", { ref: bar, className: "kjun-bottom-navigation", "data-icons": layout.hasIcons || void 0, "data-icon-style": iconStyle, "data-labels": layout.iconOnly ? "false" : void 0, "data-surface": surface ? void 0 : "false", "data-sticky": sticky || void 0, "aria-label": ariaLabel, style: { paddingBottom: webSafeBottom(safeArea) }, children: items.map((item) => {
|
|
15357
15519
|
const selected = value === item.key, parts2 = layout.parts(item);
|
|
15358
15520
|
const badge = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(NavigationBadgeMark, { badge: item.badge });
|
|
15359
15521
|
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Destination, { item, selected, onNavigate, onReselect, children: [
|
|
@@ -15368,7 +15530,7 @@ function KjunBottomNavigation({ items, value, ariaLabel, safeArea = true, keyboa
|
|
|
15368
15530
|
] }, item.key);
|
|
15369
15531
|
}) });
|
|
15370
15532
|
}
|
|
15371
|
-
function KjunFloatingNavigation({ items, value, ariaLabel, safeArea = true, keyboardVisible = false, hideOnKeyboard = true, onNavigate, onReselect }) {
|
|
15533
|
+
function KjunFloatingNavigation({ items, value, ariaLabel, safeArea = true, keyboardVisible = false, hideOnKeyboard = true, onNavigate, onReselect, sticky = false }) {
|
|
15372
15534
|
const m = useKjunMessages();
|
|
15373
15535
|
ariaLabel != null ? ariaLabel : ariaLabel = m.mainNavigation;
|
|
15374
15536
|
const geometry = import_tokens91.tokens.extensions.floatingNavigation;
|
|
@@ -15381,7 +15543,8 @@ function KjunFloatingNavigation({ items, value, ariaLabel, safeArea = true, keyb
|
|
|
15381
15543
|
if (delta) nav.scrollLeft += delta;
|
|
15382
15544
|
}, [nav, value, items.map((item) => item.key).join("\n")]);
|
|
15383
15545
|
if (keyboardVisible && hideOnKeyboard) return null;
|
|
15384
|
-
|
|
15546
|
+
const edge2 = floatingBarEdge(geometry.offset, webSafeBottom(safeArea));
|
|
15547
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("nav", { ref: bar, className: "kjun-floating-navigation", "data-sticky": sticky || void 0, "aria-label": ariaLabel, style: { marginBottom: edge2, bottom: sticky ? edge2 : void 0 }, children: items.map((item) => {
|
|
15385
15548
|
const selected = value === item.key;
|
|
15386
15549
|
const badge = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(NavigationBadgeMark, { badge: item.badge });
|
|
15387
15550
|
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Destination, { item, selected, onNavigate, onReselect, children: item.icon ? /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("span", { className: "kjun-navigation-icon", children: [
|
|
@@ -15393,12 +15556,12 @@ function KjunFloatingNavigation({ items, value, ariaLabel, safeArea = true, keyb
|
|
|
15393
15556
|
] }) }, item.key);
|
|
15394
15557
|
}) });
|
|
15395
15558
|
}
|
|
15396
|
-
function KjunBottomActionBar({ description, children, safeArea = true, keyboardVisible = false, hideOnKeyboard = false, surface = true, variant = "docked", ariaLabel }) {
|
|
15559
|
+
function KjunBottomActionBar({ description, children, safeArea = true, keyboardVisible = false, hideOnKeyboard = false, surface = true, variant = "docked", ariaLabel, sticky = false }) {
|
|
15397
15560
|
const [bar] = useBottomBar();
|
|
15398
15561
|
if (keyboardVisible && hideOnKeyboard) return null;
|
|
15399
15562
|
const floating = variant === "floating", inset = floating ? import_tokens91.tokens.extensions.floatingNavigation.offset : import_tokens91.tokens.extensions.navigation.padding;
|
|
15400
15563
|
const actions = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "kjun-navigation-actions", children });
|
|
15401
|
-
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { ref: bar, className: "kjun-bottom-action-bar", role: ariaLabel ? "region" : void 0, "aria-label": ariaLabel, "data-variant": floating ? "floating" : void 0, "data-surface": surface ? void 0 : "false", style: { paddingBottom: `calc(${inset}px + ${webSafeBottom(safeArea)})` }, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "kjun-bottom-action-content", children: [
|
|
15564
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { ref: bar, className: "kjun-bottom-action-bar", role: ariaLabel ? "region" : void 0, "aria-label": ariaLabel, "data-variant": floating ? "floating" : void 0, "data-surface": surface ? void 0 : "false", "data-sticky": sticky || void 0, style: { paddingBottom: `calc(${inset}px + ${webSafeBottom(safeArea)})` }, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "kjun-bottom-action-content", children: [
|
|
15402
15565
|
description && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: description }),
|
|
15403
15566
|
floating ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ActionSizeContext.Provider, { value: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ActionShapeContext.Provider, { value: "pill", children: actions }) }) : actions
|
|
15404
15567
|
] }) });
|
|
@@ -15873,9 +16036,135 @@ function KjunSideNavigation({
|
|
|
15873
16036
|
}
|
|
15874
16037
|
|
|
15875
16038
|
// packages/react/src/side-navigation-layout.tsx
|
|
16039
|
+
var import_tokens94 = require("@kjun-ui/tokens");
|
|
16040
|
+
var import_react85 = require("react");
|
|
16041
|
+
|
|
16042
|
+
// shared/package-runtime/side-navigation-layout.ts
|
|
16043
|
+
function spacesRailCellWidth(geometry) {
|
|
16044
|
+
return geometry.paddingX * 2 + geometry.iconSize + geometry.spacesRailPaddingX * 2;
|
|
16045
|
+
}
|
|
16046
|
+
function spacesColumnWidth(geometry, surface, panelCollapsed) {
|
|
16047
|
+
const rail = spacesRailCellWidth(geometry);
|
|
16048
|
+
if (panelCollapsed) return rail;
|
|
16049
|
+
return rail + geometry.spacesPanelWidth + (surface === "card" ? geometry.spacesPanelInset : 0);
|
|
16050
|
+
}
|
|
16051
|
+
function spacesFocusAfterChange(nextCollapsed, focusInPanel, byButton) {
|
|
16052
|
+
if (nextCollapsed) return focusInPanel || byButton ? "expand" : null;
|
|
16053
|
+
return byButton ? "collapse" : null;
|
|
16054
|
+
}
|
|
16055
|
+
function spacesIgnoredProps(props) {
|
|
16056
|
+
const ignored = [];
|
|
16057
|
+
if (props.collapsed) ignored.push("collapsed");
|
|
16058
|
+
if (props.railLabels) ignored.push("railLabels");
|
|
16059
|
+
if (props.width !== void 0 && props.width !== "md") ignored.push("width");
|
|
16060
|
+
return ignored;
|
|
16061
|
+
}
|
|
16062
|
+
|
|
16063
|
+
// packages/react/src/side-navigation-layout-spaces.tsx
|
|
15876
16064
|
var import_tokens93 = require("@kjun-ui/tokens");
|
|
15877
16065
|
var import_react84 = require("react");
|
|
15878
16066
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
16067
|
+
function SpacesLayout(p) {
|
|
16068
|
+
var _a;
|
|
16069
|
+
const m = useKjunMessages(), reduced = useReducedMotion(), panelId = "kjun-side-panel-" + (0, import_react84.useId)().replace(/[^\w-]/g, "");
|
|
16070
|
+
const panel = (0, import_react84.useRef)(null), expand = (0, import_react84.useRef)(null), collapse = (0, import_react84.useRef)(null);
|
|
16071
|
+
const [settled, setSettled] = (0, import_react84.useState)(p.panelCollapsed);
|
|
16072
|
+
const byButton = (0, import_react84.useRef)(false), first = (0, import_react84.useRef)(true);
|
|
16073
|
+
(0, import_react84.useEffect)(() => {
|
|
16074
|
+
var _a2, _b;
|
|
16075
|
+
if (first.current) {
|
|
16076
|
+
first.current = false;
|
|
16077
|
+
return;
|
|
16078
|
+
}
|
|
16079
|
+
const inPanel = !!panel.current && panel.current.contains(document.activeElement);
|
|
16080
|
+
const target = spacesFocusAfterChange(p.panelCollapsed, inPanel, byButton.current);
|
|
16081
|
+
byButton.current = false;
|
|
16082
|
+
if (target === "expand") (_a2 = expand.current) == null ? void 0 : _a2.focus();
|
|
16083
|
+
else if (target === "collapse") (_b = collapse.current) == null ? void 0 : _b.focus();
|
|
16084
|
+
if (!p.panelCollapsed) {
|
|
16085
|
+
setSettled(false);
|
|
16086
|
+
return;
|
|
16087
|
+
}
|
|
16088
|
+
const timer = setTimeout(() => setSettled(true), reduced ? 0 : import_tokens93.tokens.motion.collapse);
|
|
16089
|
+
return () => clearTimeout(timer);
|
|
16090
|
+
}, [p.panelCollapsed]);
|
|
16091
|
+
const request = (next) => {
|
|
16092
|
+
var _a2;
|
|
16093
|
+
byButton.current = true;
|
|
16094
|
+
(_a2 = p.onPanelCollapsedChange) == null ? void 0 : _a2.call(p, next);
|
|
16095
|
+
};
|
|
16096
|
+
const render = (slot, state) => typeof slot === "function" ? slot(state) : slot;
|
|
16097
|
+
const toggle = (next, ref) => {
|
|
16098
|
+
const label = next ? m.collapseSpacesPanel : m.expandSpacesPanel;
|
|
16099
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(KjunTooltip, { content: label, placement: "right", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
16100
|
+
"button",
|
|
16101
|
+
{
|
|
16102
|
+
ref,
|
|
16103
|
+
type: "button",
|
|
16104
|
+
className: "kjun-side-navigation-toggle kjun-side-navigation-layout-panel-toggle",
|
|
16105
|
+
"aria-label": label,
|
|
16106
|
+
"aria-expanded": !p.panelCollapsed,
|
|
16107
|
+
"aria-controls": panelId,
|
|
16108
|
+
onClick: () => request(next),
|
|
16109
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(IconFallbacks, { icons: componentIcons, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(KjunIcon, { name: next ? "layout-sidebar-left-collapse" : "layout-sidebar-left-expand", size: import_tokens93.tokens.extensions.sideNavigation.iconSize }) })
|
|
16110
|
+
}
|
|
16111
|
+
) });
|
|
16112
|
+
};
|
|
16113
|
+
const band = (drawer) => {
|
|
16114
|
+
var _a2;
|
|
16115
|
+
const closed = !drawer && p.panelCollapsed;
|
|
16116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
16117
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "kjun-side-navigation-layout-spaces", children: [
|
|
16118
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "kjun-side-navigation-layout-spaces-top", children: closed && toggle(false, expand) }),
|
|
16119
|
+
render(p.spaces, { collapsed: true, drawer, closeDrawer: p.closeDrawer })
|
|
16120
|
+
] }),
|
|
16121
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("section", { ref: panel, id: panelId, className: "kjun-side-navigation-layout-panel", "aria-label": (_a2 = p.panelLabel) != null ? _a2 : m.spacesPanel, hidden: closed && settled, children: [
|
|
16122
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "kjun-side-navigation-layout-panel-head", children: [
|
|
16123
|
+
p.spacesTitle != null && p.spacesTitle !== false && p.spacesTitle !== "" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "kjun-side-navigation-layout-panel-title", children: p.spacesTitle }),
|
|
16124
|
+
drawer ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: "kjun-side-navigation-toggle kjun-side-navigation-layout-panel-toggle", "aria-label": m.close, onClick: p.closeDrawer, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(KjunIcon, { name: "x", size: import_tokens93.tokens.extensions.sideNavigation.iconSize }) }) : (!closed || !settled) && toggle(true, collapse)
|
|
16125
|
+
] }),
|
|
16126
|
+
render(p.nav, { collapsed: false, drawer, closeDrawer: p.closeDrawer })
|
|
16127
|
+
] })
|
|
16128
|
+
] });
|
|
16129
|
+
};
|
|
16130
|
+
if (p.narrow) return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: p.classes, "data-drawer": "", children: [
|
|
16131
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "kjun-side-navigation-layout-main", children: p.children }),
|
|
16132
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
16133
|
+
KjunDrawer,
|
|
16134
|
+
{
|
|
16135
|
+
open: p.navOpen,
|
|
16136
|
+
onOpenChange: (next) => {
|
|
16137
|
+
var _a2;
|
|
16138
|
+
return (_a2 = p.onNavOpenChange) == null ? void 0 : _a2.call(p, next);
|
|
16139
|
+
},
|
|
16140
|
+
position: "left",
|
|
16141
|
+
ariaLabel: (_a = p.drawerLabel) != null ? _a : m.mainNavigation,
|
|
16142
|
+
width: spacesColumnWidth(import_tokens93.tokens.extensions.sideNavigation, p.panelSurface, false),
|
|
16143
|
+
closable: false,
|
|
16144
|
+
noPadding: true,
|
|
16145
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "kjun-side-navigation-layout-band", "data-panel-surface": p.panelSurface, children: band(true) })
|
|
16146
|
+
}
|
|
16147
|
+
)
|
|
16148
|
+
] });
|
|
16149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
16150
|
+
"div",
|
|
16151
|
+
{
|
|
16152
|
+
className: p.classes,
|
|
16153
|
+
"data-spaces": "",
|
|
16154
|
+
"data-panel-surface": p.panelSurface,
|
|
16155
|
+
"data-panel-collapsed": p.panelCollapsed ? "" : void 0,
|
|
16156
|
+
"data-sticky": p.sticky ? void 0 : "false",
|
|
16157
|
+
style: p.offset,
|
|
16158
|
+
children: [
|
|
16159
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "kjun-side-navigation-layout-nav", children: band(false) }),
|
|
16160
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "kjun-side-navigation-layout-main", children: p.children })
|
|
16161
|
+
]
|
|
16162
|
+
}
|
|
16163
|
+
);
|
|
16164
|
+
}
|
|
16165
|
+
|
|
16166
|
+
// packages/react/src/side-navigation-layout.tsx
|
|
16167
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
15879
16168
|
var subscribeTo = (query2) => (notify) => {
|
|
15880
16169
|
if (typeof matchMedia !== "function") return () => {
|
|
15881
16170
|
};
|
|
@@ -15885,8 +16174,8 @@ var subscribeTo = (query2) => (notify) => {
|
|
|
15885
16174
|
};
|
|
15886
16175
|
function useNarrow(breakpoint) {
|
|
15887
16176
|
const query2 = `(width < ${breakpoint}px)`;
|
|
15888
|
-
const subscribe2 = (0,
|
|
15889
|
-
return (0,
|
|
16177
|
+
const subscribe2 = (0, import_react85.useCallback)(subscribeTo(query2), [query2]);
|
|
16178
|
+
return (0, import_react85.useSyncExternalStore)(subscribe2, () => breakpoint > 0 && typeof matchMedia === "function" && matchMedia(query2).matches, () => false);
|
|
15890
16179
|
}
|
|
15891
16180
|
function KjunSideNavigationLayout({
|
|
15892
16181
|
nav,
|
|
@@ -15898,23 +16187,40 @@ function KjunSideNavigationLayout({
|
|
|
15898
16187
|
width = "md",
|
|
15899
16188
|
sticky = true,
|
|
15900
16189
|
stickyOffset = 0,
|
|
15901
|
-
breakpoint =
|
|
16190
|
+
breakpoint = import_tokens94.tokens.responsive.sideNavigationLayout,
|
|
15902
16191
|
navOpen = false,
|
|
15903
16192
|
onNavOpenChange,
|
|
15904
16193
|
drawerLabel,
|
|
16194
|
+
spaces,
|
|
16195
|
+
spacesTitle,
|
|
16196
|
+
panelSurface = "card",
|
|
16197
|
+
panelCollapsed = false,
|
|
16198
|
+
onPanelCollapsedChange,
|
|
16199
|
+
panelLabel,
|
|
15905
16200
|
className
|
|
15906
16201
|
}) {
|
|
15907
16202
|
const m = useKjunMessages(), narrow = useNarrow(breakpoint), below = useNarrow(railBreakpoint);
|
|
15908
|
-
const
|
|
15909
|
-
|
|
15910
|
-
const
|
|
15911
|
-
|
|
16203
|
+
const spaced = spaces != null && spaces !== false;
|
|
16204
|
+
const folded = spaced ? panelCollapsed : collapsed, onFold = spaced ? onPanelCollapsedChange : onCollapsedChange;
|
|
16205
|
+
const latest = (0, import_react85.useRef)({ collapsed: folded, navOpen, onCollapsedChange: onFold, onNavOpenChange });
|
|
16206
|
+
latest.current = { collapsed: folded, navOpen, onCollapsedChange: onFold, onNavOpenChange };
|
|
16207
|
+
const warned4 = (0, import_react85.useRef)(false);
|
|
16208
|
+
(0, import_react85.useEffect)(() => {
|
|
16209
|
+
if (!spaced || warned4.current || !developmentMode9()) return;
|
|
16210
|
+
const ignored = spacesIgnoredProps({ collapsed, railLabels, width });
|
|
16211
|
+
if (ignored.length > 0) {
|
|
16212
|
+
warned4.current = true;
|
|
16213
|
+
console.warn(`KjunSideNavigationLayout: ${ignored.join(", ")} do not apply with spaces.`);
|
|
16214
|
+
}
|
|
16215
|
+
}, [spaced, collapsed, railLabels, width]);
|
|
16216
|
+
const wasNarrow = (0, import_react85.useRef)(narrow);
|
|
16217
|
+
(0, import_react85.useEffect)(() => {
|
|
15912
16218
|
var _a, _b;
|
|
15913
16219
|
if (wasNarrow.current && !narrow && latest.current.navOpen) (_b = (_a = latest.current).onNavOpenChange) == null ? void 0 : _b.call(_a, false);
|
|
15914
16220
|
wasNarrow.current = narrow;
|
|
15915
16221
|
}, [narrow]);
|
|
15916
|
-
const wasBelow = (0,
|
|
15917
|
-
(0,
|
|
16222
|
+
const wasBelow = (0, import_react85.useRef)(null);
|
|
16223
|
+
(0, import_react85.useEffect)(() => {
|
|
15918
16224
|
var _a, _b;
|
|
15919
16225
|
if (railBreakpoint <= 0) {
|
|
15920
16226
|
wasBelow.current = null;
|
|
@@ -15930,22 +16236,43 @@ function KjunSideNavigationLayout({
|
|
|
15930
16236
|
};
|
|
15931
16237
|
const menu = (state) => typeof nav === "function" ? nav({ ...state, closeDrawer }) : nav;
|
|
15932
16238
|
const classes = "kjun-side-navigation-layout" + (className ? " " + className : "");
|
|
15933
|
-
|
|
15934
|
-
|
|
15935
|
-
|
|
16239
|
+
const offset = sticky && stickyOffset > 0 ? { ["--_kjun-side-navigation-layout-top"]: stickyOffset + "px" } : void 0;
|
|
16240
|
+
if (spaced) return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
16241
|
+
SpacesLayout,
|
|
16242
|
+
{
|
|
16243
|
+
spaces,
|
|
16244
|
+
nav,
|
|
16245
|
+
spacesTitle,
|
|
16246
|
+
panelSurface,
|
|
16247
|
+
panelCollapsed,
|
|
16248
|
+
onPanelCollapsedChange,
|
|
16249
|
+
panelLabel,
|
|
16250
|
+
narrow,
|
|
16251
|
+
navOpen,
|
|
16252
|
+
onNavOpenChange,
|
|
16253
|
+
closeDrawer,
|
|
16254
|
+
drawerLabel,
|
|
16255
|
+
sticky,
|
|
16256
|
+
offset,
|
|
16257
|
+
classes,
|
|
16258
|
+
children
|
|
16259
|
+
}
|
|
16260
|
+
);
|
|
16261
|
+
if (narrow) return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: classes, "data-drawer": "", children: [
|
|
16262
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "kjun-side-navigation-layout-main", children }),
|
|
16263
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
15936
16264
|
KjunDrawer,
|
|
15937
16265
|
{
|
|
15938
16266
|
open: navOpen,
|
|
15939
16267
|
onOpenChange: (next) => onNavOpenChange == null ? void 0 : onNavOpenChange(next),
|
|
15940
16268
|
position: "left",
|
|
15941
16269
|
ariaLabel: drawerLabel != null ? drawerLabel : m.mainNavigation,
|
|
15942
|
-
width:
|
|
16270
|
+
width: import_tokens94.tokens.extensions.sideNavigation.width[width],
|
|
15943
16271
|
children: menu({ collapsed: false, drawer: true })
|
|
15944
16272
|
}
|
|
15945
16273
|
)
|
|
15946
16274
|
] });
|
|
15947
|
-
|
|
15948
|
-
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
16275
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
|
|
15949
16276
|
"div",
|
|
15950
16277
|
{
|
|
15951
16278
|
className: classes,
|
|
@@ -15955,19 +16282,19 @@ function KjunSideNavigationLayout({
|
|
|
15955
16282
|
"data-sticky": sticky ? void 0 : "false",
|
|
15956
16283
|
style: offset,
|
|
15957
16284
|
children: [
|
|
15958
|
-
/* @__PURE__ */ (0,
|
|
15959
|
-
/* @__PURE__ */ (0,
|
|
16285
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "kjun-side-navigation-layout-nav", children: menu({ collapsed, drawer: false }) }),
|
|
16286
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "kjun-side-navigation-layout-main", children })
|
|
15960
16287
|
]
|
|
15961
16288
|
}
|
|
15962
16289
|
);
|
|
15963
16290
|
}
|
|
15964
16291
|
|
|
15965
16292
|
// packages/react/src/pressable.tsx
|
|
15966
|
-
var
|
|
15967
|
-
var
|
|
15968
|
-
var KjunPressable = (0,
|
|
16293
|
+
var import_react86 = require("react");
|
|
16294
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
16295
|
+
var KjunPressable = (0, import_react86.forwardRef)(function KjunPressable2({ ariaLabel, disabled = false, pressEffect = "overlay", focusRingInset = false, className, children, onClick, onKeyDown, onKeyUp, ...props }, ref) {
|
|
15969
16296
|
var _a;
|
|
15970
|
-
return /* @__PURE__ */ (0,
|
|
16297
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
15971
16298
|
"div",
|
|
15972
16299
|
{
|
|
15973
16300
|
role: "button",
|
|
@@ -16000,14 +16327,14 @@ var KjunPressable = (0, import_react85.forwardRef)(function KjunPressable2({ ari
|
|
|
16000
16327
|
});
|
|
16001
16328
|
|
|
16002
16329
|
// packages/react/src/media.tsx
|
|
16003
|
-
var
|
|
16004
|
-
var
|
|
16005
|
-
var
|
|
16330
|
+
var import_react87 = require("react");
|
|
16331
|
+
var import_tokens95 = require("@kjun-ui/tokens");
|
|
16332
|
+
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
16006
16333
|
function KjunImage({ src, alt, decorative = false, aspectRatio = 1, fit = "cover", shape = "square", fallback: fallback2, lazy = true, onLoad, onError }) {
|
|
16007
|
-
const current = (0,
|
|
16334
|
+
const current = (0, import_react87.useRef)({ src, version: 0 });
|
|
16008
16335
|
if (current.current.src !== src) current.current = { src, version: current.current.version + 1 };
|
|
16009
16336
|
const version = current.current.version;
|
|
16010
|
-
const [result, setResult] = (0,
|
|
16337
|
+
const [result, setResult] = (0, import_react87.useState)({ version, state: "loading" });
|
|
16011
16338
|
const state = result.version === version ? result.state : "loading";
|
|
16012
16339
|
const failed = !src || state === "error";
|
|
16013
16340
|
const auto = aspectRatio === "auto";
|
|
@@ -16017,7 +16344,7 @@ function KjunImage({ src, alt, decorative = false, aspectRatio = 1, fit = "cover
|
|
|
16017
16344
|
if (next === "loaded") onLoad == null ? void 0 : onLoad();
|
|
16018
16345
|
else onError == null ? void 0 : onError();
|
|
16019
16346
|
};
|
|
16020
|
-
const settled = (0,
|
|
16347
|
+
const settled = (0, import_react87.useRef)(-1);
|
|
16021
16348
|
const seen = (img) => {
|
|
16022
16349
|
if (!img || !img.complete || settled.current === version) return;
|
|
16023
16350
|
settled.current = version;
|
|
@@ -16029,7 +16356,7 @@ function KjunImage({ src, alt, decorative = false, aspectRatio = 1, fit = "cover
|
|
|
16029
16356
|
settle(next);
|
|
16030
16357
|
};
|
|
16031
16358
|
const textual = typeof fallback2 === "string" || typeof fallback2 === "number";
|
|
16032
|
-
return /* @__PURE__ */ (0,
|
|
16359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
|
|
16033
16360
|
"span",
|
|
16034
16361
|
{
|
|
16035
16362
|
className: "kjun-image",
|
|
@@ -16039,25 +16366,25 @@ function KjunImage({ src, alt, decorative = false, aspectRatio = 1, fit = "cover
|
|
|
16039
16366
|
"data-ratio": auto ? "auto" : void 0,
|
|
16040
16367
|
"data-fallback": failed && textual ? "text" : void 0,
|
|
16041
16368
|
children: [
|
|
16042
|
-
!failed && /* @__PURE__ */ (0,
|
|
16043
|
-
failed && /* @__PURE__ */ (0,
|
|
16044
|
-
/* @__PURE__ */ (0,
|
|
16045
|
-
/* @__PURE__ */ (0,
|
|
16046
|
-
] }) : fallback2 != null ? fallback2 : /* @__PURE__ */ (0,
|
|
16369
|
+
!failed && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("img", { ref: seen, src, alt: decorative ? "" : alt, loading: lazy ? "lazy" : "eager", style: { objectFit: fit }, onLoad: () => load("loaded"), onError: () => load("error") }, version),
|
|
16370
|
+
failed && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "kjun-image-fallback", "data-text": textual ? "" : void 0, role: decorative ? void 0 : "img", "aria-label": decorative ? void 0 : alt, "aria-hidden": decorative || void 0, children: textual ? /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
|
|
16371
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(KjunIcon, { name: "photo", size: import_tokens95.tokens.extensions.image.fallbackIconSize }),
|
|
16372
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "kjun-image-fallback-text", children: fallback2 })
|
|
16373
|
+
] }) : fallback2 != null ? fallback2 : /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(KjunIcon, { name: "photo", size: import_tokens95.tokens.extensions.image.fallbackIconSize }) })
|
|
16047
16374
|
]
|
|
16048
16375
|
}
|
|
16049
16376
|
);
|
|
16050
16377
|
}
|
|
16051
16378
|
function KjunAvatar({ src, name = "", alt, decorative = false, size = "md", shape = "circle", color, textColor, fallback: fallback2, onLoad, onError }) {
|
|
16052
16379
|
const m = useKjunMessages();
|
|
16053
|
-
return /* @__PURE__ */ (0,
|
|
16380
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "kjun-avatar", "data-shape": shape, "data-size": size, style: { width: import_tokens95.tokens.extensions.avatar[size], height: import_tokens95.tokens.extensions.avatar[size], ["--_kjun-avatar-color"]: color, ["--_kjun-avatar-text-color"]: textColor }, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(KjunImage, { src, alt: alt || name || m.user, decorative, fallback: (
|
|
16054
16381
|
/* A span, so the image does not treat initials as a text caption. */
|
|
16055
|
-
/* @__PURE__ */ (0,
|
|
16382
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { children: fallback2 != null ? fallback2 : Array.from(name.trim())[0] || /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(KjunIcon, { name: "user", size: import_tokens95.tokens.extensions.avatar.fallbackIconSizes[size] }) })
|
|
16056
16383
|
), onLoad, onError }) });
|
|
16057
16384
|
}
|
|
16058
16385
|
|
|
16059
16386
|
// packages/react/src/avatar-group.tsx
|
|
16060
|
-
var
|
|
16387
|
+
var import_react88 = require("react");
|
|
16061
16388
|
|
|
16062
16389
|
// shared/package-runtime/avatar-group.ts
|
|
16063
16390
|
var AVATAR_GROUP_OVERFLOW_CAP = 99;
|
|
@@ -16073,54 +16400,54 @@ function avatarGroupModel({ count, max = DEFAULT_MAX, total, size }) {
|
|
|
16073
16400
|
}
|
|
16074
16401
|
|
|
16075
16402
|
// packages/react/src/avatar-group.tsx
|
|
16076
|
-
var
|
|
16077
|
-
var KjunAvatarGroup = (0,
|
|
16403
|
+
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
16404
|
+
var KjunAvatarGroup = (0, import_react88.forwardRef)(function KjunAvatarGroup2({ items, max, total, size = "md", shape = "circle", ariaLabel, ringColor, pressable = false, disabled = false, onClick, className, style, id, "aria-describedby": describedBy }, ref) {
|
|
16078
16405
|
const m = useKjunMessages();
|
|
16079
16406
|
const { visible, overflowText, totalCount } = avatarGroupModel({ count: items.length, max, total, size });
|
|
16080
16407
|
const label = ariaLabel != null ? ariaLabel : m.avatarGroupCount(totalCount);
|
|
16081
16408
|
const rootStyle = ringColor === void 0 ? style : { ...style, ["--_kjun-avatar-group-ring"]: ringColor };
|
|
16082
|
-
const content = /* @__PURE__ */ (0,
|
|
16083
|
-
items.slice(0, visible).map(({ key, ...item }, index) => /* @__PURE__ */ (0,
|
|
16084
|
-
overflowText && /* @__PURE__ */ (0,
|
|
16409
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
|
|
16410
|
+
items.slice(0, visible).map(({ key, ...item }, index) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "kjun-avatar-group-item", "aria-hidden": "true", style: { zIndex: visible + 1 - index }, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(KjunAvatar, { ...item, size, shape, decorative: true }) }, key)),
|
|
16411
|
+
overflowText && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "kjun-avatar-group-item kjun-avatar-group-overflow", "aria-hidden": "true", "data-digits": overflowText.length - 1, style: { zIndex: 0 }, children: overflowText })
|
|
16085
16412
|
] });
|
|
16086
16413
|
const classes = className ? `kjun-avatar-group ${className}` : "kjun-avatar-group";
|
|
16087
|
-
return pressable ? /* @__PURE__ */ (0,
|
|
16414
|
+
return pressable ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("button", { ref, id, "aria-describedby": describedBy, type: "button", className: classes, "data-pressable": "", "data-size": size, "data-shape": shape, "aria-label": label, disabled, onClick, style: rootStyle, children: content }) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { ref, id, "aria-describedby": describedBy, className: classes, role: "img", "data-size": size, "data-shape": shape, "aria-label": label, style: rootStyle, children: content });
|
|
16088
16415
|
});
|
|
16089
16416
|
|
|
16090
16417
|
// packages/react/src/chip.tsx
|
|
16091
|
-
var
|
|
16418
|
+
var import_react89 = require("react");
|
|
16092
16419
|
|
|
16093
16420
|
// shared/package-runtime/chip-size.ts
|
|
16094
|
-
var
|
|
16421
|
+
var import_tokens96 = require("@kjun-ui/tokens");
|
|
16095
16422
|
function chipSize(size) {
|
|
16096
|
-
return typeof size === "string" && Object.prototype.hasOwnProperty.call(
|
|
16423
|
+
return typeof size === "string" && Object.prototype.hasOwnProperty.call(import_tokens96.tokens.extensions.chip.typography, size) ? size : "md";
|
|
16097
16424
|
}
|
|
16098
16425
|
|
|
16099
16426
|
// packages/react/src/chip.tsx
|
|
16100
|
-
var
|
|
16101
|
-
var
|
|
16102
|
-
var KjunChip = (0,
|
|
16427
|
+
var import_tokens97 = require("@kjun-ui/tokens");
|
|
16428
|
+
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
16429
|
+
var KjunChip = (0, import_react89.forwardRef)(function KjunChip2({ label, icon: icon2, removable = false, disabled = false, size: requested = "md", removeLabel: removeLabel2, onRemove, className, ...props }, ref) {
|
|
16103
16430
|
const m = useKjunMessages(), size = chipSize(requested);
|
|
16104
|
-
return /* @__PURE__ */ (0,
|
|
16105
|
-
icon2 && /* @__PURE__ */ (0,
|
|
16106
|
-
/* @__PURE__ */ (0,
|
|
16107
|
-
removable && /* @__PURE__ */ (0,
|
|
16431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("span", { ...props, className: "kjun-chip" + (className ? " " + className : ""), "data-size": size, "data-disabled": disabled, "data-removable": removable, "aria-disabled": disabled && !removable ? true : void 0, children: [
|
|
16432
|
+
icon2 && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(KjunIcon, { name: icon2, size: import_tokens97.tokens.extensions.chip.iconSizes[size] }),
|
|
16433
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { title: label, children: label }),
|
|
16434
|
+
removable && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("button", { ref, type: "button", "aria-label": removeLabel2 || m.remove(label), disabled, onClick: () => onRemove == null ? void 0 : onRemove(), children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(KjunIcon, { name: "x", size: import_tokens97.tokens.extensions.chip.removeIconSizes[size] }) })
|
|
16108
16435
|
] });
|
|
16109
16436
|
});
|
|
16110
16437
|
|
|
16111
16438
|
// packages/react/src/fab.tsx
|
|
16112
|
-
var
|
|
16113
|
-
var
|
|
16114
|
-
var
|
|
16115
|
-
var KjunFab = (0,
|
|
16439
|
+
var import_tokens98 = require("@kjun-ui/tokens");
|
|
16440
|
+
var import_react90 = require("react");
|
|
16441
|
+
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
16442
|
+
var KjunFab = (0, import_react90.forwardRef)(function KjunFab2({ icon: icon2, label, collapsed = false, ariaLabel, size = "md", loading = false, disabled = false, safeArea = true, avoidBottomBar = true, offsetBottom = 0, onClick, className = "", style, ...rest }, ref) {
|
|
16116
16443
|
const busy = useMinimumLoading(loading), offset = fabOffset(offsetBottom);
|
|
16117
|
-
const iconSize = size === "sm" ?
|
|
16444
|
+
const iconSize = size === "sm" ? import_tokens98.tokens.extensions.fab.smallIconSize : import_tokens98.tokens.extensions.fab.iconSize;
|
|
16118
16445
|
const name = ariaLabel || rest["aria-label"];
|
|
16119
|
-
(0,
|
|
16446
|
+
(0, import_react90.useEffect)(() => {
|
|
16120
16447
|
const warning = developmentMode9() && fabNameWarning(label, name);
|
|
16121
16448
|
if (warning) console.warn(warning);
|
|
16122
16449
|
}, [label, name]);
|
|
16123
|
-
return /* @__PURE__ */ (0,
|
|
16450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
16124
16451
|
"button",
|
|
16125
16452
|
{
|
|
16126
16453
|
...rest,
|
|
@@ -16140,8 +16467,8 @@ var KjunFab = (0, import_react89.forwardRef)(function KjunFab2({ icon: icon2, la
|
|
|
16140
16467
|
},
|
|
16141
16468
|
style: { ...offset ? { "--_kjun-fab-offset": offset + "px" } : {}, ...style },
|
|
16142
16469
|
children: [
|
|
16143
|
-
busy ? /* @__PURE__ */ (0,
|
|
16144
|
-
label && /* @__PURE__ */ (0,
|
|
16470
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(KjunSpinnerGlyph, { size: iconSize }) : /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(KjunIcon, { name: icon2, size: iconSize }),
|
|
16471
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "kjun-fab-label", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { children: label }) })
|
|
16145
16472
|
]
|
|
16146
16473
|
}
|
|
16147
16474
|
);
|
|
@@ -16327,22 +16654,22 @@ function createSliderSession(initial, options) {
|
|
|
16327
16654
|
}
|
|
16328
16655
|
|
|
16329
16656
|
// packages/react/src/range-input.tsx
|
|
16330
|
-
var
|
|
16657
|
+
var import_react91 = require("react");
|
|
16331
16658
|
var import_react_aria_components10 = require("react-aria-components");
|
|
16332
|
-
var
|
|
16333
|
-
var
|
|
16659
|
+
var import_tokens99 = require("@kjun-ui/tokens");
|
|
16660
|
+
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
16334
16661
|
var edge = "calc(var(--_kjun-slider-thumb) / -2)";
|
|
16335
16662
|
function RangeThumb({ index, label, name, format: format2, front, dragging, bubble, inputs }) {
|
|
16336
|
-
const state = (0,
|
|
16337
|
-
const input = (0,
|
|
16663
|
+
const state = (0, import_react91.useContext)(import_react_aria_components10.SliderStateContext);
|
|
16664
|
+
const input = (0, import_react91.useRef)(null), thumb2 = (0, import_react91.useRef)(null);
|
|
16338
16665
|
const text = format2(state.values[index]);
|
|
16339
|
-
(0,
|
|
16666
|
+
(0, import_react91.useLayoutEffect)(() => {
|
|
16340
16667
|
var _a, _b;
|
|
16341
16668
|
(_a = input.current) == null ? void 0 : _a.setAttribute("aria-valuetext", text);
|
|
16342
16669
|
inputs[index] = input.current;
|
|
16343
16670
|
(_b = thumb2.current) == null ? void 0 : _b.toggleAttribute("data-dragging", dragging || state.isThumbDragging(index));
|
|
16344
16671
|
});
|
|
16345
|
-
return /* @__PURE__ */ (0,
|
|
16672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_react_aria_components10.SliderThumb, { ref: thumb2, index, inputRef: input, name, className: "kjun-slider-thumb", "aria-label": label, "data-front": front || void 0, children: bubble && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "kjun-tooltip kjun-slider-value-label", "aria-hidden": "true", children: text }) });
|
|
16346
16673
|
}
|
|
16347
16674
|
function RangeInput(props) {
|
|
16348
16675
|
const {
|
|
@@ -16372,16 +16699,16 @@ function RangeInput(props) {
|
|
|
16372
16699
|
const format2 = sliderFormatter(formatValue, locale, min, step);
|
|
16373
16700
|
const formatRange2 = "formatRange" in props ? props.formatRange : void 0;
|
|
16374
16701
|
const thumbLabels = "thumbLabels" in props ? props.thumbLabels || [m.minimum, m.maximum] : [m.minimum, m.maximum];
|
|
16375
|
-
const domain = (0,
|
|
16702
|
+
const domain = (0, import_tokens99.createSliderDomain)(min, max, step);
|
|
16376
16703
|
const list = Array.isArray(value) ? value : [value];
|
|
16377
16704
|
const valid = domain.valid && (!Array.isArray(value) || value.length === 2) && list.every((v) => domain.accepts(v)) && (list.length === 1 || list[0] <= list[1]);
|
|
16378
|
-
const latest = (0,
|
|
16705
|
+
const latest = (0, import_react91.useRef)(value);
|
|
16379
16706
|
latest.current = value;
|
|
16380
|
-
const active = (0,
|
|
16381
|
-
const inputs = (0,
|
|
16382
|
-
const track = (0,
|
|
16383
|
-
const [ownDrag, setOwnDrag] = (0,
|
|
16384
|
-
(0,
|
|
16707
|
+
const active = (0, import_react91.useRef)(false);
|
|
16708
|
+
const inputs = (0, import_react91.useRef)([]);
|
|
16709
|
+
const track = (0, import_react91.useRef)(null);
|
|
16710
|
+
const [ownDrag, setOwnDrag] = (0, import_react91.useState)(null);
|
|
16711
|
+
(0, import_react91.useEffect)(() => {
|
|
16385
16712
|
if (!valid) console.warn("KJUN Slider: \uBC94\uC704\xB7step\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
|
|
16386
16713
|
}, [valid]);
|
|
16387
16714
|
const emit = (result) => {
|
|
@@ -16426,7 +16753,7 @@ function RangeInput(props) {
|
|
|
16426
16753
|
return sliderValueAt(vertical ? event.clientY - box.top : event.clientX - box.left, vertical ? box.height : box.width, min, top, layout);
|
|
16427
16754
|
};
|
|
16428
16755
|
const collapsed = valid && !disabled && list.length === 2 && list[0] === list[1];
|
|
16429
|
-
(0,
|
|
16756
|
+
(0, import_react91.useEffect)(() => {
|
|
16430
16757
|
const element = track.current;
|
|
16431
16758
|
if (!element || !collapsed) return;
|
|
16432
16759
|
const down = (event) => {
|
|
@@ -16461,7 +16788,7 @@ function RangeInput(props) {
|
|
|
16461
16788
|
const dots = valid ? sliderMarks(marks, min, top, step, list, layout, fillOrigin) : [];
|
|
16462
16789
|
const fill = sliderFillBox(fractions, layout, valid ? sliderOriginFraction(fillOrigin, min, top) : void 0);
|
|
16463
16790
|
const [lead, trail] = vertical ? ["top", "bottom"] : ["left", "right"];
|
|
16464
|
-
return /* @__PURE__ */ (0,
|
|
16791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
|
|
16465
16792
|
import_react_aria_components10.Slider,
|
|
16466
16793
|
{
|
|
16467
16794
|
id,
|
|
@@ -16486,15 +16813,15 @@ function RangeInput(props) {
|
|
|
16486
16813
|
}
|
|
16487
16814
|
},
|
|
16488
16815
|
children: [
|
|
16489
|
-
(label || showValue) && /* @__PURE__ */ (0,
|
|
16490
|
-
label && /* @__PURE__ */ (0,
|
|
16491
|
-
showValue && /* @__PURE__ */ (0,
|
|
16816
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "kjun-slider-caption", children: [
|
|
16817
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_react_aria_components10.Label, { className: "kjun-slider-label", children: label }),
|
|
16818
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_react_aria_components10.SliderOutput, { className: "kjun-slider-value", children: ({ state }) => sliderValueText(valid ? state.values : list, format2, formatRange2) })
|
|
16492
16819
|
] }),
|
|
16493
|
-
/* @__PURE__ */ (0,
|
|
16494
|
-
/* @__PURE__ */ (0,
|
|
16495
|
-
/* @__PURE__ */ (0,
|
|
16496
|
-
dots.filter((dot) => dot.dot).map((dot) => /* @__PURE__ */ (0,
|
|
16497
|
-
list.map((_, i) => /* @__PURE__ */ (0,
|
|
16820
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_react_aria_components10.SliderTrack, { ref: track, className: "kjun-slider-track", children: () => /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_jsx_runtime74.Fragment, { children: [
|
|
16821
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "kjun-slider-rail" }),
|
|
16822
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "kjun-slider-fill", "data-origin": dots.some((dot) => dot.origin) || void 0, style: { [lead]: fill.lead === null ? edge : fill.lead + "%", [trail]: fill.trail === null ? edge : fill.trail + "%" } }),
|
|
16823
|
+
dots.filter((dot) => dot.dot).map((dot) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "kjun-slider-mark", "data-active": dot.active || void 0, "data-origin": dot.origin || void 0, style: { [lead]: dot.position * 100 + "%" } }, dot.value)),
|
|
16824
|
+
list.map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
16498
16825
|
RangeThumb,
|
|
16499
16826
|
{
|
|
16500
16827
|
index: i,
|
|
@@ -16509,7 +16836,7 @@ function RangeInput(props) {
|
|
|
16509
16836
|
i
|
|
16510
16837
|
))
|
|
16511
16838
|
] }) }),
|
|
16512
|
-
dots.some((dot) => dot.label) && /* @__PURE__ */ (0,
|
|
16839
|
+
dots.some((dot) => dot.label) && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "kjun-slider-marks", "aria-hidden": "true", children: dots.filter((dot) => dot.label).map((dot) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
16513
16840
|
"span",
|
|
16514
16841
|
{
|
|
16515
16842
|
className: "kjun-slider-mark-label",
|
|
@@ -16525,15 +16852,15 @@ function RangeInput(props) {
|
|
|
16525
16852
|
);
|
|
16526
16853
|
}
|
|
16527
16854
|
function KjunSlider(props) {
|
|
16528
|
-
return /* @__PURE__ */ (0,
|
|
16855
|
+
return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(RangeInput, { ...props });
|
|
16529
16856
|
}
|
|
16530
16857
|
function KjunRangeSlider(props) {
|
|
16531
|
-
return /* @__PURE__ */ (0,
|
|
16858
|
+
return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(RangeInput, { ...props });
|
|
16532
16859
|
}
|
|
16533
16860
|
|
|
16534
16861
|
// packages/react/src/quantity-stepper.tsx
|
|
16535
|
-
var
|
|
16536
|
-
var
|
|
16862
|
+
var import_react92 = require("react");
|
|
16863
|
+
var import_tokens100 = require("@kjun-ui/tokens");
|
|
16537
16864
|
|
|
16538
16865
|
// shared/package-runtime/number-input.ts
|
|
16539
16866
|
var presets = {
|
|
@@ -16557,9 +16884,48 @@ function resolveNumberInput(options) {
|
|
|
16557
16884
|
min: finite2(options.min),
|
|
16558
16885
|
max: finite2(options.max),
|
|
16559
16886
|
suffix: options.suffix === void 0 ? preset.suffix : typeof options.suffix === "string" ? options.suffix : void 0,
|
|
16560
|
-
maxIntegerDigits: totalDigits - decimals2
|
|
16887
|
+
maxIntegerDigits: totalDigits - decimals2,
|
|
16888
|
+
step: resolveStep(finite2(options.step), decimals2)
|
|
16561
16889
|
};
|
|
16562
16890
|
}
|
|
16891
|
+
function resolveStep(step, decimals2) {
|
|
16892
|
+
if (step === void 0 || step <= 0) return void 0;
|
|
16893
|
+
const rounded = Number(step.toFixed(decimals2));
|
|
16894
|
+
return rounded > 0 ? rounded : void 0;
|
|
16895
|
+
}
|
|
16896
|
+
function written(value, o) {
|
|
16897
|
+
const text = value.toFixed(o.decimals);
|
|
16898
|
+
return /^-0(\.0*)?$/.test(text) ? text.slice(1) : text;
|
|
16899
|
+
}
|
|
16900
|
+
var stepBase = (o) => {
|
|
16901
|
+
var _a;
|
|
16902
|
+
return (_a = o.min) != null ? _a : 0;
|
|
16903
|
+
};
|
|
16904
|
+
function snapNumber(raw, o) {
|
|
16905
|
+
const value = Number(raw);
|
|
16906
|
+
if (o.step === void 0 || raw === "" || !Number.isFinite(value)) return raw;
|
|
16907
|
+
const base = stepBase(o);
|
|
16908
|
+
let snapped = base + Math.round((value - base) / o.step) * o.step;
|
|
16909
|
+
if (!o.allowNegative && snapped < 0) snapped += o.step;
|
|
16910
|
+
return written(snapped, o);
|
|
16911
|
+
}
|
|
16912
|
+
function stepNumber(raw, direction, o) {
|
|
16913
|
+
var _a;
|
|
16914
|
+
if (o.step === void 0) return null;
|
|
16915
|
+
const base = stepBase(o), value = Number(raw);
|
|
16916
|
+
const empty3 = /^-?\.?$/.test(raw) || !Number.isFinite(value);
|
|
16917
|
+
let next;
|
|
16918
|
+
if (empty3) next = base;
|
|
16919
|
+
else {
|
|
16920
|
+
const units = (value - base) / o.step, near = Math.round(units);
|
|
16921
|
+
const onGrid = Math.abs(units - near) < 1e-9;
|
|
16922
|
+
next = base + (onGrid ? near + direction : direction > 0 ? Math.ceil(units) : Math.floor(units)) * o.step;
|
|
16923
|
+
}
|
|
16924
|
+
const low = o.allowNegative ? o.min : Math.max((_a = o.min) != null ? _a : 0, 0);
|
|
16925
|
+
if (o.max !== void 0 && next > o.max) next = o.max;
|
|
16926
|
+
if (low !== void 0 && next < low) next = low;
|
|
16927
|
+
return written(next, o);
|
|
16928
|
+
}
|
|
16563
16929
|
var minus2 = /[-\u2212\u2013]/;
|
|
16564
16930
|
function parts(text, o, options) {
|
|
16565
16931
|
const negative = o.allowNegative && minus2.test(text);
|
|
@@ -16705,22 +17071,22 @@ function createPressRepeat(step, delay, interval) {
|
|
|
16705
17071
|
}
|
|
16706
17072
|
|
|
16707
17073
|
// packages/react/src/quantity-stepper.tsx
|
|
16708
|
-
var
|
|
17074
|
+
var import_jsx_runtime75 = require("react/jsx-runtime");
|
|
16709
17075
|
function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, disabled = false, error = false, size = "md", block = false, id, ariaLabel, name, onValueChange, onChangeCommit, onInvalidInput }) {
|
|
16710
17076
|
const m = useKjunMessages();
|
|
16711
|
-
const buttonStyle = { width:
|
|
16712
|
-
const domain = (0,
|
|
17077
|
+
const buttonStyle = { width: import_tokens100.tokens.input[size].height, padding: 0 };
|
|
17078
|
+
const domain = (0, import_tokens100.createNumberDomain)({ min, max, step, precision });
|
|
16713
17079
|
const usable = domain.fits(value), blocked = disabled || !usable, outside = usable && !domain.inRange(value);
|
|
16714
|
-
const [draft, setDraft] = (0,
|
|
17080
|
+
const [draft, setDraft] = (0, import_react92.useState)(String(value));
|
|
16715
17081
|
const field = useKjunField();
|
|
16716
17082
|
const invalid = error || !!(field == null ? void 0 : field.error) || outside;
|
|
16717
|
-
const composing = (0,
|
|
16718
|
-
(0,
|
|
17083
|
+
const composing = (0, import_react92.useRef)(false), dirty = (0, import_react92.useRef)(false), accepted = (0, import_react92.useRef)(value);
|
|
17084
|
+
(0, import_react92.useEffect)(() => {
|
|
16719
17085
|
setDraft(String(value));
|
|
16720
17086
|
accepted.current = value;
|
|
16721
17087
|
dirty.current = false;
|
|
16722
17088
|
}, [value, precision, min, max, step]);
|
|
16723
|
-
(0,
|
|
17089
|
+
(0, import_react92.useEffect)(() => {
|
|
16724
17090
|
if (!usable) console.warn("KJUN QuantityStepper: \uBC94\uC704\xB7step\xB7\uC815\uBC00\uB3C4\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
|
|
16725
17091
|
}, [usable]);
|
|
16726
17092
|
const emit = (next) => {
|
|
@@ -16745,17 +17111,17 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
|
|
|
16745
17111
|
emit(next);
|
|
16746
17112
|
return next !== accepted.current;
|
|
16747
17113
|
};
|
|
16748
|
-
const latest = (0,
|
|
17114
|
+
const latest = (0, import_react92.useRef)(move);
|
|
16749
17115
|
latest.current = move;
|
|
16750
|
-
const [decrease] = (0,
|
|
16751
|
-
const [increase] = (0,
|
|
16752
|
-
(0,
|
|
17116
|
+
const [decrease] = (0, import_react92.useState)(() => createPressRepeat(() => latest.current(-1), import_tokens100.tokens.extensions.compound.repeatDelay, import_tokens100.tokens.extensions.compound.repeatInterval));
|
|
17117
|
+
const [increase] = (0, import_react92.useState)(() => createPressRepeat(() => latest.current(1), import_tokens100.tokens.extensions.compound.repeatDelay, import_tokens100.tokens.extensions.compound.repeatInterval));
|
|
17118
|
+
(0, import_react92.useEffect)(() => () => {
|
|
16753
17119
|
decrease.stop();
|
|
16754
17120
|
increase.stop();
|
|
16755
17121
|
}, []);
|
|
16756
17122
|
const key = (event) => {
|
|
16757
17123
|
if (blocked) return;
|
|
16758
|
-
const action = (0,
|
|
17124
|
+
const action = (0, import_tokens100.quantityKeyAction)(event, composing.current, dirty.current);
|
|
16759
17125
|
if (!action) return;
|
|
16760
17126
|
event.preventDefault();
|
|
16761
17127
|
if (action === "cancel") {
|
|
@@ -16771,8 +17137,8 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
|
|
|
16771
17137
|
repeat.start((_a = event.currentTarget.ownerDocument.defaultView) != null ? _a : void 0);
|
|
16772
17138
|
};
|
|
16773
17139
|
const atMin = value <= min, atMax = max !== void 0 && value >= max;
|
|
16774
|
-
return /* @__PURE__ */ (0,
|
|
16775
|
-
/* @__PURE__ */ (0,
|
|
17140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(IconFallbacks, { icons: componentIcons, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "kjun-quantity", "data-size": size, "data-block": block, "data-error": invalid, children: [
|
|
17141
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
16776
17142
|
KjunButton,
|
|
16777
17143
|
{
|
|
16778
17144
|
size,
|
|
@@ -16788,7 +17154,7 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
|
|
|
16788
17154
|
prefixIcon: "minus"
|
|
16789
17155
|
}
|
|
16790
17156
|
),
|
|
16791
|
-
/* @__PURE__ */ (0,
|
|
17157
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
16792
17158
|
"input",
|
|
16793
17159
|
{
|
|
16794
17160
|
className: "kjun-input",
|
|
@@ -16822,7 +17188,7 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
|
|
|
16822
17188
|
"aria-required": (field == null ? void 0 : field.required) || void 0
|
|
16823
17189
|
}
|
|
16824
17190
|
),
|
|
16825
|
-
/* @__PURE__ */ (0,
|
|
17191
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
16826
17192
|
KjunButton,
|
|
16827
17193
|
{
|
|
16828
17194
|
size,
|
|
@@ -16838,14 +17204,14 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
|
|
|
16838
17204
|
prefixIcon: "plus"
|
|
16839
17205
|
}
|
|
16840
17206
|
),
|
|
16841
|
-
name && /* @__PURE__ */ (0,
|
|
17207
|
+
name && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("input", { type: "hidden", name, value: String(value), disabled })
|
|
16842
17208
|
] }) });
|
|
16843
17209
|
}
|
|
16844
17210
|
|
|
16845
17211
|
// packages/react/src/number-input.tsx
|
|
16846
|
-
var
|
|
16847
|
-
var
|
|
16848
|
-
var
|
|
17212
|
+
var import_react93 = require("react");
|
|
17213
|
+
var import_tokens101 = require("@kjun-ui/tokens");
|
|
17214
|
+
var import_jsx_runtime76 = require("react/jsx-runtime");
|
|
16849
17215
|
function KjunNumberInput({
|
|
16850
17216
|
value,
|
|
16851
17217
|
format: format2,
|
|
@@ -16854,6 +17220,7 @@ function KjunNumberInput({
|
|
|
16854
17220
|
allowNegative,
|
|
16855
17221
|
min,
|
|
16856
17222
|
max,
|
|
17223
|
+
step,
|
|
16857
17224
|
prefix,
|
|
16858
17225
|
suffix,
|
|
16859
17226
|
readingAid: readingAid2 = false,
|
|
@@ -16874,20 +17241,20 @@ function KjunNumberInput({
|
|
|
16874
17241
|
const scope = useKjunMessageScope();
|
|
16875
17242
|
const field = useKjunField();
|
|
16876
17243
|
const suffixText = suffix === void 0 || typeof suffix === "string" ? suffix : null;
|
|
16877
|
-
const o = (0,
|
|
16878
|
-
() => resolveNumberInput({ format: format2, decimals: decimals2, grouping, allowNegative, min, max, suffix: suffixText }),
|
|
16879
|
-
[format2, decimals2, grouping, allowNegative, min, max, suffixText]
|
|
17244
|
+
const o = (0, import_react93.useMemo)(
|
|
17245
|
+
() => resolveNumberInput({ format: format2, decimals: decimals2, grouping, allowNegative, min, max, step, suffix: suffixText }),
|
|
17246
|
+
[format2, decimals2, grouping, allowNegative, min, max, step, suffixText]
|
|
16880
17247
|
);
|
|
16881
17248
|
const shown = (raw2) => formatNumber(sanitizeNumber(raw2, o), o);
|
|
16882
17249
|
const outOfRange = (raw2) => rangeIssue(sanitizeNumber(raw2, o), o);
|
|
16883
|
-
const [view, setView] = (0,
|
|
16884
|
-
const [issue, setIssue] = (0,
|
|
16885
|
-
const input = (0,
|
|
16886
|
-
const composing = (0,
|
|
16887
|
-
const composedFrom = (0,
|
|
16888
|
-
const emitted = (0,
|
|
16889
|
-
const aidId = "kjun-number-reading-" + (0,
|
|
16890
|
-
(0,
|
|
17250
|
+
const [view, setView] = (0, import_react93.useState)(() => ({ text: shown(value), caret: null }));
|
|
17251
|
+
const [issue, setIssue] = (0, import_react93.useState)(null);
|
|
17252
|
+
const input = (0, import_react93.useRef)(null);
|
|
17253
|
+
const composing = (0, import_react93.useRef)(false), dirty = (0, import_react93.useRef)(false);
|
|
17254
|
+
const composedFrom = (0, import_react93.useRef)("");
|
|
17255
|
+
const emitted = (0, import_react93.useRef)(value), accepted = (0, import_react93.useRef)(value), acceptedIssue = (0, import_react93.useRef)(null);
|
|
17256
|
+
const aidId = "kjun-number-reading-" + (0, import_react93.useId)().replace(/:/g, "");
|
|
17257
|
+
(0, import_react93.useEffect)(() => {
|
|
16891
17258
|
if (value === emitted.current || dirty.current && sameNumber(value, emitted.current)) return;
|
|
16892
17259
|
dirty.current = false;
|
|
16893
17260
|
emitted.current = accepted.current = value;
|
|
@@ -16897,8 +17264,8 @@ function KjunNumberInput({
|
|
|
16897
17264
|
const text = shown(value);
|
|
16898
17265
|
setView({ text, caret: text.length });
|
|
16899
17266
|
}, [value]);
|
|
16900
|
-
const options = (0,
|
|
16901
|
-
(0,
|
|
17267
|
+
const options = (0, import_react93.useRef)(o);
|
|
17268
|
+
(0, import_react93.useEffect)(() => {
|
|
16902
17269
|
if (options.current === o) return;
|
|
16903
17270
|
options.current = o;
|
|
16904
17271
|
const found = outOfRange(accepted.current);
|
|
@@ -16908,7 +17275,7 @@ function KjunNumberInput({
|
|
|
16908
17275
|
const text = shown(accepted.current);
|
|
16909
17276
|
setView((old) => old.text === text ? old : { text, caret: null });
|
|
16910
17277
|
}, [o]);
|
|
16911
|
-
(0,
|
|
17278
|
+
(0, import_react93.useLayoutEffect)(() => {
|
|
16912
17279
|
const el = input.current;
|
|
16913
17280
|
if (view.caret === null || !el || el.ownerDocument.activeElement !== el) return;
|
|
16914
17281
|
el.setSelectionRange(view.caret, view.caret);
|
|
@@ -16946,10 +17313,13 @@ function KjunNumberInput({
|
|
|
16946
17313
|
};
|
|
16947
17314
|
const commit = (text = view.text) => {
|
|
16948
17315
|
if (composing.current || !dirty.current || disabled || readOnly) return;
|
|
17316
|
+
accept(snapNumber(commitNumber(sanitizeNumber(text, o), o), o), null);
|
|
17317
|
+
};
|
|
17318
|
+
const accept = (next, caret) => {
|
|
16949
17319
|
dirty.current = false;
|
|
16950
|
-
const next = commitNumber(sanitizeNumber(text, o), o);
|
|
16951
17320
|
const found = rangeIssue(next, o);
|
|
16952
|
-
|
|
17321
|
+
const text = formatNumber(next, o);
|
|
17322
|
+
setView({ text, caret: caret === "end" ? text.length : null });
|
|
16953
17323
|
setIssue(found);
|
|
16954
17324
|
acceptedIssue.current = found;
|
|
16955
17325
|
report(next);
|
|
@@ -16960,7 +17330,7 @@ function KjunNumberInput({
|
|
|
16960
17330
|
};
|
|
16961
17331
|
const key = (event) => {
|
|
16962
17332
|
var _a, _b;
|
|
16963
|
-
if (disabled || readOnly || (0,
|
|
17333
|
+
if (disabled || readOnly || (0, import_tokens101.isComposingKey)(event, composing.current)) return;
|
|
16964
17334
|
if (event.key === "Escape" && dirty.current) {
|
|
16965
17335
|
event.preventDefault();
|
|
16966
17336
|
event.stopPropagation();
|
|
@@ -16970,6 +17340,13 @@ function KjunNumberInput({
|
|
|
16970
17340
|
report(accepted.current);
|
|
16971
17341
|
return;
|
|
16972
17342
|
}
|
|
17343
|
+
if ((event.key === "ArrowUp" || event.key === "ArrowDown") && o.step !== void 0 && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
|
17344
|
+
const next = stepNumber(sanitizeNumber(event.currentTarget.value, o), event.key === "ArrowUp" ? 1 : -1, o);
|
|
17345
|
+
if (next === null) return;
|
|
17346
|
+
event.preventDefault();
|
|
17347
|
+
accept(next, "end");
|
|
17348
|
+
return;
|
|
17349
|
+
}
|
|
16973
17350
|
if (event.key !== "Backspace" && event.key !== "Delete" || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
16974
17351
|
const el = event.currentTarget;
|
|
16975
17352
|
const removed = deleteAcrossSeparator(el.value, (_a = el.selectionStart) != null ? _a : 0, (_b = el.selectionEnd) != null ? _b : 0, event.key);
|
|
@@ -16981,13 +17358,13 @@ function KjunNumberInput({
|
|
|
16981
17358
|
const raw = sanitizeNumber(view.text, o);
|
|
16982
17359
|
const aid = readingAid2 ? readingAid(raw, o, scope) : "";
|
|
16983
17360
|
const message = issue && !error && !(field == null ? void 0 : field.error) ? rangeMessage(issue, o, scope) : "";
|
|
16984
|
-
const owner = "kjun-number-" + (0,
|
|
16985
|
-
(0,
|
|
17361
|
+
const owner = "kjun-number-" + (0, import_react93.useId)(), toGroup = field == null ? void 0 : field.reportError;
|
|
17362
|
+
(0, import_react93.useEffect)(() => {
|
|
16986
17363
|
toGroup == null ? void 0 : toGroup(owner, message);
|
|
16987
17364
|
}, [toGroup, message]);
|
|
16988
|
-
(0,
|
|
16989
|
-
return /* @__PURE__ */ (0,
|
|
16990
|
-
/* @__PURE__ */ (0,
|
|
17365
|
+
(0, import_react93.useEffect)(() => () => toGroup == null ? void 0 : toGroup(owner, ""), [toGroup]);
|
|
17366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "kjun-number-input" + (className ? " " + className : ""), "data-format": o.format, "data-align": align, style, children: [
|
|
17367
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
16991
17368
|
KjunInput,
|
|
16992
17369
|
{
|
|
16993
17370
|
ref: input,
|
|
@@ -17022,8 +17399,8 @@ function KjunNumberInput({
|
|
|
17022
17399
|
}
|
|
17023
17400
|
}
|
|
17024
17401
|
),
|
|
17025
|
-
aid && /* @__PURE__ */ (0,
|
|
17026
|
-
name && /* @__PURE__ */ (0,
|
|
17402
|
+
aid && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { id: aidId, className: "kjun-form-hint kjun-number-input-reading", children: aid }),
|
|
17403
|
+
name && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("input", { type: "hidden", name, value: commitNumber(raw, o), disabled })
|
|
17027
17404
|
] });
|
|
17028
17405
|
}
|
|
17029
17406
|
|
|
@@ -17213,28 +17590,28 @@ var wheelItemAt = (column, row) => {
|
|
|
17213
17590
|
};
|
|
17214
17591
|
|
|
17215
17592
|
// packages/react/src/time-picker.tsx
|
|
17216
|
-
var
|
|
17217
|
-
var
|
|
17593
|
+
var import_react95 = require("react");
|
|
17594
|
+
var import_tokens103 = require("@kjun-ui/tokens");
|
|
17218
17595
|
|
|
17219
17596
|
// packages/react/src/time-wheel.tsx
|
|
17220
|
-
var
|
|
17221
|
-
var
|
|
17222
|
-
var
|
|
17223
|
-
var rowHeight =
|
|
17597
|
+
var import_tokens102 = require("@kjun-ui/tokens");
|
|
17598
|
+
var import_react94 = require("react");
|
|
17599
|
+
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
17600
|
+
var rowHeight = import_tokens102.tokens.extensions.timePicker.wheelRowHeight;
|
|
17224
17601
|
var settleDelay = 120;
|
|
17225
17602
|
var travelLimit = 1e3;
|
|
17226
17603
|
function WheelColumnView({ column, disabled, readOnly, autoFocus, onPick, onEnter, onFocus }) {
|
|
17227
|
-
const scroller = (0,
|
|
17228
|
-
const travel = (0,
|
|
17604
|
+
const scroller = (0, import_react94.useRef)(null), held = (0, import_react94.useRef)(false), timer = (0, import_react94.useRef)(void 0), mounted = (0, import_react94.useRef)(false);
|
|
17605
|
+
const travel = (0, import_react94.useRef)(null);
|
|
17229
17606
|
const go = (element, top, smooth) => {
|
|
17230
17607
|
travel.current = { top, until: Date.now() + travelLimit };
|
|
17231
17608
|
element.scrollTo({ top, behavior: smooth ? "smooth" : "instant" });
|
|
17232
17609
|
};
|
|
17233
17610
|
const reduced = useReducedMotion();
|
|
17234
17611
|
const item = column.items[column.index];
|
|
17235
|
-
const latest = (0,
|
|
17612
|
+
const latest = (0, import_react94.useRef)({ column, onPick });
|
|
17236
17613
|
latest.current = { column, onPick };
|
|
17237
|
-
(0,
|
|
17614
|
+
(0, import_react94.useLayoutEffect)(() => {
|
|
17238
17615
|
const element = scroller.current;
|
|
17239
17616
|
if (!element) return;
|
|
17240
17617
|
const current = mounted.current ? element.scrollTop / rowHeight : null;
|
|
@@ -17242,11 +17619,11 @@ function WheelColumnView({ column, disabled, readOnly, autoFocus, onPick, onEnte
|
|
|
17242
17619
|
if (current === null || Math.abs(current - row) > 0.01) go(element, row * rowHeight, mounted.current && !reduced);
|
|
17243
17620
|
mounted.current = true;
|
|
17244
17621
|
}, [column.index, column.items.length, column.loop, reduced]);
|
|
17245
|
-
(0,
|
|
17622
|
+
(0, import_react94.useEffect)(() => {
|
|
17246
17623
|
var _a;
|
|
17247
17624
|
if (autoFocus) (_a = scroller.current) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
17248
17625
|
}, [autoFocus]);
|
|
17249
|
-
(0,
|
|
17626
|
+
(0, import_react94.useEffect)(() => () => clearTimeout(timer.current), []);
|
|
17250
17627
|
const settle = () => {
|
|
17251
17628
|
const element = scroller.current, { column: column2, onPick: onPick2 } = latest.current;
|
|
17252
17629
|
if (!element || held.current) return;
|
|
@@ -17268,7 +17645,7 @@ function WheelColumnView({ column, disabled, readOnly, autoFocus, onPick, onEnte
|
|
|
17268
17645
|
timer.current = setTimeout(settle, settleDelay);
|
|
17269
17646
|
};
|
|
17270
17647
|
const locked = disabled || readOnly;
|
|
17271
|
-
return /* @__PURE__ */ (0,
|
|
17648
|
+
return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "kjun-time-wheel-column", "data-key": column.key, children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
|
|
17272
17649
|
"div",
|
|
17273
17650
|
{
|
|
17274
17651
|
ref: scroller,
|
|
@@ -17330,7 +17707,7 @@ function WheelColumnView({ column, disabled, readOnly, autoFocus, onPick, onEnte
|
|
|
17330
17707
|
const value = wheelKey(column, event.key);
|
|
17331
17708
|
if (value !== null) onPick(value);
|
|
17332
17709
|
},
|
|
17333
|
-
children: Array.from({ length: wheelCopies(column) }, (_, copy) => column.items.map((entry, index) => /* @__PURE__ */ (0,
|
|
17710
|
+
children: Array.from({ length: wheelCopies(column) }, (_, copy) => column.items.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
|
|
17334
17711
|
"div",
|
|
17335
17712
|
{
|
|
17336
17713
|
className: "kjun-time-wheel-row",
|
|
@@ -17348,7 +17725,7 @@ function WheelColumnView({ column, disabled, readOnly, autoFocus, onPick, onEnte
|
|
|
17348
17725
|
) });
|
|
17349
17726
|
}
|
|
17350
17727
|
function TimeWheel({ columns, label, labelledBy, inline = false, disabled = false, readOnly = false, focusColumn = null, onFocusColumn, onPick, onEnter }) {
|
|
17351
|
-
return /* @__PURE__ */ (0,
|
|
17728
|
+
return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
|
|
17352
17729
|
"div",
|
|
17353
17730
|
{
|
|
17354
17731
|
className: "kjun-time-wheel",
|
|
@@ -17358,10 +17735,10 @@ function TimeWheel({ columns, label, labelledBy, inline = false, disabled = fals
|
|
|
17358
17735
|
"data-inline": inline || void 0,
|
|
17359
17736
|
"data-disabled": disabled || void 0,
|
|
17360
17737
|
children: [
|
|
17361
|
-
/* @__PURE__ */ (0,
|
|
17362
|
-
columns.map((column, index) => /* @__PURE__ */ (0,
|
|
17363
|
-
wheelSeparated(columns, index) && /* @__PURE__ */ (0,
|
|
17364
|
-
/* @__PURE__ */ (0,
|
|
17738
|
+
/* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "kjun-time-wheel-band", "aria-hidden": "true" }),
|
|
17739
|
+
columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_react94.Fragment, { children: [
|
|
17740
|
+
wheelSeparated(columns, index) && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { className: "kjun-time-wheel-separator", "aria-hidden": "true", children: ":" }),
|
|
17741
|
+
/* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
|
|
17365
17742
|
WheelColumnView,
|
|
17366
17743
|
{
|
|
17367
17744
|
column,
|
|
@@ -17383,7 +17760,7 @@ function TimeWheel({ columns, label, labelledBy, inline = false, disabled = fals
|
|
|
17383
17760
|
}
|
|
17384
17761
|
|
|
17385
17762
|
// packages/react/src/time-picker.tsx
|
|
17386
|
-
var
|
|
17763
|
+
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
17387
17764
|
var subscribeCoarse = (notify) => {
|
|
17388
17765
|
if (typeof matchMedia !== "function") return () => {
|
|
17389
17766
|
};
|
|
@@ -17419,15 +17796,15 @@ function KjunTimePicker({
|
|
|
17419
17796
|
}) {
|
|
17420
17797
|
const scope = useKjunMessageScope(), m = scope.messages;
|
|
17421
17798
|
ariaLabel != null ? ariaLabel : ariaLabel = m.time;
|
|
17422
|
-
const root = (0,
|
|
17423
|
-
const field = useKjunField(), uid = (0,
|
|
17799
|
+
const root = (0, import_react95.useRef)(null), opener = (0, import_react95.useRef)(null);
|
|
17800
|
+
const field = useKjunField(), uid = (0, import_react95.useId)();
|
|
17424
17801
|
const fieldId = id || (field == null ? void 0 : field.id) || `kjun-time-${uid}`;
|
|
17425
|
-
const [typing] = (0,
|
|
17426
|
-
const coarse = (0,
|
|
17802
|
+
const [typing] = (0, import_react95.useState)(createSegmentTyping);
|
|
17803
|
+
const coarse = (0, import_react95.useSyncExternalStore)(subscribeCoarse, coarsePointer, () => false);
|
|
17427
17804
|
const layout = resolveTimeLayout(layoutProp, coarse), trigger = resolveTimeTrigger(triggerProp, layout === "inline" ? "popover" : layout);
|
|
17428
|
-
const domain = (0,
|
|
17805
|
+
const domain = (0, import_react95.useMemo)(() => (0, import_tokens103.createTimeDomain)({ precision, min, max, minuteStep, secondStep }), [precision, min, max, minuteStep, secondStep]);
|
|
17429
17806
|
const accepted = domain.accepts(value);
|
|
17430
|
-
(0,
|
|
17807
|
+
(0, import_react95.useEffect)(() => {
|
|
17431
17808
|
if (!domain.valid) warnPicker("TimePicker: check min, max, minuteStep and secondStep.");
|
|
17432
17809
|
else if (!accepted) warnPicker(`TimePicker: ${value} is outside the step or bounds.`);
|
|
17433
17810
|
}, [domain, accepted, value]);
|
|
@@ -17439,7 +17816,7 @@ function KjunTimePicker({
|
|
|
17439
17816
|
}
|
|
17440
17817
|
};
|
|
17441
17818
|
const shape = { precision, hourCycle, minuteStep, secondStep, messages: m, periodFirst: periodLeads(scope.language) };
|
|
17442
|
-
const [open, setOpen] = (0,
|
|
17819
|
+
const [open, setOpen] = (0, import_react95.useState)(false), [draft, setDraft] = (0, import_react95.useState)(() => wheelStart(domain, value)), [focusColumn, setFocusColumn] = (0, import_react95.useState)(null), [active, setActive] = (0, import_react95.useState)(null);
|
|
17443
17820
|
const openAt = (column, from) => {
|
|
17444
17821
|
if (blocked || readOnly) return;
|
|
17445
17822
|
opener.current = from;
|
|
@@ -17459,7 +17836,7 @@ function KjunTimePicker({
|
|
|
17459
17836
|
setDraft(time2);
|
|
17460
17837
|
if (layout === "inline") change(time2);
|
|
17461
17838
|
};
|
|
17462
|
-
const wheel = (inline) => /* @__PURE__ */ (0,
|
|
17839
|
+
const wheel = (inline) => /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
17463
17840
|
TimeWheel,
|
|
17464
17841
|
{
|
|
17465
17842
|
columns,
|
|
@@ -17474,17 +17851,17 @@ function KjunTimePicker({
|
|
|
17474
17851
|
onEnter: inline ? void 0 : confirm
|
|
17475
17852
|
}
|
|
17476
17853
|
);
|
|
17477
|
-
const now = /* @__PURE__ */ (0,
|
|
17478
|
-
const actions = /* @__PURE__ */ (0,
|
|
17479
|
-
/* @__PURE__ */ (0,
|
|
17480
|
-
/* @__PURE__ */ (0,
|
|
17854
|
+
const now = /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(KjunButton, { size: layout === "sheet" ? "md" : "sm", variant: "ghost", onClick: () => setDraft(wheelStart(domain, null)), children: m.now });
|
|
17855
|
+
const actions = /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(import_jsx_runtime78.Fragment, { children: [
|
|
17856
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(KjunButton, { size: layout === "sheet" ? "md" : "sm", variant: "secondary", onClick: () => setOpen(false), children: m.cancel }),
|
|
17857
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(KjunButton, { size: layout === "sheet" ? "md" : "sm", variant: "primary", onClick: confirm, children: m.confirm })
|
|
17481
17858
|
] });
|
|
17482
|
-
const hidden = name && /* @__PURE__ */ (0,
|
|
17483
|
-
if (layout === "inline") return /* @__PURE__ */ (0,
|
|
17859
|
+
const hidden = name && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("input", { type: "hidden", name, value: value != null ? value : "" });
|
|
17860
|
+
if (layout === "inline") return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "kjun-time-picker-inline", "data-block": block || void 0, "data-error": invalid || void 0, id: id != null ? id : field == null ? void 0 : field.id, children: [
|
|
17484
17861
|
wheel(true),
|
|
17485
17862
|
hidden
|
|
17486
17863
|
] });
|
|
17487
|
-
const panel = layout === "sheet" ? /* @__PURE__ */ (0,
|
|
17864
|
+
const panel = layout === "sheet" ? /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
17488
17865
|
KjunDrawer,
|
|
17489
17866
|
{
|
|
17490
17867
|
open: open && !blocked,
|
|
@@ -17496,9 +17873,9 @@ function KjunTimePicker({
|
|
|
17496
17873
|
headerActions: now,
|
|
17497
17874
|
footer: actions,
|
|
17498
17875
|
returnFocus: () => opener.current,
|
|
17499
|
-
children: /* @__PURE__ */ (0,
|
|
17876
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "kjun-time-sheet-body", children: wheel(false) })
|
|
17500
17877
|
}
|
|
17501
|
-
) : /* @__PURE__ */ (0,
|
|
17878
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
|
|
17502
17879
|
FloatingPanel,
|
|
17503
17880
|
{
|
|
17504
17881
|
field: true,
|
|
@@ -17510,22 +17887,22 @@ function KjunTimePicker({
|
|
|
17510
17887
|
labelledBy: field == null ? void 0 : field.labelId,
|
|
17511
17888
|
ariaLabel,
|
|
17512
17889
|
returnFocus: () => opener.current,
|
|
17513
|
-
maxHeight:
|
|
17890
|
+
maxHeight: import_tokens103.tokens.extensions.floating.maxHeight,
|
|
17514
17891
|
children: [
|
|
17515
17892
|
wheel(false),
|
|
17516
|
-
/* @__PURE__ */ (0,
|
|
17893
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "kjun-time-panel-footer", children: [
|
|
17517
17894
|
now,
|
|
17518
|
-
/* @__PURE__ */ (0,
|
|
17895
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "kjun-time-panel-actions", children: actions })
|
|
17519
17896
|
] })
|
|
17520
17897
|
]
|
|
17521
17898
|
}
|
|
17522
17899
|
);
|
|
17523
17900
|
if (trigger === "button") {
|
|
17524
|
-
const spec =
|
|
17901
|
+
const spec = import_tokens103.tokens.input[size], text = timeText(domain, value, shape), valueId = `${fieldId}-value`;
|
|
17525
17902
|
const clear = clearable && value !== null && !blocked && !readOnly;
|
|
17526
|
-
return /* @__PURE__ */ (0,
|
|
17527
|
-
/* @__PURE__ */ (0,
|
|
17528
|
-
/* @__PURE__ */ (0,
|
|
17903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(import_jsx_runtime78.Fragment, { children: [
|
|
17904
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { ref: root, className: "kjun-select-shell kjun-time-button-field", "data-block": block || void 0, children: [
|
|
17905
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
|
|
17529
17906
|
"button",
|
|
17530
17907
|
{
|
|
17531
17908
|
id: fieldId,
|
|
@@ -17540,7 +17917,7 @@ function KjunTimePicker({
|
|
|
17540
17917
|
"aria-invalid": invalid || void 0,
|
|
17541
17918
|
"aria-required": (field == null ? void 0 : field.required) || void 0,
|
|
17542
17919
|
"aria-readonly": readOnly || void 0,
|
|
17543
|
-
style: { height: spec.height, borderRadius: spec.radius, ...inputTypeStyle(size), paddingInline: spec.padding -
|
|
17920
|
+
style: { height: spec.height, borderRadius: spec.radius, ...inputTypeStyle(size), paddingInline: spec.padding - import_tokens103.tokens.border.controlWidth },
|
|
17544
17921
|
onClick: (event) => openAt(0, event.currentTarget),
|
|
17545
17922
|
onKeyDown: (event) => {
|
|
17546
17923
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
@@ -17549,12 +17926,12 @@ function KjunTimePicker({
|
|
|
17549
17926
|
}
|
|
17550
17927
|
},
|
|
17551
17928
|
children: [
|
|
17552
|
-
/* @__PURE__ */ (0,
|
|
17553
|
-
/* @__PURE__ */ (0,
|
|
17929
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { id: valueId, className: text ? void 0 : "kjun-placeholder", style: { paddingRight: clear ? spec.clearSize + spec.affixGap : void 0 }, children: text || m.selectTime }),
|
|
17930
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(KjunIcon, { name: "clock", size: spec.iconSize, style: { flexShrink: 0, color: blocked ? "var(--_kjun-color-text-disabled)" : "var(--_kjun-color-text-tertiary)" } })
|
|
17554
17931
|
]
|
|
17555
17932
|
}
|
|
17556
17933
|
),
|
|
17557
|
-
clear && /* @__PURE__ */ (0,
|
|
17934
|
+
clear && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
17558
17935
|
KjunButton,
|
|
17559
17936
|
{
|
|
17560
17937
|
size: "sm",
|
|
@@ -17568,7 +17945,7 @@ function KjunTimePicker({
|
|
|
17568
17945
|
change(null);
|
|
17569
17946
|
(_b = (_a = root.current) == null ? void 0 : _a.querySelector(".kjun-time-trigger")) == null ? void 0 : _b.focus();
|
|
17570
17947
|
},
|
|
17571
|
-
children: /* @__PURE__ */ (0,
|
|
17948
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "kjun-select-clear-mark", style: selectClearMarkStyle(spec), children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(KjunIcon, { name: "x", size: spec.clearMarkIconSize }) })
|
|
17572
17949
|
}
|
|
17573
17950
|
),
|
|
17574
17951
|
hidden
|
|
@@ -17581,8 +17958,8 @@ function KjunTimePicker({
|
|
|
17581
17958
|
var _a, _b;
|
|
17582
17959
|
return Array.from((_b = (_a = root.current) == null ? void 0 : _a.querySelectorAll(".kjun-time-segment-value")) != null ? _b : []);
|
|
17583
17960
|
};
|
|
17584
|
-
return /* @__PURE__ */ (0,
|
|
17585
|
-
/* @__PURE__ */ (0,
|
|
17961
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(import_jsx_runtime78.Fragment, { children: [
|
|
17962
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
|
|
17586
17963
|
"div",
|
|
17587
17964
|
{
|
|
17588
17965
|
ref: root,
|
|
@@ -17598,15 +17975,15 @@ function KjunTimePicker({
|
|
|
17598
17975
|
"aria-labelledby": field == null ? void 0 : field.labelId,
|
|
17599
17976
|
"aria-describedby": field == null ? void 0 : field.describedBy,
|
|
17600
17977
|
children: [
|
|
17601
|
-
/* @__PURE__ */ (0,
|
|
17978
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "kjun-time-segments", children: segments.map((segment, index) => {
|
|
17602
17979
|
var _a;
|
|
17603
17980
|
const labelId = `${fieldId}-segment-${index}`, text = segmentText(segment);
|
|
17604
17981
|
const separated = index > 0 && segment.key !== "period" && segments[index - 1].key !== "period";
|
|
17605
|
-
return /* @__PURE__ */ (0,
|
|
17606
|
-
separated && /* @__PURE__ */ (0,
|
|
17607
|
-
/* @__PURE__ */ (0,
|
|
17608
|
-
/* @__PURE__ */ (0,
|
|
17609
|
-
/* @__PURE__ */ (0,
|
|
17982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(import_react95.Fragment, { children: [
|
|
17983
|
+
separated && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "kjun-time-separator", "aria-hidden": true, children: ":" }),
|
|
17984
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "kjun-time-segment", "data-period": segment.key === "period" || void 0, children: [
|
|
17985
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { id: labelId, className: "kjun-sr-only", "aria-hidden": true, children: segment.label }),
|
|
17986
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
17610
17987
|
"input",
|
|
17611
17988
|
{
|
|
17612
17989
|
id: index === 0 ? fieldId : `${fieldId}-${index}`,
|
|
@@ -17660,14 +18037,14 @@ function KjunTimePicker({
|
|
|
17660
18037
|
] })
|
|
17661
18038
|
] }, segment.key);
|
|
17662
18039
|
}) }),
|
|
17663
|
-
clearable && value !== null && !blocked && !readOnly ? /* @__PURE__ */ (0,
|
|
18040
|
+
clearable && value !== null && !blocked && !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(KjunButton, { className: "kjun-time-clear", size, variant: "ghost", prefixIcon: "x", ariaLabel: m.clearValue(ariaLabel), onClick: () => {
|
|
17664
18041
|
var _a;
|
|
17665
18042
|
change(null);
|
|
17666
18043
|
(_a = inputs()[0]) == null ? void 0 : _a.focus();
|
|
17667
|
-
} }) : /* @__PURE__ */ (0,
|
|
18044
|
+
} }) : /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "kjun-time-icon", "aria-hidden": "true", onClick: () => {
|
|
17668
18045
|
var _a;
|
|
17669
18046
|
return openAt(0, (_a = inputs()[0]) != null ? _a : null);
|
|
17670
|
-
}, children: /* @__PURE__ */ (0,
|
|
18047
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(KjunIcon, { name: "clock", size: import_tokens103.tokens.input[size].iconSize }) }),
|
|
17671
18048
|
hidden
|
|
17672
18049
|
]
|
|
17673
18050
|
}
|