twico-ui 1.31.1 → 1.32.1
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 +22 -0
- package/dist/index.cjs +378 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.mjs +378 -53
- package/dist/index.mjs.map +1 -1
- package/llms.txt +5 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -5867,6 +5867,7 @@ function Combobox({
|
|
|
5867
5867
|
setQuery("");
|
|
5868
5868
|
}
|
|
5869
5869
|
function commit(v) {
|
|
5870
|
+
if (disabled) return;
|
|
5870
5871
|
const o = flat.find((x) => x.value === v);
|
|
5871
5872
|
if (o && o.disabled) return;
|
|
5872
5873
|
if (value === void 0) setInternal(v);
|
|
@@ -6043,7 +6044,7 @@ function Combobox({
|
|
|
6043
6044
|
...rest
|
|
6044
6045
|
}
|
|
6045
6046
|
),
|
|
6046
|
-
clearable && selected && !open ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-cb__clear", "aria-label": "Clear", onClick: (e) => {
|
|
6047
|
+
clearable && selected && !open && !disabled ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-cb__clear", "aria-label": "Clear", onClick: (e) => {
|
|
6047
6048
|
e.stopPropagation();
|
|
6048
6049
|
commit(null);
|
|
6049
6050
|
}, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) }) }) : null,
|
|
@@ -7333,6 +7334,7 @@ var MULTI_CSS = `
|
|
|
7333
7334
|
background: var(--_accent-subtle); color: var(--_accent-subtle-fg);
|
|
7334
7335
|
border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--font-semibold);
|
|
7335
7336
|
}
|
|
7337
|
+
.twc-ms__control[data-disabled="true"] .twc-ms__chip { padding-inline-end: 9px; } /* #342: no \u2715 \u2192 symmetric pad */
|
|
7336
7338
|
.twc-ms__chip-x { display: inline-grid; place-items: center; width: 16px; height: 16px; border: none; padding: 0; background: transparent; color: inherit; cursor: pointer; border-radius: var(--radius-full); opacity: 0.7; }
|
|
7337
7339
|
.twc-ms__chip-x:hover { opacity: 1; background: color-mix(in srgb, currentColor 18%, transparent); }
|
|
7338
7340
|
.twc-ms__chip-x svg { width: 12px; height: 12px; }
|
|
@@ -7575,6 +7577,7 @@ function MultiSelect({
|
|
|
7575
7577
|
setScrollTop(next);
|
|
7576
7578
|
}, [active, open, virtualized, rows, listH]);
|
|
7577
7579
|
function commit(next) {
|
|
7580
|
+
if (disabled) return;
|
|
7578
7581
|
if (value === void 0) setInternal(next);
|
|
7579
7582
|
onChange?.(next);
|
|
7580
7583
|
}
|
|
@@ -7731,10 +7734,10 @@ function MultiSelect({
|
|
|
7731
7734
|
children: [
|
|
7732
7735
|
(maxTagCount != null ? selectedOpts.slice(0, maxTagCount) : selectedOpts).map((o) => /* @__PURE__ */ jsxs("span", { className: "twc-ms__chip", children: [
|
|
7733
7736
|
o.label,
|
|
7734
|
-
/* @__PURE__ */ jsx("button", { type: "button", tabIndex: -1, className: "twc-ms__chip-x", "aria-label": `Remove ${o.label}`, onClick: (e) => {
|
|
7737
|
+
!disabled ? /* @__PURE__ */ jsx("button", { type: "button", tabIndex: -1, className: "twc-ms__chip-x", "aria-label": `Remove ${o.label}`, onClick: (e) => {
|
|
7735
7738
|
e.stopPropagation();
|
|
7736
7739
|
toggle(o.value);
|
|
7737
|
-
}, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.6", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) }) })
|
|
7740
|
+
}, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.6", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) }) }) : null
|
|
7738
7741
|
] }, o.value)),
|
|
7739
7742
|
maxTagCount != null && selectedOpts.length > maxTagCount ? /* @__PURE__ */ jsxs("span", { className: "twc-ms__more", title: selectedOpts.slice(maxTagCount).map((o) => o.label).join(", "), children: [
|
|
7740
7743
|
"+",
|
|
@@ -7787,8 +7790,10 @@ function MultiSelect({
|
|
|
7787
7790
|
tabIndex: -1,
|
|
7788
7791
|
onClick: (e) => {
|
|
7789
7792
|
e.stopPropagation();
|
|
7790
|
-
|
|
7791
|
-
|
|
7793
|
+
if (!disabled) {
|
|
7794
|
+
setOpen((o) => !o);
|
|
7795
|
+
inputRef.current?.focus();
|
|
7796
|
+
}
|
|
7792
7797
|
},
|
|
7793
7798
|
children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" }) })
|
|
7794
7799
|
}
|
|
@@ -8432,7 +8437,13 @@ var DT_CSS = `
|
|
|
8432
8437
|
/* #244: batch editor = pick columns (searchable), then set a value for each. */
|
|
8433
8438
|
.twc-dt__be-add { padding: 6px 6px 8px; border-bottom: var(--border-thin) solid var(--color-divider); }
|
|
8434
8439
|
.twc-dt__be-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; }
|
|
8435
|
-
|
|
8440
|
+
/* #341: cap width at min(260, row \u2212 160px) so the value control keeps ~120px (+ gaps + remove) and never
|
|
8441
|
+
collapses \u2014 panel-width-aware in pure CSS, so it also grows if the (resizable) panel is widened. */
|
|
8442
|
+
.twc-dt__be-name { position: relative; flex: none; width: clamp(88px, var(--twc-dt-be-name-usr, 108px), min(260px, 100% - 160px)); font-size: var(--text-sm); color: var(--color-text); }
|
|
8443
|
+
/* #341: ellipsis lives on the inner text span so the outer field can host the (edge-overhanging) resize handle without clipping it. */
|
|
8444
|
+
.twc-dt__be-name-txt { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
8445
|
+
/* #341: reveal the batch-name resize handle (reused .twc-dt__f-rz) on row hover, like the filter fields. */
|
|
8446
|
+
.twc-dt__be-row:hover .twc-dt__f-rz { opacity: 1; }
|
|
8436
8447
|
.twc-dt__be-ctl { flex: 1; min-width: 0; }
|
|
8437
8448
|
.twc-dt__be-x { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; border: none;
|
|
8438
8449
|
background: transparent; color: var(--color-text-subtle); cursor: pointer; border-radius: var(--radius-sm);
|
|
@@ -8497,6 +8508,19 @@ var DT_CSS = `
|
|
|
8497
8508
|
clipping to one line. height stays a per-row minimum, so single-line cells are unchanged. */
|
|
8498
8509
|
.twc-dt__td[data-wrap="true"] { white-space: normal; overflow: hidden; text-overflow: clip;
|
|
8499
8510
|
word-break: break-word; overflow-wrap: anywhere; vertical-align: top; padding-block: 10px; line-height: 1.45; }
|
|
8511
|
+
/* #338: "combined" column cell \u2014 one column showing several source columns' values. */
|
|
8512
|
+
.twc-dt__combine--stack { display: flex; flex-direction: column; gap: 1px; }
|
|
8513
|
+
.twc-dt__combine-sep { color: var(--color-text-subtle); padding-inline: 3px; }
|
|
8514
|
+
.twc-dt__combine-label { color: var(--color-text-muted); font-weight: var(--font-medium); }
|
|
8515
|
+
/* #339: the runtime combine-columns editor panel. */
|
|
8516
|
+
.twc-dt__combine-hint { padding: 2px 12px 8px; font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
8517
|
+
.twc-dt__combine-opts { padding: 8px 12px; border-top: var(--border-thin) solid var(--color-divider); display: flex; flex-direction: column; gap: 8px; }
|
|
8518
|
+
.twc-dt__combine-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: var(--text-sm); color: var(--color-text); }
|
|
8519
|
+
.twc-dt__combine-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: var(--border-thin) solid var(--color-divider); }
|
|
8520
|
+
.twc-dt__combine-apply { border: none; background: var(--color-primary); color: var(--color-primary-fg); font-family: inherit; font-size: var(--text-sm); font-weight: var(--font-semibold); padding: 6px 14px; border-radius: var(--radius-md); cursor: pointer; }
|
|
8521
|
+
.twc-dt__combine-apply:hover { opacity: 0.9; }
|
|
8522
|
+
.twc-dt__combine-apply:focus-visible { outline: none; box-shadow: var(--ring); }
|
|
8523
|
+
.twc-dt__col-combined { color: var(--color-text-subtle); font-size: var(--text-xs); font-style: italic; }
|
|
8500
8524
|
.twc-dt__td[data-num="true"] { text-align: end; font-variant-numeric: tabular-nums; }
|
|
8501
8525
|
/* Auto row-number gutter (rowNumbers) \u2014 a sticky-left ordinal column. */
|
|
8502
8526
|
.twc-dt__rownum { text-align: end; font-variant-numeric: tabular-nums; color: var(--color-text-subtle);
|
|
@@ -8831,6 +8855,34 @@ function mergeColOrder(saved, propFields) {
|
|
|
8831
8855
|
return result;
|
|
8832
8856
|
}
|
|
8833
8857
|
var getColVal = (col, row) => col && col.valueGetter ? col.valueGetter(row) : row == null ? void 0 : row[col && col.field];
|
|
8858
|
+
function combineCfg(combine) {
|
|
8859
|
+
if (!combine) return null;
|
|
8860
|
+
const cfg = Array.isArray(combine) ? { fields: combine } : combine;
|
|
8861
|
+
const fields = Array.isArray(cfg.fields) ? cfg.fields.filter((f) => f != null) : [];
|
|
8862
|
+
if (!fields.length) return null;
|
|
8863
|
+
return { fields, separator: cfg.separator != null ? cfg.separator : " \xB7 ", labels: !!cfg.labels, layout: cfg.layout === "stack" ? "stack" : "inline" };
|
|
8864
|
+
}
|
|
8865
|
+
var combineSrcCols = (cfg, byField) => cfg.fields.map((f) => byField && byField[f] || { field: f, headerName: String(f) });
|
|
8866
|
+
var combineValueGetter = (srcCols, cfg) => (row) => srcCols.map((sc) => {
|
|
8867
|
+
const v = getColVal(sc, row);
|
|
8868
|
+
const s = v == null ? "" : String(v);
|
|
8869
|
+
return cfg.labels && s ? `${sc.headerName ?? sc.field}: ${s}` : s;
|
|
8870
|
+
}).filter(Boolean).join(cfg.separator);
|
|
8871
|
+
function renderCombined(srcCols, row, cfg) {
|
|
8872
|
+
const nodes = [];
|
|
8873
|
+
let count = 0;
|
|
8874
|
+
srcCols.forEach((sc, idx) => {
|
|
8875
|
+
const v = getColVal(sc, row);
|
|
8876
|
+
if (v == null || v === "") return;
|
|
8877
|
+
const disp = sc.valueFormatter ? sc.valueFormatter(v, row) : v;
|
|
8878
|
+
const label = cfg.labels ? React51__default.createElement("span", { className: "twc-dt__combine-label" }, (sc.headerName ?? sc.field) + ": ") : null;
|
|
8879
|
+
if (count > 0 && cfg.layout !== "stack") nodes.push(React51__default.createElement("span", { key: "sep" + idx, className: "twc-dt__combine-sep", "aria-hidden": "true" }, cfg.separator));
|
|
8880
|
+
nodes.push(React51__default.createElement("span", { key: idx, className: "twc-dt__combine-item" }, label, disp));
|
|
8881
|
+
count++;
|
|
8882
|
+
});
|
|
8883
|
+
if (!nodes.length) return "";
|
|
8884
|
+
return React51__default.createElement("span", { className: cfg.layout === "stack" ? "twc-dt__combine twc-dt__combine--stack" : "twc-dt__combine" }, nodes);
|
|
8885
|
+
}
|
|
8834
8886
|
var diffValueNode = (col, v, row) => col.renderCell ? col.renderCell(v, row) : col.valueFormatter ? col.valueFormatter(v, row) : v == null ? "" : v;
|
|
8835
8887
|
function renderDiffCell(col, val, row) {
|
|
8836
8888
|
const meta = row && row.__diffMeta;
|
|
@@ -9211,6 +9263,7 @@ function Datatable({
|
|
|
9211
9263
|
aggregationValues = null,
|
|
9212
9264
|
disableColumnReorder = false,
|
|
9213
9265
|
disableColumnResize = false,
|
|
9266
|
+
columnCombining = false,
|
|
9214
9267
|
emptyMessage,
|
|
9215
9268
|
renderEmpty,
|
|
9216
9269
|
editMode = false,
|
|
@@ -9277,9 +9330,19 @@ function Datatable({
|
|
|
9277
9330
|
if (diffData && onClassifiedRef.current) onClassifiedRef.current(diffData.counts);
|
|
9278
9331
|
}, [diffData]);
|
|
9279
9332
|
const diffRowKeyFn = React51__default.useCallback((r2) => r2.__diffKey, []);
|
|
9333
|
+
const [userCombine, setUserCombine] = React51__default.useState({});
|
|
9280
9334
|
const columns = React51__default.useMemo(
|
|
9281
|
-
() =>
|
|
9282
|
-
|
|
9335
|
+
() => {
|
|
9336
|
+
if (!isDiff) return columnsProp;
|
|
9337
|
+
const byField = {};
|
|
9338
|
+
for (const c of columnsProp) if (c && c.field != null) byField[c.field] = c;
|
|
9339
|
+
return [DIFF_OP_COLUMN, ...columnsProp.map((c) => {
|
|
9340
|
+
const cfg = combineCfg(userCombine[c.field] || c.combine);
|
|
9341
|
+
const base = cfg && !c.valueGetter ? { ...c, valueGetter: combineValueGetter(combineSrcCols(cfg, byField), cfg) } : c;
|
|
9342
|
+
return { ...base, renderCell: (val, row) => renderDiffCell(base, val, row) };
|
|
9343
|
+
})];
|
|
9344
|
+
},
|
|
9345
|
+
[isDiff, columnsProp, userCombine]
|
|
9283
9346
|
);
|
|
9284
9347
|
const rows = React51__default.useMemo(
|
|
9285
9348
|
() => isDiff ? diffData.rows.filter((r2) => !diffOnly || r2.op !== "unchanged").map((r2) => ({ ...r2.to || r2.from, __diffop: r2.op, __diffMeta: r2, __diffKey: r2.key })) : rowsProp,
|
|
@@ -9319,8 +9382,26 @@ function Datatable({
|
|
|
9319
9382
|
getActions: () => []
|
|
9320
9383
|
});
|
|
9321
9384
|
}
|
|
9385
|
+
const byField = {};
|
|
9386
|
+
for (const c of out) if (c.field != null) byField[c.field] = c;
|
|
9387
|
+
for (let i = 0; i < out.length; i++) {
|
|
9388
|
+
const c = out[i];
|
|
9389
|
+
const cfg = combineCfg(userCombine[c.field] || c.combine);
|
|
9390
|
+
if (!cfg) continue;
|
|
9391
|
+
const srcCols = combineSrcCols(cfg, byField);
|
|
9392
|
+
out[i] = {
|
|
9393
|
+
...c,
|
|
9394
|
+
editable: false,
|
|
9395
|
+
// the combined value is synthetic — inline editing would write to a phantom field
|
|
9396
|
+
valueGetter: c.valueGetter || combineValueGetter(srcCols, cfg),
|
|
9397
|
+
// Consumer renderCell wins. If they overrode only valueGetter, fall back to the DEFAULT cell render
|
|
9398
|
+
// (renderCell: undefined) so the cell shows THEIR value — keeping display in sync with what
|
|
9399
|
+
// sort/filter/search/export use — rather than the auto source-join. Otherwise render the combined cell.
|
|
9400
|
+
renderCell: c.renderCell || (c.valueGetter ? void 0 : ((value, row) => renderCombined(srcCols, row, cfg)))
|
|
9401
|
+
};
|
|
9402
|
+
}
|
|
9322
9403
|
return out;
|
|
9323
|
-
}, [columns, rowPinning]);
|
|
9404
|
+
}, [columns, rowPinning, userCombine]);
|
|
9324
9405
|
const _autoKey = React51__default.useRef();
|
|
9325
9406
|
if (!_autoKey.current) _autoKey.current = { map: /* @__PURE__ */ new WeakMap(), n: 0 };
|
|
9326
9407
|
const keyOf = rowKey || ((r2, i) => {
|
|
@@ -9354,6 +9435,42 @@ function Datatable({
|
|
|
9354
9435
|
n.has(field) ? n.delete(field) : n.add(field);
|
|
9355
9436
|
return n;
|
|
9356
9437
|
});
|
|
9438
|
+
const openCombineEditor = (field) => {
|
|
9439
|
+
const existing = userCombine[field];
|
|
9440
|
+
setCombineTarget(field);
|
|
9441
|
+
setCombineDraft({
|
|
9442
|
+
selected: existing ? existing.fields.filter((f) => f !== field) : [],
|
|
9443
|
+
layout: existing && existing.layout === "stack" ? "stack" : "inline",
|
|
9444
|
+
labels: !!(existing && existing.labels)
|
|
9445
|
+
});
|
|
9446
|
+
};
|
|
9447
|
+
const closeCombineEditor = () => {
|
|
9448
|
+
setPanel(null);
|
|
9449
|
+
closePanel();
|
|
9450
|
+
setCombineTarget(null);
|
|
9451
|
+
setCombineDraft(null);
|
|
9452
|
+
restoreTriggerFocus();
|
|
9453
|
+
};
|
|
9454
|
+
const applyCombine = () => {
|
|
9455
|
+
if (!combineTarget || !combineDraft) return;
|
|
9456
|
+
const field = combineTarget;
|
|
9457
|
+
const sources = combineDraft.selected.filter((f) => f !== field);
|
|
9458
|
+
setUserCombine((m) => {
|
|
9459
|
+
const next = { ...m };
|
|
9460
|
+
if (sources.length) next[field] = { fields: [field, ...sources], layout: combineDraft.layout === "stack" ? "stack" : "inline", separator: " \xB7 ", labels: !!combineDraft.labels };
|
|
9461
|
+
else delete next[field];
|
|
9462
|
+
return next;
|
|
9463
|
+
});
|
|
9464
|
+
closeCombineEditor();
|
|
9465
|
+
};
|
|
9466
|
+
const uncombine = (field) => {
|
|
9467
|
+
setUserCombine((m) => {
|
|
9468
|
+
const next = { ...m };
|
|
9469
|
+
delete next[field];
|
|
9470
|
+
return next;
|
|
9471
|
+
});
|
|
9472
|
+
closeCombineEditor();
|
|
9473
|
+
};
|
|
9357
9474
|
const [pins, setPins] = React51__default.useState(() => {
|
|
9358
9475
|
const left = [], right = [];
|
|
9359
9476
|
columns.forEach((c) => {
|
|
@@ -9415,6 +9532,7 @@ function Datatable({
|
|
|
9415
9532
|
const rowFocusRef = React51__default.useRef(null);
|
|
9416
9533
|
const [fWidths, setFWidths] = React51__default.useState({});
|
|
9417
9534
|
const [fPanelSize, setFPanelSize] = React51__default.useState(null);
|
|
9535
|
+
const [batchNameW, setBatchNameW] = React51__default.useState(null);
|
|
9418
9536
|
const [popSizes, setPopSizes] = React51__default.useState({});
|
|
9419
9537
|
const serializeState = () => ({
|
|
9420
9538
|
filters: filters.map(({ id, ...f }) => f),
|
|
@@ -9435,7 +9553,11 @@ function Datatable({
|
|
|
9435
9553
|
filterPanelSize: fPanelSize || void 0,
|
|
9436
9554
|
filterFieldWidths: fWidths.col != null || fWidths.op != null || fWidths.val != null || fWidths.logic != null ? fWidths : void 0,
|
|
9437
9555
|
// #304: additive, optional — user-resized sizes of the other toolbar popovers, keyed by popover id.
|
|
9438
|
-
popoverSizes: Object.keys(popSizes).length ? popSizes : void 0
|
|
9556
|
+
popoverSizes: Object.keys(popSizes).length ? popSizes : void 0,
|
|
9557
|
+
// #339: additive, optional — runtime user-defined combined columns, keyed by target field.
|
|
9558
|
+
columnCombine: Object.keys(userCombine).length ? userCombine : void 0,
|
|
9559
|
+
// #341: additive, optional — user-resized batch-editor column-name field width (px).
|
|
9560
|
+
batchNameWidth: batchNameW != null ? batchNameW : void 0
|
|
9439
9561
|
});
|
|
9440
9562
|
const applyState = (s) => {
|
|
9441
9563
|
if (!s || typeof s !== "object") return;
|
|
@@ -9480,6 +9602,16 @@ function Datatable({
|
|
|
9480
9602
|
}
|
|
9481
9603
|
if (Object.keys(next).length) setPopSizes(next);
|
|
9482
9604
|
}
|
|
9605
|
+
if (s.columnCombine && typeof s.columnCombine === "object") {
|
|
9606
|
+
const uc = {};
|
|
9607
|
+
for (const [f, cfg] of Object.entries(s.columnCombine)) {
|
|
9608
|
+
if (!known.has(f) || !cfg || !Array.isArray(cfg.fields)) continue;
|
|
9609
|
+
const rest2 = cfg.fields.filter((x) => known.has(x) && x !== f);
|
|
9610
|
+
if (rest2.length) uc[f] = { fields: [f, ...rest2], layout: cfg.layout === "stack" ? "stack" : "inline", separator: typeof cfg.separator === "string" ? cfg.separator : " \xB7 ", labels: !!cfg.labels };
|
|
9611
|
+
}
|
|
9612
|
+
if (Object.keys(uc).length) setUserCombine(uc);
|
|
9613
|
+
}
|
|
9614
|
+
if (typeof s.batchNameWidth === "number") setBatchNameW(clampNum(s.batchNameWidth, 88, 260));
|
|
9483
9615
|
};
|
|
9484
9616
|
const stateReadyRef = React51__default.useRef(false);
|
|
9485
9617
|
const stateRestoredRef = React51__default.useRef(false);
|
|
@@ -9497,7 +9629,7 @@ function Datatable({
|
|
|
9497
9629
|
}
|
|
9498
9630
|
}
|
|
9499
9631
|
return void 0;
|
|
9500
|
-
}, [filters, filterLogic, sort, quick, pageVal, sizeVal, order, widths, hidden, pins, density, fWidths, fPanelSize, popSizes, stateKey]);
|
|
9632
|
+
}, [filters, filterLogic, sort, quick, pageVal, sizeVal, order, widths, hidden, pins, density, fWidths, fPanelSize, popSizes, userCombine, batchNameW, stateKey]);
|
|
9501
9633
|
const restoreState = () => {
|
|
9502
9634
|
let saved = null;
|
|
9503
9635
|
if (stateKey) {
|
|
@@ -9638,6 +9770,15 @@ function Datatable({
|
|
|
9638
9770
|
const [menuPos, openMenu, closeMenu] = useFloating();
|
|
9639
9771
|
const [panel, setPanel] = React51__default.useState(null);
|
|
9640
9772
|
const [panelPos, openPanel, closePanel] = useFloating();
|
|
9773
|
+
const [combineTarget, setCombineTarget] = React51__default.useState(null);
|
|
9774
|
+
const [combineDraft, setCombineDraft] = React51__default.useState(null);
|
|
9775
|
+
const combinePanelRef = React51__default.useRef(null);
|
|
9776
|
+
React51__default.useEffect(() => {
|
|
9777
|
+
if (panel === "combine" && combinePanelRef.current) {
|
|
9778
|
+
const el = combinePanelRef.current.querySelector('[role="switch"], button, [tabindex]');
|
|
9779
|
+
(el || combinePanelRef.current).focus?.();
|
|
9780
|
+
}
|
|
9781
|
+
}, [panel]);
|
|
9641
9782
|
const [rowMenu, setRowMenu] = React51__default.useState(null);
|
|
9642
9783
|
const [rowMenuPos, openRowMenu, closeRowMenu] = useFloating();
|
|
9643
9784
|
const [exportOpen, setExportOpen] = React51__default.useState(false);
|
|
@@ -9738,7 +9879,21 @@ function Datatable({
|
|
|
9738
9879
|
};
|
|
9739
9880
|
}, [exportOpen]);
|
|
9740
9881
|
const colByField = React51__default.useMemo(() => Object.fromEntries(cols.map((c) => [c.field, c])), [cols]);
|
|
9741
|
-
const
|
|
9882
|
+
const combineSources = React51__default.useMemo(() => {
|
|
9883
|
+
const s = /* @__PURE__ */ new Set();
|
|
9884
|
+
for (const cfg of Object.values(userCombine)) (cfg && cfg.fields ? cfg.fields : []).slice(1).forEach((f) => s.add(f));
|
|
9885
|
+
return s;
|
|
9886
|
+
}, [userCombine]);
|
|
9887
|
+
const stackCombineTargets = React51__default.useMemo(
|
|
9888
|
+
() => new Set(cols.filter((c) => {
|
|
9889
|
+
const cfg = combineCfg(userCombine[c.field] || c.combine);
|
|
9890
|
+
return cfg && cfg.layout === "stack";
|
|
9891
|
+
}).map((c) => c.field)),
|
|
9892
|
+
[cols, userCombine]
|
|
9893
|
+
);
|
|
9894
|
+
const effectiveHidden = React51__default.useMemo(() => combineSources.size ? /* @__PURE__ */ new Set([...hidden, ...combineSources]) : hidden, [hidden, combineSources]);
|
|
9895
|
+
const effectiveWrapped = React51__default.useMemo(() => stackCombineTargets.size ? /* @__PURE__ */ new Set([...wrapped, ...stackCombineTargets]) : wrapped, [wrapped, stackCombineTargets]);
|
|
9896
|
+
const visibleCols = cols.filter((c) => !effectiveHidden.has(c.field));
|
|
9742
9897
|
const colFieldsKey = JSON.stringify(
|
|
9743
9898
|
cols.filter((c) => typeof c.field === "string" && c.type !== "actions").map((c) => c.field)
|
|
9744
9899
|
);
|
|
@@ -9757,17 +9912,17 @@ function Datatable({
|
|
|
9757
9912
|
const i = order.indexOf(f);
|
|
9758
9913
|
return i === -1 ? 9999 : i;
|
|
9759
9914
|
};
|
|
9760
|
-
const L = pins.left.map((f) => colByField[f]).filter((c) => c && !
|
|
9761
|
-
const R = pins.right.map((f) => colByField[f]).filter((c) => c && !
|
|
9915
|
+
const L = pins.left.map((f) => colByField[f]).filter((c) => c && !effectiveHidden.has(c.field));
|
|
9916
|
+
const R = pins.right.map((f) => colByField[f]).filter((c) => c && !effectiveHidden.has(c.field));
|
|
9762
9917
|
const mid = visibleCols.filter((c) => !pins.left.includes(c.field) && !pins.right.includes(c.field)).sort((a, b) => orderIdx(a.field) - orderIdx(b.field));
|
|
9763
9918
|
return [...L, ...mid, ...R];
|
|
9764
|
-
}, [pins,
|
|
9919
|
+
}, [pins, effectiveHidden, visibleCols, colByField, order]);
|
|
9765
9920
|
const NUM_W = 56;
|
|
9766
9921
|
const CHK_W = checkboxSelection ? rowReorder ? 68 : 44 : 0;
|
|
9767
9922
|
const numLeft = CHK_W;
|
|
9768
9923
|
const leadW = numLeft + (showRowNum ? NUM_W : 0);
|
|
9769
|
-
const visLeft = React51__default.useMemo(() => pins.left.filter((f) => colByField[f] && !
|
|
9770
|
-
const visRight = React51__default.useMemo(() => pins.right.filter((f) => colByField[f] && !
|
|
9924
|
+
const visLeft = React51__default.useMemo(() => pins.left.filter((f) => colByField[f] && !effectiveHidden.has(f)), [pins.left, colByField, effectiveHidden]);
|
|
9925
|
+
const visRight = React51__default.useMemo(() => pins.right.filter((f) => colByField[f] && !effectiveHidden.has(f)), [pins.right, colByField, effectiveHidden]);
|
|
9771
9926
|
const stickyOf = (field) => {
|
|
9772
9927
|
if (visLeft.includes(field)) {
|
|
9773
9928
|
let off = leadW;
|
|
@@ -10383,6 +10538,7 @@ function Datatable({
|
|
|
10383
10538
|
if (el) el.focus();
|
|
10384
10539
|
}
|
|
10385
10540
|
function onGridKeyDown(e) {
|
|
10541
|
+
if (e.target.closest("input, textarea, select, [contenteditable='true']")) return;
|
|
10386
10542
|
if (editing) return;
|
|
10387
10543
|
const td = e.target.closest(".twc-dt__td[data-r]");
|
|
10388
10544
|
if (!td) return;
|
|
@@ -10932,6 +11088,54 @@ function Datatable({
|
|
|
10932
11088
|
if (field === "val") p.removeAttribute("data-val-fixed");
|
|
10933
11089
|
}
|
|
10934
11090
|
};
|
|
11091
|
+
const BE_NAME_MIN = 88, BE_NAME_MAX = 260;
|
|
11092
|
+
const startBeNameResize = (e) => {
|
|
11093
|
+
if (e.button != null && e.button !== 0) return;
|
|
11094
|
+
e.preventDefault();
|
|
11095
|
+
e.stopPropagation();
|
|
11096
|
+
const handle = e.currentTarget;
|
|
11097
|
+
const panel2 = handle.closest(".twc-dt__cfg"), nameEl = handle.closest(".twc-dt__be-name");
|
|
11098
|
+
if (!panel2 || !nameEl) return;
|
|
11099
|
+
const startX = e.clientX, startW = nameEl.getBoundingClientRect().width;
|
|
11100
|
+
const dir = getComputedStyle(panel2).direction === "rtl" ? -1 : 1;
|
|
11101
|
+
handle.setAttribute("data-active", "true");
|
|
11102
|
+
let last = startW;
|
|
11103
|
+
const onMove = (ev) => {
|
|
11104
|
+
last = clampNum(startW + (ev.clientX - startX) * dir, BE_NAME_MIN, BE_NAME_MAX);
|
|
11105
|
+
panel2.style.setProperty("--twc-dt-be-name-usr", `${last}px`);
|
|
11106
|
+
};
|
|
11107
|
+
const onUp = () => {
|
|
11108
|
+
setBatchNameW(last);
|
|
11109
|
+
handle.removeAttribute("data-active");
|
|
11110
|
+
window.removeEventListener("pointermove", onMove);
|
|
11111
|
+
window.removeEventListener("pointerup", onUp);
|
|
11112
|
+
};
|
|
11113
|
+
window.addEventListener("pointermove", onMove);
|
|
11114
|
+
window.addEventListener("pointerup", onUp);
|
|
11115
|
+
};
|
|
11116
|
+
const onBeNameResizeKey = (e) => {
|
|
11117
|
+
const panel2 = e.currentTarget.closest(".twc-dt__cfg");
|
|
11118
|
+
if (e.key === "Enter" || e.key === " " || e.key === "Backspace") {
|
|
11119
|
+
e.preventDefault();
|
|
11120
|
+
e.stopPropagation();
|
|
11121
|
+
setBatchNameW(null);
|
|
11122
|
+
if (panel2) panel2.style.removeProperty("--twc-dt-be-name-usr");
|
|
11123
|
+
return;
|
|
11124
|
+
}
|
|
11125
|
+
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(e.key)) return;
|
|
11126
|
+
e.preventDefault();
|
|
11127
|
+
e.stopPropagation();
|
|
11128
|
+
const nameEl = e.currentTarget.closest(".twc-dt__be-name");
|
|
11129
|
+
const cur = nameEl ? nameEl.getBoundingClientRect().width : batchNameW ?? 108;
|
|
11130
|
+
const dir = panel2 && getComputedStyle(panel2).direction === "rtl" ? -1 : 1;
|
|
11131
|
+
const step = e.shiftKey ? 2 : 10;
|
|
11132
|
+
let next = cur;
|
|
11133
|
+
if (e.key === "ArrowRight") next = cur + step * dir;
|
|
11134
|
+
else if (e.key === "ArrowLeft") next = cur - step * dir;
|
|
11135
|
+
else if (e.key === "Home") next = BE_NAME_MIN;
|
|
11136
|
+
else if (e.key === "End") next = BE_NAME_MAX;
|
|
11137
|
+
setBatchNameW(clampNum(next, BE_NAME_MIN, BE_NAME_MAX));
|
|
11138
|
+
};
|
|
10935
11139
|
const startPanelResize = (e) => {
|
|
10936
11140
|
if (e.button != null && e.button !== 0) return;
|
|
10937
11141
|
e.preventDefault();
|
|
@@ -11154,7 +11358,7 @@ function Datatable({
|
|
|
11154
11358
|
const shownColRows = cols.filter((c) => c.field !== "__pinactions__" && c.headerName.toLowerCase().includes(colQuery.trim().toLowerCase())).sort((a, b) => orderIdxOf(a.field) - orderIdxOf(b.field));
|
|
11155
11359
|
const rowNumMatch = rowNumbers && "row number".includes(colQuery.trim().toLowerCase());
|
|
11156
11360
|
const manageableCols = cols.filter((c) => c.field !== "__pinactions__");
|
|
11157
|
-
const visibleColCount = manageableCols.filter((c) => !
|
|
11361
|
+
const visibleColCount = manageableCols.filter((c) => !effectiveHidden.has(c.field)).length;
|
|
11158
11362
|
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) }));
|
|
11159
11363
|
const totalCols = ordered.length + (checkboxSelection ? 1 : 0) + (showRowNum ? 1 : 0);
|
|
11160
11364
|
function renderGroupRow(item) {
|
|
@@ -11312,7 +11516,7 @@ function Datatable({
|
|
|
11312
11516
|
"data-cell-active": cellActive || void 0,
|
|
11313
11517
|
"data-cell-selected": cellSelected || void 0,
|
|
11314
11518
|
"data-copied": cellFlash || void 0,
|
|
11315
|
-
"data-wrap":
|
|
11519
|
+
"data-wrap": effectiveWrapped.has(c.field) || void 0,
|
|
11316
11520
|
"data-pin": st.pin,
|
|
11317
11521
|
"data-pin-edge": st.edge,
|
|
11318
11522
|
style: { width: widthOf(c), ...st.style },
|
|
@@ -12009,7 +12213,7 @@ function Datatable({
|
|
|
12009
12213
|
delete values[f];
|
|
12010
12214
|
return { ...b, fields, values };
|
|
12011
12215
|
});
|
|
12012
|
-
return /* @__PURE__ */ jsxs("div", { className: "twc-dt__pop twc-dt__cfg", style: { top: batchEditPos.top, left: batchEditPos.left, width: 320, ...popStyle("batchedit") }, "data-pop-sized": popSizes.batchedit ? "" : void 0, children: [
|
|
12216
|
+
return /* @__PURE__ */ jsxs("div", { className: "twc-dt__pop twc-dt__cfg", style: { top: batchEditPos.top, left: batchEditPos.left, width: 320, "--twc-dt-be-name-usr": batchNameW != null ? `${batchNameW}px` : void 0, ...popStyle("batchedit") }, "data-pop-sized": popSizes.batchedit ? "" : void 0, children: [
|
|
12013
12217
|
/* @__PURE__ */ jsx(Caret, { pos: batchEditPos }),
|
|
12014
12218
|
/* @__PURE__ */ jsxs("div", { className: "twc-dt__cfg-head", children: [
|
|
12015
12219
|
"Edit ",
|
|
@@ -12030,10 +12234,25 @@ function Datatable({
|
|
|
12030
12234
|
onChange: addField
|
|
12031
12235
|
}
|
|
12032
12236
|
) }) : null,
|
|
12033
|
-
/* @__PURE__ */ jsx("div", { className: "twc-dt__cfg-list", children: pickedCols.length === 0 ? /* @__PURE__ */ jsx("div", { className: "twc-dt__be-empty", children: "Pick a column to set its value on all selected rows." }) : pickedCols.map((c) => {
|
|
12237
|
+
/* @__PURE__ */ jsx("div", { className: "twc-dt__cfg-list", children: pickedCols.length === 0 ? /* @__PURE__ */ jsx("div", { className: "twc-dt__be-empty", children: "Pick a column to set its value on all selected rows." }) : pickedCols.map((c, i) => {
|
|
12034
12238
|
const opts = c.valueOptions ? c.valueOptions.map((o) => typeof o === "string" ? { value: o, label: o } : o) : null;
|
|
12035
12239
|
return /* @__PURE__ */ jsxs("div", { className: "twc-dt__be-row", children: [
|
|
12036
|
-
/* @__PURE__ */
|
|
12240
|
+
/* @__PURE__ */ jsxs("span", { className: "twc-dt__be-name", title: String(c.headerName ?? c.field), children: [
|
|
12241
|
+
/* @__PURE__ */ jsx("span", { className: "twc-dt__be-name-txt", children: c.headerName }),
|
|
12242
|
+
resizableFilters && i === 0 ? /* @__PURE__ */ jsx(
|
|
12243
|
+
"span",
|
|
12244
|
+
{
|
|
12245
|
+
className: "twc-dt__f-rz",
|
|
12246
|
+
role: "separator",
|
|
12247
|
+
"aria-orientation": "vertical",
|
|
12248
|
+
tabIndex: 0,
|
|
12249
|
+
"aria-label": "Resize column name field (Enter to reset)",
|
|
12250
|
+
onPointerDown: startBeNameResize,
|
|
12251
|
+
onClick: (e) => e.stopPropagation(),
|
|
12252
|
+
onKeyDown: onBeNameResizeKey
|
|
12253
|
+
}
|
|
12254
|
+
) : null
|
|
12255
|
+
] }),
|
|
12037
12256
|
/* @__PURE__ */ jsx("div", { className: "twc-dt__be-ctl", children: c.renderBatchEditCell ? c.renderBatchEditCell({
|
|
12038
12257
|
value: batchEdit.values[c.field],
|
|
12039
12258
|
field: c.field,
|
|
@@ -12148,6 +12367,18 @@ function Datatable({
|
|
|
12148
12367
|
" ",
|
|
12149
12368
|
groupBy.includes(c.field) ? "Stop grouping" : "Group by this column"
|
|
12150
12369
|
] }) : null,
|
|
12370
|
+
columnCombining && c.type !== "actions" ? /* @__PURE__ */ jsxs("button", { type: "button", role: "menuitem", className: "twc-dt__mi", "data-active": !!userCombine[c.field] || void 0, onClick: () => {
|
|
12371
|
+
const anchor = menuTriggerRef.current;
|
|
12372
|
+
setColMenu(null);
|
|
12373
|
+
closeMenu();
|
|
12374
|
+
openCombineEditor(c.field);
|
|
12375
|
+
setPanel("combine");
|
|
12376
|
+
openPanel(anchor, "right", 300);
|
|
12377
|
+
}, children: [
|
|
12378
|
+
/* @__PURE__ */ jsx(Svg, { d: I.columns }),
|
|
12379
|
+
" ",
|
|
12380
|
+
userCombine[c.field] ? "Edit combined column\u2026" : "Combine columns\u2026"
|
|
12381
|
+
] }) : null,
|
|
12151
12382
|
!disableColumnReorder && c.reorderable !== false && c.type !== "actions" && !pins.left.includes(c.field) && !pins.right.includes(c.field) && movableMidFields.length > 1 ? (() => {
|
|
12152
12383
|
const midIdx = movableMidFields.indexOf(c.field);
|
|
12153
12384
|
const atFirst = midIdx === 0;
|
|
@@ -12315,10 +12546,13 @@ function Datatable({
|
|
|
12315
12546
|
e.preventDefault();
|
|
12316
12547
|
onColDrop(c.field);
|
|
12317
12548
|
} : void 0,
|
|
12318
|
-
onClick: () => c.hideable && toggleHiddenField(c.field),
|
|
12549
|
+
onClick: () => c.hideable && !combineSources.has(c.field) && toggleHiddenField(c.field),
|
|
12319
12550
|
children: [
|
|
12320
12551
|
canDrag ? /* @__PURE__ */ jsx("span", { className: "twc-dt__col-grip", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Svg, { d: I.grip }) }) : null,
|
|
12321
|
-
/* @__PURE__ */
|
|
12552
|
+
/* @__PURE__ */ jsxs("span", { className: "twc-dt__col-name", children: [
|
|
12553
|
+
c.headerName,
|
|
12554
|
+
combineSources.has(c.field) ? /* @__PURE__ */ jsx("span", { className: "twc-dt__col-combined", children: " \xB7 combined" }) : null
|
|
12555
|
+
] }),
|
|
12322
12556
|
c.pinnable && c.type !== "actions" ? (
|
|
12323
12557
|
// Pin from here too, so columns scrolled out of view (no reachable header ⋮) can still be pinned.
|
|
12324
12558
|
/* @__PURE__ */ jsxs("span", { className: "twc-dt__col-pins", draggable: false, onClick: (e) => e.stopPropagation(), children: [
|
|
@@ -12354,19 +12588,19 @@ function Datatable({
|
|
|
12354
12588
|
"span",
|
|
12355
12589
|
{
|
|
12356
12590
|
className: "twc-dt__sw",
|
|
12357
|
-
"data-on": !
|
|
12591
|
+
"data-on": !effectiveHidden.has(c.field) || void 0,
|
|
12358
12592
|
role: "switch",
|
|
12359
|
-
"aria-checked": !
|
|
12593
|
+
"aria-checked": !effectiveHidden.has(c.field),
|
|
12360
12594
|
"aria-label": c.headerName,
|
|
12361
|
-
"aria-disabled": !c.hideable || void 0,
|
|
12362
|
-
tabIndex: c.hideable ? 0 : -1,
|
|
12595
|
+
"aria-disabled": !c.hideable || combineSources.has(c.field) || void 0,
|
|
12596
|
+
tabIndex: c.hideable && !combineSources.has(c.field) ? 0 : -1,
|
|
12363
12597
|
onKeyDown: (e) => {
|
|
12364
|
-
if ((e.key === "Enter" || e.key === " ") && c.hideable) {
|
|
12598
|
+
if ((e.key === "Enter" || e.key === " ") && c.hideable && !combineSources.has(c.field)) {
|
|
12365
12599
|
e.preventDefault();
|
|
12366
12600
|
toggleHiddenField(c.field);
|
|
12367
12601
|
}
|
|
12368
12602
|
},
|
|
12369
|
-
style: c.hideable ? void 0 : { opacity: 0.4 }
|
|
12603
|
+
style: c.hideable && !combineSources.has(c.field) ? void 0 : { opacity: 0.4 }
|
|
12370
12604
|
}
|
|
12371
12605
|
)
|
|
12372
12606
|
]
|
|
@@ -12377,6 +12611,82 @@ function Datatable({
|
|
|
12377
12611
|
] }),
|
|
12378
12612
|
popGrip("columns")
|
|
12379
12613
|
] }) : null,
|
|
12614
|
+
panel === "combine" && panelPos && combineTarget && combineDraft ? (() => {
|
|
12615
|
+
const target = colByField[combineTarget];
|
|
12616
|
+
const candidates = cols.filter((c) => c.field !== combineTarget && c.type !== "actions" && c.field !== "__pinactions__" && c.hideable !== false && !userCombine[c.field]);
|
|
12617
|
+
const toggle = (f) => setCombineDraft((d) => ({ ...d, selected: d.selected.includes(f) ? d.selected.filter((x) => x !== f) : [...d.selected, f] }));
|
|
12618
|
+
return /* @__PURE__ */ jsxs("div", { ref: combinePanelRef, tabIndex: -1, className: "twc-dt__pop twc-dt__cols", style: { top: panelPos.top, left: panelPos.left, ...popStyle("combine") }, "data-pop-sized": popSizes.combine ? "" : void 0, role: "dialog", "aria-label": `Combine columns into ${target?.headerName || combineTarget}`, children: [
|
|
12619
|
+
/* @__PURE__ */ jsx("div", { className: "twc-dt__panel-head", children: /* @__PURE__ */ jsxs("span", { className: "twc-dt__panel-title", children: [
|
|
12620
|
+
"Combine into \u201C",
|
|
12621
|
+
target?.headerName || combineTarget,
|
|
12622
|
+
"\u201D"
|
|
12623
|
+
] }) }),
|
|
12624
|
+
/* @__PURE__ */ jsx("div", { className: "twc-dt__combine-hint", children: "Pick columns to merge into this one \u2014 their data shows in this cell and their own columns hide." }),
|
|
12625
|
+
/* @__PURE__ */ jsx("div", { className: "twc-dt__col-list", children: candidates.length === 0 ? /* @__PURE__ */ jsx("div", { className: "twc-dt__empty", style: { padding: "18px 12px" }, children: "No other columns" }) : candidates.map((c) => {
|
|
12626
|
+
const on = combineDraft.selected.includes(c.field);
|
|
12627
|
+
return /* @__PURE__ */ jsxs("div", { className: "twc-dt__col-row", onClick: () => toggle(c.field), children: [
|
|
12628
|
+
/* @__PURE__ */ jsx("span", { className: "twc-dt__col-name", children: c.headerName }),
|
|
12629
|
+
/* @__PURE__ */ jsx(
|
|
12630
|
+
"span",
|
|
12631
|
+
{
|
|
12632
|
+
className: "twc-dt__sw",
|
|
12633
|
+
"data-on": on || void 0,
|
|
12634
|
+
role: "switch",
|
|
12635
|
+
"aria-checked": on,
|
|
12636
|
+
"aria-label": c.headerName,
|
|
12637
|
+
tabIndex: 0,
|
|
12638
|
+
onKeyDown: (e) => {
|
|
12639
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
12640
|
+
e.preventDefault();
|
|
12641
|
+
toggle(c.field);
|
|
12642
|
+
}
|
|
12643
|
+
}
|
|
12644
|
+
}
|
|
12645
|
+
)
|
|
12646
|
+
] }, c.field);
|
|
12647
|
+
}) }),
|
|
12648
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-dt__combine-opts", children: [
|
|
12649
|
+
/* @__PURE__ */ jsxs("label", { className: "twc-dt__combine-opt", children: [
|
|
12650
|
+
/* @__PURE__ */ jsx("span", { children: "Layout" }),
|
|
12651
|
+
/* @__PURE__ */ jsx(
|
|
12652
|
+
Select,
|
|
12653
|
+
{
|
|
12654
|
+
size: "sm",
|
|
12655
|
+
portal: true,
|
|
12656
|
+
matchTriggerWidth: false,
|
|
12657
|
+
value: combineDraft.layout,
|
|
12658
|
+
options: [{ value: "inline", label: "Inline" }, { value: "stack", label: "Stacked" }],
|
|
12659
|
+
onChange: (v) => setCombineDraft((d) => ({ ...d, layout: v }))
|
|
12660
|
+
}
|
|
12661
|
+
)
|
|
12662
|
+
] }),
|
|
12663
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-dt__combine-opt", onClick: () => setCombineDraft((d) => ({ ...d, labels: !d.labels })), style: { cursor: "pointer" }, children: [
|
|
12664
|
+
/* @__PURE__ */ jsx("span", { children: "Show labels" }),
|
|
12665
|
+
/* @__PURE__ */ jsx(
|
|
12666
|
+
"span",
|
|
12667
|
+
{
|
|
12668
|
+
className: "twc-dt__sw",
|
|
12669
|
+
"data-on": combineDraft.labels || void 0,
|
|
12670
|
+
role: "switch",
|
|
12671
|
+
"aria-checked": combineDraft.labels,
|
|
12672
|
+
"aria-label": "Show labels",
|
|
12673
|
+
tabIndex: 0,
|
|
12674
|
+
onKeyDown: (e) => {
|
|
12675
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
12676
|
+
e.preventDefault();
|
|
12677
|
+
setCombineDraft((d) => ({ ...d, labels: !d.labels }));
|
|
12678
|
+
}
|
|
12679
|
+
}
|
|
12680
|
+
}
|
|
12681
|
+
)
|
|
12682
|
+
] })
|
|
12683
|
+
] }),
|
|
12684
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-dt__combine-foot", children: [
|
|
12685
|
+
userCombine[combineTarget] ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__link", onClick: () => uncombine(combineTarget), children: "Uncombine" }) : /* @__PURE__ */ jsx("span", {}),
|
|
12686
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__combine-apply", onClick: applyCombine, children: "Apply" })
|
|
12687
|
+
] })
|
|
12688
|
+
] });
|
|
12689
|
+
})() : null,
|
|
12380
12690
|
panel === "agg" && panelPos ? /* @__PURE__ */ jsxs("div", { className: "twc-dt__pop twc-dt__cfg", style: { top: panelPos.top, left: panelPos.left, width: 300, ...popStyle("agg") }, "data-pop-sized": popSizes.agg ? "" : void 0, role: "dialog", "aria-label": "Aggregation settings", children: [
|
|
12381
12691
|
/* @__PURE__ */ jsxs("div", { className: "twc-dt__panel-head", children: [
|
|
12382
12692
|
/* @__PURE__ */ jsx("span", { className: "twc-dt__panel-title", children: "Aggregation" }),
|
|
@@ -15424,6 +15734,7 @@ function FileUpload({
|
|
|
15424
15734
|
} else if (accepted.length) set(accepted.slice(0, 1));
|
|
15425
15735
|
}
|
|
15426
15736
|
function remove(i) {
|
|
15737
|
+
if (disabled) return;
|
|
15427
15738
|
set(files.filter((_, idx) => idx !== i));
|
|
15428
15739
|
}
|
|
15429
15740
|
return /* @__PURE__ */ jsxs("div", { className: `twc-upload ${className}`, "data-size": size, ...rest, children: [
|
|
@@ -15494,7 +15805,7 @@ function FileUpload({
|
|
|
15494
15805
|
/* @__PURE__ */ jsx("span", { className: "twc-upload__file-name", children: f.name }),
|
|
15495
15806
|
/* @__PURE__ */ jsx("span", { className: "twc-upload__file-size", children: fmtSize(f.size) })
|
|
15496
15807
|
] }),
|
|
15497
|
-
/* @__PURE__ */ jsx("button", { className: "twc-upload__file-x", "aria-label": `Remove ${f.name}`, onClick: () => remove(i), type: "button", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) }) })
|
|
15808
|
+
!disabled ? /* @__PURE__ */ jsx("button", { className: "twc-upload__file-x", "aria-label": `Remove ${f.name}`, onClick: () => remove(i), type: "button", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) }) }) : null
|
|
15498
15809
|
] }, fileKey(f))) }) : null,
|
|
15499
15810
|
error ? /* @__PURE__ */ jsx("span", { id: descId, className: "twc-field__error", children: error }) : null
|
|
15500
15811
|
] });
|
|
@@ -15529,6 +15840,8 @@ var ICONBTN_CSS = `
|
|
|
15529
15840
|
.twc-iconbtn:focus-visible { outline: none; box-shadow: var(--ring); }
|
|
15530
15841
|
.twc-iconbtn:active:not(:disabled) { transform: scale(var(--press-scale)); }
|
|
15531
15842
|
.twc-iconbtn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
15843
|
+
/* #342: disabled state for the anchor form (as="a") \u2014 :disabled doesn't apply to <a>. */
|
|
15844
|
+
.twc-iconbtn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
|
|
15532
15845
|
.twc-iconbtn svg { width: 1.25em; height: 1.25em; }
|
|
15533
15846
|
|
|
15534
15847
|
/* tone supplies the accent set; variant decides how it's applied \u2014 mirrors Button. Default tone
|
|
@@ -15547,6 +15860,11 @@ var ICONBTN_CSS = `
|
|
|
15547
15860
|
.twc-iconbtn[data-variant="outline"]:hover:not(:disabled) { border-color: var(--_accent); color: var(--_accent); background: var(--color-surface-sunken); }
|
|
15548
15861
|
.twc-iconbtn[data-variant="ghost"]:hover:not(:disabled) { background: var(--color-surface-sunken); color: var(--_accent); }
|
|
15549
15862
|
`;
|
|
15863
|
+
function safeHref6(url) {
|
|
15864
|
+
if (url == null) return void 0;
|
|
15865
|
+
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
15866
|
+
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
15867
|
+
}
|
|
15550
15868
|
function IconButton({
|
|
15551
15869
|
children,
|
|
15552
15870
|
icon,
|
|
@@ -15555,21 +15873,28 @@ function IconButton({
|
|
|
15555
15873
|
size = "md",
|
|
15556
15874
|
round = false,
|
|
15557
15875
|
disabled = false,
|
|
15876
|
+
as = "button",
|
|
15877
|
+
href,
|
|
15558
15878
|
className = "",
|
|
15559
15879
|
"aria-label": ariaLabel,
|
|
15560
15880
|
...rest
|
|
15561
15881
|
}) {
|
|
15562
15882
|
const __twcStyles = useScopedStyles("twc-iconbtn-styles", ICONBTN_CSS);
|
|
15883
|
+
const Tag2 = as;
|
|
15884
|
+
const inert = Tag2 === "a" && disabled;
|
|
15563
15885
|
return /* @__PURE__ */ jsxs(
|
|
15564
|
-
|
|
15886
|
+
Tag2,
|
|
15565
15887
|
{
|
|
15566
15888
|
className: `twc-iconbtn ${className}`,
|
|
15567
15889
|
"data-variant": variant,
|
|
15568
15890
|
"data-tone": tone,
|
|
15569
15891
|
"data-size": size,
|
|
15570
15892
|
"data-round": round || void 0,
|
|
15571
|
-
disabled,
|
|
15572
|
-
type: "button",
|
|
15893
|
+
disabled: Tag2 === "button" ? disabled : void 0,
|
|
15894
|
+
type: Tag2 === "button" ? "button" : void 0,
|
|
15895
|
+
href: Tag2 === "a" && !inert ? safeHref6(href) : void 0,
|
|
15896
|
+
"aria-disabled": inert || void 0,
|
|
15897
|
+
tabIndex: inert ? -1 : void 0,
|
|
15573
15898
|
"aria-label": ariaLabel,
|
|
15574
15899
|
...rest,
|
|
15575
15900
|
children: [
|
|
@@ -15771,7 +16096,7 @@ var LIST_CSS = `
|
|
|
15771
16096
|
`;
|
|
15772
16097
|
function List({ items, plain = false, emptyMessage, className = "", ...rest }) {
|
|
15773
16098
|
const __twcStyles = useScopedStyles("twc-list-styles", LIST_CSS);
|
|
15774
|
-
const
|
|
16099
|
+
const safeHref14 = (url) => {
|
|
15775
16100
|
if (url == null) return void 0;
|
|
15776
16101
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
15777
16102
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -15783,7 +16108,7 @@ function List({ items, plain = false, emptyMessage, className = "", ...rest }) {
|
|
|
15783
16108
|
/* @__PURE__ */ jsxs("ul", { className: `twc-list ${className}`, role: "list", "data-plain": plain || void 0, ...rest, children: [
|
|
15784
16109
|
__twcStyles,
|
|
15785
16110
|
items.length === 0 ? /* @__PURE__ */ jsx("li", { role: "presentation", style: { display: "contents" }, children: /* @__PURE__ */ jsx("div", { className: "twc-list__empty", children: emptyMessage ?? "Nothing here yet" }) }) : items.map((it, i) => {
|
|
15786
|
-
const href =
|
|
16111
|
+
const href = safeHref14(it.href);
|
|
15787
16112
|
const interactive = Boolean(it.onClick || href);
|
|
15788
16113
|
const Tag2 = href ? "a" : interactive ? "button" : "div";
|
|
15789
16114
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -15839,7 +16164,7 @@ button.twc-navbar__brand, a.twc-navbar__brand { cursor: pointer; }
|
|
|
15839
16164
|
.twc-navbar__menu-btn { display: inline-grid; }
|
|
15840
16165
|
}
|
|
15841
16166
|
`;
|
|
15842
|
-
function
|
|
16167
|
+
function safeHref7(url) {
|
|
15843
16168
|
if (url == null) return void 0;
|
|
15844
16169
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
15845
16170
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -15862,9 +16187,9 @@ function Navbar({
|
|
|
15862
16187
|
return /* @__PURE__ */ jsxs("header", { className: `twc-navbar ${className}`, "data-sticky": sticky || void 0, ...rest, children: [
|
|
15863
16188
|
__twcStyles,
|
|
15864
16189
|
onMenuClick ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-navbar__menu-btn", "aria-expanded": menuOpen, "aria-controls": menuControls, "aria-label": menuOpen ? "Close menu" : "Open menu", onClick: onMenuClick, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M4 6h16M4 12h16M4 18h16" }) }) }) : null,
|
|
15865
|
-
brand ? brandHref ? /* @__PURE__ */ jsx("a", { className: "twc-navbar__brand", href:
|
|
16190
|
+
brand ? brandHref ? /* @__PURE__ */ jsx("a", { className: "twc-navbar__brand", href: safeHref7(brandHref), children: brand }) : onBrandClick ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-navbar__brand", onClick: onBrandClick, children: brand }) : /* @__PURE__ */ jsx("span", { className: "twc-navbar__brand", children: brand }) : null,
|
|
15866
16191
|
/* @__PURE__ */ jsx("nav", { className: "twc-navbar__links", "aria-label": navLabel, children: links.map((l, i) => {
|
|
15867
|
-
const href =
|
|
16192
|
+
const href = safeHref7(l.href);
|
|
15868
16193
|
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
15869
16194
|
l.icon,
|
|
15870
16195
|
l.label
|
|
@@ -16651,13 +16976,13 @@ function Sidebar({
|
|
|
16651
16976
|
document.addEventListener("keydown", onKey);
|
|
16652
16977
|
return () => document.removeEventListener("keydown", onKey);
|
|
16653
16978
|
}, [overlay, open, openProp, onOpenChange]);
|
|
16654
|
-
const
|
|
16979
|
+
const safeHref14 = (url) => {
|
|
16655
16980
|
if (url == null) return void 0;
|
|
16656
16981
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
16657
16982
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
16658
16983
|
};
|
|
16659
16984
|
const renderItem = (it, i) => {
|
|
16660
|
-
const href =
|
|
16985
|
+
const href = safeHref14(it.href);
|
|
16661
16986
|
const labelStr = typeof it.label === "string" ? it.label : void 0;
|
|
16662
16987
|
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
16663
16988
|
it.icon ? /* @__PURE__ */ jsx("span", { className: "twc-sidebar__ic", "aria-hidden": "true", children: it.icon }) : labelStr != null ? /* @__PURE__ */ jsx("span", { className: "twc-sidebar__ic twc-sidebar__ic--initial", "aria-hidden": "true", children: labelStr.charAt(0) }) : null,
|
|
@@ -18371,7 +18696,7 @@ function bgValue(bg) {
|
|
|
18371
18696
|
if (BG[bg]) return `var(${BG[bg]})`;
|
|
18372
18697
|
return String(bg).startsWith("--") ? `var(${bg})` : bg;
|
|
18373
18698
|
}
|
|
18374
|
-
function
|
|
18699
|
+
function safeHref8(url) {
|
|
18375
18700
|
if (url == null) return void 0;
|
|
18376
18701
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
18377
18702
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -18419,7 +18744,7 @@ var Box = React51__default.forwardRef(function Box2({
|
|
|
18419
18744
|
...style,
|
|
18420
18745
|
...flatStyle
|
|
18421
18746
|
};
|
|
18422
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
18747
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref8(rest.href);
|
|
18423
18748
|
return /* @__PURE__ */ jsxs(Tag2, { ref, className: `twc-box ${className}`.trim(), style: s, "data-twc-sx": sxAttr, ...rest, children: [
|
|
18424
18749
|
styleNode,
|
|
18425
18750
|
children
|
|
@@ -18427,7 +18752,7 @@ var Box = React51__default.forwardRef(function Box2({
|
|
|
18427
18752
|
});
|
|
18428
18753
|
Box.displayName = "Box";
|
|
18429
18754
|
var SIZES = { sm: 640, md: 768, lg: 1024, xl: 1280, full: "100%" };
|
|
18430
|
-
function
|
|
18755
|
+
function safeHref9(url) {
|
|
18431
18756
|
if (url == null) return void 0;
|
|
18432
18757
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
18433
18758
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -18444,7 +18769,7 @@ var Container = React51__default.forwardRef(function Container2({
|
|
|
18444
18769
|
}, ref) {
|
|
18445
18770
|
const { flatStyle, styleNode, sxAttr } = useSx(sx);
|
|
18446
18771
|
const max = SIZES[size] ?? size;
|
|
18447
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
18772
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref9(rest.href);
|
|
18448
18773
|
return /* @__PURE__ */ jsxs(
|
|
18449
18774
|
Tag2,
|
|
18450
18775
|
{
|
|
@@ -18475,7 +18800,7 @@ function space2(v) {
|
|
|
18475
18800
|
if (typeof v === "number") return `var(--space-${String(v).replace(".", "-")})`;
|
|
18476
18801
|
return v;
|
|
18477
18802
|
}
|
|
18478
|
-
function
|
|
18803
|
+
function safeHref10(url) {
|
|
18479
18804
|
if (url == null) return void 0;
|
|
18480
18805
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
18481
18806
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -18503,7 +18828,7 @@ var Stack = React51__default.forwardRef(function Stack2({
|
|
|
18503
18828
|
...rest
|
|
18504
18829
|
}, ref) {
|
|
18505
18830
|
const { flatStyle, styleNode, sxAttr } = useSx(sx);
|
|
18506
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
18831
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref10(rest.href);
|
|
18507
18832
|
const kids = divider != null ? React51__default.Children.toArray(children).flatMap((child, i, arr) => i < arr.length - 1 ? [child, /* @__PURE__ */ jsx(React51__default.Fragment, { children: divider }, `twc-stack-div-${i}`)] : [child]) : children;
|
|
18508
18833
|
return /* @__PURE__ */ jsxs(
|
|
18509
18834
|
Tag2,
|
|
@@ -18558,7 +18883,7 @@ var CODE_CSS = `
|
|
|
18558
18883
|
.twc-code__copy:focus-visible { outline: none; box-shadow: var(--ring); }
|
|
18559
18884
|
.twc-code__copy svg { width: 15px; height: 15px; display: block; }
|
|
18560
18885
|
`;
|
|
18561
|
-
function
|
|
18886
|
+
function safeHref11(url) {
|
|
18562
18887
|
if (url == null) return void 0;
|
|
18563
18888
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
18564
18889
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -18575,7 +18900,7 @@ function Code({
|
|
|
18575
18900
|
}) {
|
|
18576
18901
|
const __twcStyles = useScopedStyles("twc-code-styles", CODE_CSS);
|
|
18577
18902
|
const Tag2 = as ?? (block ? "pre" : "code");
|
|
18578
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
18903
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref11(rest.href);
|
|
18579
18904
|
const rootRef = React51__default.useRef(null);
|
|
18580
18905
|
const [copied, setCopied] = React51__default.useState(false);
|
|
18581
18906
|
const timerRef = React51__default.useRef(null);
|
|
@@ -18600,7 +18925,7 @@ function Code({
|
|
|
18600
18925
|
] });
|
|
18601
18926
|
}
|
|
18602
18927
|
var LEVEL_SIZE = { 1: "4xl", 2: "2xl", 3: "xl", 4: "lg", 5: "base", 6: "sm" };
|
|
18603
|
-
function
|
|
18928
|
+
function safeHref12(url) {
|
|
18604
18929
|
if (url == null) return void 0;
|
|
18605
18930
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
18606
18931
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -18622,7 +18947,7 @@ var Heading = React51__default.forwardRef(function Heading2({
|
|
|
18622
18947
|
const { flatStyle, styleNode, sxAttr } = useSx(sx);
|
|
18623
18948
|
const Tag2 = as || `h${level}`;
|
|
18624
18949
|
const sz = size || (display ? "display" : LEVEL_SIZE[level]) || "2xl";
|
|
18625
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
18950
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref12(rest.href);
|
|
18626
18951
|
return /* @__PURE__ */ jsxs(
|
|
18627
18952
|
Tag2,
|
|
18628
18953
|
{
|
|
@@ -18669,7 +18994,7 @@ var TONE = {
|
|
|
18669
18994
|
// Adopt the surrounding color (e.g. inside a solid Button/Badge/Alert or a link).
|
|
18670
18995
|
inherit: "inherit"
|
|
18671
18996
|
};
|
|
18672
|
-
function
|
|
18997
|
+
function safeHref13(url) {
|
|
18673
18998
|
if (url == null) return void 0;
|
|
18674
18999
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
18675
19000
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -18689,7 +19014,7 @@ var Text = React51__default.forwardRef(function Text2({
|
|
|
18689
19014
|
...rest
|
|
18690
19015
|
}, ref) {
|
|
18691
19016
|
const { flatStyle, styleNode, sxAttr } = useSx(sx);
|
|
18692
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
19017
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref13(rest.href);
|
|
18693
19018
|
const toneToken = TONE[tone] || TONE.default;
|
|
18694
19019
|
return /* @__PURE__ */ jsxs(
|
|
18695
19020
|
Tag2,
|