@wordrhyme/auto-crud 1.23.2 → 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/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");
@@ -2098,175 +2126,183 @@ function ViewMenu({ resourceId, table, fieldsReady = true, defaultView, presets,
2098
2126
  className: cn("pointer-events-none absolute inset-x-0 h-1 bg-primary", linePosition === "top" ? "top-0" : "bottom-0", tabs?.classNames?.indicator)
2099
2127
  }) : null;
2100
2128
  const triggerLabel = display === "tabs" ? "视图设置" : selected === null ? "切换视图" : void 0;
2129
+ const viewActions = selected && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [canUpdate ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
2130
+ type: "button",
2131
+ size: "sm",
2132
+ disabled: mutation.isPending,
2133
+ onClick: () => mutation.mutate({
2134
+ operation: "update",
2135
+ input: {
2136
+ name: selected.name,
2137
+ slug: selected.slug,
2138
+ scope: selected.source === "saved" ? selected.scope : void 0,
2139
+ query: current
2140
+ }
2141
+ }),
2142
+ children: "保存修改"
2143
+ }) : canCreate && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
2144
+ type: "button",
2145
+ size: "sm",
2146
+ disabled: mutation.isPending,
2147
+ onClick: () => open("create"),
2148
+ children: "另存为新视图"
2149
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
2150
+ type: "button",
2151
+ size: "sm",
2152
+ variant: "ghost",
2153
+ disabled: mutation.isPending,
2154
+ onClick: () => select(selected),
2155
+ children: "还原"
2156
+ })] });
2101
2157
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [children(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2102
2158
  className: "flex min-w-0 flex-wrap items-center gap-2",
2103
2159
  children: [
2104
2160
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2105
- className: cn("flex min-w-0 max-w-full items-center gap-1", display === "tabs" && lineTabs && ["relative w-full before:pointer-events-none before:absolute before:inset-x-0 before:h-px before:bg-border", linePosition === "top" ? "before:top-0" : "before:bottom-0"]),
2106
- children: [display === "tabs" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2107
- className: cn("min-w-0 max-w-full overflow-x-auto", lineTabs && "flex-1"),
2108
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.ToggleGroup, {
2109
- type: "single",
2110
- size: "sm",
2111
- spacing: 1,
2112
- value: selected ? `view:${selected.id}` : "all",
2113
- onValueChange: selectValue,
2114
- disabled: !fieldsReady || views.isPending || mutation.isPending,
2115
- "aria-label": "已保存的视图",
2116
- className: cn(lineTabs ? "min-w-full justify-start gap-0 rounded-none bg-transparent p-0" : "rounded-lg bg-muted p-1", tabs?.classNames?.list),
2117
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.ToggleGroupItem, {
2118
- value: "all",
2119
- className: tabClassName,
2120
- children: [
2121
- "全部",
2122
- renderCount("all"),
2123
- renderIndicator(selected === null)
2124
- ]
2125
- }), viewItems.map((view, index$1) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.ToggleGroupItem, {
2126
- value: `view:${view.id}`,
2127
- title: view.source === "preset" ? `${view.name}(预设视图)` : view.name,
2128
- className: tabClassName,
2129
- children: [
2130
- view.name,
2131
- renderCount(`view:${index$1}`),
2132
- renderIndicator(selected?.id === view.id),
2133
- selected?.id === view.id && dirty && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2134
- "aria-label": "有未保存修改",
2135
- className: "size-1.5 rounded-full bg-current"
2136
- })
2137
- ]
2138
- }, view.id))]
2139
- })
2140
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenu, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuTrigger, {
2141
- asChild: true,
2142
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
2143
- type: "button",
2144
- variant: display === "tabs" ? "ghost" : "outline",
2145
- size: display === "tabs" || selected === null ? "icon-sm" : "sm",
2146
- className: cn("relative shrink-0", display === "dropdown" && selected === null && counts && "w-auto px-2"),
2147
- "aria-label": triggerLabel,
2148
- title: triggerLabel,
2149
- disabled: !fieldsReady || views.isPending || mutation.isPending,
2150
- children: display === "tabs" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Settings, { className: "size-4" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2151
- selected ? selected.name : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Layers, {
2152
- "aria-hidden": "true",
2153
- className: "size-4"
2154
- }),
2155
- renderCount(selected ? `view:${viewItems.findIndex((view) => view.id === selected.id)}` : "all"),
2156
- dirty && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2157
- "aria-label": "有未保存修改",
2158
- className: cn("size-1.5 rounded-full bg-current", selected === null && "absolute right-1 top-1")
2159
- }),
2160
- selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "size-4" })
2161
- ] })
2162
- })
2163
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuContent, {
2164
- align: "start",
2165
- children: [
2166
- display === "dropdown" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioGroup, {
2161
+ className: cn("flex min-w-0 max-w-full items-center gap-1", display === "tabs" && "w-full", display === "tabs" && lineTabs && ["relative before:pointer-events-none before:absolute before:inset-x-0 before:h-px before:bg-border", linePosition === "top" ? "before:top-0" : "before:bottom-0"]),
2162
+ children: [
2163
+ display === "tabs" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2164
+ className: "min-w-0 flex-1 overflow-x-auto",
2165
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.ToggleGroup, {
2166
+ type: "single",
2167
+ size: "sm",
2168
+ spacing: 1,
2167
2169
  value: selected ? `view:${selected.id}` : "all",
2168
2170
  onValueChange: selectValue,
2169
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioItem, {
2171
+ disabled: !fieldsReady || views.isPending || mutation.isPending,
2172
+ "aria-label": "已保存的视图",
2173
+ className: cn(lineTabs ? "min-w-full justify-start gap-0 rounded-none bg-transparent p-0" : "rounded-lg bg-muted p-1", tabs?.classNames?.list),
2174
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.ToggleGroupItem, {
2170
2175
  value: "all",
2171
- children: ["全部", renderCount("all")]
2172
- }), viewItems.map((view, index$1) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioItem, {
2176
+ className: tabClassName,
2177
+ children: [
2178
+ "全部",
2179
+ renderCount("all"),
2180
+ renderIndicator(selected === null)
2181
+ ]
2182
+ }), viewItems.map((view, index$1) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.ToggleGroupItem, {
2173
2183
  value: `view:${view.id}`,
2174
- children: [view.name, renderCount(`view:${index$1}`)]
2184
+ title: view.source === "preset" ? `${view.name}(预设视图)` : view.name,
2185
+ className: tabClassName,
2186
+ children: [
2187
+ view.name,
2188
+ renderCount(`view:${index$1}`),
2189
+ renderIndicator(selected?.id === view.id),
2190
+ selected?.id === view.id && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2191
+ "aria-label": dirty ? "有未保存修改" : void 0,
2192
+ className: cn("size-1.5 rounded-full bg-current", !dirty && "invisible")
2193
+ })
2194
+ ]
2175
2195
  }, view.id))]
2176
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuSeparator, {})] }),
2177
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuLabel, { children: "视图设置" }),
2178
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2179
- disabled: !ready || !canCreate,
2180
- onSelect: () => open("create"),
2181
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Plus, { className: "size-4" }), "另存为新视图"]
2182
- }),
2183
- selected && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2184
- canUpdate && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2185
- onSelect: () => open("rename"),
2186
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Pencil, { className: "size-4" }), "重命名视图"]
2187
- }),
2196
+ })
2197
+ }),
2198
+ display === "tabs" && viewActions && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2199
+ className: cn("flex shrink-0 items-center gap-1", !dirty && "invisible"),
2200
+ children: viewActions
2201
+ }),
2202
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenu, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuTrigger, {
2203
+ asChild: true,
2204
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
2205
+ type: "button",
2206
+ variant: display === "tabs" ? "ghost" : "outline",
2207
+ size: display === "tabs" || selected === null ? "icon-sm" : "sm",
2208
+ className: cn("relative shrink-0", display === "dropdown" && selected === null && counts && "w-auto px-2"),
2209
+ "aria-label": triggerLabel,
2210
+ title: triggerLabel,
2211
+ disabled: !fieldsReady || views.isPending || mutation.isPending,
2212
+ children: display === "tabs" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Settings, { className: "size-4" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2213
+ selected ? selected.name : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Layers, {
2214
+ "aria-hidden": "true",
2215
+ className: "size-4"
2216
+ }),
2217
+ renderCount(selected ? `view:${viewItems.findIndex((view) => view.id === selected.id)}` : "all"),
2218
+ dirty && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2219
+ "aria-label": "有未保存修改",
2220
+ className: cn("size-1.5 rounded-full bg-current", selected === null && "absolute right-1 top-1")
2221
+ }),
2222
+ selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "size-4" })
2223
+ ] })
2224
+ })
2225
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuContent, {
2226
+ align: "start",
2227
+ children: [
2228
+ display === "dropdown" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioGroup, {
2229
+ value: selected ? `view:${selected.id}` : "all",
2230
+ onValueChange: selectValue,
2231
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioItem, {
2232
+ value: "all",
2233
+ children: ["全部", renderCount("all")]
2234
+ }), viewItems.map((view, index$1) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioItem, {
2235
+ value: `view:${view.id}`,
2236
+ children: [view.name, renderCount(`view:${index$1}`)]
2237
+ }, view.id))]
2238
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuSeparator, {})] }),
2239
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuLabel, { children: "视图设置" }),
2188
2240
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2189
2241
  disabled: !ready || !canCreate,
2190
- onSelect: () => open("duplicate"),
2191
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Copy, { className: "size-4" }), "复制视图"]
2192
- }),
2193
- canDelete && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2194
- onSelect: () => open("delete"),
2195
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Trash2, { className: "size-4" }), "删除视图"]
2242
+ onSelect: () => open("create"),
2243
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Plus, { className: "size-4" }), "另存为新视图"]
2196
2244
  }),
2245
+ selected && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2246
+ canUpdate && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2247
+ onSelect: () => open("rename"),
2248
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Pencil, { className: "size-4" }), "重命名视图"]
2249
+ }),
2250
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2251
+ disabled: !ready || !canCreate,
2252
+ onSelect: () => open("duplicate"),
2253
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Copy, { className: "size-4" }), "复制视图"]
2254
+ }),
2255
+ canDelete && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2256
+ onSelect: () => open("delete"),
2257
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Trash2, { className: "size-4" }), "删除视图"]
2258
+ }),
2259
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2260
+ disabled: !ready,
2261
+ onSelect: hideView,
2262
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.EyeOff, { className: "size-4" }), "隐藏视图"]
2263
+ })
2264
+ ] }),
2265
+ selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuSeparator, {}),
2197
2266
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2267
+ disabled: !ready || viewItems.length < 2,
2268
+ onSelect: () => open("reorder"),
2269
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowDownUp, { className: "size-4" }), "调整顺序"]
2270
+ }),
2271
+ restorableViews.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuSub, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuSubTrigger, {
2198
2272
  disabled: !ready,
2199
- onSelect: hideView,
2200
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.EyeOff, { className: "size-4" }), "隐藏视图"]
2201
- })
2202
- ] }),
2203
- selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuSeparator, {}),
2204
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2205
- disabled: !ready || viewItems.length < 2,
2206
- onSelect: () => open("reorder"),
2207
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowDownUp, { className: "size-4" }), "调整顺序"]
2208
- }),
2209
- restorableViews.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuSub, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuSubTrigger, {
2210
- disabled: !ready,
2211
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Eye, { className: "size-4" }), "恢复隐藏视图"]
2212
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuSubContent, { children: restorableViews.map((view) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2213
- onSelect: () => {
2214
- preferencesRestored.current = false;
2215
- savePreferences({ hiddenViewIds: preferencesRef.current?.hiddenViewIds?.filter((id) => id !== view.id) });
2216
- setError(null);
2217
- },
2218
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Eye, { className: "size-4" }), view.name]
2219
- }, view.id)) })] }),
2220
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuSub, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuSubTrigger, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.PanelsTopLeft, { className: "size-4" }), "展示方式"] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuSubContent, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioGroup, {
2221
- value: display,
2222
- onValueChange: (value) => {
2223
- if (value === "dropdown" || value === "tabs") {
2224
- setDisplay(value);
2225
- savePreferences({
2226
- selector: value,
2227
- viewId: selected?.id ?? null
2228
- });
2229
- }
2230
- },
2231
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioItem, {
2232
- value: "dropdown",
2233
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "size-4" }), "下拉"]
2234
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioItem, {
2235
- value: "tabs",
2236
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.AppWindow, { className: "size-4" }), "Tab"]
2237
- })]
2238
- }) })] })
2239
- ]
2240
- })] })]
2273
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Eye, { className: "size-4" }), "恢复隐藏视图"]
2274
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuSubContent, { children: restorableViews.map((view) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuItem, {
2275
+ onSelect: () => {
2276
+ preferencesRestored.current = false;
2277
+ savePreferences({ hiddenViewIds: preferencesRef.current?.hiddenViewIds?.filter((id) => id !== view.id) });
2278
+ setError(null);
2279
+ },
2280
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Eye, { className: "size-4" }), view.name]
2281
+ }, view.id)) })] }),
2282
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuSub, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuSubTrigger, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.PanelsTopLeft, { className: "size-4" }), "展示方式"] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.DropdownMenuSubContent, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioGroup, {
2283
+ value: display,
2284
+ onValueChange: (value) => {
2285
+ if (value === "dropdown" || value === "tabs") {
2286
+ setDisplay(value);
2287
+ savePreferences({
2288
+ selector: value,
2289
+ viewId: selected?.id ?? null
2290
+ });
2291
+ }
2292
+ },
2293
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioItem, {
2294
+ value: "dropdown",
2295
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "size-4" }), "下拉"]
2296
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.DropdownMenuRadioItem, {
2297
+ value: "tabs",
2298
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.AppWindow, { className: "size-4" }), "Tab"]
2299
+ })]
2300
+ }) })] })
2301
+ ]
2302
+ })] })
2303
+ ]
2241
2304
  }),
2242
- dirty && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [canUpdate ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
2243
- type: "button",
2244
- size: "sm",
2245
- disabled: mutation.isPending,
2246
- onClick: () => mutation.mutate({
2247
- operation: "update",
2248
- input: {
2249
- name: selected.name,
2250
- slug: selected.slug,
2251
- scope: selected.source === "saved" ? selected.scope : void 0,
2252
- query: current
2253
- }
2254
- }),
2255
- children: "保存修改"
2256
- }) : canCreate && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
2257
- type: "button",
2258
- size: "sm",
2259
- disabled: mutation.isPending,
2260
- onClick: () => open("create"),
2261
- children: "另存为新视图"
2262
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
2263
- type: "button",
2264
- size: "sm",
2265
- variant: "ghost",
2266
- disabled: mutation.isPending,
2267
- onClick: () => select(selected),
2268
- children: "还原"
2269
- })] }),
2305
+ display === "dropdown" && dirty && viewActions,
2270
2306
  (error !== null || views.error !== null || collection.error !== null) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2271
2307
  role: "alert",
2272
2308
  className: "text-sm text-destructive",
@@ -3438,6 +3474,8 @@ function DataTablePagination({ table, pageSizeOptions = [
3438
3474
  const canJump = Number.isFinite(pageCount) && pageCount > 0;
3439
3475
  const canGoNext = table.getCanNextPage() && (knownPageCount || table.options.data.length >= pageSize);
3440
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;
3441
3479
  (0, react.useEffect)(() => {
3442
3480
  if (!responsive || !container.current || !summary.current || !controls.current || !navigation.current) return;
3443
3481
  if (typeof ResizeObserver === "undefined") return;
@@ -3486,7 +3524,7 @@ function DataTablePagination({ table, pageSizeOptions = [
3486
3524
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3487
3525
  ref: summary,
3488
3526
  className: "flex flex-1 items-center gap-6 whitespace-nowrap text-muted-foreground text-sm",
3489
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: locale.selected(table.getFilteredSelectedRowModel().rows.length, table.getFilteredRowModel().rows.length) }), total !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: locale.total(total) })]
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) })]
3490
3528
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3491
3529
  ref: controls,
3492
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"),
@@ -3803,7 +3841,7 @@ function DataTable({ table, actionBar, pagination, expandedRow, rowFooter, child
3803
3841
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTablePagination, {
3804
3842
  table,
3805
3843
  ...pagination
3806
- }), actionBar && table.getFilteredSelectedRowModel().rows.length > 0 && actionBar]
3844
+ }), actionBar && getSelectedTableRows(table).length > 0 && actionBar]
3807
3845
  })
3808
3846
  ]
3809
3847
  });
@@ -5985,12 +6023,14 @@ function createSelectColumn() {
5985
6023
  id: "select",
5986
6024
  header: ({ table }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Checkbox, {
5987
6025
  "aria-label": "Select all",
6026
+ disabled: !table.getPaginationRowModel().flatRows.some((row) => row.getCanSelect()),
5988
6027
  className: "translate-y-0.5",
5989
6028
  checked: table.getIsAllPageRowsSelected() || table.getIsSomePageRowsSelected() && "indeterminate",
5990
6029
  onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
5991
6030
  }),
5992
6031
  cell: ({ row }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Checkbox, {
5993
6032
  "aria-label": "Select row",
6033
+ disabled: !row.getCanSelect(),
5994
6034
  className: "translate-y-0.5",
5995
6035
  checked: row.getIsSelected(),
5996
6036
  onCheckedChange: (value) => row.toggleSelected(!!value)
@@ -7332,7 +7372,7 @@ function getExportColumnIds(table) {
7332
7372
  function exportTableToCSV(table, opts = {}) {
7333
7373
  const { filename = "table", excludeColumns = [], onlySelected = false } = opts;
7334
7374
  const headers = getExportColumnIds(table).filter((id) => !excludeColumns.includes(id));
7335
- downloadCSV([headers.join(","), ...(onlySelected ? table.getFilteredSelectedRowModel().rows : table.getRowModel().rows).map((row) => headers.map((header) => {
7375
+ downloadCSV([headers.join(","), ...(onlySelected ? getSelectedTableRows(table) : table.getRowModel().rows).map((row) => headers.map((header) => {
7336
7376
  const cellValue = row.getValue(header);
7337
7377
  return typeof cellValue === "string" ? `"${cellValue.replace(/"/g, "\"\"")}"` : cellValue;
7338
7378
  }).join(","))].join("\n"), filename);
@@ -7381,14 +7421,14 @@ function AutoTableActionBar({ table, locale: localeProp, onDeleteSelected, onUpd
7381
7421
  ...enUSActionBar,
7382
7422
  ...localeProp
7383
7423
  }), [localeProp]);
7384
- const rows = table.getFilteredSelectedRowModel().rows;
7424
+ const rows = getSelectedTableRows(table);
7385
7425
  const selectedRows = react.useMemo(() => rows.map((row) => row.original), [rows]);
7386
7426
  const [deleteDialogOpen, setDeleteDialogOpen] = react.useState(false);
7387
7427
  react.useEffect(() => {
7388
7428
  if (selectedRows.length === 0) setDeleteDialogOpen(false);
7389
7429
  }, [selectedRows.length]);
7390
7430
  const clearSelection = react.useCallback(() => {
7391
- table.toggleAllRowsSelected(false);
7431
+ table.resetRowSelection(true);
7392
7432
  }, [table]);
7393
7433
  const actionContext = react.useMemo(() => ({
7394
7434
  rows: selectedRows,
@@ -7795,7 +7835,7 @@ const filterModeConfig = {
7795
7835
  tooltip: "Linear-style command filters"
7796
7836
  }
7797
7837
  };
7798
- 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 }) {
7799
7839
  const inheritedResourceId = (0, react.useContext)(CrudResourceContext);
7800
7840
  const activeResourceId = resourceId ?? inheritedResourceId;
7801
7841
  const viewsEnabled = views ?? false;
@@ -7916,12 +7956,28 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
7916
7956
  actions
7917
7957
  ]);
7918
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]);
7919
7975
  const { table, shallow, debounceMs, throttleMs } = useDataTable({
7920
- data,
7976
+ data: keyedData,
7921
7977
  columns,
7922
7978
  queryKeys,
7923
- enableRowSelection,
7924
- getRowId,
7979
+ enableRowSelection: enableRowSelection && !pagePending,
7980
+ getRowId: resolveRowId,
7925
7981
  getRowCanExpand: () => enableExpansion,
7926
7982
  getExpandedRowModel: enableExpansion ? expandedRowModel : void 0,
7927
7983
  autoResetExpanded: defaultExpanded ? false : void 0,
@@ -7953,14 +8009,95 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
7953
8009
  exportTableRef.current = null;
7954
8010
  };
7955
8011
  }, [table, exportTableRef]);
7956
- const rowSelection = table.getState().rowSelection;
7957
- const columnFilters = table.getState().columnFilters;
7958
- const selectedRows = (0, react.useMemo)(() => table.getFilteredSelectedRowModel().rows.map((row) => row.original), [
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
+ }, [
7959
8079
  table,
7960
8080
  rowSelection,
7961
- columnFilters,
7962
- data
8081
+ selectedTableRows,
8082
+ pagePending,
8083
+ data,
8084
+ loadedIndex
7963
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]);
7964
8101
  const getSelectedRowsFn = (0, react.useCallback)(() => selectedRows, [selectedRows]);
7965
8102
  (0, react.useEffect)(() => {
7966
8103
  if (getSelectedRows) getSelectedRows.current = getSelectedRowsFn;
@@ -8077,20 +8214,28 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
8077
8214
  });
8078
8215
  const state = table.getState();
8079
8216
  const tableContent = (0, react.useMemo)(() => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTable, {
8080
- pagination,
8217
+ pagination: {
8218
+ ...pagination,
8219
+ locale: {
8220
+ selectedCount: actionBarLocale?.selected,
8221
+ ...pagination?.locale
8222
+ }
8223
+ },
8081
8224
  table,
8082
8225
  classNames,
8083
8226
  expandedRow,
8084
8227
  rowFooter
8085
8228
  }), [
8086
8229
  table,
8087
- data,
8230
+ keyedData,
8231
+ pagePending,
8088
8232
  columns,
8089
8233
  getRowId,
8090
8234
  pageCount,
8091
8235
  total,
8092
8236
  stableInitialState,
8093
8237
  pagination,
8238
+ actionBarLocale?.selected,
8094
8239
  classNames,
8095
8240
  expandedRow,
8096
8241
  rowFooter,
@@ -9657,10 +9802,6 @@ function resolveOwnerBatchActions(actions) {
9657
9802
  function isUnifiedActionsConfig(actions) {
9658
9803
  return typeof actions === "object" && actions !== null && !Array.isArray(actions);
9659
9804
  }
9660
- function readRowId(row, idKey) {
9661
- const value = row[idKey];
9662
- return value === null || value === void 0 ? void 0 : String(value);
9663
- }
9664
9805
  function readRowIds(rows, idKey) {
9665
9806
  return rows.flatMap((row) => {
9666
9807
  const value = readRowId(row, idKey);
@@ -10853,7 +10994,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
10853
10994
  ...action$1,
10854
10995
  onClick: (_rows, { table }) => {
10855
10996
  const headers = getExportColumnIds(table).filter((key) => key !== "select" && key !== "actions" && !denyFields?.includes(key));
10856
- exportAllToCSV(table.getFilteredSelectedRowModel().rows.map((row) => formatExportRow(row.original, resolvedFields, Object.fromEntries(headers.map((key) => [key, row.getValue(key)])))), {
10997
+ exportAllToCSV(getSelectedTableRows(table).map((row) => formatExportRow(row.original, resolvedFields, Object.fromEntries(headers.map((key) => [key, row.getValue(key)])))), {
10857
10998
  filename: "table",
10858
10999
  headers
10859
11000
  });
@@ -11165,6 +11306,9 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
11165
11306
  enableRowSelection: tableConfig?.enableRowSelection,
11166
11307
  initialColumnVisibility: tableConfig?.initialColumnVisibility,
11167
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,
11168
11312
  expandedRow: tableConfig?.expandedRow,
11169
11313
  rowFooter: tableConfig?.rowFooter,
11170
11314
  defaultExpanded: tableConfig?.defaultExpanded,
@@ -12109,25 +12253,49 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
12109
12253
  const [filtersReady, setFiltersReady] = (0, react.useState)(!metadataPending);
12110
12254
  (0, react.useEffect)(() => setFiltersReady(!metadataPending), [metadataPending]);
12111
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]);
12112
12270
  const queryInput = (0, react.useMemo)(() => {
12271
+ if (page === firstPageParams.page && perPage === firstPageParams.perPage && sort === firstPageParams.sort) return firstPageInput;
12113
12272
  const autoParams = {
12273
+ ...firstPageParams,
12114
12274
  page,
12115
12275
  perPage,
12116
- sort,
12117
- filters,
12118
- joinOperator,
12119
- ...search.trim() ? { search: search.trim() } : {}
12276
+ sort
12120
12277
  };
12121
12278
  return queryTransform ? queryTransform(autoParams) : autoParams;
12122
12279
  }, [
12123
12280
  page,
12124
12281
  perPage,
12125
12282
  sort,
12126
- filters,
12127
- joinOperator,
12128
- search,
12283
+ firstPageParams,
12284
+ firstPageInput,
12129
12285
  queryTransform
12130
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]);
12131
12299
  const hasReadyListData = (0, react.useRef)(false);
12132
12300
  const listQuery = router.list.useQuery(queryInput, {
12133
12301
  ...queryContext !== void 0 ? { trpc: { context: queryContext } } : {},
@@ -12310,6 +12478,7 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
12310
12478
  return;
12311
12479
  }
12312
12480
  toast$1.success("删除成功");
12481
+ selectionScope.notifyDeleted(modal.selected);
12313
12482
  dispatch({
12314
12483
  type: "DELETE_SUCCEEDED",
12315
12484
  payload: modal.selected
@@ -12321,7 +12490,8 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
12321
12490
  idKey,
12322
12491
  deleteMutation,
12323
12492
  refreshResource,
12324
- toast$1
12493
+ toast$1,
12494
+ selectionScope
12325
12495
  ]);
12326
12496
  const deleteMany = (0, react.useCallback)((rows) => {
12327
12497
  const currentHooks = hooksRef.current;
@@ -12424,6 +12594,8 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
12424
12594
  filterState,
12425
12595
  tableData: {
12426
12596
  data: tableRows,
12597
+ selectionScope,
12598
+ isPlaceholderData: Boolean(listQuery.isPlaceholderData),
12427
12599
  countSource: {
12428
12600
  navigationKey: listData && !listQuery.isPlaceholderData ? navigationKey : null,
12429
12601
  refreshVersion,