@wordrhyme/auto-crud 1.0.4 → 1.0.6
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 +13 -11
- package/dist/index.d.cts +16 -3
- package/dist/index.d.ts +32 -19
- package/dist/index.js +13 -11
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -4726,14 +4726,14 @@ function FormModal({ open, onOpenChange, title, description, children, variant =
|
|
|
4726
4726
|
onOpenChange,
|
|
4727
4727
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.SheetContent, {
|
|
4728
4728
|
side,
|
|
4729
|
-
className:
|
|
4729
|
+
className: cn("sm:max-w-lg flex flex-col p-0", className),
|
|
4730
4730
|
children: [
|
|
4731
4731
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.SheetHeader, {
|
|
4732
4732
|
className: "flex-shrink-0 px-6 pt-6",
|
|
4733
4733
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.SheetTitle, { children: title }), description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.SheetDescription, { children: description })]
|
|
4734
4734
|
}),
|
|
4735
4735
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4736
|
-
className: "flex-1 overflow-auto",
|
|
4736
|
+
className: "flex-1 overflow-y-auto min-h-0",
|
|
4737
4737
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4738
4738
|
className: "px-6 py-4",
|
|
4739
4739
|
children
|
|
@@ -4750,16 +4750,16 @@ function FormModal({ open, onOpenChange, title, description, children, variant =
|
|
|
4750
4750
|
open,
|
|
4751
4751
|
onOpenChange,
|
|
4752
4752
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.DialogContent, {
|
|
4753
|
-
className:
|
|
4753
|
+
className: cn("max-w-2xl sm:max-w-2xl flex flex-col max-h-[85vh] overflow-hidden p-0", className),
|
|
4754
4754
|
children: [
|
|
4755
4755
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.DialogHeader, {
|
|
4756
4756
|
className: "flex-shrink-0 px-6 pt-6",
|
|
4757
4757
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.DialogTitle, { children: title }), description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.DialogDescription, { children: description })]
|
|
4758
4758
|
}),
|
|
4759
4759
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4760
|
-
className: "flex-1 overflow-auto",
|
|
4760
|
+
className: "flex-1 overflow-y-auto min-h-0",
|
|
4761
4761
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4762
|
-
className: "px-6 py-4",
|
|
4762
|
+
className: "px-6 py-4 text-sm",
|
|
4763
4763
|
children
|
|
4764
4764
|
})
|
|
4765
4765
|
}),
|
|
@@ -5374,7 +5374,7 @@ function resolveLocale(localeProp) {
|
|
|
5374
5374
|
|
|
5375
5375
|
//#endregion
|
|
5376
5376
|
//#region src/components/auto-crud/crud-form-modal.tsx
|
|
5377
|
-
function CrudFormModal({ open, onOpenChange, mode, schema, initialValues, onSubmit, loading = false, variant = "dialog", overrides, title, locale = zhCN.formModal, gridColumns, labelAlign, labelWidth }) {
|
|
5377
|
+
function CrudFormModal({ open, onOpenChange, mode, schema, initialValues, onSubmit, loading = false, variant = "dialog", overrides, title, locale = zhCN.formModal, gridColumns, labelAlign, labelWidth, className }) {
|
|
5378
5378
|
const defaultTitle = mode === "create" ? locale.createTitle : locale.editTitle;
|
|
5379
5379
|
const formRef = (0, react.useRef)(null);
|
|
5380
5380
|
const handleSubmit = async () => {
|
|
@@ -5385,6 +5385,7 @@ function CrudFormModal({ open, onOpenChange, mode, schema, initialValues, onSubm
|
|
|
5385
5385
|
onOpenChange,
|
|
5386
5386
|
title: title ?? defaultTitle,
|
|
5387
5387
|
variant,
|
|
5388
|
+
className,
|
|
5388
5389
|
footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5389
5390
|
className: "flex justify-end gap-2",
|
|
5390
5391
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Button, {
|
|
@@ -5979,7 +5980,7 @@ function resolveActions(items, defaults, rowActionsLocale) {
|
|
|
5979
5980
|
*
|
|
5980
5981
|
* 高级 CRUD 表格组件,封装了完整的增删改查流程
|
|
5981
5982
|
*/
|
|
5982
|
-
function AutoCrudTable({ title, description, schema, resource, fields, table: tableConfig, form: formConfig, slots, permissions, actions: actionItems, locale: localeProp }) {
|
|
5983
|
+
function AutoCrudTable({ title, description, schema, resource, fields, table: tableConfig, form: formConfig, slots, permissions, actions: actionItems, locale: localeProp, onCreate }) {
|
|
5983
5984
|
const locale = resolveLocale(localeProp);
|
|
5984
5985
|
const can = {
|
|
5985
5986
|
create: permissions?.can?.create ?? true,
|
|
@@ -6082,10 +6083,10 @@ function AutoCrudTable({ title, description, schema, resource, fields, table: ta
|
|
|
6082
6083
|
disabled: exporting || selectedCount === 0 && !resource.handlers.export,
|
|
6083
6084
|
children: [exporting ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Upload, { className: "mr-2 h-4 w-4" }), selectedCount > 0 ? locale.toolbar.exportSelected(selectedCount) : locale.toolbar.export]
|
|
6084
6085
|
}),
|
|
6085
|
-
can.create && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Button, {
|
|
6086
|
-
onClick: resource.handlers.openCreate,
|
|
6086
|
+
can.create && (slots?.createButton ? slots.createButton : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Button, {
|
|
6087
|
+
onClick: onCreate ?? resource.handlers.openCreate,
|
|
6087
6088
|
children: locale.toolbar.create
|
|
6088
|
-
})
|
|
6089
|
+
}))
|
|
6089
6090
|
]
|
|
6090
6091
|
})]
|
|
6091
6092
|
}),
|
|
@@ -6124,7 +6125,8 @@ function AutoCrudTable({ title, description, schema, resource, fields, table: ta
|
|
|
6124
6125
|
variant: resource.modal.variant,
|
|
6125
6126
|
overrides: formOverrides,
|
|
6126
6127
|
locale: locale.formModal,
|
|
6127
|
-
gridColumns: formConfig?.columns
|
|
6128
|
+
gridColumns: formConfig?.columns,
|
|
6129
|
+
className: formConfig?.className
|
|
6128
6130
|
}),
|
|
6129
6131
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewModal, {
|
|
6130
6132
|
open: resource.modal.viewOpen,
|
package/dist/index.d.cts
CHANGED
|
@@ -701,10 +701,12 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
701
701
|
};
|
|
702
702
|
/** 表单配置 */
|
|
703
703
|
form?: {
|
|
704
|
-
/**
|
|
704
|
+
/** 表单覆盖配置(兼容旧 API,优先级低于 fieldOverrides) */
|
|
705
705
|
overrides?: Record<string, any>;
|
|
706
706
|
/** 表单列数 */
|
|
707
707
|
columns?: number;
|
|
708
|
+
/** 弹窗自定义容器类名(支持控制大小、最大高度等) */
|
|
709
|
+
className?: string;
|
|
708
710
|
};
|
|
709
711
|
/** 扩展点 */
|
|
710
712
|
slots?: {
|
|
@@ -712,6 +714,8 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
712
714
|
toolbarStart?: React$1.ReactNode;
|
|
713
715
|
/** 工具栏右侧插槽 */
|
|
714
716
|
toolbarEnd?: React$1.ReactNode;
|
|
717
|
+
/** 覆盖内置的新建按钮组件 */
|
|
718
|
+
createButton?: React$1.ReactNode;
|
|
715
719
|
};
|
|
716
720
|
/** 行操作配置,见 {@link ActionItem} */
|
|
717
721
|
actions?: ActionItem<z.output<TSchema>>[];
|
|
@@ -748,6 +752,11 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
748
752
|
* ```
|
|
749
753
|
*/
|
|
750
754
|
locale?: LocaleProp;
|
|
755
|
+
/**
|
|
756
|
+
* 自定义新建按钮点击事件
|
|
757
|
+
* 如果提供,将覆盖默认的打开新建弹窗行为
|
|
758
|
+
*/
|
|
759
|
+
onCreate?: () => void;
|
|
751
760
|
}
|
|
752
761
|
/**
|
|
753
762
|
* AutoCrudTable 组件
|
|
@@ -765,7 +774,8 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
765
774
|
slots,
|
|
766
775
|
permissions,
|
|
767
776
|
actions: actionItems,
|
|
768
|
-
locale: localeProp
|
|
777
|
+
locale: localeProp,
|
|
778
|
+
onCreate
|
|
769
779
|
}: AutoCrudTableProps<TSchema>): react_jsx_runtime3.JSX.Element;
|
|
770
780
|
//#endregion
|
|
771
781
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
@@ -1119,6 +1129,8 @@ interface CrudFormModalProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
|
1119
1129
|
labelAlign?: "left" | "top" | "right";
|
|
1120
1130
|
/** Label 宽度(labelAlign 为 left 时有效) */
|
|
1121
1131
|
labelWidth?: number | string;
|
|
1132
|
+
/** 弹窗自定义样式 */
|
|
1133
|
+
className?: string;
|
|
1122
1134
|
}
|
|
1123
1135
|
declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
1124
1136
|
open,
|
|
@@ -1134,7 +1146,8 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1134
1146
|
locale,
|
|
1135
1147
|
gridColumns,
|
|
1136
1148
|
labelAlign,
|
|
1137
|
-
labelWidth
|
|
1149
|
+
labelWidth,
|
|
1150
|
+
className
|
|
1138
1151
|
}: CrudFormModalProps<T>): react_jsx_runtime3.JSX.Element;
|
|
1139
1152
|
//#endregion
|
|
1140
1153
|
//#region src/components/auto-crud/import-dialog.d.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _tanstack_react_table0 from "@tanstack/react-table";
|
|
|
3
3
|
import { Column, ColumnDef, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
|
|
4
4
|
import { DropdownMenuTrigger, PopoverContent } from "@pixpilot/shadcn";
|
|
5
5
|
import { ClassValue } from "clsx";
|
|
6
|
-
import * as
|
|
6
|
+
import * as react_jsx_runtime4 from "react/jsx-runtime";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { ISchema } from "@formily/json-schema";
|
|
9
9
|
|
|
@@ -314,7 +314,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
314
314
|
enableExport,
|
|
315
315
|
enableDelete,
|
|
316
316
|
extraActions
|
|
317
|
-
}: AutoTableActionBarProps<TData>):
|
|
317
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
318
318
|
//#endregion
|
|
319
319
|
//#region src/lib/schema-bridge/types.d.ts
|
|
320
320
|
/**
|
|
@@ -470,7 +470,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
470
470
|
enableExport,
|
|
471
471
|
onSelectedCountChange,
|
|
472
472
|
getSelectedRows
|
|
473
|
-
}: AutoTableProps<T>):
|
|
473
|
+
}: AutoTableProps<T>): react_jsx_runtime4.JSX.Element;
|
|
474
474
|
//#endregion
|
|
475
475
|
//#region src/i18n/locale.d.ts
|
|
476
476
|
/**
|
|
@@ -701,10 +701,12 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
701
701
|
};
|
|
702
702
|
/** 表单配置 */
|
|
703
703
|
form?: {
|
|
704
|
-
/**
|
|
704
|
+
/** 表单覆盖配置(兼容旧 API,优先级低于 fieldOverrides) */
|
|
705
705
|
overrides?: Record<string, any>;
|
|
706
706
|
/** 表单列数 */
|
|
707
707
|
columns?: number;
|
|
708
|
+
/** 弹窗自定义容器类名(支持控制大小、最大高度等) */
|
|
709
|
+
className?: string;
|
|
708
710
|
};
|
|
709
711
|
/** 扩展点 */
|
|
710
712
|
slots?: {
|
|
@@ -712,6 +714,8 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
712
714
|
toolbarStart?: React$1.ReactNode;
|
|
713
715
|
/** 工具栏右侧插槽 */
|
|
714
716
|
toolbarEnd?: React$1.ReactNode;
|
|
717
|
+
/** 覆盖内置的新建按钮组件 */
|
|
718
|
+
createButton?: React$1.ReactNode;
|
|
715
719
|
};
|
|
716
720
|
/** 行操作配置,见 {@link ActionItem} */
|
|
717
721
|
actions?: ActionItem<z.output<TSchema>>[];
|
|
@@ -748,6 +752,11 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
748
752
|
* ```
|
|
749
753
|
*/
|
|
750
754
|
locale?: LocaleProp;
|
|
755
|
+
/**
|
|
756
|
+
* 自定义新建按钮点击事件
|
|
757
|
+
* 如果提供,将覆盖默认的打开新建弹窗行为
|
|
758
|
+
*/
|
|
759
|
+
onCreate?: () => void;
|
|
751
760
|
}
|
|
752
761
|
/**
|
|
753
762
|
* AutoCrudTable 组件
|
|
@@ -765,8 +774,9 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
765
774
|
slots,
|
|
766
775
|
permissions,
|
|
767
776
|
actions: actionItems,
|
|
768
|
-
locale: localeProp
|
|
769
|
-
|
|
777
|
+
locale: localeProp,
|
|
778
|
+
onCreate
|
|
779
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime4.JSX.Element;
|
|
770
780
|
//#endregion
|
|
771
781
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
772
782
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -798,7 +808,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
798
808
|
labelAlign,
|
|
799
809
|
labelWidth,
|
|
800
810
|
showSubmitButton
|
|
801
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
811
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime4.JSX.Element;
|
|
802
812
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
803
813
|
ref?: React.Ref<AutoFormRef>;
|
|
804
814
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1096,7 +1106,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1096
1106
|
shallow,
|
|
1097
1107
|
filters: externalFilters,
|
|
1098
1108
|
onFiltersChange
|
|
1099
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1109
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime4.JSX.Element | null;
|
|
1100
1110
|
//#endregion
|
|
1101
1111
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1102
1112
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -1119,6 +1129,8 @@ interface CrudFormModalProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
|
1119
1129
|
labelAlign?: "left" | "top" | "right";
|
|
1120
1130
|
/** Label 宽度(labelAlign 为 left 时有效) */
|
|
1121
1131
|
labelWidth?: number | string;
|
|
1132
|
+
/** 弹窗自定义样式 */
|
|
1133
|
+
className?: string;
|
|
1122
1134
|
}
|
|
1123
1135
|
declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
1124
1136
|
open,
|
|
@@ -1134,8 +1146,9 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1134
1146
|
locale,
|
|
1135
1147
|
gridColumns,
|
|
1136
1148
|
labelAlign,
|
|
1137
|
-
labelWidth
|
|
1138
|
-
|
|
1149
|
+
labelWidth,
|
|
1150
|
+
className
|
|
1151
|
+
}: CrudFormModalProps<T>): react_jsx_runtime4.JSX.Element;
|
|
1139
1152
|
//#endregion
|
|
1140
1153
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1141
1154
|
interface ImportDialogProps {
|
|
@@ -1157,7 +1170,7 @@ declare function ImportDialog({
|
|
|
1157
1170
|
columns,
|
|
1158
1171
|
title,
|
|
1159
1172
|
locale
|
|
1160
|
-
}: ImportDialogProps):
|
|
1173
|
+
}: ImportDialogProps): react_jsx_runtime4.JSX.Element;
|
|
1161
1174
|
//#endregion
|
|
1162
1175
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1163
1176
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1177,7 +1190,7 @@ declare function ExportDialog({
|
|
|
1177
1190
|
selectedCount,
|
|
1178
1191
|
onExport,
|
|
1179
1192
|
canExportFiltered
|
|
1180
|
-
}: ExportDialogProps):
|
|
1193
|
+
}: ExportDialogProps): react_jsx_runtime4.JSX.Element;
|
|
1181
1194
|
//#endregion
|
|
1182
1195
|
//#region src/components/data-table/data-table.d.ts
|
|
1183
1196
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1190,7 +1203,7 @@ declare function DataTable<TData>({
|
|
|
1190
1203
|
children,
|
|
1191
1204
|
className,
|
|
1192
1205
|
...props
|
|
1193
|
-
}: DataTableProps<TData>):
|
|
1206
|
+
}: DataTableProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1194
1207
|
//#endregion
|
|
1195
1208
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1196
1209
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1201,7 +1214,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1201
1214
|
children,
|
|
1202
1215
|
className,
|
|
1203
1216
|
...props
|
|
1204
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1217
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1205
1218
|
//#endregion
|
|
1206
1219
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1207
1220
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1213,7 +1226,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1213
1226
|
label,
|
|
1214
1227
|
className,
|
|
1215
1228
|
...props
|
|
1216
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1229
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime4.JSX.Element;
|
|
1217
1230
|
//#endregion
|
|
1218
1231
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1219
1232
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1227,7 +1240,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1227
1240
|
title,
|
|
1228
1241
|
options,
|
|
1229
1242
|
multiple
|
|
1230
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1243
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime4.JSX.Element;
|
|
1231
1244
|
//#endregion
|
|
1232
1245
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1233
1246
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1239,7 +1252,7 @@ declare function DataTablePagination<TData>({
|
|
|
1239
1252
|
pageSizeOptions,
|
|
1240
1253
|
className,
|
|
1241
1254
|
...props
|
|
1242
|
-
}: DataTablePaginationProps<TData>):
|
|
1255
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1243
1256
|
//#endregion
|
|
1244
1257
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1245
1258
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1250,7 +1263,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1250
1263
|
children,
|
|
1251
1264
|
className,
|
|
1252
1265
|
...props
|
|
1253
|
-
}: DataTableToolbarProps<TData>):
|
|
1266
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1254
1267
|
//#endregion
|
|
1255
1268
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1256
1269
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1261,7 +1274,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1261
1274
|
table,
|
|
1262
1275
|
disabled,
|
|
1263
1276
|
...props
|
|
1264
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1277
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1265
1278
|
//#endregion
|
|
1266
1279
|
//#region src/hooks/use-data-table.d.ts
|
|
1267
1280
|
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, "state" | "pageCount" | "getCoreRowModel" | "manualFiltering" | "manualPagination" | "manualSorting">, Required<Pick<TableOptions<TData>, "pageCount">> {
|
package/dist/index.js
CHANGED
|
@@ -4684,14 +4684,14 @@ function FormModal({ open, onOpenChange, title, description, children, variant =
|
|
|
4684
4684
|
onOpenChange,
|
|
4685
4685
|
children: /* @__PURE__ */ jsxs(SheetContent, {
|
|
4686
4686
|
side,
|
|
4687
|
-
className:
|
|
4687
|
+
className: cn("sm:max-w-lg flex flex-col p-0", className),
|
|
4688
4688
|
children: [
|
|
4689
4689
|
/* @__PURE__ */ jsxs(SheetHeader, {
|
|
4690
4690
|
className: "flex-shrink-0 px-6 pt-6",
|
|
4691
4691
|
children: [/* @__PURE__ */ jsx(SheetTitle, { children: title }), description && /* @__PURE__ */ jsx(SheetDescription, { children: description })]
|
|
4692
4692
|
}),
|
|
4693
4693
|
/* @__PURE__ */ jsx("div", {
|
|
4694
|
-
className: "flex-1 overflow-auto",
|
|
4694
|
+
className: "flex-1 overflow-y-auto min-h-0",
|
|
4695
4695
|
children: /* @__PURE__ */ jsx("div", {
|
|
4696
4696
|
className: "px-6 py-4",
|
|
4697
4697
|
children
|
|
@@ -4708,16 +4708,16 @@ function FormModal({ open, onOpenChange, title, description, children, variant =
|
|
|
4708
4708
|
open,
|
|
4709
4709
|
onOpenChange,
|
|
4710
4710
|
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
4711
|
-
className:
|
|
4711
|
+
className: cn("max-w-2xl sm:max-w-2xl flex flex-col max-h-[85vh] overflow-hidden p-0", className),
|
|
4712
4712
|
children: [
|
|
4713
4713
|
/* @__PURE__ */ jsxs(DialogHeader, {
|
|
4714
4714
|
className: "flex-shrink-0 px-6 pt-6",
|
|
4715
4715
|
children: [/* @__PURE__ */ jsx(DialogTitle, { children: title }), description && /* @__PURE__ */ jsx(DialogDescription, { children: description })]
|
|
4716
4716
|
}),
|
|
4717
4717
|
/* @__PURE__ */ jsx("div", {
|
|
4718
|
-
className: "flex-1 overflow-auto",
|
|
4718
|
+
className: "flex-1 overflow-y-auto min-h-0",
|
|
4719
4719
|
children: /* @__PURE__ */ jsx("div", {
|
|
4720
|
-
className: "px-6 py-4",
|
|
4720
|
+
className: "px-6 py-4 text-sm",
|
|
4721
4721
|
children
|
|
4722
4722
|
})
|
|
4723
4723
|
}),
|
|
@@ -5332,7 +5332,7 @@ function resolveLocale(localeProp) {
|
|
|
5332
5332
|
|
|
5333
5333
|
//#endregion
|
|
5334
5334
|
//#region src/components/auto-crud/crud-form-modal.tsx
|
|
5335
|
-
function CrudFormModal({ open, onOpenChange, mode, schema, initialValues, onSubmit, loading = false, variant = "dialog", overrides, title, locale = zhCN.formModal, gridColumns, labelAlign, labelWidth }) {
|
|
5335
|
+
function CrudFormModal({ open, onOpenChange, mode, schema, initialValues, onSubmit, loading = false, variant = "dialog", overrides, title, locale = zhCN.formModal, gridColumns, labelAlign, labelWidth, className }) {
|
|
5336
5336
|
const defaultTitle = mode === "create" ? locale.createTitle : locale.editTitle;
|
|
5337
5337
|
const formRef = useRef(null);
|
|
5338
5338
|
const handleSubmit = async () => {
|
|
@@ -5343,6 +5343,7 @@ function CrudFormModal({ open, onOpenChange, mode, schema, initialValues, onSubm
|
|
|
5343
5343
|
onOpenChange,
|
|
5344
5344
|
title: title ?? defaultTitle,
|
|
5345
5345
|
variant,
|
|
5346
|
+
className,
|
|
5346
5347
|
footer: /* @__PURE__ */ jsxs("div", {
|
|
5347
5348
|
className: "flex justify-end gap-2",
|
|
5348
5349
|
children: [/* @__PURE__ */ jsx(Button, {
|
|
@@ -5937,7 +5938,7 @@ function resolveActions(items, defaults, rowActionsLocale) {
|
|
|
5937
5938
|
*
|
|
5938
5939
|
* 高级 CRUD 表格组件,封装了完整的增删改查流程
|
|
5939
5940
|
*/
|
|
5940
|
-
function AutoCrudTable({ title, description, schema, resource, fields, table: tableConfig, form: formConfig, slots, permissions, actions: actionItems, locale: localeProp }) {
|
|
5941
|
+
function AutoCrudTable({ title, description, schema, resource, fields, table: tableConfig, form: formConfig, slots, permissions, actions: actionItems, locale: localeProp, onCreate }) {
|
|
5941
5942
|
const locale = resolveLocale(localeProp);
|
|
5942
5943
|
const can = {
|
|
5943
5944
|
create: permissions?.can?.create ?? true,
|
|
@@ -6040,10 +6041,10 @@ function AutoCrudTable({ title, description, schema, resource, fields, table: ta
|
|
|
6040
6041
|
disabled: exporting || selectedCount === 0 && !resource.handlers.export,
|
|
6041
6042
|
children: [exporting ? /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Upload, { className: "mr-2 h-4 w-4" }), selectedCount > 0 ? locale.toolbar.exportSelected(selectedCount) : locale.toolbar.export]
|
|
6042
6043
|
}),
|
|
6043
|
-
can.create && /* @__PURE__ */ jsx(Button, {
|
|
6044
|
-
onClick: resource.handlers.openCreate,
|
|
6044
|
+
can.create && (slots?.createButton ? slots.createButton : /* @__PURE__ */ jsx(Button, {
|
|
6045
|
+
onClick: onCreate ?? resource.handlers.openCreate,
|
|
6045
6046
|
children: locale.toolbar.create
|
|
6046
|
-
})
|
|
6047
|
+
}))
|
|
6047
6048
|
]
|
|
6048
6049
|
})]
|
|
6049
6050
|
}),
|
|
@@ -6082,7 +6083,8 @@ function AutoCrudTable({ title, description, schema, resource, fields, table: ta
|
|
|
6082
6083
|
variant: resource.modal.variant,
|
|
6083
6084
|
overrides: formOverrides,
|
|
6084
6085
|
locale: locale.formModal,
|
|
6085
|
-
gridColumns: formConfig?.columns
|
|
6086
|
+
gridColumns: formConfig?.columns,
|
|
6087
|
+
className: formConfig?.className
|
|
6086
6088
|
}),
|
|
6087
6089
|
/* @__PURE__ */ jsx(ViewModal, {
|
|
6088
6090
|
open: resource.modal.viewOpen,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordrhyme/auto-crud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
6
6
|
"author": "wordrhyme",
|
|
7
7
|
"license": "MIT",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"nanoid": "^5.1.6",
|
|
66
66
|
"tailwind-merge": "^3.4.0",
|
|
67
67
|
"vaul": "^1.1.2",
|
|
68
|
-
"@pixpilot/shadcn-ui": "1.4.0",
|
|
69
68
|
"@pixpilot/formily-shadcn": "1.7.2",
|
|
70
|
-
"@pixpilot/shadcn": "1.2.0"
|
|
69
|
+
"@pixpilot/shadcn": "1.2.0",
|
|
70
|
+
"@pixpilot/shadcn-ui": "1.4.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@tanstack/react-query": "^5.90.15",
|
|
@@ -81,11 +81,11 @@
|
|
|
81
81
|
"react-dom": "19.2.4",
|
|
82
82
|
"tsdown": "^0.15.12",
|
|
83
83
|
"typescript": "^5.9.3",
|
|
84
|
-
"@internal/prettier-config": "0.0.1",
|
|
85
84
|
"@internal/eslint-config": "0.3.0",
|
|
85
|
+
"@internal/prettier-config": "0.0.1",
|
|
86
86
|
"@internal/tsconfig": "0.1.0",
|
|
87
|
-
"@internal/
|
|
88
|
-
"@internal/
|
|
87
|
+
"@internal/vitest-config": "0.1.0",
|
|
88
|
+
"@internal/tsdown-config": "0.1.0"
|
|
89
89
|
},
|
|
90
90
|
"prettier": "@internal/prettier-config",
|
|
91
91
|
"scripts": {
|