@wordrhyme/auto-crud 1.23.3 → 1.24.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/README.md +6 -0
- package/dist/index.cjs +195 -31
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +196 -32
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1211,6 +1211,12 @@ open({
|
|
|
1211
1211
|
|
|
1212
1212
|
## 🔄 批量操作
|
|
1213
1213
|
|
|
1214
|
+
在同一查询结果中,勾选记录后可以翻页继续选择。表头复选框只勾选或取消当前页,批量操作栏的“清空选择”会清空所有页。选中计数、批量更新、删除和导出都使用累计勾选的记录。重新加载已选记录时,批量操作使用最近加载的数据。
|
|
1215
|
+
|
|
1216
|
+
使用 `useAutoCrudResource` 时,更换列表路由、搜索词、筛选条件或 `query` 注入的条件(如搜索图片)会清空选择。翻页、调整每页数量和排序可以保留选择。新请求等待期间,表格继续显示上一份数据时会禁用勾选。单行删除成功后,表格会移除该记录的勾选,保留其他记录。
|
|
1217
|
+
|
|
1218
|
+
`AutoCrudTable` 使用 `resource.idKey`(默认 `id`)识别记录,显式传入的 `table.getRowId` 优先。独立使用 `AutoTable` 时,默认读取 `id`,也可以传入 `getRowId`。跨页选择要求主键在整个结果集中唯一。缺少主键的记录只在当前加载的数据中保留选择。手动分页时,可用 `pagePending` 标记加载中或占位的数据,待当前页响应到达后恢复勾选。
|
|
1219
|
+
|
|
1214
1220
|
### 批量更新
|
|
1215
1221
|
|
|
1216
1222
|
```typescript
|
package/dist/index.cjs
CHANGED
|
@@ -15,12 +15,12 @@ let clsx = require("clsx");
|
|
|
15
15
|
clsx = require_position.__toESM(clsx);
|
|
16
16
|
let tailwind_merge = require("tailwind-merge");
|
|
17
17
|
tailwind_merge = require_position.__toESM(tailwind_merge);
|
|
18
|
+
let __tanstack_react_table = require("@tanstack/react-table");
|
|
19
|
+
__tanstack_react_table = require_position.__toESM(__tanstack_react_table);
|
|
18
20
|
let __wordrhyme_shadcn_ui = require("@wordrhyme/shadcn-ui");
|
|
19
21
|
__wordrhyme_shadcn_ui = require_position.__toESM(__wordrhyme_shadcn_ui);
|
|
20
22
|
let nanoid = require("nanoid");
|
|
21
23
|
nanoid = require_position.__toESM(nanoid);
|
|
22
|
-
let __tanstack_react_table = require("@tanstack/react-table");
|
|
23
|
-
__tanstack_react_table = require_position.__toESM(__tanstack_react_table);
|
|
24
24
|
let __wordrhyme_ui = require("@wordrhyme/ui");
|
|
25
25
|
__wordrhyme_ui = require_position.__toESM(__wordrhyme_ui);
|
|
26
26
|
let __wordrhyme_formily_shadcn = require("@wordrhyme/formily-shadcn");
|
|
@@ -252,6 +252,34 @@ const dataTableConfig = {
|
|
|
252
252
|
|
|
253
253
|
//#endregion
|
|
254
254
|
//#region src/lib/data-table.ts
|
|
255
|
+
function readRowId(row, idKey) {
|
|
256
|
+
const value = row[idKey];
|
|
257
|
+
return value === null || value === void 0 ? void 0 : String(value);
|
|
258
|
+
}
|
|
259
|
+
function getSelectedTableRows(table) {
|
|
260
|
+
return table.options.meta?.selectedRows ?? table.getFilteredSelectedRowModel().rows;
|
|
261
|
+
}
|
|
262
|
+
function createRowSelectionScope() {
|
|
263
|
+
const listeners$1 = /* @__PURE__ */ new Set();
|
|
264
|
+
return {
|
|
265
|
+
onDelete(listener) {
|
|
266
|
+
listeners$1.add(listener);
|
|
267
|
+
return () => {
|
|
268
|
+
listeners$1.delete(listener);
|
|
269
|
+
};
|
|
270
|
+
},
|
|
271
|
+
notifyDeleted(row) {
|
|
272
|
+
listeners$1.forEach((listener) => listener(row));
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/** Infer a total only when the loaded page accounts for the whole result. */
|
|
277
|
+
function getSelectionTotal(table, loadedPageIndex = table.getState().pagination.pageIndex) {
|
|
278
|
+
if (table.options.rowCount !== void 0 || !table.options.manualPagination) return table.getRowCount();
|
|
279
|
+
const pages = table.getPageCount();
|
|
280
|
+
if (pages === 0) return 0;
|
|
281
|
+
if (pages === 1 && loadedPageIndex === 0) return table.getFilteredRowModel().rows.length;
|
|
282
|
+
}
|
|
255
283
|
function getColumnPinningStyle({ column, withBorder = false }) {
|
|
256
284
|
const isPinned = column.getIsPinned();
|
|
257
285
|
const isLastLeftPinnedColumn = isPinned === "left" && column.getIsLastColumn("left");
|
|
@@ -3446,6 +3474,8 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3446
3474
|
const canJump = Number.isFinite(pageCount) && pageCount > 0;
|
|
3447
3475
|
const canGoNext = table.getCanNextPage() && (knownPageCount || table.options.data.length >= pageSize);
|
|
3448
3476
|
const total = table.options.rowCount ?? (table.options.manualPagination ? void 0 : table.getRowCount());
|
|
3477
|
+
const selectedCount = getSelectedTableRows(table).length;
|
|
3478
|
+
const selectionTotal = table.options.meta?.selectedRows !== void 0 ? getSelectionTotal(table) : table.getFilteredRowModel().rows.length;
|
|
3449
3479
|
(0, react.useEffect)(() => {
|
|
3450
3480
|
if (!responsive || !container.current || !summary.current || !controls.current || !navigation.current) return;
|
|
3451
3481
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3494,7 +3524,7 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3494
3524
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3495
3525
|
ref: summary,
|
|
3496
3526
|
className: "flex flex-1 items-center gap-6 whitespace-nowrap text-muted-foreground text-sm",
|
|
3497
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: locale.selected(
|
|
3527
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selectionTotal === void 0 || selectedCount > selectionTotal ? (locale.selectedCount ?? enUSActionBar.selected)(selectedCount) : locale.selected(selectedCount, selectionTotal) }), total !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: locale.total(total) })]
|
|
3498
3528
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3499
3529
|
ref: controls,
|
|
3500
3530
|
className: cn("flex items-center gap-4 sm:gap-6 lg:gap-8", responsive ? "flex-row flex-wrap justify-center whitespace-nowrap [&>*]:shrink-0" : "flex-col-reverse sm:flex-row"),
|
|
@@ -3811,7 +3841,7 @@ function DataTable({ table, actionBar, pagination, expandedRow, rowFooter, child
|
|
|
3811
3841
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTablePagination, {
|
|
3812
3842
|
table,
|
|
3813
3843
|
...pagination
|
|
3814
|
-
}), actionBar && table
|
|
3844
|
+
}), actionBar && getSelectedTableRows(table).length > 0 && actionBar]
|
|
3815
3845
|
})
|
|
3816
3846
|
]
|
|
3817
3847
|
});
|
|
@@ -5993,12 +6023,14 @@ function createSelectColumn() {
|
|
|
5993
6023
|
id: "select",
|
|
5994
6024
|
header: ({ table }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Checkbox, {
|
|
5995
6025
|
"aria-label": "Select all",
|
|
6026
|
+
disabled: !table.getPaginationRowModel().flatRows.some((row) => row.getCanSelect()),
|
|
5996
6027
|
className: "translate-y-0.5",
|
|
5997
6028
|
checked: table.getIsAllPageRowsSelected() || table.getIsSomePageRowsSelected() && "indeterminate",
|
|
5998
6029
|
onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
|
|
5999
6030
|
}),
|
|
6000
6031
|
cell: ({ row }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Checkbox, {
|
|
6001
6032
|
"aria-label": "Select row",
|
|
6033
|
+
disabled: !row.getCanSelect(),
|
|
6002
6034
|
className: "translate-y-0.5",
|
|
6003
6035
|
checked: row.getIsSelected(),
|
|
6004
6036
|
onCheckedChange: (value) => row.toggleSelected(!!value)
|
|
@@ -7340,7 +7372,7 @@ function getExportColumnIds(table) {
|
|
|
7340
7372
|
function exportTableToCSV(table, opts = {}) {
|
|
7341
7373
|
const { filename = "table", excludeColumns = [], onlySelected = false } = opts;
|
|
7342
7374
|
const headers = getExportColumnIds(table).filter((id) => !excludeColumns.includes(id));
|
|
7343
|
-
downloadCSV([headers.join(","), ...(onlySelected ? table
|
|
7375
|
+
downloadCSV([headers.join(","), ...(onlySelected ? getSelectedTableRows(table) : table.getRowModel().rows).map((row) => headers.map((header) => {
|
|
7344
7376
|
const cellValue = row.getValue(header);
|
|
7345
7377
|
return typeof cellValue === "string" ? `"${cellValue.replace(/"/g, "\"\"")}"` : cellValue;
|
|
7346
7378
|
}).join(","))].join("\n"), filename);
|
|
@@ -7389,14 +7421,14 @@ function AutoTableActionBar({ table, locale: localeProp, onDeleteSelected, onUpd
|
|
|
7389
7421
|
...enUSActionBar,
|
|
7390
7422
|
...localeProp
|
|
7391
7423
|
}), [localeProp]);
|
|
7392
|
-
const rows = table
|
|
7424
|
+
const rows = getSelectedTableRows(table);
|
|
7393
7425
|
const selectedRows = react.useMemo(() => rows.map((row) => row.original), [rows]);
|
|
7394
7426
|
const [deleteDialogOpen, setDeleteDialogOpen] = react.useState(false);
|
|
7395
7427
|
react.useEffect(() => {
|
|
7396
7428
|
if (selectedRows.length === 0) setDeleteDialogOpen(false);
|
|
7397
7429
|
}, [selectedRows.length]);
|
|
7398
7430
|
const clearSelection = react.useCallback(() => {
|
|
7399
|
-
table.
|
|
7431
|
+
table.resetRowSelection(true);
|
|
7400
7432
|
}, [table]);
|
|
7401
7433
|
const actionContext = react.useMemo(() => ({
|
|
7402
7434
|
rows: selectedRows,
|
|
@@ -7803,7 +7835,7 @@ const filterModeConfig = {
|
|
|
7803
7835
|
tooltip: "Linear-style command filters"
|
|
7804
7836
|
}
|
|
7805
7837
|
};
|
|
7806
|
-
function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, rowFooter, defaultExpanded = false, pageCount = 1, pagination, total, overrides, classNames, enableRowSelection = true, queryKeys, initialColumnVisibility, exclude, filterOnly, actions, pinnedColumns, filterMode, search = false, batchSearch, filterState, toolbarExtra, locale = enUSTableControls, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarLocale, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows, exportTableRef }) {
|
|
7838
|
+
function AutoTable({ resourceId, views, schema, data, getRowId, idKey = "id", selectionScope, pagePending = false, expandedRow, rowFooter, defaultExpanded = false, pageCount = 1, pagination, total, overrides, classNames, enableRowSelection = true, queryKeys, initialColumnVisibility, exclude, filterOnly, actions, pinnedColumns, filterMode, search = false, batchSearch, filterState, toolbarExtra, locale = enUSTableControls, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarLocale, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows, exportTableRef }) {
|
|
7807
7839
|
const inheritedResourceId = (0, react.useContext)(CrudResourceContext);
|
|
7808
7840
|
const activeResourceId = resourceId ?? inheritedResourceId;
|
|
7809
7841
|
const viewsEnabled = views ?? false;
|
|
@@ -7924,12 +7956,28 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
|
|
|
7924
7956
|
actions
|
|
7925
7957
|
]);
|
|
7926
7958
|
const expandedRowModel = (0, react.useMemo)(() => (0, __tanstack_react_table.getExpandedRowModel)(), []);
|
|
7959
|
+
const resolveRowId = (0, react.useMemo)(() => {
|
|
7960
|
+
if (getRowId) return getRowId;
|
|
7961
|
+
const anonymousRows = /* @__PURE__ */ new WeakMap();
|
|
7962
|
+
let nextId = 0;
|
|
7963
|
+
return (record) => {
|
|
7964
|
+
const key = readRowId(record, idKey);
|
|
7965
|
+
if (key !== void 0) return `key:${key}`;
|
|
7966
|
+
let id = anonymousRows.get(record);
|
|
7967
|
+
if (id === void 0) {
|
|
7968
|
+
id = `local:${nextId++}`;
|
|
7969
|
+
anonymousRows.set(record, id);
|
|
7970
|
+
}
|
|
7971
|
+
return id;
|
|
7972
|
+
};
|
|
7973
|
+
}, [getRowId, idKey]);
|
|
7974
|
+
const keyedData = (0, react.useMemo)(() => data.slice(), [data, idKey]);
|
|
7927
7975
|
const { table, shallow, debounceMs, throttleMs } = useDataTable({
|
|
7928
|
-
data,
|
|
7976
|
+
data: keyedData,
|
|
7929
7977
|
columns,
|
|
7930
7978
|
queryKeys,
|
|
7931
|
-
enableRowSelection,
|
|
7932
|
-
getRowId,
|
|
7979
|
+
enableRowSelection: enableRowSelection && !pagePending,
|
|
7980
|
+
getRowId: resolveRowId,
|
|
7933
7981
|
getRowCanExpand: () => enableExpansion,
|
|
7934
7982
|
getExpandedRowModel: enableExpansion ? expandedRowModel : void 0,
|
|
7935
7983
|
autoResetExpanded: defaultExpanded ? false : void 0,
|
|
@@ -7961,14 +8009,95 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
|
|
|
7961
8009
|
exportTableRef.current = null;
|
|
7962
8010
|
};
|
|
7963
8011
|
}, [table, exportTableRef]);
|
|
7964
|
-
const
|
|
7965
|
-
const
|
|
7966
|
-
const
|
|
8012
|
+
const [filters] = useReadableFilters(columns, { state: filterState });
|
|
8013
|
+
const [query] = useQueryState("search", parseAsString.withDefault(""));
|
|
8014
|
+
const [join] = useQueryState(queryKeys?.joinOperator ?? "joinOperator", parseAsString.withDefault("and"));
|
|
8015
|
+
const resultSet = (0, react.useMemo)(() => selectionScope ?? JSON.stringify([
|
|
8016
|
+
query.trim(),
|
|
8017
|
+
join,
|
|
8018
|
+
filterSignature(filters),
|
|
8019
|
+
batchSearch?.filter
|
|
8020
|
+
]), [
|
|
8021
|
+
selectionScope,
|
|
8022
|
+
query,
|
|
8023
|
+
join,
|
|
8024
|
+
filters,
|
|
8025
|
+
batchSearch?.filter
|
|
8026
|
+
]);
|
|
8027
|
+
const scope = (0, react.useMemo)(() => ({
|
|
8028
|
+
activeResourceId,
|
|
8029
|
+
idKey,
|
|
8030
|
+
enableRowSelection,
|
|
8031
|
+
resultSet
|
|
8032
|
+
}), [
|
|
8033
|
+
activeResourceId,
|
|
8034
|
+
idKey,
|
|
8035
|
+
enableRowSelection,
|
|
8036
|
+
resultSet
|
|
8037
|
+
]);
|
|
8038
|
+
const [previousScope, setPreviousScope] = (0, react.useState)(scope);
|
|
8039
|
+
if (previousScope !== scope) {
|
|
8040
|
+
setPreviousScope(scope);
|
|
8041
|
+
table.resetRowSelection(true);
|
|
8042
|
+
}
|
|
8043
|
+
const { rowSelection, pagination: { pageIndex } } = table.getState();
|
|
8044
|
+
const pageSelection = table.getFilteredSelectedRowModel().rows;
|
|
8045
|
+
const retained = (0, react.useRef)([]);
|
|
8046
|
+
const loadedPage = (0, react.useRef)(null);
|
|
8047
|
+
const loadedIndex = loadedPage.current?.data === data ? loadedPage.current.index : pageIndex;
|
|
8048
|
+
const allRowsLoaded = !pagePending && getSelectionTotal(table, loadedIndex) === data.length;
|
|
8049
|
+
const selectedTableRows = (0, react.useMemo)(() => {
|
|
8050
|
+
if (pagePending) return retained.current.filter((row) => rowSelection[row.id]);
|
|
8051
|
+
if (allRowsLoaded || pageSelection.length === Object.keys(rowSelection).length) return pageSelection;
|
|
8052
|
+
const rows = /* @__PURE__ */ new Map();
|
|
8053
|
+
for (const row of retained.current) if (rowSelection[row.id] && (getRowId || row.original[idKey] != null)) rows.set(row.id, row);
|
|
8054
|
+
for (const row of pageSelection) rows.set(row.id, row);
|
|
8055
|
+
return Array.from(rows.values());
|
|
8056
|
+
}, [
|
|
8057
|
+
allRowsLoaded,
|
|
8058
|
+
pagePending,
|
|
8059
|
+
pageSelection,
|
|
8060
|
+
rowSelection,
|
|
8061
|
+
getRowId,
|
|
8062
|
+
idKey
|
|
8063
|
+
]);
|
|
8064
|
+
table.setOptions((options) => ({
|
|
8065
|
+
...options,
|
|
8066
|
+
meta: {
|
|
8067
|
+
...options.meta,
|
|
8068
|
+
selectedRows: selectedTableRows
|
|
8069
|
+
}
|
|
8070
|
+
}));
|
|
8071
|
+
(0, react.useLayoutEffect)(() => {
|
|
8072
|
+
loadedPage.current = pagePending ? null : {
|
|
8073
|
+
data,
|
|
8074
|
+
index: loadedIndex
|
|
8075
|
+
};
|
|
8076
|
+
retained.current = selectedTableRows;
|
|
8077
|
+
if (!pagePending && Object.keys(rowSelection).length > selectedTableRows.length) table.setRowSelection(Object.fromEntries(selectedTableRows.map((row) => [row.id, true])));
|
|
8078
|
+
}, [
|
|
7967
8079
|
table,
|
|
7968
8080
|
rowSelection,
|
|
7969
|
-
|
|
7970
|
-
|
|
8081
|
+
selectedTableRows,
|
|
8082
|
+
pagePending,
|
|
8083
|
+
data,
|
|
8084
|
+
loadedIndex
|
|
7971
8085
|
]);
|
|
8086
|
+
(0, react.useLayoutEffect)(() => selectionScope?.onDelete((deleted) => {
|
|
8087
|
+
const id = readRowId(deleted, idKey);
|
|
8088
|
+
const rows = retained.current.filter((row) => row.original === deleted || id !== void 0 && readRowId(row.original, idKey) === id);
|
|
8089
|
+
if (!rows.length) return;
|
|
8090
|
+
table.setRowSelection((current) => {
|
|
8091
|
+
const next = { ...current };
|
|
8092
|
+
for (const row of rows) delete next[row.id];
|
|
8093
|
+
return next;
|
|
8094
|
+
});
|
|
8095
|
+
}), [
|
|
8096
|
+
selectionScope,
|
|
8097
|
+
table,
|
|
8098
|
+
idKey
|
|
8099
|
+
]);
|
|
8100
|
+
const selectedRows = (0, react.useMemo)(() => selectedTableRows.map((row) => row.original), [selectedTableRows]);
|
|
7972
8101
|
const getSelectedRowsFn = (0, react.useCallback)(() => selectedRows, [selectedRows]);
|
|
7973
8102
|
(0, react.useEffect)(() => {
|
|
7974
8103
|
if (getSelectedRows) getSelectedRows.current = getSelectedRowsFn;
|
|
@@ -8085,20 +8214,28 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
|
|
|
8085
8214
|
});
|
|
8086
8215
|
const state = table.getState();
|
|
8087
8216
|
const tableContent = (0, react.useMemo)(() => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTable, {
|
|
8088
|
-
pagination
|
|
8217
|
+
pagination: {
|
|
8218
|
+
...pagination,
|
|
8219
|
+
locale: {
|
|
8220
|
+
selectedCount: actionBarLocale?.selected,
|
|
8221
|
+
...pagination?.locale
|
|
8222
|
+
}
|
|
8223
|
+
},
|
|
8089
8224
|
table,
|
|
8090
8225
|
classNames,
|
|
8091
8226
|
expandedRow,
|
|
8092
8227
|
rowFooter
|
|
8093
8228
|
}), [
|
|
8094
8229
|
table,
|
|
8095
|
-
|
|
8230
|
+
keyedData,
|
|
8231
|
+
pagePending,
|
|
8096
8232
|
columns,
|
|
8097
8233
|
getRowId,
|
|
8098
8234
|
pageCount,
|
|
8099
8235
|
total,
|
|
8100
8236
|
stableInitialState,
|
|
8101
8237
|
pagination,
|
|
8238
|
+
actionBarLocale?.selected,
|
|
8102
8239
|
classNames,
|
|
8103
8240
|
expandedRow,
|
|
8104
8241
|
rowFooter,
|
|
@@ -9665,10 +9802,6 @@ function resolveOwnerBatchActions(actions) {
|
|
|
9665
9802
|
function isUnifiedActionsConfig(actions) {
|
|
9666
9803
|
return typeof actions === "object" && actions !== null && !Array.isArray(actions);
|
|
9667
9804
|
}
|
|
9668
|
-
function readRowId(row, idKey) {
|
|
9669
|
-
const value = row[idKey];
|
|
9670
|
-
return value === null || value === void 0 ? void 0 : String(value);
|
|
9671
|
-
}
|
|
9672
9805
|
function readRowIds(rows, idKey) {
|
|
9673
9806
|
return rows.flatMap((row) => {
|
|
9674
9807
|
const value = readRowId(row, idKey);
|
|
@@ -10861,7 +10994,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
10861
10994
|
...action$1,
|
|
10862
10995
|
onClick: (_rows, { table }) => {
|
|
10863
10996
|
const headers = getExportColumnIds(table).filter((key) => key !== "select" && key !== "actions" && !denyFields?.includes(key));
|
|
10864
|
-
exportAllToCSV(table
|
|
10997
|
+
exportAllToCSV(getSelectedTableRows(table).map((row) => formatExportRow(row.original, resolvedFields, Object.fromEntries(headers.map((key) => [key, row.getValue(key)])))), {
|
|
10865
10998
|
filename: "table",
|
|
10866
10999
|
headers
|
|
10867
11000
|
});
|
|
@@ -11173,6 +11306,9 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
11173
11306
|
enableRowSelection: tableConfig?.enableRowSelection,
|
|
11174
11307
|
initialColumnVisibility: tableConfig?.initialColumnVisibility,
|
|
11175
11308
|
getRowId: tableConfig?.getRowId,
|
|
11309
|
+
idKey: resourceIdKey,
|
|
11310
|
+
selectionScope: resource.tableData.selectionScope,
|
|
11311
|
+
pagePending: resource.tableData.isLoading || resource.tableData.isPlaceholderData || Boolean(resource.tableData.error) && resource.tableData.data.length === 0,
|
|
11176
11312
|
expandedRow: tableConfig?.expandedRow,
|
|
11177
11313
|
rowFooter: tableConfig?.rowFooter,
|
|
11178
11314
|
defaultExpanded: tableConfig?.defaultExpanded,
|
|
@@ -12117,25 +12253,49 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
|
|
|
12117
12253
|
const [filtersReady, setFiltersReady] = (0, react.useState)(!metadataPending);
|
|
12118
12254
|
(0, react.useEffect)(() => setFiltersReady(!metadataPending), [metadataPending]);
|
|
12119
12255
|
const listReady = !metadataPending && filtersReady;
|
|
12256
|
+
const firstPageParams = (0, react.useMemo)(() => ({
|
|
12257
|
+
page: 1,
|
|
12258
|
+
perPage: 10,
|
|
12259
|
+
sort: defaultSorting,
|
|
12260
|
+
filters,
|
|
12261
|
+
joinOperator,
|
|
12262
|
+
...search.trim() ? { search: search.trim() } : {}
|
|
12263
|
+
}), [
|
|
12264
|
+
defaultSorting,
|
|
12265
|
+
filters,
|
|
12266
|
+
joinOperator,
|
|
12267
|
+
search
|
|
12268
|
+
]);
|
|
12269
|
+
const firstPageInput = (0, react.useMemo)(() => queryTransform ? queryTransform({ ...firstPageParams }) : firstPageParams, [queryTransform, firstPageParams]);
|
|
12120
12270
|
const queryInput = (0, react.useMemo)(() => {
|
|
12271
|
+
if (page === firstPageParams.page && perPage === firstPageParams.perPage && sort === firstPageParams.sort) return firstPageInput;
|
|
12121
12272
|
const autoParams = {
|
|
12273
|
+
...firstPageParams,
|
|
12122
12274
|
page,
|
|
12123
12275
|
perPage,
|
|
12124
|
-
sort
|
|
12125
|
-
filters,
|
|
12126
|
-
joinOperator,
|
|
12127
|
-
...search.trim() ? { search: search.trim() } : {}
|
|
12276
|
+
sort
|
|
12128
12277
|
};
|
|
12129
12278
|
return queryTransform ? queryTransform(autoParams) : autoParams;
|
|
12130
12279
|
}, [
|
|
12131
12280
|
page,
|
|
12132
12281
|
perPage,
|
|
12133
12282
|
sort,
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
search,
|
|
12283
|
+
firstPageParams,
|
|
12284
|
+
firstPageInput,
|
|
12137
12285
|
queryTransform
|
|
12138
12286
|
]);
|
|
12287
|
+
const previousCriteria = (0, react.useRef)(void 0);
|
|
12288
|
+
const selectionCriteria = (0, react.useMemo)(() => {
|
|
12289
|
+
const criteria = firstPageInput?.filters === filters ? {
|
|
12290
|
+
...firstPageInput,
|
|
12291
|
+
filters: filterSignature(filters)
|
|
12292
|
+
} : firstPageInput;
|
|
12293
|
+
return (0, __tanstack_react_query.replaceEqualDeep)(previousCriteria.current, criteria);
|
|
12294
|
+
}, [firstPageInput, filters]);
|
|
12295
|
+
(0, react.useEffect)(() => {
|
|
12296
|
+
previousCriteria.current = selectionCriteria;
|
|
12297
|
+
}, [selectionCriteria]);
|
|
12298
|
+
const selectionScope = (0, react.useMemo)(() => createRowSelectionScope(), [router.list, selectionCriteria]);
|
|
12139
12299
|
const hasReadyListData = (0, react.useRef)(false);
|
|
12140
12300
|
const listQuery = router.list.useQuery(queryInput, {
|
|
12141
12301
|
...queryContext !== void 0 ? { trpc: { context: queryContext } } : {},
|
|
@@ -12318,6 +12478,7 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
|
|
|
12318
12478
|
return;
|
|
12319
12479
|
}
|
|
12320
12480
|
toast$1.success("删除成功");
|
|
12481
|
+
selectionScope.notifyDeleted(modal.selected);
|
|
12321
12482
|
dispatch({
|
|
12322
12483
|
type: "DELETE_SUCCEEDED",
|
|
12323
12484
|
payload: modal.selected
|
|
@@ -12329,7 +12490,8 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
|
|
|
12329
12490
|
idKey,
|
|
12330
12491
|
deleteMutation,
|
|
12331
12492
|
refreshResource,
|
|
12332
|
-
toast$1
|
|
12493
|
+
toast$1,
|
|
12494
|
+
selectionScope
|
|
12333
12495
|
]);
|
|
12334
12496
|
const deleteMany = (0, react.useCallback)((rows) => {
|
|
12335
12497
|
const currentHooks = hooksRef.current;
|
|
@@ -12432,6 +12594,8 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
|
|
|
12432
12594
|
filterState,
|
|
12433
12595
|
tableData: {
|
|
12434
12596
|
data: tableRows,
|
|
12597
|
+
selectionScope,
|
|
12598
|
+
isPlaceholderData: Boolean(listQuery.isPlaceholderData),
|
|
12435
12599
|
countSource: {
|
|
12436
12600
|
navigationKey: listData && !listQuery.isPlaceholderData ? navigationKey : null,
|
|
12437
12601
|
refreshVersion,
|
package/dist/index.d.cts
CHANGED
|
@@ -2,9 +2,9 @@ import { a as positionActions, i as matchesPosition, n as actionPositionSchema,
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
4
|
import { ComponentProps, ReactNode } from "react";
|
|
5
|
-
import * as react_jsx_runtime17 from "react/jsx-runtime";
|
|
6
5
|
import * as _tanstack_react_table0 from "@tanstack/react-table";
|
|
7
6
|
import { Column, ColumnDef, ColumnMeta, ColumnSort, Row, RowData, Table, TableOptions, TableState, VisibilityState } from "@tanstack/react-table";
|
|
7
|
+
import * as react_jsx_runtime17 from "react/jsx-runtime";
|
|
8
8
|
import { JsonSchemaFormScope } from "@wordrhyme/formily-shadcn";
|
|
9
9
|
import { ISchema } from "@formily/json-schema";
|
|
10
10
|
import { DropdownMenuItem } from "@wordrhyme/ui";
|
|
@@ -111,6 +111,12 @@ interface BatchSearchLocale {
|
|
|
111
111
|
combination: string;
|
|
112
112
|
}
|
|
113
113
|
//#endregion
|
|
114
|
+
//#region src/lib/data-table.d.ts
|
|
115
|
+
/** Stable for one result set. Each mounted table observes its successful deletions. */
|
|
116
|
+
interface RowSelectionScope<TData> {
|
|
117
|
+
onDelete: (listener: (deleted: TData) => void) => () => void;
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
114
120
|
//#region src/lib/default-sorting.d.ts
|
|
115
121
|
type AutoCrudSorting = Array<{
|
|
116
122
|
id: string;
|
|
@@ -742,6 +748,10 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
|
|
|
742
748
|
idKey?: keyof TListItem & string;
|
|
743
749
|
tableData: {
|
|
744
750
|
data: TListItem[];
|
|
751
|
+
/** @internal Scope of the effective list query and its confirmed deletions. */
|
|
752
|
+
selectionScope?: RowSelectionScope<TListItem>;
|
|
753
|
+
/** True while showing rows from the previous request. */
|
|
754
|
+
isPlaceholderData?: boolean;
|
|
745
755
|
/** @internal Used by AutoCrudTable to refresh saved-view counts. */
|
|
746
756
|
countSource?: ViewCountSource;
|
|
747
757
|
pageCount: number;
|
|
@@ -929,6 +939,8 @@ interface TableControlsLocale {
|
|
|
929
939
|
}
|
|
930
940
|
interface TablePaginationLocale {
|
|
931
941
|
selected: (count: number, total: number) => string;
|
|
942
|
+
/** Selection summary when the server omits the total across pages. */
|
|
943
|
+
selectedCount?: (count: number) => string;
|
|
932
944
|
total: (count: number) => string;
|
|
933
945
|
rowsPerPage: string;
|
|
934
946
|
page: (page: number, total: number) => string;
|
|
@@ -1188,6 +1200,8 @@ interface TablePaginationOptions {
|
|
|
1188
1200
|
}
|
|
1189
1201
|
declare module '@tanstack/react-table' {
|
|
1190
1202
|
interface TableMeta<TData extends RowData> {
|
|
1203
|
+
/** Selected records retained by AutoTable across server pages. */
|
|
1204
|
+
selectedRows?: Row<TData>[];
|
|
1191
1205
|
queryKeys?: QueryKeys;
|
|
1192
1206
|
queryStateOptions?: UrlStateOptions;
|
|
1193
1207
|
filterState?: TableFilterState<TData>;
|
|
@@ -1643,6 +1657,12 @@ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> extends Pick<Data
|
|
|
1643
1657
|
data: z.infer<T>[];
|
|
1644
1658
|
/** Stable row identity; required when expandedRow is provided. */
|
|
1645
1659
|
getRowId?: TableOptions<z.infer<T>>['getRowId'];
|
|
1660
|
+
/** Business key for row selection. Defaults to id; getRowId takes precedence. */
|
|
1661
|
+
idKey?: string;
|
|
1662
|
+
/** @internal Result set supplied by useAutoCrudResource. */
|
|
1663
|
+
selectionScope?: RowSelectionScope<z.infer<T>>;
|
|
1664
|
+
/** Displayed rows are loading or belong to a previous request. */
|
|
1665
|
+
pagePending?: boolean;
|
|
1646
1666
|
/** Initially expand all rows. Defaults to false; only applies with expandedRow. */
|
|
1647
1667
|
defaultExpanded?: boolean;
|
|
1648
1668
|
pageCount?: number;
|
|
@@ -1716,6 +1736,9 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1716
1736
|
schema,
|
|
1717
1737
|
data,
|
|
1718
1738
|
getRowId,
|
|
1739
|
+
idKey,
|
|
1740
|
+
selectionScope,
|
|
1741
|
+
pagePending,
|
|
1719
1742
|
expandedRow,
|
|
1720
1743
|
rowFooter,
|
|
1721
1744
|
defaultExpanded,
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import * as react_jsx_runtime17 from "react/jsx-runtime";
|
|
|
5
5
|
import { DropdownMenuTrigger, PopoverContentProps } from "@wordrhyme/shadcn";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { ClassValue } from "clsx";
|
|
8
|
-
import { MultiCombobox, MultiComboboxOption, MultiComboboxProps, MultiComboboxTriggerRenderProps, Select, SelectMode, SelectOption, SelectProps, SelectSearchableDynamicProps, SelectSearchableMultipleProps, SelectSearchableProps, SelectSearchableSingleProps, SelectSimpleProps, SelectTriggerRenderProps } from "@wordrhyme/shadcn-ui";
|
|
9
8
|
import * as _tanstack_react_table0 from "@tanstack/react-table";
|
|
10
9
|
import { Column, ColumnDef, ColumnMeta, ColumnSort, Row, RowData, Table as Table$1, TableOptions, TableState, VisibilityState } from "@tanstack/react-table";
|
|
10
|
+
import { MultiCombobox, MultiComboboxOption, MultiComboboxProps, MultiComboboxTriggerRenderProps, Select, SelectMode, SelectOption, SelectProps, SelectSearchableDynamicProps, SelectSearchableMultipleProps, SelectSearchableProps, SelectSearchableSingleProps, SelectSimpleProps, SelectTriggerRenderProps } from "@wordrhyme/shadcn-ui";
|
|
11
11
|
import { DropdownMenuItem as DropdownMenuItem$1 } from "@wordrhyme/ui";
|
|
12
12
|
import { JsonSchemaFormScope } from "@wordrhyme/formily-shadcn";
|
|
13
13
|
import { ISchema } from "@formily/json-schema";
|
|
@@ -111,6 +111,12 @@ interface BatchSearchLocale {
|
|
|
111
111
|
combination: string;
|
|
112
112
|
}
|
|
113
113
|
//#endregion
|
|
114
|
+
//#region src/lib/data-table.d.ts
|
|
115
|
+
/** Stable for one result set. Each mounted table observes its successful deletions. */
|
|
116
|
+
interface RowSelectionScope<TData> {
|
|
117
|
+
onDelete: (listener: (deleted: TData) => void) => () => void;
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
114
120
|
//#region src/lib/default-sorting.d.ts
|
|
115
121
|
type AutoCrudSorting = Array<{
|
|
116
122
|
id: string;
|
|
@@ -742,6 +748,10 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
|
|
|
742
748
|
idKey?: keyof TListItem & string;
|
|
743
749
|
tableData: {
|
|
744
750
|
data: TListItem[];
|
|
751
|
+
/** @internal Scope of the effective list query and its confirmed deletions. */
|
|
752
|
+
selectionScope?: RowSelectionScope<TListItem>;
|
|
753
|
+
/** True while showing rows from the previous request. */
|
|
754
|
+
isPlaceholderData?: boolean;
|
|
745
755
|
/** @internal Used by AutoCrudTable to refresh saved-view counts. */
|
|
746
756
|
countSource?: ViewCountSource;
|
|
747
757
|
pageCount: number;
|
|
@@ -929,6 +939,8 @@ interface TableControlsLocale {
|
|
|
929
939
|
}
|
|
930
940
|
interface TablePaginationLocale {
|
|
931
941
|
selected: (count: number, total: number) => string;
|
|
942
|
+
/** Selection summary when the server omits the total across pages. */
|
|
943
|
+
selectedCount?: (count: number) => string;
|
|
932
944
|
total: (count: number) => string;
|
|
933
945
|
rowsPerPage: string;
|
|
934
946
|
page: (page: number, total: number) => string;
|
|
@@ -1188,6 +1200,8 @@ interface TablePaginationOptions {
|
|
|
1188
1200
|
}
|
|
1189
1201
|
declare module '@tanstack/react-table' {
|
|
1190
1202
|
interface TableMeta<TData extends RowData> {
|
|
1203
|
+
/** Selected records retained by AutoTable across server pages. */
|
|
1204
|
+
selectedRows?: Row<TData>[];
|
|
1191
1205
|
queryKeys?: QueryKeys;
|
|
1192
1206
|
queryStateOptions?: UrlStateOptions;
|
|
1193
1207
|
filterState?: TableFilterState<TData>;
|
|
@@ -1643,6 +1657,12 @@ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> extends Pick<Data
|
|
|
1643
1657
|
data: z.infer<T>[];
|
|
1644
1658
|
/** Stable row identity; required when expandedRow is provided. */
|
|
1645
1659
|
getRowId?: TableOptions<z.infer<T>>['getRowId'];
|
|
1660
|
+
/** Business key for row selection. Defaults to id; getRowId takes precedence. */
|
|
1661
|
+
idKey?: string;
|
|
1662
|
+
/** @internal Result set supplied by useAutoCrudResource. */
|
|
1663
|
+
selectionScope?: RowSelectionScope<z.infer<T>>;
|
|
1664
|
+
/** Displayed rows are loading or belong to a previous request. */
|
|
1665
|
+
pagePending?: boolean;
|
|
1646
1666
|
/** Initially expand all rows. Defaults to false; only applies with expandedRow. */
|
|
1647
1667
|
defaultExpanded?: boolean;
|
|
1648
1668
|
pageCount?: number;
|
|
@@ -1716,6 +1736,9 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1716
1736
|
schema,
|
|
1717
1737
|
data,
|
|
1718
1738
|
getRowId,
|
|
1739
|
+
idKey,
|
|
1740
|
+
selectionScope,
|
|
1741
|
+
pagePending,
|
|
1719
1742
|
expandedRow,
|
|
1720
1743
|
rowFooter,
|
|
1721
1744
|
defaultExpanded,
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { i as positionActions, n as compareOrder, r as matchesPosition, t as actionPositionSchema } from "./position--p6kJnYA.js";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { Fragment, createContext, createElement, forwardRef, useCallback, useContext, useEffect, useId, useImperativeHandle, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
3
|
+
import { Fragment, createContext, createElement, forwardRef, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { hashKey, keepPreviousData, useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
|
+
import { hashKey, keepPreviousData, replaceEqualDeep, useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
6
6
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Badge, Button, Calendar, Checkbox, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, Label, Popover, PopoverContent, PopoverTrigger, RadioGroup, RadioGroupItem, Select as Select$1, SelectContent, SelectItem, SelectTrigger, SelectValue, Separator, Slider, Switch, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Textarea, ToggleGroup, ToggleGroupItem, cn as cn$1 } from "@wordrhyme/shadcn";
|
|
7
7
|
import { AppWindow, ArrowDownUp, BadgeCheck, CalendarIcon, Check, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, ChevronRightIcon, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsRightIcon, ChevronsUpDown, CommandIcon, Copy, Download, Ellipsis, Eye, EyeOff, FileDown, FileSpreadsheetIcon, GripVertical, Info, Layers, List, ListFilter, ListFilterIcon, Loader2, PanelsTopLeft, Pencil, Plus, PlusCircle, RefreshCw, Search, Settings, Settings2, Text, Trash2, Upload, X, XCircle } from "lucide-react";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { clsx } from "clsx";
|
|
10
10
|
import { twMerge } from "tailwind-merge";
|
|
11
|
+
import { flexRender, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
11
12
|
import { ActionBar, ActionBarClose, ActionBarGroup, ActionBarItem, ActionBarSelection, ActionBarSeparator, Faceted, FacetedBadgeList, FacetedContent, FacetedEmpty, FacetedGroup, FacetedInput, FacetedItem, FacetedList, FacetedTrigger, MultiCombobox, Select, Select as Select$2, Sortable, SortableContent, SortableItem, SortableItemHandle, SortableOverlay } from "@wordrhyme/shadcn-ui";
|
|
12
13
|
import { customAlphabet } from "nanoid";
|
|
13
|
-
import { flexRender, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
14
14
|
import { AlertDialog as AlertDialog$1, AlertDialogAction as AlertDialogAction$1, AlertDialogCancel as AlertDialogCancel$1, AlertDialogContent as AlertDialogContent$1, AlertDialogDescription as AlertDialogDescription$1, AlertDialogFooter as AlertDialogFooter$1, AlertDialogHeader as AlertDialogHeader$1, AlertDialogTitle as AlertDialogTitle$1, Button as Button$1, Calendar as Calendar$1, Dialog as Dialog$1, DialogContent as DialogContent$1, DialogDescription as DialogDescription$1, DialogHeader as DialogHeader$1, DialogTitle as DialogTitle$1, DropdownMenu as DropdownMenu$1, DropdownMenuContent as DropdownMenuContent$1, DropdownMenuItem as DropdownMenuItem$1, DropdownMenuSeparator as DropdownMenuSeparator$1, DropdownMenuTrigger as DropdownMenuTrigger$1, Popover as Popover$1, PopoverContent as PopoverContent$1, PopoverTrigger as PopoverTrigger$1, Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@wordrhyme/ui";
|
|
15
15
|
import { DatePicker, Form, JsonSchemaField, connect, defaultComponentRegistry, mapProps } from "@wordrhyme/formily-shadcn";
|
|
16
16
|
import { createForm } from "@formily/core";
|
|
@@ -236,6 +236,34 @@ const dataTableConfig = {
|
|
|
236
236
|
|
|
237
237
|
//#endregion
|
|
238
238
|
//#region src/lib/data-table.ts
|
|
239
|
+
function readRowId(row, idKey) {
|
|
240
|
+
const value = row[idKey];
|
|
241
|
+
return value === null || value === void 0 ? void 0 : String(value);
|
|
242
|
+
}
|
|
243
|
+
function getSelectedTableRows(table) {
|
|
244
|
+
return table.options.meta?.selectedRows ?? table.getFilteredSelectedRowModel().rows;
|
|
245
|
+
}
|
|
246
|
+
function createRowSelectionScope() {
|
|
247
|
+
const listeners$1 = /* @__PURE__ */ new Set();
|
|
248
|
+
return {
|
|
249
|
+
onDelete(listener) {
|
|
250
|
+
listeners$1.add(listener);
|
|
251
|
+
return () => {
|
|
252
|
+
listeners$1.delete(listener);
|
|
253
|
+
};
|
|
254
|
+
},
|
|
255
|
+
notifyDeleted(row) {
|
|
256
|
+
listeners$1.forEach((listener) => listener(row));
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/** Infer a total only when the loaded page accounts for the whole result. */
|
|
261
|
+
function getSelectionTotal(table, loadedPageIndex = table.getState().pagination.pageIndex) {
|
|
262
|
+
if (table.options.rowCount !== void 0 || !table.options.manualPagination) return table.getRowCount();
|
|
263
|
+
const pages = table.getPageCount();
|
|
264
|
+
if (pages === 0) return 0;
|
|
265
|
+
if (pages === 1 && loadedPageIndex === 0) return table.getFilteredRowModel().rows.length;
|
|
266
|
+
}
|
|
239
267
|
function getColumnPinningStyle({ column, withBorder = false }) {
|
|
240
268
|
const isPinned = column.getIsPinned();
|
|
241
269
|
const isLastLeftPinnedColumn = isPinned === "left" && column.getIsLastColumn("left");
|
|
@@ -3430,6 +3458,8 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3430
3458
|
const canJump = Number.isFinite(pageCount) && pageCount > 0;
|
|
3431
3459
|
const canGoNext = table.getCanNextPage() && (knownPageCount || table.options.data.length >= pageSize);
|
|
3432
3460
|
const total = table.options.rowCount ?? (table.options.manualPagination ? void 0 : table.getRowCount());
|
|
3461
|
+
const selectedCount = getSelectedTableRows(table).length;
|
|
3462
|
+
const selectionTotal = table.options.meta?.selectedRows !== void 0 ? getSelectionTotal(table) : table.getFilteredRowModel().rows.length;
|
|
3433
3463
|
useEffect(() => {
|
|
3434
3464
|
if (!responsive || !container.current || !summary.current || !controls.current || !navigation.current) return;
|
|
3435
3465
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3478,7 +3508,7 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3478
3508
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
3479
3509
|
ref: summary,
|
|
3480
3510
|
className: "flex flex-1 items-center gap-6 whitespace-nowrap text-muted-foreground text-sm",
|
|
3481
|
-
children: [/* @__PURE__ */ jsx("span", { children: locale.selected(
|
|
3511
|
+
children: [/* @__PURE__ */ jsx("span", { children: selectionTotal === void 0 || selectedCount > selectionTotal ? (locale.selectedCount ?? enUSActionBar.selected)(selectedCount) : locale.selected(selectedCount, selectionTotal) }), total !== void 0 && /* @__PURE__ */ jsx("span", { children: locale.total(total) })]
|
|
3482
3512
|
}), /* @__PURE__ */ jsxs("div", {
|
|
3483
3513
|
ref: controls,
|
|
3484
3514
|
className: cn("flex items-center gap-4 sm:gap-6 lg:gap-8", responsive ? "flex-row flex-wrap justify-center whitespace-nowrap [&>*]:shrink-0" : "flex-col-reverse sm:flex-row"),
|
|
@@ -3795,7 +3825,7 @@ function DataTable({ table, actionBar, pagination, expandedRow, rowFooter, child
|
|
|
3795
3825
|
children: [/* @__PURE__ */ jsx(DataTablePagination, {
|
|
3796
3826
|
table,
|
|
3797
3827
|
...pagination
|
|
3798
|
-
}), actionBar && table
|
|
3828
|
+
}), actionBar && getSelectedTableRows(table).length > 0 && actionBar]
|
|
3799
3829
|
})
|
|
3800
3830
|
]
|
|
3801
3831
|
});
|
|
@@ -5977,12 +6007,14 @@ function createSelectColumn() {
|
|
|
5977
6007
|
id: "select",
|
|
5978
6008
|
header: ({ table }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
5979
6009
|
"aria-label": "Select all",
|
|
6010
|
+
disabled: !table.getPaginationRowModel().flatRows.some((row) => row.getCanSelect()),
|
|
5980
6011
|
className: "translate-y-0.5",
|
|
5981
6012
|
checked: table.getIsAllPageRowsSelected() || table.getIsSomePageRowsSelected() && "indeterminate",
|
|
5982
6013
|
onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
|
|
5983
6014
|
}),
|
|
5984
6015
|
cell: ({ row }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
5985
6016
|
"aria-label": "Select row",
|
|
6017
|
+
disabled: !row.getCanSelect(),
|
|
5986
6018
|
className: "translate-y-0.5",
|
|
5987
6019
|
checked: row.getIsSelected(),
|
|
5988
6020
|
onCheckedChange: (value) => row.toggleSelected(!!value)
|
|
@@ -7324,7 +7356,7 @@ function getExportColumnIds(table) {
|
|
|
7324
7356
|
function exportTableToCSV(table, opts = {}) {
|
|
7325
7357
|
const { filename = "table", excludeColumns = [], onlySelected = false } = opts;
|
|
7326
7358
|
const headers = getExportColumnIds(table).filter((id) => !excludeColumns.includes(id));
|
|
7327
|
-
downloadCSV([headers.join(","), ...(onlySelected ? table
|
|
7359
|
+
downloadCSV([headers.join(","), ...(onlySelected ? getSelectedTableRows(table) : table.getRowModel().rows).map((row) => headers.map((header) => {
|
|
7328
7360
|
const cellValue = row.getValue(header);
|
|
7329
7361
|
return typeof cellValue === "string" ? `"${cellValue.replace(/"/g, "\"\"")}"` : cellValue;
|
|
7330
7362
|
}).join(","))].join("\n"), filename);
|
|
@@ -7373,14 +7405,14 @@ function AutoTableActionBar({ table, locale: localeProp, onDeleteSelected, onUpd
|
|
|
7373
7405
|
...enUSActionBar,
|
|
7374
7406
|
...localeProp
|
|
7375
7407
|
}), [localeProp]);
|
|
7376
|
-
const rows = table
|
|
7408
|
+
const rows = getSelectedTableRows(table);
|
|
7377
7409
|
const selectedRows = React.useMemo(() => rows.map((row) => row.original), [rows]);
|
|
7378
7410
|
const [deleteDialogOpen, setDeleteDialogOpen] = React.useState(false);
|
|
7379
7411
|
React.useEffect(() => {
|
|
7380
7412
|
if (selectedRows.length === 0) setDeleteDialogOpen(false);
|
|
7381
7413
|
}, [selectedRows.length]);
|
|
7382
7414
|
const clearSelection = React.useCallback(() => {
|
|
7383
|
-
table.
|
|
7415
|
+
table.resetRowSelection(true);
|
|
7384
7416
|
}, [table]);
|
|
7385
7417
|
const actionContext = React.useMemo(() => ({
|
|
7386
7418
|
rows: selectedRows,
|
|
@@ -7787,7 +7819,7 @@ const filterModeConfig = {
|
|
|
7787
7819
|
tooltip: "Linear-style command filters"
|
|
7788
7820
|
}
|
|
7789
7821
|
};
|
|
7790
|
-
function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, rowFooter, defaultExpanded = false, pageCount = 1, pagination, total, overrides, classNames, enableRowSelection = true, queryKeys, initialColumnVisibility, exclude, filterOnly, actions, pinnedColumns, filterMode, search = false, batchSearch, filterState, toolbarExtra, locale = enUSTableControls, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarLocale, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows, exportTableRef }) {
|
|
7822
|
+
function AutoTable({ resourceId, views, schema, data, getRowId, idKey = "id", selectionScope, pagePending = false, expandedRow, rowFooter, defaultExpanded = false, pageCount = 1, pagination, total, overrides, classNames, enableRowSelection = true, queryKeys, initialColumnVisibility, exclude, filterOnly, actions, pinnedColumns, filterMode, search = false, batchSearch, filterState, toolbarExtra, locale = enUSTableControls, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarLocale, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows, exportTableRef }) {
|
|
7791
7823
|
const inheritedResourceId = useContext(CrudResourceContext);
|
|
7792
7824
|
const activeResourceId = resourceId ?? inheritedResourceId;
|
|
7793
7825
|
const viewsEnabled = views ?? false;
|
|
@@ -7908,12 +7940,28 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
|
|
|
7908
7940
|
actions
|
|
7909
7941
|
]);
|
|
7910
7942
|
const expandedRowModel = useMemo(() => getExpandedRowModel(), []);
|
|
7943
|
+
const resolveRowId = useMemo(() => {
|
|
7944
|
+
if (getRowId) return getRowId;
|
|
7945
|
+
const anonymousRows = /* @__PURE__ */ new WeakMap();
|
|
7946
|
+
let nextId = 0;
|
|
7947
|
+
return (record) => {
|
|
7948
|
+
const key = readRowId(record, idKey);
|
|
7949
|
+
if (key !== void 0) return `key:${key}`;
|
|
7950
|
+
let id = anonymousRows.get(record);
|
|
7951
|
+
if (id === void 0) {
|
|
7952
|
+
id = `local:${nextId++}`;
|
|
7953
|
+
anonymousRows.set(record, id);
|
|
7954
|
+
}
|
|
7955
|
+
return id;
|
|
7956
|
+
};
|
|
7957
|
+
}, [getRowId, idKey]);
|
|
7958
|
+
const keyedData = useMemo(() => data.slice(), [data, idKey]);
|
|
7911
7959
|
const { table, shallow, debounceMs, throttleMs } = useDataTable({
|
|
7912
|
-
data,
|
|
7960
|
+
data: keyedData,
|
|
7913
7961
|
columns,
|
|
7914
7962
|
queryKeys,
|
|
7915
|
-
enableRowSelection,
|
|
7916
|
-
getRowId,
|
|
7963
|
+
enableRowSelection: enableRowSelection && !pagePending,
|
|
7964
|
+
getRowId: resolveRowId,
|
|
7917
7965
|
getRowCanExpand: () => enableExpansion,
|
|
7918
7966
|
getExpandedRowModel: enableExpansion ? expandedRowModel : void 0,
|
|
7919
7967
|
autoResetExpanded: defaultExpanded ? false : void 0,
|
|
@@ -7945,14 +7993,95 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
|
|
|
7945
7993
|
exportTableRef.current = null;
|
|
7946
7994
|
};
|
|
7947
7995
|
}, [table, exportTableRef]);
|
|
7948
|
-
const
|
|
7949
|
-
const
|
|
7950
|
-
const
|
|
7996
|
+
const [filters] = useReadableFilters(columns, { state: filterState });
|
|
7997
|
+
const [query] = useQueryState("search", parseAsString.withDefault(""));
|
|
7998
|
+
const [join] = useQueryState(queryKeys?.joinOperator ?? "joinOperator", parseAsString.withDefault("and"));
|
|
7999
|
+
const resultSet = useMemo(() => selectionScope ?? JSON.stringify([
|
|
8000
|
+
query.trim(),
|
|
8001
|
+
join,
|
|
8002
|
+
filterSignature(filters),
|
|
8003
|
+
batchSearch?.filter
|
|
8004
|
+
]), [
|
|
8005
|
+
selectionScope,
|
|
8006
|
+
query,
|
|
8007
|
+
join,
|
|
8008
|
+
filters,
|
|
8009
|
+
batchSearch?.filter
|
|
8010
|
+
]);
|
|
8011
|
+
const scope = useMemo(() => ({
|
|
8012
|
+
activeResourceId,
|
|
8013
|
+
idKey,
|
|
8014
|
+
enableRowSelection,
|
|
8015
|
+
resultSet
|
|
8016
|
+
}), [
|
|
8017
|
+
activeResourceId,
|
|
8018
|
+
idKey,
|
|
8019
|
+
enableRowSelection,
|
|
8020
|
+
resultSet
|
|
8021
|
+
]);
|
|
8022
|
+
const [previousScope, setPreviousScope] = useState(scope);
|
|
8023
|
+
if (previousScope !== scope) {
|
|
8024
|
+
setPreviousScope(scope);
|
|
8025
|
+
table.resetRowSelection(true);
|
|
8026
|
+
}
|
|
8027
|
+
const { rowSelection, pagination: { pageIndex } } = table.getState();
|
|
8028
|
+
const pageSelection = table.getFilteredSelectedRowModel().rows;
|
|
8029
|
+
const retained = useRef([]);
|
|
8030
|
+
const loadedPage = useRef(null);
|
|
8031
|
+
const loadedIndex = loadedPage.current?.data === data ? loadedPage.current.index : pageIndex;
|
|
8032
|
+
const allRowsLoaded = !pagePending && getSelectionTotal(table, loadedIndex) === data.length;
|
|
8033
|
+
const selectedTableRows = useMemo(() => {
|
|
8034
|
+
if (pagePending) return retained.current.filter((row) => rowSelection[row.id]);
|
|
8035
|
+
if (allRowsLoaded || pageSelection.length === Object.keys(rowSelection).length) return pageSelection;
|
|
8036
|
+
const rows = /* @__PURE__ */ new Map();
|
|
8037
|
+
for (const row of retained.current) if (rowSelection[row.id] && (getRowId || row.original[idKey] != null)) rows.set(row.id, row);
|
|
8038
|
+
for (const row of pageSelection) rows.set(row.id, row);
|
|
8039
|
+
return Array.from(rows.values());
|
|
8040
|
+
}, [
|
|
8041
|
+
allRowsLoaded,
|
|
8042
|
+
pagePending,
|
|
8043
|
+
pageSelection,
|
|
8044
|
+
rowSelection,
|
|
8045
|
+
getRowId,
|
|
8046
|
+
idKey
|
|
8047
|
+
]);
|
|
8048
|
+
table.setOptions((options) => ({
|
|
8049
|
+
...options,
|
|
8050
|
+
meta: {
|
|
8051
|
+
...options.meta,
|
|
8052
|
+
selectedRows: selectedTableRows
|
|
8053
|
+
}
|
|
8054
|
+
}));
|
|
8055
|
+
useLayoutEffect(() => {
|
|
8056
|
+
loadedPage.current = pagePending ? null : {
|
|
8057
|
+
data,
|
|
8058
|
+
index: loadedIndex
|
|
8059
|
+
};
|
|
8060
|
+
retained.current = selectedTableRows;
|
|
8061
|
+
if (!pagePending && Object.keys(rowSelection).length > selectedTableRows.length) table.setRowSelection(Object.fromEntries(selectedTableRows.map((row) => [row.id, true])));
|
|
8062
|
+
}, [
|
|
7951
8063
|
table,
|
|
7952
8064
|
rowSelection,
|
|
7953
|
-
|
|
7954
|
-
|
|
8065
|
+
selectedTableRows,
|
|
8066
|
+
pagePending,
|
|
8067
|
+
data,
|
|
8068
|
+
loadedIndex
|
|
8069
|
+
]);
|
|
8070
|
+
useLayoutEffect(() => selectionScope?.onDelete((deleted) => {
|
|
8071
|
+
const id = readRowId(deleted, idKey);
|
|
8072
|
+
const rows = retained.current.filter((row) => row.original === deleted || id !== void 0 && readRowId(row.original, idKey) === id);
|
|
8073
|
+
if (!rows.length) return;
|
|
8074
|
+
table.setRowSelection((current) => {
|
|
8075
|
+
const next = { ...current };
|
|
8076
|
+
for (const row of rows) delete next[row.id];
|
|
8077
|
+
return next;
|
|
8078
|
+
});
|
|
8079
|
+
}), [
|
|
8080
|
+
selectionScope,
|
|
8081
|
+
table,
|
|
8082
|
+
idKey
|
|
7955
8083
|
]);
|
|
8084
|
+
const selectedRows = useMemo(() => selectedTableRows.map((row) => row.original), [selectedTableRows]);
|
|
7956
8085
|
const getSelectedRowsFn = useCallback(() => selectedRows, [selectedRows]);
|
|
7957
8086
|
useEffect(() => {
|
|
7958
8087
|
if (getSelectedRows) getSelectedRows.current = getSelectedRowsFn;
|
|
@@ -8069,20 +8198,28 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
|
|
|
8069
8198
|
});
|
|
8070
8199
|
const state = table.getState();
|
|
8071
8200
|
const tableContent = useMemo(() => /* @__PURE__ */ jsx(DataTable, {
|
|
8072
|
-
pagination
|
|
8201
|
+
pagination: {
|
|
8202
|
+
...pagination,
|
|
8203
|
+
locale: {
|
|
8204
|
+
selectedCount: actionBarLocale?.selected,
|
|
8205
|
+
...pagination?.locale
|
|
8206
|
+
}
|
|
8207
|
+
},
|
|
8073
8208
|
table,
|
|
8074
8209
|
classNames,
|
|
8075
8210
|
expandedRow,
|
|
8076
8211
|
rowFooter
|
|
8077
8212
|
}), [
|
|
8078
8213
|
table,
|
|
8079
|
-
|
|
8214
|
+
keyedData,
|
|
8215
|
+
pagePending,
|
|
8080
8216
|
columns,
|
|
8081
8217
|
getRowId,
|
|
8082
8218
|
pageCount,
|
|
8083
8219
|
total,
|
|
8084
8220
|
stableInitialState,
|
|
8085
8221
|
pagination,
|
|
8222
|
+
actionBarLocale?.selected,
|
|
8086
8223
|
classNames,
|
|
8087
8224
|
expandedRow,
|
|
8088
8225
|
rowFooter,
|
|
@@ -9649,10 +9786,6 @@ function resolveOwnerBatchActions(actions) {
|
|
|
9649
9786
|
function isUnifiedActionsConfig(actions) {
|
|
9650
9787
|
return typeof actions === "object" && actions !== null && !Array.isArray(actions);
|
|
9651
9788
|
}
|
|
9652
|
-
function readRowId(row, idKey) {
|
|
9653
|
-
const value = row[idKey];
|
|
9654
|
-
return value === null || value === void 0 ? void 0 : String(value);
|
|
9655
|
-
}
|
|
9656
9789
|
function readRowIds(rows, idKey) {
|
|
9657
9790
|
return rows.flatMap((row) => {
|
|
9658
9791
|
const value = readRowId(row, idKey);
|
|
@@ -10845,7 +10978,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
10845
10978
|
...action$1,
|
|
10846
10979
|
onClick: (_rows, { table }) => {
|
|
10847
10980
|
const headers = getExportColumnIds(table).filter((key) => key !== "select" && key !== "actions" && !denyFields?.includes(key));
|
|
10848
|
-
exportAllToCSV(table
|
|
10981
|
+
exportAllToCSV(getSelectedTableRows(table).map((row) => formatExportRow(row.original, resolvedFields, Object.fromEntries(headers.map((key) => [key, row.getValue(key)])))), {
|
|
10849
10982
|
filename: "table",
|
|
10850
10983
|
headers
|
|
10851
10984
|
});
|
|
@@ -11157,6 +11290,9 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
11157
11290
|
enableRowSelection: tableConfig?.enableRowSelection,
|
|
11158
11291
|
initialColumnVisibility: tableConfig?.initialColumnVisibility,
|
|
11159
11292
|
getRowId: tableConfig?.getRowId,
|
|
11293
|
+
idKey: resourceIdKey,
|
|
11294
|
+
selectionScope: resource.tableData.selectionScope,
|
|
11295
|
+
pagePending: resource.tableData.isLoading || resource.tableData.isPlaceholderData || Boolean(resource.tableData.error) && resource.tableData.data.length === 0,
|
|
11160
11296
|
expandedRow: tableConfig?.expandedRow,
|
|
11161
11297
|
rowFooter: tableConfig?.rowFooter,
|
|
11162
11298
|
defaultExpanded: tableConfig?.defaultExpanded,
|
|
@@ -12101,25 +12237,49 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
|
|
|
12101
12237
|
const [filtersReady, setFiltersReady] = useState(!metadataPending);
|
|
12102
12238
|
useEffect(() => setFiltersReady(!metadataPending), [metadataPending]);
|
|
12103
12239
|
const listReady = !metadataPending && filtersReady;
|
|
12240
|
+
const firstPageParams = useMemo(() => ({
|
|
12241
|
+
page: 1,
|
|
12242
|
+
perPage: 10,
|
|
12243
|
+
sort: defaultSorting,
|
|
12244
|
+
filters,
|
|
12245
|
+
joinOperator,
|
|
12246
|
+
...search.trim() ? { search: search.trim() } : {}
|
|
12247
|
+
}), [
|
|
12248
|
+
defaultSorting,
|
|
12249
|
+
filters,
|
|
12250
|
+
joinOperator,
|
|
12251
|
+
search
|
|
12252
|
+
]);
|
|
12253
|
+
const firstPageInput = useMemo(() => queryTransform ? queryTransform({ ...firstPageParams }) : firstPageParams, [queryTransform, firstPageParams]);
|
|
12104
12254
|
const queryInput = useMemo(() => {
|
|
12255
|
+
if (page === firstPageParams.page && perPage === firstPageParams.perPage && sort === firstPageParams.sort) return firstPageInput;
|
|
12105
12256
|
const autoParams = {
|
|
12257
|
+
...firstPageParams,
|
|
12106
12258
|
page,
|
|
12107
12259
|
perPage,
|
|
12108
|
-
sort
|
|
12109
|
-
filters,
|
|
12110
|
-
joinOperator,
|
|
12111
|
-
...search.trim() ? { search: search.trim() } : {}
|
|
12260
|
+
sort
|
|
12112
12261
|
};
|
|
12113
12262
|
return queryTransform ? queryTransform(autoParams) : autoParams;
|
|
12114
12263
|
}, [
|
|
12115
12264
|
page,
|
|
12116
12265
|
perPage,
|
|
12117
12266
|
sort,
|
|
12118
|
-
|
|
12119
|
-
|
|
12120
|
-
search,
|
|
12267
|
+
firstPageParams,
|
|
12268
|
+
firstPageInput,
|
|
12121
12269
|
queryTransform
|
|
12122
12270
|
]);
|
|
12271
|
+
const previousCriteria = useRef(void 0);
|
|
12272
|
+
const selectionCriteria = useMemo(() => {
|
|
12273
|
+
const criteria = firstPageInput?.filters === filters ? {
|
|
12274
|
+
...firstPageInput,
|
|
12275
|
+
filters: filterSignature(filters)
|
|
12276
|
+
} : firstPageInput;
|
|
12277
|
+
return replaceEqualDeep(previousCriteria.current, criteria);
|
|
12278
|
+
}, [firstPageInput, filters]);
|
|
12279
|
+
useEffect(() => {
|
|
12280
|
+
previousCriteria.current = selectionCriteria;
|
|
12281
|
+
}, [selectionCriteria]);
|
|
12282
|
+
const selectionScope = useMemo(() => createRowSelectionScope(), [router.list, selectionCriteria]);
|
|
12123
12283
|
const hasReadyListData = useRef(false);
|
|
12124
12284
|
const listQuery = router.list.useQuery(queryInput, {
|
|
12125
12285
|
...queryContext !== void 0 ? { trpc: { context: queryContext } } : {},
|
|
@@ -12302,6 +12462,7 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
|
|
|
12302
12462
|
return;
|
|
12303
12463
|
}
|
|
12304
12464
|
toast$1.success("删除成功");
|
|
12465
|
+
selectionScope.notifyDeleted(modal.selected);
|
|
12305
12466
|
dispatch({
|
|
12306
12467
|
type: "DELETE_SUCCEEDED",
|
|
12307
12468
|
payload: modal.selected
|
|
@@ -12313,7 +12474,8 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
|
|
|
12313
12474
|
idKey,
|
|
12314
12475
|
deleteMutation,
|
|
12315
12476
|
refreshResource,
|
|
12316
|
-
toast$1
|
|
12477
|
+
toast$1,
|
|
12478
|
+
selectionScope
|
|
12317
12479
|
]);
|
|
12318
12480
|
const deleteMany = useCallback((rows) => {
|
|
12319
12481
|
const currentHooks = hooksRef.current;
|
|
@@ -12416,6 +12578,8 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
|
|
|
12416
12578
|
filterState,
|
|
12417
12579
|
tableData: {
|
|
12418
12580
|
data: tableRows,
|
|
12581
|
+
selectionScope,
|
|
12582
|
+
isPlaceholderData: Boolean(listQuery.isPlaceholderData),
|
|
12419
12583
|
countSource: {
|
|
12420
12584
|
navigationKey: listData && !listQuery.isPlaceholderData ? navigationKey : null,
|
|
12421
12585
|
refreshVersion,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordrhyme/auto-crud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.24.0",
|
|
5
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
6
6
|
"author": "wordrhyme",
|
|
7
7
|
"license": "MIT",
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
"nanoid": "^5.1.6",
|
|
72
72
|
"tailwind-merge": "^3.5.0",
|
|
73
73
|
"vaul": "^1.1.2",
|
|
74
|
+
"@wordrhyme/formily-shadcn": "2.1.5",
|
|
74
75
|
"@wordrhyme/shadcn": "2.0.3",
|
|
75
|
-
"@wordrhyme/shadcn-ui": "2.1.
|
|
76
|
-
"@wordrhyme/formily-shadcn": "2.1.4"
|
|
76
|
+
"@wordrhyme/shadcn-ui": "2.1.5"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@storybook/react": "^8.6.18",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"typescript": "^5.9.3",
|
|
96
96
|
"vitest": "^3.2.4",
|
|
97
97
|
"@internal/prettier-config": "0.0.1",
|
|
98
|
-
"@internal/tsconfig": "0.1.0",
|
|
99
98
|
"@internal/eslint-config": "0.3.0",
|
|
99
|
+
"@internal/tsconfig": "0.1.0",
|
|
100
100
|
"@internal/tsdown-config": "0.1.0",
|
|
101
101
|
"@internal/vitest-config": "0.1.0"
|
|
102
102
|
},
|