@wordrhyme/auto-crud 1.1.1 → 1.1.2
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 +3 -3
- package/dist/index.d.cts +21 -21
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -4318,12 +4318,12 @@ function AutoTableActionBar({ table, onDeleteSelected, onUpdateSelected, batchUp
|
|
|
4318
4318
|
if (action.component) return renderComponent(action.component);
|
|
4319
4319
|
if (action.type === "batchUpdate") return renderBatchUpdate(action.type);
|
|
4320
4320
|
if (action.type === "export") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ActionBarItem, {
|
|
4321
|
-
onClick: () => action.onClick ? action.onClick(selectedRows, actionContext) : onExport(),
|
|
4321
|
+
onClick: (event) => action.onClick ? action.onClick(selectedRows, actionContext, event) : onExport(),
|
|
4322
4322
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Download, {}), action.label ?? "Export"]
|
|
4323
4323
|
}, "export");
|
|
4324
4324
|
if (action.type === "delete") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ActionBarItem, {
|
|
4325
4325
|
variant: "destructive",
|
|
4326
|
-
onClick: () => action.onClick ? action.onClick(selectedRows, actionContext) : onDelete(),
|
|
4326
|
+
onClick: (event) => action.onClick ? action.onClick(selectedRows, actionContext, event) : onDelete(),
|
|
4327
4327
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Trash2, {}), action.label ?? "Delete"]
|
|
4328
4328
|
}, "delete");
|
|
4329
4329
|
return null;
|
|
@@ -4345,7 +4345,7 @@ function AutoTableActionBar({ table, onDeleteSelected, onUpdateSelected, batchUp
|
|
|
4345
4345
|
if (!action.label || !action.onClick) return null;
|
|
4346
4346
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionBarItem, {
|
|
4347
4347
|
variant: action.variant === "destructive" ? "destructive" : "secondary",
|
|
4348
|
-
onClick: () => action.onClick?.(selectedRows, actionContext),
|
|
4348
|
+
onClick: (event) => action.onClick?.(selectedRows, actionContext, event),
|
|
4349
4349
|
children: action.label
|
|
4350
4350
|
}, `custom-${index}`);
|
|
4351
4351
|
}, [
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import * as _tanstack_react_table0 from "@tanstack/react-table";
|
|
4
4
|
import { Column, ColumnDef, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
|
|
@@ -304,7 +304,7 @@ type BatchBuiltinActionType = 'batchUpdate' | 'export' | 'delete';
|
|
|
304
304
|
type BatchBuiltinActionItem<TData> = {
|
|
305
305
|
type: BatchBuiltinActionType;
|
|
306
306
|
/** 替代默认行为 */
|
|
307
|
-
onClick?: (rows: TData[], context: BatchActionContext<TData>) => void;
|
|
307
|
+
onClick?: (rows: TData[], context: BatchActionContext<TData>, event: React$1.MouseEvent<HTMLButtonElement>) => void;
|
|
308
308
|
/** 替代默认标签,仅对 export/delete 生效 */
|
|
309
309
|
label?: string;
|
|
310
310
|
/** 替代整个内置操作的渲染 */
|
|
@@ -315,7 +315,7 @@ type BatchCustomActionItem<TData> = {
|
|
|
315
315
|
/** 操作文本。传 component 时可省略 */
|
|
316
316
|
label?: string;
|
|
317
317
|
/** 自定义点击行为。传 component 时可省略 */
|
|
318
|
-
onClick?: (rows: TData[], context: BatchActionContext<TData>) => void;
|
|
318
|
+
onClick?: (rows: TData[], context: BatchActionContext<TData>, event: React$1.MouseEvent<HTMLButtonElement>) => void;
|
|
319
319
|
/** 渲染自定义内容 */
|
|
320
320
|
component?: React$1.ReactNode | ((context: BatchActionContext<TData>) => React$1.ReactNode);
|
|
321
321
|
/** 仅在无内置项时生效:插入到首部还是尾部(默认 end) */
|
|
@@ -352,7 +352,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
352
352
|
enableDelete,
|
|
353
353
|
extraActions,
|
|
354
354
|
actions
|
|
355
|
-
}: AutoTableActionBarProps<TData>):
|
|
355
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime6.JSX.Element;
|
|
356
356
|
//#endregion
|
|
357
357
|
//#region src/lib/schema-bridge/types.d.ts
|
|
358
358
|
/**
|
|
@@ -514,7 +514,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
514
514
|
showDefaultExport,
|
|
515
515
|
onSelectedCountChange,
|
|
516
516
|
getSelectedRows
|
|
517
|
-
}: AutoTableProps<T>):
|
|
517
|
+
}: AutoTableProps<T>): react_jsx_runtime6.JSX.Element;
|
|
518
518
|
//#endregion
|
|
519
519
|
//#region src/i18n/locale.d.ts
|
|
520
520
|
/**
|
|
@@ -847,7 +847,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
847
847
|
toolbarActions,
|
|
848
848
|
locale: localeProp,
|
|
849
849
|
onCreate
|
|
850
|
-
}: AutoCrudTableProps<TSchema>):
|
|
850
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime6.JSX.Element;
|
|
851
851
|
//#endregion
|
|
852
852
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
853
853
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -879,7 +879,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
879
879
|
labelAlign,
|
|
880
880
|
labelWidth,
|
|
881
881
|
showSubmitButton
|
|
882
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
882
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime6.JSX.Element;
|
|
883
883
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
884
884
|
ref?: React.Ref<AutoFormRef>;
|
|
885
885
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1093,12 +1093,12 @@ declare const filterItemSchema: z.ZodObject<{
|
|
|
1093
1093
|
variant: z.ZodEnum<{
|
|
1094
1094
|
number: "number";
|
|
1095
1095
|
boolean: "boolean";
|
|
1096
|
-
text: "text";
|
|
1097
|
-
range: "range";
|
|
1098
1096
|
date: "date";
|
|
1099
|
-
|
|
1097
|
+
text: "text";
|
|
1100
1098
|
select: "select";
|
|
1101
1099
|
multiSelect: "multiSelect";
|
|
1100
|
+
dateRange: "dateRange";
|
|
1101
|
+
range: "range";
|
|
1102
1102
|
}>;
|
|
1103
1103
|
operator: z.ZodEnum<{
|
|
1104
1104
|
iLike: "iLike";
|
|
@@ -1177,7 +1177,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1177
1177
|
shallow,
|
|
1178
1178
|
filters: externalFilters,
|
|
1179
1179
|
onFiltersChange
|
|
1180
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1180
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime6.JSX.Element | null;
|
|
1181
1181
|
//#endregion
|
|
1182
1182
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1183
1183
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -1219,7 +1219,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1219
1219
|
labelAlign,
|
|
1220
1220
|
labelWidth,
|
|
1221
1221
|
className
|
|
1222
|
-
}: CrudFormModalProps<T>):
|
|
1222
|
+
}: CrudFormModalProps<T>): react_jsx_runtime6.JSX.Element;
|
|
1223
1223
|
//#endregion
|
|
1224
1224
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1225
1225
|
interface ImportDialogProps {
|
|
@@ -1241,7 +1241,7 @@ declare function ImportDialog({
|
|
|
1241
1241
|
columns,
|
|
1242
1242
|
title,
|
|
1243
1243
|
locale
|
|
1244
|
-
}: ImportDialogProps):
|
|
1244
|
+
}: ImportDialogProps): react_jsx_runtime6.JSX.Element;
|
|
1245
1245
|
//#endregion
|
|
1246
1246
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1247
1247
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1261,7 +1261,7 @@ declare function ExportDialog({
|
|
|
1261
1261
|
selectedCount,
|
|
1262
1262
|
onExport,
|
|
1263
1263
|
canExportFiltered
|
|
1264
|
-
}: ExportDialogProps):
|
|
1264
|
+
}: ExportDialogProps): react_jsx_runtime6.JSX.Element;
|
|
1265
1265
|
//#endregion
|
|
1266
1266
|
//#region src/components/data-table/data-table.d.ts
|
|
1267
1267
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1274,7 +1274,7 @@ declare function DataTable<TData>({
|
|
|
1274
1274
|
children,
|
|
1275
1275
|
className,
|
|
1276
1276
|
...props
|
|
1277
|
-
}: DataTableProps<TData>):
|
|
1277
|
+
}: DataTableProps<TData>): react_jsx_runtime6.JSX.Element;
|
|
1278
1278
|
//#endregion
|
|
1279
1279
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1280
1280
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1285,7 +1285,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1285
1285
|
children,
|
|
1286
1286
|
className,
|
|
1287
1287
|
...props
|
|
1288
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1288
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime6.JSX.Element;
|
|
1289
1289
|
//#endregion
|
|
1290
1290
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1291
1291
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1297,7 +1297,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1297
1297
|
label,
|
|
1298
1298
|
className,
|
|
1299
1299
|
...props
|
|
1300
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1300
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime6.JSX.Element;
|
|
1301
1301
|
//#endregion
|
|
1302
1302
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1303
1303
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1311,7 +1311,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1311
1311
|
title,
|
|
1312
1312
|
options,
|
|
1313
1313
|
multiple
|
|
1314
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1314
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime6.JSX.Element;
|
|
1315
1315
|
//#endregion
|
|
1316
1316
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1317
1317
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1323,7 +1323,7 @@ declare function DataTablePagination<TData>({
|
|
|
1323
1323
|
pageSizeOptions,
|
|
1324
1324
|
className,
|
|
1325
1325
|
...props
|
|
1326
|
-
}: DataTablePaginationProps<TData>):
|
|
1326
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime6.JSX.Element;
|
|
1327
1327
|
//#endregion
|
|
1328
1328
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1329
1329
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1334,7 +1334,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1334
1334
|
children,
|
|
1335
1335
|
className,
|
|
1336
1336
|
...props
|
|
1337
|
-
}: DataTableToolbarProps<TData>):
|
|
1337
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime6.JSX.Element;
|
|
1338
1338
|
//#endregion
|
|
1339
1339
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1340
1340
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1345,7 +1345,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1345
1345
|
table,
|
|
1346
1346
|
disabled,
|
|
1347
1347
|
...props
|
|
1348
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1348
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime6.JSX.Element;
|
|
1349
1349
|
//#endregion
|
|
1350
1350
|
//#region src/hooks/use-data-table.d.ts
|
|
1351
1351
|
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, "state" | "pageCount" | "getCoreRowModel" | "manualFiltering" | "manualPagination" | "manualSorting">, Required<Pick<TableOptions<TData>, "pageCount">> {
|
package/dist/index.d.ts
CHANGED
|
@@ -304,7 +304,7 @@ type BatchBuiltinActionType = 'batchUpdate' | 'export' | 'delete';
|
|
|
304
304
|
type BatchBuiltinActionItem<TData> = {
|
|
305
305
|
type: BatchBuiltinActionType;
|
|
306
306
|
/** 替代默认行为 */
|
|
307
|
-
onClick?: (rows: TData[], context: BatchActionContext<TData>) => void;
|
|
307
|
+
onClick?: (rows: TData[], context: BatchActionContext<TData>, event: React$1.MouseEvent<HTMLButtonElement>) => void;
|
|
308
308
|
/** 替代默认标签,仅对 export/delete 生效 */
|
|
309
309
|
label?: string;
|
|
310
310
|
/** 替代整个内置操作的渲染 */
|
|
@@ -315,7 +315,7 @@ type BatchCustomActionItem<TData> = {
|
|
|
315
315
|
/** 操作文本。传 component 时可省略 */
|
|
316
316
|
label?: string;
|
|
317
317
|
/** 自定义点击行为。传 component 时可省略 */
|
|
318
|
-
onClick?: (rows: TData[], context: BatchActionContext<TData>) => void;
|
|
318
|
+
onClick?: (rows: TData[], context: BatchActionContext<TData>, event: React$1.MouseEvent<HTMLButtonElement>) => void;
|
|
319
319
|
/** 渲染自定义内容 */
|
|
320
320
|
component?: React$1.ReactNode | ((context: BatchActionContext<TData>) => React$1.ReactNode);
|
|
321
321
|
/** 仅在无内置项时生效:插入到首部还是尾部(默认 end) */
|
|
@@ -1093,12 +1093,12 @@ declare const filterItemSchema: z.ZodObject<{
|
|
|
1093
1093
|
variant: z.ZodEnum<{
|
|
1094
1094
|
number: "number";
|
|
1095
1095
|
boolean: "boolean";
|
|
1096
|
-
text: "text";
|
|
1097
|
-
range: "range";
|
|
1098
1096
|
date: "date";
|
|
1099
|
-
|
|
1097
|
+
text: "text";
|
|
1100
1098
|
select: "select";
|
|
1101
1099
|
multiSelect: "multiSelect";
|
|
1100
|
+
dateRange: "dateRange";
|
|
1101
|
+
range: "range";
|
|
1102
1102
|
}>;
|
|
1103
1103
|
operator: z.ZodEnum<{
|
|
1104
1104
|
iLike: "iLike";
|
package/dist/index.js
CHANGED
|
@@ -4276,12 +4276,12 @@ function AutoTableActionBar({ table, onDeleteSelected, onUpdateSelected, batchUp
|
|
|
4276
4276
|
if (action.component) return renderComponent(action.component);
|
|
4277
4277
|
if (action.type === "batchUpdate") return renderBatchUpdate(action.type);
|
|
4278
4278
|
if (action.type === "export") return /* @__PURE__ */ jsxs(ActionBarItem, {
|
|
4279
|
-
onClick: () => action.onClick ? action.onClick(selectedRows, actionContext) : onExport(),
|
|
4279
|
+
onClick: (event) => action.onClick ? action.onClick(selectedRows, actionContext, event) : onExport(),
|
|
4280
4280
|
children: [/* @__PURE__ */ jsx(Download, {}), action.label ?? "Export"]
|
|
4281
4281
|
}, "export");
|
|
4282
4282
|
if (action.type === "delete") return /* @__PURE__ */ jsxs(ActionBarItem, {
|
|
4283
4283
|
variant: "destructive",
|
|
4284
|
-
onClick: () => action.onClick ? action.onClick(selectedRows, actionContext) : onDelete(),
|
|
4284
|
+
onClick: (event) => action.onClick ? action.onClick(selectedRows, actionContext, event) : onDelete(),
|
|
4285
4285
|
children: [/* @__PURE__ */ jsx(Trash2, {}), action.label ?? "Delete"]
|
|
4286
4286
|
}, "delete");
|
|
4287
4287
|
return null;
|
|
@@ -4303,7 +4303,7 @@ function AutoTableActionBar({ table, onDeleteSelected, onUpdateSelected, batchUp
|
|
|
4303
4303
|
if (!action.label || !action.onClick) return null;
|
|
4304
4304
|
return /* @__PURE__ */ jsx(ActionBarItem, {
|
|
4305
4305
|
variant: action.variant === "destructive" ? "destructive" : "secondary",
|
|
4306
|
-
onClick: () => action.onClick?.(selectedRows, actionContext),
|
|
4306
|
+
onClick: (event) => action.onClick?.(selectedRows, actionContext, event),
|
|
4307
4307
|
children: action.label
|
|
4308
4308
|
}, `custom-${index}`);
|
|
4309
4309
|
}, [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordrhyme/auto-crud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
6
6
|
"author": "wordrhyme",
|
|
7
7
|
"license": "MIT",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"nanoid": "^5.1.6",
|
|
66
66
|
"tailwind-merge": "^3.5.0",
|
|
67
67
|
"vaul": "^1.1.2",
|
|
68
|
-
"@pixpilot/shadcn": "1.2.7",
|
|
69
68
|
"@pixpilot/formily-shadcn": "1.11.20",
|
|
69
|
+
"@pixpilot/shadcn": "1.2.7",
|
|
70
70
|
"@pixpilot/shadcn-ui": "1.21.1"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"@internal/prettier-config": "0.0.1",
|
|
86
86
|
"@internal/tsconfig": "0.1.0",
|
|
87
87
|
"@internal/eslint-config": "0.3.0",
|
|
88
|
-
"@internal/
|
|
89
|
-
"@internal/
|
|
88
|
+
"@internal/vitest-config": "0.1.0",
|
|
89
|
+
"@internal/tsdown-config": "0.1.0"
|
|
90
90
|
},
|
|
91
91
|
"prettier": "@internal/prettier-config",
|
|
92
92
|
"scripts": {
|