@kjun-ui/react 0.19.0 → 0.20.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 +423 -90
- package/dist/index.js +405 -72
- package/dist/styles.css +127 -61
- package/dist/types/packages/react/src/list.d.cts +1 -1
- package/dist/types/packages/react/src/list.d.ts +1 -1
- package/dist/types/packages/react/src/range-input.d.cts +12 -1
- package/dist/types/packages/react/src/range-input.d.ts +12 -1
- package/dist/types/packages/react/src/table-cards.d.cts +1 -1
- package/dist/types/packages/react/src/table-cards.d.ts +1 -1
- package/dist/types/shared/package-runtime/slider-view.d.cts +90 -0
- package/dist/types/shared/package-runtime/slider-view.d.ts +90 -0
- package/dist/types/shared/package-runtime/table-groups.d.cts +9 -0
- package/dist/types/shared/package-runtime/table-groups.d.ts +9 -0
- package/dist/types/shared/package-runtime/table-presentation.d.cts +2 -0
- package/dist/types/shared/package-runtime/table-presentation.d.ts +2 -0
- package/dist/types/shared/package-runtime/table.d.cts +3 -0
- package/dist/types/shared/package-runtime/table.d.ts +3 -0
- package/dist/types/shared/package-runtime/use-table-group-expansion.d.cts +6 -0
- package/dist/types/shared/package-runtime/use-table-group-expansion.d.ts +6 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -7842,16 +7842,16 @@ function useNumberMotion(value, animated, fromPrevious, reduced) {
|
|
|
7842
7842
|
// packages/react/src/number-display.tsx
|
|
7843
7843
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
7844
7844
|
var finiteNumber = (value) => value == null || typeof value === "boolean" || typeof value === "string" && !value.trim() || !["number", "string"].includes(typeof value) || !Number.isFinite(Number(value)) ? null : Number(value) || 0;
|
|
7845
|
-
var format = (value,
|
|
7846
|
-
minimumFractionDigits: Math.max(0, Math.min(20,
|
|
7847
|
-
maximumFractionDigits: Math.max(0, Math.min(20,
|
|
7845
|
+
var format = (value, decimals2 = 0) => new Intl.NumberFormat(void 0, {
|
|
7846
|
+
minimumFractionDigits: Math.max(0, Math.min(20, decimals2)),
|
|
7847
|
+
maximumFractionDigits: Math.max(0, Math.min(20, decimals2))
|
|
7848
7848
|
}).format(value);
|
|
7849
7849
|
function useCountUp(value, animated, fromPrevious) {
|
|
7850
7850
|
return useNumberMotion(value, animated, fromPrevious, useReducedMotion());
|
|
7851
7851
|
}
|
|
7852
7852
|
function KjunAnimatedNumber({
|
|
7853
7853
|
value,
|
|
7854
|
-
decimals = 0,
|
|
7854
|
+
decimals: decimals2 = 0,
|
|
7855
7855
|
prefix = "",
|
|
7856
7856
|
suffix = "",
|
|
7857
7857
|
animated = true,
|
|
@@ -7862,7 +7862,7 @@ function KjunAnimatedNumber({
|
|
|
7862
7862
|
const n = useCountUp(value, animated, fromPrevious);
|
|
7863
7863
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("span", { className: "kjun-animated-number " + className, children: [
|
|
7864
7864
|
prefix && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "kjun-number-affix", "data-side": "prefix", children: prefix }),
|
|
7865
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { children: typeof n === "string" ? n : formatter ? formatter(n) : format(n,
|
|
7865
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { children: typeof n === "string" ? n : formatter ? formatter(n) : format(n, decimals2) }),
|
|
7866
7866
|
suffix && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "kjun-number-affix", "data-side": "suffix", children: suffix })
|
|
7867
7867
|
] });
|
|
7868
7868
|
}
|
|
@@ -7905,7 +7905,7 @@ function KjunSignedValue({
|
|
|
7905
7905
|
value,
|
|
7906
7906
|
format: kind = "number",
|
|
7907
7907
|
isRaw = false,
|
|
7908
|
-
decimals = 2,
|
|
7908
|
+
decimals: decimals2 = 2,
|
|
7909
7909
|
prefix = "",
|
|
7910
7910
|
suffix = "",
|
|
7911
7911
|
showSign = true,
|
|
@@ -7915,7 +7915,7 @@ function KjunSignedValue({
|
|
|
7915
7915
|
formatter
|
|
7916
7916
|
}) {
|
|
7917
7917
|
const n = finiteNumber(value), role2 = loading || n === null ? "text-secondary" : stale ? "text-tertiary" : n > 0 ? "price-up" : n < 0 ? "price-down" : "price-neutral";
|
|
7918
|
-
const display = n === null ? "\u2014" : formatter ? formatter(n) : prefix + (showSign && n > 0 ? "+" : "") + format(kind === "percent" && !isRaw ? n * 100 : n,
|
|
7918
|
+
const display = n === null ? "\u2014" : formatter ? formatter(n) : prefix + (showSign && n > 0 ? "+" : "") + format(kind === "percent" && !isRaw ? n * 100 : n, decimals2) + (kind === "percent" ? "%" : "") + suffix;
|
|
7919
7919
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7920
7920
|
"span",
|
|
7921
7921
|
{
|
|
@@ -7939,14 +7939,14 @@ function KjunDeviation({
|
|
|
7939
7939
|
value,
|
|
7940
7940
|
variant = "pill",
|
|
7941
7941
|
signalThreshold = 1,
|
|
7942
|
-
decimals = 2,
|
|
7942
|
+
decimals: decimals2 = 2,
|
|
7943
7943
|
formatter
|
|
7944
7944
|
}) {
|
|
7945
7945
|
const m = useKjunMessages();
|
|
7946
7946
|
const n = finiteNumber(value);
|
|
7947
7947
|
if (n === null)
|
|
7948
7948
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { style: { color: "var(--_kjun-color-text-disabled)" }, children: "-" });
|
|
7949
|
-
const abs = Math.abs(n), signal = abs >= signalThreshold, level = (0, import_tokens47.deviationLevel)(n), neutral = level === "neutral", role2 = neutral ? "text-secondary" : n > 0 ? "price-up" : "price-down", label = formatter ? formatter(n) : (n > 0 ? "+" : "") + format(n,
|
|
7949
|
+
const abs = Math.abs(n), signal = abs >= signalThreshold, level = (0, import_tokens47.deviationLevel)(n), neutral = level === "neutral", role2 = neutral ? "text-secondary" : n > 0 ? "price-up" : "price-down", label = formatter ? formatter(n) : (n > 0 ? "+" : "") + format(n, decimals2) + "%";
|
|
7950
7950
|
if (variant === "badge")
|
|
7951
7951
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("span", { className: "kjun-deviation-badge", children: [
|
|
7952
7952
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
@@ -8316,17 +8316,36 @@ function useTableModel2(props) {
|
|
|
8316
8316
|
}
|
|
8317
8317
|
|
|
8318
8318
|
// shared/package-runtime/table-groups.ts
|
|
8319
|
+
var tableGroupKey = (value) => value == null ? "null:" : typeof value + ":" + String(value);
|
|
8319
8320
|
function groupTableRows(rows, groupBy) {
|
|
8320
8321
|
if (!groupBy) return null;
|
|
8321
8322
|
const groups = /* @__PURE__ */ new Map();
|
|
8322
8323
|
for (const row of rows) {
|
|
8323
|
-
const value = getValue(row, groupBy), key =
|
|
8324
|
+
const value = getValue(row, groupBy), key = tableGroupKey(value);
|
|
8324
8325
|
let group = groups.get(key);
|
|
8325
8326
|
if (!group) groups.set(key, group = { key, value, rows: [] });
|
|
8326
8327
|
group.rows.push(row);
|
|
8327
8328
|
}
|
|
8328
8329
|
return [...groups.values()];
|
|
8329
8330
|
}
|
|
8331
|
+
function tableGroupExpansion(groups, expanded, internalCollapsed) {
|
|
8332
|
+
const keys = expanded === void 0 ? null : new Set(expanded.map(tableGroupKey));
|
|
8333
|
+
const collapsed = keys ? (groups != null ? groups : []).filter((group) => !keys.has(group.key)).map((group) => group.key) : internalCollapsed;
|
|
8334
|
+
return {
|
|
8335
|
+
collapsed,
|
|
8336
|
+
toggle(key) {
|
|
8337
|
+
const group = groups == null ? void 0 : groups.find((group2) => group2.key === key);
|
|
8338
|
+
if (!group) return null;
|
|
8339
|
+
const values = expanded != null ? expanded : groups.filter((group2) => !collapsed.includes(group2.key)).map((group2) => group2.value);
|
|
8340
|
+
const next = values.filter((value) => tableGroupKey(value) !== key);
|
|
8341
|
+
const opening = collapsed.includes(key);
|
|
8342
|
+
return {
|
|
8343
|
+
expanded: opening ? [...next, group.value] : next,
|
|
8344
|
+
collapsed: opening ? collapsed.filter((value) => value !== key) : [...collapsed, key]
|
|
8345
|
+
};
|
|
8346
|
+
}
|
|
8347
|
+
};
|
|
8348
|
+
}
|
|
8330
8349
|
function summarizeColumn(rows, key, kind) {
|
|
8331
8350
|
if (kind === "count") return rows.length;
|
|
8332
8351
|
const values = rows.map((row) => getValue(row, key)).filter((value) => typeof value === "number" && Number.isFinite(value));
|
|
@@ -8448,6 +8467,25 @@ function tableGroupName(label, group) {
|
|
|
8448
8467
|
return typeof label === "string" || typeof label === "number" ? String(label) : group.value == null || group.value === "" ? "-" : String(group.value);
|
|
8449
8468
|
}
|
|
8450
8469
|
|
|
8470
|
+
// shared/package-runtime/use-table-group-expansion.ts
|
|
8471
|
+
var import_react54 = require("react");
|
|
8472
|
+
function useTableGroupExpansion(groups, groupBy, expanded, onChange) {
|
|
8473
|
+
const [internal, setInternal] = (0, import_react54.useState)({ field: groupBy, collapsed: [] });
|
|
8474
|
+
(0, import_react54.useEffect)(() => {
|
|
8475
|
+
setInternal({ field: groupBy, collapsed: [] });
|
|
8476
|
+
}, [groupBy]);
|
|
8477
|
+
const state = tableGroupExpansion(groups, expanded, internal.field === groupBy ? internal.collapsed : []);
|
|
8478
|
+
return {
|
|
8479
|
+
collapsed: state.collapsed,
|
|
8480
|
+
toggleGroup(key) {
|
|
8481
|
+
const next = state.toggle(key);
|
|
8482
|
+
if (!next) return;
|
|
8483
|
+
if (expanded === void 0) setInternal({ field: groupBy, collapsed: next.collapsed });
|
|
8484
|
+
onChange == null ? void 0 : onChange(next.expanded);
|
|
8485
|
+
}
|
|
8486
|
+
};
|
|
8487
|
+
}
|
|
8488
|
+
|
|
8451
8489
|
// packages/react/src/table-toolbar.tsx
|
|
8452
8490
|
var import_tokens49 = require("@kjun-ui/tokens");
|
|
8453
8491
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
@@ -8504,13 +8542,13 @@ function TableToolbar({
|
|
|
8504
8542
|
|
|
8505
8543
|
// packages/react/src/table-grid.tsx
|
|
8506
8544
|
var import_tokens51 = require("@kjun-ui/tokens");
|
|
8507
|
-
var
|
|
8545
|
+
var import_react56 = require("react");
|
|
8508
8546
|
|
|
8509
8547
|
// packages/react/src/table-check.tsx
|
|
8510
|
-
var
|
|
8548
|
+
var import_react55 = require("react");
|
|
8511
8549
|
var import_tokens50 = require("@kjun-ui/tokens");
|
|
8512
8550
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
8513
|
-
var TableCheck = (0,
|
|
8551
|
+
var TableCheck = (0, import_react55.forwardRef)(
|
|
8514
8552
|
function TableCheck2(props, ref) {
|
|
8515
8553
|
const size = import_tokens50.tokens.extensions.checkbox.iconSizes.sm;
|
|
8516
8554
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(IconFallbacks, { icons: componentIcons, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("span", { className: "kjun-table-check", children: [
|
|
@@ -8526,7 +8564,7 @@ var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
|
8526
8564
|
function TableGrid({ 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, stickyOffset = 0 }) {
|
|
8527
8565
|
const m = useKjunMessages();
|
|
8528
8566
|
const span = visible.length + Number(selectable) + Number(expandable);
|
|
8529
|
-
const bodyRow = (row, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
8567
|
+
const bodyRow = (row, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_react56.Fragment, { children: [
|
|
8530
8568
|
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
8531
8569
|
"tr",
|
|
8532
8570
|
{
|
|
@@ -8597,9 +8635,9 @@ function TableGrid({ initialLoading, skeletonRows, skeletonHidden, state, onRowC
|
|
|
8597
8635
|
group.rows.length > 1 && summaryRow(group.rows, "subtotal", "subtotal")
|
|
8598
8636
|
] }, "group:" + group.key);
|
|
8599
8637
|
});
|
|
8600
|
-
const [stuck, setStuck] = (0,
|
|
8638
|
+
const [stuck, setStuck] = (0, import_react56.useState)(false), table = (0, import_react56.useRef)(null);
|
|
8601
8639
|
const pageSticky = stickyHeader && maxHeight == null;
|
|
8602
|
-
(0,
|
|
8640
|
+
(0, import_react56.useEffect)(() => {
|
|
8603
8641
|
if (!pageSticky) return;
|
|
8604
8642
|
const update = () => setStuck(stickyHeaderStuck(table.current, stickyOffset));
|
|
8605
8643
|
update();
|
|
@@ -8717,8 +8755,9 @@ function TableTotals({ totals }) {
|
|
|
8717
8755
|
|
|
8718
8756
|
// packages/react/src/table-cards.tsx
|
|
8719
8757
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
8720
|
-
function TableGroupHeader({ label, count, totals }) {
|
|
8758
|
+
function TableGroupHeader({ label, count, totals, toggle }) {
|
|
8721
8759
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "kjun-table-card-group", children: [
|
|
8760
|
+
toggle,
|
|
8722
8761
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { children: label }),
|
|
8723
8762
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "kjun-table-card-group-count", children: count }),
|
|
8724
8763
|
totals.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "kjun-table-card-group-total", children: totals.map((total) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { children: totals.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
@@ -8728,14 +8767,33 @@ function TableGroupHeader({ label, count, totals }) {
|
|
|
8728
8767
|
] }) : total.value }, total.key)) })
|
|
8729
8768
|
] });
|
|
8730
8769
|
}
|
|
8731
|
-
function useTableGroups({ groupLabel, groupTotals, state }, className, itemsClass, item) {
|
|
8770
|
+
function useTableGroups({ groupLabel, groupTotals, state, collapsed, toggleGroup }, className, itemsClass, item) {
|
|
8732
8771
|
const m = useKjunMessages();
|
|
8733
8772
|
return (list) => list.map((group) => {
|
|
8734
|
-
var _a;
|
|
8773
|
+
var _a, _b;
|
|
8735
8774
|
const label = groupLabel == null ? void 0 : groupLabel(group);
|
|
8775
|
+
const open = !(collapsed == null ? void 0 : collapsed.includes(group.key));
|
|
8736
8776
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { role: "group", "aria-label": tableGroupName(label, group), className, children: [
|
|
8737
|
-
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
8738
|
-
|
|
8777
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
8778
|
+
TableGroupHeader,
|
|
8779
|
+
{
|
|
8780
|
+
label,
|
|
8781
|
+
count: m.groupCount(group.rows.length),
|
|
8782
|
+
totals: group.rows.length > 1 ? (_a = groupTotals == null ? void 0 : groupTotals(group.rows)) != null ? _a : [] : [],
|
|
8783
|
+
toggle: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
8784
|
+
KjunButton,
|
|
8785
|
+
{
|
|
8786
|
+
variant: "ghost",
|
|
8787
|
+
size: "xs",
|
|
8788
|
+
prefixIcon: open ? "chevron-down" : "chevron-right",
|
|
8789
|
+
"aria-expanded": open,
|
|
8790
|
+
ariaLabel: m.toggleGroup(String((_b = group.value) != null ? _b : ""), open),
|
|
8791
|
+
onClick: () => toggleGroup == null ? void 0 : toggleGroup(group.key)
|
|
8792
|
+
}
|
|
8793
|
+
)
|
|
8794
|
+
}
|
|
8795
|
+
),
|
|
8796
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: itemsClass, role: "list", children: group.rows.map((row) => item(row, state.rowIndex(row))) })
|
|
8739
8797
|
] }, group.key);
|
|
8740
8798
|
});
|
|
8741
8799
|
}
|
|
@@ -8952,7 +9010,7 @@ function TableList(props) {
|
|
|
8952
9010
|
}
|
|
8953
9011
|
|
|
8954
9012
|
// packages/react/src/table-view.tsx
|
|
8955
|
-
var
|
|
9013
|
+
var import_react57 = require("react");
|
|
8956
9014
|
var import_tokens54 = require("@kjun-ui/tokens");
|
|
8957
9015
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
8958
9016
|
function KjunTable(props) {
|
|
@@ -8983,8 +9041,10 @@ function KjunTable(props) {
|
|
|
8983
9041
|
onRowClick,
|
|
8984
9042
|
onRetry
|
|
8985
9043
|
} = props;
|
|
8986
|
-
const state = useTableModel2(props), query2 = useQueryDisplay(props), revealed = useLoadingReveal(query2.initialLoading, skeleton ? loadingDelay : 0), [mobile, setMobile] = (0,
|
|
8987
|
-
(
|
|
9044
|
+
const state = useTableModel2(props), query2 = useQueryDisplay(props), revealed = useLoadingReveal(query2.initialLoading, skeleton ? loadingDelay : 0), [mobile, setMobile] = (0, import_react57.useState)(false);
|
|
9045
|
+
const groups = groupTableRows(state.rows, props.groupBy);
|
|
9046
|
+
const expansion = useTableGroupExpansion(groups, props.groupBy, props.expandedGroups, props.onExpandedGroupsChange);
|
|
9047
|
+
(0, import_react57.useEffect)(() => {
|
|
8988
9048
|
const media = matchMedia(`(width < ${import_tokens54.tokens.table.mobileBreakpoint}px)`);
|
|
8989
9049
|
const update = () => setMobile(media.matches);
|
|
8990
9050
|
update();
|
|
@@ -8993,9 +9053,8 @@ function KjunTable(props) {
|
|
|
8993
9053
|
}, []);
|
|
8994
9054
|
const layout = tablePresentation(props, mobile);
|
|
8995
9055
|
const grouping = {
|
|
8996
|
-
groups
|
|
8997
|
-
|
|
8998
|
-
toggleGroup: (key) => setCollapsed((keys) => keys.includes(key) ? keys.filter((k) => k !== key) : [...keys, key]),
|
|
9056
|
+
groups,
|
|
9057
|
+
...expansion,
|
|
8999
9058
|
groupLabel: (group) => props.renderGroupLabel ? props.renderGroupLabel(group.value, group.rows) : group.value == null || group.value === "" ? "-" : String(group.value),
|
|
9000
9059
|
summary: props.summary ? (col, rows) => tableSummaryValue(props, col, rows, locale) : null
|
|
9001
9060
|
};
|
|
@@ -9080,7 +9139,7 @@ function KjunTable(props) {
|
|
|
9080
9139
|
loadingText,
|
|
9081
9140
|
loadingDelay: skeleton ? 0 : loadingDelay,
|
|
9082
9141
|
children: [
|
|
9083
|
-
card ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(TableCards, { ...{ initialLoading: query2.initialLoading, skeletonRows, skeletonHidden: query2.initialLoading && !revealed, state, onRowClick, selectable, checkbox, cell, expandable, expand, renderExpand, emptyContent, emptyText, layout, ariaLabel, customClass, rowKeyDown }, groups: grouping.groups, groupLabel: grouping.groupLabel, groupTotals: (rows) => tableTotals(props, rows, locale), totals: tableTotals(props, state.rows, locale) }) : layout.list ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(TableList, { ...{ initialLoading: query2.initialLoading, skeletonRows, skeletonHidden: query2.initialLoading && !revealed, state, onRowClick, selectable, checkbox, cell, expandable, expand, renderExpand, emptyContent, emptyText, layout, ariaLabel, customClass, rowKeyDown }, groups: grouping.groups, groupLabel: grouping.groupLabel, groupTotals: (rows) => tableTotals(props, rows, locale), totals: tableTotals(props, state.rows, locale) }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(TableGrid, { ...{ initialLoading: query2.initialLoading, skeletonRows, skeletonHidden: query2.initialLoading && !revealed, state, onRowClick, selectable, checkbox, cell, expandable, expand, renderExpand, emptyContent, emptyText, visible, maxHeight, stickyHeader, compact, striped, hoverable, ariaLabel, customClass, rowKeyDown, ...grouping }, stickyOffset: props.stickyOffset, sortable: props.sortable }),
|
|
9142
|
+
card ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(TableCards, { ...{ initialLoading: query2.initialLoading, skeletonRows, skeletonHidden: query2.initialLoading && !revealed, state, onRowClick, selectable, checkbox, cell, expandable, expand, renderExpand, emptyContent, emptyText, layout, ariaLabel, customClass, rowKeyDown }, groups: grouping.groups, collapsed: grouping.collapsed, toggleGroup: grouping.toggleGroup, groupLabel: grouping.groupLabel, groupTotals: (rows) => tableTotals(props, rows, locale), totals: tableTotals(props, state.rows, locale) }) : layout.list ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(TableList, { ...{ initialLoading: query2.initialLoading, skeletonRows, skeletonHidden: query2.initialLoading && !revealed, state, onRowClick, selectable, checkbox, cell, expandable, expand, renderExpand, emptyContent, emptyText, layout, ariaLabel, customClass, rowKeyDown }, groups: grouping.groups, collapsed: grouping.collapsed, toggleGroup: grouping.toggleGroup, groupLabel: grouping.groupLabel, groupTotals: (rows) => tableTotals(props, rows, locale), totals: tableTotals(props, state.rows, locale) }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(TableGrid, { ...{ initialLoading: query2.initialLoading, skeletonRows, skeletonHidden: query2.initialLoading && !revealed, state, onRowClick, selectable, checkbox, cell, expandable, expand, renderExpand, emptyContent, emptyText, visible, maxHeight, stickyHeader, compact, striped, hoverable, ariaLabel, customClass, rowKeyDown, ...grouping }, stickyOffset: props.stickyOffset, sortable: props.sortable }),
|
|
9084
9143
|
pagination && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
9085
9144
|
KjunPagination,
|
|
9086
9145
|
{
|
|
@@ -9120,7 +9179,7 @@ function KjunKpiHero(props) {
|
|
|
9120
9179
|
value,
|
|
9121
9180
|
prefix = "",
|
|
9122
9181
|
suffix = "",
|
|
9123
|
-
decimals = 0,
|
|
9182
|
+
decimals: decimals2 = 0,
|
|
9124
9183
|
deltaAbsolute = null,
|
|
9125
9184
|
deltaPercent = null,
|
|
9126
9185
|
deltaDescription = "",
|
|
@@ -9140,8 +9199,8 @@ function KjunKpiHero(props) {
|
|
|
9140
9199
|
v > 0 ? "+" : v < 0 ? "\u2212" : "",
|
|
9141
9200
|
kind === "absolute" && prefix && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-number-affix", "data-side": "prefix", children: prefix }),
|
|
9142
9201
|
new Intl.NumberFormat(void 0, {
|
|
9143
|
-
minimumFractionDigits: kind === "absolute" ?
|
|
9144
|
-
maximumFractionDigits: kind === "absolute" ?
|
|
9202
|
+
minimumFractionDigits: kind === "absolute" ? decimals2 : 1,
|
|
9203
|
+
maximumFractionDigits: kind === "absolute" ? decimals2 : 1
|
|
9145
9204
|
}).format(Math.abs(v)),
|
|
9146
9205
|
kind === "percent" && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "kjun-number-affix", "data-side": "suffix", children: "%" })
|
|
9147
9206
|
] });
|
|
@@ -9162,7 +9221,7 @@ function KjunKpiHero(props) {
|
|
|
9162
9221
|
KjunAnimatedNumber,
|
|
9163
9222
|
{
|
|
9164
9223
|
value,
|
|
9165
|
-
decimals,
|
|
9224
|
+
decimals: decimals2,
|
|
9166
9225
|
animated,
|
|
9167
9226
|
formatter
|
|
9168
9227
|
}
|
|
@@ -9365,7 +9424,7 @@ function KjunKpiRow({
|
|
|
9365
9424
|
var import_tokens56 = require("@kjun-ui/tokens");
|
|
9366
9425
|
|
|
9367
9426
|
// shared/package-runtime/market-cards.ts
|
|
9368
|
-
var
|
|
9427
|
+
var import_react58 = require("react");
|
|
9369
9428
|
function useMarketCardsModel(props, persistence) {
|
|
9370
9429
|
const {
|
|
9371
9430
|
columns,
|
|
@@ -9381,8 +9440,8 @@ function useMarketCardsModel(props, persistence) {
|
|
|
9381
9440
|
sortKey: c.sortable ? metricConfig[c.key].sortKey : null,
|
|
9382
9441
|
isDefaultSort: c.defaultSort
|
|
9383
9442
|
}));
|
|
9384
|
-
const [key, setKey] = (0,
|
|
9385
|
-
const mounted = (0,
|
|
9443
|
+
const [key, setKey] = (0, import_react58.useState)(""), restoreSignature = JSON.stringify([storageNamespace, pills]);
|
|
9444
|
+
const mounted = (0, import_react58.useRef)("");
|
|
9386
9445
|
const save = (key2) => {
|
|
9387
9446
|
var _a;
|
|
9388
9447
|
try {
|
|
@@ -9390,7 +9449,7 @@ function useMarketCardsModel(props, persistence) {
|
|
|
9390
9449
|
} catch (e) {
|
|
9391
9450
|
}
|
|
9392
9451
|
};
|
|
9393
|
-
(0,
|
|
9452
|
+
(0, import_react58.useEffect)(() => {
|
|
9394
9453
|
var _a, _b;
|
|
9395
9454
|
if (mounted.current === restoreSignature) return;
|
|
9396
9455
|
mounted.current = restoreSignature;
|
|
@@ -9715,7 +9774,7 @@ function watchTrailingOverflow(element, onChange) {
|
|
|
9715
9774
|
}
|
|
9716
9775
|
|
|
9717
9776
|
// packages/react/src/market-table.tsx
|
|
9718
|
-
var
|
|
9777
|
+
var import_react59 = require("react");
|
|
9719
9778
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
9720
9779
|
function KjunMarketTable(props) {
|
|
9721
9780
|
const m = useKjunMessages();
|
|
@@ -9737,8 +9796,8 @@ function KjunMarketTable(props) {
|
|
|
9737
9796
|
formatMetric,
|
|
9738
9797
|
renderCell
|
|
9739
9798
|
} = props;
|
|
9740
|
-
const scroller = (0,
|
|
9741
|
-
(0,
|
|
9799
|
+
const scroller = (0, import_react59.useRef)(null), [fadeEnd, setFadeEnd] = (0, import_react59.useState)(false);
|
|
9800
|
+
(0, import_react59.useEffect)(() => scroller.current ? watchTrailingOverflow(scroller.current, setFadeEnd) : void 0, [rows, columns]);
|
|
9742
9801
|
const render = (row, col) => {
|
|
9743
9802
|
const value = getValue(row, col.key), stale = !!getValue(row, "stale");
|
|
9744
9803
|
if (cellLoading(row, col))
|
|
@@ -9919,7 +9978,7 @@ function KjunMarketTable(props) {
|
|
|
9919
9978
|
|
|
9920
9979
|
// packages/react/src/list.tsx
|
|
9921
9980
|
var import_tokens60 = require("@kjun-ui/tokens");
|
|
9922
|
-
var
|
|
9981
|
+
var import_react60 = require("react");
|
|
9923
9982
|
|
|
9924
9983
|
// shared/package-runtime/list-row.ts
|
|
9925
9984
|
function listRowKind({ checked, selected, href, pressable }) {
|
|
@@ -9948,11 +10007,11 @@ function warnListRowProps({ checked, selected, href, chevron }) {
|
|
|
9948
10007
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
9949
10008
|
function KjunListRow({ title, description, icon, leading, trailing, actions, href, disabled = false, destructive = false, chevron = false, selected, checked, onCheckedChange, onClick, ariaLabel, children, titleLines, descriptionLines }) {
|
|
9950
10009
|
const kind = listRowKind({ checked, selected, href, pressable: !!(href || onClick) }), toggle = kind === "switch";
|
|
9951
|
-
const content = (0,
|
|
9952
|
-
(0,
|
|
10010
|
+
const content = (0, import_react60.useRef)(null), pressable = kind !== "static";
|
|
10011
|
+
(0, import_react60.useEffect)(() => {
|
|
9953
10012
|
if (pressable) warnNestedControls(content.current, "KJUN ListRow: a pressable row's content contains buttons or links; move them to actions.");
|
|
9954
10013
|
}, [pressable]);
|
|
9955
|
-
(0,
|
|
10014
|
+
(0, import_react60.useEffect)(() => warnListRowProps({ checked, selected, href, chevron }), [checked !== void 0, selected !== void 0, !!href, chevron]);
|
|
9956
10015
|
const clamp = (lines) => lines ? { WebkitLineClamp: lines } : void 0;
|
|
9957
10016
|
const front = leading || (icon ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(KjunIcon, { name: icon, className: "kjun-list-icon", size: import_tokens60.tokens.extensions.list.iconSize }) : null);
|
|
9958
10017
|
const contents = /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
|
|
@@ -9971,17 +10030,17 @@ function KjunListRow({ title, description, icon, leading, trailing, actions, hre
|
|
|
9971
10030
|
onCheckedChange == null ? void 0 : onCheckedChange(!checked);
|
|
9972
10031
|
onClick == null ? void 0 : onClick(event);
|
|
9973
10032
|
}, children: contents }) : kind === "radio" ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { className: "kjun-list-main", type: "button", role: "radio", "aria-checked": !!selected, "aria-label": ariaLabel, disabled, onClick, children: contents }) : href ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("a", { className: "kjun-list-main", href: disabled ? void 0 : href, "aria-label": ariaLabel, "aria-disabled": disabled || void 0, onClick: disabled ? (e) => e.preventDefault() : onClick, children: contents }) : onClick ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { className: "kjun-list-main", type: "button", "aria-label": ariaLabel, disabled, onClick, children: contents }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "kjun-list-main", children: contents });
|
|
9974
|
-
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("li", { className: "kjun-list-row", "data-leading": front ? "" : void 0, "data-destructive": destructive || void 0, "data-disabled": disabled || void 0, children: [
|
|
10033
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("li", { className: "kjun-list-row", "data-leading": front ? leading ? "" : "icon" : void 0, "data-destructive": destructive || void 0, "data-disabled": disabled || void 0, children: [
|
|
9975
10034
|
main,
|
|
9976
10035
|
hasContent(actions) && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "kjun-list-actions", "data-disabled": disabled || void 0, inert: disabled || void 0, children: actions })
|
|
9977
10036
|
] });
|
|
9978
10037
|
}
|
|
9979
|
-
var ListGroupContext = (0,
|
|
10038
|
+
var ListGroupContext = (0, import_react60.createContext)(null);
|
|
9980
10039
|
function KjunListSection({ title, description, actions, children, ariaLabel, surface = true, divider = true, density = "default", radius, titleVariant, headingLevel = 3, empty: empty3, footer }) {
|
|
9981
|
-
const group = (0,
|
|
10040
|
+
const group = (0, import_react60.useContext)(ListGroupContext), corner = radius != null ? radius : group === "inset" ? "lg" : "none";
|
|
9982
10041
|
const label = titleVariant ? titleVariant === "label" : !!title && !description;
|
|
9983
10042
|
const outside = corner !== "none" && !!title && label;
|
|
9984
|
-
const id = "kjun-" + (0,
|
|
10043
|
+
const id = "kjun-" + (0, import_react60.useId)(), Heading2 = `h${headingLevel}`;
|
|
9985
10044
|
const rounded = corner === "none" ? void 0 : { borderRadius: `var(--_kjun-geometry-card-radii-${corner})` };
|
|
9986
10045
|
const rows = hasContent(children) ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("ul", { className: "kjun-list", "aria-label": ariaLabel || void 0, "aria-labelledby": ariaLabel || !title ? void 0 : id, "data-divider": divider ? void 0 : "false", "data-density": density === "compact" ? "compact" : void 0, children }) : hasContent(empty3) ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "kjun-list-empty", children: empty3 }) : null;
|
|
9987
10046
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
@@ -10099,14 +10158,14 @@ function KjunBottomActionBar({ description, children, safeArea = true, keyboardV
|
|
|
10099
10158
|
}
|
|
10100
10159
|
|
|
10101
10160
|
// packages/react/src/media.tsx
|
|
10102
|
-
var
|
|
10161
|
+
var import_react61 = require("react");
|
|
10103
10162
|
var import_tokens62 = require("@kjun-ui/tokens");
|
|
10104
10163
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
10105
10164
|
function KjunImage({ src, alt, decorative = false, aspectRatio = 1, fit = "cover", fallback: fallback2, lazy = true, onLoad, onError }) {
|
|
10106
|
-
const current = (0,
|
|
10165
|
+
const current = (0, import_react61.useRef)({ src, version: 0 });
|
|
10107
10166
|
if (current.current.src !== src) current.current = { src, version: current.current.version + 1 };
|
|
10108
10167
|
const version = current.current.version;
|
|
10109
|
-
const [result, setResult] = (0,
|
|
10168
|
+
const [result, setResult] = (0, import_react61.useState)({ version, state: "loading" });
|
|
10110
10169
|
const state = result.version === version ? result.state : "loading";
|
|
10111
10170
|
const failed = !src || state === "error";
|
|
10112
10171
|
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("span", { className: "kjun-image", style: { aspectRatio: aspectRatio > 0 ? aspectRatio : 1 }, "data-state": failed ? "error" : state, children: [
|
|
@@ -10157,33 +10216,217 @@ function KjunFab({ icon, ariaLabel, disabled = false, safeArea = true, offsetBot
|
|
|
10157
10216
|
);
|
|
10158
10217
|
}
|
|
10159
10218
|
|
|
10219
|
+
// shared/package-runtime/slider-view.ts
|
|
10220
|
+
var decimals = (value) => {
|
|
10221
|
+
var _a;
|
|
10222
|
+
const text = String(value);
|
|
10223
|
+
return text.includes("e-") ? Number(text.split("e-")[1]) : ((_a = text.split(".")[1]) != null ? _a : "").length;
|
|
10224
|
+
};
|
|
10225
|
+
var formatters = /* @__PURE__ */ new Map();
|
|
10226
|
+
function sliderFormatter(formatValue, locale, min = 0, step = 1) {
|
|
10227
|
+
if (formatValue) return formatValue;
|
|
10228
|
+
const digits = Math.min(6, Math.max(decimals(min), decimals(step)));
|
|
10229
|
+
const key = (locale != null ? locale : "") + "|" + digits;
|
|
10230
|
+
let format2 = formatters.get(key);
|
|
10231
|
+
if (!format2) {
|
|
10232
|
+
const intl = new Intl.NumberFormat(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits });
|
|
10233
|
+
format2 = (value) => intl.format(value);
|
|
10234
|
+
formatters.set(key, format2);
|
|
10235
|
+
}
|
|
10236
|
+
return format2;
|
|
10237
|
+
}
|
|
10238
|
+
function sliderValueText(values, format2, formatRange2) {
|
|
10239
|
+
if (values.length === 2 && formatRange2) return formatRange2(values[0], values[1]);
|
|
10240
|
+
return values.length === 2 && values[0] === values[1] ? format2(values[0]) : values.map(format2).join(" \u2013 ");
|
|
10241
|
+
}
|
|
10242
|
+
var warnedMarks = false;
|
|
10243
|
+
function sliderMarks(marks, min, max, step, values, layout = {}) {
|
|
10244
|
+
if (!marks || !(max > min)) return [];
|
|
10245
|
+
const steps = Math.round((max - min) / step);
|
|
10246
|
+
if (marks === true && steps > 24 && !warnedMarks) {
|
|
10247
|
+
warnedMarks = true;
|
|
10248
|
+
console.warn(`KJUN Slider: marks={true}\uB294 step\uC774 24\uAC1C \uC774\uD558\uC77C \uB54C\uB9CC \uC810\uC744 \uADF8\uB9BD\uB2C8\uB2E4(\uC9C0\uAE08 ${steps}\uAC1C). \uAC12 \uBC30\uC5F4\uB85C \uC6D0\uD558\uB294 \uC704\uCE58\uB9CC \uB118\uAE30\uC138\uC694.`);
|
|
10249
|
+
}
|
|
10250
|
+
const list = marks === true ? steps <= 24 ? Array.from({ length: steps + 1 }, (_, i) => ({ value: min + i * step })) : [] : marks.filter((mark) => mark.value >= min && mark.value <= max);
|
|
10251
|
+
const high = values[values.length - 1];
|
|
10252
|
+
return list.map((mark) => ({
|
|
10253
|
+
...mark,
|
|
10254
|
+
fraction: (mark.value - min) / (max - min),
|
|
10255
|
+
/** Offset from the left (or the top when vertical), like the thumbs. */
|
|
10256
|
+
position: sliderAxis((mark.value - min) / (max - min), layout),
|
|
10257
|
+
// On the fill the dot turns light: a single slider fills from min, a range between its thumbs.
|
|
10258
|
+
active: values.length === 2 ? mark.value > values[0] && mark.value < high : mark.value < high,
|
|
10259
|
+
dot: mark.value !== min && mark.value !== max,
|
|
10260
|
+
// Which rail end an end label aligns to: the visual left or right (vertical labels sit beside the rail and need none).
|
|
10261
|
+
edge: layout.vertical || mark.value !== min && mark.value !== max ? void 0 : mark.value === min !== !!layout.rtl ? "start" : "end"
|
|
10262
|
+
}));
|
|
10263
|
+
}
|
|
10264
|
+
function sliderAxis(fraction, { rtl = false, vertical = false } = {}) {
|
|
10265
|
+
return vertical || rtl ? 1 - fraction : fraction;
|
|
10266
|
+
}
|
|
10267
|
+
function sliderFillBox(fractions, layout = {}) {
|
|
10268
|
+
const ends = fractions.map((fraction) => sliderAxis(fraction, layout) * 100);
|
|
10269
|
+
if (ends.length === 2) return { lead: Math.min(...ends), trail: 100 - Math.max(...ends) };
|
|
10270
|
+
return layout.vertical || layout.rtl ? { lead: ends[0], trail: null } : { lead: null, trail: 100 - ends[0] };
|
|
10271
|
+
}
|
|
10272
|
+
function sliderPageSize(min, max, step) {
|
|
10273
|
+
const tenth = Math.floor((max - min) / 10 / step) * step;
|
|
10274
|
+
return Math.max(step, tenth);
|
|
10275
|
+
}
|
|
10276
|
+
function sliderKeyValue(key, value, min, max, step, rtl = false) {
|
|
10277
|
+
if (key === "Home") return min;
|
|
10278
|
+
if (key === "End") return max;
|
|
10279
|
+
if (key === "PageUp" || key === "PageDown") return value + (key === "PageUp" ? 1 : -1) * sliderPageSize(min, max, step);
|
|
10280
|
+
const delta = { ArrowRight: rtl ? -1 : 1, ArrowLeft: rtl ? 1 : -1, ArrowUp: 1, ArrowDown: -1 };
|
|
10281
|
+
return key in delta ? value + delta[key] * step : null;
|
|
10282
|
+
}
|
|
10283
|
+
function sliderValueAt(offset, length, min, max, { rtl = false, vertical = false } = {}) {
|
|
10284
|
+
let fraction = Math.max(0, Math.min(1, offset / Math.max(1, length)));
|
|
10285
|
+
if (vertical || rtl) fraction = 1 - fraction;
|
|
10286
|
+
return min + fraction * (max - min);
|
|
10287
|
+
}
|
|
10288
|
+
function sliderFractions(values, min, max) {
|
|
10289
|
+
return values.map((value) => max > min ? Math.max(0, Math.min(1, (value - min) / (max - min))) : 0);
|
|
10290
|
+
}
|
|
10291
|
+
function sliderFrontThumb(values, min, max) {
|
|
10292
|
+
if (values.length !== 2 || values[0] !== values[1]) return null;
|
|
10293
|
+
return values[0] >= (min + max) / 2 ? 0 : 1;
|
|
10294
|
+
}
|
|
10295
|
+
function sliderPick(values, number, snapped) {
|
|
10296
|
+
if (values.length !== 2) return { index: 0, pending: false };
|
|
10297
|
+
if (values[0] === values[1]) {
|
|
10298
|
+
if (snapped === values[0]) return { index: values[0] >= number ? 0 : 1, pending: true };
|
|
10299
|
+
return { index: number > values[0] ? 1 : 0, pending: false };
|
|
10300
|
+
}
|
|
10301
|
+
return { index: Math.abs(number - values[1]) < Math.abs(number - values[0]) ? 1 : 0, pending: false };
|
|
10302
|
+
}
|
|
10303
|
+
function createSliderSession(initial, options) {
|
|
10304
|
+
let latest = [...initial], dirty = false, pending = false, active = null;
|
|
10305
|
+
const update = (index, number) => {
|
|
10306
|
+
if (options.blocked()) return;
|
|
10307
|
+
const next = [...latest];
|
|
10308
|
+
next[index] = Math.min(
|
|
10309
|
+
index === 0 && next.length === 2 ? next[1] : options.max(),
|
|
10310
|
+
Math.max(index === 1 ? next[0] : options.min(), options.snap(number))
|
|
10311
|
+
);
|
|
10312
|
+
if (next[index] === latest[index]) return;
|
|
10313
|
+
latest = next;
|
|
10314
|
+
dirty = true;
|
|
10315
|
+
options.emit([...next]);
|
|
10316
|
+
};
|
|
10317
|
+
const commit = () => {
|
|
10318
|
+
if (options.blocked() || !dirty) return;
|
|
10319
|
+
dirty = false;
|
|
10320
|
+
options.commit([...latest]);
|
|
10321
|
+
};
|
|
10322
|
+
return {
|
|
10323
|
+
get values() {
|
|
10324
|
+
return latest;
|
|
10325
|
+
},
|
|
10326
|
+
get active() {
|
|
10327
|
+
return active;
|
|
10328
|
+
},
|
|
10329
|
+
sync(values) {
|
|
10330
|
+
if (active === null) latest = [...values];
|
|
10331
|
+
},
|
|
10332
|
+
update,
|
|
10333
|
+
commit,
|
|
10334
|
+
press(number) {
|
|
10335
|
+
var _a;
|
|
10336
|
+
if (options.blocked()) return null;
|
|
10337
|
+
const pick = sliderPick(latest, number, options.snap(number));
|
|
10338
|
+
active = pick.index;
|
|
10339
|
+
pending = pick.pending;
|
|
10340
|
+
(_a = options.focus) == null ? void 0 : _a.call(options, active);
|
|
10341
|
+
update(active, number);
|
|
10342
|
+
return active;
|
|
10343
|
+
},
|
|
10344
|
+
move(number) {
|
|
10345
|
+
var _a;
|
|
10346
|
+
if (active === null) return active;
|
|
10347
|
+
if (pending) {
|
|
10348
|
+
if (options.snap(number) === latest[0]) return active;
|
|
10349
|
+
active = number > latest[0] ? 1 : 0;
|
|
10350
|
+
pending = false;
|
|
10351
|
+
(_a = options.focus) == null ? void 0 : _a.call(options, active);
|
|
10352
|
+
}
|
|
10353
|
+
update(active, number);
|
|
10354
|
+
return active;
|
|
10355
|
+
},
|
|
10356
|
+
release() {
|
|
10357
|
+
if (active === null) return;
|
|
10358
|
+
active = null;
|
|
10359
|
+
pending = false;
|
|
10360
|
+
commit();
|
|
10361
|
+
},
|
|
10362
|
+
cancel() {
|
|
10363
|
+
active = null;
|
|
10364
|
+
pending = false;
|
|
10365
|
+
dirty = false;
|
|
10366
|
+
},
|
|
10367
|
+
key(index, key, rtl = false) {
|
|
10368
|
+
const next = sliderKeyValue(key, latest[index], options.min(), options.max(), options.step(), rtl);
|
|
10369
|
+
if (next === null) return false;
|
|
10370
|
+
update(index, next);
|
|
10371
|
+
return true;
|
|
10372
|
+
}
|
|
10373
|
+
};
|
|
10374
|
+
}
|
|
10375
|
+
|
|
10160
10376
|
// packages/react/src/range-input.tsx
|
|
10161
|
-
var
|
|
10377
|
+
var import_react62 = require("react");
|
|
10162
10378
|
var import_react_aria_components10 = require("react-aria-components");
|
|
10163
10379
|
var import_tokens65 = require("@kjun-ui/tokens");
|
|
10164
10380
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
const
|
|
10168
|
-
const
|
|
10169
|
-
(
|
|
10381
|
+
var edge = "calc(var(--_kjun-slider-thumb) / -2)";
|
|
10382
|
+
function RangeThumb({ index, label, format: format2, front, dragging, inputs }) {
|
|
10383
|
+
const state = (0, import_react62.useContext)(import_react_aria_components10.SliderStateContext);
|
|
10384
|
+
const input = (0, import_react62.useRef)(null);
|
|
10385
|
+
const text = format2(state.values[index]);
|
|
10386
|
+
(0, import_react62.useLayoutEffect)(() => {
|
|
10170
10387
|
var _a;
|
|
10171
10388
|
(_a = input.current) == null ? void 0 : _a.setAttribute("aria-valuetext", text);
|
|
10389
|
+
inputs[index] = input.current;
|
|
10172
10390
|
});
|
|
10173
|
-
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10391
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10392
|
+
import_react_aria_components10.SliderThumb,
|
|
10393
|
+
{
|
|
10394
|
+
index,
|
|
10395
|
+
inputRef: input,
|
|
10396
|
+
className: "kjun-slider-thumb" + (dragging ? " kjun-slider-thumb--dragging" : ""),
|
|
10397
|
+
"aria-label": label,
|
|
10398
|
+
style: front ? { zIndex: 1 } : void 0
|
|
10399
|
+
}
|
|
10400
|
+
);
|
|
10174
10401
|
}
|
|
10175
|
-
function RangeInput(
|
|
10176
|
-
const
|
|
10177
|
-
const
|
|
10402
|
+
function RangeInput(props) {
|
|
10403
|
+
const { value, min = 0, max = 100, step = 1, disabled = false, label, ariaLabel, showValue = true, formatValue, marks, size = "md", orientation = "horizontal" } = props;
|
|
10404
|
+
const m = useKjunMessages(), locale = useKjunMessageScope().intl;
|
|
10405
|
+
const { direction } = (0, import_react_aria_components10.useLocale)();
|
|
10406
|
+
const vertical = orientation === "vertical", layout = { rtl: direction === "rtl" && !vertical, vertical };
|
|
10407
|
+
const format2 = sliderFormatter(formatValue, locale, min, step);
|
|
10408
|
+
const formatRange2 = "formatRange" in props ? props.formatRange : void 0;
|
|
10409
|
+
const thumbLabels = "thumbLabels" in props ? props.thumbLabels || [m.minimum, m.maximum] : [m.minimum, m.maximum];
|
|
10178
10410
|
const domain = (0, import_tokens65.createSliderDomain)(min, max, step);
|
|
10179
10411
|
const list = Array.isArray(value) ? value : [value];
|
|
10180
10412
|
const valid = domain.valid && (!Array.isArray(value) || value.length === 2) && list.every((v) => domain.accepts(v)) && (list.length === 1 || list[0] <= list[1]);
|
|
10181
|
-
const latest = (0,
|
|
10413
|
+
const latest = (0, import_react62.useRef)(value);
|
|
10182
10414
|
latest.current = value;
|
|
10183
|
-
const active = (0,
|
|
10184
|
-
(0,
|
|
10415
|
+
const active = (0, import_react62.useRef)(false);
|
|
10416
|
+
const inputs = (0, import_react62.useRef)([]);
|
|
10417
|
+
const track = (0, import_react62.useRef)(null);
|
|
10418
|
+
const [ownDrag, setOwnDrag] = (0, import_react62.useState)(null);
|
|
10419
|
+
(0, import_react62.useEffect)(() => {
|
|
10185
10420
|
if (!valid) console.warn("KJUN Slider: \uBC94\uC704\xB7step\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
|
|
10186
10421
|
}, [valid]);
|
|
10422
|
+
const emit = (result) => {
|
|
10423
|
+
var _a;
|
|
10424
|
+
return (_a = props.onValueChange) == null ? void 0 : _a.call(props, result);
|
|
10425
|
+
};
|
|
10426
|
+
const commit = (result) => {
|
|
10427
|
+
var _a;
|
|
10428
|
+
return (_a = props.onChangeCommit) == null ? void 0 : _a.call(props, result);
|
|
10429
|
+
};
|
|
10187
10430
|
const change = (next) => {
|
|
10188
10431
|
if (!valid || disabled) return;
|
|
10189
10432
|
const snapped = (Array.isArray(next) ? next : [next]).map(domain.snap);
|
|
@@ -10191,24 +10434,114 @@ function RangeInput({ value, min = 0, max = 100, step = 1, disabled = false, lab
|
|
|
10191
10434
|
if (JSON.stringify(result) === JSON.stringify(latest.current)) return;
|
|
10192
10435
|
latest.current = result;
|
|
10193
10436
|
active.current = true;
|
|
10194
|
-
|
|
10437
|
+
emit(result);
|
|
10438
|
+
};
|
|
10439
|
+
const top = valid ? domain.snap(max) : max;
|
|
10440
|
+
const session = () => createSliderSession(Array.isArray(latest.current) ? latest.current : [latest.current], {
|
|
10441
|
+
min: () => min,
|
|
10442
|
+
max: () => top,
|
|
10443
|
+
step: () => step,
|
|
10444
|
+
snap: domain.snap,
|
|
10445
|
+
blocked: () => disabled || !valid,
|
|
10446
|
+
emit: (next) => {
|
|
10447
|
+
const result = next.length === 1 ? next[0] : next;
|
|
10448
|
+
latest.current = result;
|
|
10449
|
+
emit(result);
|
|
10450
|
+
},
|
|
10451
|
+
commit: (next) => commit(next.length === 1 ? next[0] : next),
|
|
10452
|
+
focus: (index) => {
|
|
10453
|
+
var _a;
|
|
10454
|
+
setOwnDrag(index);
|
|
10455
|
+
(_a = inputs.current[index]) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
10456
|
+
}
|
|
10457
|
+
});
|
|
10458
|
+
const valueAt = (event) => {
|
|
10459
|
+
const box = track.current.getBoundingClientRect();
|
|
10460
|
+
return sliderValueAt(vertical ? event.clientY - box.top : event.clientX - box.left, vertical ? box.height : box.width, min, top, layout);
|
|
10195
10461
|
};
|
|
10196
|
-
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
|
|
10462
|
+
const collapsed = valid && !disabled && list.length === 2 && list[0] === list[1];
|
|
10463
|
+
(0, import_react62.useEffect)(() => {
|
|
10464
|
+
const element = track.current;
|
|
10465
|
+
if (!element || !collapsed) return;
|
|
10466
|
+
const down = (event) => {
|
|
10467
|
+
if (event.button !== 0) return;
|
|
10468
|
+
event.preventDefault();
|
|
10469
|
+
event.stopPropagation();
|
|
10470
|
+
const drag = session();
|
|
10471
|
+
drag.press(valueAt(event));
|
|
10472
|
+
const move = (next) => drag.move(valueAt(next));
|
|
10473
|
+
const up = () => {
|
|
10474
|
+
drag.release();
|
|
10475
|
+
setOwnDrag(null);
|
|
10476
|
+
removeEventListener("pointermove", move);
|
|
10477
|
+
removeEventListener("pointerup", up);
|
|
10478
|
+
removeEventListener("pointercancel", up);
|
|
10479
|
+
};
|
|
10480
|
+
addEventListener("pointermove", move);
|
|
10481
|
+
addEventListener("pointerup", up);
|
|
10482
|
+
addEventListener("pointercancel", up);
|
|
10483
|
+
};
|
|
10484
|
+
element.addEventListener("pointerdown", down, true);
|
|
10485
|
+
return () => element.removeEventListener("pointerdown", down, true);
|
|
10486
|
+
});
|
|
10487
|
+
const pickMark = (number) => {
|
|
10488
|
+
const drag = session();
|
|
10489
|
+
drag.press(number);
|
|
10490
|
+
drag.release();
|
|
10491
|
+
setOwnDrag(null);
|
|
10492
|
+
};
|
|
10493
|
+
const fractions = sliderFractions(list, min, top);
|
|
10494
|
+
const front = valid ? sliderFrontThumb(list, min, top) : null;
|
|
10495
|
+
const dots = valid ? sliderMarks(marks, min, top, step, list, layout) : [];
|
|
10496
|
+
const fill = sliderFillBox(fractions, layout);
|
|
10497
|
+
const [lead, trail] = vertical ? ["top", "bottom"] : ["left", "right"];
|
|
10498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
10499
|
+
import_react_aria_components10.Slider,
|
|
10500
|
+
{
|
|
10501
|
+
className: "kjun-slider",
|
|
10502
|
+
"data-size": size,
|
|
10503
|
+
"data-orientation": orientation,
|
|
10504
|
+
"data-disabled": disabled || !valid,
|
|
10505
|
+
orientation,
|
|
10506
|
+
"aria-label": label ? void 0 : ariaLabel || m.value,
|
|
10507
|
+
style: vertical && props.length ? { "--_kjun-slider-length": props.length + "px" } : void 0,
|
|
10508
|
+
value: valid ? value : Array.isArray(value) ? fractions.map((f) => f * 100) : fractions[0] * 100,
|
|
10509
|
+
minValue: valid ? min : 0,
|
|
10510
|
+
maxValue: valid ? top : 100,
|
|
10511
|
+
step: valid ? step : 1,
|
|
10512
|
+
isDisabled: disabled || !valid,
|
|
10513
|
+
onChange: change,
|
|
10514
|
+
onChangeEnd: () => {
|
|
10515
|
+
if (valid && !disabled && active.current) {
|
|
10516
|
+
active.current = false;
|
|
10517
|
+
commit(latest.current);
|
|
10518
|
+
}
|
|
10519
|
+
},
|
|
10520
|
+
children: [
|
|
10521
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "kjun-slider-caption", children: [
|
|
10522
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_react_aria_components10.Label, { className: "kjun-slider-label", children: label }),
|
|
10523
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_react_aria_components10.SliderOutput, { className: "kjun-slider-value", children: ({ state }) => sliderValueText(valid ? state.values : list, format2, formatRange2) })
|
|
10524
|
+
] }),
|
|
10525
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_react_aria_components10.SliderTrack, { ref: track, className: "kjun-slider-track", children: () => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
|
|
10526
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "kjun-slider-rail" }),
|
|
10527
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "kjun-slider-fill", style: { [lead]: fill.lead === null ? edge : fill.lead + "%", [trail]: fill.trail === null ? edge : fill.trail + "%" } }),
|
|
10528
|
+
dots.filter((dot) => dot.dot).map((dot) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "kjun-slider-mark", "data-active": dot.active || void 0, style: { [lead]: dot.position * 100 + "%" } }, dot.value)),
|
|
10529
|
+
list.map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(RangeThumb, { index: i, format: format2, front: front === i, dragging: ownDrag === i, inputs: inputs.current, label: list.length === 2 ? thumbLabels[i] : ariaLabel || label || m.value }, i))
|
|
10530
|
+
] }) }),
|
|
10531
|
+
dots.some((dot) => dot.label) && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "kjun-slider-marks", "aria-hidden": "true", children: dots.filter((dot) => dot.label).map((dot) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10532
|
+
"span",
|
|
10533
|
+
{
|
|
10534
|
+
className: "kjun-slider-mark-label",
|
|
10535
|
+
"data-edge": dot.edge,
|
|
10536
|
+
style: { [lead]: dot.position * 100 + "%" },
|
|
10537
|
+
onClick: () => pickMark(dot.value),
|
|
10538
|
+
children: dot.label
|
|
10539
|
+
},
|
|
10540
|
+
dot.value
|
|
10541
|
+
)) })
|
|
10542
|
+
]
|
|
10200
10543
|
}
|
|
10201
|
-
|
|
10202
|
-
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "kjun-slider-caption", children: [
|
|
10203
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_react_aria_components10.Label, { className: "kjun-slider-label", children: label }),
|
|
10204
|
-
showValue && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_react_aria_components10.SliderOutput, { className: "kjun-slider-value", children: ({ state }) => state.values.map(formatValue != null ? formatValue : String).join(" \u2013 ") })
|
|
10205
|
-
] }),
|
|
10206
|
-
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_react_aria_components10.SliderTrack, { className: "kjun-slider-track", children: ({ state }) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
|
|
10207
|
-
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "kjun-slider-rail" }),
|
|
10208
|
-
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "kjun-slider-fill", style: { left: (list.length === 2 ? state.getThumbPercent(0) * 100 : 0) + "%", width: (state.getThumbPercent(list.length - 1) - (list.length === 2 ? state.getThumbPercent(0) : 0)) * 100 + "%" } }),
|
|
10209
|
-
list.map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(RangeThumb, { index: i, formatValue, label: list.length === 2 ? thumbLabels[i] : ariaLabel || label || m.value }, i))
|
|
10210
|
-
] }) })
|
|
10211
|
-
] });
|
|
10544
|
+
);
|
|
10212
10545
|
}
|
|
10213
10546
|
function KjunSlider(props) {
|
|
10214
10547
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(RangeInput, { ...props });
|
|
@@ -10218,7 +10551,7 @@ function KjunRangeSlider(props) {
|
|
|
10218
10551
|
}
|
|
10219
10552
|
|
|
10220
10553
|
// packages/react/src/quantity-stepper.tsx
|
|
10221
|
-
var
|
|
10554
|
+
var import_react63 = require("react");
|
|
10222
10555
|
var import_tokens66 = require("@kjun-ui/tokens");
|
|
10223
10556
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
10224
10557
|
function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, disabled = false, error = false, size = "md", block = false, id, ariaLabel, onValueChange, onChangeCommit, onInvalidInput }) {
|
|
@@ -10227,15 +10560,15 @@ function KjunQuantityStepper({ value, min = 0, max, step = 1, precision = 0, dis
|
|
|
10227
10560
|
const buttonStyle = { width: import_tokens66.tokens.input[size].height, padding: 0 };
|
|
10228
10561
|
const domain = (0, import_tokens66.createNumberDomain)({ min, max, step, precision });
|
|
10229
10562
|
const valid = domain.valid && domain.accepts(value), blocked = disabled || !valid;
|
|
10230
|
-
const [draft, setDraft] = (0,
|
|
10563
|
+
const [draft, setDraft] = (0, import_react63.useState)(String(value));
|
|
10231
10564
|
const field = useKjunField();
|
|
10232
|
-
const composing = (0,
|
|
10233
|
-
(0,
|
|
10565
|
+
const composing = (0, import_react63.useRef)(false), dirty = (0, import_react63.useRef)(false), accepted = (0, import_react63.useRef)(value);
|
|
10566
|
+
(0, import_react63.useEffect)(() => {
|
|
10234
10567
|
setDraft(String(value));
|
|
10235
10568
|
accepted.current = value;
|
|
10236
10569
|
dirty.current = false;
|
|
10237
10570
|
}, [value, precision, min, max, step]);
|
|
10238
|
-
(0,
|
|
10571
|
+
(0, import_react63.useEffect)(() => {
|
|
10239
10572
|
if (!valid) console.warn("KJUN QuantityStepper: \uBC94\uC704\xB7step\xB7\uC815\uBC00\uB3C4\xB7\uAC12\uC744 \uD655\uC778\uD558\uC138\uC694.");
|
|
10240
10573
|
}, [valid]);
|
|
10241
10574
|
const emit = (next) => {
|
|
@@ -10351,7 +10684,7 @@ function timeSegments(domain, value, { precision, hourCycle = 24, messages, peri
|
|
|
10351
10684
|
var periodLeads = (language) => !language || ["ko", "ja", "zh"].includes(language);
|
|
10352
10685
|
|
|
10353
10686
|
// packages/react/src/time-picker.tsx
|
|
10354
|
-
var
|
|
10687
|
+
var import_react64 = require("react");
|
|
10355
10688
|
var import_tokens67 = require("@kjun-ui/tokens");
|
|
10356
10689
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
10357
10690
|
function KjunTimePicker({
|
|
@@ -10375,12 +10708,12 @@ function KjunTimePicker({
|
|
|
10375
10708
|
}) {
|
|
10376
10709
|
const scope = useKjunMessageScope(), m = scope.messages;
|
|
10377
10710
|
ariaLabel != null ? ariaLabel : ariaLabel = m.time;
|
|
10378
|
-
const root = (0,
|
|
10379
|
-
const field = useKjunField(), uid = (0,
|
|
10711
|
+
const root = (0, import_react64.useRef)(null);
|
|
10712
|
+
const field = useKjunField(), uid = (0, import_react64.useId)();
|
|
10380
10713
|
const fieldId = (field == null ? void 0 : field.id) || `kjun-time-${uid}`;
|
|
10381
|
-
const domain = (0,
|
|
10714
|
+
const domain = (0, import_react64.useMemo)(() => (0, import_tokens67.createTimeDomain)({ precision, min, max, minuteStep, secondStep }), [precision, min, max, minuteStep, secondStep]);
|
|
10382
10715
|
const accepted = domain.accepts(value);
|
|
10383
|
-
(0,
|
|
10716
|
+
(0, import_react64.useEffect)(() => {
|
|
10384
10717
|
if (!domain.valid) warnPicker("TimePicker: check min, max, minuteStep and secondStep.");
|
|
10385
10718
|
else if (!accepted) warnPicker(`TimePicker: ${value} is outside the step or bounds.`);
|
|
10386
10719
|
}, [domain, accepted, value]);
|
|
@@ -10411,7 +10744,7 @@ function KjunTimePicker({
|
|
|
10411
10744
|
const segmentId = index === 0 ? fieldId : `${fieldId}-${index}`;
|
|
10412
10745
|
const labelId = `${fieldId}-segment-${index}`;
|
|
10413
10746
|
const separated = index > 0 && segment.key !== "period" && segments[index - 1].key !== "period";
|
|
10414
|
-
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
10747
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_react64.Fragment, { children: [
|
|
10415
10748
|
separated && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "kjun-time-separator", "aria-hidden": true, children: ":" }),
|
|
10416
10749
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(FieldContext.Provider, { value: { ...field, id: segmentId, labelId: (field == null ? void 0 : field.labelId) ? `${field.labelId} ${labelId}` : void 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "kjun-time-segment", "data-period": segment.key === "period" || void 0, children: [
|
|
10417
10750
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { id: labelId, className: "kjun-sr-only", "aria-hidden": true, children: segment.label }),
|