@wordrhyme/auto-crud 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,11 +1,12 @@
1
1
  import * as react_jsx_runtime1 from "react/jsx-runtime";
2
2
  import { z } from "zod";
3
+ import { JsonSchemaFormScope } from "@wordrhyme/formily-shadcn";
3
4
  import * as _tanstack_react_table0 from "@tanstack/react-table";
4
5
  import { Column, ColumnDef, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
5
6
  import * as React$1 from "react";
6
- import { ComponentProps, ReactNode } from "react";
7
7
  import { ISchema } from "@formily/json-schema";
8
- import { Command, DropdownMenuTrigger, PopoverContent } from "@pixpilot/shadcn";
8
+ import { DropdownMenuTrigger, PopoverContent } from "@wordrhyme/shadcn";
9
+ import { MultiCombobox, MultiComboboxOption, MultiComboboxProps, MultiComboboxTriggerRenderProps, Select, SelectMode, SelectOption, SelectProps, SelectSearchableDynamicProps, SelectSearchableMultipleProps, SelectSearchableProps, SelectSearchableSingleProps, SelectSimpleProps, SelectTriggerRenderProps } from "@wordrhyme/shadcn-ui";
9
10
  import { ClassValue } from "clsx";
10
11
 
11
12
  //#region src/hooks/use-auto-crud-resource.d.ts
@@ -152,6 +153,8 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
152
153
  deleteMany: (rows: TListItem[]) => void;
153
154
  updateMany: (rows: TListItem[], data: Record<string, unknown>) => void;
154
155
  setVariant: (variant: ModalVariant$1) => void;
156
+ /** 刷新当前列表数据 */
157
+ refresh?: () => Promise<unknown>;
155
158
  /** 导入数据(router 有 import 路由时自动可用) */
156
159
  import: ((rows: Record<string, unknown>[]) => Promise<ImportResult>) | null;
157
160
  /** 导出筛选结果(router 有 export procedure 或传入 exportFetcher 时自动可用)。导出选中行由 AutoCrudTable 内部处理 */
@@ -341,6 +344,12 @@ type BatchCustomActionItem<TData> = BatchActionMeta & {
341
344
  };
342
345
  type BatchActionItem<TData> = BatchBuiltinActionItem<TData> | BatchCustomActionItem<TData>;
343
346
  type BatchActionConfig<TData> = BatchActionItem<TData>[] | ((defaults: BatchBuiltinActionItem<TData>[]) => BatchActionItem<TData>[]);
347
+ interface BatchDeleteConfirmation {
348
+ title: string;
349
+ description: (count: number) => string;
350
+ cancel: string;
351
+ confirm: string;
352
+ }
344
353
  interface AutoTableActionBarProps<TData> {
345
354
  table: Table<TData>;
346
355
  onDeleteSelected?: (rows: TData[]) => void;
@@ -358,6 +367,8 @@ interface AutoTableActionBarProps<TData> {
358
367
  extraActions?: React$1.ReactNode;
359
368
  /** 批量操作配置,支持和行操作/顶部工具栏一致的顺序接管语义 */
360
369
  actions?: BatchActionConfig<TData>;
370
+ /** 批量删除二次确认文案 */
371
+ deleteConfirmation?: BatchDeleteConfirmation;
361
372
  }
362
373
  declare function AutoTableActionBar<TData>({
363
374
  table,
@@ -368,7 +379,8 @@ declare function AutoTableActionBar<TData>({
368
379
  showDefaultExport,
369
380
  enableDelete,
370
381
  extraActions,
371
- actions
382
+ actions,
383
+ deleteConfirmation
372
384
  }: AutoTableActionBarProps<TData>): react_jsx_runtime1.JSX.Element;
373
385
  //#endregion
374
386
  //#region src/lib/schema-bridge/types.d.ts
@@ -507,6 +519,8 @@ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> {
507
519
  actionBarExtra?: React.ReactNode;
508
520
  /** 批量悬浮操作配置 */
509
521
  actionBarActions?: BatchActionConfig<z.infer<T>>;
522
+ /** 批量删除二次确认文案 */
523
+ deleteConfirmation?: BatchDeleteConfirmation;
510
524
  /** 初始排序 */
511
525
  initialSorting?: any[];
512
526
  /** 是否启用导出功能 (默认 true) */
@@ -536,6 +550,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
536
550
  batchUpdateFields,
537
551
  actionBarExtra,
538
552
  actionBarActions,
553
+ deleteConfirmation,
539
554
  initialSorting,
540
555
  enableExport,
541
556
  showDefaultExport,
@@ -557,6 +572,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
557
572
  */
558
573
  interface AutoCrudLocale {
559
574
  toolbar: {
575
+ refresh: string;
560
576
  create: string;
561
577
  import: string;
562
578
  export: string;
@@ -590,6 +606,12 @@ interface AutoCrudLocale {
590
606
  confirm: string;
591
607
  confirming: string;
592
608
  };
609
+ bulkDeleteModal: {
610
+ title: string;
611
+ description: (count: number) => string;
612
+ cancel: string;
613
+ confirm: string;
614
+ };
593
615
  importDialog: {
594
616
  title: string;
595
617
  uploadDescription: string;
@@ -650,11 +672,14 @@ type AutoCrudOption = {
650
672
  };
651
673
  type AutoCrudDataSourceContext = {
652
674
  field: string;
675
+ page?: number;
676
+ pageSize?: number;
653
677
  search?: string;
654
678
  values?: Record<string, unknown>;
655
679
  signal?: AbortSignal;
656
680
  };
657
681
  type AutoCrudDataSourceResult = AutoCrudOption[] | {
682
+ hasMore?: boolean;
658
683
  options?: AutoCrudOption[];
659
684
  };
660
685
  type AutoCrudDataSourceLoader = (context: AutoCrudDataSourceContext) => AutoCrudDataSourceResult | Promise<AutoCrudDataSourceResult>;
@@ -662,11 +687,19 @@ type AutoCrudDataSourceConfig = string;
662
687
  type AutoCrudDataSourceRegistration = AutoCrudDataSourceLoader | {
663
688
  dependencies?: string[];
664
689
  reset?: boolean;
690
+ search?: boolean;
691
+ debounceMs?: number;
692
+ loadMore?: boolean;
693
+ pageSize?: number;
665
694
  load: AutoCrudDataSourceLoader;
666
695
  };
667
696
  type AutoCrudDataSourceEntry = {
668
697
  dependencies: string[];
669
698
  reset: boolean;
699
+ search: boolean;
700
+ debounceMs: number;
701
+ loadMore: boolean;
702
+ pageSize: number;
670
703
  load: AutoCrudDataSourceLoader;
671
704
  };
672
705
  type RegistryListener$1 = () => void;
@@ -839,8 +872,9 @@ type AutoCrudActionConfig<T> = RowActionConfig<T> | AutoCrudActionsConfig<T>;
839
872
  /**
840
873
  * 顶部工具栏内置操作项
841
874
  */
875
+ type ToolbarBuiltinActionType = 'refresh' | 'create' | 'import' | 'export';
842
876
  type ToolbarBuiltinActionItem = ActionMeta & {
843
- type: 'create' | 'import' | 'export';
877
+ type: ToolbarBuiltinActionType;
844
878
  /** 替代默认的行为 */
845
879
  onClick?: () => void;
846
880
  /** 替代默认的标签文本 */
@@ -866,6 +900,8 @@ interface AutoCrudToolbarContext {
866
900
  rowIds: string[];
867
901
  selectedRowIds: string[];
868
902
  selectedCount: number;
903
+ refresh?: () => Promise<unknown>;
904
+ isRefreshing: boolean;
869
905
  openCreate?: () => void;
870
906
  }
871
907
  type AutoCrudToolbarResolver = (targetId: string, ownerActions: readonly ToolbarActionItem[], context: AutoCrudToolbarContext) => ToolbarActionItem[];
@@ -925,6 +961,8 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
925
961
  form?: {
926
962
  /** 表单覆盖配置(兼容旧 API,优先级低于 fieldOverrides) */
927
963
  overrides?: Record<string, any>;
964
+ /** Formily schema expression/reaction scope */
965
+ scope?: JsonSchemaFormScope;
928
966
  /** 表单列数 */
929
967
  columns?: number;
930
968
  /** 弹窗自定义容器类名(支持控制大小、最大高度等) */
@@ -1006,7 +1044,12 @@ interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
1006
1044
  schema: T;
1007
1045
  initialValues?: Partial<z.infer<T>>;
1008
1046
  onSubmit: (values: z.infer<T>) => void | Promise<void>;
1047
+ /** 统一字段配置,推荐用于描述 auto-crud 字段级表单行为 */
1048
+ fields?: Fields;
1049
+ /** Formily 字段 schema 覆盖配置,保留兼容旧 API */
1009
1050
  overrides?: FormSchemaOverrides;
1051
+ /** Formily schema expression/reaction scope */
1052
+ scope?: JsonSchemaFormScope;
1010
1053
  mode?: 'create' | 'edit';
1011
1054
  loading?: boolean;
1012
1055
  gridColumns?: number;
@@ -1024,7 +1067,9 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
1024
1067
  schema: zodSchema,
1025
1068
  initialValues,
1026
1069
  onSubmit,
1070
+ fields,
1027
1071
  overrides,
1072
+ scope: scopeProp,
1028
1073
  mode,
1029
1074
  loading,
1030
1075
  gridColumns,
@@ -1289,6 +1334,20 @@ declare module '@tanstack/react-table' {
1289
1334
  icon?: React.FC<React.SVGProps<SVGSVGElement>>;
1290
1335
  /** 控制在哪些筛选模式下显示(未设置则在所有模式显示) */
1291
1336
  modes?: Array<'simple' | 'advanced' | 'command'>;
1337
+ /** 内部:远程筛选选项搜索值 */
1338
+ autoCrudFilterSearchValue?: string;
1339
+ /** 内部:远程筛选选项搜索回调 */
1340
+ autoCrudFilterOnSearch?: (value: string) => void;
1341
+ /** 内部:是否启用本地选项过滤 */
1342
+ autoCrudFilterShouldFilter?: boolean;
1343
+ /** 内部:远程筛选当前弹窗选项,和稳定标签缓存分离 */
1344
+ autoCrudFilterOptions?: Option[];
1345
+ /** 内部:远程筛选是否还有更多选项 */
1346
+ autoCrudFilterHasMore?: boolean;
1347
+ /** 内部:远程筛选是否正在加载 */
1348
+ autoCrudFilterLoading?: boolean;
1349
+ /** 内部:远程筛选弹窗滚动回调 */
1350
+ autoCrudFilterOnPopupScroll?: React.UIEventHandler<HTMLElement>;
1292
1351
  }
1293
1352
  }
1294
1353
  interface QueryKeys {
@@ -1342,18 +1401,19 @@ type ModalVariant = "dialog" | "sheet";
1342
1401
  interface CrudFormModalProps<T extends z.ZodObject<z.ZodRawShape>> {
1343
1402
  open: boolean;
1344
1403
  onOpenChange: (open: boolean) => void;
1345
- mode: "create" | "edit";
1404
+ mode: 'create' | 'edit';
1346
1405
  schema: T;
1347
1406
  initialValues?: Partial<z.infer<T>>;
1348
1407
  onSubmit: (values: z.infer<T>) => void | Promise<void>;
1349
1408
  loading?: boolean;
1350
1409
  variant?: ModalVariant;
1351
1410
  overrides?: FormSchemaOverrides;
1411
+ scope?: JsonSchemaFormScope;
1352
1412
  title?: string;
1353
- locale?: AutoCrudLocale["formModal"];
1413
+ locale?: AutoCrudLocale['formModal'];
1354
1414
  gridColumns?: number;
1355
1415
  /** Label 对齐方式 */
1356
- labelAlign?: "left" | "top" | "right";
1416
+ labelAlign?: 'left' | 'top' | 'right';
1357
1417
  /** Label 宽度(labelAlign 为 left 时有效) */
1358
1418
  labelWidth?: number | string;
1359
1419
  /** 弹窗自定义样式 */
@@ -1369,6 +1429,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
1369
1429
  loading,
1370
1430
  variant,
1371
1431
  overrides,
1432
+ scope,
1372
1433
  title,
1373
1434
  locale,
1374
1435
  gridColumns,
@@ -1388,7 +1449,7 @@ interface ImportDialogProps {
1388
1449
  /** 对话框标题(优先于 locale.title) */
1389
1450
  title?: string;
1390
1451
  /** 语言包,默认 zh-CN */
1391
- locale?: AutoCrudLocale["importDialog"];
1452
+ locale?: AutoCrudLocale['importDialog'];
1392
1453
  }
1393
1454
  declare function ImportDialog({
1394
1455
  open,
@@ -1503,47 +1564,6 @@ declare function DataTableViewOptions<TData>({
1503
1564
  ...props
1504
1565
  }: DataTableViewOptionsProps<TData>): react_jsx_runtime1.JSX.Element;
1505
1566
  //#endregion
1506
- //#region src/components/ui/multi-combobox.d.ts
1507
- interface MultiComboboxOption {
1508
- value: string;
1509
- label: ReactNode;
1510
- searchText?: string | string[];
1511
- keywords?: string[];
1512
- count?: number;
1513
- disabled?: boolean;
1514
- icon?: React$1.ComponentType<{
1515
- className?: string;
1516
- }>;
1517
- }
1518
- interface MultiComboboxTriggerRenderProps {
1519
- open: boolean;
1520
- selectedOptions: MultiComboboxOption[];
1521
- selectedValues: string[];
1522
- clearSelection: (event?: React$1.MouseEvent) => void;
1523
- disabled?: boolean;
1524
- readOnly?: boolean;
1525
- }
1526
- interface MultiComboboxProps extends Omit<ComponentProps<typeof Command>, 'value' | 'defaultValue' | 'onChange' | 'onValueChange'> {
1527
- value?: string[];
1528
- defaultValue?: string[];
1529
- onChange?: (value: string[]) => void;
1530
- options?: MultiComboboxOption[];
1531
- placeholder?: string;
1532
- searchPlaceholder?: string;
1533
- emptyText?: string;
1534
- clearText?: string;
1535
- selectedText?: string;
1536
- selectionMode?: 'single' | 'multiple';
1537
- disabled?: boolean;
1538
- readOnly?: boolean;
1539
- className?: string;
1540
- contentClassName?: string;
1541
- triggerClassName?: string;
1542
- matchTriggerWidth?: boolean;
1543
- renderTrigger?: (props: MultiComboboxTriggerRenderProps) => ReactNode;
1544
- }
1545
- declare const MultiCombobox: React$1.FC<MultiComboboxProps>;
1546
- //#endregion
1547
1567
  //#region src/lib/crud-actions.d.ts
1548
1568
  type CrudActionZone = 'toolbar' | 'row' | 'batch';
1549
1569
  type CrudActionBase = {
@@ -1917,4 +1937,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
1917
1937
  */
1918
1938
  declare function downloadCSVTemplate(headers: string[], filename?: string): void;
1919
1939
  //#endregion
1920
- export { type ActionConfig, type ActionItem, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudRowActionContext, 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, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, 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, type RowActionConfig, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, 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, crudActions, 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, setToolbarResolver, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
1940
+ export { type ActionConfig, type ActionItem, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudRowActionContext, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, 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, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, 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, type RowActionConfig, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, cn, coerceRowValues, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, 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, setToolbarResolver, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };