@wordrhyme/auto-crud 1.22.1 → 1.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +98 -43
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +20 -19
- package/dist/index.js +98 -43
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -3418,9 +3418,11 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3418
3418
|
const [hasSpace, setHasSpace] = (0, react.useState)(false);
|
|
3419
3419
|
const hideExtras = responsive && !hasSpace;
|
|
3420
3420
|
const hiddenClass = hideExtras ? "absolute invisible pointer-events-none left-0 top-0" : void 0;
|
|
3421
|
-
const pageIndex = table.getState().pagination
|
|
3421
|
+
const { pageIndex, pageSize } = table.getState().pagination;
|
|
3422
3422
|
const pageCount = table.getPageCount();
|
|
3423
|
+
const knownPageCount = pageCount >= 0;
|
|
3423
3424
|
const canJump = Number.isFinite(pageCount) && pageCount > 0;
|
|
3425
|
+
const canGoNext = table.getCanNextPage() && (knownPageCount || table.options.data.length >= pageSize);
|
|
3424
3426
|
const total = table.options.rowCount ?? (table.options.manualPagination ? void 0 : table.getRowCount());
|
|
3425
3427
|
(0, react.useEffect)(() => {
|
|
3426
3428
|
if (!responsive || !container.current || !summary.current || !controls.current || !navigation.current) return;
|
|
@@ -3490,16 +3492,16 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3490
3492
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.SelectValue, { placeholder: table.getState().pagination.pageSize })
|
|
3491
3493
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.SelectContent, {
|
|
3492
3494
|
side: "top",
|
|
3493
|
-
children: pageSizeOptions.map((pageSize) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.SelectItem, {
|
|
3494
|
-
value: `${pageSize}`,
|
|
3495
|
-
children: pageSize
|
|
3496
|
-
}, pageSize))
|
|
3495
|
+
children: pageSizeOptions.map((pageSize$1) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.SelectItem, {
|
|
3496
|
+
value: `${pageSize$1}`,
|
|
3497
|
+
children: pageSize$1
|
|
3498
|
+
}, pageSize$1))
|
|
3497
3499
|
})]
|
|
3498
3500
|
})]
|
|
3499
3501
|
}),
|
|
3500
3502
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3501
3503
|
className: "flex items-center justify-center font-medium text-sm",
|
|
3502
|
-
children: locale.page(pageIndex + 1, pageCount)
|
|
3504
|
+
children: knownPageCount ? locale.page(pageIndex + 1, pageCount) : pageIndex + 1
|
|
3503
3505
|
}),
|
|
3504
3506
|
showPageJump && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3505
3507
|
ref: pageJump,
|
|
@@ -3564,7 +3566,7 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3564
3566
|
size: "icon",
|
|
3565
3567
|
className: "size-8",
|
|
3566
3568
|
onClick: () => table.nextPage(),
|
|
3567
|
-
disabled: !
|
|
3569
|
+
disabled: !canGoNext,
|
|
3568
3570
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, {})
|
|
3569
3571
|
}),
|
|
3570
3572
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
|
|
@@ -3573,7 +3575,7 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3573
3575
|
size: "icon",
|
|
3574
3576
|
className: cn("size-8", alwaysShowFirstLast ? "flex" : "hidden lg:flex", hiddenClass),
|
|
3575
3577
|
onClick: () => table.setPageIndex(table.getPageCount() - 1),
|
|
3576
|
-
disabled: !
|
|
3578
|
+
disabled: !canJump || !canGoNext,
|
|
3577
3579
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronsRight, {})
|
|
3578
3580
|
})
|
|
3579
3581
|
]
|
|
@@ -7910,7 +7912,7 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
|
|
|
7910
7912
|
getExpandedRowModel: enableExpansion ? expandedRowModel : void 0,
|
|
7911
7913
|
autoResetExpanded: defaultExpanded ? false : void 0,
|
|
7912
7914
|
pageCount,
|
|
7913
|
-
|
|
7915
|
+
rowCount: total,
|
|
7914
7916
|
enableAdvancedFilter,
|
|
7915
7917
|
initialState: stableInitialState,
|
|
7916
7918
|
shallow: false,
|
|
@@ -10606,6 +10608,39 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
10606
10608
|
const canImport = can.import && !!resource.handlers.import;
|
|
10607
10609
|
const canExport = can.export;
|
|
10608
10610
|
const [importOpen, setImportOpen] = react.useState(false);
|
|
10611
|
+
const resourceIdKey = resource.idKey ?? "id";
|
|
10612
|
+
const modal = resource.modal;
|
|
10613
|
+
const deleteTarget = modal.selected && (readRowId(modal.selected, resourceIdKey) ?? modal.selected);
|
|
10614
|
+
const deleteRequest = react.useRef(null);
|
|
10615
|
+
const [deletePhase, setDeletePhase] = react.useState("idle");
|
|
10616
|
+
const deleting = deletePhase !== "idle" || resource.mutations.isDeleting;
|
|
10617
|
+
react.useEffect(() => {
|
|
10618
|
+
if (deletePhase !== "settled" || !deleteRequest.current) return;
|
|
10619
|
+
const submitted = deleteRequest.current;
|
|
10620
|
+
deleteRequest.current = null;
|
|
10621
|
+
setDeletePhase("idle");
|
|
10622
|
+
if (modal.deleteOpen && submitted.target === deleteTarget && submitted.modal.viewOpen === modal.viewOpen && submitted.modal.editOpen === modal.editOpen && submitted.modal.createOpen === modal.createOpen) resource.handlers.closeModals();
|
|
10623
|
+
}, [
|
|
10624
|
+
deletePhase,
|
|
10625
|
+
deleteTarget,
|
|
10626
|
+
modal,
|
|
10627
|
+
resource.handlers
|
|
10628
|
+
]);
|
|
10629
|
+
const confirmDelete = async () => {
|
|
10630
|
+
if (deleteRequest.current || deleting) return;
|
|
10631
|
+
deleteRequest.current = {
|
|
10632
|
+
target: deleteTarget,
|
|
10633
|
+
modal
|
|
10634
|
+
};
|
|
10635
|
+
setDeletePhase("pending");
|
|
10636
|
+
try {
|
|
10637
|
+
await resource.handlers.confirmDelete();
|
|
10638
|
+
} catch (error) {
|
|
10639
|
+
sonner.toast.error(error instanceof Error ? error.message : String(error));
|
|
10640
|
+
} finally {
|
|
10641
|
+
setDeletePhase("settled");
|
|
10642
|
+
}
|
|
10643
|
+
};
|
|
10609
10644
|
const [selectedRows, setSelectedRows] = react.useState([]);
|
|
10610
10645
|
const [exporting, setExporting] = react.useState(false);
|
|
10611
10646
|
const exportBusyRef = react.useRef(false);
|
|
@@ -10626,7 +10661,6 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
10626
10661
|
]);
|
|
10627
10662
|
const excludedColumns = react.useMemo(() => hiddenColumns.filter((key) => !filterOnly.includes(key)), [hiddenColumns, filterOnly]);
|
|
10628
10663
|
const dynamicResolveOptions = useDynamicResolveOptions(resolvedFields, resource.tableData.data, hiddenColumns);
|
|
10629
|
-
const resourceIdKey = resource.idKey ?? "id";
|
|
10630
10664
|
const tagFields = react.useMemo(() => Object.entries(resolvedFields).filter(([field, config]) => config.tags && !config.hidden && !denyFields?.includes(field)).map(([field, config]) => {
|
|
10631
10665
|
const label = config.label ?? humanize(field);
|
|
10632
10666
|
return {
|
|
@@ -11187,12 +11221,26 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
11187
11221
|
}),
|
|
11188
11222
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_ui.AlertDialog, {
|
|
11189
11223
|
open: resource.modal.deleteOpen,
|
|
11190
|
-
onOpenChange: (open) =>
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11224
|
+
onOpenChange: (open) => {
|
|
11225
|
+
if (!open && !deleteRequest.current && !deleting) resource.handlers.closeModals();
|
|
11226
|
+
},
|
|
11227
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_ui.AlertDialogContent, {
|
|
11228
|
+
"aria-busy": deleting,
|
|
11229
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_ui.AlertDialogHeader, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_ui.AlertDialogTitle, { children: locale.deleteModal.title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_ui.AlertDialogDescription, { children: locale.deleteModal.description })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_ui.AlertDialogFooter, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_ui.AlertDialogCancel, {
|
|
11230
|
+
disabled: deleting,
|
|
11231
|
+
children: locale.deleteModal.cancel
|
|
11232
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_ui.AlertDialogAction, {
|
|
11233
|
+
onClick: (event) => {
|
|
11234
|
+
event.preventDefault();
|
|
11235
|
+
confirmDelete();
|
|
11236
|
+
},
|
|
11237
|
+
disabled: deleting,
|
|
11238
|
+
children: [deleting && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, {
|
|
11239
|
+
"aria-hidden": "true",
|
|
11240
|
+
className: "h-4 w-4 animate-spin"
|
|
11241
|
+
}), deleting ? locale.deleteModal.confirming : locale.deleteModal.confirm]
|
|
11242
|
+
})] })]
|
|
11243
|
+
})
|
|
11196
11244
|
}),
|
|
11197
11245
|
canImport && resource.handlers.import && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImportDialog, {
|
|
11198
11246
|
open: importOpen,
|
|
@@ -11931,18 +11979,21 @@ function modalReducer(state, action$1) {
|
|
|
11931
11979
|
case "OPEN_CREATE": return {
|
|
11932
11980
|
...state,
|
|
11933
11981
|
createOpen: true,
|
|
11982
|
+
deleteOpen: false,
|
|
11934
11983
|
selected: null,
|
|
11935
11984
|
copySource: null
|
|
11936
11985
|
};
|
|
11937
11986
|
case "OPEN_CREATE_WITH_COPY": return {
|
|
11938
11987
|
...state,
|
|
11939
11988
|
createOpen: true,
|
|
11989
|
+
deleteOpen: false,
|
|
11940
11990
|
selected: null,
|
|
11941
11991
|
copySource: action$1.payload
|
|
11942
11992
|
};
|
|
11943
11993
|
case "OPEN_EDIT": return {
|
|
11944
11994
|
...state,
|
|
11945
11995
|
editOpen: true,
|
|
11996
|
+
deleteOpen: false,
|
|
11946
11997
|
selected: action$1.payload
|
|
11947
11998
|
};
|
|
11948
11999
|
case "OPEN_DELETE": return {
|
|
@@ -11950,9 +12001,19 @@ function modalReducer(state, action$1) {
|
|
|
11950
12001
|
deleteOpen: true,
|
|
11951
12002
|
selected: action$1.payload
|
|
11952
12003
|
};
|
|
12004
|
+
case "DELETE_SUCCEEDED": {
|
|
12005
|
+
if (!state.deleteOpen || state.selected !== action$1.payload) return state;
|
|
12006
|
+
const otherModalOpen = state.createOpen || state.editOpen || state.viewOpen;
|
|
12007
|
+
return {
|
|
12008
|
+
...state,
|
|
12009
|
+
deleteOpen: false,
|
|
12010
|
+
selected: otherModalOpen ? state.selected : null
|
|
12011
|
+
};
|
|
12012
|
+
}
|
|
11953
12013
|
case "OPEN_VIEW": return {
|
|
11954
12014
|
...state,
|
|
11955
12015
|
viewOpen: true,
|
|
12016
|
+
deleteOpen: false,
|
|
11956
12017
|
selected: action$1.payload
|
|
11957
12018
|
};
|
|
11958
12019
|
case "CLOSE_ALL": return {
|
|
@@ -12193,44 +12254,38 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
|
|
|
12193
12254
|
const confirmDelete = (0, react.useCallback)(async () => {
|
|
12194
12255
|
const currentHooks = hooksRef.current;
|
|
12195
12256
|
if (!modal.selected) return;
|
|
12257
|
+
let data = modal.selected;
|
|
12196
12258
|
try {
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
12200
|
-
|
|
12201
|
-
|
|
12202
|
-
|
|
12203
|
-
|
|
12204
|
-
|
|
12205
|
-
}
|
|
12206
|
-
|
|
12207
|
-
}
|
|
12259
|
+
const handled = currentHooks?.beforeDelete ? await currentHooks.beforeDelete(modal.selected) : void 0;
|
|
12260
|
+
if (handled === false) return;
|
|
12261
|
+
if (handled !== true) {
|
|
12262
|
+
const id = modal.selected[idKey];
|
|
12263
|
+
data = typeof deleteMutation.mutateAsync === "function" ? await deleteMutation.mutateAsync(id) : await new Promise((resolve, reject) => {
|
|
12264
|
+
deleteMutation.mutate(id, {
|
|
12265
|
+
onSuccess: resolve,
|
|
12266
|
+
onError: reject
|
|
12267
|
+
});
|
|
12268
|
+
});
|
|
12208
12269
|
}
|
|
12209
|
-
const id = modal.selected[idKey];
|
|
12210
|
-
deleteMutation.mutate(id, {
|
|
12211
|
-
onSuccess: (data) => {
|
|
12212
|
-
toast$1.success("删除成功");
|
|
12213
|
-
closeModals();
|
|
12214
|
-
listQuery.refetch();
|
|
12215
|
-
currentHooks?.onSuccess?.("delete", data);
|
|
12216
|
-
},
|
|
12217
|
-
onError: (error) => {
|
|
12218
|
-
const err = error;
|
|
12219
|
-
toast$1.error(`删除失败: ${err.message}`);
|
|
12220
|
-
currentHooks?.onError?.("delete", err);
|
|
12221
|
-
}
|
|
12222
|
-
});
|
|
12223
12270
|
} catch (error) {
|
|
12224
12271
|
const err = error;
|
|
12225
12272
|
toast$1.error(`删除失败: ${err.message}`);
|
|
12226
12273
|
currentHooks?.onError?.("delete", err);
|
|
12274
|
+
return;
|
|
12227
12275
|
}
|
|
12276
|
+
toast$1.success("删除成功");
|
|
12277
|
+
dispatch({
|
|
12278
|
+
type: "DELETE_SUCCEEDED",
|
|
12279
|
+
payload: modal.selected
|
|
12280
|
+
});
|
|
12281
|
+
listQuery.refetch();
|
|
12282
|
+
currentHooks?.onSuccess?.("delete", data);
|
|
12228
12283
|
}, [
|
|
12229
12284
|
modal.selected,
|
|
12230
12285
|
idKey,
|
|
12231
12286
|
deleteMutation,
|
|
12232
|
-
|
|
12233
|
-
|
|
12287
|
+
listQuery,
|
|
12288
|
+
toast$1
|
|
12234
12289
|
]);
|
|
12235
12290
|
const deleteMany = (0, react.useCallback)((rows) => {
|
|
12236
12291
|
const currentHooks = hooksRef.current;
|
package/dist/index.d.cts
CHANGED
|
@@ -299,6 +299,7 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
|
|
|
299
299
|
closeModals: () => void;
|
|
300
300
|
submitCreate: (values: z.infer<TSchema>) => void;
|
|
301
301
|
submitUpdate: (values: z.infer<TSchema>) => void;
|
|
302
|
+
/** The table waits for a returned promise and ignores its resolved value. */
|
|
302
303
|
confirmDelete: () => void;
|
|
303
304
|
deleteMany: (rows: TListItem[]) => void;
|
|
304
305
|
updateMany: (rows: TListItem[], data: Record<string, unknown>) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as positionActions, i as matchesPosition, n as actionPositionSchema, r as compareOrder, t as ActionPosition } from "./position-mYekVBBH.js";
|
|
2
2
|
import * as React$1 from "react";
|
|
3
3
|
import { ComponentProps, ReactNode } from "react";
|
|
4
|
-
import * as
|
|
4
|
+
import * as react_jsx_runtime20 from "react/jsx-runtime";
|
|
5
5
|
import { DropdownMenuTrigger, PopoverContentProps } from "@wordrhyme/shadcn";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { ClassValue } from "clsx";
|
|
@@ -299,6 +299,7 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
|
|
|
299
299
|
closeModals: () => void;
|
|
300
300
|
submitCreate: (values: z.infer<TSchema>) => void;
|
|
301
301
|
submitUpdate: (values: z.infer<TSchema>) => void;
|
|
302
|
+
/** The table waits for a returned promise and ignores its resolved value. */
|
|
302
303
|
confirmDelete: () => void;
|
|
303
304
|
deleteMany: (rows: TListItem[]) => void;
|
|
304
305
|
updateMany: (rows: TListItem[], data: Record<string, unknown>) => void;
|
|
@@ -1052,7 +1053,7 @@ interface AutoCrudProviderProps {
|
|
|
1052
1053
|
declare function AutoCrudProvider({
|
|
1053
1054
|
children,
|
|
1054
1055
|
...config
|
|
1055
|
-
}: AutoCrudProviderProps):
|
|
1056
|
+
}: AutoCrudProviderProps): react_jsx_runtime20.JSX.Element;
|
|
1056
1057
|
//#endregion
|
|
1057
1058
|
//#region src/lib/saved-views.d.ts
|
|
1058
1059
|
declare const viewQuerySchema: z.ZodObject<{
|
|
@@ -1397,7 +1398,7 @@ declare function DataTable<TData>({
|
|
|
1397
1398
|
className,
|
|
1398
1399
|
classNames,
|
|
1399
1400
|
...props
|
|
1400
|
-
}: DataTableProps<TData>):
|
|
1401
|
+
}: DataTableProps<TData>): react_jsx_runtime20.JSX.Element;
|
|
1401
1402
|
//#endregion
|
|
1402
1403
|
//#region src/components/auto-crud/auto-table-action-bar.d.ts
|
|
1403
1404
|
/** 批量更新字段配置 */
|
|
@@ -1488,7 +1489,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
1488
1489
|
extraActions,
|
|
1489
1490
|
actions,
|
|
1490
1491
|
deleteConfirmation
|
|
1491
|
-
}: AutoTableActionBarProps<TData>):
|
|
1492
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime20.JSX.Element;
|
|
1492
1493
|
//#endregion
|
|
1493
1494
|
//#region src/lib/schema-bridge/types.d.ts
|
|
1494
1495
|
/**
|
|
@@ -1742,7 +1743,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1742
1743
|
onSelectedRowsChange,
|
|
1743
1744
|
getSelectedRows,
|
|
1744
1745
|
exportTableRef
|
|
1745
|
-
}: AutoTableProps<T>):
|
|
1746
|
+
}: AutoTableProps<T>): react_jsx_runtime20.JSX.Element;
|
|
1746
1747
|
//#endregion
|
|
1747
1748
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
1748
1749
|
type AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> = {
|
|
@@ -1785,7 +1786,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1785
1786
|
labelAlign,
|
|
1786
1787
|
labelWidth,
|
|
1787
1788
|
showSubmitButton
|
|
1788
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
1789
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime20.JSX.Element;
|
|
1789
1790
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
1790
1791
|
ref?: React.Ref<AutoFormRef>;
|
|
1791
1792
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -2172,7 +2173,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
2172
2173
|
locale: localeProp,
|
|
2173
2174
|
onCreate,
|
|
2174
2175
|
onExport
|
|
2175
|
-
}: AutoCrudTableProps<TSchema>):
|
|
2176
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime20.JSX.Element;
|
|
2176
2177
|
//#endregion
|
|
2177
2178
|
//#region src/components/auto-crud/auto-table-simple-filters.d.ts
|
|
2178
2179
|
interface AutoTableSimpleFiltersProps<TData> {
|
|
@@ -2188,7 +2189,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
2188
2189
|
filters: externalFilters,
|
|
2189
2190
|
onFiltersChange,
|
|
2190
2191
|
leading
|
|
2191
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
2192
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime20.JSX.Element | null;
|
|
2192
2193
|
//#endregion
|
|
2193
2194
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
2194
2195
|
type ModalVariant = 'dialog' | 'sheet';
|
|
@@ -2237,7 +2238,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
2237
2238
|
labelAlign,
|
|
2238
2239
|
labelWidth,
|
|
2239
2240
|
className
|
|
2240
|
-
}: CrudFormModalProps<T> & CrudFormModalMode<T>):
|
|
2241
|
+
}: CrudFormModalProps<T> & CrudFormModalMode<T>): react_jsx_runtime20.JSX.Element;
|
|
2241
2242
|
//#endregion
|
|
2242
2243
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
2243
2244
|
interface ImportDialogProps {
|
|
@@ -2262,7 +2263,7 @@ declare function ImportDialog({
|
|
|
2262
2263
|
fields,
|
|
2263
2264
|
title,
|
|
2264
2265
|
locale
|
|
2265
|
-
}: ImportDialogProps):
|
|
2266
|
+
}: ImportDialogProps): react_jsx_runtime20.JSX.Element;
|
|
2266
2267
|
//#endregion
|
|
2267
2268
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
2268
2269
|
type ExportMode = 'selected' | 'filtered';
|
|
@@ -2282,7 +2283,7 @@ declare function ExportDialog({
|
|
|
2282
2283
|
selectedCount,
|
|
2283
2284
|
onExport,
|
|
2284
2285
|
canExportFiltered
|
|
2285
|
-
}: ExportDialogProps):
|
|
2286
|
+
}: ExportDialogProps): react_jsx_runtime20.JSX.Element;
|
|
2286
2287
|
//#endregion
|
|
2287
2288
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
2288
2289
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<'div'> {
|
|
@@ -2293,7 +2294,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
2293
2294
|
children,
|
|
2294
2295
|
className,
|
|
2295
2296
|
...props
|
|
2296
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
2297
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime20.JSX.Element;
|
|
2297
2298
|
//#endregion
|
|
2298
2299
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
2299
2300
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -2305,7 +2306,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
2305
2306
|
label,
|
|
2306
2307
|
className,
|
|
2307
2308
|
...props
|
|
2308
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
2309
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime20.JSX.Element;
|
|
2309
2310
|
//#endregion
|
|
2310
2311
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
2311
2312
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -2319,7 +2320,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
2319
2320
|
title,
|
|
2320
2321
|
options,
|
|
2321
2322
|
multiple
|
|
2322
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
2323
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime20.JSX.Element;
|
|
2323
2324
|
//#endregion
|
|
2324
2325
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
2325
2326
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<'div'>, TablePaginationOptions {
|
|
@@ -2336,7 +2337,7 @@ declare function DataTablePagination<TData>({
|
|
|
2336
2337
|
pageJumpLabel,
|
|
2337
2338
|
className,
|
|
2338
2339
|
...props
|
|
2339
|
-
}: DataTablePaginationProps<TData>):
|
|
2340
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime20.JSX.Element;
|
|
2340
2341
|
//#endregion
|
|
2341
2342
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
2342
2343
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<'div'> {
|
|
@@ -2347,7 +2348,7 @@ declare function DataTableToolbar<TData>({
|
|
|
2347
2348
|
children,
|
|
2348
2349
|
className,
|
|
2349
2350
|
...props
|
|
2350
|
-
}: DataTableToolbarProps<TData>):
|
|
2351
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime20.JSX.Element;
|
|
2351
2352
|
//#endregion
|
|
2352
2353
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
2353
2354
|
interface DataTableViewOptionsProps<TData> extends PopoverContentProps {
|
|
@@ -2360,7 +2361,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
2360
2361
|
disabled,
|
|
2361
2362
|
locale,
|
|
2362
2363
|
...props
|
|
2363
|
-
}: DataTableViewOptionsProps<TData>):
|
|
2364
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime20.JSX.Element;
|
|
2364
2365
|
//#endregion
|
|
2365
2366
|
//#region src/lib/crud-actions.d.ts
|
|
2366
2367
|
type CrudActionZone = 'toolbar' | 'row' | 'batch';
|
|
@@ -2802,7 +2803,7 @@ declare function TagFilter({
|
|
|
2802
2803
|
resourceId: resourceIdProp,
|
|
2803
2804
|
field,
|
|
2804
2805
|
...props
|
|
2805
|
-
}: TagFilterProps):
|
|
2806
|
+
}: TagFilterProps): react_jsx_runtime20.JSX.Element;
|
|
2806
2807
|
interface TagAssignmentProps extends TagScope, Pick<RowActionDialogProps, 'open' | 'onOpenChange'> {
|
|
2807
2808
|
title: string;
|
|
2808
2809
|
/** Current record tags, snapshotted when the editor opens. */
|
|
@@ -2813,6 +2814,6 @@ interface TagAssignmentProps extends TagScope, Pick<RowActionDialogProps, 'open'
|
|
|
2813
2814
|
onSaved?: () => unknown | Promise<unknown>;
|
|
2814
2815
|
}
|
|
2815
2816
|
/** Controlled dialog. Callers own the trigger, its appearance and its placement. */
|
|
2816
|
-
declare function TagAssignment(props: TagAssignmentProps):
|
|
2817
|
+
declare function TagAssignment(props: TagAssignmentProps): react_jsx_runtime20.JSX.Element | null;
|
|
2817
2818
|
//#endregion
|
|
2818
2819
|
export { type ActionConfig, type ActionItem, type ActionPosition, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudExportContext, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, AutoCrudProvider, type AutoCrudProviderProps, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, type AutoCrudRowOpenOptions, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, type AutoTableProps, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchSearchConfig, type BatchSearchField, type BatchSearchFilter, type BatchSearchLocale, type BatchSearchState, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableClassNames, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, type DataTableProps, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type DataTableViewOptionsProps, type DateFormatPreset, type DateFormatter, type DateLocaleOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldTableDisplay, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportIssue, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, type PresetView, QueryKeys, type RowActionConfig, type RowActionDialogProps, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, type SavedView, type SavedViewsConfig, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type TableActionBarLocale, type TableBatchSearchConfig, type TableControlsLocale, type TableFilterState, type TablePaginationLocale, type TablePaginationOptions, type TableSearchConfig, type TableSearchProps, TagAssignment, type TagAssignmentProps, TagFilter, type TagFilterProps, type TagFilterValue, type TagInput, type TagOption, type TagScope, type TagService, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, type ViewCapabilities, type ViewInput, type ViewQuery, type ViewScope, type ViewStorage, type ViewStorageCapabilities, type WorkbookSheet, actionPositionSchema, cn, coerceRowValues, compareOrder, components, createActionsColumn, createEditFormSchema, createFormSchema, createLocalViewStorage, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, exportWorkbook, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, matchesPosition, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, positionActions, presetViewSchema, resolveLocale, savedViewSchema, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, tagFilterValueSchema, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, viewCapabilitiesSchema, viewInputSchema, viewQuerySchema, viewScopeSchema, viewStorageCapabilitiesSchema, zhCN };
|
package/dist/index.js
CHANGED
|
@@ -3402,9 +3402,11 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3402
3402
|
const [hasSpace, setHasSpace] = useState(false);
|
|
3403
3403
|
const hideExtras = responsive && !hasSpace;
|
|
3404
3404
|
const hiddenClass = hideExtras ? "absolute invisible pointer-events-none left-0 top-0" : void 0;
|
|
3405
|
-
const pageIndex = table.getState().pagination
|
|
3405
|
+
const { pageIndex, pageSize } = table.getState().pagination;
|
|
3406
3406
|
const pageCount = table.getPageCount();
|
|
3407
|
+
const knownPageCount = pageCount >= 0;
|
|
3407
3408
|
const canJump = Number.isFinite(pageCount) && pageCount > 0;
|
|
3409
|
+
const canGoNext = table.getCanNextPage() && (knownPageCount || table.options.data.length >= pageSize);
|
|
3408
3410
|
const total = table.options.rowCount ?? (table.options.manualPagination ? void 0 : table.getRowCount());
|
|
3409
3411
|
useEffect(() => {
|
|
3410
3412
|
if (!responsive || !container.current || !summary.current || !controls.current || !navigation.current) return;
|
|
@@ -3474,16 +3476,16 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3474
3476
|
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: table.getState().pagination.pageSize })
|
|
3475
3477
|
}), /* @__PURE__ */ jsx(SelectContent, {
|
|
3476
3478
|
side: "top",
|
|
3477
|
-
children: pageSizeOptions.map((pageSize) => /* @__PURE__ */ jsx(SelectItem, {
|
|
3478
|
-
value: `${pageSize}`,
|
|
3479
|
-
children: pageSize
|
|
3480
|
-
}, pageSize))
|
|
3479
|
+
children: pageSizeOptions.map((pageSize$1) => /* @__PURE__ */ jsx(SelectItem, {
|
|
3480
|
+
value: `${pageSize$1}`,
|
|
3481
|
+
children: pageSize$1
|
|
3482
|
+
}, pageSize$1))
|
|
3481
3483
|
})]
|
|
3482
3484
|
})]
|
|
3483
3485
|
}),
|
|
3484
3486
|
/* @__PURE__ */ jsx("div", {
|
|
3485
3487
|
className: "flex items-center justify-center font-medium text-sm",
|
|
3486
|
-
children: locale.page(pageIndex + 1, pageCount)
|
|
3488
|
+
children: knownPageCount ? locale.page(pageIndex + 1, pageCount) : pageIndex + 1
|
|
3487
3489
|
}),
|
|
3488
3490
|
showPageJump && /* @__PURE__ */ jsx("div", {
|
|
3489
3491
|
ref: pageJump,
|
|
@@ -3548,7 +3550,7 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3548
3550
|
size: "icon",
|
|
3549
3551
|
className: "size-8",
|
|
3550
3552
|
onClick: () => table.nextPage(),
|
|
3551
|
-
disabled: !
|
|
3553
|
+
disabled: !canGoNext,
|
|
3552
3554
|
children: /* @__PURE__ */ jsx(ChevronRight, {})
|
|
3553
3555
|
}),
|
|
3554
3556
|
/* @__PURE__ */ jsx(Button, {
|
|
@@ -3557,7 +3559,7 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
3557
3559
|
size: "icon",
|
|
3558
3560
|
className: cn("size-8", alwaysShowFirstLast ? "flex" : "hidden lg:flex", hiddenClass),
|
|
3559
3561
|
onClick: () => table.setPageIndex(table.getPageCount() - 1),
|
|
3560
|
-
disabled: !
|
|
3562
|
+
disabled: !canJump || !canGoNext,
|
|
3561
3563
|
children: /* @__PURE__ */ jsx(ChevronsRight, {})
|
|
3562
3564
|
})
|
|
3563
3565
|
]
|
|
@@ -7894,7 +7896,7 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
|
|
|
7894
7896
|
getExpandedRowModel: enableExpansion ? expandedRowModel : void 0,
|
|
7895
7897
|
autoResetExpanded: defaultExpanded ? false : void 0,
|
|
7896
7898
|
pageCount,
|
|
7897
|
-
|
|
7899
|
+
rowCount: total,
|
|
7898
7900
|
enableAdvancedFilter,
|
|
7899
7901
|
initialState: stableInitialState,
|
|
7900
7902
|
shallow: false,
|
|
@@ -10590,6 +10592,39 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
10590
10592
|
const canImport = can.import && !!resource.handlers.import;
|
|
10591
10593
|
const canExport = can.export;
|
|
10592
10594
|
const [importOpen, setImportOpen] = React.useState(false);
|
|
10595
|
+
const resourceIdKey = resource.idKey ?? "id";
|
|
10596
|
+
const modal = resource.modal;
|
|
10597
|
+
const deleteTarget = modal.selected && (readRowId(modal.selected, resourceIdKey) ?? modal.selected);
|
|
10598
|
+
const deleteRequest = React.useRef(null);
|
|
10599
|
+
const [deletePhase, setDeletePhase] = React.useState("idle");
|
|
10600
|
+
const deleting = deletePhase !== "idle" || resource.mutations.isDeleting;
|
|
10601
|
+
React.useEffect(() => {
|
|
10602
|
+
if (deletePhase !== "settled" || !deleteRequest.current) return;
|
|
10603
|
+
const submitted = deleteRequest.current;
|
|
10604
|
+
deleteRequest.current = null;
|
|
10605
|
+
setDeletePhase("idle");
|
|
10606
|
+
if (modal.deleteOpen && submitted.target === deleteTarget && submitted.modal.viewOpen === modal.viewOpen && submitted.modal.editOpen === modal.editOpen && submitted.modal.createOpen === modal.createOpen) resource.handlers.closeModals();
|
|
10607
|
+
}, [
|
|
10608
|
+
deletePhase,
|
|
10609
|
+
deleteTarget,
|
|
10610
|
+
modal,
|
|
10611
|
+
resource.handlers
|
|
10612
|
+
]);
|
|
10613
|
+
const confirmDelete = async () => {
|
|
10614
|
+
if (deleteRequest.current || deleting) return;
|
|
10615
|
+
deleteRequest.current = {
|
|
10616
|
+
target: deleteTarget,
|
|
10617
|
+
modal
|
|
10618
|
+
};
|
|
10619
|
+
setDeletePhase("pending");
|
|
10620
|
+
try {
|
|
10621
|
+
await resource.handlers.confirmDelete();
|
|
10622
|
+
} catch (error) {
|
|
10623
|
+
toast.error(error instanceof Error ? error.message : String(error));
|
|
10624
|
+
} finally {
|
|
10625
|
+
setDeletePhase("settled");
|
|
10626
|
+
}
|
|
10627
|
+
};
|
|
10593
10628
|
const [selectedRows, setSelectedRows] = React.useState([]);
|
|
10594
10629
|
const [exporting, setExporting] = React.useState(false);
|
|
10595
10630
|
const exportBusyRef = React.useRef(false);
|
|
@@ -10610,7 +10645,6 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
10610
10645
|
]);
|
|
10611
10646
|
const excludedColumns = React.useMemo(() => hiddenColumns.filter((key) => !filterOnly.includes(key)), [hiddenColumns, filterOnly]);
|
|
10612
10647
|
const dynamicResolveOptions = useDynamicResolveOptions(resolvedFields, resource.tableData.data, hiddenColumns);
|
|
10613
|
-
const resourceIdKey = resource.idKey ?? "id";
|
|
10614
10648
|
const tagFields = React.useMemo(() => Object.entries(resolvedFields).filter(([field, config]) => config.tags && !config.hidden && !denyFields?.includes(field)).map(([field, config]) => {
|
|
10615
10649
|
const label = config.label ?? humanize(field);
|
|
10616
10650
|
return {
|
|
@@ -11171,12 +11205,26 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
11171
11205
|
}),
|
|
11172
11206
|
/* @__PURE__ */ jsx(AlertDialog$1, {
|
|
11173
11207
|
open: resource.modal.deleteOpen,
|
|
11174
|
-
onOpenChange: (open) =>
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11208
|
+
onOpenChange: (open) => {
|
|
11209
|
+
if (!open && !deleteRequest.current && !deleting) resource.handlers.closeModals();
|
|
11210
|
+
},
|
|
11211
|
+
children: /* @__PURE__ */ jsxs(AlertDialogContent$1, {
|
|
11212
|
+
"aria-busy": deleting,
|
|
11213
|
+
children: [/* @__PURE__ */ jsxs(AlertDialogHeader$1, { children: [/* @__PURE__ */ jsx(AlertDialogTitle$1, { children: locale.deleteModal.title }), /* @__PURE__ */ jsx(AlertDialogDescription$1, { children: locale.deleteModal.description })] }), /* @__PURE__ */ jsxs(AlertDialogFooter$1, { children: [/* @__PURE__ */ jsx(AlertDialogCancel$1, {
|
|
11214
|
+
disabled: deleting,
|
|
11215
|
+
children: locale.deleteModal.cancel
|
|
11216
|
+
}), /* @__PURE__ */ jsxs(AlertDialogAction$1, {
|
|
11217
|
+
onClick: (event) => {
|
|
11218
|
+
event.preventDefault();
|
|
11219
|
+
confirmDelete();
|
|
11220
|
+
},
|
|
11221
|
+
disabled: deleting,
|
|
11222
|
+
children: [deleting && /* @__PURE__ */ jsx(Loader2, {
|
|
11223
|
+
"aria-hidden": "true",
|
|
11224
|
+
className: "h-4 w-4 animate-spin"
|
|
11225
|
+
}), deleting ? locale.deleteModal.confirming : locale.deleteModal.confirm]
|
|
11226
|
+
})] })]
|
|
11227
|
+
})
|
|
11180
11228
|
}),
|
|
11181
11229
|
canImport && resource.handlers.import && /* @__PURE__ */ jsx(ImportDialog, {
|
|
11182
11230
|
open: importOpen,
|
|
@@ -11915,18 +11963,21 @@ function modalReducer(state, action$1) {
|
|
|
11915
11963
|
case "OPEN_CREATE": return {
|
|
11916
11964
|
...state,
|
|
11917
11965
|
createOpen: true,
|
|
11966
|
+
deleteOpen: false,
|
|
11918
11967
|
selected: null,
|
|
11919
11968
|
copySource: null
|
|
11920
11969
|
};
|
|
11921
11970
|
case "OPEN_CREATE_WITH_COPY": return {
|
|
11922
11971
|
...state,
|
|
11923
11972
|
createOpen: true,
|
|
11973
|
+
deleteOpen: false,
|
|
11924
11974
|
selected: null,
|
|
11925
11975
|
copySource: action$1.payload
|
|
11926
11976
|
};
|
|
11927
11977
|
case "OPEN_EDIT": return {
|
|
11928
11978
|
...state,
|
|
11929
11979
|
editOpen: true,
|
|
11980
|
+
deleteOpen: false,
|
|
11930
11981
|
selected: action$1.payload
|
|
11931
11982
|
};
|
|
11932
11983
|
case "OPEN_DELETE": return {
|
|
@@ -11934,9 +11985,19 @@ function modalReducer(state, action$1) {
|
|
|
11934
11985
|
deleteOpen: true,
|
|
11935
11986
|
selected: action$1.payload
|
|
11936
11987
|
};
|
|
11988
|
+
case "DELETE_SUCCEEDED": {
|
|
11989
|
+
if (!state.deleteOpen || state.selected !== action$1.payload) return state;
|
|
11990
|
+
const otherModalOpen = state.createOpen || state.editOpen || state.viewOpen;
|
|
11991
|
+
return {
|
|
11992
|
+
...state,
|
|
11993
|
+
deleteOpen: false,
|
|
11994
|
+
selected: otherModalOpen ? state.selected : null
|
|
11995
|
+
};
|
|
11996
|
+
}
|
|
11937
11997
|
case "OPEN_VIEW": return {
|
|
11938
11998
|
...state,
|
|
11939
11999
|
viewOpen: true,
|
|
12000
|
+
deleteOpen: false,
|
|
11940
12001
|
selected: action$1.payload
|
|
11941
12002
|
};
|
|
11942
12003
|
case "CLOSE_ALL": return {
|
|
@@ -12177,44 +12238,38 @@ function useAutoCrudResource({ router, queryKeys, schema, query: queryTransform,
|
|
|
12177
12238
|
const confirmDelete = useCallback(async () => {
|
|
12178
12239
|
const currentHooks = hooksRef.current;
|
|
12179
12240
|
if (!modal.selected) return;
|
|
12241
|
+
let data = modal.selected;
|
|
12180
12242
|
try {
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
}
|
|
12190
|
-
|
|
12191
|
-
}
|
|
12243
|
+
const handled = currentHooks?.beforeDelete ? await currentHooks.beforeDelete(modal.selected) : void 0;
|
|
12244
|
+
if (handled === false) return;
|
|
12245
|
+
if (handled !== true) {
|
|
12246
|
+
const id = modal.selected[idKey];
|
|
12247
|
+
data = typeof deleteMutation.mutateAsync === "function" ? await deleteMutation.mutateAsync(id) : await new Promise((resolve, reject) => {
|
|
12248
|
+
deleteMutation.mutate(id, {
|
|
12249
|
+
onSuccess: resolve,
|
|
12250
|
+
onError: reject
|
|
12251
|
+
});
|
|
12252
|
+
});
|
|
12192
12253
|
}
|
|
12193
|
-
const id = modal.selected[idKey];
|
|
12194
|
-
deleteMutation.mutate(id, {
|
|
12195
|
-
onSuccess: (data) => {
|
|
12196
|
-
toast$1.success("删除成功");
|
|
12197
|
-
closeModals();
|
|
12198
|
-
listQuery.refetch();
|
|
12199
|
-
currentHooks?.onSuccess?.("delete", data);
|
|
12200
|
-
},
|
|
12201
|
-
onError: (error) => {
|
|
12202
|
-
const err = error;
|
|
12203
|
-
toast$1.error(`删除失败: ${err.message}`);
|
|
12204
|
-
currentHooks?.onError?.("delete", err);
|
|
12205
|
-
}
|
|
12206
|
-
});
|
|
12207
12254
|
} catch (error) {
|
|
12208
12255
|
const err = error;
|
|
12209
12256
|
toast$1.error(`删除失败: ${err.message}`);
|
|
12210
12257
|
currentHooks?.onError?.("delete", err);
|
|
12258
|
+
return;
|
|
12211
12259
|
}
|
|
12260
|
+
toast$1.success("删除成功");
|
|
12261
|
+
dispatch({
|
|
12262
|
+
type: "DELETE_SUCCEEDED",
|
|
12263
|
+
payload: modal.selected
|
|
12264
|
+
});
|
|
12265
|
+
listQuery.refetch();
|
|
12266
|
+
currentHooks?.onSuccess?.("delete", data);
|
|
12212
12267
|
}, [
|
|
12213
12268
|
modal.selected,
|
|
12214
12269
|
idKey,
|
|
12215
12270
|
deleteMutation,
|
|
12216
|
-
|
|
12217
|
-
|
|
12271
|
+
listQuery,
|
|
12272
|
+
toast$1
|
|
12218
12273
|
]);
|
|
12219
12274
|
const deleteMany = useCallback((rows) => {
|
|
12220
12275
|
const currentHooks = hooksRef.current;
|
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.23.1",
|
|
5
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
6
6
|
"author": "wordrhyme",
|
|
7
7
|
"license": "MIT",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"tailwind-merge": "^3.5.0",
|
|
73
73
|
"vaul": "^1.1.2",
|
|
74
74
|
"@wordrhyme/formily-shadcn": "2.1.4",
|
|
75
|
-
"@wordrhyme/shadcn": "2.
|
|
76
|
-
"@wordrhyme/shadcn
|
|
75
|
+
"@wordrhyme/shadcn-ui": "2.1.4",
|
|
76
|
+
"@wordrhyme/shadcn": "2.0.3"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@storybook/react": "^8.6.18",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"vitest": "^3.2.4",
|
|
97
97
|
"@internal/eslint-config": "0.3.0",
|
|
98
98
|
"@internal/prettier-config": "0.0.1",
|
|
99
|
-
"@internal/tsconfig": "0.1.0",
|
|
100
99
|
"@internal/tsdown-config": "0.1.0",
|
|
100
|
+
"@internal/tsconfig": "0.1.0",
|
|
101
101
|
"@internal/vitest-config": "0.1.0"
|
|
102
102
|
},
|
|
103
103
|
"prettier": "@internal/prettier-config",
|