@wordrhyme/auto-crud 0.5.0 → 1.0.0

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,4 +1,4 @@
1
- import * as react_jsx_runtime2 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime3 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";
@@ -86,6 +86,33 @@ interface UseAutoCrudResourceOptions<TSchema extends z.ZodObject<z.ZodRawShape>,
86
86
  * - ToastAdapter: 注入自定义 toast 实现
87
87
  */
88
88
  toast?: ToastAdapter | false;
89
+ /**
90
+ * 自定义导出数据获取函数(escape hatch)
91
+ *
92
+ * 通常不需要传此参数:
93
+ * - 导出选中行:纯客户端,零配置
94
+ * - 导出筛选结果:router 有 export procedure 时自动可用
95
+ *
96
+ * 仅当需要完全自定义导出逻辑时才使用(如队列导出、自定义接口等)
97
+ * 传入后优先级高于 router.export
98
+ */
99
+ exportFetcher?: (params: any) => Promise<{
100
+ data: Record<string, unknown>[];
101
+ total: number;
102
+ hasMore: boolean;
103
+ }>;
104
+ }
105
+ /**
106
+ * 导入结果类型(与服务端保持一致)
107
+ */
108
+ interface ImportResult {
109
+ success: number;
110
+ updated: number;
111
+ skipped: number;
112
+ failed: Array<{
113
+ row: number;
114
+ errors: string[];
115
+ }>;
89
116
  }
90
117
  /**
91
118
  * Hook 返回值类型
@@ -103,6 +130,7 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
103
130
  isCreating: boolean;
104
131
  isUpdating: boolean;
105
132
  isDeleting: boolean;
133
+ isImporting: boolean;
106
134
  };
107
135
  handlers: {
108
136
  openCreate: () => void;
@@ -117,10 +145,15 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
117
145
  deleteMany: (rows: TListItem[]) => void;
118
146
  updateMany: (rows: TListItem[], data: Record<string, unknown>) => void;
119
147
  setVariant: (variant: ModalVariant$1) => void;
148
+ /** 导入数据(router 有 import 路由时自动可用) */
149
+ import: ((rows: Record<string, unknown>[]) => Promise<ImportResult>) | null;
150
+ /** 导出筛选结果(router 有 export procedure 或传入 exportFetcher 时自动可用)。导出选中行由 AutoCrudTable 内部处理 */
151
+ export: (() => Promise<Record<string, unknown>[]>) | null;
120
152
  };
121
153
  }
122
154
  /**
123
155
  * tRPC Router 接口定义(宽松类型以兼容实际 tRPC router)
156
+ * import 为可选 — 传入 router 时自动检测是否存在
124
157
  */
125
158
  interface CrudRouter {
126
159
  list: {
@@ -141,6 +174,27 @@ interface CrudRouter {
141
174
  updateMany?: {
142
175
  useMutation: (opts?: any) => any;
143
176
  };
177
+ /** 导入路由(mutation,由 createCrudRouter 自动生成) */
178
+ import?: {
179
+ useMutation: (opts?: any) => any;
180
+ };
181
+ /** 导出路由(query,由 createCrudRouter 自动生成) */
182
+ export?: {
183
+ useQuery: (input?: any, opts?: any) => any;
184
+ };
185
+ }
186
+ /**
187
+ * 自动生成的查询参数(由内部 URL 状态管理生成)
188
+ */
189
+ interface AutoQueryParams {
190
+ page: number;
191
+ perPage: number;
192
+ sort: Array<{
193
+ id: string;
194
+ desc: boolean;
195
+ }>;
196
+ filters: any[];
197
+ joinOperator: "and" | "or";
144
198
  }
145
199
  /**
146
200
  * Hook 配置参数
@@ -148,10 +202,24 @@ interface CrudRouter {
148
202
  interface UseAutoCrudResourceParams<TSchema extends z.ZodObject<z.ZodRawShape>, TListItem> {
149
203
  /** tRPC router (如 trpc.tasks) */
150
204
  router: CrudRouter;
151
- /** 列表查询参数 */
152
- queryInput?: any;
153
205
  /** Zod schema */
154
206
  schema: TSchema;
207
+ /**
208
+ * 查询参数变换函数
209
+ *
210
+ * 默认零配置:hook 内部自动管理 URL 状态(分页、排序、筛选),
211
+ * 传入此函数可注入额外参数或修改自动生成的参数。
212
+ *
213
+ * @example
214
+ * ```tsx
215
+ * // 注入租户 ID
216
+ * query: (params) => ({ ...params, tenantId: currentTenant.id })
217
+ *
218
+ * // 覆盖默认分页
219
+ * query: (params) => ({ ...params, perPage: 20 })
220
+ * ```
221
+ */
222
+ query?: (params: AutoQueryParams) => Record<string, unknown>;
155
223
  /** 其他配置选项 */
156
224
  options?: UseAutoCrudResourceOptions<TSchema, TListItem>;
157
225
  }
@@ -160,7 +228,8 @@ interface UseAutoCrudResourceParams<TSchema extends z.ZodObject<z.ZodRawShape>,
160
228
  */
161
229
  declare function useAutoCrudResource<TSchema extends z.ZodObject<z.ZodRawShape>, TListItem = z.output<TSchema>>({
162
230
  router,
163
- queryInput,
231
+ schema,
232
+ query: queryTransform,
164
233
  options
165
234
  }: UseAutoCrudResourceParams<TSchema, TListItem>): UseAutoCrudResourceReturn<TSchema, TListItem>;
166
235
  //#endregion
@@ -178,6 +247,8 @@ interface CrudOperationPermissions {
178
247
  delete?: boolean;
179
248
  /** 是否允许导出 */
180
249
  export?: boolean;
250
+ /** 是否允许导入 */
251
+ import?: boolean;
181
252
  }
182
253
  /**
183
254
  * AutoCrudTable 权限配置
@@ -243,7 +314,7 @@ declare function AutoTableActionBar<TData>({
243
314
  enableExport,
244
315
  enableDelete,
245
316
  extraActions
246
- }: AutoTableActionBarProps<TData>): react_jsx_runtime2.JSX.Element;
317
+ }: AutoTableActionBarProps<TData>): react_jsx_runtime3.JSX.Element;
247
318
  //#endregion
248
319
  //#region src/lib/schema-bridge/types.d.ts
249
320
  /**
@@ -369,6 +440,10 @@ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> {
369
440
  initialSorting?: any[];
370
441
  /** 是否启用导出功能 (默认 true) */
371
442
  enableExport?: boolean;
443
+ /** 选中行数变化回调(用于外层组件获知选中状态) */
444
+ onSelectedCountChange?: (count: number) => void;
445
+ /** 获取选中行数据的回调(由外层组件调用) */
446
+ getSelectedRows?: React.MutableRefObject<(() => z.infer<T>[]) | null>;
372
447
  }
373
448
  declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
374
449
  schema,
@@ -385,10 +460,37 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
385
460
  batchUpdateFields,
386
461
  actionBarExtra,
387
462
  initialSorting,
388
- enableExport
389
- }: AutoTableProps<T>): react_jsx_runtime2.JSX.Element;
463
+ enableExport,
464
+ onSelectedCountChange,
465
+ getSelectedRows
466
+ }: AutoTableProps<T>): react_jsx_runtime3.JSX.Element;
390
467
  //#endregion
391
468
  //#region src/components/auto-crud/auto-crud-table.d.ts
469
+ /**
470
+ * 筛选器独立配置
471
+ * 可独立于 table.meta 配置筛选器行为
472
+ */
473
+ interface FilterConfig {
474
+ /** 是否启用筛选(默认跟随 table.meta.variant 推断) */
475
+ enabled?: boolean;
476
+ /** 筛选器类型 */
477
+ variant?: "text" | "number" | "range" | "date" | "dateRange" | "boolean" | "select" | "multiSelect";
478
+ /** select/multiSelect 的选项列表 */
479
+ options?: Array<{
480
+ label: string;
481
+ value: string;
482
+ count?: number;
483
+ icon?: React$1.FC<React$1.SVGProps<SVGSVGElement>>;
484
+ }>;
485
+ /** range 的最小/最大值 */
486
+ range?: [number, number];
487
+ /** number 的单位 */
488
+ unit?: string;
489
+ /** 过滤器占位符 */
490
+ placeholder?: string;
491
+ /** 是否在筛选栏中隐藏(隐藏筛选但不影响表格列显示) */
492
+ hidden?: boolean;
493
+ }
392
494
  /**
393
495
  * 统一字段配置
394
496
  * 支持共用配置 + 表格/表单特定配置
@@ -398,6 +500,11 @@ interface Field {
398
500
  label?: string;
399
501
  /** 是否隐藏(表格和表单都隐藏) */
400
502
  hidden?: boolean;
503
+ /**
504
+ * 筛选器独立配置
505
+ * 独立于 table.meta 控制筛选器行为,不影响表格列显示/隐藏
506
+ */
507
+ filter?: FilterConfig;
401
508
  /** 表格特定配置 */
402
509
  table?: {
403
510
  /** 是否在表格中隐藏 */
@@ -468,9 +575,9 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
468
575
  /** 扩展点 */
469
576
  slots?: {
470
577
  /** 工具栏左侧插槽 */
471
- toolbarStart?: React.ReactNode;
578
+ toolbarStart?: React$1.ReactNode;
472
579
  /** 工具栏右侧插槽 */
473
- toolbarEnd?: React.ReactNode;
580
+ toolbarEnd?: React$1.ReactNode;
474
581
  /** 自定义行操作 */
475
582
  rowActions?: (row: z.output<TSchema>) => Array<{
476
583
  label: string;
@@ -489,6 +596,7 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
489
596
  * update: user.role === 'admin' || user.role === 'editor',
490
597
  * delete: user.role === 'admin',
491
598
  * export: true,
599
+ * import: true,
492
600
  * },
493
601
  * deny: user.role === 'user' ? ['salary', 'ssn'] : [],
494
602
  * }), [user.role]);
@@ -513,7 +621,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
513
621
  form: formConfig,
514
622
  slots,
515
623
  permissions
516
- }: AutoCrudTableProps<TSchema>): react_jsx_runtime2.JSX.Element;
624
+ }: AutoCrudTableProps<TSchema>): react_jsx_runtime3.JSX.Element;
517
625
  //#endregion
518
626
  //#region src/components/auto-crud/auto-form.d.ts
519
627
  interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
@@ -545,11 +653,87 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
545
653
  labelAlign,
546
654
  labelWidth,
547
655
  showSubmitButton
548
- }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime2.JSX.Element;
656
+ }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime3.JSX.Element;
549
657
  declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
550
658
  ref?: React.Ref<AutoFormRef>;
551
659
  }) => ReturnType<typeof AutoFormInner>;
552
660
  //#endregion
661
+ //#region src/hooks/use-url-state.d.ts
662
+ /**
663
+ * URL 状态管理 Hook - 替代 nuqs
664
+ * 将 React 状态同步到 URL query string
665
+ *
666
+ * 架构说明:
667
+ * - 使用 queueMicrotask 延迟 URL 更新,确保在渲染完成后执行
668
+ * - 符合 React 渲染规则,不会触发 "Cannot update a component while rendering" 错误
669
+ */
670
+ interface UrlStateOptions {
671
+ /** 历史记录模式: push 添加新记录, replace 替换当前记录 */
672
+ history?: "push" | "replace";
673
+ /** 是否浅层更新(不触发页面刷新) */
674
+ shallow?: boolean;
675
+ /** 节流时间(毫秒) */
676
+ throttleMs?: number;
677
+ /** 防抖时间(毫秒) */
678
+ debounceMs?: number;
679
+ /** 当值等于默认值时是否清除 URL 参数 */
680
+ clearOnDefault?: boolean;
681
+ /** 滚动到顶部 */
682
+ scroll?: boolean;
683
+ /** React transition */
684
+ startTransition?: React$1.TransitionStartFunction;
685
+ }
686
+ interface Parser<T> {
687
+ parse: (value: string) => T;
688
+ serialize: (value: T) => string;
689
+ }
690
+ declare const parseAsInteger: Parser<number> & {
691
+ withDefault: (defaultValue: number) => Parser<number> & {
692
+ defaultValue: number;
693
+ };
694
+ };
695
+ declare const parseAsString: Parser<string> & {
696
+ withDefault: (defaultValue: string) => Parser<string> & {
697
+ defaultValue: string;
698
+ };
699
+ };
700
+ declare function parseAsStringEnum<T extends string>(validValues: readonly T[]): Parser<T | null> & {
701
+ withDefault: (defaultValue: T) => Parser<T> & {
702
+ defaultValue: T;
703
+ };
704
+ };
705
+ declare function parseAsArrayOf<T>(itemParser: Parser<T>, separator?: string): Parser<T[]> & {
706
+ withDefault: (defaultValue: T[]) => Parser<T[]> & {
707
+ defaultValue: T[];
708
+ };
709
+ };
710
+ declare function getUrlParams(): URLSearchParams;
711
+ declare function setSearchParams(params: URLSearchParams, options?: Pick<UrlStateOptions, "history" | "scroll">): void;
712
+ /**
713
+ * 单个 URL 状态参数
714
+ */
715
+ declare function useUrlState<T>(key: string, parser: Parser<T> & {
716
+ defaultValue?: T;
717
+ }, options?: UrlStateOptions): [T, (value: T | ((prev: T) => T)) => void];
718
+ /**
719
+ * 多个 URL 状态参数
720
+ */
721
+ declare function useUrlStates<T extends Record<string, unknown>>(parsers: { [K in keyof T]: Parser<T[K]> & {
722
+ defaultValue?: T[K];
723
+ } }, options?: UrlStateOptions): [T, (values: Partial<T>) => void];
724
+ /**
725
+ * nuqs 兼容层 - useQueryState
726
+ */
727
+ declare function useQueryState<T>(key: string, parser: Parser<T> & {
728
+ defaultValue?: T;
729
+ }, options?: UrlStateOptions): [T, (value: T | ((prev: T) => T)) => Promise<URLSearchParams>];
730
+ /**
731
+ * nuqs 兼容层 - useQueryStates
732
+ */
733
+ declare function useQueryStates<T extends Record<string, unknown>>(parsers: { [K in keyof T]: Parser<T[K]> & {
734
+ defaultValue?: T[K];
735
+ } }, options?: UrlStateOptions): [T, (values: Partial<T>) => Promise<URLSearchParams>];
736
+ //#endregion
553
737
  //#region src/config/data-table.d.ts
554
738
  type DataTableConfig = typeof dataTableConfig;
555
739
  declare const dataTableConfig: {
@@ -676,82 +860,6 @@ declare const dataTableConfig: {
676
860
  joinOperators: readonly ["and", "or"];
677
861
  };
678
862
  //#endregion
679
- //#region src/hooks/use-url-state.d.ts
680
- /**
681
- * URL 状态管理 Hook - 替代 nuqs
682
- * 将 React 状态同步到 URL query string
683
- *
684
- * 架构说明:
685
- * - 使用 queueMicrotask 延迟 URL 更新,确保在渲染完成后执行
686
- * - 符合 React 渲染规则,不会触发 "Cannot update a component while rendering" 错误
687
- */
688
- interface UrlStateOptions {
689
- /** 历史记录模式: push 添加新记录, replace 替换当前记录 */
690
- history?: "push" | "replace";
691
- /** 是否浅层更新(不触发页面刷新) */
692
- shallow?: boolean;
693
- /** 节流时间(毫秒) */
694
- throttleMs?: number;
695
- /** 防抖时间(毫秒) */
696
- debounceMs?: number;
697
- /** 当值等于默认值时是否清除 URL 参数 */
698
- clearOnDefault?: boolean;
699
- /** 滚动到顶部 */
700
- scroll?: boolean;
701
- /** React transition */
702
- startTransition?: React$1.TransitionStartFunction;
703
- }
704
- interface Parser<T> {
705
- parse: (value: string) => T;
706
- serialize: (value: T) => string;
707
- }
708
- declare const parseAsInteger: Parser<number> & {
709
- withDefault: (defaultValue: number) => Parser<number> & {
710
- defaultValue: number;
711
- };
712
- };
713
- declare const parseAsString: Parser<string> & {
714
- withDefault: (defaultValue: string) => Parser<string> & {
715
- defaultValue: string;
716
- };
717
- };
718
- declare function parseAsStringEnum<T extends string>(validValues: readonly T[]): Parser<T | null> & {
719
- withDefault: (defaultValue: T) => Parser<T> & {
720
- defaultValue: T;
721
- };
722
- };
723
- declare function parseAsArrayOf<T>(itemParser: Parser<T>, separator?: string): Parser<T[]> & {
724
- withDefault: (defaultValue: T[]) => Parser<T[]> & {
725
- defaultValue: T[];
726
- };
727
- };
728
- declare function getUrlParams(): URLSearchParams;
729
- declare function setSearchParams(params: URLSearchParams, options?: Pick<UrlStateOptions, "history" | "scroll">): void;
730
- /**
731
- * 单个 URL 状态参数
732
- */
733
- declare function useUrlState<T>(key: string, parser: Parser<T> & {
734
- defaultValue?: T;
735
- }, options?: UrlStateOptions): [T, (value: T | ((prev: T) => T)) => void];
736
- /**
737
- * 多个 URL 状态参数
738
- */
739
- declare function useUrlStates<T extends Record<string, unknown>>(parsers: { [K in keyof T]: Parser<T[K]> & {
740
- defaultValue?: T[K];
741
- } }, options?: UrlStateOptions): [T, (values: Partial<T>) => void];
742
- /**
743
- * nuqs 兼容层 - useQueryState
744
- */
745
- declare function useQueryState<T>(key: string, parser: Parser<T> & {
746
- defaultValue?: T;
747
- }, options?: UrlStateOptions): [T, (value: T | ((prev: T) => T)) => Promise<URLSearchParams>];
748
- /**
749
- * nuqs 兼容层 - useQueryStates
750
- */
751
- declare function useQueryStates<T extends Record<string, unknown>>(parsers: { [K in keyof T]: Parser<T[K]> & {
752
- defaultValue?: T[K];
753
- } }, options?: UrlStateOptions): [T, (values: Partial<T>) => Promise<URLSearchParams>];
754
- //#endregion
755
863
  //#region src/lib/parsers.d.ts
756
864
  declare const filterItemSchema: z.ZodObject<{
757
865
  id: z.ZodString;
@@ -759,12 +867,12 @@ declare const filterItemSchema: z.ZodObject<{
759
867
  variant: z.ZodEnum<{
760
868
  number: "number";
761
869
  boolean: "boolean";
762
- date: "date";
763
870
  text: "text";
871
+ range: "range";
872
+ date: "date";
873
+ dateRange: "dateRange";
764
874
  select: "select";
765
875
  multiSelect: "multiSelect";
766
- dateRange: "dateRange";
767
- range: "range";
768
876
  }>;
769
877
  operator: z.ZodEnum<{
770
878
  iLike: "iLike";
@@ -790,6 +898,7 @@ type FilterItemSchema = z.infer<typeof filterItemSchema>;
790
898
  declare module "@tanstack/react-table" {
791
899
  interface TableMeta<TData extends RowData> {
792
900
  queryKeys?: QueryKeys;
901
+ queryStateOptions?: UrlStateOptions;
793
902
  }
794
903
  interface ColumnMeta<TData extends RowData, TValue> {
795
904
  label?: string;
@@ -840,7 +949,7 @@ declare function AutoTableSimpleFilters<TData>({
840
949
  shallow,
841
950
  filters: externalFilters,
842
951
  onFiltersChange
843
- }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime2.JSX.Element | null;
952
+ }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime3.JSX.Element | null;
844
953
  //#endregion
845
954
  //#region src/components/auto-crud/form-modal.d.ts
846
955
  type ModalVariant = "dialog" | "sheet";
@@ -875,7 +984,46 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
875
984
  title,
876
985
  labelAlign,
877
986
  labelWidth
878
- }: CrudFormModalProps<T>): react_jsx_runtime2.JSX.Element;
987
+ }: CrudFormModalProps<T>): react_jsx_runtime3.JSX.Element;
988
+ //#endregion
989
+ //#region src/components/auto-crud/import-dialog.d.ts
990
+ interface ImportDialogProps {
991
+ open: boolean;
992
+ onOpenChange: (open: boolean) => void;
993
+ /** 执行导入的回调 */
994
+ onImport: (rows: Record<string, unknown>[]) => Promise<ImportResult>;
995
+ /** 可用列名(用于生成模板) */
996
+ columns?: string[];
997
+ /** 对话框标题 */
998
+ title?: string;
999
+ }
1000
+ declare function ImportDialog({
1001
+ open,
1002
+ onOpenChange,
1003
+ onImport,
1004
+ columns,
1005
+ title
1006
+ }: ImportDialogProps): react_jsx_runtime3.JSX.Element;
1007
+ //#endregion
1008
+ //#region src/components/auto-crud/export-dialog.d.ts
1009
+ type ExportMode = "selected" | "filtered";
1010
+ interface ExportDialogProps {
1011
+ open: boolean;
1012
+ onOpenChange: (open: boolean) => void;
1013
+ /** 当前选中的行数 */
1014
+ selectedCount: number;
1015
+ /** 执行导出 */
1016
+ onExport: (mode: ExportMode) => Promise<void>;
1017
+ /** 是否支持导出筛选结果(需要 exportFetcher) */
1018
+ canExportFiltered?: boolean;
1019
+ }
1020
+ declare function ExportDialog({
1021
+ open,
1022
+ onOpenChange,
1023
+ selectedCount,
1024
+ onExport,
1025
+ canExportFiltered
1026
+ }: ExportDialogProps): react_jsx_runtime3.JSX.Element;
879
1027
  //#endregion
880
1028
  //#region src/components/data-table/data-table.d.ts
881
1029
  interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
@@ -888,7 +1036,7 @@ declare function DataTable<TData>({
888
1036
  children,
889
1037
  className,
890
1038
  ...props
891
- }: DataTableProps<TData>): react_jsx_runtime2.JSX.Element;
1039
+ }: DataTableProps<TData>): react_jsx_runtime3.JSX.Element;
892
1040
  //#endregion
893
1041
  //#region src/components/data-table/data-table-advanced-toolbar.d.ts
894
1042
  interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
@@ -899,7 +1047,7 @@ declare function DataTableAdvancedToolbar<TData>({
899
1047
  children,
900
1048
  className,
901
1049
  ...props
902
- }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
1050
+ }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
903
1051
  //#endregion
904
1052
  //#region src/components/data-table/data-table-column-header.d.ts
905
1053
  interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
@@ -911,7 +1059,7 @@ declare function DataTableColumnHeader<TData, TValue>({
911
1059
  label,
912
1060
  className,
913
1061
  ...props
914
- }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
1062
+ }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
915
1063
  //#endregion
916
1064
  //#region src/components/data-table/data-table-faceted-filter.d.ts
917
1065
  interface DataTableFacetedFilterProps<TData, TValue> {
@@ -925,7 +1073,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
925
1073
  title,
926
1074
  options,
927
1075
  multiple
928
- }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
1076
+ }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
929
1077
  //#endregion
930
1078
  //#region src/components/data-table/data-table-pagination.d.ts
931
1079
  interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
@@ -937,7 +1085,7 @@ declare function DataTablePagination<TData>({
937
1085
  pageSizeOptions,
938
1086
  className,
939
1087
  ...props
940
- }: DataTablePaginationProps<TData>): react_jsx_runtime2.JSX.Element;
1088
+ }: DataTablePaginationProps<TData>): react_jsx_runtime3.JSX.Element;
941
1089
  //#endregion
942
1090
  //#region src/components/data-table/data-table-toolbar.d.ts
943
1091
  interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
@@ -948,7 +1096,7 @@ declare function DataTableToolbar<TData>({
948
1096
  children,
949
1097
  className,
950
1098
  ...props
951
- }: DataTableToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
1099
+ }: DataTableToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
952
1100
  //#endregion
953
1101
  //#region src/components/data-table/data-table-view-options.d.ts
954
1102
  interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
@@ -959,7 +1107,7 @@ declare function DataTableViewOptions<TData>({
959
1107
  table,
960
1108
  disabled,
961
1109
  ...props
962
- }: DataTableViewOptionsProps<TData>): react_jsx_runtime2.JSX.Element;
1110
+ }: DataTableViewOptionsProps<TData>): react_jsx_runtime3.JSX.Element;
963
1111
  //#endregion
964
1112
  //#region src/hooks/use-data-table.d.ts
965
1113
  interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, "state" | "pageCount" | "getCoreRowModel" | "manualFiltering" | "manualPagination" | "manualSorting">, Required<Pick<TableOptions<TData>, "pageCount">> {
@@ -1230,4 +1378,68 @@ declare function formatDate(date: Date | string | number | undefined, opts?: Int
1230
1378
  */
1231
1379
  declare function humanize(str: string): string;
1232
1380
  //#endregion
1233
- export { type ActionsColumnConfig, AutoCrudTable, type AutoCrudTableProps, AutoForm, 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, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldType, type Fields, FilterOperator, type FilterVariant, type FormSchemaOverrides, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, Option, type ParsedZodField, type Parser, QueryKeys, SchemaAdapter, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, cn, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, formatDate, getUrlParams, humanize, noopToastAdapter, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseZodField, setSearchParams, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates };
1381
+ //#region src/lib/import.d.ts
1382
+ interface ParsedImportData {
1383
+ headers: string[];
1384
+ rows: Record<string, unknown>[];
1385
+ format: "csv" | "json";
1386
+ }
1387
+ /**
1388
+ * 解析 CSV 字符串为对象数组
1389
+ * 支持:引号包裹、逗号转义、换行符、空值
1390
+ */
1391
+ declare function parseCSV(content: string): {
1392
+ headers: string[];
1393
+ rows: Record<string, string>[];
1394
+ };
1395
+ /**
1396
+ * 解析 JSON 字符串为对象数组
1397
+ * 支持 JSON 数组或 { data: [...] } 格式
1398
+ */
1399
+ declare function parseJSON(content: string): Record<string, unknown>[];
1400
+ /**
1401
+ * 统一解析入口:根据文件扩展名自动选择解析器
1402
+ */
1403
+ declare function parseImportFile(file: File): Promise<ParsedImportData>;
1404
+ /**
1405
+ * 生成 CSV 模板(仅包含表头,用于下载空模板)
1406
+ */
1407
+ declare function generateCSVTemplate(headers: string[]): string;
1408
+ /**
1409
+ * 将数据数组转换为 CSV 字符串
1410
+ */
1411
+ declare function dataToCSV<T extends Record<string, unknown>>(data: T[], opts?: {
1412
+ headers?: string[];
1413
+ excludeColumns?: string[];
1414
+ }): string;
1415
+ /**
1416
+ * 根据 Zod Schema 将 CSV 解析出的 string 值转换为正确类型
1417
+ *
1418
+ * CSV 解析后所有值都是 string,需要根据 schema 字段类型进行转换:
1419
+ * - number: parseFloat
1420
+ * - boolean: "true"/"1"/"yes" → true, 其他 → false
1421
+ * - date: new Date(value)
1422
+ * - 空字符串 → undefined(让 schema 默认值生效)
1423
+ */
1424
+ declare function coerceRowValues<T extends z.ZodObject<z.ZodRawShape>>(rows: Record<string, unknown>[], schema: T): Record<string, unknown>[];
1425
+ //#endregion
1426
+ //#region src/lib/export.d.ts
1427
+ declare function exportTableToCSV<TData>(table: Table<TData>, opts?: {
1428
+ filename?: string;
1429
+ excludeColumns?: (keyof TData | "select" | "actions")[];
1430
+ onlySelected?: boolean;
1431
+ }): void;
1432
+ /**
1433
+ * 导出原始数据数组为 CSV(用于服务端全量导出)
1434
+ */
1435
+ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], opts?: {
1436
+ filename?: string;
1437
+ headers?: string[];
1438
+ excludeColumns?: string[];
1439
+ }): void;
1440
+ /**
1441
+ * 下载 CSV 模板文件
1442
+ */
1443
+ declare function downloadCSVTemplate(headers: string[], filename?: string): void;
1444
+ //#endregion
1445
+ 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 };