twico-ui 1.35.0 → 1.36.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 +7 -0
- package/dist/index.cjs +40 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +40 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2183,6 +2183,13 @@ interface DatatableColumn<T = any> {
|
|
|
2183
2183
|
combine?: string[] | { fields: string[]; layout?: "inline" | "stack"; separator?: string; labels?: boolean };
|
|
2184
2184
|
/** Header label. @default field ("Actions" for actions columns) */
|
|
2185
2185
|
headerName?: string;
|
|
2186
|
+
/** #367: fully custom column-header renderer — the header analogue of `renderCell`, mirroring MUI
|
|
2187
|
+
* DataGrid's `renderHeader`. Receives the resolved column and returns the node rendered inside the
|
|
2188
|
+
* header cell (e.g. a label + a trailing (i) `Tooltip`) in place of `headerName`. `headerName` stays
|
|
2189
|
+
* the plain-text label used for quick-search, the Columns menu, CSV/Excel export, aggregation, and the
|
|
2190
|
+
* a11y sort/resize labels, so a custom header never breaks those string consumers — keep it set to that
|
|
2191
|
+
* label. (A non-string `headerName` also no longer throws in the Columns menu.) */
|
|
2192
|
+
renderHeader?: (args: { column: DatatableColumn<T> }) => React.ReactNode;
|
|
2186
2193
|
/** Data type. "actions" renders per-row action buttons via getActions. @default "string" */
|
|
2187
2194
|
type?: "string" | "number" | "actions";
|
|
2188
2195
|
/** Filter operators + value comparison for this column, **decoupled from the edit `type`** (#270).
|
package/dist/index.d.ts
CHANGED
|
@@ -2183,6 +2183,13 @@ interface DatatableColumn<T = any> {
|
|
|
2183
2183
|
combine?: string[] | { fields: string[]; layout?: "inline" | "stack"; separator?: string; labels?: boolean };
|
|
2184
2184
|
/** Header label. @default field ("Actions" for actions columns) */
|
|
2185
2185
|
headerName?: string;
|
|
2186
|
+
/** #367: fully custom column-header renderer — the header analogue of `renderCell`, mirroring MUI
|
|
2187
|
+
* DataGrid's `renderHeader`. Receives the resolved column and returns the node rendered inside the
|
|
2188
|
+
* header cell (e.g. a label + a trailing (i) `Tooltip`) in place of `headerName`. `headerName` stays
|
|
2189
|
+
* the plain-text label used for quick-search, the Columns menu, CSV/Excel export, aggregation, and the
|
|
2190
|
+
* a11y sort/resize labels, so a custom header never breaks those string consumers — keep it set to that
|
|
2191
|
+
* label. (A non-string `headerName` also no longer throws in the Columns menu.) */
|
|
2192
|
+
renderHeader?: (args: { column: DatatableColumn<T> }) => React.ReactNode;
|
|
2186
2193
|
/** Data type. "actions" renders per-row action buttons via getActions. @default "string" */
|
|
2187
2194
|
type?: "string" | "number" | "actions";
|
|
2188
2195
|
/** Filter operators + value comparison for this column, **decoupled from the edit `type`** (#270).
|
package/dist/index.mjs
CHANGED
|
@@ -8869,11 +8869,12 @@ function combineCfg(combine) {
|
|
|
8869
8869
|
if (!fields.length) return null;
|
|
8870
8870
|
return { fields, separator: cfg.separator != null ? cfg.separator : " \xB7 ", labels: !!cfg.labels, layout: cfg.layout === "stack" ? "stack" : "inline" };
|
|
8871
8871
|
}
|
|
8872
|
+
var colLabel = (c) => typeof c.headerName === "string" ? c.headerName : String(c.field ?? "");
|
|
8872
8873
|
var combineSrcCols = (cfg, byField) => cfg.fields.map((f) => byField && byField[f] || { field: f, headerName: String(f) });
|
|
8873
8874
|
var combineValueGetter = (srcCols, cfg) => (row) => srcCols.map((sc) => {
|
|
8874
8875
|
const v = getColVal(sc, row);
|
|
8875
8876
|
const s = v == null ? "" : String(v);
|
|
8876
|
-
return cfg.labels && s ? `${sc
|
|
8877
|
+
return cfg.labels && s ? `${colLabel(sc)}: ${s}` : s;
|
|
8877
8878
|
}).filter(Boolean).join(cfg.separator);
|
|
8878
8879
|
function renderCombined(srcCols, row, cfg) {
|
|
8879
8880
|
const nodes = [];
|
|
@@ -8882,7 +8883,7 @@ function renderCombined(srcCols, row, cfg) {
|
|
|
8882
8883
|
const v = getColVal(sc, row);
|
|
8883
8884
|
if (v == null || v === "") return;
|
|
8884
8885
|
const disp = sc.valueFormatter ? sc.valueFormatter(v, row) : v;
|
|
8885
|
-
const label = cfg.labels ? React51__default.createElement("span", { className: "twc-dt__combine-label" }, (sc
|
|
8886
|
+
const label = cfg.labels ? React51__default.createElement("span", { className: "twc-dt__combine-label" }, colLabel(sc) + ": ") : null;
|
|
8886
8887
|
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));
|
|
8887
8888
|
nodes.push(React51__default.createElement("span", { key: idx, className: "twc-dt__combine-item" }, label, disp));
|
|
8888
8889
|
count++;
|
|
@@ -9132,7 +9133,7 @@ function EditCell({ col, value, options, onChange, onCommit, onCommitValue, onCa
|
|
|
9132
9133
|
className: "twc-dt__editor",
|
|
9133
9134
|
type: col.type === "number" ? "number" : "text",
|
|
9134
9135
|
value: value ?? "",
|
|
9135
|
-
"aria-label": `Edit ${col
|
|
9136
|
+
"aria-label": `Edit ${colLabel(col)}`,
|
|
9136
9137
|
onChange: (e) => onChange(e.target.value),
|
|
9137
9138
|
onKeyDown,
|
|
9138
9139
|
onBlur: onCommit
|
|
@@ -9783,7 +9784,7 @@ function Datatable({
|
|
|
9783
9784
|
}, [rowGroupingKey]);
|
|
9784
9785
|
const AUTO_CHROME = 74;
|
|
9785
9786
|
const autoWidth = (c) => {
|
|
9786
|
-
const label =
|
|
9787
|
+
const label = colLabel(c);
|
|
9787
9788
|
return AUTO_CHROME + Math.ceil(label.length * 8);
|
|
9788
9789
|
};
|
|
9789
9790
|
const clampWidth = (w, c) => {
|
|
@@ -9907,6 +9908,7 @@ function Datatable({
|
|
|
9907
9908
|
};
|
|
9908
9909
|
}, [exportOpen]);
|
|
9909
9910
|
const colByField = React51__default.useMemo(() => Object.fromEntries(cols.map((c) => [c.field, c])), [cols]);
|
|
9911
|
+
const fieldLabel = (f) => colLabel(colByField[f] || { field: f });
|
|
9910
9912
|
const combineSources = React51__default.useMemo(() => {
|
|
9911
9913
|
const s = /* @__PURE__ */ new Set();
|
|
9912
9914
|
for (const cfg of Object.values(userCombine)) (cfg && cfg.fields ? cfg.fields : []).slice(1).forEach((f) => s.add(f));
|
|
@@ -10067,7 +10069,7 @@ function Datatable({
|
|
|
10067
10069
|
const v = computeAgg({ ...c, aggregation: agg }, rowsIn);
|
|
10068
10070
|
if (v == null) continue;
|
|
10069
10071
|
const disp = c.aggregationFormatter ? c.aggregationFormatter(v) : c.valueFormatter ? c.valueFormatter(v, null) : typeof v === "number" ? v.toLocaleString() : v;
|
|
10070
|
-
parts.push(`${c
|
|
10072
|
+
parts.push(`${colLabel(c)} ${disp}`);
|
|
10071
10073
|
}
|
|
10072
10074
|
return parts;
|
|
10073
10075
|
}
|
|
@@ -10420,7 +10422,7 @@ function Datatable({
|
|
|
10420
10422
|
next.splice(dir > 0 ? b + 1 : b, 0, field);
|
|
10421
10423
|
return next;
|
|
10422
10424
|
});
|
|
10423
|
-
const label =
|
|
10425
|
+
const label = fieldLabel(field);
|
|
10424
10426
|
setReorderMsg(`Moved ${label} ${dir < 0 ? "left" : "right"}.`);
|
|
10425
10427
|
}
|
|
10426
10428
|
function optionsForField(field) {
|
|
@@ -10527,7 +10529,7 @@ function Datatable({
|
|
|
10527
10529
|
const rowXml = (cells, r2) => `<row r="${r2}">${cells.map((v, ci) => cell(`${colLetter(ci)}${r2}`, v)).join("")}</row>`;
|
|
10528
10530
|
const lastCell = `${expCols.length ? colLetter(expCols.length - 1) : "A"}${source.length + 1}`;
|
|
10529
10531
|
const sheet = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
10530
|
-
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><dimension ref="A1:${lastCell}"/><sheetViews><sheetView tabSelected="1" workbookViewId="0"/></sheetViews><sheetData>` + rowXml(expCols.map((c) => c
|
|
10532
|
+
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><dimension ref="A1:${lastCell}"/><sheetViews><sheetView tabSelected="1" workbookViewId="0"/></sheetViews><sheetData>` + rowXml(expCols.map((c) => colLabel(c)), 1) + source.map((row, ri) => rowXml(expCols.map((c) => cellValue(c, row)), ri + 2)).join("") + "</sheetData></worksheet>";
|
|
10531
10533
|
download(xlsxPackage(sheet), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlsx");
|
|
10532
10534
|
return;
|
|
10533
10535
|
}
|
|
@@ -10535,7 +10537,7 @@ function Datatable({
|
|
|
10535
10537
|
const s = defang(v, v == null ? "" : String(v));
|
|
10536
10538
|
return /[",\n]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
|
|
10537
10539
|
};
|
|
10538
|
-
const header = expCols.map((c) => escape(c
|
|
10540
|
+
const header = expCols.map((c) => escape(colLabel(c))).join(",");
|
|
10539
10541
|
const lines = source.map((row) => expCols.map((c) => escape(cellValue(c, row))).join(","));
|
|
10540
10542
|
const text = "\uFEFF" + [header, ...lines].join("\r\n");
|
|
10541
10543
|
download(text, "text/csv;charset=utf-8;", "csv");
|
|
@@ -11072,7 +11074,7 @@ function Datatable({
|
|
|
11072
11074
|
const widest = (labels) => labels.reduce((m, l) => Math.max(m, ctx.measureText(String(l)).width), 0);
|
|
11073
11075
|
const logicW = Math.min(180, Math.max(84, Math.ceil(widest(["And", "Or"]) + chrome)));
|
|
11074
11076
|
const colCap = Math.max(118, Math.min(210, el.clientWidth - logicW - 118 - 30 - 30 - 140 - 5 * 6 - 2 * 4));
|
|
11075
|
-
const colW = Math.min(colCap, Math.max(118, Math.ceil(widest(filterableCols.map((c) => c
|
|
11077
|
+
const colW = Math.min(colCap, Math.max(118, Math.ceil(widest(filterableCols.map((c) => colLabel(c))) + chrome)));
|
|
11076
11078
|
const opW = Math.min(170, Math.max(118, Math.ceil(widest(ALL_OP_LABELS) + chrome)));
|
|
11077
11079
|
if (Number.isFinite(logicW)) el.style.setProperty("--twc-dt-flogic-fit", `${logicW}px`);
|
|
11078
11080
|
if (Number.isFinite(colW)) el.style.setProperty("--twc-dt-fcol-fit", `${colW}px`);
|
|
@@ -11435,7 +11437,7 @@ function Datatable({
|
|
|
11435
11437
|
const i = order.indexOf(f);
|
|
11436
11438
|
return i === -1 ? 9999 : i;
|
|
11437
11439
|
};
|
|
11438
|
-
const shownColRows = cols.filter((c) => c.field !== "__pinactions__" && c.
|
|
11440
|
+
const shownColRows = cols.filter((c) => c.field !== "__pinactions__" && colLabel(c).toLowerCase().includes(colQuery.trim().toLowerCase())).sort((a, b) => orderIdxOf(a.field) - orderIdxOf(b.field));
|
|
11439
11441
|
const rowNumMatch = rowNumbers && "row number".includes(colQuery.trim().toLowerCase());
|
|
11440
11442
|
const manageableCols = cols.filter((c) => c.field !== "__pinactions__");
|
|
11441
11443
|
const visibleColCount = manageableCols.filter((c) => !effectiveHidden.has(c.field)).length;
|
|
@@ -11455,7 +11457,7 @@ function Datatable({
|
|
|
11455
11457
|
children: [
|
|
11456
11458
|
/* @__PURE__ */ jsx("span", { className: "twc-dt__group-chev", "data-open": !item.collapsed || void 0, children: /* @__PURE__ */ jsx(Svg, { d: I.chevDown }) }),
|
|
11457
11459
|
/* @__PURE__ */ jsxs("span", { className: "twc-dt__group-name", children: [
|
|
11458
|
-
|
|
11460
|
+
fieldLabel(item.field),
|
|
11459
11461
|
":"
|
|
11460
11462
|
] }),
|
|
11461
11463
|
/* @__PURE__ */ jsx("span", { className: "twc-dt__group-val", children: String(item.value) }),
|
|
@@ -11677,8 +11679,8 @@ function Datatable({
|
|
|
11677
11679
|
const f = v.valueFormatter || col?.valueFormatter;
|
|
11678
11680
|
return f ? f(val, null) : typeof val === "number" ? val.toLocaleString() : val;
|
|
11679
11681
|
};
|
|
11680
|
-
const vlabel = (v) => v.label || (
|
|
11681
|
-
const rowFieldLabel = rFields.map((f) =>
|
|
11682
|
+
const vlabel = (v) => v.label || fieldLabel(v.field);
|
|
11683
|
+
const rowFieldLabel = rFields.map((f) => fieldLabel(f)).join(" / ");
|
|
11682
11684
|
const leafPaths = [];
|
|
11683
11685
|
const seen2 = /* @__PURE__ */ new Set();
|
|
11684
11686
|
for (const r2 of rows) {
|
|
@@ -11973,8 +11975,8 @@ function Datatable({
|
|
|
11973
11975
|
/* @__PURE__ */ jsx(Svg, { d: I.group }),
|
|
11974
11976
|
/* @__PURE__ */ jsx("span", { className: "twc-dt__groupbar-label", children: "Grouped by" }),
|
|
11975
11977
|
activeGroupBy.map((f) => /* @__PURE__ */ jsxs("span", { className: "twc-dt__groupchip", children: [
|
|
11976
|
-
|
|
11977
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__groupchip-x", "aria-label": `Stop grouping by ${
|
|
11978
|
+
fieldLabel(f),
|
|
11979
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__groupchip-x", "aria-label": `Stop grouping by ${fieldLabel(f)}`, onClick: () => toggleGroupField(f), children: /* @__PURE__ */ jsx(Svg, { d: I.x }) })
|
|
11978
11980
|
] }, f)),
|
|
11979
11981
|
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__groupbar-clear", onClick: () => setGroupBy([]), children: "Clear all" })
|
|
11980
11982
|
] }) : null,
|
|
@@ -12096,8 +12098,8 @@ function Datatable({
|
|
|
12096
12098
|
className: "twc-dt__th-label",
|
|
12097
12099
|
role: c.sortable ? "button" : void 0,
|
|
12098
12100
|
tabIndex: c.sortable ? 0 : void 0,
|
|
12099
|
-
"data-ovtext": typeof c.headerName === "string" ? c.headerName : void 0,
|
|
12100
|
-
"aria-label": c.sortable ? `${c
|
|
12101
|
+
"data-ovtext": !c.renderHeader && typeof c.headerName === "string" ? c.headerName : void 0,
|
|
12102
|
+
"aria-label": c.sortable ? `${colLabel(c)}, sort` : void 0,
|
|
12101
12103
|
draggable: reorderable || void 0,
|
|
12102
12104
|
onDragStart: reorderable ? (e) => {
|
|
12103
12105
|
setDrag({ from: c.field, over: null, after: false });
|
|
@@ -12115,7 +12117,7 @@ function Datatable({
|
|
|
12115
12117
|
children: [
|
|
12116
12118
|
reorderable ? /* @__PURE__ */ jsx("span", { className: "twc-dt__grip", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Svg, { d: I.grip }) }) : null,
|
|
12117
12119
|
filteredFields.has(c.field) ? /* @__PURE__ */ jsx("span", { className: "twc-dt__filterdot" }) : null,
|
|
12118
|
-
c.headerName,
|
|
12120
|
+
c.renderHeader ? c.renderHeader({ column: c }) : c.headerName,
|
|
12119
12121
|
c.sortable ? /* @__PURE__ */ jsx("span", { className: "twc-dt__sort", children: /* @__PURE__ */ jsx(Svg, { d: I.arrow }) }) : null
|
|
12120
12122
|
]
|
|
12121
12123
|
}
|
|
@@ -12151,7 +12153,7 @@ function Datatable({
|
|
|
12151
12153
|
"data-active": resizing || void 0,
|
|
12152
12154
|
role: "separator",
|
|
12153
12155
|
"aria-orientation": "vertical",
|
|
12154
|
-
"aria-label": `Resize ${c
|
|
12156
|
+
"aria-label": `Resize ${colLabel(c)} column (double-click to fit content)`,
|
|
12155
12157
|
"aria-valuenow": w,
|
|
12156
12158
|
"aria-valuemin": 72,
|
|
12157
12159
|
tabIndex: 0,
|
|
@@ -12326,15 +12328,15 @@ function Datatable({
|
|
|
12326
12328
|
placeholder: "Add a column\u2026",
|
|
12327
12329
|
value: "",
|
|
12328
12330
|
"aria-label": "Add a column to edit",
|
|
12329
|
-
options: unpicked.map((c) => ({ value: c.field, label:
|
|
12331
|
+
options: unpicked.map((c) => ({ value: c.field, label: colLabel(c) })),
|
|
12330
12332
|
onChange: addField
|
|
12331
12333
|
}
|
|
12332
12334
|
) }) : null,
|
|
12333
12335
|
/* @__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) => {
|
|
12334
12336
|
const opts = c.valueOptions ? c.valueOptions.map((o) => typeof o === "string" ? { value: o, label: o } : o) : null;
|
|
12335
12337
|
return /* @__PURE__ */ jsxs("div", { className: "twc-dt__be-row", children: [
|
|
12336
|
-
/* @__PURE__ */ jsxs("span", { className: "twc-dt__be-name", title:
|
|
12337
|
-
/* @__PURE__ */ jsx("span", { className: "twc-dt__be-name-txt", children: c
|
|
12338
|
+
/* @__PURE__ */ jsxs("span", { className: "twc-dt__be-name", title: colLabel(c), children: [
|
|
12339
|
+
/* @__PURE__ */ jsx("span", { className: "twc-dt__be-name-txt", children: colLabel(c) }),
|
|
12338
12340
|
resizableFilters && i === 0 ? /* @__PURE__ */ jsx(
|
|
12339
12341
|
"span",
|
|
12340
12342
|
{
|
|
@@ -12374,7 +12376,7 @@ function Datatable({
|
|
|
12374
12376
|
onChange: (e) => setBatchEdit((b) => ({ ...b, values: { ...b.values, [c.field]: e.target.value } }))
|
|
12375
12377
|
}
|
|
12376
12378
|
) }),
|
|
12377
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__be-x", "aria-label": `Remove ${
|
|
12379
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__be-x", "aria-label": `Remove ${colLabel(c)}`, onClick: () => removeField(c.field), children: /* @__PURE__ */ jsx(Svg, { d: I.x }) })
|
|
12378
12380
|
] }, c.field);
|
|
12379
12381
|
}) }),
|
|
12380
12382
|
/* @__PURE__ */ jsxs("div", { className: "twc-dt__cfg-foot", children: [
|
|
@@ -12646,7 +12648,7 @@ function Datatable({
|
|
|
12646
12648
|
children: [
|
|
12647
12649
|
canDrag ? /* @__PURE__ */ jsx("span", { className: "twc-dt__col-grip", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Svg, { d: I.grip }) }) : null,
|
|
12648
12650
|
/* @__PURE__ */ jsxs("span", { className: "twc-dt__col-name", children: [
|
|
12649
|
-
c
|
|
12651
|
+
colLabel(c),
|
|
12650
12652
|
combineSources.has(c.field) ? /* @__PURE__ */ jsx("span", { className: "twc-dt__col-combined", children: " \xB7 combined" }) : null
|
|
12651
12653
|
] }),
|
|
12652
12654
|
c.pinnable && c.type !== "actions" ? (
|
|
@@ -12659,7 +12661,7 @@ function Datatable({
|
|
|
12659
12661
|
className: "twc-dt__col-pin",
|
|
12660
12662
|
"data-on": pins.left.includes(c.field) || void 0,
|
|
12661
12663
|
"aria-pressed": pins.left.includes(c.field),
|
|
12662
|
-
"aria-label": `Pin ${c
|
|
12664
|
+
"aria-label": `Pin ${colLabel(c)} to left`,
|
|
12663
12665
|
title: pins.left.includes(c.field) ? "Unpin" : "Pin to left",
|
|
12664
12666
|
onClick: () => setPin(c.field, pins.left.includes(c.field) ? null : "left"),
|
|
12665
12667
|
children: /* @__PURE__ */ jsx(Svg, { d: I.pinL })
|
|
@@ -12672,7 +12674,7 @@ function Datatable({
|
|
|
12672
12674
|
className: "twc-dt__col-pin",
|
|
12673
12675
|
"data-on": pins.right.includes(c.field) || void 0,
|
|
12674
12676
|
"aria-pressed": pins.right.includes(c.field),
|
|
12675
|
-
"aria-label": `Pin ${c
|
|
12677
|
+
"aria-label": `Pin ${colLabel(c)} to right`,
|
|
12676
12678
|
title: pins.right.includes(c.field) ? "Unpin" : "Pin to right",
|
|
12677
12679
|
onClick: () => setPin(c.field, pins.right.includes(c.field) ? null : "right"),
|
|
12678
12680
|
children: /* @__PURE__ */ jsx(Svg, { d: I.pin })
|
|
@@ -12687,7 +12689,7 @@ function Datatable({
|
|
|
12687
12689
|
"data-on": !effectiveHidden.has(c.field) || void 0,
|
|
12688
12690
|
role: "switch",
|
|
12689
12691
|
"aria-checked": !effectiveHidden.has(c.field),
|
|
12690
|
-
"aria-label": c
|
|
12692
|
+
"aria-label": colLabel(c),
|
|
12691
12693
|
"aria-disabled": !c.hideable || combineSources.has(c.field) || void 0,
|
|
12692
12694
|
tabIndex: c.hideable && !combineSources.has(c.field) ? 0 : -1,
|
|
12693
12695
|
onKeyDown: (e) => {
|
|
@@ -12711,17 +12713,17 @@ function Datatable({
|
|
|
12711
12713
|
const target = colByField[combineTarget];
|
|
12712
12714
|
const candidates = cols.filter((c) => c.field !== combineTarget && c.type !== "actions" && c.field !== "__pinactions__" && c.hideable !== false && !userCombine[c.field]);
|
|
12713
12715
|
const toggle = (f) => setCombineDraft((d) => ({ ...d, selected: d.selected.includes(f) ? d.selected.filter((x) => x !== f) : [...d.selected, f] }));
|
|
12714
|
-
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
|
|
12716
|
+
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 ? colLabel(target) : combineTarget}`, children: [
|
|
12715
12717
|
/* @__PURE__ */ jsx("div", { className: "twc-dt__panel-head", children: /* @__PURE__ */ jsxs("span", { className: "twc-dt__panel-title", children: [
|
|
12716
12718
|
"Combine into \u201C",
|
|
12717
|
-
target
|
|
12719
|
+
target ? colLabel(target) : combineTarget,
|
|
12718
12720
|
"\u201D"
|
|
12719
12721
|
] }) }),
|
|
12720
12722
|
/* @__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." }),
|
|
12721
12723
|
/* @__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) => {
|
|
12722
12724
|
const on = combineDraft.selected.includes(c.field);
|
|
12723
12725
|
return /* @__PURE__ */ jsxs("div", { className: "twc-dt__col-row", onClick: () => toggle(c.field), children: [
|
|
12724
|
-
/* @__PURE__ */ jsx("span", { className: "twc-dt__col-name", children: c
|
|
12726
|
+
/* @__PURE__ */ jsx("span", { className: "twc-dt__col-name", children: colLabel(c) }),
|
|
12725
12727
|
/* @__PURE__ */ jsx(
|
|
12726
12728
|
"span",
|
|
12727
12729
|
{
|
|
@@ -12729,7 +12731,7 @@ function Datatable({
|
|
|
12729
12731
|
"data-on": on || void 0,
|
|
12730
12732
|
role: "switch",
|
|
12731
12733
|
"aria-checked": on,
|
|
12732
|
-
"aria-label": c
|
|
12734
|
+
"aria-label": colLabel(c),
|
|
12733
12735
|
tabIndex: 0,
|
|
12734
12736
|
onKeyDown: (e) => {
|
|
12735
12737
|
if (e.key === "Enter" || e.key === " ") {
|
|
@@ -12812,7 +12814,7 @@ function Datatable({
|
|
|
12812
12814
|
const numeric = c.type === "number";
|
|
12813
12815
|
const opts = numeric ? [{ value: "", label: "None" }, { value: "sum", label: "Sum" }, { value: "avg", label: "Avg" }, { value: "min", label: "Min" }, { value: "max", label: "Max" }, { value: "count", label: "Count" }] : [{ value: "", label: "None" }, { value: "count", label: "Count" }];
|
|
12814
12816
|
return /* @__PURE__ */ jsxs("div", { className: "twc-dt__cfg-row", children: [
|
|
12815
|
-
/* @__PURE__ */ jsx("span", { className: "twc-dt__cfg-name", children: c
|
|
12817
|
+
/* @__PURE__ */ jsx("span", { className: "twc-dt__cfg-name", children: colLabel(c) }),
|
|
12816
12818
|
/* @__PURE__ */ jsx("div", { className: "twc-dt__cfg-ctl", children: /* @__PURE__ */ jsx(
|
|
12817
12819
|
Select,
|
|
12818
12820
|
{
|
|
@@ -12836,9 +12838,9 @@ function Datatable({
|
|
|
12836
12838
|
popGrip("agg")
|
|
12837
12839
|
] }) : null,
|
|
12838
12840
|
panel === "pivot" && panelPos ? (() => {
|
|
12839
|
-
const fieldOpts = ordered.filter((c) => c.type !== "actions").map((c) => ({ value: c.field, label: c
|
|
12841
|
+
const fieldOpts = ordered.filter((c) => c.type !== "actions").map((c) => ({ value: c.field, label: colLabel(c) }));
|
|
12840
12842
|
const aggOpts = [{ value: "sum", label: "Sum" }, { value: "avg", label: "Avg" }, { value: "min", label: "Min" }, { value: "max", label: "Max" }, { value: "count", label: "Count" }];
|
|
12841
|
-
const valueFieldOpts = ordered.filter((c) => c.type !== "actions" && !pivotConfig.values.some((v) => v.field === c.field)).map((c) => ({ value: c.field, label: c
|
|
12843
|
+
const valueFieldOpts = ordered.filter((c) => c.type !== "actions" && !pivotConfig.values.some((v) => v.field === c.field)).map((c) => ({ value: c.field, label: colLabel(c) }));
|
|
12842
12844
|
return /* @__PURE__ */ jsxs("div", { className: "twc-dt__pop twc-dt__cfg", style: { top: panelPos.top, left: panelPos.left, width: 320, ...popStyle("pivot") }, "data-pop-sized": popSizes.pivot ? "" : void 0, role: "dialog", "aria-label": "Pivot settings", children: [
|
|
12843
12845
|
/* @__PURE__ */ jsxs("div", { className: "twc-dt__panel-head", children: [
|
|
12844
12846
|
/* @__PURE__ */ jsx("span", { className: "twc-dt__panel-title", children: "Pivot" }),
|
|
@@ -12907,7 +12909,7 @@ function Datatable({
|
|
|
12907
12909
|
/* @__PURE__ */ jsxs("div", { className: "twc-dt__cfg-section", children: [
|
|
12908
12910
|
/* @__PURE__ */ jsx("span", { className: "twc-dt__cfg-label", children: "Values" }),
|
|
12909
12911
|
pivotConfig.values.map((v, i) => /* @__PURE__ */ jsxs("div", { className: "twc-dt__cfg-row", children: [
|
|
12910
|
-
/* @__PURE__ */ jsx("span", { className: "twc-dt__cfg-name", children:
|
|
12912
|
+
/* @__PURE__ */ jsx("span", { className: "twc-dt__cfg-name", children: fieldLabel(v.field) }),
|
|
12911
12913
|
/* @__PURE__ */ jsx("div", { className: "twc-dt__cfg-ctl", children: /* @__PURE__ */ jsx(
|
|
12912
12914
|
Select,
|
|
12913
12915
|
{
|
|
@@ -12923,7 +12925,7 @@ function Datatable({
|
|
|
12923
12925
|
{
|
|
12924
12926
|
type: "button",
|
|
12925
12927
|
className: "twc-dt__cfg-x",
|
|
12926
|
-
"aria-label": `Remove ${
|
|
12928
|
+
"aria-label": `Remove ${fieldLabel(v.field)}`,
|
|
12927
12929
|
onClick: () => setPivotConfig((p) => ({ ...p, values: p.values.filter((_, j) => j !== i) })),
|
|
12928
12930
|
children: /* @__PURE__ */ jsx(Svg, { d: I.x })
|
|
12929
12931
|
}
|
|
@@ -13005,7 +13007,7 @@ function Datatable({
|
|
|
13005
13007
|
size: "sm",
|
|
13006
13008
|
portal: true,
|
|
13007
13009
|
value: f.field,
|
|
13008
|
-
options: filterableCols.map((c) => ({ value: c.field, label: c
|
|
13010
|
+
options: filterableCols.map((c) => ({ value: c.field, label: colLabel(c) })),
|
|
13009
13011
|
onChange: (v) => {
|
|
13010
13012
|
const nc = colByField[v];
|
|
13011
13013
|
setFilters((arr) => arr.map((x) => x.id === f.id ? { ...x, field: v, op: opsFor(filterTypeOf(nc))[0].value, value: "" } : x));
|
|
@@ -13062,7 +13064,7 @@ function Datatable({
|
|
|
13062
13064
|
),
|
|
13063
13065
|
fieldHandle("val", i)
|
|
13064
13066
|
] }),
|
|
13065
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__frm-x", "aria-label": `Add another condition on ${col
|
|
13067
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__frm-x", "aria-label": `Add another condition on ${colLabel(col)}`, title: "Add another condition on this column", onClick: () => addFilter(f.field), children: /* @__PURE__ */ jsx(Svg, { d: I.plus }) }),
|
|
13066
13068
|
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__frm-x", "aria-label": "Remove filter", onClick: () => setFilters((arr) => arr.filter((x) => x.id !== f.id)), children: /* @__PURE__ */ jsx(Svg, { d: I.x }) })
|
|
13067
13069
|
] }, f.id);
|
|
13068
13070
|
}) }),
|