twico-ui 1.27.0 → 1.28.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 +35 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.mjs +35 -17
- package/dist/index.mjs.map +1 -1
- package/llms.txt +2 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1843,6 +1843,10 @@ interface DatatableProps<T = any> extends Omit<React.HTMLAttributes<HTMLDivEleme
|
|
|
1843
1843
|
* full row objects server-side rather than relying on `selectedRows`.
|
|
1844
1844
|
*/
|
|
1845
1845
|
batchActions?: DatatableBatchAction<T>[];
|
|
1846
|
+
/** #322: fired when the checkbox row selection changes — `(keys, rows)`. The row-mode analogue of
|
|
1847
|
+
* `onCellSelectionChange`, so a consumer can track the selection and drive a batch action's own
|
|
1848
|
+
* `disabled`/`hidden` (which also accept predicates). */
|
|
1849
|
+
onRowSelectionChange?: (keys: Array<string | number>, rows: T[]) => void;
|
|
1846
1850
|
/** Row height preset. With `showDensity`, the toolbar density button cycles it locally; changing this prop re-applies it. @default "comfortable" */
|
|
1847
1851
|
density?: "compact" | "standard" | "comfortable";
|
|
1848
1852
|
/**
|
|
@@ -2229,7 +2233,12 @@ interface DatatableBatchAction<T = any> {
|
|
|
2229
2233
|
) => void;
|
|
2230
2234
|
/** Render in danger color. */
|
|
2231
2235
|
danger?: boolean;
|
|
2232
|
-
|
|
2236
|
+
/** #322: disable the action — a static boolean, or a predicate evaluated against the current selection so
|
|
2237
|
+
* an action that only applies to a subset of the selected rows can grey out when it doesn't apply. */
|
|
2238
|
+
disabled?: boolean | ((keys: Array<string | number>, rows: T[]) => boolean);
|
|
2239
|
+
/** #322: hide the action entirely when the predicate returns true (e.g. `(_, rows) => rows.every(r => r.isGroup)`
|
|
2240
|
+
* drops "Mark as new thread" when only group rows are selected). A static `true` always hides it. */
|
|
2241
|
+
hidden?: boolean | ((keys: Array<string | number>, rows: T[]) => boolean);
|
|
2233
2242
|
}
|
|
2234
2243
|
|
|
2235
2244
|
declare function Datatable<T = any>(props: DatatableProps<T>): React.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -1843,6 +1843,10 @@ interface DatatableProps<T = any> extends Omit<React.HTMLAttributes<HTMLDivEleme
|
|
|
1843
1843
|
* full row objects server-side rather than relying on `selectedRows`.
|
|
1844
1844
|
*/
|
|
1845
1845
|
batchActions?: DatatableBatchAction<T>[];
|
|
1846
|
+
/** #322: fired when the checkbox row selection changes — `(keys, rows)`. The row-mode analogue of
|
|
1847
|
+
* `onCellSelectionChange`, so a consumer can track the selection and drive a batch action's own
|
|
1848
|
+
* `disabled`/`hidden` (which also accept predicates). */
|
|
1849
|
+
onRowSelectionChange?: (keys: Array<string | number>, rows: T[]) => void;
|
|
1846
1850
|
/** Row height preset. With `showDensity`, the toolbar density button cycles it locally; changing this prop re-applies it. @default "comfortable" */
|
|
1847
1851
|
density?: "compact" | "standard" | "comfortable";
|
|
1848
1852
|
/**
|
|
@@ -2229,7 +2233,12 @@ interface DatatableBatchAction<T = any> {
|
|
|
2229
2233
|
) => void;
|
|
2230
2234
|
/** Render in danger color. */
|
|
2231
2235
|
danger?: boolean;
|
|
2232
|
-
|
|
2236
|
+
/** #322: disable the action — a static boolean, or a predicate evaluated against the current selection so
|
|
2237
|
+
* an action that only applies to a subset of the selected rows can grey out when it doesn't apply. */
|
|
2238
|
+
disabled?: boolean | ((keys: Array<string | number>, rows: T[]) => boolean);
|
|
2239
|
+
/** #322: hide the action entirely when the predicate returns true (e.g. `(_, rows) => rows.every(r => r.isGroup)`
|
|
2240
|
+
* drops "Mark as new thread" when only group rows are selected). A static `true` always hides it. */
|
|
2241
|
+
hidden?: boolean | ((keys: Array<string | number>, rows: T[]) => boolean);
|
|
2233
2242
|
}
|
|
2234
2243
|
|
|
2235
2244
|
declare function Datatable<T = any>(props: DatatableProps<T>): React.JSX.Element;
|
package/dist/index.mjs
CHANGED
|
@@ -9137,6 +9137,7 @@ function Datatable({
|
|
|
9137
9137
|
onServerChange,
|
|
9138
9138
|
onColumnVisibilityChange,
|
|
9139
9139
|
batchActions = [],
|
|
9140
|
+
onRowSelectionChange,
|
|
9140
9141
|
showExport = false,
|
|
9141
9142
|
showDensity = false,
|
|
9142
9143
|
showPivot = false,
|
|
@@ -10389,6 +10390,18 @@ function Datatable({
|
|
|
10389
10390
|
setFocus((f) => ({ r: Math.min(f.r, Math.max(0, leafRows.length - 1)), c: Math.min(f.c, Math.max(0, ordered.length - 1)) }));
|
|
10390
10391
|
}, [leafRows.length, ordered.length, pageVal]);
|
|
10391
10392
|
const selectedRows = React51__default.useMemo(() => rows.filter((r2, i) => selected.has(keyOf(r2, i))), [rows, selected]);
|
|
10393
|
+
const selKeys = React51__default.useMemo(() => [...selected], [selected]);
|
|
10394
|
+
const onRowSelRef = React51__default.useRef(onRowSelectionChange);
|
|
10395
|
+
onRowSelRef.current = onRowSelectionChange;
|
|
10396
|
+
const prevRowSelSigRef = React51__default.useRef("");
|
|
10397
|
+
React51__default.useEffect(() => {
|
|
10398
|
+
const cb = onRowSelRef.current;
|
|
10399
|
+
if (!cb) return;
|
|
10400
|
+
const sig = selKeys.join(",");
|
|
10401
|
+
if (sig === prevRowSelSigRef.current) return;
|
|
10402
|
+
prevRowSelSigRef.current = sig;
|
|
10403
|
+
cb(selKeys, selectedRows);
|
|
10404
|
+
}, [selKeys, selectedRows]);
|
|
10392
10405
|
function clearSelection() {
|
|
10393
10406
|
setSelected(/* @__PURE__ */ new Set());
|
|
10394
10407
|
}
|
|
@@ -10485,11 +10498,11 @@ function Datatable({
|
|
|
10485
10498
|
}
|
|
10486
10499
|
patch[c.field] = v;
|
|
10487
10500
|
});
|
|
10488
|
-
const
|
|
10501
|
+
const selKeys2 = new Set(selected);
|
|
10489
10502
|
const changedRows = [];
|
|
10490
10503
|
const nextAll = rows.map((r2, i) => {
|
|
10491
10504
|
const k = keyOf(r2, i);
|
|
10492
|
-
if (!
|
|
10505
|
+
if (!selKeys2.has(k)) return r2;
|
|
10493
10506
|
const updated = { ...r2, ...patch };
|
|
10494
10507
|
changedRows.push(updated);
|
|
10495
10508
|
return updated;
|
|
@@ -11379,21 +11392,26 @@ function Datatable({
|
|
|
11379
11392
|
/* @__PURE__ */ jsx(Svg, { d: I.pencil }),
|
|
11380
11393
|
"Edit"
|
|
11381
11394
|
] }) : null,
|
|
11382
|
-
batchActions.map((a, i) =>
|
|
11383
|
-
"
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
"
|
|
11388
|
-
|
|
11389
|
-
|
|
11390
|
-
|
|
11391
|
-
a.
|
|
11392
|
-
|
|
11393
|
-
|
|
11394
|
-
|
|
11395
|
-
|
|
11396
|
-
|
|
11395
|
+
batchActions.map((a, i) => {
|
|
11396
|
+
const isHidden = typeof a.hidden === "function" ? a.hidden(selKeys, selectedRows) : !!a.hidden;
|
|
11397
|
+
if (isHidden) return null;
|
|
11398
|
+
const isDisabled = typeof a.disabled === "function" ? a.disabled(selKeys, selectedRows) : !!a.disabled;
|
|
11399
|
+
return /* @__PURE__ */ jsxs(
|
|
11400
|
+
"button",
|
|
11401
|
+
{
|
|
11402
|
+
type: "button",
|
|
11403
|
+
className: "twc-dt__batch-btn",
|
|
11404
|
+
"data-danger": a.danger || void 0,
|
|
11405
|
+
disabled: isDisabled,
|
|
11406
|
+
onClick: (e) => a.onClick?.(selKeys, selectedRows, clearSelection, { anchorEl: e.currentTarget }),
|
|
11407
|
+
children: [
|
|
11408
|
+
a.icon,
|
|
11409
|
+
a.label
|
|
11410
|
+
]
|
|
11411
|
+
},
|
|
11412
|
+
i
|
|
11413
|
+
);
|
|
11414
|
+
})
|
|
11397
11415
|
] })
|
|
11398
11416
|
] }) : null,
|
|
11399
11417
|
isDiff && diff.showSummary !== false ? /* @__PURE__ */ jsxs("span", { className: "twc-dt__diff-summary", "aria-label": "Diff summary", children: [
|