twico-ui 1.33.1 → 1.35.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/CHANGELOG.md +25 -0
- package/dist/index.cjs +339 -176
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.mjs +339 -176
- package/dist/index.mjs.map +1 -1
- package/llms.txt +7 -0
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -8362,6 +8362,16 @@ var DT_CSS = `
|
|
|
8362
8362
|
.twc-dt__group-sub span { font-variant-numeric: tabular-nums; }
|
|
8363
8363
|
.twc-dt__group-sub span b { color: var(--color-text); }
|
|
8364
8364
|
|
|
8365
|
+
/* #350: expandable row detail (renderRowDetail) \u2014 leading chevron column + full-width detail row */
|
|
8366
|
+
.twc-dt__expand-cell { text-align: center; padding-inline: 0; }
|
|
8367
|
+
.twc-dt__expand-btn { display: inline-grid; place-items: center; width: 24px; height: 24px; border: none; padding: 0; background: transparent; color: var(--color-text-subtle); cursor: pointer; border-radius: var(--radius-sm); }
|
|
8368
|
+
.twc-dt__expand-btn:hover { color: var(--color-text); background: color-mix(in srgb, currentColor 12%, transparent); }
|
|
8369
|
+
.twc-dt__expand-btn:focus-visible { outline: none; box-shadow: var(--ring); }
|
|
8370
|
+
.twc-dt__expand-chev { display: inline-flex; transform: rotate(-90deg); transition: transform var(--duration-base) var(--ease-spring); }
|
|
8371
|
+
.twc-dt__expand-chev[data-open] { transform: rotate(0deg); color: var(--color-primary); }
|
|
8372
|
+
.twc-dt__expand-chev svg { width: 16px; height: 16px; }
|
|
8373
|
+
.twc-dt__detail-cell { box-sizing: border-box; background: var(--color-surface-sunken); border-bottom: var(--border-thin) solid var(--color-divider); padding: 12px 16px; }
|
|
8374
|
+
|
|
8365
8375
|
/* Pivot view */
|
|
8366
8376
|
.twc-dt__pivot { table-layout: auto; width: 100%; }
|
|
8367
8377
|
.twc-dt__pivot th, .twc-dt__pivot td { white-space: nowrap; }
|
|
@@ -9309,6 +9319,20 @@ function Datatable({
|
|
|
9309
9319
|
virtualized = false,
|
|
9310
9320
|
overscan = 8,
|
|
9311
9321
|
rowHeight,
|
|
9322
|
+
// #350 (first pass): expandable/collapsible rows. `renderRowDetail(row)` returns the detail panel for a
|
|
9323
|
+
// row (return null/undefined ⇒ that row isn't expandable). Presence of the fn enables a leading chevron
|
|
9324
|
+
// column + a full-width detail <tr> under each expanded row. Expansion is uncontrolled unless
|
|
9325
|
+
// `expandedRowIds` is supplied; `onExpandedRowsChange` fires the next expanded-key array on every toggle.
|
|
9326
|
+
renderRowDetail,
|
|
9327
|
+
expandedRowIds,
|
|
9328
|
+
onExpandedRowsChange,
|
|
9329
|
+
// #359: server-mode lazy row-tree — `getRowCanExpand(row)` draws the same leading chevron on parent DATA
|
|
9330
|
+
// rows (independent of renderRowDetail); expanding reveals CHILD data rows in the SAME columns rather than a
|
|
9331
|
+
// panel. In server mode the host returns children inline (the expanded set is folded into onServerChange);
|
|
9332
|
+
// in client mode `getSubRows(row)` supplies them. `getRowDepth(row)` indents nested rows so they read as a tree.
|
|
9333
|
+
getRowCanExpand,
|
|
9334
|
+
getRowDepth,
|
|
9335
|
+
getSubRows,
|
|
9312
9336
|
className = "",
|
|
9313
9337
|
...rest
|
|
9314
9338
|
}) {
|
|
@@ -9515,6 +9539,13 @@ function Datatable({
|
|
|
9515
9539
|
const gridRef = React51__default.useRef(null);
|
|
9516
9540
|
const [groupBy, setGroupBy] = React51__default.useState(rowGrouping || []);
|
|
9517
9541
|
const [collapsed, setCollapsed] = React51__default.useState(() => /* @__PURE__ */ new Set());
|
|
9542
|
+
const [internalExpanded, setInternalExpanded] = React51__default.useState(() => /* @__PURE__ */ new Set());
|
|
9543
|
+
const expandControlled = expandedRowIds !== void 0;
|
|
9544
|
+
const expandedSet = React51__default.useMemo(
|
|
9545
|
+
() => new Set(expandControlled ? expandedRowIds : internalExpanded),
|
|
9546
|
+
[expandControlled, expandedRowIds, internalExpanded]
|
|
9547
|
+
);
|
|
9548
|
+
const expandedKey = React51__default.useMemo(() => JSON.stringify([...expandedSet].sort()), [expandedSet]);
|
|
9518
9549
|
const [pinnedRows, setPinnedRows] = React51__default.useState({ top: [], bottom: [] });
|
|
9519
9550
|
const [headH, setHeadH] = React51__default.useState(41);
|
|
9520
9551
|
const theadRef = React51__default.useRef(null);
|
|
@@ -9916,7 +9947,12 @@ function Datatable({
|
|
|
9916
9947
|
}, [pins, effectiveHidden, visibleCols, colByField, order]);
|
|
9917
9948
|
const NUM_W = 56;
|
|
9918
9949
|
const CHK_W = checkboxSelection ? rowReorder ? 68 : 44 : 0;
|
|
9919
|
-
const
|
|
9950
|
+
const hasRowDetail = typeof renderRowDetail === "function";
|
|
9951
|
+
const hasRowTree = typeof getRowCanExpand === "function";
|
|
9952
|
+
const hasExpandCol = hasRowDetail || hasRowTree;
|
|
9953
|
+
const treeExpandedKey = hasRowTree ? expandedKey : "";
|
|
9954
|
+
const EXP_W = hasExpandCol ? 44 : 0;
|
|
9955
|
+
const numLeft = EXP_W + CHK_W;
|
|
9920
9956
|
const leadW = numLeft + (showRowNum ? NUM_W : 0);
|
|
9921
9957
|
const visLeft = React51__default.useMemo(() => pins.left.filter((f) => colByField[f] && !effectiveHidden.has(f)), [pins.left, colByField, effectiveHidden]);
|
|
9922
9958
|
const visRight = React51__default.useMemo(() => pins.right.filter((f) => colByField[f] && !effectiveHidden.has(f)), [pins.right, colByField, effectiveHidden]);
|
|
@@ -9988,6 +10024,40 @@ function Datatable({
|
|
|
9988
10024
|
React51__default.useEffect(() => {
|
|
9989
10025
|
if (pageVal > totalPages - 1) commitPage(0);
|
|
9990
10026
|
}, [totalPages]);
|
|
10027
|
+
const treeRows = React51__default.useMemo(() => {
|
|
10028
|
+
if (serverMode || typeof getSubRows !== "function") return null;
|
|
10029
|
+
const out = [];
|
|
10030
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
10031
|
+
const walk = (r2, d) => {
|
|
10032
|
+
const key = keyOf(r2);
|
|
10033
|
+
if (seen2.has(key)) return;
|
|
10034
|
+
seen2.add(key);
|
|
10035
|
+
out.push({ row: r2, depth: d });
|
|
10036
|
+
if (expandedSet.has(key)) for (const c of getSubRows(r2) || []) walk(c, d + 1);
|
|
10037
|
+
};
|
|
10038
|
+
for (const r2 of paged) walk(r2, 0);
|
|
10039
|
+
return out;
|
|
10040
|
+
}, [serverMode, getSubRows, paged, expandedSet, keyOf]);
|
|
10041
|
+
const depthByKey = React51__default.useMemo(() => {
|
|
10042
|
+
const m = /* @__PURE__ */ new Map();
|
|
10043
|
+
if (treeRows) for (const t of treeRows) m.set(keyOf(t.row), t.depth);
|
|
10044
|
+
return m;
|
|
10045
|
+
}, [treeRows, keyOf]);
|
|
10046
|
+
const treeSeqByKey = React51__default.useMemo(() => {
|
|
10047
|
+
if (!treeRows) return null;
|
|
10048
|
+
const m = /* @__PURE__ */ new Map();
|
|
10049
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
10050
|
+
let n = 0;
|
|
10051
|
+
const walk = (r2) => {
|
|
10052
|
+
const key = keyOf(r2);
|
|
10053
|
+
if (seen2.has(key)) return;
|
|
10054
|
+
seen2.add(key);
|
|
10055
|
+
m.set(key, n++);
|
|
10056
|
+
if (expandedSet.has(key)) for (const c of getSubRows(r2) || []) walk(c);
|
|
10057
|
+
};
|
|
10058
|
+
for (const r2 of processed) walk(r2);
|
|
10059
|
+
return m;
|
|
10060
|
+
}, [treeRows, processed, expandedSet, getSubRows, keyOf]);
|
|
9991
10061
|
const activeGroupBy = React51__default.useMemo(() => groupBy.filter((f) => colByField[f]), [groupBy, colByField]);
|
|
9992
10062
|
function subtotalText(rowsIn) {
|
|
9993
10063
|
const parts = [];
|
|
@@ -10038,7 +10108,7 @@ function Datatable({
|
|
|
10038
10108
|
};
|
|
10039
10109
|
return build(paged, 0, "");
|
|
10040
10110
|
}, [activeGroupBy, collapsed, paged, ordered, aggOn]);
|
|
10041
|
-
const leafRows = displayItems ? displayItems.filter((i) => i.kind === "leaf").map((i) => i.row) : paged;
|
|
10111
|
+
const leafRows = displayItems ? displayItems.filter((i) => i.kind === "leaf").map((i) => i.row) : treeRows ? treeRows.map((t) => t.row) : paged;
|
|
10042
10112
|
function toggleGroup(key) {
|
|
10043
10113
|
setCollapsed((s) => {
|
|
10044
10114
|
const n = new Set(s);
|
|
@@ -10290,12 +10360,14 @@ function Datatable({
|
|
|
10290
10360
|
// #303: "and" (default) | "or" — the server groups its WHERE accordingly
|
|
10291
10361
|
quickFilter: quick.trim(),
|
|
10292
10362
|
visibleColumns,
|
|
10293
|
-
hiddenColumns
|
|
10363
|
+
hiddenColumns,
|
|
10294
10364
|
// #191: server can project only the visible columns
|
|
10365
|
+
...hasRowTree ? { expanded: [...expandedSet] } : null
|
|
10366
|
+
// #359: only a row-tree folds expanded parents in
|
|
10295
10367
|
});
|
|
10296
10368
|
}, 250);
|
|
10297
10369
|
return () => clearTimeout(t);
|
|
10298
|
-
}, [serverMode, pageVal, sizeVal, sort, filters, filterLogic, quick, visibleColumns, hiddenColumns]);
|
|
10370
|
+
}, [serverMode, pageVal, sizeVal, sort, filters, filterLogic, quick, visibleColumns, hiddenColumns, treeExpandedKey]);
|
|
10299
10371
|
const onColVisRef = React51__default.useRef(onColumnVisibilityChange);
|
|
10300
10372
|
onColVisRef.current = onColumnVisibilityChange;
|
|
10301
10373
|
const lastVisibleKey = React51__default.useRef(null);
|
|
@@ -10511,6 +10583,12 @@ function Datatable({
|
|
|
10511
10583
|
return n;
|
|
10512
10584
|
});
|
|
10513
10585
|
}
|
|
10586
|
+
function toggleRowDetail(k) {
|
|
10587
|
+
const n = new Set(expandedSet);
|
|
10588
|
+
n.has(k) ? n.delete(k) : n.add(k);
|
|
10589
|
+
onExpandedRowsChange?.([...n]);
|
|
10590
|
+
if (!expandControlled) setInternalExpanded(n);
|
|
10591
|
+
}
|
|
10514
10592
|
function handleRowClick(e, k, row) {
|
|
10515
10593
|
if (selectionMode === "none") return;
|
|
10516
10594
|
if (e.target.closest("button, a, input, select, .twc-dt__check, .twc-dt__editor-wrap")) return;
|
|
@@ -10663,12 +10741,12 @@ function Datatable({
|
|
|
10663
10741
|
next = next === "" ? null : Number(next);
|
|
10664
10742
|
if (Number.isNaN(next)) next = null;
|
|
10665
10743
|
}
|
|
10666
|
-
const row =
|
|
10744
|
+
const row = leafRows.find((r2, i) => keyOf(r2, i) === editing.key);
|
|
10667
10745
|
setEditing(null);
|
|
10668
10746
|
if (!row || row[editing.field] === next) return;
|
|
10669
10747
|
const updated = { ...row, [editing.field]: next };
|
|
10670
10748
|
onRowUpdate?.(updated, row, editing.field);
|
|
10671
|
-
if (onRowsChange) {
|
|
10749
|
+
if (onRowsChange && rows.some((r2, i) => keyOf(r2, i) === editing.key)) {
|
|
10672
10750
|
onRowsChange(rows.map((r2, i) => keyOf(r2, i) === editing.key ? updated : r2));
|
|
10673
10751
|
}
|
|
10674
10752
|
}
|
|
@@ -10797,20 +10875,25 @@ function Datatable({
|
|
|
10797
10875
|
};
|
|
10798
10876
|
const writeCellPatches = (patchByKey) => {
|
|
10799
10877
|
if (!patchByKey.size) return 0;
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
const
|
|
10803
|
-
|
|
10804
|
-
if (!patch) return r2;
|
|
10878
|
+
let count = 0;
|
|
10879
|
+
leafRows.forEach((r2, i) => {
|
|
10880
|
+
const patch = patchByKey.get(keyOf(r2, i));
|
|
10881
|
+
if (!patch) return;
|
|
10805
10882
|
const updated = { ...r2, ...patch };
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
});
|
|
10809
|
-
changed.forEach(([updated, orig, patch]) => {
|
|
10810
|
-
for (const f of Object.keys(patch)) onRowUpdate?.(updated, orig, f);
|
|
10883
|
+
for (const f of Object.keys(patch)) onRowUpdate?.(updated, r2, f);
|
|
10884
|
+
count++;
|
|
10811
10885
|
});
|
|
10812
|
-
if (onRowsChange
|
|
10813
|
-
|
|
10886
|
+
if (onRowsChange) {
|
|
10887
|
+
let anyTop = false;
|
|
10888
|
+
const nextAll = rows.map((r2, i) => {
|
|
10889
|
+
const patch = patchByKey.get(keyOf(r2, i));
|
|
10890
|
+
if (!patch) return r2;
|
|
10891
|
+
anyTop = true;
|
|
10892
|
+
return { ...r2, ...patch };
|
|
10893
|
+
});
|
|
10894
|
+
if (anyTop) onRowsChange(nextAll);
|
|
10895
|
+
}
|
|
10896
|
+
return count;
|
|
10814
10897
|
};
|
|
10815
10898
|
const rectCells = () => {
|
|
10816
10899
|
if (!cellRect) return null;
|
|
@@ -11357,7 +11440,7 @@ function Datatable({
|
|
|
11357
11440
|
const manageableCols = cols.filter((c) => c.field !== "__pinactions__");
|
|
11358
11441
|
const visibleColCount = manageableCols.filter((c) => !effectiveHidden.has(c.field)).length;
|
|
11359
11442
|
const rppOptions = Array.from(new Set([...pageSizeOptions || [], pageSize].filter((n) => n > 0))).sort((a, b) => a - b).map((n) => ({ value: String(n), label: String(n) }));
|
|
11360
|
-
const totalCols = ordered.length + (checkboxSelection ? 1 : 0) + (showRowNum ? 1 : 0);
|
|
11443
|
+
const totalCols = ordered.length + (checkboxSelection ? 1 : 0) + (showRowNum ? 1 : 0) + (hasExpandCol ? 1 : 0);
|
|
11361
11444
|
function renderGroupRow(item) {
|
|
11362
11445
|
const subs = aggOn ? subtotalText(item.rows) : [];
|
|
11363
11446
|
return /* @__PURE__ */ jsx("tr", { className: "twc-dt__group-row", role: "row", children: /* @__PURE__ */ jsxs("td", { className: "twc-dt__group-cell", role: "gridcell", colSpan: totalCols, style: { maxWidth: "none" }, children: [
|
|
@@ -11411,6 +11494,11 @@ function Datatable({
|
|
|
11411
11494
|
function renderLeaf(row, ri, pinSide, midIdx) {
|
|
11412
11495
|
const k = keyOf(row, ri);
|
|
11413
11496
|
const sel = selected.has(k);
|
|
11497
|
+
const detail = hasRowDetail && !pinSide ? renderRowDetail(row) : null;
|
|
11498
|
+
const canTreeExpand = hasRowTree && !pinSide && !!getRowCanExpand(row);
|
|
11499
|
+
const expandable = detail != null || canTreeExpand;
|
|
11500
|
+
const open = expandable && expandedSet.has(k);
|
|
11501
|
+
const depth = getRowDepth ? getRowDepth(row) || 0 : depthByKey.get(k) || 0;
|
|
11414
11502
|
const rowActive = selectionMode === "row" && activeRowVal === k;
|
|
11415
11503
|
const stickyStyle = pinSide === "top" ? { position: "sticky", top: headH, zIndex: 5 } : pinSide === "bottom" ? { position: "sticky", bottom: 0, zIndex: 5 } : void 0;
|
|
11416
11504
|
const h = rowHeights[k];
|
|
@@ -11418,159 +11506,165 @@ function Datatable({
|
|
|
11418
11506
|
const reorderable = canReorderRows && !pinSide;
|
|
11419
11507
|
const grabbed = rowGrab && rowGrab.key === k;
|
|
11420
11508
|
const grabTarget = rowGrab && !grabbed && midIdx != null && rowGrab.index === midIdx ? rowGrab.index >= keyIndexMid.get(rowGrab.key) ? "after" : "before" : void 0;
|
|
11421
|
-
return /* @__PURE__ */ jsxs(
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
|
|
11433
|
-
|
|
11434
|
-
|
|
11435
|
-
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
/* @__PURE__ */
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11509
|
+
return /* @__PURE__ */ jsxs(React51__default.Fragment, { children: [
|
|
11510
|
+
/* @__PURE__ */ jsxs(
|
|
11511
|
+
"tr",
|
|
11512
|
+
{
|
|
11513
|
+
className: "twc-dt__row",
|
|
11514
|
+
role: "row",
|
|
11515
|
+
"aria-rowindex": treeSeqByKey ? treeSeqByKey.get(k) + 2 : (paginated && !serverMode ? pageVal * sizeVal : 0) + ri + 2,
|
|
11516
|
+
"aria-selected": (checkboxSelection ? sel : rowActive) || void 0,
|
|
11517
|
+
"data-op": row.__diffop || void 0,
|
|
11518
|
+
"data-selected": sel || void 0,
|
|
11519
|
+
"data-active": rowActive || void 0,
|
|
11520
|
+
"data-pinned-row": pinSide || void 0,
|
|
11521
|
+
"data-reorderable": reorderable || void 0,
|
|
11522
|
+
"data-row-dragging": rowDrag.from === k || void 0,
|
|
11523
|
+
"data-row-grabbed": grabbed || void 0,
|
|
11524
|
+
"data-row-grabtarget": grabTarget,
|
|
11525
|
+
"data-row-dropbefore": reorderable && rowDrag.over === k && !rowDrag.after || void 0,
|
|
11526
|
+
"data-row-dropafter": reorderable && rowDrag.over === k && rowDrag.after || void 0,
|
|
11527
|
+
"data-vrow": virtualizing && midIdx != null ? String(k) : void 0,
|
|
11528
|
+
"data-selectable": selectionMode !== "none" || void 0,
|
|
11529
|
+
style: Object.keys(rowStyle).length ? rowStyle : void 0,
|
|
11530
|
+
draggable: reorderable || void 0,
|
|
11531
|
+
onDragStart: reorderable ? (e) => {
|
|
11532
|
+
setRowDrag({ from: k, over: null, after: false });
|
|
11533
|
+
e.dataTransfer.effectAllowed = "move";
|
|
11534
|
+
e.dataTransfer.setData("text/plain", String(k));
|
|
11535
|
+
} : void 0,
|
|
11536
|
+
onDragOver: reorderable && rowDrag.from != null ? (e) => {
|
|
11537
|
+
e.preventDefault();
|
|
11538
|
+
const r2 = e.currentTarget.getBoundingClientRect();
|
|
11539
|
+
const after = e.clientY > r2.top + r2.height / 2;
|
|
11540
|
+
setRowDrag((d) => d.over === k && d.after === after ? d : { ...d, over: k, after });
|
|
11541
|
+
} : void 0,
|
|
11542
|
+
onDrop: reorderable && rowDrag.from != null ? (e) => {
|
|
11543
|
+
e.preventDefault();
|
|
11544
|
+
onRowDrop(k);
|
|
11545
|
+
} : void 0,
|
|
11546
|
+
onDragEnd: reorderable ? () => setRowDrag({ from: null, over: null, after: false }) : void 0,
|
|
11547
|
+
onClick: (e) => handleRowClick(e, k, row),
|
|
11548
|
+
children: [
|
|
11549
|
+
hasExpandCol ? /* @__PURE__ */ jsx("td", { className: "twc-dt__td twc-dt__expand-cell", role: "gridcell", "data-pin": "left", "data-pin-edge": checkboxSelection || showRowNum || visLeft.length ? void 0 : "left", style: { insetInlineStart: 0, width: EXP_W }, children: expandable ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__expand-btn", "aria-expanded": open, "aria-controls": open && detail != null ? `${gridId}-detail-${ri}` : void 0, "aria-label": open ? "Collapse row" : "Expand row", onClick: (e) => {
|
|
11550
|
+
e.stopPropagation();
|
|
11551
|
+
toggleRowDetail(k);
|
|
11552
|
+
}, children: /* @__PURE__ */ jsx("span", { className: "twc-dt__expand-chev", "data-open": open || void 0, children: /* @__PURE__ */ jsx(Svg, { d: I.chevDown }) }) }) : null }) : null,
|
|
11553
|
+
checkboxSelection ? /* @__PURE__ */ jsxs("td", { className: "twc-dt__td", role: "gridcell", "data-pin": "left", "data-pin-edge": visLeft.length || showRowNum ? void 0 : "left", style: { insetInlineStart: EXP_W, width: CHK_W }, children: [
|
|
11554
|
+
/* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: 4 }, children: [
|
|
11555
|
+
reorderable ? rowHandle(k, midIdx, row) : null,
|
|
11556
|
+
/* @__PURE__ */ jsx(
|
|
11557
|
+
"span",
|
|
11558
|
+
{
|
|
11559
|
+
className: "twc-dt__check",
|
|
11560
|
+
"data-checked": sel || void 0,
|
|
11561
|
+
onClick: () => toggleRow(k),
|
|
11562
|
+
role: "checkbox",
|
|
11563
|
+
"aria-checked": sel,
|
|
11564
|
+
"aria-label": "Select row",
|
|
11565
|
+
tabIndex: 0,
|
|
11566
|
+
onKeyDown: (e) => {
|
|
11567
|
+
if (e.key === " " || e.key === "Enter") {
|
|
11568
|
+
e.preventDefault();
|
|
11569
|
+
toggleRow(k);
|
|
11570
|
+
}
|
|
11571
|
+
},
|
|
11572
|
+
children: /* @__PURE__ */ jsx(Svg, { d: I.check })
|
|
11573
|
+
}
|
|
11574
|
+
)
|
|
11575
|
+
] }),
|
|
11576
|
+
rowResize && !pinSide ? /* @__PURE__ */ jsx("span", { className: "twc-dt__row-resizer", title: "Drag to resize row", onPointerDown: (e) => startRowResize(e, k, e.currentTarget.closest("tr")), onClick: (e) => e.stopPropagation() }) : null
|
|
11577
|
+
] }) : null,
|
|
11578
|
+
showRowNum ? /* @__PURE__ */ jsx("td", { className: "twc-dt__td twc-dt__rownum", role: "gridcell", "aria-hidden": "true", "data-pin": "left", "data-pin-edge": visLeft.length ? void 0 : "left", style: { insetInlineStart: numLeft, width: NUM_W }, children: treeSeqByKey ? treeSeqByKey.get(k) + 1 : typeof ri === "number" ? (paginated || serverMode ? pageVal * sizeVal : 0) + ri + 1 : "" }) : null,
|
|
11579
|
+
ordered.map((c, ci) => {
|
|
11580
|
+
const st = stickyOf(c.field);
|
|
11581
|
+
const val = getColVal(c, row);
|
|
11582
|
+
const isActions = c.type === "actions";
|
|
11583
|
+
const editable = isColEditable(c);
|
|
11584
|
+
const isEditing = editing && editing.key === k && editing.field === c.field;
|
|
11585
|
+
const cellActive = selectionMode === "cell" && activeCell && activeCell.key === k && activeCell.field === c.field;
|
|
11586
|
+
const cellSelected = selectionMode === "cell" && cellRect && ri >= cellRect.r0 && ri <= cellRect.r1 && ci >= cellRect.c0 && ci <= cellRect.c1;
|
|
11587
|
+
const cellFlash = clipFx && clipFx.rect && ri >= clipFx.rect.r0 && ri <= clipFx.rect.r1 && ci >= clipFx.rect.c0 && ci <= clipFx.rect.c1;
|
|
11588
|
+
const cellId = selectionMode === "cell" ? `${gridId}-${ri}-${ci}` : void 0;
|
|
11589
|
+
const display = c.valueFormatter ? c.valueFormatter(val, row) : val;
|
|
11590
|
+
const cellTitle = !isActions && !c.renderCell && !isEditing && (typeof display === "string" || typeof display === "number") ? String(display) : void 0;
|
|
11591
|
+
const cellClass = c.cellClassName ? c.cellClassName(val, row) : void 0;
|
|
11592
|
+
const cellSty = c.cellStyle ? c.cellStyle(val, row) : void 0;
|
|
11593
|
+
return /* @__PURE__ */ jsxs(
|
|
11594
|
+
"td",
|
|
11465
11595
|
{
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
"
|
|
11471
|
-
"aria-
|
|
11472
|
-
tabIndex: 0,
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
"data-cell-selected": cellSelected || void 0,
|
|
11517
|
-
"data-copied": cellFlash || void 0,
|
|
11518
|
-
"data-wrap": effectiveWrapped.has(c.field) || void 0,
|
|
11519
|
-
"data-pin": st.pin,
|
|
11520
|
-
"data-pin-edge": st.edge,
|
|
11521
|
-
style: { width: widthOf(c), ...cellSty, ...st.style, ...st.pin ? { position: "sticky", zIndex: 2 } : null },
|
|
11522
|
-
"data-ovtext": cellTitle,
|
|
11523
|
-
onClick: selectionMode === "cell" ? (e) => handleCellClick(e, k, row, c) : void 0,
|
|
11524
|
-
onFocus: () => setFocus((f) => f.r === ri && f.c === ci ? f : { r: ri, c: ci }),
|
|
11525
|
-
onDoubleClick: editable ? () => beginEdit(k, c, row) : void 0,
|
|
11526
|
-
children: [
|
|
11527
|
-
!checkboxSelection && reorderable && ci === 0 && !isEditing ? /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, maxWidth: "100%" }, children: [
|
|
11528
|
-
rowHandle(k, midIdx, row),
|
|
11529
|
-
/* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis" }, children: isActions ? renderActions(c, row) : c.renderCell ? c.renderCell(val, row) : display })
|
|
11530
|
-
] }) : isEditing ? c.renderEditCell ? (
|
|
11531
|
-
// #236: full escape hatch — the host drops in its own editor (searchable/creatable/
|
|
11532
|
-
// async Combobox, …) and drives the lifecycle via commit/cancel. Wrapped in
|
|
11533
|
-
// .twc-dt__editor-wrap so inline clicks (and any .twc-pop portal dropdown) don't
|
|
11534
|
-
// trip the outside-click auto-cancel.
|
|
11535
|
-
// #273: the wrapper handles Escape → cancel so it works for every custom editor without
|
|
11536
|
-
// each having to wire a keydown (they only get commit/cancel). A custom control that
|
|
11537
|
-
// wants Escape itself (e.g. to close its own open dropdown) stops propagation first.
|
|
11538
|
-
/* @__PURE__ */ jsx(
|
|
11539
|
-
"div",
|
|
11596
|
+
id: cellId,
|
|
11597
|
+
className: cellClass ? `twc-dt__td ${cellClass}` : "twc-dt__td",
|
|
11598
|
+
role: "gridcell",
|
|
11599
|
+
"data-r": ri,
|
|
11600
|
+
"data-c": ci,
|
|
11601
|
+
"aria-colindex": ci + 1 + (checkboxSelection ? 1 : 0) + (hasExpandCol ? 1 : 0),
|
|
11602
|
+
tabIndex: focus.r === ri && focus.c === ci ? 0 : -1,
|
|
11603
|
+
"aria-selected": cellSelected || void 0,
|
|
11604
|
+
"data-num": c.type === "number" || void 0,
|
|
11605
|
+
"data-actions": isActions || void 0,
|
|
11606
|
+
"data-editable": editable && !isEditing || void 0,
|
|
11607
|
+
"data-editing": isEditing || void 0,
|
|
11608
|
+
"data-cell-active": cellActive || void 0,
|
|
11609
|
+
"data-cell-selected": cellSelected || void 0,
|
|
11610
|
+
"data-copied": cellFlash || void 0,
|
|
11611
|
+
"data-wrap": effectiveWrapped.has(c.field) || void 0,
|
|
11612
|
+
"data-pin": st.pin,
|
|
11613
|
+
"data-pin-edge": st.edge,
|
|
11614
|
+
style: { width: widthOf(c), ...cellSty, ...st.style, ...st.pin ? { position: "sticky", zIndex: 2 } : null, ...ci === 0 && depth ? { paddingInlineStart: `calc(12px + ${depth * 20}px)` } : null },
|
|
11615
|
+
"data-ovtext": cellTitle,
|
|
11616
|
+
onClick: selectionMode === "cell" ? (e) => handleCellClick(e, k, row, c) : void 0,
|
|
11617
|
+
onFocus: () => setFocus((f) => f.r === ri && f.c === ci ? f : { r: ri, c: ci }),
|
|
11618
|
+
onDoubleClick: editable ? () => beginEdit(k, c, row) : void 0,
|
|
11619
|
+
children: [
|
|
11620
|
+
!checkboxSelection && reorderable && ci === 0 && !isEditing ? /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, maxWidth: "100%" }, children: [
|
|
11621
|
+
rowHandle(k, midIdx, row),
|
|
11622
|
+
/* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis" }, children: isActions ? renderActions(c, row) : c.renderCell ? c.renderCell(val, row) : display })
|
|
11623
|
+
] }) : isEditing ? c.renderEditCell ? (
|
|
11624
|
+
// #236: full escape hatch — the host drops in its own editor (searchable/creatable/
|
|
11625
|
+
// async Combobox, …) and drives the lifecycle via commit/cancel. Wrapped in
|
|
11626
|
+
// .twc-dt__editor-wrap so inline clicks (and any .twc-pop portal dropdown) don't
|
|
11627
|
+
// trip the outside-click auto-cancel.
|
|
11628
|
+
// #273: the wrapper handles Escape → cancel so it works for every custom editor without
|
|
11629
|
+
// each having to wire a keydown (they only get commit/cancel). A custom control that
|
|
11630
|
+
// wants Escape itself (e.g. to close its own open dropdown) stops propagation first.
|
|
11631
|
+
/* @__PURE__ */ jsx(
|
|
11632
|
+
"div",
|
|
11633
|
+
{
|
|
11634
|
+
className: "twc-dt__editor-wrap",
|
|
11635
|
+
onKeyDown: (e) => {
|
|
11636
|
+
if (e.key === "Escape") {
|
|
11637
|
+
e.stopPropagation();
|
|
11638
|
+
cancelEdit();
|
|
11639
|
+
}
|
|
11640
|
+
},
|
|
11641
|
+
children: c.renderEditCell({ value: editing.value, row, field: c.field, commit: (v) => commitEdit(v), cancel: cancelEdit })
|
|
11642
|
+
}
|
|
11643
|
+
)
|
|
11644
|
+
) : /* @__PURE__ */ jsx(
|
|
11645
|
+
EditCell,
|
|
11540
11646
|
{
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11647
|
+
col: c,
|
|
11648
|
+
value: editing.value,
|
|
11649
|
+
options: c.valueOptions ? optionsForField(c.field) : null,
|
|
11650
|
+
onChange: (v) => setEditing((e) => ({ ...e, value: v })),
|
|
11651
|
+
onCommit: () => commitEdit(),
|
|
11652
|
+
onCommitValue: (v) => commitEdit(v),
|
|
11653
|
+
onCancel: cancelEdit,
|
|
11654
|
+
onKeyDown: onEditKey
|
|
11549
11655
|
}
|
|
11550
|
-
)
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
}
|
|
11563
|
-
) : isActions ? renderActions(c, row) : c.renderCell ? c.renderCell(val, row) : display,
|
|
11564
|
-
editable && !isEditing ? /* @__PURE__ */ jsx("span", { className: "twc-dt__edit-hint", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Svg, { d: I.pencil }) }) : null
|
|
11565
|
-
]
|
|
11566
|
-
},
|
|
11567
|
-
c.field
|
|
11568
|
-
);
|
|
11569
|
-
})
|
|
11570
|
-
]
|
|
11571
|
-
},
|
|
11572
|
-
(pinSide ? "p-" : "") + k
|
|
11573
|
-
);
|
|
11656
|
+
) : isActions ? renderActions(c, row) : c.renderCell ? c.renderCell(val, row) : display,
|
|
11657
|
+
editable && !isEditing ? /* @__PURE__ */ jsx("span", { className: "twc-dt__edit-hint", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Svg, { d: I.pencil }) }) : null
|
|
11658
|
+
]
|
|
11659
|
+
},
|
|
11660
|
+
c.field
|
|
11661
|
+
);
|
|
11662
|
+
})
|
|
11663
|
+
]
|
|
11664
|
+
}
|
|
11665
|
+
),
|
|
11666
|
+
open && detail != null ? /* @__PURE__ */ jsx("tr", { className: "twc-dt__detail-row", role: "row", children: /* @__PURE__ */ jsx("td", { id: `${gridId}-detail-${ri}`, className: "twc-dt__detail-cell", role: "gridcell", colSpan: totalCols, style: { maxWidth: "none" }, children: detail }) }) : null
|
|
11667
|
+
] }, (pinSide ? "p-" : "") + k);
|
|
11574
11668
|
}
|
|
11575
11669
|
function renderPivot() {
|
|
11576
11670
|
const rFields = pivotConfig.rows, cFields = pivotConfig.columns || [], values = pivotConfig.values;
|
|
@@ -11906,15 +12000,16 @@ function Datatable({
|
|
|
11906
12000
|
ref: gridRef,
|
|
11907
12001
|
role: "grid",
|
|
11908
12002
|
"aria-label": ariaLabelAttr || ariaLabel,
|
|
11909
|
-
"aria-rowcount": totalRows + 1,
|
|
11910
|
-
"aria-colcount": ordered.length + (checkboxSelection ? 1 : 0),
|
|
12003
|
+
"aria-rowcount": (treeSeqByKey ? treeSeqByKey.size : totalRows) + 1,
|
|
12004
|
+
"aria-colcount": ordered.length + (checkboxSelection ? 1 : 0) + (hasExpandCol ? 1 : 0),
|
|
11911
12005
|
"aria-multiselectable": selectionMode === "cell" || void 0,
|
|
11912
12006
|
"aria-activedescendant": activeCellId,
|
|
11913
12007
|
"aria-busy": loading || void 0,
|
|
11914
12008
|
onKeyDown: onGridKeyDown,
|
|
11915
12009
|
children: [
|
|
11916
12010
|
/* @__PURE__ */ jsx("thead", { ref: theadRef, children: /* @__PURE__ */ jsxs("tr", { role: "row", "aria-rowindex": 1, children: [
|
|
11917
|
-
|
|
12011
|
+
hasExpandCol ? /* @__PURE__ */ jsx("th", { className: "twc-dt__th twc-dt__expand-cell", role: "columnheader", "aria-label": "Expand", "data-pin": "left", "data-pin-edge": checkboxSelection || showRowNum || visLeft.length ? void 0 : "left", style: { insetInlineStart: 0, width: EXP_W, minWidth: EXP_W } }) : null,
|
|
12012
|
+
checkboxSelection ? /* @__PURE__ */ jsx("th", { className: "twc-dt__th", role: "columnheader", "aria-label": "Select", "data-pin": "left", "data-pin-edge": visLeft.length || showRowNum ? void 0 : "left", style: { insetInlineStart: EXP_W, width: CHK_W, minWidth: CHK_W }, children: /* @__PURE__ */ jsx("div", { className: "twc-dt__th-inner", style: { justifyContent: "center", padding: 0 }, children: /* @__PURE__ */ jsx(
|
|
11918
12013
|
"span",
|
|
11919
12014
|
{
|
|
11920
12015
|
className: "twc-dt__check",
|
|
@@ -12090,7 +12185,8 @@ function Datatable({
|
|
|
12090
12185
|
})
|
|
12091
12186
|
] }) }),
|
|
12092
12187
|
/* @__PURE__ */ jsx("tbody", { children: loading ? Array.from({ length: paginated ? Math.min(sizeVal, 8) : 8 }).map((_, ri) => /* @__PURE__ */ jsxs("tr", { className: "twc-dt__row", role: "row", children: [
|
|
12093
|
-
|
|
12188
|
+
hasExpandCol ? /* @__PURE__ */ jsx("td", { className: "twc-dt__td twc-dt__expand-cell", role: "gridcell", "data-pin": "left", style: { insetInlineStart: 0, width: EXP_W } }) : null,
|
|
12189
|
+
checkboxSelection ? /* @__PURE__ */ jsx("td", { className: "twc-dt__td", role: "gridcell", "data-pin": "left", style: { insetInlineStart: EXP_W, width: CHK_W }, children: /* @__PURE__ */ jsx("span", { className: "twc-dt__sk", "aria-hidden": "true", style: { "--_w": "18px", height: 18, borderRadius: 4 } }) }) : null,
|
|
12094
12190
|
showRowNum ? /* @__PURE__ */ jsx("td", { className: "twc-dt__td twc-dt__rownum", role: "gridcell", "aria-hidden": "true", "data-pin": "left", style: { insetInlineStart: numLeft, width: NUM_W }, children: /* @__PURE__ */ jsx("span", { className: "twc-dt__sk", "aria-hidden": "true", style: { "--_w": "16px", height: 14, borderRadius: 4 } }) }) : null,
|
|
12095
12191
|
ordered.map((c, ci) => {
|
|
12096
12192
|
const st = stickyOf(c.field);
|
|
@@ -12112,7 +12208,8 @@ function Datatable({
|
|
|
12112
12208
|
pinnedBottomRows.map((row) => renderLeaf(row, keyIndex.get(keyOf(row)), "bottom"))
|
|
12113
12209
|
] }) }),
|
|
12114
12210
|
hasAggregation && aggOn && !loading && paged.length > 0 ? /* @__PURE__ */ jsx("tfoot", { children: /* @__PURE__ */ jsxs("tr", { role: "row", children: [
|
|
12115
|
-
|
|
12211
|
+
hasExpandCol ? /* @__PURE__ */ jsx("td", { role: "gridcell", "data-pin": "left", "data-pin-edge": checkboxSelection || showRowNum || visLeft.length ? void 0 : "left", style: { insetInlineStart: 0, width: EXP_W } }) : null,
|
|
12212
|
+
checkboxSelection ? /* @__PURE__ */ jsx("td", { role: "gridcell", "data-pin": "left", "data-pin-edge": visLeft.length || showRowNum ? void 0 : "left", style: { insetInlineStart: EXP_W, width: CHK_W } }) : null,
|
|
12116
12213
|
showRowNum ? /* @__PURE__ */ jsx("td", { className: "twc-dt__rownum", role: "gridcell", "aria-hidden": "true", "data-pin": "left", "data-pin-edge": visLeft.length ? void 0 : "left", style: { insetInlineStart: numLeft, width: NUM_W } }) : null,
|
|
12117
12214
|
ordered.map((c) => {
|
|
12118
12215
|
const st = stickyOf(c.field);
|
|
@@ -17147,6 +17244,18 @@ var SLIDER_CSS = `
|
|
|
17147
17244
|
transition: opacity var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-spring);
|
|
17148
17245
|
}
|
|
17149
17246
|
.twc-slider__track[data-show-bubble="true"] .twc-slider__bubble { opacity: 1; transform: translateX(-50%) scale(1); }
|
|
17247
|
+
/* #351: editable numeric inputs (manual entry, synced with the thumbs) */
|
|
17248
|
+
.twc-slider__inputs { display: inline-flex; align-items: center; gap: var(--space-1-5); }
|
|
17249
|
+
.twc-slider__input-sep { color: var(--color-text-muted); font-weight: var(--font-semibold); }
|
|
17250
|
+
.twc-slider__input {
|
|
17251
|
+
min-width: 0; text-align: end; font-family: inherit; font-size: var(--text-sm); font-weight: var(--font-semibold);
|
|
17252
|
+
color: var(--_accent); font-variant-numeric: tabular-nums;
|
|
17253
|
+
padding: 2px 6px; border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface);
|
|
17254
|
+
transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
|
|
17255
|
+
}
|
|
17256
|
+
.twc-slider__input:hover:not(:disabled) { border-color: var(--color-border-strong); }
|
|
17257
|
+
.twc-slider__input:focus-visible { outline: none; border-color: var(--_accent); box-shadow: var(--ring); }
|
|
17258
|
+
.twc-slider[data-disabled="true"] .twc-slider__input { cursor: not-allowed; }
|
|
17150
17259
|
`;
|
|
17151
17260
|
function Slider({
|
|
17152
17261
|
label,
|
|
@@ -17165,6 +17274,7 @@ function Slider({
|
|
|
17165
17274
|
range: range2 = false,
|
|
17166
17275
|
showValue = true,
|
|
17167
17276
|
showTicks = false,
|
|
17277
|
+
editable = false,
|
|
17168
17278
|
formatValue,
|
|
17169
17279
|
getAriaValueText,
|
|
17170
17280
|
name,
|
|
@@ -17203,6 +17313,7 @@ function Slider({
|
|
|
17203
17313
|
const indices = isRange ? [0, 1] : [0];
|
|
17204
17314
|
const trackRef = React51__default.useRef(null);
|
|
17205
17315
|
const [dragging, setDragging] = React51__default.useState(false);
|
|
17316
|
+
const [typed, setTyped] = React51__default.useState({});
|
|
17206
17317
|
const fmt = (v) => formatValue ? formatValue(v) : v.toFixed(decimals);
|
|
17207
17318
|
const valueTextFor = (v) => {
|
|
17208
17319
|
if (getAriaValueText) return getAriaValueText(v);
|
|
@@ -17226,6 +17337,27 @@ function Slider({
|
|
|
17226
17337
|
}
|
|
17227
17338
|
commit(next);
|
|
17228
17339
|
};
|
|
17340
|
+
const commitInput = (i) => {
|
|
17341
|
+
const s = typed[i];
|
|
17342
|
+
setTyped((t) => {
|
|
17343
|
+
const n = { ...t };
|
|
17344
|
+
delete n[i];
|
|
17345
|
+
return n;
|
|
17346
|
+
});
|
|
17347
|
+
if (s == null || String(s).trim() === "") return;
|
|
17348
|
+
const num = parseFloat(s);
|
|
17349
|
+
if (Number.isFinite(num)) setThumb(i, num);
|
|
17350
|
+
};
|
|
17351
|
+
const stepInput = (i, dir) => {
|
|
17352
|
+
const base = typed[i] != null && Number.isFinite(parseFloat(typed[i])) ? parseFloat(typed[i]) : clampedVals[i];
|
|
17353
|
+
setTyped((t) => {
|
|
17354
|
+
const n = { ...t };
|
|
17355
|
+
delete n[i];
|
|
17356
|
+
return n;
|
|
17357
|
+
});
|
|
17358
|
+
setThumb(i, base + dir * step);
|
|
17359
|
+
};
|
|
17360
|
+
const inputSize = Math.max(String(min).length, String(max).length, decimals > 0 ? decimals + 2 : 1) + 1;
|
|
17229
17361
|
const fromClientX = (clientX) => {
|
|
17230
17362
|
const node = trackRef.current;
|
|
17231
17363
|
if (!node) return clampedVals[0];
|
|
@@ -17281,9 +17413,40 @@ function Slider({
|
|
|
17281
17413
|
return /* @__PURE__ */ jsxs("div", { className: `twc-slider ${className}`, "data-tone": tone, "data-size": size, "data-disabled": disabled || void 0, ...rest, children: [
|
|
17282
17414
|
__twcStyles,
|
|
17283
17415
|
name ? clampedVals.map((v, i) => /* @__PURE__ */ jsx("input", { type: "hidden", name, value: v, disabled: disabled || void 0 }, i)) : null,
|
|
17284
|
-
label || showValue ? /* @__PURE__ */ jsxs("div", { className: "twc-slider__head", children: [
|
|
17416
|
+
label || showValue || editable ? /* @__PURE__ */ jsxs("div", { className: "twc-slider__head", children: [
|
|
17285
17417
|
label ? /* @__PURE__ */ jsx("label", { className: "twc-slider__label", id: labelId, children: label }) : /* @__PURE__ */ jsx("span", {}),
|
|
17286
|
-
|
|
17418
|
+
editable ? /* @__PURE__ */ jsx("span", { className: "twc-slider__inputs", children: indices.map((i) => /* @__PURE__ */ jsxs(React51__default.Fragment, { children: [
|
|
17419
|
+
i > 0 ? /* @__PURE__ */ jsx("span", { className: "twc-slider__input-sep", "aria-hidden": "true", children: "\u2013" }) : null,
|
|
17420
|
+
/* @__PURE__ */ jsx(
|
|
17421
|
+
"input",
|
|
17422
|
+
{
|
|
17423
|
+
className: "twc-slider__input",
|
|
17424
|
+
type: "text",
|
|
17425
|
+
inputMode: min < 0 ? "text" : "decimal",
|
|
17426
|
+
size: inputSize,
|
|
17427
|
+
value: typed[i] != null ? typed[i] : String(clampedVals[i]),
|
|
17428
|
+
disabled: disabled || void 0,
|
|
17429
|
+
"aria-labelledby": isRange ? void 0 : labelId,
|
|
17430
|
+
"aria-label": isRange ? i === 0 ? "Minimum value" : "Maximum value" : labelId ? void 0 : "Value",
|
|
17431
|
+
onChange: (e) => setTyped((t) => ({ ...t, [i]: e.target.value })),
|
|
17432
|
+
onBlur: () => commitInput(i),
|
|
17433
|
+
onKeyDown: (e) => {
|
|
17434
|
+
if (e.key === "Enter") {
|
|
17435
|
+
if (typed[i] != null) {
|
|
17436
|
+
e.preventDefault();
|
|
17437
|
+
commitInput(i);
|
|
17438
|
+
}
|
|
17439
|
+
} else if (e.key === "ArrowUp") {
|
|
17440
|
+
e.preventDefault();
|
|
17441
|
+
stepInput(i, 1);
|
|
17442
|
+
} else if (e.key === "ArrowDown") {
|
|
17443
|
+
e.preventDefault();
|
|
17444
|
+
stepInput(i, -1);
|
|
17445
|
+
}
|
|
17446
|
+
}
|
|
17447
|
+
}
|
|
17448
|
+
)
|
|
17449
|
+
] }, i)) }) : showValue ? /* @__PURE__ */ jsx("span", { className: "twc-slider__value", children: headValue }) : null
|
|
17287
17450
|
] }) : null,
|
|
17288
17451
|
/* @__PURE__ */ jsxs("div", { className: "twc-slider__track", ref: trackRef, "data-show-bubble": dragging || void 0, onPointerDown, children: [
|
|
17289
17452
|
/* @__PURE__ */ jsx("div", { className: "twc-slider__rail" }),
|