@wordrhyme/auto-crud 1.2.1 → 1.2.4

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.d.cts CHANGED
@@ -24,7 +24,7 @@ declare const noopToastAdapter: ToastAdapter;
24
24
  /**
25
25
  * Modal 状态类型
26
26
  */
27
- type ModalVariant$1 = "dialog" | "sheet";
27
+ type ModalVariant$1 = 'dialog' | 'sheet';
28
28
  interface ModalState<T> {
29
29
  createOpen: boolean;
30
30
  editOpen: boolean;
@@ -66,9 +66,9 @@ interface CrudHooks<TSchema extends z.ZodObject<z.ZodRawShape>, TListItem> {
66
66
  */
67
67
  beforeDelete?: (item: TListItem) => boolean | void | Promise<boolean | void>;
68
68
  /** 操作成功回调 */
69
- onSuccess?: (op: "create" | "update" | "delete", payload: unknown) => void;
69
+ onSuccess?: (op: 'create' | 'update' | 'delete', payload: unknown) => void;
70
70
  /** 操作失败回调 */
71
- onError?: (op: "create" | "update" | "delete", error: Error) => void;
71
+ onError?: (op: 'create' | 'update' | 'delete', error: Error) => void;
72
72
  }
73
73
  /**
74
74
  * Hook 配置选项
@@ -119,6 +119,8 @@ interface ImportResult {
119
119
  * Hook 返回值类型
120
120
  */
121
121
  interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>, TListItem> {
122
+ /** 主键字段名(默认: "id") */
123
+ idKey?: keyof TListItem & string;
122
124
  tableData: {
123
125
  data: TListItem[];
124
126
  pageCount: number;
@@ -204,7 +206,7 @@ interface AutoQueryParams {
204
206
  }>;
205
207
  search?: string;
206
208
  filters: any[];
207
- joinOperator: "and" | "or";
209
+ joinOperator: 'and' | 'or';
208
210
  }
209
211
  /**
210
212
  * Hook 配置参数
@@ -368,11 +370,11 @@ declare function AutoTableActionBar<TData>({
368
370
  /**
369
371
  * 字段类型映射
370
372
  */
371
- type FieldType = "string" | "number" | "boolean" | "date" | "enum" | "array" | "object";
373
+ type FieldType = 'string' | 'number' | 'boolean' | 'date' | 'enum' | 'array' | 'object';
372
374
  /**
373
375
  * DataTable Filter Variant
374
376
  */
375
- type FilterVariant = "text" | "number" | "boolean" | "select" | "multiSelect" | "date" | "dateRange" | "range";
377
+ type FilterVariant = 'text' | 'number' | 'boolean' | 'select' | 'multiSelect' | 'date' | 'dateRange' | 'range';
376
378
  /**
377
379
  * 解析后的 Zod 字段信息
378
380
  */
@@ -408,10 +410,10 @@ interface CreateTableSchemaOptions<T> {
408
410
  interface CreateFormSchemaOptions {
409
411
  overrides?: FormSchemaOverrides;
410
412
  exclude?: string[];
411
- layout?: "vertical" | "horizontal" | "grid";
413
+ layout?: 'vertical' | 'horizontal' | 'grid';
412
414
  gridColumns?: number;
413
415
  /** Label 对齐方式 */
414
- labelAlign?: "left" | "top" | "right";
416
+ labelAlign?: 'left' | 'top' | 'right';
415
417
  /** Label 宽度(labelAlign 为 left 时有效) */
416
418
  labelWidth?: number | string;
417
419
  /** Label 栅格占位 */
@@ -450,7 +452,7 @@ interface ResolvedActionItem<T> {
450
452
  label: string;
451
453
  onClick: (row: T) => void;
452
454
  separator?: boolean;
453
- variant?: "default" | "destructive";
455
+ variant?: 'default' | 'destructive';
454
456
  }
455
457
  /**
456
458
  * 操作列配置(ResolvedActionItem 数组)
@@ -506,6 +508,8 @@ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> {
506
508
  showDefaultExport?: boolean;
507
509
  /** 选中行数变化回调(用于外层组件获知选中状态) */
508
510
  onSelectedCountChange?: (count: number) => void;
511
+ /** 选中行数据变化回调(用于外层组件获知选中行身份变化) */
512
+ onSelectedRowsChange?: (rows: z.infer<T>[]) => void;
509
513
  /** 获取选中行数据的回调(由外层组件调用) */
510
514
  getSelectedRows?: React.MutableRefObject<(() => z.infer<T>[]) | null>;
511
515
  }
@@ -529,6 +533,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
529
533
  enableExport,
530
534
  showDefaultExport,
531
535
  onSelectedCountChange,
536
+ onSelectedRowsChange,
532
537
  getSelectedRows
533
538
  }: AutoTableProps<T>): react_jsx_runtime3.JSX.Element;
534
539
  //#endregion
@@ -646,10 +651,16 @@ type AutoCrudDataSourceResult = AutoCrudOption[] | {
646
651
  options?: AutoCrudOption[];
647
652
  };
648
653
  type AutoCrudDataSourceLoader = (context: AutoCrudDataSourceContext) => AutoCrudDataSourceResult | Promise<AutoCrudDataSourceResult>;
649
- type AutoCrudDataSourceConfig = string | {
650
- key: string;
651
- dependsOn?: string[];
652
- resetOnChange?: boolean;
654
+ type AutoCrudDataSourceConfig = string;
655
+ type AutoCrudDataSourceRegistration = AutoCrudDataSourceLoader | {
656
+ dependencies?: string[];
657
+ reset?: boolean;
658
+ load: AutoCrudDataSourceLoader;
659
+ };
660
+ type AutoCrudDataSourceEntry = {
661
+ dependencies: string[];
662
+ reset: boolean;
663
+ load: AutoCrudDataSourceLoader;
653
664
  };
654
665
  type RegistryListener = () => void;
655
666
  declare const formComponents: {
@@ -659,17 +670,22 @@ declare const formComponents: {
659
670
  all(): Record<string, AutoCrudFormComponentConfig>;
660
671
  subscribe(listener: RegistryListener): () => void;
661
672
  };
662
- declare const dataSources: {
663
- register(name: string, value: AutoCrudDataSourceLoader): void;
673
+ declare const components: {
674
+ register(name: string, value: AutoCrudFormComponentConfig): void;
664
675
  unregister(name: string): void;
665
- get(name: string): AutoCrudDataSourceLoader | undefined;
666
- all(): Record<string, AutoCrudDataSourceLoader>;
676
+ get(name: string): AutoCrudFormComponentConfig | undefined;
677
+ all(): Record<string, AutoCrudFormComponentConfig>;
667
678
  subscribe(listener: RegistryListener): () => void;
668
679
  };
680
+ declare const dataSources: {
681
+ register(name: string, registration: AutoCrudDataSourceRegistration): void;
682
+ unregister: (name: string) => void;
683
+ get: (name: string) => AutoCrudDataSourceEntry | undefined;
684
+ all: () => Record<string, AutoCrudDataSourceEntry>;
685
+ subscribe: (listener: RegistryListener) => () => void;
686
+ };
669
687
  declare function normalizeDataSourceConfig(config: AutoCrudDataSourceConfig | undefined): {
670
688
  key: string;
671
- dependsOn: string[];
672
- resetOnChange: boolean;
673
689
  } | undefined;
674
690
  declare function normalizeOptions(result: AutoCrudDataSourceResult | undefined): AutoCrudOption[];
675
691
  //#endregion
@@ -812,6 +828,16 @@ type ToolbarCustomActionItem = {
812
828
  };
813
829
  type ToolbarActionItem = ToolbarBuiltinActionItem | ToolbarCustomActionItem;
814
830
  type ToolbarActionConfig = ToolbarActionItem[] | ((defaults: ToolbarBuiltinActionItem[]) => ToolbarActionItem[]);
831
+ interface AutoCrudToolbarContext {
832
+ crudId: string;
833
+ idKey: string;
834
+ rowIds: string[];
835
+ selectedRowIds: string[];
836
+ selectedCount: number;
837
+ openCreate?: () => void;
838
+ }
839
+ type AutoCrudToolbarResolver = (targetId: string, ownerActions: readonly ToolbarActionItem[], context: AutoCrudToolbarContext) => ToolbarActionItem[];
840
+ declare function setAutoCrudToolbarResolver(resolver: AutoCrudToolbarResolver | null): void;
815
841
  /**
816
842
  * AutoCrudTable Props 接口
817
843
  */
@@ -855,7 +881,7 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
855
881
  batchFields?: (string | BatchUpdateField)[];
856
882
  /**
857
883
  * 多选后悬浮批量操作栏配置
858
- * 用法类同 `actions` 行操作和 `toolbarActions` 顶部工具栏。
884
+ * 用法类同 `actions` 行操作和 `toolbar` 顶部工具栏。
859
885
  * 只传 custom 时保留默认批量操作;包含任意内置 type 时完全接管顺序。
860
886
  */
861
887
  batchActions?: BatchActionConfig<z.output<TSchema>>;
@@ -877,6 +903,8 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
877
903
  * 顶层工具栏操作配置
878
904
  * 用法类同 `actions` 行操作。一旦配置了包含内置 `type` 的数组,它将完全接管右侧工具栏!
879
905
  */
906
+ toolbar?: ToolbarActionConfig;
907
+ /** @deprecated Use toolbar instead. */
880
908
  toolbarActions?: ToolbarActionConfig;
881
909
  /**
882
910
  * 权限配置
@@ -923,6 +951,7 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
923
951
  * 高级 CRUD 表格组件,封装了完整的增删改查流程
924
952
  */
925
953
  declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
954
+ id,
926
955
  title,
927
956
  description,
928
957
  schema,
@@ -932,6 +961,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
932
961
  form: formConfig,
933
962
  permissions,
934
963
  actions: actionItems,
964
+ toolbar,
935
965
  toolbarActions,
936
966
  locale: localeProp,
937
967
  onCreate
@@ -1209,7 +1239,7 @@ declare const filterItemSchema: z.ZodObject<{
1209
1239
  type FilterItemSchema = z.infer<typeof filterItemSchema>;
1210
1240
  //#endregion
1211
1241
  //#region src/types/data-table.d.ts
1212
- declare module "@tanstack/react-table" {
1242
+ declare module '@tanstack/react-table' {
1213
1243
  interface TableMeta<TData extends RowData> {
1214
1244
  queryKeys?: QueryKeys;
1215
1245
  queryStateOptions?: UrlStateOptions;
@@ -1224,7 +1254,7 @@ declare module "@tanstack/react-table" {
1224
1254
  unit?: string;
1225
1255
  icon?: React.FC<React.SVGProps<SVGSVGElement>>;
1226
1256
  /** 控制在哪些筛选模式下显示(未设置则在所有模式显示) */
1227
- modes?: Array<"simple" | "advanced" | "command">;
1257
+ modes?: Array<'simple' | 'advanced' | 'command'>;
1228
1258
  }
1229
1259
  }
1230
1260
  interface QueryKeys {
@@ -1241,10 +1271,10 @@ interface Option {
1241
1271
  count?: number;
1242
1272
  icon?: React.FC<React.SVGProps<SVGSVGElement>>;
1243
1273
  }
1244
- type FilterOperator = DataTableConfig["operators"][number];
1245
- type FilterVariant$1 = DataTableConfig["filterVariants"][number];
1246
- type JoinOperator = DataTableConfig["joinOperators"][number];
1247
- interface ExtendedColumnSort<TData> extends Omit<ColumnSort, "id"> {
1274
+ type FilterOperator = DataTableConfig['operators'][number];
1275
+ type FilterVariant$1 = DataTableConfig['filterVariants'][number];
1276
+ type JoinOperator = DataTableConfig['joinOperators'][number];
1277
+ interface ExtendedColumnSort<TData> extends Omit<ColumnSort, 'id'> {
1248
1278
  id: Extract<keyof TData, string>;
1249
1279
  }
1250
1280
  interface ExtendedColumnFilter<TData> extends FilterItemSchema {
@@ -1252,7 +1282,7 @@ interface ExtendedColumnFilter<TData> extends FilterItemSchema {
1252
1282
  }
1253
1283
  interface DataTableRowAction<TData> {
1254
1284
  row: Row<TData>;
1255
- variant: "update" | "delete";
1285
+ variant: 'update' | 'delete';
1256
1286
  }
1257
1287
  //#endregion
1258
1288
  //#region src/components/auto-crud/auto-table-simple-filters.d.ts
@@ -1814,4 +1844,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
1814
1844
  */
1815
1845
  declare function downloadCSVTemplate(headers: string[], filename?: string): void;
1816
1846
  //#endregion
1817
- export { type ActionItem, type ActionsColumnConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceLoader, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, AutoCrudTable, type AutoCrudTableProps, AutoForm, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, 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 FieldOption, 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, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, 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, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setSearchParams, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
1847
+ export { type ActionItem, type ActionsColumnConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, 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 FieldOption, 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, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, SchemaAdapter, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, cn, coerceRowValues, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setAutoCrudToolbarResolver, setSearchParams, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as _tanstack_react_table0 from "@tanstack/react-table";
4
4
  import { Column, ColumnDef, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
5
5
  import { Command, DropdownMenuTrigger, PopoverContent } from "@pixpilot/shadcn";
6
6
  import { ClassValue } from "clsx";
7
- import * as react_jsx_runtime3 from "react/jsx-runtime";
7
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
8
8
  import { z } from "zod";
9
9
  import { ISchema } from "@formily/json-schema";
10
10
 
@@ -24,7 +24,7 @@ declare const noopToastAdapter: ToastAdapter;
24
24
  /**
25
25
  * Modal 状态类型
26
26
  */
27
- type ModalVariant$1 = "dialog" | "sheet";
27
+ type ModalVariant$1 = 'dialog' | 'sheet';
28
28
  interface ModalState<T> {
29
29
  createOpen: boolean;
30
30
  editOpen: boolean;
@@ -66,9 +66,9 @@ interface CrudHooks<TSchema extends z.ZodObject<z.ZodRawShape>, TListItem> {
66
66
  */
67
67
  beforeDelete?: (item: TListItem) => boolean | void | Promise<boolean | void>;
68
68
  /** 操作成功回调 */
69
- onSuccess?: (op: "create" | "update" | "delete", payload: unknown) => void;
69
+ onSuccess?: (op: 'create' | 'update' | 'delete', payload: unknown) => void;
70
70
  /** 操作失败回调 */
71
- onError?: (op: "create" | "update" | "delete", error: Error) => void;
71
+ onError?: (op: 'create' | 'update' | 'delete', error: Error) => void;
72
72
  }
73
73
  /**
74
74
  * Hook 配置选项
@@ -119,6 +119,8 @@ interface ImportResult {
119
119
  * Hook 返回值类型
120
120
  */
121
121
  interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>, TListItem> {
122
+ /** 主键字段名(默认: "id") */
123
+ idKey?: keyof TListItem & string;
122
124
  tableData: {
123
125
  data: TListItem[];
124
126
  pageCount: number;
@@ -204,7 +206,7 @@ interface AutoQueryParams {
204
206
  }>;
205
207
  search?: string;
206
208
  filters: any[];
207
- joinOperator: "and" | "or";
209
+ joinOperator: 'and' | 'or';
208
210
  }
209
211
  /**
210
212
  * Hook 配置参数
@@ -362,17 +364,17 @@ declare function AutoTableActionBar<TData>({
362
364
  enableDelete,
363
365
  extraActions,
364
366
  actions
365
- }: AutoTableActionBarProps<TData>): react_jsx_runtime3.JSX.Element;
367
+ }: AutoTableActionBarProps<TData>): react_jsx_runtime1.JSX.Element;
366
368
  //#endregion
367
369
  //#region src/lib/schema-bridge/types.d.ts
368
370
  /**
369
371
  * 字段类型映射
370
372
  */
371
- type FieldType = "string" | "number" | "boolean" | "date" | "enum" | "array" | "object";
373
+ type FieldType = 'string' | 'number' | 'boolean' | 'date' | 'enum' | 'array' | 'object';
372
374
  /**
373
375
  * DataTable Filter Variant
374
376
  */
375
- type FilterVariant = "text" | "number" | "boolean" | "select" | "multiSelect" | "date" | "dateRange" | "range";
377
+ type FilterVariant = 'text' | 'number' | 'boolean' | 'select' | 'multiSelect' | 'date' | 'dateRange' | 'range';
376
378
  /**
377
379
  * 解析后的 Zod 字段信息
378
380
  */
@@ -408,10 +410,10 @@ interface CreateTableSchemaOptions<T> {
408
410
  interface CreateFormSchemaOptions {
409
411
  overrides?: FormSchemaOverrides;
410
412
  exclude?: string[];
411
- layout?: "vertical" | "horizontal" | "grid";
413
+ layout?: 'vertical' | 'horizontal' | 'grid';
412
414
  gridColumns?: number;
413
415
  /** Label 对齐方式 */
414
- labelAlign?: "left" | "top" | "right";
416
+ labelAlign?: 'left' | 'top' | 'right';
415
417
  /** Label 宽度(labelAlign 为 left 时有效) */
416
418
  labelWidth?: number | string;
417
419
  /** Label 栅格占位 */
@@ -450,7 +452,7 @@ interface ResolvedActionItem<T> {
450
452
  label: string;
451
453
  onClick: (row: T) => void;
452
454
  separator?: boolean;
453
- variant?: "default" | "destructive";
455
+ variant?: 'default' | 'destructive';
454
456
  }
455
457
  /**
456
458
  * 操作列配置(ResolvedActionItem 数组)
@@ -506,6 +508,8 @@ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> {
506
508
  showDefaultExport?: boolean;
507
509
  /** 选中行数变化回调(用于外层组件获知选中状态) */
508
510
  onSelectedCountChange?: (count: number) => void;
511
+ /** 选中行数据变化回调(用于外层组件获知选中行身份变化) */
512
+ onSelectedRowsChange?: (rows: z.infer<T>[]) => void;
509
513
  /** 获取选中行数据的回调(由外层组件调用) */
510
514
  getSelectedRows?: React.MutableRefObject<(() => z.infer<T>[]) | null>;
511
515
  }
@@ -529,8 +533,9 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
529
533
  enableExport,
530
534
  showDefaultExport,
531
535
  onSelectedCountChange,
536
+ onSelectedRowsChange,
532
537
  getSelectedRows
533
- }: AutoTableProps<T>): react_jsx_runtime3.JSX.Element;
538
+ }: AutoTableProps<T>): react_jsx_runtime1.JSX.Element;
534
539
  //#endregion
535
540
  //#region src/i18n/locale.d.ts
536
541
  /**
@@ -646,10 +651,16 @@ type AutoCrudDataSourceResult = AutoCrudOption[] | {
646
651
  options?: AutoCrudOption[];
647
652
  };
648
653
  type AutoCrudDataSourceLoader = (context: AutoCrudDataSourceContext) => AutoCrudDataSourceResult | Promise<AutoCrudDataSourceResult>;
649
- type AutoCrudDataSourceConfig = string | {
650
- key: string;
651
- dependsOn?: string[];
652
- resetOnChange?: boolean;
654
+ type AutoCrudDataSourceConfig = string;
655
+ type AutoCrudDataSourceRegistration = AutoCrudDataSourceLoader | {
656
+ dependencies?: string[];
657
+ reset?: boolean;
658
+ load: AutoCrudDataSourceLoader;
659
+ };
660
+ type AutoCrudDataSourceEntry = {
661
+ dependencies: string[];
662
+ reset: boolean;
663
+ load: AutoCrudDataSourceLoader;
653
664
  };
654
665
  type RegistryListener = () => void;
655
666
  declare const formComponents: {
@@ -659,17 +670,22 @@ declare const formComponents: {
659
670
  all(): Record<string, AutoCrudFormComponentConfig>;
660
671
  subscribe(listener: RegistryListener): () => void;
661
672
  };
662
- declare const dataSources: {
663
- register(name: string, value: AutoCrudDataSourceLoader): void;
673
+ declare const components: {
674
+ register(name: string, value: AutoCrudFormComponentConfig): void;
664
675
  unregister(name: string): void;
665
- get(name: string): AutoCrudDataSourceLoader | undefined;
666
- all(): Record<string, AutoCrudDataSourceLoader>;
676
+ get(name: string): AutoCrudFormComponentConfig | undefined;
677
+ all(): Record<string, AutoCrudFormComponentConfig>;
667
678
  subscribe(listener: RegistryListener): () => void;
668
679
  };
680
+ declare const dataSources: {
681
+ register(name: string, registration: AutoCrudDataSourceRegistration): void;
682
+ unregister: (name: string) => void;
683
+ get: (name: string) => AutoCrudDataSourceEntry | undefined;
684
+ all: () => Record<string, AutoCrudDataSourceEntry>;
685
+ subscribe: (listener: RegistryListener) => () => void;
686
+ };
669
687
  declare function normalizeDataSourceConfig(config: AutoCrudDataSourceConfig | undefined): {
670
688
  key: string;
671
- dependsOn: string[];
672
- resetOnChange: boolean;
673
689
  } | undefined;
674
690
  declare function normalizeOptions(result: AutoCrudDataSourceResult | undefined): AutoCrudOption[];
675
691
  //#endregion
@@ -812,6 +828,16 @@ type ToolbarCustomActionItem = {
812
828
  };
813
829
  type ToolbarActionItem = ToolbarBuiltinActionItem | ToolbarCustomActionItem;
814
830
  type ToolbarActionConfig = ToolbarActionItem[] | ((defaults: ToolbarBuiltinActionItem[]) => ToolbarActionItem[]);
831
+ interface AutoCrudToolbarContext {
832
+ crudId: string;
833
+ idKey: string;
834
+ rowIds: string[];
835
+ selectedRowIds: string[];
836
+ selectedCount: number;
837
+ openCreate?: () => void;
838
+ }
839
+ type AutoCrudToolbarResolver = (targetId: string, ownerActions: readonly ToolbarActionItem[], context: AutoCrudToolbarContext) => ToolbarActionItem[];
840
+ declare function setAutoCrudToolbarResolver(resolver: AutoCrudToolbarResolver | null): void;
815
841
  /**
816
842
  * AutoCrudTable Props 接口
817
843
  */
@@ -855,7 +881,7 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
855
881
  batchFields?: (string | BatchUpdateField)[];
856
882
  /**
857
883
  * 多选后悬浮批量操作栏配置
858
- * 用法类同 `actions` 行操作和 `toolbarActions` 顶部工具栏。
884
+ * 用法类同 `actions` 行操作和 `toolbar` 顶部工具栏。
859
885
  * 只传 custom 时保留默认批量操作;包含任意内置 type 时完全接管顺序。
860
886
  */
861
887
  batchActions?: BatchActionConfig<z.output<TSchema>>;
@@ -877,6 +903,8 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
877
903
  * 顶层工具栏操作配置
878
904
  * 用法类同 `actions` 行操作。一旦配置了包含内置 `type` 的数组,它将完全接管右侧工具栏!
879
905
  */
906
+ toolbar?: ToolbarActionConfig;
907
+ /** @deprecated Use toolbar instead. */
880
908
  toolbarActions?: ToolbarActionConfig;
881
909
  /**
882
910
  * 权限配置
@@ -923,6 +951,7 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
923
951
  * 高级 CRUD 表格组件,封装了完整的增删改查流程
924
952
  */
925
953
  declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
954
+ id,
926
955
  title,
927
956
  description,
928
957
  schema,
@@ -932,10 +961,11 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
932
961
  form: formConfig,
933
962
  permissions,
934
963
  actions: actionItems,
964
+ toolbar,
935
965
  toolbarActions,
936
966
  locale: localeProp,
937
967
  onCreate
938
- }: AutoCrudTableProps<TSchema>): react_jsx_runtime3.JSX.Element;
968
+ }: AutoCrudTableProps<TSchema>): react_jsx_runtime1.JSX.Element;
939
969
  //#endregion
940
970
  //#region src/components/auto-crud/auto-form.d.ts
941
971
  interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
@@ -967,7 +997,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
967
997
  labelAlign,
968
998
  labelWidth,
969
999
  showSubmitButton
970
- }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime3.JSX.Element;
1000
+ }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime1.JSX.Element;
971
1001
  declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
972
1002
  ref?: React.Ref<AutoFormRef>;
973
1003
  }) => ReturnType<typeof AutoFormInner>;
@@ -1209,7 +1239,7 @@ declare const filterItemSchema: z.ZodObject<{
1209
1239
  type FilterItemSchema = z.infer<typeof filterItemSchema>;
1210
1240
  //#endregion
1211
1241
  //#region src/types/data-table.d.ts
1212
- declare module "@tanstack/react-table" {
1242
+ declare module '@tanstack/react-table' {
1213
1243
  interface TableMeta<TData extends RowData> {
1214
1244
  queryKeys?: QueryKeys;
1215
1245
  queryStateOptions?: UrlStateOptions;
@@ -1224,7 +1254,7 @@ declare module "@tanstack/react-table" {
1224
1254
  unit?: string;
1225
1255
  icon?: React.FC<React.SVGProps<SVGSVGElement>>;
1226
1256
  /** 控制在哪些筛选模式下显示(未设置则在所有模式显示) */
1227
- modes?: Array<"simple" | "advanced" | "command">;
1257
+ modes?: Array<'simple' | 'advanced' | 'command'>;
1228
1258
  }
1229
1259
  }
1230
1260
  interface QueryKeys {
@@ -1241,10 +1271,10 @@ interface Option {
1241
1271
  count?: number;
1242
1272
  icon?: React.FC<React.SVGProps<SVGSVGElement>>;
1243
1273
  }
1244
- type FilterOperator = DataTableConfig["operators"][number];
1245
- type FilterVariant$1 = DataTableConfig["filterVariants"][number];
1246
- type JoinOperator = DataTableConfig["joinOperators"][number];
1247
- interface ExtendedColumnSort<TData> extends Omit<ColumnSort, "id"> {
1274
+ type FilterOperator = DataTableConfig['operators'][number];
1275
+ type FilterVariant$1 = DataTableConfig['filterVariants'][number];
1276
+ type JoinOperator = DataTableConfig['joinOperators'][number];
1277
+ interface ExtendedColumnSort<TData> extends Omit<ColumnSort, 'id'> {
1248
1278
  id: Extract<keyof TData, string>;
1249
1279
  }
1250
1280
  interface ExtendedColumnFilter<TData> extends FilterItemSchema {
@@ -1252,7 +1282,7 @@ interface ExtendedColumnFilter<TData> extends FilterItemSchema {
1252
1282
  }
1253
1283
  interface DataTableRowAction<TData> {
1254
1284
  row: Row<TData>;
1255
- variant: "update" | "delete";
1285
+ variant: 'update' | 'delete';
1256
1286
  }
1257
1287
  //#endregion
1258
1288
  //#region src/components/auto-crud/auto-table-simple-filters.d.ts
@@ -1269,7 +1299,7 @@ declare function AutoTableSimpleFilters<TData>({
1269
1299
  filters: externalFilters,
1270
1300
  onFiltersChange,
1271
1301
  leading
1272
- }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime3.JSX.Element | null;
1302
+ }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime1.JSX.Element | null;
1273
1303
  //#endregion
1274
1304
  //#region src/components/auto-crud/form-modal.d.ts
1275
1305
  type ModalVariant = "dialog" | "sheet";
@@ -1311,7 +1341,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
1311
1341
  labelAlign,
1312
1342
  labelWidth,
1313
1343
  className
1314
- }: CrudFormModalProps<T>): react_jsx_runtime3.JSX.Element;
1344
+ }: CrudFormModalProps<T>): react_jsx_runtime1.JSX.Element;
1315
1345
  //#endregion
1316
1346
  //#region src/components/auto-crud/import-dialog.d.ts
1317
1347
  interface ImportDialogProps {
@@ -1333,7 +1363,7 @@ declare function ImportDialog({
1333
1363
  columns,
1334
1364
  title,
1335
1365
  locale
1336
- }: ImportDialogProps): react_jsx_runtime3.JSX.Element;
1366
+ }: ImportDialogProps): react_jsx_runtime1.JSX.Element;
1337
1367
  //#endregion
1338
1368
  //#region src/components/auto-crud/export-dialog.d.ts
1339
1369
  type ExportMode = "selected" | "filtered";
@@ -1353,7 +1383,7 @@ declare function ExportDialog({
1353
1383
  selectedCount,
1354
1384
  onExport,
1355
1385
  canExportFiltered
1356
- }: ExportDialogProps): react_jsx_runtime3.JSX.Element;
1386
+ }: ExportDialogProps): react_jsx_runtime1.JSX.Element;
1357
1387
  //#endregion
1358
1388
  //#region src/components/data-table/data-table.d.ts
1359
1389
  interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
@@ -1366,7 +1396,7 @@ declare function DataTable<TData>({
1366
1396
  children,
1367
1397
  className,
1368
1398
  ...props
1369
- }: DataTableProps<TData>): react_jsx_runtime3.JSX.Element;
1399
+ }: DataTableProps<TData>): react_jsx_runtime1.JSX.Element;
1370
1400
  //#endregion
1371
1401
  //#region src/components/data-table/data-table-advanced-toolbar.d.ts
1372
1402
  interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
@@ -1377,7 +1407,7 @@ declare function DataTableAdvancedToolbar<TData>({
1377
1407
  children,
1378
1408
  className,
1379
1409
  ...props
1380
- }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
1410
+ }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime1.JSX.Element;
1381
1411
  //#endregion
1382
1412
  //#region src/components/data-table/data-table-column-header.d.ts
1383
1413
  interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
@@ -1389,7 +1419,7 @@ declare function DataTableColumnHeader<TData, TValue>({
1389
1419
  label,
1390
1420
  className,
1391
1421
  ...props
1392
- }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
1422
+ }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime1.JSX.Element;
1393
1423
  //#endregion
1394
1424
  //#region src/components/data-table/data-table-faceted-filter.d.ts
1395
1425
  interface DataTableFacetedFilterProps<TData, TValue> {
@@ -1403,7 +1433,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
1403
1433
  title,
1404
1434
  options,
1405
1435
  multiple
1406
- }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
1436
+ }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime1.JSX.Element;
1407
1437
  //#endregion
1408
1438
  //#region src/components/data-table/data-table-pagination.d.ts
1409
1439
  interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
@@ -1415,7 +1445,7 @@ declare function DataTablePagination<TData>({
1415
1445
  pageSizeOptions,
1416
1446
  className,
1417
1447
  ...props
1418
- }: DataTablePaginationProps<TData>): react_jsx_runtime3.JSX.Element;
1448
+ }: DataTablePaginationProps<TData>): react_jsx_runtime1.JSX.Element;
1419
1449
  //#endregion
1420
1450
  //#region src/components/data-table/data-table-toolbar.d.ts
1421
1451
  interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
@@ -1426,7 +1456,7 @@ declare function DataTableToolbar<TData>({
1426
1456
  children,
1427
1457
  className,
1428
1458
  ...props
1429
- }: DataTableToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
1459
+ }: DataTableToolbarProps<TData>): react_jsx_runtime1.JSX.Element;
1430
1460
  //#endregion
1431
1461
  //#region src/components/data-table/data-table-view-options.d.ts
1432
1462
  interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
@@ -1437,7 +1467,7 @@ declare function DataTableViewOptions<TData>({
1437
1467
  table,
1438
1468
  disabled,
1439
1469
  ...props
1440
- }: DataTableViewOptionsProps<TData>): react_jsx_runtime3.JSX.Element;
1470
+ }: DataTableViewOptionsProps<TData>): react_jsx_runtime1.JSX.Element;
1441
1471
  //#endregion
1442
1472
  //#region src/components/ui/multi-combobox.d.ts
1443
1473
  interface MultiComboboxOption {
@@ -1814,4 +1844,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
1814
1844
  */
1815
1845
  declare function downloadCSVTemplate(headers: string[], filename?: string): void;
1816
1846
  //#endregion
1817
- export { type ActionItem, type ActionsColumnConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceLoader, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, AutoCrudTable, type AutoCrudTableProps, AutoForm, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, 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 FieldOption, 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, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, 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, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setSearchParams, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
1847
+ export { type ActionItem, type ActionsColumnConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, 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 FieldOption, 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, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, SchemaAdapter, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, cn, coerceRowValues, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setAutoCrudToolbarResolver, setSearchParams, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };