@qin-ui/antdv-next-pro 1.1.9 → 1.1.11
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/AI-CONTEXT.md +37 -0
- package/LICENSE +9 -0
- package/README.md +139 -130
- package/api.json +213 -0
- package/es/antdv-next-pro.css +6 -6
- package/es/component-provider/index-Daiw7IxY.js +186 -0
- package/es/component-provider/index.js +2 -184
- package/es/core/{index-C98RSrpN.js → index-ghYuQ3Sy.js} +29 -29
- package/es/form/{index-CyMXEA_9.js → index-7clzY8ZD.js} +67 -73
- package/es/form/index.js +10 -16
- package/es/index.d.ts +674 -139
- package/es/index.js +25 -22
- package/es/table/index.js +4 -4
- package/package.json +11 -8
package/es/index.d.ts
CHANGED
|
@@ -35,7 +35,6 @@ import { FormTooltipProps } from 'antdv-next/dist/form/FormItemLabel';
|
|
|
35
35
|
import { GlobalComponents } from 'vue';
|
|
36
36
|
import { GlobalDirectives } from 'vue';
|
|
37
37
|
import { HTMLAttributes } from 'vue';
|
|
38
|
-
import { InjectionKey } from 'vue';
|
|
39
38
|
import { Input } from 'antdv-next';
|
|
40
39
|
import { InputNumber } from 'antdv-next';
|
|
41
40
|
import { InputOTP } from 'antdv-next';
|
|
@@ -69,7 +68,7 @@ import { Variant } from 'antdv-next/dist/config-provider/context';
|
|
|
69
68
|
import { VNode } from 'vue';
|
|
70
69
|
import { VNodeProps } from 'vue';
|
|
71
70
|
|
|
72
|
-
declare const __VLS_component: DefineComponent<
|
|
71
|
+
declare const __VLS_component: DefineComponent<Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
73
72
|
|
|
74
73
|
declare type __VLS_PrettifyLocal<T> = {
|
|
75
74
|
[K in keyof T]: T[K];
|
|
@@ -97,13 +96,17 @@ declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
|
97
96
|
};
|
|
98
97
|
};
|
|
99
98
|
|
|
99
|
+
/**
|
|
100
|
+
* FormItem 实例提供的额外方法
|
|
101
|
+
* @template FormItemInstance - FormItem 组件实例类型
|
|
102
|
+
*/
|
|
100
103
|
declare type AdditionalMethods<FormItemInstance> = {
|
|
101
104
|
/**
|
|
102
|
-
* @description 获取FormItem实例的方法
|
|
105
|
+
* @description 获取 FormItem 实例的方法
|
|
103
106
|
*/
|
|
104
107
|
getFormItemRef?: () => FormItemInstance;
|
|
105
108
|
/**
|
|
106
|
-
* @description 获取传入FormItem组件的属性
|
|
109
|
+
* @description 获取传入 FormItem 组件的属性
|
|
107
110
|
*/
|
|
108
111
|
getFormItemComputedProps?: () => Readonly<{
|
|
109
112
|
[x: string]: any;
|
|
@@ -113,7 +116,7 @@ declare type AdditionalMethods<FormItemInstance> = {
|
|
|
113
116
|
*/
|
|
114
117
|
getComponentRef?: () => any;
|
|
115
118
|
/**
|
|
116
|
-
* @description 获取传入Component组件的属性
|
|
119
|
+
* @description 获取传入 Component 组件的属性
|
|
117
120
|
*/
|
|
118
121
|
getComponentComputedProps?: () => Readonly<{
|
|
119
122
|
disabled?: boolean;
|
|
@@ -128,12 +131,49 @@ declare type AllowStringKey<T, Prefix extends string = ''> = {
|
|
|
128
131
|
/**
|
|
129
132
|
* @type {Object} Base - 基础公共字段类型
|
|
130
133
|
*/
|
|
131
|
-
|
|
134
|
+
declare type Base<D extends Data = Data> = BaseWithFields<D> | BaseWithoutFields<D>;
|
|
132
135
|
|
|
136
|
+
/**
|
|
137
|
+
* 基础表格列配置接口
|
|
138
|
+
* @template D - 表格数据类型,应为一个对象类型
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* interface User { name: string; age: number; address: { city: string } }
|
|
143
|
+
*
|
|
144
|
+
* // 简单列
|
|
145
|
+
* const column: BaseColumn<User> = {
|
|
146
|
+
* key: 'name',
|
|
147
|
+
* title: '姓名',
|
|
148
|
+
* }
|
|
149
|
+
*
|
|
150
|
+
* // 带数据索引和嵌套列
|
|
151
|
+
* const column: BaseColumn<User> = {
|
|
152
|
+
* key: 'address',
|
|
153
|
+
* title: '地址',
|
|
154
|
+
* children: [
|
|
155
|
+
* { key: 'city', title: '城市' },
|
|
156
|
+
* ],
|
|
157
|
+
* }
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
133
160
|
declare interface BaseColumn<D extends Data = Data> {
|
|
161
|
+
/**
|
|
162
|
+
* @description 列字段路径(数据对象的 key 路径),支持点号分隔的深层路径
|
|
163
|
+
* @example 'name' | 'address.city'
|
|
164
|
+
*/
|
|
134
165
|
key?: Path<D>;
|
|
166
|
+
/**
|
|
167
|
+
* @description 数据索引,与 key 作用类似,支持数组格式
|
|
168
|
+
* @example 'name' | ['address', 'city']
|
|
169
|
+
*/
|
|
135
170
|
dataIndex?: Path<D> | Path<D>[];
|
|
171
|
+
/**
|
|
172
|
+
* @description 嵌套子列配置,用于实现表头分组
|
|
173
|
+
* @example [{ key: 'firstName', title: '名' }, { key: 'lastName', title: '姓' }]
|
|
174
|
+
*/
|
|
136
175
|
children?: BaseColumn<D>[];
|
|
176
|
+
/** 其他任意自定义属性(如 title、width、fixed 等 UI 属性) */
|
|
137
177
|
[key: string]: any;
|
|
138
178
|
}
|
|
139
179
|
|
|
@@ -195,7 +235,11 @@ declare type BaseCommon<D extends Data = Data> = {
|
|
|
195
235
|
extraProps?: Record<string, any>;
|
|
196
236
|
};
|
|
197
237
|
|
|
198
|
-
|
|
238
|
+
/**
|
|
239
|
+
* 内置组件映射表
|
|
240
|
+
* @description antdv-next 内置支持的组件类型映射
|
|
241
|
+
*/
|
|
242
|
+
declare type BaseComponentMap = {
|
|
199
243
|
'input': typeof Input;
|
|
200
244
|
'textarea': typeof TextArea;
|
|
201
245
|
'input-search': typeof InputSearch;
|
|
@@ -217,49 +261,49 @@ export declare type BaseComponentMap = {
|
|
|
217
261
|
'transfer': typeof Transfer;
|
|
218
262
|
};
|
|
219
263
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
264
|
+
/**
|
|
265
|
+
* 基础字段配置接口
|
|
266
|
+
* @template D - 表单数据类型,应为一个对象类型
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```ts
|
|
270
|
+
* // 简单的文本输入字段
|
|
271
|
+
* const field: BaseField<{ name: string }> = {
|
|
272
|
+
* path: 'name',
|
|
273
|
+
* label: '姓名',
|
|
274
|
+
* }
|
|
275
|
+
*
|
|
276
|
+
* // 带嵌套子字段
|
|
277
|
+
* const field: BaseField<{ address: { city: string; street: string } }> = {
|
|
278
|
+
* path: 'address',
|
|
279
|
+
* label: '地址',
|
|
280
|
+
* fields: [
|
|
281
|
+
* { path: 'city', label: '城市' },
|
|
282
|
+
* { path: 'street', label: '街道' },
|
|
283
|
+
* ],
|
|
284
|
+
* }
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
declare interface BaseField<D extends Data = Data> {
|
|
288
|
+
/**
|
|
289
|
+
* @description 字段路径(数据对象的 key 路径),支持点号分隔的深层路径
|
|
290
|
+
* @example 'name' | 'user.address.city'
|
|
291
|
+
*/
|
|
228
292
|
path?: Path<D> | any;
|
|
293
|
+
/**
|
|
294
|
+
* @description 字段名称,与 path 作用相同,两者选其一即可
|
|
295
|
+
* @deprecated 推荐使用 path 替代
|
|
296
|
+
*/
|
|
229
297
|
name?: any;
|
|
298
|
+
/**
|
|
299
|
+
* @description 嵌套子字段配置数组,用于实现分组/嵌套字段
|
|
300
|
+
* @example [{ path: 'firstName', label: '名' }, { path: 'lastName', label: '姓' }]
|
|
301
|
+
*/
|
|
230
302
|
fields?: any[];
|
|
303
|
+
/** 其他任意自定义属性 */
|
|
231
304
|
[key: string]: any;
|
|
232
305
|
}
|
|
233
306
|
|
|
234
|
-
export declare const BaseForm: <F extends Form<any> = Form>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal_2<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
235
|
-
props: __VLS_PrettifyLocal_2<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & ({
|
|
236
|
-
grid?: Grid;
|
|
237
|
-
form?: F;
|
|
238
|
-
} & Partial<Omit<FormProps, "model">>) & Partial<{}>> & PublicProps;
|
|
239
|
-
expose(exposed: ShallowUnwrapRef< {}>): void;
|
|
240
|
-
attrs: any;
|
|
241
|
-
slots: Readonly<Partial<Record<F extends Form<infer D extends Data> ? Path<D> : string, Slot<VModelProps & {
|
|
242
|
-
path?: string;
|
|
243
|
-
} & Data & {
|
|
244
|
-
[x: string]: any;
|
|
245
|
-
disabled?: boolean;
|
|
246
|
-
}>> & {
|
|
247
|
-
default: Slot;
|
|
248
|
-
}>> & Partial<Record<F extends Form<infer D extends Data> ? Path<D> : string, Slot<VModelProps & {
|
|
249
|
-
path?: string;
|
|
250
|
-
} & Data & {
|
|
251
|
-
[x: string]: any;
|
|
252
|
-
disabled?: boolean;
|
|
253
|
-
}>> & {
|
|
254
|
-
default: Slot;
|
|
255
|
-
}>;
|
|
256
|
-
emit: {};
|
|
257
|
-
}>) => VNode & {
|
|
258
|
-
__ctx?: Awaited<typeof __VLS_setup>;
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
export declare const BaseFormItem: DefineComponent<Props_4, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props_4> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
262
|
-
|
|
263
307
|
declare type BaseWithFields<D extends Data = Data> = BaseCommon<D> & {
|
|
264
308
|
/**
|
|
265
309
|
* @description 嵌套子字段配置
|
|
@@ -341,34 +385,102 @@ declare type ButtonProps = {
|
|
|
341
385
|
onClick: () => void;
|
|
342
386
|
};
|
|
343
387
|
|
|
388
|
+
/**
|
|
389
|
+
* @qin-ui/antdv-next-pro 表格列配置类型
|
|
390
|
+
*
|
|
391
|
+
* @description 继承 antdv-next 的 ColumnType 列类型,并添加:
|
|
392
|
+
* - 类型安全的 dataIndex(基于泛型 D 推导路径),优先使用
|
|
393
|
+
* - key 作为辅助标识
|
|
394
|
+
* - hidden 属性用于控制列显隐
|
|
395
|
+
*
|
|
396
|
+
* @template D - 表格行数据类型
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```ts
|
|
400
|
+
* interface User { name: string; age: number }
|
|
401
|
+
*
|
|
402
|
+
* const columns: Columns<User> = [
|
|
403
|
+
* { dataIndex: 'name', title: '姓名', width: 120 },
|
|
404
|
+
* { dataIndex: 'age', title: '年龄', width: 80 },
|
|
405
|
+
* ]
|
|
406
|
+
* ```
|
|
407
|
+
|
|
408
|
+
* @public
|
|
409
|
+
*/
|
|
344
410
|
export declare type Column<D extends Data = Data> = Omit<TableColumnType, 'dataIndex' | 'key'> & {
|
|
411
|
+
/**
|
|
412
|
+
* @description 列数据路径(主要字段),优先使用 dataIndex 进行字段匹配
|
|
413
|
+
* @example 'name' | 'address.city' | ['address', 'city']
|
|
414
|
+
*/
|
|
345
415
|
dataIndex?: KeyExpandString<Extract<keyof D, string>> | Paths<D>;
|
|
416
|
+
/**
|
|
417
|
+
* @description 列字段标识(辅助字段),当 dataIndex 不满足需求时使用
|
|
418
|
+
*/
|
|
346
419
|
key?: Path<D>;
|
|
420
|
+
/**
|
|
421
|
+
* @description 是否隐藏该列
|
|
422
|
+
* @default false
|
|
423
|
+
*/
|
|
347
424
|
hidden?: boolean;
|
|
348
425
|
};
|
|
349
426
|
|
|
427
|
+
/**
|
|
428
|
+
* 列查找函数类型,通过自定义函数匹配列
|
|
429
|
+
* @template D - 表格数据类型
|
|
430
|
+
* @template C - 列配置类型
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```ts
|
|
434
|
+
* // 查找 title 为 '姓名' 的列
|
|
435
|
+
* const findBy: ColumnFindBy<MyData> = (column) => column.title === '姓名'
|
|
436
|
+
*
|
|
437
|
+
* // 查找所有宽度小于 100 的列
|
|
438
|
+
* const findBy: ColumnFindBy<MyData> = (column) => column.width && column.width < 100
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
350
441
|
declare type ColumnFindBy<D extends Data, C extends BaseColumn<D> = BaseColumn<D>> = (column: Readonly<C>) => boolean;
|
|
351
442
|
|
|
443
|
+
/**
|
|
444
|
+
* @qin-ui/antdv-next-pro 表格列配置数组类型
|
|
445
|
+
* @template D - 表格行数据类型
|
|
446
|
+
|
|
447
|
+
* @public
|
|
448
|
+
*/
|
|
352
449
|
export declare type Columns<D extends Data = Data> = Array<Column<D>>;
|
|
353
450
|
|
|
451
|
+
/**
|
|
452
|
+
* 列配置数组类型
|
|
453
|
+
* @template D - 表格数据类型
|
|
454
|
+
* @template C - 列配置类型
|
|
455
|
+
*/
|
|
354
456
|
declare type Columns_2<D extends Data = Data, C extends BaseColumn<D> = BaseColumn<D>> = Array<C>;
|
|
355
457
|
|
|
356
458
|
/**
|
|
357
|
-
*
|
|
459
|
+
* 组件映射扩展接口
|
|
460
|
+
* @description 暴露给外部扩充自定义组件类型的接口。
|
|
461
|
+
* 用户可通过 TypeScript 的声明合并(module augmentation)添加自定义组件。
|
|
462
|
+
*
|
|
358
463
|
* @example
|
|
359
464
|
* ```ts
|
|
360
|
-
*
|
|
465
|
+
* // 在项目中任意 .d.ts 文件中
|
|
466
|
+
* declare module '@qin-ui/antdv-next-pro' {
|
|
361
467
|
* interface ComponentMap {
|
|
362
468
|
* 'my-custom-input': typeof MyCustomInput;
|
|
363
469
|
* }
|
|
364
470
|
* }
|
|
365
471
|
* ```
|
|
472
|
+
|
|
473
|
+
* @public
|
|
366
474
|
*/
|
|
367
475
|
export declare interface ComponentMap {
|
|
368
476
|
}
|
|
369
477
|
|
|
370
|
-
|
|
478
|
+
/**
|
|
479
|
+
* 组件名称联合类型
|
|
480
|
+
* @description 所有支持的组件名称
|
|
371
481
|
|
|
482
|
+
* @public
|
|
483
|
+
*/
|
|
372
484
|
export declare type ComponentName = keyof BaseComponentMap | keyof ComponentMap | 'custom';
|
|
373
485
|
|
|
374
486
|
export declare type ComponentVars = Partial<RequiredComponentVars>;
|
|
@@ -376,17 +488,45 @@ export declare type ComponentVars = Partial<RequiredComponentVars>;
|
|
|
376
488
|
/**
|
|
377
489
|
* @description 容器组件类型
|
|
378
490
|
*/
|
|
379
|
-
|
|
491
|
+
declare type ContainerComponent = Component<PathProps>;
|
|
380
492
|
|
|
381
493
|
export declare const ContainerFragment: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
382
494
|
|
|
495
|
+
/**
|
|
496
|
+
* 基础数据类型,表示任意对象
|
|
497
|
+
* @description 所有表单数据对象和表格数据对象的基础类型
|
|
498
|
+
*/
|
|
383
499
|
declare type Data = Record<string, any>;
|
|
384
500
|
|
|
501
|
+
/**
|
|
502
|
+
* 递归地将对象的所有属性变为可选
|
|
503
|
+
* @template T - 原始类型
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* ```ts
|
|
507
|
+
* type T = DeepPartial<{ name: string; address: { city: string } }>
|
|
508
|
+
* // { name?: string; address?: { city?: string } }
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
385
511
|
declare type DeepPartial<T> = T extends object ? {
|
|
386
512
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
387
513
|
} : T;
|
|
388
514
|
|
|
389
515
|
declare const _default: {
|
|
516
|
+
/**
|
|
517
|
+
* @qin-ui/antdv-next-pro 安装方法
|
|
518
|
+
* @description 全局注册所有组件(ProForm、ProTable、ProComponentProvider)
|
|
519
|
+
*
|
|
520
|
+
* @param {App} app - Vue 应用实例
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* ```ts
|
|
524
|
+
* import { createApp } from 'vue'
|
|
525
|
+
* import QinUI from '@qin-ui/antdv-next-pro'
|
|
526
|
+
* const app = createApp(App)
|
|
527
|
+
* app.use(QinUI)
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
390
530
|
install(app: App): void;
|
|
391
531
|
};
|
|
392
532
|
export default _default;
|
|
@@ -450,9 +590,9 @@ declare const _default_2: <T extends Table<any> = Table>(__VLS_props: NonNullabl
|
|
|
450
590
|
bodyCell?: (props: {
|
|
451
591
|
text: any;
|
|
452
592
|
value: any;
|
|
453
|
-
record: T extends Table<infer
|
|
593
|
+
record: T extends Table<any, infer R extends Data> ? R : never;
|
|
454
594
|
index: number;
|
|
455
|
-
column: Column<T extends Table<infer
|
|
595
|
+
column: Column<T extends Table<any, infer R extends Data> ? R : never>;
|
|
456
596
|
}) => void;
|
|
457
597
|
}> & Readonly<Partial<Record<"table" | "search-form" | "button-bar" | "toolbar", Slot>>>, "default">> & Omit<Omit<Readonly<{
|
|
458
598
|
default?: (() => any) | undefined;
|
|
@@ -489,9 +629,9 @@ declare const _default_2: <T extends Table<any> = Table>(__VLS_props: NonNullabl
|
|
|
489
629
|
bodyCell?: (props: {
|
|
490
630
|
text: any;
|
|
491
631
|
value: any;
|
|
492
|
-
record: T extends Table<infer
|
|
632
|
+
record: T extends Table<any, infer R extends Data> ? R : never;
|
|
493
633
|
index: number;
|
|
494
|
-
column: Column<T extends Table<infer
|
|
634
|
+
column: Column<T extends Table<any, infer R extends Data> ? R : never>;
|
|
495
635
|
}) => void;
|
|
496
636
|
}> & Readonly<Partial<Record<"table" | "search-form" | "button-bar" | "toolbar", Slot>>>, "default">;
|
|
497
637
|
emit: ((evt: "update:size", value: ButtonSize) => void) & ((evt: "update:loading", value: boolean) => void);
|
|
@@ -499,7 +639,34 @@ declare const _default_2: <T extends Table<any> = Table>(__VLS_props: NonNullabl
|
|
|
499
639
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
500
640
|
};
|
|
501
641
|
|
|
502
|
-
|
|
642
|
+
declare const _default_3: <F extends Form<any> = Form>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal_2<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
643
|
+
props: __VLS_PrettifyLocal_2<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & ({
|
|
644
|
+
grid?: Grid;
|
|
645
|
+
form?: F;
|
|
646
|
+
} & Partial<Omit<FormProps, "model">>) & Partial<{}>> & PublicProps;
|
|
647
|
+
expose(exposed: ShallowUnwrapRef< {}>): void;
|
|
648
|
+
attrs: any;
|
|
649
|
+
slots: Readonly<Partial<Record<F extends Form<infer D extends Data> ? Path<D> : string, Slot<VModelProps & {
|
|
650
|
+
path?: string;
|
|
651
|
+
} & Data & {
|
|
652
|
+
[x: string]: any;
|
|
653
|
+
disabled?: boolean;
|
|
654
|
+
}>> & {
|
|
655
|
+
default: Slot;
|
|
656
|
+
}>> & Partial<Record<F extends Form<infer D extends Data> ? Path<D> : string, Slot<VModelProps & {
|
|
657
|
+
path?: string;
|
|
658
|
+
} & Data & {
|
|
659
|
+
[x: string]: any;
|
|
660
|
+
disabled?: boolean;
|
|
661
|
+
}>> & {
|
|
662
|
+
default: Slot;
|
|
663
|
+
}>;
|
|
664
|
+
emit: {};
|
|
665
|
+
}>) => VNode & {
|
|
666
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
declare const _default_4: DefineComponent<Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props_3> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
503
670
|
|
|
504
671
|
declare type Expand = {
|
|
505
672
|
minExpandRows?: number;
|
|
@@ -510,6 +677,18 @@ declare type ExpandButtonProps = ButtonProps & {
|
|
|
510
677
|
expandStatus: boolean;
|
|
511
678
|
};
|
|
512
679
|
|
|
680
|
+
/**
|
|
681
|
+
* 用 Record<string, any> 扩展对象类型,保留所有原始属性结构,
|
|
682
|
+
* 同时允许访问任意字符串 key。
|
|
683
|
+
* @template D - 原始对象类型
|
|
684
|
+
*
|
|
685
|
+
* @example
|
|
686
|
+
* ```ts
|
|
687
|
+
* type T = ExtendWithAny<{ name: string; age: number }>
|
|
688
|
+
* // { name: string; age: number } & Record<string, any>
|
|
689
|
+
* // 可访问任意额外属性: obj.anyKey
|
|
690
|
+
* ```
|
|
691
|
+
*/
|
|
513
692
|
declare type ExtendWithAny<D> = {
|
|
514
693
|
[K in keyof D]: IsRecord<D[K]> extends true ? ExtendWithAny<D[K]> : D[K];
|
|
515
694
|
} & Record<string, any>;
|
|
@@ -517,23 +696,37 @@ declare type ExtendWithAny<D> = {
|
|
|
517
696
|
/**
|
|
518
697
|
* @description 字段配置类型,包含所有字段属性和响应式支持
|
|
519
698
|
* @template D - 数据对象类型
|
|
699
|
+
|
|
700
|
+
* @public
|
|
520
701
|
*/
|
|
521
702
|
export declare type Field<C extends ComponentName = ComponentName, D extends Data = Data> = (FieldTypeMap<D>[C] & {
|
|
522
703
|
component?: C extends 'custom' ? FieldTypeMap<D>[C]['component'] : C;
|
|
523
704
|
}) | WithFields<D>;
|
|
524
705
|
|
|
525
|
-
|
|
706
|
+
/**
|
|
707
|
+
* 字段查找函数类型,通过自定义函数匹配字段
|
|
708
|
+
* @template D - 表单数据类型
|
|
709
|
+
* @template F - 字段配置类型
|
|
710
|
+
* @example
|
|
711
|
+
* ```ts
|
|
712
|
+
* // 查找 label 为 '姓名' 的字段
|
|
713
|
+
* const findBy: FieldFindBy<MyData> = (field) => field.label === '姓名'
|
|
714
|
+
* ```
|
|
715
|
+
*/
|
|
716
|
+
declare type FieldFindBy<D extends Data, F extends BaseField<D> = BaseField<D>> = (field: Readonly<F>) => boolean;
|
|
526
717
|
|
|
527
718
|
/**
|
|
528
719
|
* @description 字段数组类型
|
|
529
720
|
* @template D - 数据对象类型
|
|
721
|
+
|
|
722
|
+
* @public
|
|
530
723
|
*/
|
|
531
724
|
export declare type Fields<D extends Data = Data> = Array<Field<ComponentName, D>>;
|
|
532
725
|
|
|
533
726
|
/**
|
|
534
727
|
* @type {FieldTypeMap} 字段类型集合
|
|
535
728
|
*/
|
|
536
|
-
|
|
729
|
+
declare type FieldTypeMap<D extends Data = Data> = {
|
|
537
730
|
[K in ComponentName]: K extends 'custom' ? WithCommon<{
|
|
538
731
|
slots?: Slots;
|
|
539
732
|
[x: string]: any;
|
|
@@ -545,18 +738,63 @@ export declare type FieldTypeMap<D extends Data = Data> = {
|
|
|
545
738
|
};
|
|
546
739
|
|
|
547
740
|
/**
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
741
|
+
* @qin-ui/antdv-next-pro 的表单实例类型
|
|
742
|
+
*
|
|
743
|
+
* @description 在 core Form 类型的基础上:
|
|
744
|
+
* 1. 将字段类型 F 默认绑定为本地 Field<ComponentName, D>,支持 antdv-next 所有内置组件类型
|
|
745
|
+
* 2. 将底层表单实例 I 绑定为 antdv-next 的 FormInstance,使 formRef 获得完整的类型提示
|
|
746
|
+
*
|
|
747
|
+
* @template D - 表单数据类型
|
|
748
|
+
* @template F - 字段配置类型,默认使用本地 Field 类型
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* ```ts
|
|
752
|
+
* interface User { name: string; age: number }
|
|
753
|
+
* const form: Form<User> = useForm({ name: '张三', age: 25 })
|
|
754
|
+
* form.formRef.value?.validate() // 类型安全地访问 antdv-next Form validate 方法
|
|
755
|
+
* ```
|
|
756
|
+
|
|
757
|
+
* @public
|
|
552
758
|
*/
|
|
553
759
|
export declare type Form<D extends Data = Data, F extends Field<ComponentName, D> = Field<ComponentName, D>> = Form_2<D, F, FormInstance>;
|
|
554
760
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
761
|
+
/**
|
|
762
|
+
* 表单实例类型
|
|
763
|
+
* @template D - 表单数据类型
|
|
764
|
+
* @template F - 字段配置类型
|
|
765
|
+
* @template I - 底层 UI 框架 Form 组件实例类型
|
|
766
|
+
*
|
|
767
|
+
* 组合了表单数据操作、字段操作和表单 ref 操作的能力。
|
|
768
|
+
*
|
|
769
|
+
* @example
|
|
770
|
+
* ```ts
|
|
771
|
+
* // 定义数据类型
|
|
772
|
+
* interface User {
|
|
773
|
+
* name: string
|
|
774
|
+
* age: number
|
|
775
|
+
* address: { city: string; street: string }
|
|
776
|
+
* }
|
|
777
|
+
*
|
|
778
|
+
* // 创建表单实例
|
|
779
|
+
* const form: Form<User> = useForm({
|
|
780
|
+
* name: '张三',
|
|
781
|
+
* age: 25,
|
|
782
|
+
* })
|
|
783
|
+
*
|
|
784
|
+
* // 读取数据
|
|
785
|
+
* form.getFormData('name') // '张三'
|
|
786
|
+
* form.getFormData('address.city') // 支持深层路径
|
|
787
|
+
*
|
|
788
|
+
* // 设置数据
|
|
789
|
+
* form.setFormData('name', '李四')
|
|
790
|
+
* form.setFormData({ name: '王五', age: 30 }) // 批量设置
|
|
791
|
+
*
|
|
792
|
+
* // 字段操作
|
|
793
|
+
* form.getField('name') // 获取字段配置
|
|
794
|
+
* form.setField('name', { label: '用户名' }) // 更新字段配置
|
|
795
|
+
* ```
|
|
796
|
+
*/
|
|
797
|
+
declare type Form_2<D extends Data = Data, F extends BaseField<D> = BaseField<D>, I = any> = ReturnType<typeof useFormData<D>> & ReturnType<typeof useFields_2<D, F>> & ReturnType<typeof useFormRef_2<I>>;
|
|
560
798
|
|
|
561
799
|
declare type FormItemInstance = InstanceType<typeof FormItem>;
|
|
562
800
|
|
|
@@ -564,32 +802,18 @@ declare type _FormProps = Pick<Partial<FormProps>, 'colon' | 'disabled' | 'label
|
|
|
564
802
|
|
|
565
803
|
declare type FP<T extends Record<string, any>> = Partial<T & Pick<Base, 'valueFormatter' | 'componentContainer' | 'modelProp' | 'componentClass' | 'componentStyle'> & AllowedComponentProps>;
|
|
566
804
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
export declare type Grid = boolean | (RowProps & {});
|
|
574
|
-
|
|
575
|
-
export declare const INJECT_COMPONENTS: InjectionKey<Partial<Record<string, Component>>>;
|
|
576
|
-
|
|
577
|
-
export declare const INJECT_CONFIG: {
|
|
578
|
-
[key in keyof RequiredComponentVars]: {
|
|
579
|
-
injectionKey: InjectionKey<RequiredComponentVars[key]>;
|
|
580
|
-
default: RequiredComponentVars[key];
|
|
581
|
-
};
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
export declare type InjectConfigEntry<T = any> = {
|
|
585
|
-
injectionKey: InjectionKey<T>;
|
|
586
|
-
default: T;
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
export declare const InjectionFormKey: InjectionKey<any>;
|
|
805
|
+
/**
|
|
806
|
+
* 根据组件名获取组件类型
|
|
807
|
+
* @template K - 组件名称
|
|
808
|
+
*/
|
|
809
|
+
declare type GetComponentType<K extends ComponentName> = K extends keyof ComponentMap ? ComponentMap[K] : K extends keyof BaseComponentMap ? BaseComponentMap[K] : never;
|
|
590
810
|
|
|
591
|
-
|
|
811
|
+
declare type Grid = boolean | (RowProps & {});
|
|
592
812
|
|
|
813
|
+
/**
|
|
814
|
+
* 判断类型是否为对象(排除函数、数组和 null)
|
|
815
|
+
* @template T - 要判断的类型
|
|
816
|
+
*/
|
|
593
817
|
declare type IsRecord<T> = T extends object ? T extends ((...args: any[]) => any) | any[] | null ? false : true : false;
|
|
594
818
|
|
|
595
819
|
declare type JoinPath<Prefix extends any[], Key extends PropertyKey> = [
|
|
@@ -597,8 +821,34 @@ declare type JoinPath<Prefix extends any[], Key extends PropertyKey> = [
|
|
|
597
821
|
KeyExpandString<Extract<Key, string>>
|
|
598
822
|
];
|
|
599
823
|
|
|
824
|
+
/**
|
|
825
|
+
* 展开字符串联合类型,保留字符串字面量,同时兼容 string
|
|
826
|
+
* @template T - 字符串字面量类型
|
|
827
|
+
*/
|
|
600
828
|
declare type KeyExpandString<T extends string> = T | (string & {});
|
|
601
829
|
|
|
830
|
+
/**
|
|
831
|
+
* 点号分隔的路径字符串类型
|
|
832
|
+
* @template D - 数据对象类型
|
|
833
|
+
*
|
|
834
|
+
* @description 用于类型安全地表示深层对象属性的路径。
|
|
835
|
+
* 例如给定 `{ user: { name: string; address: { city: string } } }`,
|
|
836
|
+
* 路径值可以是 `'user'`、`'user.name'`、`'user.address.city'`。
|
|
837
|
+
*
|
|
838
|
+
* 同时兼容 string 类型,用于运行时动态路径。
|
|
839
|
+
*
|
|
840
|
+
* @example
|
|
841
|
+
* ```ts
|
|
842
|
+
* interface User {
|
|
843
|
+
* name: string
|
|
844
|
+
* age: number
|
|
845
|
+
* address: { city: string; street: string }
|
|
846
|
+
* }
|
|
847
|
+
*
|
|
848
|
+
* type P = KeyPathString<User>
|
|
849
|
+
* // 'name' | 'age' | 'address' | 'address.city' | 'address.street' | string
|
|
850
|
+
* ```
|
|
851
|
+
*/
|
|
602
852
|
declare type KeyPathString<D extends Data> = KeyExpandString<AllowStringKey<D>>;
|
|
603
853
|
|
|
604
854
|
declare type MaybeRefOrComputedRef<T = any> = MaybeRef<T> | ComputedRef<T>;
|
|
@@ -608,28 +858,66 @@ declare type MaybeRefOrComputedRef<T = any> = MaybeRef<T> | ComputedRef<T>;
|
|
|
608
858
|
*/
|
|
609
859
|
declare type NotSupportedRefOrGetterProps = 'component' | 'formItemContainer' | 'componentContainer' | 'valueFormatter' | 'fields' | 'slots' | 'modelProp';
|
|
610
860
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
861
|
+
/**
|
|
862
|
+
* 分页参数
|
|
863
|
+
*
|
|
864
|
+
* @example
|
|
865
|
+
* ```ts
|
|
866
|
+
* const pageParam: PageParam = {
|
|
867
|
+
* current: 1,
|
|
868
|
+
* pageSize: 10,
|
|
869
|
+
* total: 100,
|
|
870
|
+
* }
|
|
871
|
+
* ```
|
|
872
|
+
*/
|
|
620
873
|
declare interface PageParam {
|
|
874
|
+
/** 当前页码 */
|
|
621
875
|
current: number;
|
|
876
|
+
/** 每页条数 */
|
|
622
877
|
pageSize: number;
|
|
878
|
+
/** 总记录数 */
|
|
623
879
|
total: number;
|
|
880
|
+
/** 其他自定义分页属性 */
|
|
624
881
|
[key: string]: any;
|
|
625
882
|
}
|
|
626
883
|
|
|
884
|
+
/**
|
|
885
|
+
* 路径类型,用于类型安全的深层属性访问
|
|
886
|
+
* @template D - 数据对象类型
|
|
887
|
+
*
|
|
888
|
+
* @description 提供对数据对象的深层路径的类型推导。
|
|
889
|
+
* 在 useFormData、useFields 等 API 中作为 path 参数的类型。
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* ```ts
|
|
893
|
+
* interface User { name: string; address: { city: string } }
|
|
894
|
+
*
|
|
895
|
+
* // 类型安全的路径
|
|
896
|
+
* const path: Path<User> = 'address.city' // ✅
|
|
897
|
+
* const path: Path<User> = 'invalid.path' // ❌ 类型错误
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
627
900
|
declare type Path<D extends Data = Data> = KeyPathString<D>;
|
|
628
901
|
|
|
629
|
-
|
|
902
|
+
declare type PathProps = {
|
|
630
903
|
path?: string;
|
|
631
904
|
} & Data;
|
|
632
905
|
|
|
906
|
+
/**
|
|
907
|
+
* 路径数组类型(Path 的数组表示)
|
|
908
|
+
* @template T - 数据对象类型
|
|
909
|
+
* @template Prefix - 前缀路径数组(内部递归使用)
|
|
910
|
+
*
|
|
911
|
+
* @description 与 Path 类似,但以元组数组形式表示路径。
|
|
912
|
+
*
|
|
913
|
+
* @example
|
|
914
|
+
* ```ts
|
|
915
|
+
* interface User { name: string; address: { city: string } }
|
|
916
|
+
*
|
|
917
|
+
* type P = Paths<User>
|
|
918
|
+
* // ['name'] | ['address'] | ['address', 'city']
|
|
919
|
+
* ```
|
|
920
|
+
*/
|
|
633
921
|
declare type Paths<T, Prefix extends any[] = []> = T extends object ? {
|
|
634
922
|
[K in keyof T]: IsRecord<T[K]> extends true ? JoinPath<Prefix, K> | Paths<T[K], JoinPath<Prefix, K>> : JoinPath<Prefix, K>;
|
|
635
923
|
}[keyof T] : never;
|
|
@@ -697,21 +985,21 @@ export declare const ProForm: SFCWithInstall<(<F extends Form<any> = Form>(__VLS
|
|
|
697
985
|
prefixCls?: string | undefined;
|
|
698
986
|
wrapperCol?: (ColProps & Partial<HTMLAttributes>) | undefined;
|
|
699
987
|
layout?: FormLayout | undefined;
|
|
700
|
-
|
|
701
|
-
onSubmit?: FormEmits["submit"] | undefined;
|
|
988
|
+
size?: ButtonSize;
|
|
702
989
|
disabled?: boolean | undefined;
|
|
703
|
-
|
|
990
|
+
variant?: Variant | undefined;
|
|
704
991
|
classes?: FormClassNamesType | undefined;
|
|
705
992
|
styles?: FormStylesType | undefined;
|
|
993
|
+
autoComplete?: string | undefined | undefined;
|
|
994
|
+
onReset?: FormEmits["reset"] | undefined;
|
|
995
|
+
onSubmit?: FormEmits["submit"] | undefined;
|
|
996
|
+
labelWrap?: boolean | undefined;
|
|
706
997
|
feedbackIcons?: FeedbackIcons | undefined;
|
|
707
|
-
size?: ButtonSize;
|
|
708
998
|
scrollToFirstError?: (ScrollFocusOptions | boolean) | undefined;
|
|
709
|
-
variant?: Variant | undefined;
|
|
710
999
|
validateMessages?: ValidateMessages | undefined;
|
|
711
1000
|
preserve?: boolean | undefined;
|
|
712
1001
|
clearOnDestroy?: boolean | undefined;
|
|
713
1002
|
validateOnRuleChange?: boolean | undefined;
|
|
714
|
-
autoComplete?: string | undefined | undefined;
|
|
715
1003
|
onFinish?: FormEmits["finish"] | undefined;
|
|
716
1004
|
onFinishFailed?: FormEmits["finishFailed"] | undefined;
|
|
717
1005
|
onValidate?: FormEmits["validate"] | undefined;
|
|
@@ -740,28 +1028,23 @@ export declare const ProForm: SFCWithInstall<(<F extends Form<any> = Form>(__VLS
|
|
|
740
1028
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
741
1029
|
})>;
|
|
742
1030
|
|
|
743
|
-
export declare type ProFormInstance = ComponentExposed<typeof
|
|
1031
|
+
export declare type ProFormInstance = ComponentExposed<typeof _default_3>;
|
|
744
1032
|
|
|
745
|
-
export declare type ProFormItemInstance = ComponentExposed<typeof
|
|
1033
|
+
export declare type ProFormItemInstance = ComponentExposed<typeof _default_4>;
|
|
746
1034
|
|
|
747
|
-
export declare type ProFormItemProps = ComponentProps<typeof
|
|
1035
|
+
export declare type ProFormItemProps = ComponentProps<typeof _default_4>;
|
|
748
1036
|
|
|
749
|
-
export declare type ProFormProps = ComponentProps<typeof
|
|
1037
|
+
export declare type ProFormProps = ComponentProps<typeof _default_3>;
|
|
750
1038
|
|
|
751
1039
|
declare type Props = {
|
|
752
|
-
component?: string | Component;
|
|
753
|
-
path?: string;
|
|
754
|
-
};
|
|
755
|
-
|
|
756
|
-
declare type Props_2 = {
|
|
757
1040
|
component?: ContainerComponent;
|
|
758
1041
|
};
|
|
759
1042
|
|
|
760
|
-
declare type
|
|
1043
|
+
declare type Props_2 = {
|
|
761
1044
|
component?: SlotComponentType;
|
|
762
1045
|
};
|
|
763
1046
|
|
|
764
|
-
declare type
|
|
1047
|
+
declare type Props_3 = {
|
|
765
1048
|
grid?: Grid;
|
|
766
1049
|
fields?: Fields;
|
|
767
1050
|
disabled?: boolean;
|
|
@@ -777,9 +1060,9 @@ export declare type ProTableProps = ComponentProps<typeof _default_2>;
|
|
|
777
1060
|
* @description 自定义组件
|
|
778
1061
|
* @example (p, ctx) => h('div', ctx.attrs)
|
|
779
1062
|
*/
|
|
780
|
-
|
|
1063
|
+
declare type RenderComponentType = Component<VModelProps & PathProps>;
|
|
781
1064
|
|
|
782
|
-
|
|
1065
|
+
declare type RequiredComponentVars = {
|
|
783
1066
|
'pro-table': PP<TableProps & Pick<ProTableProps, 'control' | 'searchFormConfig' | 'immediateSearch' | 'addIndexColumn' | 'tableContainer'>>;
|
|
784
1067
|
'pro-form': PP<Omit<ProFormProps, 'form' | 'grid'> & {
|
|
785
1068
|
grid: Exclude<Grid, undefined | boolean>;
|
|
@@ -811,41 +1094,105 @@ declare type SetPageParam = (pageParam: Partial<PageParam> | ((pre: Readonly<Pag
|
|
|
811
1094
|
|
|
812
1095
|
declare type SFCWithInstall<T> = T & Plugin_2;
|
|
813
1096
|
|
|
814
|
-
export declare const SlotComponent: DefineComponent<
|
|
1097
|
+
export declare const SlotComponent: DefineComponent<Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props_2> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
815
1098
|
|
|
816
1099
|
/**
|
|
817
1100
|
* @description 插槽组件类型
|
|
818
1101
|
*/
|
|
819
|
-
|
|
1102
|
+
declare type SlotComponentType = Component<PathProps> | VNode | string | number | boolean | null | undefined | ((...args: any[]) => SlotComponentType);
|
|
820
1103
|
|
|
821
1104
|
/**
|
|
822
1105
|
* @description 插槽对象类型
|
|
823
1106
|
*/
|
|
824
|
-
|
|
1107
|
+
declare type Slots = {
|
|
825
1108
|
[name: string]: SlotComponentType;
|
|
826
1109
|
};
|
|
827
1110
|
|
|
828
1111
|
/**
|
|
829
|
-
*
|
|
1112
|
+
* @qin-ui/antdv-next-pro 的表格实例类型
|
|
1113
|
+
*
|
|
1114
|
+
* @description 在 core Table 类型的基础上,将列类型 C 绑定为本地 Column<T>,
|
|
1115
|
+
* 使 columns 操作获得 antdv-next 表格列的完整属性类型提示。
|
|
1116
|
+
*
|
|
1117
|
+
* @template D - 搜索表单数据类型
|
|
1118
|
+
* @template T - 表格行数据类型
|
|
1119
|
+
|
|
1120
|
+
* @public
|
|
830
1121
|
*/
|
|
831
1122
|
export declare type Table<D extends Data = Data, T extends Data = ExtendWithAny<D>> = Table_2<D, T, Column<T>>;
|
|
832
1123
|
|
|
1124
|
+
/**
|
|
1125
|
+
* 表格实例类型
|
|
1126
|
+
* @template D - 搜索表单数据类型
|
|
1127
|
+
* @template T - 表格数据类型(表格行数据类型),默认为 ExtendWithAny<D>
|
|
1128
|
+
* @template C - 列配置类型,继承自 BaseColumn<T>
|
|
1129
|
+
*
|
|
1130
|
+
* 组合了列操作、数据源管理、分页管理和搜索表单的能力。
|
|
1131
|
+
*
|
|
1132
|
+
* @example
|
|
1133
|
+
* ```ts
|
|
1134
|
+
* interface User { name: string; age: number; }
|
|
1135
|
+
* interface SearchParams { keyword: string }
|
|
1136
|
+
*
|
|
1137
|
+
* const table: Table<SearchParams, User> = useTable({
|
|
1138
|
+
* columns: [
|
|
1139
|
+
* { key: 'name', title: '姓名' },
|
|
1140
|
+
* { key: 'age', title: '年龄' },
|
|
1141
|
+
* ],
|
|
1142
|
+
* dataSource: [
|
|
1143
|
+
* { name: '张三', age: 25 },
|
|
1144
|
+
* ],
|
|
1145
|
+
* searchFields: [
|
|
1146
|
+
* { path: 'keyword', label: '关键词', component: 'input' },
|
|
1147
|
+
* ],
|
|
1148
|
+
* })
|
|
1149
|
+
*
|
|
1150
|
+
* // 列操作
|
|
1151
|
+
* table.setColumn('name', { title: '用户名' })
|
|
1152
|
+
* table.appendColumn('name', { key: 'email', title: '邮箱' })
|
|
1153
|
+
* table.deleteColumn('age')
|
|
1154
|
+
*
|
|
1155
|
+
* // 分页操作
|
|
1156
|
+
* table.setPageParam({ current: 2, pageSize: 20 })
|
|
1157
|
+
* table.resetQueryParams()
|
|
1158
|
+
*
|
|
1159
|
+
* // 搜索表单
|
|
1160
|
+
* table.searchForm.getFormData('keyword')
|
|
1161
|
+
* table.searchForm.setFormData('keyword', '张三')
|
|
1162
|
+
* ```
|
|
1163
|
+
*/
|
|
833
1164
|
declare type Table_2<D extends Data = Data, T extends Data = ExtendWithAny<D>, C extends BaseColumn<T> = BaseColumn<T>> = {
|
|
1165
|
+
/** 列配置数组(响应式) */
|
|
834
1166
|
columns: Ref<Columns_2<T, C>>;
|
|
1167
|
+
/** 数据源数组(响应式) */
|
|
835
1168
|
dataSource: Ref<T[]>;
|
|
1169
|
+
/** 分页参数(响应式) */
|
|
836
1170
|
pageParam: Reactive<PageParam>;
|
|
1171
|
+
/** 搜索表单实例 */
|
|
837
1172
|
searchForm: Form_2<D>;
|
|
1173
|
+
/** 设置列配置 */
|
|
838
1174
|
setColumn: SetColumn<T, C>;
|
|
1175
|
+
/** 删除列 */
|
|
839
1176
|
deleteColumn: (path: Path<T> | ColumnFindBy<T, C>, options?: UpdateColumnOptions) => void;
|
|
1177
|
+
/** 在指定列后追加列 */
|
|
840
1178
|
appendColumn: (path: Path<T> | ColumnFindBy<T, C> | undefined, column: C | Columns_2<T, C>, options?: UpdateColumnOptions) => void;
|
|
1179
|
+
/** 在指定列前插入列 */
|
|
841
1180
|
prependColumn: (path: Path<T> | ColumnFindBy<T, C> | undefined, column: C | Columns_2<T, C>, options?: UpdateColumnOptions) => void;
|
|
1181
|
+
/** 设置分页参数 */
|
|
842
1182
|
setPageParam: SetPageParam;
|
|
1183
|
+
/** 重置查询参数(重置分页和搜索条件到初始值) */
|
|
843
1184
|
resetQueryParams: () => void;
|
|
844
1185
|
};
|
|
845
1186
|
|
|
846
|
-
|
|
847
|
-
|
|
1187
|
+
/**
|
|
1188
|
+
* 列更新选项
|
|
1189
|
+
*/
|
|
848
1190
|
declare type UpdateColumnOptions = {
|
|
1191
|
+
/**
|
|
1192
|
+
* @description 是否更新所有匹配的列
|
|
1193
|
+
* - true: 更新所有匹配的列
|
|
1194
|
+
* - false/undefined: 只更新第一个匹配的列
|
|
1195
|
+
*/
|
|
849
1196
|
all?: boolean;
|
|
850
1197
|
};
|
|
851
1198
|
|
|
@@ -853,19 +1200,96 @@ declare type UpdateFieldOptions = {
|
|
|
853
1200
|
all?: boolean;
|
|
854
1201
|
};
|
|
855
1202
|
|
|
856
|
-
/** useFields 返回值类型,固定为本地 Fields<D>
|
|
1203
|
+
/** useFields 返回值类型,固定为本地 Fields<D>
|
|
1204
|
+
* @public
|
|
1205
|
+
*/
|
|
857
1206
|
export declare type UseFields<D extends Data = Data> = ReturnType<typeof useFields<D>>;
|
|
858
1207
|
|
|
859
1208
|
/**
|
|
860
|
-
*
|
|
861
|
-
*
|
|
862
|
-
*
|
|
1209
|
+
* @qin-ui/antdv-next-pro 的字段配置管理 Hook
|
|
1210
|
+
*
|
|
1211
|
+
* @description 类型安全的 re-export。将 core useFields 的泛型参数绑定为本地类型:
|
|
1212
|
+
* - 字段类型 F → Field<ComponentName, D>(支持 antdv-next 组件类型推导)
|
|
1213
|
+
* - FormItem 实例 → antdv-next 的 FormItemInstance
|
|
1214
|
+
*
|
|
1215
|
+
* @template D - 表单数据类型
|
|
1216
|
+
*
|
|
1217
|
+
* @example
|
|
1218
|
+
* ```ts
|
|
1219
|
+
* interface User { name: string; age: number }
|
|
1220
|
+
*
|
|
1221
|
+
* const { fields, getField, setField } = useFields<User>([
|
|
1222
|
+
* { path: 'name', label: '姓名', component: 'input' },
|
|
1223
|
+
* { path: 'age', label: '年龄', component: 'input-number' },
|
|
1224
|
+
* ])
|
|
1225
|
+
* ```
|
|
1226
|
+
|
|
1227
|
+
* @public
|
|
863
1228
|
*/
|
|
864
1229
|
export declare const useFields: {
|
|
865
1230
|
<D extends Data = Data>(initFields?: Fields<D>): ReturnType<typeof useFields_2<D, Field<ComponentName, D>, FormItemInstance>>;
|
|
866
1231
|
};
|
|
867
1232
|
|
|
868
|
-
|
|
1233
|
+
/**
|
|
1234
|
+
* 字段配置管理 Hook
|
|
1235
|
+
*
|
|
1236
|
+
* @description 提供对字段配置数组的增删改查操作,支持:
|
|
1237
|
+
* - 通过路径字符串或查找函数定位字段
|
|
1238
|
+
* - 深层嵌套字段的遍历和匹配
|
|
1239
|
+
* - 字段配置的合并/覆盖更新
|
|
1240
|
+
* - 字段的添加、插入、删除
|
|
1241
|
+
* - 父级字段查找
|
|
1242
|
+
*
|
|
1243
|
+
* @template D - 表单数据类型,用于路径类型推导
|
|
1244
|
+
* @template F - 字段配置类型,继承自 BaseField<D>
|
|
1245
|
+
* @template FormInstance - 底层 FormItem 组件实例类型
|
|
1246
|
+
*
|
|
1247
|
+
* @param {F[]} [initFields] - 初始字段配置数组
|
|
1248
|
+
*
|
|
1249
|
+
* @returns {object} 字段操作对象
|
|
1250
|
+
* @returns {Ref<F[]>} .fields - 字段配置数组(响应式)
|
|
1251
|
+
* @returns {Function} .getField(path) - 获取字段配置
|
|
1252
|
+
* @returns {Function} .setField(path, field) - 更新字段配置
|
|
1253
|
+
* @returns {Function} .deleteField(path) - 删除字段
|
|
1254
|
+
* @returns {Function} .appendField(path, field) - 在指定字段后追加
|
|
1255
|
+
* @returns {Function} .prependField(path, field) - 在指定字段前插入
|
|
1256
|
+
* @returns {Function} .getParentField(path) - 获取父级字段
|
|
1257
|
+
*
|
|
1258
|
+
* @example
|
|
1259
|
+
* ```ts
|
|
1260
|
+
* interface User { name: string; age: number; address: { city: string } }
|
|
1261
|
+
*
|
|
1262
|
+
* const { fields, getField, setField, deleteField } = useFields<User>([
|
|
1263
|
+
* { path: 'name', label: '姓名', component: 'input' },
|
|
1264
|
+
* { path: 'age', label: '年龄', component: 'input-number' },
|
|
1265
|
+
* {
|
|
1266
|
+
* path: 'address',
|
|
1267
|
+
* label: '地址',
|
|
1268
|
+
* fields: [
|
|
1269
|
+
* { path: 'city', label: '城市' },
|
|
1270
|
+
* ],
|
|
1271
|
+
* },
|
|
1272
|
+
* ])
|
|
1273
|
+
*
|
|
1274
|
+
* // 通过路径获取字段
|
|
1275
|
+
* getField('name') // { path: 'name', label: '姓名', ... }
|
|
1276
|
+
* getField('address.city') // { path: 'city', label: '城市', ... }
|
|
1277
|
+
*
|
|
1278
|
+
* // 通过查找函数获取字段
|
|
1279
|
+
* getField(f => f.label === '姓名')
|
|
1280
|
+
*
|
|
1281
|
+
* // 更新字段(合并模式)
|
|
1282
|
+
* setField('name', { label: '用户名' })
|
|
1283
|
+
*
|
|
1284
|
+
* // 删除字段
|
|
1285
|
+
* deleteField('age')
|
|
1286
|
+
*
|
|
1287
|
+
* // 追加/插入字段
|
|
1288
|
+
* appendField('name', { path: 'email', label: '邮箱', component: 'input' })
|
|
1289
|
+
* prependField('name', { path: 'id', label: 'ID', component: 'input' })
|
|
1290
|
+
* ```
|
|
1291
|
+
*/
|
|
1292
|
+
declare const useFields_2: <D extends Data = Data, F extends BaseField<D> = BaseField<D>, FormInstance = any>(initFields?: F[]) => {
|
|
869
1293
|
fields: Ref<F[], F[]>;
|
|
870
1294
|
getField: {
|
|
871
1295
|
(path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
@@ -894,8 +1318,29 @@ declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = Ba
|
|
|
894
1318
|
};
|
|
895
1319
|
|
|
896
1320
|
/**
|
|
897
|
-
*
|
|
898
|
-
*
|
|
1321
|
+
* 创建 @qin-ui/antdv-next-pro 表单实例的 Hook
|
|
1322
|
+
*
|
|
1323
|
+
* @description 类型安全的 re-export。将 core useForm 的泛型参数绑定为本地类型:
|
|
1324
|
+
* - 字段类型 F → Field<ComponentName, D>(支持 antdv-next 组件类型推导)
|
|
1325
|
+
* - 表单实例 → antdv-next 的 FormInstance
|
|
1326
|
+
*
|
|
1327
|
+
* @template D - 表单数据类型
|
|
1328
|
+
*
|
|
1329
|
+
* @example
|
|
1330
|
+
* ```ts
|
|
1331
|
+
* interface User { name: string; age: number }
|
|
1332
|
+
*
|
|
1333
|
+
* const form = useForm<User>(
|
|
1334
|
+
* { name: '张三', age: 25 },
|
|
1335
|
+
* [
|
|
1336
|
+
* { path: 'name', label: '姓名', component: 'input' },
|
|
1337
|
+
* { path: 'age', label: '年龄', component: 'input-number' },
|
|
1338
|
+
* ],
|
|
1339
|
+
* true
|
|
1340
|
+
* )
|
|
1341
|
+
* ```
|
|
1342
|
+
|
|
1343
|
+
* @public
|
|
899
1344
|
*/
|
|
900
1345
|
export declare const useForm: {
|
|
901
1346
|
<D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>, initFields?: Field<ComponentName, D>[], root?: boolean): Form<D, Field<ComponentName, D>>;
|
|
@@ -903,9 +1348,43 @@ export declare const useForm: {
|
|
|
903
1348
|
};
|
|
904
1349
|
|
|
905
1350
|
/**
|
|
906
|
-
* 表单数据处理
|
|
907
|
-
*
|
|
908
|
-
* @
|
|
1351
|
+
* 表单数据处理 Hook
|
|
1352
|
+
*
|
|
1353
|
+
* @description 提供响应式表单数据的管理能力,支持:
|
|
1354
|
+
* - 响应式数据存储(基于 Vue reactive)
|
|
1355
|
+
* - 深层路径读写(支持点号分隔,如 'address.city')
|
|
1356
|
+
* - 类型安全的路径提示(传入泛型 D 后,path 参数可获得类型推导)
|
|
1357
|
+
* - 父子表单自动注入(非根表单会从注入中获取数据)
|
|
1358
|
+
* @public
|
|
1359
|
+
*
|
|
1360
|
+
* @template D - 表单数据类型,应为一个对象类型
|
|
1361
|
+
* @param {ExtendWithAny<DeepPartial<D>>} [initFormData] - 初始表单数据
|
|
1362
|
+
*
|
|
1363
|
+
* @returns {object} 表单数据操作对象
|
|
1364
|
+
* @returns {D & Record<string, any>} .formData - 响应式表单数据
|
|
1365
|
+
* @returns {Function} .getFormData(path) - 获取指定路径的数据
|
|
1366
|
+
* @returns {Function} .setFormData(path, value) - 设置指定路径的数据
|
|
1367
|
+
*
|
|
1368
|
+
* @example
|
|
1369
|
+
* ```ts
|
|
1370
|
+
* interface User { name: string; age: number; address: { city: string } }
|
|
1371
|
+
*
|
|
1372
|
+
* const { formData, getFormData, setFormData } = useFormData<User>({
|
|
1373
|
+
* name: '张三',
|
|
1374
|
+
* address: { city: '北京' }
|
|
1375
|
+
* })
|
|
1376
|
+
*
|
|
1377
|
+
* // 读取
|
|
1378
|
+
* getFormData('name') // '张三'
|
|
1379
|
+
* getFormData('address.city') // '北京'
|
|
1380
|
+
* formData.name // '张三'(响应式)
|
|
1381
|
+
*
|
|
1382
|
+
* // 设置
|
|
1383
|
+
* setFormData('name', '李四')
|
|
1384
|
+
* setFormData('address.city', '上海')
|
|
1385
|
+
* setFormData({ name: '王五', age: 30 }) // 批量覆盖
|
|
1386
|
+
* setFormData(prev => ({ ...prev, name: '赵六' })) // 函数式更新
|
|
1387
|
+
* ```
|
|
909
1388
|
*/
|
|
910
1389
|
export declare const useFormData: <D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>) => {
|
|
911
1390
|
formData: Reactive<ExtendWithAny<D>>;
|
|
@@ -924,20 +1403,76 @@ export declare const useFormData: <D extends Data = Data>(initFormData?: ExtendW
|
|
|
924
1403
|
};
|
|
925
1404
|
|
|
926
1405
|
/**
|
|
927
|
-
*
|
|
928
|
-
*
|
|
1406
|
+
* @qin-ui/antdv-next-pro 的表单组件实例引用 Hook
|
|
1407
|
+
*
|
|
1408
|
+
* @description 类型安全的 re-export。将 core useFormRef 的泛型参数绑定为 antdv-next 的 FormInstance,
|
|
1409
|
+
* 使 formRef 获取到完整的 antdv-next Form 组件 API 类型提示。
|
|
1410
|
+
*
|
|
1411
|
+
* @returns {object} 表单组件实例引用管理对象
|
|
1412
|
+
* @returns {Ref<FormInstance | undefined>} .formRef - antdv-next Form 实例的响应式引用
|
|
1413
|
+
* @returns {Function} .setFormRef(inst) - 设置表单组件实例
|
|
1414
|
+
*
|
|
1415
|
+
* @example
|
|
1416
|
+
* ```ts
|
|
1417
|
+
* const { formRef, setFormRef } = useFormRef()
|
|
1418
|
+
* await formRef.value?.validate()
|
|
1419
|
+
* formRef.value?.resetFields()
|
|
1420
|
+
* ```
|
|
1421
|
+
|
|
1422
|
+
* @public
|
|
929
1423
|
*/
|
|
930
1424
|
export declare const useFormRef: {
|
|
931
1425
|
(): ReturnType<typeof useFormRef_2<FormInstance>>;
|
|
932
1426
|
};
|
|
933
1427
|
|
|
1428
|
+
/**
|
|
1429
|
+
* 表单组件实例引用 Hook
|
|
1430
|
+
*
|
|
1431
|
+
* @description 用于获取和设置底层 UI 框架(如 ant-design-vue、element-plus)的 Form 组件实例。
|
|
1432
|
+
* 在 ProForm 组件内部自动调用 setFormRef 绑定实例,外部可通过 formRef 访问。
|
|
1433
|
+
*
|
|
1434
|
+
* @template F - 底层 Form 组件实例类型,默认为 any
|
|
1435
|
+
*
|
|
1436
|
+
* @returns {object} 表单组件实例引用管理对象
|
|
1437
|
+
* @returns {Ref<F | undefined>} .formRef - 表单组件实例的响应式引用
|
|
1438
|
+
* @returns {Function} .setFormRef(inst) - 设置表单组件实例
|
|
1439
|
+
*
|
|
1440
|
+
* @example
|
|
1441
|
+
* ```ts
|
|
1442
|
+
* const { formRef, setFormRef } = useFormRef<InstanceType<typeof AForm>>()
|
|
1443
|
+
* setFormRef(formComponentInstance)
|
|
1444
|
+
* console.log(formRef.value) // 可通过 formRef 访问底层 Form 实例的方法
|
|
1445
|
+
* ```
|
|
1446
|
+
*/
|
|
934
1447
|
declare const useFormRef_2: <F = any>() => {
|
|
935
1448
|
formRef: Ref<F | undefined, F | undefined>;
|
|
936
1449
|
setFormRef: (inst: F) => void;
|
|
937
1450
|
};
|
|
938
1451
|
|
|
939
1452
|
/**
|
|
940
|
-
*
|
|
1453
|
+
* 创建 @qin-ui/antdv-next-pro 表格实例的 Hook
|
|
1454
|
+
*
|
|
1455
|
+
* @description 类型安全的 re-export。将 core useTable 的列类型绑定为本地 Column<T>,
|
|
1456
|
+
* 使 columns 操作获得 antdv-next 表格列的完整类型提示。
|
|
1457
|
+
*
|
|
1458
|
+
* @template D - 搜索表单数据类型
|
|
1459
|
+
* @template T - 表格行数据类型
|
|
1460
|
+
*
|
|
1461
|
+
* @example
|
|
1462
|
+
* ```ts
|
|
1463
|
+
* interface User { name: string; age: number; email: string }
|
|
1464
|
+
*
|
|
1465
|
+
* const table = useTable<User>({
|
|
1466
|
+
* columns: [
|
|
1467
|
+
* { dataIndex: 'name', title: '姓名', width: 120 },
|
|
1468
|
+
* { dataIndex: 'age', title: '年龄', width: 80 },
|
|
1469
|
+
* ],
|
|
1470
|
+
* dataSource: [],
|
|
1471
|
+
* pageParam: { current: 1, pageSize: 20, total: 0 },
|
|
1472
|
+
* })
|
|
1473
|
+
* ```
|
|
1474
|
+
|
|
1475
|
+
* @public
|
|
941
1476
|
*/
|
|
942
1477
|
export declare const useTable: <D extends Data = Data, T extends Data = ExtendWithAny<D>>(params: {
|
|
943
1478
|
columns?: Columns<T>;
|
|
@@ -947,14 +1482,14 @@ export declare const useTable: <D extends Data = Data, T extends Data = ExtendWi
|
|
|
947
1482
|
searchFields?: Fields<D>;
|
|
948
1483
|
}) => Table<D, T>;
|
|
949
1484
|
|
|
950
|
-
|
|
1485
|
+
declare type ValueFormatter = {
|
|
951
1486
|
(val: any, oldVal: any): any;
|
|
952
1487
|
} | {
|
|
953
1488
|
get?: (val: any) => any;
|
|
954
1489
|
set?: (val: any, oldVal: any) => any;
|
|
955
1490
|
};
|
|
956
1491
|
|
|
957
|
-
|
|
1492
|
+
declare type VModelProps<T = any> = {
|
|
958
1493
|
value?: T;
|
|
959
1494
|
'onUpdate:value'?: (val: T) => void;
|
|
960
1495
|
};
|
|
@@ -978,7 +1513,7 @@ declare type WithFields<D extends Data = Data> = WithRef<WithCommonBase & BaseWi
|
|
|
978
1513
|
* @description 为对象属性添加响应式支持的类型
|
|
979
1514
|
* @template T - 原始类型
|
|
980
1515
|
*/
|
|
981
|
-
|
|
1516
|
+
declare type WithRef<T> = {
|
|
982
1517
|
[P in keyof T]: P extends NotSupportedRefOrGetterProps ? T[P] : T[P] extends (...args: any[]) => any ? T[P] : MaybeRefOrComputedRef<T[P]>;
|
|
983
1518
|
};
|
|
984
1519
|
|