@wordrhyme/auto-crud 1.0.1 → 1.0.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/README.md +76 -7
- package/dist/index.cjs +590 -94
- package/dist/index.d.cts +153 -15
- package/dist/index.d.ts +169 -31
- package/dist/index.js +582 -94
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -394,16 +394,23 @@ declare function createSelectColumn<T>(): ColumnDef<T>;
|
|
|
394
394
|
/**
|
|
395
395
|
* 操作列配置
|
|
396
396
|
*/
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
397
|
+
/**
|
|
398
|
+
* 已解析的操作项(渲染层使用)
|
|
399
|
+
*/
|
|
400
|
+
interface ResolvedActionItem<T> {
|
|
401
|
+
label: string;
|
|
402
|
+
onClick: (row: T) => void;
|
|
403
|
+
separator?: boolean;
|
|
404
|
+
variant?: "default" | "destructive";
|
|
402
405
|
}
|
|
406
|
+
/**
|
|
407
|
+
* 操作列配置(ResolvedActionItem 数组)
|
|
408
|
+
*/
|
|
409
|
+
type ActionsColumnConfig<T> = ResolvedActionItem<T>[];
|
|
403
410
|
/**
|
|
404
411
|
* 创建操作列
|
|
405
412
|
*/
|
|
406
|
-
declare function createActionsColumn<T>(
|
|
413
|
+
declare function createActionsColumn<T>(items: ActionsColumnConfig<T>): ColumnDef<T>;
|
|
407
414
|
//#endregion
|
|
408
415
|
//#region src/components/auto-crud/auto-table.d.ts
|
|
409
416
|
/** 过滤模式类型 */
|
|
@@ -465,6 +472,96 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
465
472
|
getSelectedRows
|
|
466
473
|
}: AutoTableProps<T>): react_jsx_runtime0.JSX.Element;
|
|
467
474
|
//#endregion
|
|
475
|
+
//#region src/i18n/locale.d.ts
|
|
476
|
+
/**
|
|
477
|
+
* AutoCrud 国际化接口及内置语言包
|
|
478
|
+
*
|
|
479
|
+
* 使用方式:
|
|
480
|
+
* // 内置语言
|
|
481
|
+
* <AutoCrudTable locale="en-US" ... />
|
|
482
|
+
*
|
|
483
|
+
* // 部分覆盖(以 zh-CN 为基础深合并)
|
|
484
|
+
* <AutoCrudTable locale={{ toolbar: { create: "Add" } }} ... />
|
|
485
|
+
*/
|
|
486
|
+
interface AutoCrudLocale {
|
|
487
|
+
toolbar: {
|
|
488
|
+
create: string;
|
|
489
|
+
import: string;
|
|
490
|
+
export: string;
|
|
491
|
+
exportSelected: (count: number) => string;
|
|
492
|
+
};
|
|
493
|
+
rowActions: {
|
|
494
|
+
view: string;
|
|
495
|
+
edit: string;
|
|
496
|
+
copy: string;
|
|
497
|
+
delete: string;
|
|
498
|
+
};
|
|
499
|
+
viewModal: {
|
|
500
|
+
title: string;
|
|
501
|
+
};
|
|
502
|
+
boolean: {
|
|
503
|
+
true: string;
|
|
504
|
+
false: string;
|
|
505
|
+
};
|
|
506
|
+
formModal: {
|
|
507
|
+
createTitle: string;
|
|
508
|
+
editTitle: string;
|
|
509
|
+
cancel: string;
|
|
510
|
+
create: string;
|
|
511
|
+
save: string;
|
|
512
|
+
submitting: string;
|
|
513
|
+
};
|
|
514
|
+
deleteModal: {
|
|
515
|
+
title: string;
|
|
516
|
+
description: string;
|
|
517
|
+
cancel: string;
|
|
518
|
+
confirm: string;
|
|
519
|
+
confirming: string;
|
|
520
|
+
};
|
|
521
|
+
importDialog: {
|
|
522
|
+
title: string;
|
|
523
|
+
uploadDescription: string;
|
|
524
|
+
previewDescription: (count: number) => string;
|
|
525
|
+
importingDescription: string;
|
|
526
|
+
doneDescription: string;
|
|
527
|
+
dragHint: string;
|
|
528
|
+
formatHint: string;
|
|
529
|
+
downloadTemplate: string;
|
|
530
|
+
moreColumns: (count: number) => string;
|
|
531
|
+
previewSummary: (rows: number, fields: number, format: string, previewLimit?: number) => string;
|
|
532
|
+
reselect: string;
|
|
533
|
+
confirmImport: string;
|
|
534
|
+
importingRows: (count: number) => string;
|
|
535
|
+
resultCreated: string;
|
|
536
|
+
resultUpdated: string;
|
|
537
|
+
resultSkipped: string;
|
|
538
|
+
resultFailed: string;
|
|
539
|
+
failedRowHeader: string;
|
|
540
|
+
failedErrorHeader: string;
|
|
541
|
+
close: string;
|
|
542
|
+
continueImport: string;
|
|
543
|
+
errorNoData: string;
|
|
544
|
+
errorParseFailed: string;
|
|
545
|
+
errorImportFailed: string;
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
declare const zhCN: AutoCrudLocale;
|
|
549
|
+
declare const enUS: AutoCrudLocale;
|
|
550
|
+
declare const jaJP: AutoCrudLocale;
|
|
551
|
+
declare const koKR: AutoCrudLocale;
|
|
552
|
+
declare const frFR: AutoCrudLocale;
|
|
553
|
+
declare const deDE: AutoCrudLocale;
|
|
554
|
+
declare const esES: AutoCrudLocale;
|
|
555
|
+
type DeepPartial<T> = { [P in keyof T]?: T[P] extends ((...args: unknown[]) => unknown) ? T[P] : T[P] extends object ? DeepPartial<T[P]> : T[P] };
|
|
556
|
+
/** locale prop 类型:内置语言 key 或部分覆盖对象 */
|
|
557
|
+
type LocaleProp = string | DeepPartial<AutoCrudLocale>;
|
|
558
|
+
/**
|
|
559
|
+
* 解析 locale prop 为完整的 AutoCrudLocale
|
|
560
|
+
* - string → 内置语言(fallback: zh-CN)
|
|
561
|
+
* - object → 以 zh-CN 为基础深合并
|
|
562
|
+
*/
|
|
563
|
+
declare function resolveLocale(localeProp?: LocaleProp): AutoCrudLocale;
|
|
564
|
+
//#endregion
|
|
468
565
|
//#region src/components/auto-crud/auto-crud-table.d.ts
|
|
469
566
|
/**
|
|
470
567
|
* 筛选器独立配置
|
|
@@ -539,6 +636,31 @@ interface Field {
|
|
|
539
636
|
} | false;
|
|
540
637
|
}
|
|
541
638
|
type Fields = Record<string, Field>;
|
|
639
|
+
type BuiltinType = "view" | "edit" | "copy" | "delete";
|
|
640
|
+
/** 内置操作项(覆盖默认行为或调整位置) */
|
|
641
|
+
type BuiltinActionItem<T> = {
|
|
642
|
+
type: BuiltinType;
|
|
643
|
+
onClick?: (row: T) => void;
|
|
644
|
+
label?: string;
|
|
645
|
+
separator?: boolean;
|
|
646
|
+
};
|
|
647
|
+
/** 自定义操作项 */
|
|
648
|
+
type CustomActionItem<T> = {
|
|
649
|
+
type: "custom";
|
|
650
|
+
label: string;
|
|
651
|
+
onClick: (row: T) => void;
|
|
652
|
+
/** 仅在无内置项时生效:插入到首部还是尾部(默认 end) */
|
|
653
|
+
position?: "start" | "end";
|
|
654
|
+
separator?: boolean;
|
|
655
|
+
variant?: "default" | "destructive";
|
|
656
|
+
};
|
|
657
|
+
/**
|
|
658
|
+
* 行操作项
|
|
659
|
+
*
|
|
660
|
+
* - **只传 custom**:内置保持默认,custom 追加到首/尾
|
|
661
|
+
* - **包含任意内置 type**:数组完全接管,未列出的隐藏,顺序即渲染顺序
|
|
662
|
+
*/
|
|
663
|
+
type ActionItem<T> = BuiltinActionItem<T> | CustomActionItem<T>;
|
|
542
664
|
/**
|
|
543
665
|
* AutoCrudTable Props 接口
|
|
544
666
|
*/
|
|
@@ -590,12 +712,9 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
590
712
|
toolbarStart?: React$1.ReactNode;
|
|
591
713
|
/** 工具栏右侧插槽 */
|
|
592
714
|
toolbarEnd?: React$1.ReactNode;
|
|
593
|
-
/** 自定义行操作 */
|
|
594
|
-
rowActions?: (row: z.output<TSchema>) => Array<{
|
|
595
|
-
label: string;
|
|
596
|
-
onClick: () => void;
|
|
597
|
-
}>;
|
|
598
715
|
};
|
|
716
|
+
/** 行操作配置,见 {@link ActionItem} */
|
|
717
|
+
actions?: ActionItem<z.output<TSchema>>[];
|
|
599
718
|
/**
|
|
600
719
|
* 权限配置
|
|
601
720
|
* 控制按钮显示和字段访问
|
|
@@ -617,6 +736,18 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
617
736
|
* ```
|
|
618
737
|
*/
|
|
619
738
|
permissions?: CrudPermissions;
|
|
739
|
+
/**
|
|
740
|
+
* 语言配置
|
|
741
|
+
* - 内置语言 key:`"zh-CN"`(默认)、`"en-US"`
|
|
742
|
+
* - 部分覆盖对象:以 zh-CN 为基础深合并
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* ```tsx
|
|
746
|
+
* <AutoCrudTable locale="en-US" ... />
|
|
747
|
+
* <AutoCrudTable locale={{ toolbar: { create: "Add New" } }} ... />
|
|
748
|
+
* ```
|
|
749
|
+
*/
|
|
750
|
+
locale?: LocaleProp;
|
|
620
751
|
}
|
|
621
752
|
/**
|
|
622
753
|
* AutoCrudTable 组件
|
|
@@ -632,7 +763,9 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
632
763
|
table: tableConfig,
|
|
633
764
|
form: formConfig,
|
|
634
765
|
slots,
|
|
635
|
-
permissions
|
|
766
|
+
permissions,
|
|
767
|
+
actions: actionItems,
|
|
768
|
+
locale: localeProp
|
|
636
769
|
}: AutoCrudTableProps<TSchema>): react_jsx_runtime0.JSX.Element;
|
|
637
770
|
//#endregion
|
|
638
771
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
@@ -980,6 +1113,7 @@ interface CrudFormModalProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
|
980
1113
|
variant?: ModalVariant;
|
|
981
1114
|
overrides?: FormSchemaOverrides;
|
|
982
1115
|
title?: string;
|
|
1116
|
+
locale?: AutoCrudLocale["formModal"];
|
|
983
1117
|
/** Label 对齐方式 */
|
|
984
1118
|
labelAlign?: "left" | "top" | "right";
|
|
985
1119
|
/** Label 宽度(labelAlign 为 left 时有效) */
|
|
@@ -996,6 +1130,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
996
1130
|
variant,
|
|
997
1131
|
overrides,
|
|
998
1132
|
title,
|
|
1133
|
+
locale,
|
|
999
1134
|
labelAlign,
|
|
1000
1135
|
labelWidth
|
|
1001
1136
|
}: CrudFormModalProps<T>): react_jsx_runtime0.JSX.Element;
|
|
@@ -1008,15 +1143,18 @@ interface ImportDialogProps {
|
|
|
1008
1143
|
onImport: (rows: Record<string, unknown>[]) => Promise<ImportResult>;
|
|
1009
1144
|
/** 可用列名(用于生成模板) */
|
|
1010
1145
|
columns?: string[];
|
|
1011
|
-
/**
|
|
1146
|
+
/** 对话框标题(优先于 locale.title) */
|
|
1012
1147
|
title?: string;
|
|
1148
|
+
/** 语言包,默认 zh-CN */
|
|
1149
|
+
locale?: AutoCrudLocale["importDialog"];
|
|
1013
1150
|
}
|
|
1014
1151
|
declare function ImportDialog({
|
|
1015
1152
|
open,
|
|
1016
1153
|
onOpenChange,
|
|
1017
1154
|
onImport,
|
|
1018
1155
|
columns,
|
|
1019
|
-
title
|
|
1156
|
+
title,
|
|
1157
|
+
locale
|
|
1020
1158
|
}: ImportDialogProps): react_jsx_runtime0.JSX.Element;
|
|
1021
1159
|
//#endregion
|
|
1022
1160
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
@@ -1456,4 +1594,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
|
|
|
1456
1594
|
*/
|
|
1457
1595
|
declare function downloadCSVTemplate(headers: string[], filename?: string): void;
|
|
1458
1596
|
//#endregion
|
|
1459
|
-
export { type ActionsColumnConfig, 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, 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, downloadCSVTemplate, exportAllToCSV, exportTableToCSV, formatDate, generateCSVTemplate, getUrlParams, humanize, noopToastAdapter, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, setSearchParams, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates };
|
|
1597
|
+
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 };
|
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_runtime3 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_runtime3.JSX.Element;
|
|
318
318
|
//#endregion
|
|
319
319
|
//#region src/lib/schema-bridge/types.d.ts
|
|
320
320
|
/**
|
|
@@ -394,16 +394,23 @@ declare function createSelectColumn<T>(): ColumnDef<T>;
|
|
|
394
394
|
/**
|
|
395
395
|
* 操作列配置
|
|
396
396
|
*/
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
397
|
+
/**
|
|
398
|
+
* 已解析的操作项(渲染层使用)
|
|
399
|
+
*/
|
|
400
|
+
interface ResolvedActionItem<T> {
|
|
401
|
+
label: string;
|
|
402
|
+
onClick: (row: T) => void;
|
|
403
|
+
separator?: boolean;
|
|
404
|
+
variant?: "default" | "destructive";
|
|
402
405
|
}
|
|
406
|
+
/**
|
|
407
|
+
* 操作列配置(ResolvedActionItem 数组)
|
|
408
|
+
*/
|
|
409
|
+
type ActionsColumnConfig<T> = ResolvedActionItem<T>[];
|
|
403
410
|
/**
|
|
404
411
|
* 创建操作列
|
|
405
412
|
*/
|
|
406
|
-
declare function createActionsColumn<T>(
|
|
413
|
+
declare function createActionsColumn<T>(items: ActionsColumnConfig<T>): ColumnDef<T>;
|
|
407
414
|
//#endregion
|
|
408
415
|
//#region src/components/auto-crud/auto-table.d.ts
|
|
409
416
|
/** 过滤模式类型 */
|
|
@@ -463,7 +470,97 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
463
470
|
enableExport,
|
|
464
471
|
onSelectedCountChange,
|
|
465
472
|
getSelectedRows
|
|
466
|
-
}: AutoTableProps<T>):
|
|
473
|
+
}: AutoTableProps<T>): react_jsx_runtime3.JSX.Element;
|
|
474
|
+
//#endregion
|
|
475
|
+
//#region src/i18n/locale.d.ts
|
|
476
|
+
/**
|
|
477
|
+
* AutoCrud 国际化接口及内置语言包
|
|
478
|
+
*
|
|
479
|
+
* 使用方式:
|
|
480
|
+
* // 内置语言
|
|
481
|
+
* <AutoCrudTable locale="en-US" ... />
|
|
482
|
+
*
|
|
483
|
+
* // 部分覆盖(以 zh-CN 为基础深合并)
|
|
484
|
+
* <AutoCrudTable locale={{ toolbar: { create: "Add" } }} ... />
|
|
485
|
+
*/
|
|
486
|
+
interface AutoCrudLocale {
|
|
487
|
+
toolbar: {
|
|
488
|
+
create: string;
|
|
489
|
+
import: string;
|
|
490
|
+
export: string;
|
|
491
|
+
exportSelected: (count: number) => string;
|
|
492
|
+
};
|
|
493
|
+
rowActions: {
|
|
494
|
+
view: string;
|
|
495
|
+
edit: string;
|
|
496
|
+
copy: string;
|
|
497
|
+
delete: string;
|
|
498
|
+
};
|
|
499
|
+
viewModal: {
|
|
500
|
+
title: string;
|
|
501
|
+
};
|
|
502
|
+
boolean: {
|
|
503
|
+
true: string;
|
|
504
|
+
false: string;
|
|
505
|
+
};
|
|
506
|
+
formModal: {
|
|
507
|
+
createTitle: string;
|
|
508
|
+
editTitle: string;
|
|
509
|
+
cancel: string;
|
|
510
|
+
create: string;
|
|
511
|
+
save: string;
|
|
512
|
+
submitting: string;
|
|
513
|
+
};
|
|
514
|
+
deleteModal: {
|
|
515
|
+
title: string;
|
|
516
|
+
description: string;
|
|
517
|
+
cancel: string;
|
|
518
|
+
confirm: string;
|
|
519
|
+
confirming: string;
|
|
520
|
+
};
|
|
521
|
+
importDialog: {
|
|
522
|
+
title: string;
|
|
523
|
+
uploadDescription: string;
|
|
524
|
+
previewDescription: (count: number) => string;
|
|
525
|
+
importingDescription: string;
|
|
526
|
+
doneDescription: string;
|
|
527
|
+
dragHint: string;
|
|
528
|
+
formatHint: string;
|
|
529
|
+
downloadTemplate: string;
|
|
530
|
+
moreColumns: (count: number) => string;
|
|
531
|
+
previewSummary: (rows: number, fields: number, format: string, previewLimit?: number) => string;
|
|
532
|
+
reselect: string;
|
|
533
|
+
confirmImport: string;
|
|
534
|
+
importingRows: (count: number) => string;
|
|
535
|
+
resultCreated: string;
|
|
536
|
+
resultUpdated: string;
|
|
537
|
+
resultSkipped: string;
|
|
538
|
+
resultFailed: string;
|
|
539
|
+
failedRowHeader: string;
|
|
540
|
+
failedErrorHeader: string;
|
|
541
|
+
close: string;
|
|
542
|
+
continueImport: string;
|
|
543
|
+
errorNoData: string;
|
|
544
|
+
errorParseFailed: string;
|
|
545
|
+
errorImportFailed: string;
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
declare const zhCN: AutoCrudLocale;
|
|
549
|
+
declare const enUS: AutoCrudLocale;
|
|
550
|
+
declare const jaJP: AutoCrudLocale;
|
|
551
|
+
declare const koKR: AutoCrudLocale;
|
|
552
|
+
declare const frFR: AutoCrudLocale;
|
|
553
|
+
declare const deDE: AutoCrudLocale;
|
|
554
|
+
declare const esES: AutoCrudLocale;
|
|
555
|
+
type DeepPartial<T> = { [P in keyof T]?: T[P] extends ((...args: unknown[]) => unknown) ? T[P] : T[P] extends object ? DeepPartial<T[P]> : T[P] };
|
|
556
|
+
/** locale prop 类型:内置语言 key 或部分覆盖对象 */
|
|
557
|
+
type LocaleProp = string | DeepPartial<AutoCrudLocale>;
|
|
558
|
+
/**
|
|
559
|
+
* 解析 locale prop 为完整的 AutoCrudLocale
|
|
560
|
+
* - string → 内置语言(fallback: zh-CN)
|
|
561
|
+
* - object → 以 zh-CN 为基础深合并
|
|
562
|
+
*/
|
|
563
|
+
declare function resolveLocale(localeProp?: LocaleProp): AutoCrudLocale;
|
|
467
564
|
//#endregion
|
|
468
565
|
//#region src/components/auto-crud/auto-crud-table.d.ts
|
|
469
566
|
/**
|
|
@@ -539,6 +636,31 @@ interface Field {
|
|
|
539
636
|
} | false;
|
|
540
637
|
}
|
|
541
638
|
type Fields = Record<string, Field>;
|
|
639
|
+
type BuiltinType = "view" | "edit" | "copy" | "delete";
|
|
640
|
+
/** 内置操作项(覆盖默认行为或调整位置) */
|
|
641
|
+
type BuiltinActionItem<T> = {
|
|
642
|
+
type: BuiltinType;
|
|
643
|
+
onClick?: (row: T) => void;
|
|
644
|
+
label?: string;
|
|
645
|
+
separator?: boolean;
|
|
646
|
+
};
|
|
647
|
+
/** 自定义操作项 */
|
|
648
|
+
type CustomActionItem<T> = {
|
|
649
|
+
type: "custom";
|
|
650
|
+
label: string;
|
|
651
|
+
onClick: (row: T) => void;
|
|
652
|
+
/** 仅在无内置项时生效:插入到首部还是尾部(默认 end) */
|
|
653
|
+
position?: "start" | "end";
|
|
654
|
+
separator?: boolean;
|
|
655
|
+
variant?: "default" | "destructive";
|
|
656
|
+
};
|
|
657
|
+
/**
|
|
658
|
+
* 行操作项
|
|
659
|
+
*
|
|
660
|
+
* - **只传 custom**:内置保持默认,custom 追加到首/尾
|
|
661
|
+
* - **包含任意内置 type**:数组完全接管,未列出的隐藏,顺序即渲染顺序
|
|
662
|
+
*/
|
|
663
|
+
type ActionItem<T> = BuiltinActionItem<T> | CustomActionItem<T>;
|
|
542
664
|
/**
|
|
543
665
|
* AutoCrudTable Props 接口
|
|
544
666
|
*/
|
|
@@ -590,12 +712,9 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
590
712
|
toolbarStart?: React$1.ReactNode;
|
|
591
713
|
/** 工具栏右侧插槽 */
|
|
592
714
|
toolbarEnd?: React$1.ReactNode;
|
|
593
|
-
/** 自定义行操作 */
|
|
594
|
-
rowActions?: (row: z.output<TSchema>) => Array<{
|
|
595
|
-
label: string;
|
|
596
|
-
onClick: () => void;
|
|
597
|
-
}>;
|
|
598
715
|
};
|
|
716
|
+
/** 行操作配置,见 {@link ActionItem} */
|
|
717
|
+
actions?: ActionItem<z.output<TSchema>>[];
|
|
599
718
|
/**
|
|
600
719
|
* 权限配置
|
|
601
720
|
* 控制按钮显示和字段访问
|
|
@@ -617,6 +736,18 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
|
617
736
|
* ```
|
|
618
737
|
*/
|
|
619
738
|
permissions?: CrudPermissions;
|
|
739
|
+
/**
|
|
740
|
+
* 语言配置
|
|
741
|
+
* - 内置语言 key:`"zh-CN"`(默认)、`"en-US"`
|
|
742
|
+
* - 部分覆盖对象:以 zh-CN 为基础深合并
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* ```tsx
|
|
746
|
+
* <AutoCrudTable locale="en-US" ... />
|
|
747
|
+
* <AutoCrudTable locale={{ toolbar: { create: "Add New" } }} ... />
|
|
748
|
+
* ```
|
|
749
|
+
*/
|
|
750
|
+
locale?: LocaleProp;
|
|
620
751
|
}
|
|
621
752
|
/**
|
|
622
753
|
* AutoCrudTable 组件
|
|
@@ -632,8 +763,10 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
632
763
|
table: tableConfig,
|
|
633
764
|
form: formConfig,
|
|
634
765
|
slots,
|
|
635
|
-
permissions
|
|
636
|
-
|
|
766
|
+
permissions,
|
|
767
|
+
actions: actionItems,
|
|
768
|
+
locale: localeProp
|
|
769
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime3.JSX.Element;
|
|
637
770
|
//#endregion
|
|
638
771
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
639
772
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -665,7 +798,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
665
798
|
labelAlign,
|
|
666
799
|
labelWidth,
|
|
667
800
|
showSubmitButton
|
|
668
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
801
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime3.JSX.Element;
|
|
669
802
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
670
803
|
ref?: React.Ref<AutoFormRef>;
|
|
671
804
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -963,7 +1096,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
963
1096
|
shallow,
|
|
964
1097
|
filters: externalFilters,
|
|
965
1098
|
onFiltersChange
|
|
966
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1099
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime3.JSX.Element | null;
|
|
967
1100
|
//#endregion
|
|
968
1101
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
969
1102
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -980,6 +1113,7 @@ interface CrudFormModalProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
|
980
1113
|
variant?: ModalVariant;
|
|
981
1114
|
overrides?: FormSchemaOverrides;
|
|
982
1115
|
title?: string;
|
|
1116
|
+
locale?: AutoCrudLocale["formModal"];
|
|
983
1117
|
/** Label 对齐方式 */
|
|
984
1118
|
labelAlign?: "left" | "top" | "right";
|
|
985
1119
|
/** Label 宽度(labelAlign 为 left 时有效) */
|
|
@@ -996,9 +1130,10 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
996
1130
|
variant,
|
|
997
1131
|
overrides,
|
|
998
1132
|
title,
|
|
1133
|
+
locale,
|
|
999
1134
|
labelAlign,
|
|
1000
1135
|
labelWidth
|
|
1001
|
-
}: CrudFormModalProps<T>):
|
|
1136
|
+
}: CrudFormModalProps<T>): react_jsx_runtime3.JSX.Element;
|
|
1002
1137
|
//#endregion
|
|
1003
1138
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1004
1139
|
interface ImportDialogProps {
|
|
@@ -1008,16 +1143,19 @@ interface ImportDialogProps {
|
|
|
1008
1143
|
onImport: (rows: Record<string, unknown>[]) => Promise<ImportResult>;
|
|
1009
1144
|
/** 可用列名(用于生成模板) */
|
|
1010
1145
|
columns?: string[];
|
|
1011
|
-
/**
|
|
1146
|
+
/** 对话框标题(优先于 locale.title) */
|
|
1012
1147
|
title?: string;
|
|
1148
|
+
/** 语言包,默认 zh-CN */
|
|
1149
|
+
locale?: AutoCrudLocale["importDialog"];
|
|
1013
1150
|
}
|
|
1014
1151
|
declare function ImportDialog({
|
|
1015
1152
|
open,
|
|
1016
1153
|
onOpenChange,
|
|
1017
1154
|
onImport,
|
|
1018
1155
|
columns,
|
|
1019
|
-
title
|
|
1020
|
-
|
|
1156
|
+
title,
|
|
1157
|
+
locale
|
|
1158
|
+
}: ImportDialogProps): react_jsx_runtime3.JSX.Element;
|
|
1021
1159
|
//#endregion
|
|
1022
1160
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1023
1161
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1037,7 +1175,7 @@ declare function ExportDialog({
|
|
|
1037
1175
|
selectedCount,
|
|
1038
1176
|
onExport,
|
|
1039
1177
|
canExportFiltered
|
|
1040
|
-
}: ExportDialogProps):
|
|
1178
|
+
}: ExportDialogProps): react_jsx_runtime3.JSX.Element;
|
|
1041
1179
|
//#endregion
|
|
1042
1180
|
//#region src/components/data-table/data-table.d.ts
|
|
1043
1181
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1050,7 +1188,7 @@ declare function DataTable<TData>({
|
|
|
1050
1188
|
children,
|
|
1051
1189
|
className,
|
|
1052
1190
|
...props
|
|
1053
|
-
}: DataTableProps<TData>):
|
|
1191
|
+
}: DataTableProps<TData>): react_jsx_runtime3.JSX.Element;
|
|
1054
1192
|
//#endregion
|
|
1055
1193
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1056
1194
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1061,7 +1199,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1061
1199
|
children,
|
|
1062
1200
|
className,
|
|
1063
1201
|
...props
|
|
1064
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1202
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
|
|
1065
1203
|
//#endregion
|
|
1066
1204
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1067
1205
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1073,7 +1211,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1073
1211
|
label,
|
|
1074
1212
|
className,
|
|
1075
1213
|
...props
|
|
1076
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1214
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
|
|
1077
1215
|
//#endregion
|
|
1078
1216
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1079
1217
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1087,7 +1225,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1087
1225
|
title,
|
|
1088
1226
|
options,
|
|
1089
1227
|
multiple
|
|
1090
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1228
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
|
|
1091
1229
|
//#endregion
|
|
1092
1230
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1093
1231
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1099,7 +1237,7 @@ declare function DataTablePagination<TData>({
|
|
|
1099
1237
|
pageSizeOptions,
|
|
1100
1238
|
className,
|
|
1101
1239
|
...props
|
|
1102
|
-
}: DataTablePaginationProps<TData>):
|
|
1240
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime3.JSX.Element;
|
|
1103
1241
|
//#endregion
|
|
1104
1242
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1105
1243
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1110,7 +1248,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1110
1248
|
children,
|
|
1111
1249
|
className,
|
|
1112
1250
|
...props
|
|
1113
|
-
}: DataTableToolbarProps<TData>):
|
|
1251
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
|
|
1114
1252
|
//#endregion
|
|
1115
1253
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1116
1254
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1121,7 +1259,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1121
1259
|
table,
|
|
1122
1260
|
disabled,
|
|
1123
1261
|
...props
|
|
1124
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1262
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime3.JSX.Element;
|
|
1125
1263
|
//#endregion
|
|
1126
1264
|
//#region src/hooks/use-data-table.d.ts
|
|
1127
1265
|
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, "state" | "pageCount" | "getCoreRowModel" | "manualFiltering" | "manualPagination" | "manualSorting">, Required<Pick<TableOptions<TData>, "pageCount">> {
|
|
@@ -1456,4 +1594,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
|
|
|
1456
1594
|
*/
|
|
1457
1595
|
declare function downloadCSVTemplate(headers: string[], filename?: string): void;
|
|
1458
1596
|
//#endregion
|
|
1459
|
-
export { type ActionsColumnConfig, 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, 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, downloadCSVTemplate, exportAllToCSV, exportTableToCSV, formatDate, generateCSVTemplate, getUrlParams, humanize, noopToastAdapter, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, setSearchParams, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates };
|
|
1597
|
+
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 };
|