@wordrhyme/auto-crud 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -4
- package/dist/index.cjs +54 -24
- package/dist/index.d.cts +46 -27
- package/dist/index.d.ts +46 -27
- package/dist/index.js +54 -24
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -265,10 +265,12 @@ interface AutoCrudTableProps<TSchema> {
|
|
|
265
265
|
overrides?: Record<string, any>; // 表单覆盖配置
|
|
266
266
|
columns?: number; // 表单列数
|
|
267
267
|
};
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
/**
|
|
269
|
+
* 工具栏右侧操作配置
|
|
270
|
+
* - 只传 custom 项:内置保持默认,custom 追加到首/尾
|
|
271
|
+
* - 包含任意内置 type:数组完全接管,未列出的内置项自动隐藏
|
|
272
|
+
*/
|
|
273
|
+
toolbarActions?: ToolbarActionItem[];
|
|
272
274
|
/**
|
|
273
275
|
* 行操作配置
|
|
274
276
|
* - 只传 custom 项:内置保持默认,custom 追加到首/尾
|
|
@@ -518,6 +520,140 @@ table={{
|
|
|
518
520
|
|
|
519
521
|
---
|
|
520
522
|
|
|
523
|
+
## 🔧 工具栏操作配置
|
|
524
|
+
|
|
525
|
+
`toolbarActions` 数组控制页面顶部右侧工具栏的按钮,设计思路完全对齐行操作 `actions`。
|
|
526
|
+
|
|
527
|
+
内置操作类型:`create`(新建)、`import`(导入)、`export`(导出)。
|
|
528
|
+
|
|
529
|
+
### 只添加自定义按钮(内置保持默认)
|
|
530
|
+
|
|
531
|
+
只传 `type: "custom"` 项时,所有内置按钮(导入、导出、新建)保持原样,custom 项按 `position` 插入首部或尾部。
|
|
532
|
+
|
|
533
|
+
```tsx
|
|
534
|
+
<AutoCrudTable
|
|
535
|
+
toolbarActions={[
|
|
536
|
+
{ type: "custom", component: <Button variant="outline">分类管理</Button>, position: "start" },
|
|
537
|
+
{ type: "custom", component: <Button variant="outline">批量标签</Button> }, // 默认 position: "end"
|
|
538
|
+
]}
|
|
539
|
+
/>
|
|
540
|
+
// 渲染顺序: 分类管理 · [导入] · [导出] · [新建] · 批量标签
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### 调整内置按钮顺序
|
|
544
|
+
|
|
545
|
+
数组中只要包含任意内置 `type`,就会**完全接管工具栏** —— 未列出的内置按钮**直接隐藏**,渲染顺序**严格按数组**。
|
|
546
|
+
|
|
547
|
+
```tsx
|
|
548
|
+
<AutoCrudTable
|
|
549
|
+
toolbarActions={[
|
|
550
|
+
{ type: "create" }, // 新建移到最前
|
|
551
|
+
{ type: "export", label: "导出 CSV" }, // 覆盖文案
|
|
552
|
+
// import 未列出 → 隐藏
|
|
553
|
+
]}
|
|
554
|
+
/>
|
|
555
|
+
// 渲染顺序: 新建 · 导出 CSV(导入按钮消失)
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
### 覆盖内置按钮行为
|
|
559
|
+
|
|
560
|
+
```tsx
|
|
561
|
+
<AutoCrudTable
|
|
562
|
+
toolbarActions={[
|
|
563
|
+
{ type: "import" },
|
|
564
|
+
{ type: "export" },
|
|
565
|
+
{
|
|
566
|
+
type: "create",
|
|
567
|
+
label: "发布商品",
|
|
568
|
+
onClick: () => router.push('/products/new'), // 跳转详情页而非弹窗
|
|
569
|
+
},
|
|
570
|
+
]}
|
|
571
|
+
/>
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
### 完全替换内置按钮组件
|
|
575
|
+
|
|
576
|
+
```tsx
|
|
577
|
+
<AutoCrudTable
|
|
578
|
+
toolbarActions={[
|
|
579
|
+
{ type: "export" },
|
|
580
|
+
{
|
|
581
|
+
type: "create",
|
|
582
|
+
component: ( // 整个按钮替换
|
|
583
|
+
<DropdownMenu>
|
|
584
|
+
<DropdownMenuTrigger asChild>
|
|
585
|
+
<Button><Plus className="mr-2 h-4 w-4" />新建</Button>
|
|
586
|
+
</DropdownMenuTrigger>
|
|
587
|
+
<DropdownMenuContent>
|
|
588
|
+
<DropdownMenuItem onClick={() => create('simple')}>简易商品</DropdownMenuItem>
|
|
589
|
+
<DropdownMenuItem onClick={() => create('sku')}>多规格商品</DropdownMenuItem>
|
|
590
|
+
</DropdownMenuContent>
|
|
591
|
+
</DropdownMenu>
|
|
592
|
+
),
|
|
593
|
+
},
|
|
594
|
+
]}
|
|
595
|
+
/>
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### 混合 custom 和内置
|
|
599
|
+
|
|
600
|
+
```tsx
|
|
601
|
+
<AutoCrudTable
|
|
602
|
+
toolbarActions={[
|
|
603
|
+
{ type: "custom", component: <CategoryFilter onChange={setCategory} /> },
|
|
604
|
+
{ type: "export" },
|
|
605
|
+
{ type: "create", label: "发布", onClick: () => router.push('/products/new') },
|
|
606
|
+
]}
|
|
607
|
+
/>
|
|
608
|
+
// 渲染顺序: 分类筛选 · 导出 · 发布(导入隐藏)
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
### 与 `permissions` 的交互
|
|
612
|
+
|
|
613
|
+
`toolbarActions` 与 `permissions` 的交互规则如下:
|
|
614
|
+
|
|
615
|
+
- `permissions.can.create = false` → 即使配置了 `{ type: "create" }`,新建按钮仍不渲染
|
|
616
|
+
- `permissions.can.export = false` → 即使配置了 `{ type: "export" }`,导出按钮仍不渲染
|
|
617
|
+
- 内置项即使使用 `component` 完全替换渲染,也仍然受对应权限控制
|
|
618
|
+
- `type: "custom"` 不受 permissions 影响,由业务方自行控制
|
|
619
|
+
|
|
620
|
+
```tsx
|
|
621
|
+
<AutoCrudTable
|
|
622
|
+
permissions={{
|
|
623
|
+
can: { create: isAdmin, export: true, delete: isAdmin },
|
|
624
|
+
}}
|
|
625
|
+
toolbarActions={[
|
|
626
|
+
{ type: "export" }, // ✅ 始终渲染
|
|
627
|
+
{ type: "create", label: "发布商品" }, // 🔒 仅 isAdmin 时渲染
|
|
628
|
+
{
|
|
629
|
+
type: "custom", // ✅ 不受 permissions 影响
|
|
630
|
+
component: isEditor ? <Button>审核</Button> : null, // 业务方自行守卫
|
|
631
|
+
},
|
|
632
|
+
]}
|
|
633
|
+
/>
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
### `ToolbarActionItem` 类型
|
|
637
|
+
|
|
638
|
+
```typescript
|
|
639
|
+
type ToolbarActionItem = ToolbarBuiltinActionItem | ToolbarCustomActionItem;
|
|
640
|
+
|
|
641
|
+
type ToolbarBuiltinActionItem = {
|
|
642
|
+
type: "create" | "import" | "export";
|
|
643
|
+
onClick?: () => void; // 覆盖默认行为
|
|
644
|
+
label?: string; // 覆盖默认文案
|
|
645
|
+
component?: React.ReactNode; // 完全替换按钮渲染
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
type ToolbarCustomActionItem = {
|
|
649
|
+
type: "custom";
|
|
650
|
+
component: React.ReactNode; // 自定义渲染内容
|
|
651
|
+
position?: "start" | "end"; // 仅在无内置项时生效,默认 "end"
|
|
652
|
+
};
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
---
|
|
656
|
+
|
|
521
657
|
## 🎬 行操作配置
|
|
522
658
|
|
|
523
659
|
`actions` 数组控制每行下拉菜单的操作项,支持覆盖内置操作、添加自定义操作、完全自定义顺序。
|
package/dist/index.cjs
CHANGED
|
@@ -5980,7 +5980,7 @@ function resolveActions(items, defaults, rowActionsLocale) {
|
|
|
5980
5980
|
*
|
|
5981
5981
|
* 高级 CRUD 表格组件,封装了完整的增删改查流程
|
|
5982
5982
|
*/
|
|
5983
|
-
function AutoCrudTable({ title, description, schema, resource, fields, table: tableConfig, form: formConfig,
|
|
5983
|
+
function AutoCrudTable({ title, description, schema, resource, fields, table: tableConfig, form: formConfig, permissions, actions: actionItems, toolbarActions, locale: localeProp, onCreate }) {
|
|
5984
5984
|
const locale = resolveLocale(localeProp);
|
|
5985
5985
|
const can = {
|
|
5986
5986
|
create: permissions?.can?.create ?? true,
|
|
@@ -6061,34 +6061,64 @@ function AutoCrudTable({ title, description, schema, resource, fields, table: ta
|
|
|
6061
6061
|
children: description
|
|
6062
6062
|
})]
|
|
6063
6063
|
}),
|
|
6064
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
6065
|
-
className: "flex items-center justify-
|
|
6066
|
-
children:
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6070
|
-
className: "flex items-center gap-2",
|
|
6071
|
-
children: [
|
|
6072
|
-
slots?.toolbarEnd,
|
|
6073
|
-
canImport && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Button, {
|
|
6064
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6065
|
+
className: "flex items-center justify-end gap-4",
|
|
6066
|
+
children: (() => {
|
|
6067
|
+
const renderBuiltinButton = (type, overrides) => {
|
|
6068
|
+
if (type === "import" && canImport) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Button, {
|
|
6074
6069
|
variant: "outline",
|
|
6075
6070
|
size: "sm",
|
|
6076
|
-
onClick: () => setImportOpen(true),
|
|
6077
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Download, { className: "mr-2 h-4 w-4" }), locale.toolbar.import]
|
|
6078
|
-
})
|
|
6079
|
-
|
|
6071
|
+
onClick: overrides?.onClick ?? (() => setImportOpen(true)),
|
|
6072
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Download, { className: "mr-2 h-4 w-4" }), overrides?.label ?? locale.toolbar.import]
|
|
6073
|
+
}, "import");
|
|
6074
|
+
if (type === "export" && canExport) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Button, {
|
|
6080
6075
|
variant: "outline",
|
|
6081
6076
|
size: "sm",
|
|
6082
|
-
onClick: handleExportClick,
|
|
6077
|
+
onClick: overrides?.onClick ?? handleExportClick,
|
|
6083
6078
|
disabled: exporting || selectedCount === 0 && !resource.handlers.export,
|
|
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]
|
|
6085
|
-
})
|
|
6086
|
-
|
|
6087
|
-
onClick: onCreate ?? resource.handlers.openCreate,
|
|
6088
|
-
children: locale.toolbar.create
|
|
6089
|
-
})
|
|
6090
|
-
|
|
6091
|
-
|
|
6079
|
+
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" }), overrides?.label ?? (selectedCount > 0 ? locale.toolbar.exportSelected(selectedCount) : locale.toolbar.export)]
|
|
6080
|
+
}, "export");
|
|
6081
|
+
if (type === "create" && can.create) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Button, {
|
|
6082
|
+
onClick: overrides?.onClick ?? onCreate ?? resource.handlers.openCreate,
|
|
6083
|
+
children: overrides?.label ?? locale.toolbar.create
|
|
6084
|
+
}, "create");
|
|
6085
|
+
return null;
|
|
6086
|
+
};
|
|
6087
|
+
if (!toolbarActions || toolbarActions.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6088
|
+
className: "flex items-center gap-2",
|
|
6089
|
+
children: [
|
|
6090
|
+
renderBuiltinButton("import"),
|
|
6091
|
+
renderBuiltinButton("export"),
|
|
6092
|
+
renderBuiltinButton("create")
|
|
6093
|
+
]
|
|
6094
|
+
});
|
|
6095
|
+
if (!toolbarActions.some((i) => i.type !== "custom")) {
|
|
6096
|
+
const startNodes = toolbarActions.filter((i) => i.type === "custom" && i.position === "start").map((a, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: a.component }, `start-${i}`));
|
|
6097
|
+
const endNodes = toolbarActions.filter((i) => i.type === "custom" && i.position !== "start").map((a, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: a.component }, `end-${i}`));
|
|
6098
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6099
|
+
className: "flex items-center gap-2",
|
|
6100
|
+
children: [
|
|
6101
|
+
startNodes,
|
|
6102
|
+
renderBuiltinButton("import"),
|
|
6103
|
+
renderBuiltinButton("export"),
|
|
6104
|
+
renderBuiltinButton("create"),
|
|
6105
|
+
endNodes
|
|
6106
|
+
]
|
|
6107
|
+
});
|
|
6108
|
+
}
|
|
6109
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6110
|
+
className: "flex items-center gap-2",
|
|
6111
|
+
children: toolbarActions.map((action, index) => {
|
|
6112
|
+
if (action.type === "custom") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: action.component }, `custom-${index}`);
|
|
6113
|
+
if (!(action.type === "import" ? canImport : action.type === "export" ? canExport : can.create)) return null;
|
|
6114
|
+
if (action.component) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: action.component }, action.type);
|
|
6115
|
+
return renderBuiltinButton(action.type, {
|
|
6116
|
+
onClick: action.onClick,
|
|
6117
|
+
label: action.label
|
|
6118
|
+
});
|
|
6119
|
+
})
|
|
6120
|
+
});
|
|
6121
|
+
})()
|
|
6092
6122
|
}),
|
|
6093
6123
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutoTable, {
|
|
6094
6124
|
data: resource.tableData.data,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime4 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";
|
|
@@ -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
|
/**
|
|
@@ -661,6 +661,29 @@ type CustomActionItem<T> = {
|
|
|
661
661
|
* - **包含任意内置 type**:数组完全接管,未列出的隐藏,顺序即渲染顺序
|
|
662
662
|
*/
|
|
663
663
|
type ActionItem<T> = BuiltinActionItem<T> | CustomActionItem<T>;
|
|
664
|
+
/**
|
|
665
|
+
* 顶部工具栏内置操作项
|
|
666
|
+
*/
|
|
667
|
+
type ToolbarBuiltinActionItem = {
|
|
668
|
+
type: "create" | "import" | "export";
|
|
669
|
+
/** 替代默认的行为 */
|
|
670
|
+
onClick?: () => void;
|
|
671
|
+
/** 替代默认的标签文本 */
|
|
672
|
+
label?: string;
|
|
673
|
+
/** 替代整个按钮的渲染 */
|
|
674
|
+
component?: React$1.ReactNode;
|
|
675
|
+
};
|
|
676
|
+
/**
|
|
677
|
+
* 顶部工具栏自定义操作项
|
|
678
|
+
*/
|
|
679
|
+
type ToolbarCustomActionItem = {
|
|
680
|
+
type: "custom";
|
|
681
|
+
/** 渲染自定义内容 */
|
|
682
|
+
component: React$1.ReactNode;
|
|
683
|
+
/** 仅在无内置项时生效:插入到首部还是尾部(默认 end) */
|
|
684
|
+
position?: "start" | "end";
|
|
685
|
+
};
|
|
686
|
+
type ToolbarActionItem = ToolbarBuiltinActionItem | ToolbarCustomActionItem;
|
|
664
687
|
/**
|
|
665
688
|
* AutoCrudTable Props 接口
|
|
666
689
|
*/
|
|
@@ -708,17 +731,13 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
708
731
|
/** 弹窗自定义容器类名(支持控制大小、最大高度等) */
|
|
709
732
|
className?: string;
|
|
710
733
|
};
|
|
711
|
-
/** 扩展点 */
|
|
712
|
-
slots?: {
|
|
713
|
-
/** 工具栏左侧插槽 */
|
|
714
|
-
toolbarStart?: React$1.ReactNode;
|
|
715
|
-
/** 工具栏右侧插槽 */
|
|
716
|
-
toolbarEnd?: React$1.ReactNode;
|
|
717
|
-
/** 覆盖内置的新建按钮组件 */
|
|
718
|
-
createButton?: React$1.ReactNode;
|
|
719
|
-
};
|
|
720
734
|
/** 行操作配置,见 {@link ActionItem} */
|
|
721
735
|
actions?: ActionItem<z.output<TSchema>>[];
|
|
736
|
+
/**
|
|
737
|
+
* 顶层工具栏操作配置
|
|
738
|
+
* 用法类同 `actions` 行操作。一旦配置了包含内置 `type` 的数组,它将完全接管右侧工具栏!
|
|
739
|
+
*/
|
|
740
|
+
toolbarActions?: ToolbarActionItem[];
|
|
722
741
|
/**
|
|
723
742
|
* 权限配置
|
|
724
743
|
* 控制按钮显示和字段访问
|
|
@@ -771,12 +790,12 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
771
790
|
fields,
|
|
772
791
|
table: tableConfig,
|
|
773
792
|
form: formConfig,
|
|
774
|
-
slots,
|
|
775
793
|
permissions,
|
|
776
794
|
actions: actionItems,
|
|
795
|
+
toolbarActions,
|
|
777
796
|
locale: localeProp,
|
|
778
797
|
onCreate
|
|
779
|
-
}: AutoCrudTableProps<TSchema>):
|
|
798
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime4.JSX.Element;
|
|
780
799
|
//#endregion
|
|
781
800
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
782
801
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -808,7 +827,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
808
827
|
labelAlign,
|
|
809
828
|
labelWidth,
|
|
810
829
|
showSubmitButton
|
|
811
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
830
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime4.JSX.Element;
|
|
812
831
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
813
832
|
ref?: React.Ref<AutoFormRef>;
|
|
814
833
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1106,7 +1125,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1106
1125
|
shallow,
|
|
1107
1126
|
filters: externalFilters,
|
|
1108
1127
|
onFiltersChange
|
|
1109
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1128
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime4.JSX.Element | null;
|
|
1110
1129
|
//#endregion
|
|
1111
1130
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1112
1131
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -1148,7 +1167,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1148
1167
|
labelAlign,
|
|
1149
1168
|
labelWidth,
|
|
1150
1169
|
className
|
|
1151
|
-
}: CrudFormModalProps<T>):
|
|
1170
|
+
}: CrudFormModalProps<T>): react_jsx_runtime4.JSX.Element;
|
|
1152
1171
|
//#endregion
|
|
1153
1172
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1154
1173
|
interface ImportDialogProps {
|
|
@@ -1170,7 +1189,7 @@ declare function ImportDialog({
|
|
|
1170
1189
|
columns,
|
|
1171
1190
|
title,
|
|
1172
1191
|
locale
|
|
1173
|
-
}: ImportDialogProps):
|
|
1192
|
+
}: ImportDialogProps): react_jsx_runtime4.JSX.Element;
|
|
1174
1193
|
//#endregion
|
|
1175
1194
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1176
1195
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1190,7 +1209,7 @@ declare function ExportDialog({
|
|
|
1190
1209
|
selectedCount,
|
|
1191
1210
|
onExport,
|
|
1192
1211
|
canExportFiltered
|
|
1193
|
-
}: ExportDialogProps):
|
|
1212
|
+
}: ExportDialogProps): react_jsx_runtime4.JSX.Element;
|
|
1194
1213
|
//#endregion
|
|
1195
1214
|
//#region src/components/data-table/data-table.d.ts
|
|
1196
1215
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1203,7 +1222,7 @@ declare function DataTable<TData>({
|
|
|
1203
1222
|
children,
|
|
1204
1223
|
className,
|
|
1205
1224
|
...props
|
|
1206
|
-
}: DataTableProps<TData>):
|
|
1225
|
+
}: DataTableProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1207
1226
|
//#endregion
|
|
1208
1227
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1209
1228
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1214,7 +1233,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1214
1233
|
children,
|
|
1215
1234
|
className,
|
|
1216
1235
|
...props
|
|
1217
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1236
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1218
1237
|
//#endregion
|
|
1219
1238
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1220
1239
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1226,7 +1245,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1226
1245
|
label,
|
|
1227
1246
|
className,
|
|
1228
1247
|
...props
|
|
1229
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1248
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime4.JSX.Element;
|
|
1230
1249
|
//#endregion
|
|
1231
1250
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1232
1251
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1240,7 +1259,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1240
1259
|
title,
|
|
1241
1260
|
options,
|
|
1242
1261
|
multiple
|
|
1243
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1262
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime4.JSX.Element;
|
|
1244
1263
|
//#endregion
|
|
1245
1264
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1246
1265
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1252,7 +1271,7 @@ declare function DataTablePagination<TData>({
|
|
|
1252
1271
|
pageSizeOptions,
|
|
1253
1272
|
className,
|
|
1254
1273
|
...props
|
|
1255
|
-
}: DataTablePaginationProps<TData>):
|
|
1274
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1256
1275
|
//#endregion
|
|
1257
1276
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1258
1277
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1263,7 +1282,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1263
1282
|
children,
|
|
1264
1283
|
className,
|
|
1265
1284
|
...props
|
|
1266
|
-
}: DataTableToolbarProps<TData>):
|
|
1285
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1267
1286
|
//#endregion
|
|
1268
1287
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1269
1288
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1274,7 +1293,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1274
1293
|
table,
|
|
1275
1294
|
disabled,
|
|
1276
1295
|
...props
|
|
1277
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1296
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1278
1297
|
//#endregion
|
|
1279
1298
|
//#region src/hooks/use-data-table.d.ts
|
|
1280
1299
|
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, "state" | "pageCount" | "getCoreRowModel" | "manualFiltering" | "manualPagination" | "manualSorting">, Required<Pick<TableOptions<TData>, "pageCount">> {
|
|
@@ -1609,4 +1628,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
|
|
|
1609
1628
|
*/
|
|
1610
1629
|
declare function downloadCSVTemplate(headers: string[], filename?: string): void;
|
|
1611
1630
|
//#endregion
|
|
1612
|
-
export { type ActionItem, type ActionsColumnConfig, type AutoCrudLocale, AutoCrudTable, type AutoCrudTableProps, AutoForm, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, SchemaAdapter, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, cn, coerceRowValues, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setSearchParams, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
|
|
1631
|
+
export { type ActionItem, type ActionsColumnConfig, type AutoCrudLocale, AutoCrudTable, type AutoCrudTableProps, AutoForm, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, SchemaAdapter, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, cn, coerceRowValues, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setSearchParams, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
|
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_runtime6 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_runtime6.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_runtime6.JSX.Element;
|
|
474
474
|
//#endregion
|
|
475
475
|
//#region src/i18n/locale.d.ts
|
|
476
476
|
/**
|
|
@@ -661,6 +661,29 @@ type CustomActionItem<T> = {
|
|
|
661
661
|
* - **包含任意内置 type**:数组完全接管,未列出的隐藏,顺序即渲染顺序
|
|
662
662
|
*/
|
|
663
663
|
type ActionItem<T> = BuiltinActionItem<T> | CustomActionItem<T>;
|
|
664
|
+
/**
|
|
665
|
+
* 顶部工具栏内置操作项
|
|
666
|
+
*/
|
|
667
|
+
type ToolbarBuiltinActionItem = {
|
|
668
|
+
type: "create" | "import" | "export";
|
|
669
|
+
/** 替代默认的行为 */
|
|
670
|
+
onClick?: () => void;
|
|
671
|
+
/** 替代默认的标签文本 */
|
|
672
|
+
label?: string;
|
|
673
|
+
/** 替代整个按钮的渲染 */
|
|
674
|
+
component?: React$1.ReactNode;
|
|
675
|
+
};
|
|
676
|
+
/**
|
|
677
|
+
* 顶部工具栏自定义操作项
|
|
678
|
+
*/
|
|
679
|
+
type ToolbarCustomActionItem = {
|
|
680
|
+
type: "custom";
|
|
681
|
+
/** 渲染自定义内容 */
|
|
682
|
+
component: React$1.ReactNode;
|
|
683
|
+
/** 仅在无内置项时生效:插入到首部还是尾部(默认 end) */
|
|
684
|
+
position?: "start" | "end";
|
|
685
|
+
};
|
|
686
|
+
type ToolbarActionItem = ToolbarBuiltinActionItem | ToolbarCustomActionItem;
|
|
664
687
|
/**
|
|
665
688
|
* AutoCrudTable Props 接口
|
|
666
689
|
*/
|
|
@@ -708,17 +731,13 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
708
731
|
/** 弹窗自定义容器类名(支持控制大小、最大高度等) */
|
|
709
732
|
className?: string;
|
|
710
733
|
};
|
|
711
|
-
/** 扩展点 */
|
|
712
|
-
slots?: {
|
|
713
|
-
/** 工具栏左侧插槽 */
|
|
714
|
-
toolbarStart?: React$1.ReactNode;
|
|
715
|
-
/** 工具栏右侧插槽 */
|
|
716
|
-
toolbarEnd?: React$1.ReactNode;
|
|
717
|
-
/** 覆盖内置的新建按钮组件 */
|
|
718
|
-
createButton?: React$1.ReactNode;
|
|
719
|
-
};
|
|
720
734
|
/** 行操作配置,见 {@link ActionItem} */
|
|
721
735
|
actions?: ActionItem<z.output<TSchema>>[];
|
|
736
|
+
/**
|
|
737
|
+
* 顶层工具栏操作配置
|
|
738
|
+
* 用法类同 `actions` 行操作。一旦配置了包含内置 `type` 的数组,它将完全接管右侧工具栏!
|
|
739
|
+
*/
|
|
740
|
+
toolbarActions?: ToolbarActionItem[];
|
|
722
741
|
/**
|
|
723
742
|
* 权限配置
|
|
724
743
|
* 控制按钮显示和字段访问
|
|
@@ -771,12 +790,12 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
771
790
|
fields,
|
|
772
791
|
table: tableConfig,
|
|
773
792
|
form: formConfig,
|
|
774
|
-
slots,
|
|
775
793
|
permissions,
|
|
776
794
|
actions: actionItems,
|
|
795
|
+
toolbarActions,
|
|
777
796
|
locale: localeProp,
|
|
778
797
|
onCreate
|
|
779
|
-
}: AutoCrudTableProps<TSchema>):
|
|
798
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime6.JSX.Element;
|
|
780
799
|
//#endregion
|
|
781
800
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
782
801
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -808,7 +827,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
808
827
|
labelAlign,
|
|
809
828
|
labelWidth,
|
|
810
829
|
showSubmitButton
|
|
811
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
830
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime6.JSX.Element;
|
|
812
831
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
813
832
|
ref?: React.Ref<AutoFormRef>;
|
|
814
833
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1106,7 +1125,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1106
1125
|
shallow,
|
|
1107
1126
|
filters: externalFilters,
|
|
1108
1127
|
onFiltersChange
|
|
1109
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1128
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime6.JSX.Element | null;
|
|
1110
1129
|
//#endregion
|
|
1111
1130
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1112
1131
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -1148,7 +1167,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1148
1167
|
labelAlign,
|
|
1149
1168
|
labelWidth,
|
|
1150
1169
|
className
|
|
1151
|
-
}: CrudFormModalProps<T>):
|
|
1170
|
+
}: CrudFormModalProps<T>): react_jsx_runtime6.JSX.Element;
|
|
1152
1171
|
//#endregion
|
|
1153
1172
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1154
1173
|
interface ImportDialogProps {
|
|
@@ -1170,7 +1189,7 @@ declare function ImportDialog({
|
|
|
1170
1189
|
columns,
|
|
1171
1190
|
title,
|
|
1172
1191
|
locale
|
|
1173
|
-
}: ImportDialogProps):
|
|
1192
|
+
}: ImportDialogProps): react_jsx_runtime6.JSX.Element;
|
|
1174
1193
|
//#endregion
|
|
1175
1194
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1176
1195
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1190,7 +1209,7 @@ declare function ExportDialog({
|
|
|
1190
1209
|
selectedCount,
|
|
1191
1210
|
onExport,
|
|
1192
1211
|
canExportFiltered
|
|
1193
|
-
}: ExportDialogProps):
|
|
1212
|
+
}: ExportDialogProps): react_jsx_runtime6.JSX.Element;
|
|
1194
1213
|
//#endregion
|
|
1195
1214
|
//#region src/components/data-table/data-table.d.ts
|
|
1196
1215
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1203,7 +1222,7 @@ declare function DataTable<TData>({
|
|
|
1203
1222
|
children,
|
|
1204
1223
|
className,
|
|
1205
1224
|
...props
|
|
1206
|
-
}: DataTableProps<TData>):
|
|
1225
|
+
}: DataTableProps<TData>): react_jsx_runtime6.JSX.Element;
|
|
1207
1226
|
//#endregion
|
|
1208
1227
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1209
1228
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1214,7 +1233,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1214
1233
|
children,
|
|
1215
1234
|
className,
|
|
1216
1235
|
...props
|
|
1217
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1236
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime6.JSX.Element;
|
|
1218
1237
|
//#endregion
|
|
1219
1238
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1220
1239
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1226,7 +1245,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1226
1245
|
label,
|
|
1227
1246
|
className,
|
|
1228
1247
|
...props
|
|
1229
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1248
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime6.JSX.Element;
|
|
1230
1249
|
//#endregion
|
|
1231
1250
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1232
1251
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1240,7 +1259,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1240
1259
|
title,
|
|
1241
1260
|
options,
|
|
1242
1261
|
multiple
|
|
1243
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1262
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime6.JSX.Element;
|
|
1244
1263
|
//#endregion
|
|
1245
1264
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1246
1265
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1252,7 +1271,7 @@ declare function DataTablePagination<TData>({
|
|
|
1252
1271
|
pageSizeOptions,
|
|
1253
1272
|
className,
|
|
1254
1273
|
...props
|
|
1255
|
-
}: DataTablePaginationProps<TData>):
|
|
1274
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime6.JSX.Element;
|
|
1256
1275
|
//#endregion
|
|
1257
1276
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1258
1277
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1263,7 +1282,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1263
1282
|
children,
|
|
1264
1283
|
className,
|
|
1265
1284
|
...props
|
|
1266
|
-
}: DataTableToolbarProps<TData>):
|
|
1285
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime6.JSX.Element;
|
|
1267
1286
|
//#endregion
|
|
1268
1287
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1269
1288
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1274,7 +1293,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1274
1293
|
table,
|
|
1275
1294
|
disabled,
|
|
1276
1295
|
...props
|
|
1277
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1296
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime6.JSX.Element;
|
|
1278
1297
|
//#endregion
|
|
1279
1298
|
//#region src/hooks/use-data-table.d.ts
|
|
1280
1299
|
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, "state" | "pageCount" | "getCoreRowModel" | "manualFiltering" | "manualPagination" | "manualSorting">, Required<Pick<TableOptions<TData>, "pageCount">> {
|
|
@@ -1609,4 +1628,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
|
|
|
1609
1628
|
*/
|
|
1610
1629
|
declare function downloadCSVTemplate(headers: string[], filename?: string): void;
|
|
1611
1630
|
//#endregion
|
|
1612
|
-
export { type ActionItem, type ActionsColumnConfig, type AutoCrudLocale, AutoCrudTable, type AutoCrudTableProps, AutoForm, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, SchemaAdapter, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, cn, coerceRowValues, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setSearchParams, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
|
|
1631
|
+
export { type ActionItem, type ActionsColumnConfig, type AutoCrudLocale, AutoCrudTable, type AutoCrudTableProps, AutoForm, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, SchemaAdapter, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, cn, coerceRowValues, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setSearchParams, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
|
package/dist/index.js
CHANGED
|
@@ -5938,7 +5938,7 @@ function resolveActions(items, defaults, rowActionsLocale) {
|
|
|
5938
5938
|
*
|
|
5939
5939
|
* 高级 CRUD 表格组件,封装了完整的增删改查流程
|
|
5940
5940
|
*/
|
|
5941
|
-
function AutoCrudTable({ title, description, schema, resource, fields, table: tableConfig, form: formConfig,
|
|
5941
|
+
function AutoCrudTable({ title, description, schema, resource, fields, table: tableConfig, form: formConfig, permissions, actions: actionItems, toolbarActions, locale: localeProp, onCreate }) {
|
|
5942
5942
|
const locale = resolveLocale(localeProp);
|
|
5943
5943
|
const can = {
|
|
5944
5944
|
create: permissions?.can?.create ?? true,
|
|
@@ -6019,34 +6019,64 @@ function AutoCrudTable({ title, description, schema, resource, fields, table: ta
|
|
|
6019
6019
|
children: description
|
|
6020
6020
|
})]
|
|
6021
6021
|
}),
|
|
6022
|
-
/* @__PURE__ */
|
|
6023
|
-
className: "flex items-center justify-
|
|
6024
|
-
children:
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
6028
|
-
className: "flex items-center gap-2",
|
|
6029
|
-
children: [
|
|
6030
|
-
slots?.toolbarEnd,
|
|
6031
|
-
canImport && /* @__PURE__ */ jsxs(Button, {
|
|
6022
|
+
/* @__PURE__ */ jsx("div", {
|
|
6023
|
+
className: "flex items-center justify-end gap-4",
|
|
6024
|
+
children: (() => {
|
|
6025
|
+
const renderBuiltinButton = (type, overrides) => {
|
|
6026
|
+
if (type === "import" && canImport) return /* @__PURE__ */ jsxs(Button, {
|
|
6032
6027
|
variant: "outline",
|
|
6033
6028
|
size: "sm",
|
|
6034
|
-
onClick: () => setImportOpen(true),
|
|
6035
|
-
children: [/* @__PURE__ */ jsx(Download, { className: "mr-2 h-4 w-4" }), locale.toolbar.import]
|
|
6036
|
-
})
|
|
6037
|
-
|
|
6029
|
+
onClick: overrides?.onClick ?? (() => setImportOpen(true)),
|
|
6030
|
+
children: [/* @__PURE__ */ jsx(Download, { className: "mr-2 h-4 w-4" }), overrides?.label ?? locale.toolbar.import]
|
|
6031
|
+
}, "import");
|
|
6032
|
+
if (type === "export" && canExport) return /* @__PURE__ */ jsxs(Button, {
|
|
6038
6033
|
variant: "outline",
|
|
6039
6034
|
size: "sm",
|
|
6040
|
-
onClick: handleExportClick,
|
|
6035
|
+
onClick: overrides?.onClick ?? handleExportClick,
|
|
6041
6036
|
disabled: exporting || selectedCount === 0 && !resource.handlers.export,
|
|
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]
|
|
6043
|
-
})
|
|
6044
|
-
|
|
6045
|
-
onClick: onCreate ?? resource.handlers.openCreate,
|
|
6046
|
-
children: locale.toolbar.create
|
|
6047
|
-
})
|
|
6048
|
-
|
|
6049
|
-
|
|
6037
|
+
children: [exporting ? /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Upload, { className: "mr-2 h-4 w-4" }), overrides?.label ?? (selectedCount > 0 ? locale.toolbar.exportSelected(selectedCount) : locale.toolbar.export)]
|
|
6038
|
+
}, "export");
|
|
6039
|
+
if (type === "create" && can.create) return /* @__PURE__ */ jsx(Button, {
|
|
6040
|
+
onClick: overrides?.onClick ?? onCreate ?? resource.handlers.openCreate,
|
|
6041
|
+
children: overrides?.label ?? locale.toolbar.create
|
|
6042
|
+
}, "create");
|
|
6043
|
+
return null;
|
|
6044
|
+
};
|
|
6045
|
+
if (!toolbarActions || toolbarActions.length === 0) return /* @__PURE__ */ jsxs("div", {
|
|
6046
|
+
className: "flex items-center gap-2",
|
|
6047
|
+
children: [
|
|
6048
|
+
renderBuiltinButton("import"),
|
|
6049
|
+
renderBuiltinButton("export"),
|
|
6050
|
+
renderBuiltinButton("create")
|
|
6051
|
+
]
|
|
6052
|
+
});
|
|
6053
|
+
if (!toolbarActions.some((i) => i.type !== "custom")) {
|
|
6054
|
+
const startNodes = toolbarActions.filter((i) => i.type === "custom" && i.position === "start").map((a, i) => /* @__PURE__ */ jsx(React.Fragment, { children: a.component }, `start-${i}`));
|
|
6055
|
+
const endNodes = toolbarActions.filter((i) => i.type === "custom" && i.position !== "start").map((a, i) => /* @__PURE__ */ jsx(React.Fragment, { children: a.component }, `end-${i}`));
|
|
6056
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
6057
|
+
className: "flex items-center gap-2",
|
|
6058
|
+
children: [
|
|
6059
|
+
startNodes,
|
|
6060
|
+
renderBuiltinButton("import"),
|
|
6061
|
+
renderBuiltinButton("export"),
|
|
6062
|
+
renderBuiltinButton("create"),
|
|
6063
|
+
endNodes
|
|
6064
|
+
]
|
|
6065
|
+
});
|
|
6066
|
+
}
|
|
6067
|
+
return /* @__PURE__ */ jsx("div", {
|
|
6068
|
+
className: "flex items-center gap-2",
|
|
6069
|
+
children: toolbarActions.map((action, index) => {
|
|
6070
|
+
if (action.type === "custom") return /* @__PURE__ */ jsx(React.Fragment, { children: action.component }, `custom-${index}`);
|
|
6071
|
+
if (!(action.type === "import" ? canImport : action.type === "export" ? canExport : can.create)) return null;
|
|
6072
|
+
if (action.component) return /* @__PURE__ */ jsx(React.Fragment, { children: action.component }, action.type);
|
|
6073
|
+
return renderBuiltinButton(action.type, {
|
|
6074
|
+
onClick: action.onClick,
|
|
6075
|
+
label: action.label
|
|
6076
|
+
});
|
|
6077
|
+
})
|
|
6078
|
+
});
|
|
6079
|
+
})()
|
|
6050
6080
|
}),
|
|
6051
6081
|
/* @__PURE__ */ jsx(AutoTable, {
|
|
6052
6082
|
data: resource.tableData.data,
|
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.7",
|
|
5
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
6
6
|
"author": "wordrhyme",
|
|
7
7
|
"license": "MIT",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"react-dom": "19.2.4",
|
|
82
82
|
"tsdown": "^0.15.12",
|
|
83
83
|
"typescript": "^5.9.3",
|
|
84
|
-
"@internal/eslint-config": "0.3.0",
|
|
85
84
|
"@internal/prettier-config": "0.0.1",
|
|
85
|
+
"@internal/eslint-config": "0.3.0",
|
|
86
86
|
"@internal/tsconfig": "0.1.0",
|
|
87
87
|
"@internal/vitest-config": "0.1.0",
|
|
88
88
|
"@internal/tsdown-config": "0.1.0"
|