@qin-ui/antd-vue-pro 2.1.10 → 2.1.12
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 +123 -0
- package/README.md +312 -67
- package/api.json +229 -0
- package/es/antd-vue-pro.css +9 -9
- package/es/component-provider/index-Dmz32tSB.js +174 -0
- package/es/component-provider/index.js +2 -172
- package/es/core/{index-C98RSrpN.js → index-ghYuQ3Sy.js} +29 -29
- package/es/form/index.js +65 -74
- package/es/index.d.ts +759 -134
- package/es/index.js +18 -17
- package/es/table/index.js +7 -6
- package/package.json +5 -2
package/es/index.d.ts
CHANGED
|
@@ -31,13 +31,12 @@ import { FormProps as FormProps_2 } from 'ant-design-vue';
|
|
|
31
31
|
import { GlobalComponents } from 'vue';
|
|
32
32
|
import { GlobalDirectives } from 'vue';
|
|
33
33
|
import { HTMLAttributes } from 'vue';
|
|
34
|
-
import { InjectionKey } from 'vue';
|
|
35
34
|
import { Input } from 'ant-design-vue';
|
|
36
35
|
import { InputNumber } from 'ant-design-vue';
|
|
37
36
|
import { InputPassword } from 'ant-design-vue';
|
|
38
37
|
import { InputSearch } from 'ant-design-vue';
|
|
39
38
|
import { MaybeRef } from 'vue';
|
|
40
|
-
import { Options
|
|
39
|
+
import { Options } from 'scroll-into-view-if-needed';
|
|
41
40
|
import { Plugin as Plugin_2 } from 'vue';
|
|
42
41
|
import { PropType } from 'vue';
|
|
43
42
|
import { PublicProps } from 'vue';
|
|
@@ -65,7 +64,7 @@ import { ValidateMessages } from 'ant-design-vue/es/form/interface';
|
|
|
65
64
|
import { VNode } from 'vue';
|
|
66
65
|
import { VNodeProps } from 'vue';
|
|
67
66
|
|
|
68
|
-
declare const __VLS_component: DefineComponent<
|
|
67
|
+
declare const __VLS_component: DefineComponent<Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
69
68
|
|
|
70
69
|
declare type __VLS_PrettifyLocal<T> = {
|
|
71
70
|
[K in keyof T]: T[K];
|
|
@@ -93,13 +92,17 @@ declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
|
93
92
|
};
|
|
94
93
|
};
|
|
95
94
|
|
|
95
|
+
/**
|
|
96
|
+
* FormItem 实例提供的额外方法
|
|
97
|
+
* @template FormItemInstance - FormItem 组件实例类型
|
|
98
|
+
*/
|
|
96
99
|
declare type AdditionalMethods<FormItemInstance> = {
|
|
97
100
|
/**
|
|
98
|
-
* @description 获取FormItem实例的方法
|
|
101
|
+
* @description 获取 FormItem 实例的方法
|
|
99
102
|
*/
|
|
100
103
|
getFormItemRef?: () => FormItemInstance;
|
|
101
104
|
/**
|
|
102
|
-
* @description 获取传入FormItem组件的属性
|
|
105
|
+
* @description 获取传入 FormItem 组件的属性
|
|
103
106
|
*/
|
|
104
107
|
getFormItemComputedProps?: () => Readonly<{
|
|
105
108
|
[x: string]: any;
|
|
@@ -109,7 +112,7 @@ declare type AdditionalMethods<FormItemInstance> = {
|
|
|
109
112
|
*/
|
|
110
113
|
getComponentRef?: () => any;
|
|
111
114
|
/**
|
|
112
|
-
* @description 获取传入Component组件的属性
|
|
115
|
+
* @description 获取传入 Component 组件的属性
|
|
113
116
|
*/
|
|
114
117
|
getComponentComputedProps?: () => Readonly<{
|
|
115
118
|
disabled?: boolean;
|
|
@@ -124,12 +127,49 @@ declare type AllowStringKey<T, Prefix extends string = ''> = {
|
|
|
124
127
|
/**
|
|
125
128
|
* @type {Object} Base - 基础公共字段类型
|
|
126
129
|
*/
|
|
127
|
-
|
|
130
|
+
declare type Base<D extends Data = Data> = BaseWithFields<D> | BaseWithoutFields<D>;
|
|
128
131
|
|
|
132
|
+
/**
|
|
133
|
+
* 基础表格列配置接口
|
|
134
|
+
* @template D - 表格数据类型,应为一个对象类型
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* interface User { name: string; age: number; address: { city: string } }
|
|
139
|
+
*
|
|
140
|
+
* // 简单列
|
|
141
|
+
* const column: BaseColumn<User> = {
|
|
142
|
+
* key: 'name',
|
|
143
|
+
* title: '姓名',
|
|
144
|
+
* }
|
|
145
|
+
*
|
|
146
|
+
* // 带数据索引和嵌套列
|
|
147
|
+
* const column: BaseColumn<User> = {
|
|
148
|
+
* key: 'address',
|
|
149
|
+
* title: '地址',
|
|
150
|
+
* children: [
|
|
151
|
+
* { key: 'city', title: '城市' },
|
|
152
|
+
* ],
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
129
156
|
declare interface BaseColumn<D extends Data = Data> {
|
|
157
|
+
/**
|
|
158
|
+
* @description 列字段路径(数据对象的 key 路径),支持点号分隔的深层路径
|
|
159
|
+
* @example 'name' | 'address.city'
|
|
160
|
+
*/
|
|
130
161
|
key?: Path<D>;
|
|
162
|
+
/**
|
|
163
|
+
* @description 数据索引,与 key 作用类似,支持数组格式
|
|
164
|
+
* @example 'name' | ['address', 'city']
|
|
165
|
+
*/
|
|
131
166
|
dataIndex?: Path<D> | Path<D>[];
|
|
167
|
+
/**
|
|
168
|
+
* @description 嵌套子列配置,用于实现表头分组
|
|
169
|
+
* @example [{ key: 'firstName', title: '名' }, { key: 'lastName', title: '姓' }]
|
|
170
|
+
*/
|
|
132
171
|
children?: BaseColumn<D>[];
|
|
172
|
+
/** 其他任意自定义属性(如 title、width、fixed 等 UI 属性) */
|
|
133
173
|
[key: string]: any;
|
|
134
174
|
}
|
|
135
175
|
|
|
@@ -191,7 +231,11 @@ declare type BaseCommon<D extends Data = Data> = {
|
|
|
191
231
|
extraProps?: Record<string, any>;
|
|
192
232
|
};
|
|
193
233
|
|
|
194
|
-
|
|
234
|
+
/**
|
|
235
|
+
* 内置组件映射表
|
|
236
|
+
* @description Ant Design Vue 内置支持的组件类型映射
|
|
237
|
+
*/
|
|
238
|
+
declare type BaseComponentMap = {
|
|
195
239
|
'input': typeof Input;
|
|
196
240
|
'textarea': typeof Textarea;
|
|
197
241
|
'input-search': typeof InputSearch;
|
|
@@ -210,49 +254,49 @@ export declare type BaseComponentMap = {
|
|
|
210
254
|
'transfer': typeof Transfer;
|
|
211
255
|
};
|
|
212
256
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
257
|
+
/**
|
|
258
|
+
* 基础字段配置接口
|
|
259
|
+
* @template D - 表单数据类型,应为一个对象类型
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```ts
|
|
263
|
+
* // 简单的文本输入字段
|
|
264
|
+
* const field: BaseField<{ name: string }> = {
|
|
265
|
+
* path: 'name',
|
|
266
|
+
* label: '姓名',
|
|
267
|
+
* }
|
|
268
|
+
*
|
|
269
|
+
* // 带嵌套子字段
|
|
270
|
+
* const field: BaseField<{ address: { city: string; street: string } }> = {
|
|
271
|
+
* path: 'address',
|
|
272
|
+
* label: '地址',
|
|
273
|
+
* fields: [
|
|
274
|
+
* { path: 'city', label: '城市' },
|
|
275
|
+
* { path: 'street', label: '街道' },
|
|
276
|
+
* ],
|
|
277
|
+
* }
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
declare interface BaseField<D extends Data = Data> {
|
|
281
|
+
/**
|
|
282
|
+
* @description 字段路径(数据对象的 key 路径),支持点号分隔的深层路径
|
|
283
|
+
* @example 'name' | 'user.address.city'
|
|
284
|
+
*/
|
|
221
285
|
path?: Path<D> | any;
|
|
286
|
+
/**
|
|
287
|
+
* @description 字段名称,与 path 作用相同,两者选其一即可
|
|
288
|
+
* @deprecated 推荐使用 path 替代
|
|
289
|
+
*/
|
|
222
290
|
name?: any;
|
|
291
|
+
/**
|
|
292
|
+
* @description 嵌套子字段配置数组,用于实现分组/嵌套字段
|
|
293
|
+
* @example [{ path: 'firstName', label: '名' }, { path: 'lastName', label: '姓' }]
|
|
294
|
+
*/
|
|
223
295
|
fields?: any[];
|
|
296
|
+
/** 其他任意自定义属性 */
|
|
224
297
|
[key: string]: any;
|
|
225
298
|
}
|
|
226
299
|
|
|
227
|
-
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<{
|
|
228
|
-
props: __VLS_PrettifyLocal_2<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & ({
|
|
229
|
-
grid?: Grid;
|
|
230
|
-
form?: F;
|
|
231
|
-
} & Partial<Omit<FormProps, "model">>) & Partial<{}>> & PublicProps;
|
|
232
|
-
expose(exposed: ShallowUnwrapRef< {}>): void;
|
|
233
|
-
attrs: any;
|
|
234
|
-
slots: Readonly<Partial<Record<F extends Form<infer D extends Data> ? Path<D> : string, Slot<VModelProps & {
|
|
235
|
-
path?: string;
|
|
236
|
-
} & Data & {
|
|
237
|
-
[x: string]: any;
|
|
238
|
-
disabled?: boolean;
|
|
239
|
-
}>> & {
|
|
240
|
-
default: Slot;
|
|
241
|
-
}>> & 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
|
-
}>;
|
|
249
|
-
emit: {};
|
|
250
|
-
}>) => VNode & {
|
|
251
|
-
__ctx?: Awaited<typeof __VLS_setup>;
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
export declare const BaseFormItem: DefineComponent<Props_4, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props_4> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
255
|
-
|
|
256
300
|
declare type BaseWithFields<D extends Data = Data> = BaseCommon<D> & {
|
|
257
301
|
/**
|
|
258
302
|
* @description 嵌套子字段配置
|
|
@@ -311,25 +355,111 @@ declare type ButtonProps = {
|
|
|
311
355
|
onClick: () => void;
|
|
312
356
|
};
|
|
313
357
|
|
|
358
|
+
/**
|
|
359
|
+
* @qin-ui/antd-vue-pro 表格列配置类型
|
|
360
|
+
*
|
|
361
|
+
* @description 继承 Ant Design Vue 的 ColumnType 列类型,并添加:
|
|
362
|
+
* - 类型安全的 dataIndex(基于泛型 D 推导路径),优先使用
|
|
363
|
+
* - key 作为辅助标识,当 dataIndex 不满足需求时使用
|
|
364
|
+
* - hidden 属性用于控制列显隐
|
|
365
|
+
* - 所有 Ant Design Vue 原生的列属性依然可用(title、width、fixed、align 等)
|
|
366
|
+
*
|
|
367
|
+
* @template D - 表格行数据类型
|
|
368
|
+
* @public
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```ts
|
|
372
|
+
* interface User { name: string; age: number }
|
|
373
|
+
*
|
|
374
|
+
* const columns: Columns<User> = [
|
|
375
|
+
* {
|
|
376
|
+
* // dataIndex 是主要字段,关联数据源中对应字段路径
|
|
377
|
+
* dataIndex: 'name',
|
|
378
|
+
* title: '姓名',
|
|
379
|
+
* width: 120,
|
|
380
|
+
* },
|
|
381
|
+
* {
|
|
382
|
+
* dataIndex: 'age',
|
|
383
|
+
* title: '年龄',
|
|
384
|
+
* width: 80,
|
|
385
|
+
* },
|
|
386
|
+
* ]
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
314
389
|
export declare type Column<D extends Data = Data> = Omit<ColumnType, 'dataIndex' | 'key'> & {
|
|
390
|
+
/**
|
|
391
|
+
* @description 列数据路径(主要字段)
|
|
392
|
+
* 关联数据源中对应字段的路径,支持点号分隔的深层路径和数组路径。
|
|
393
|
+
* 优先使用 dataIndex 进行字段匹配。
|
|
394
|
+
*
|
|
395
|
+
* @example 'name' | 'address.city' | ['address', 'city']
|
|
396
|
+
*/
|
|
315
397
|
dataIndex?: KeyExpandString<Extract<keyof D, string>> | Paths<D>;
|
|
398
|
+
/**
|
|
399
|
+
* @description 列字段标识(辅助字段)
|
|
400
|
+
* 仅当 dataIndex 无法满足需求时使用,例如需要在自定义渲染中标识列时。
|
|
401
|
+
* 在字段匹配时的优先级低于 dataIndex。
|
|
402
|
+
*/
|
|
316
403
|
key?: Path<D>;
|
|
404
|
+
/**
|
|
405
|
+
* @description 是否隐藏该列
|
|
406
|
+
* @default false
|
|
407
|
+
*/
|
|
317
408
|
hidden?: boolean;
|
|
318
409
|
};
|
|
319
410
|
|
|
411
|
+
/**
|
|
412
|
+
* 列查找函数类型,通过自定义函数匹配列
|
|
413
|
+
* @template D - 表格数据类型
|
|
414
|
+
* @template C - 列配置类型
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```ts
|
|
418
|
+
* // 查找 title 为 '姓名' 的列
|
|
419
|
+
* const findBy: ColumnFindBy<MyData> = (column) => column.title === '姓名'
|
|
420
|
+
*
|
|
421
|
+
* // 查找所有宽度小于 100 的列
|
|
422
|
+
* const findBy: ColumnFindBy<MyData> = (column) => column.width && column.width < 100
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
320
425
|
declare type ColumnFindBy<D extends Data, C extends BaseColumn<D> = BaseColumn<D>> = (column: Readonly<C>) => boolean;
|
|
321
426
|
|
|
427
|
+
/**
|
|
428
|
+
* @qin-ui/antd-vue-pro 表格列配置数组类型
|
|
429
|
+
*
|
|
430
|
+
* @template D - 表格行数据类型
|
|
431
|
+
* @public
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* ```ts
|
|
435
|
+
* const columns: Columns<User> = [
|
|
436
|
+
* { dataIndex: 'name', title: '姓名' },
|
|
437
|
+
* { dataIndex: 'age', title: '年龄' },
|
|
438
|
+
* ]
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
322
441
|
export declare type Columns<D extends Data = Data> = Array<Column<D>>;
|
|
323
442
|
|
|
443
|
+
/**
|
|
444
|
+
* 列配置数组类型
|
|
445
|
+
* @template D - 表格数据类型
|
|
446
|
+
* @template C - 列配置类型
|
|
447
|
+
*/
|
|
324
448
|
declare type Columns_2<D extends Data = Data, C extends BaseColumn<D> = BaseColumn<D>> = Array<C>;
|
|
325
449
|
|
|
326
450
|
/**
|
|
327
|
-
*
|
|
451
|
+
* 组件映射扩展接口
|
|
452
|
+
* @description 暴露给外部扩充自定义组件类型的接口。
|
|
453
|
+
* 用户可通过 TypeScript 的声明合并(module augmentation)添加自定义组件。
|
|
454
|
+
* @public
|
|
455
|
+
*
|
|
328
456
|
* @example
|
|
329
457
|
* ```ts
|
|
330
|
-
*
|
|
458
|
+
* // 在项目中任意 .d.ts 文件中
|
|
459
|
+
* declare module '@qin-ui/antd-vue-pro' {
|
|
331
460
|
* interface ComponentMap {
|
|
332
461
|
* 'my-custom-input': typeof MyCustomInput;
|
|
462
|
+
* 'my-editor': typeof MyRichTextEditor;
|
|
333
463
|
* }
|
|
334
464
|
* }
|
|
335
465
|
* ```
|
|
@@ -337,26 +467,72 @@ declare type Columns_2<D extends Data = Data, C extends BaseColumn<D> = BaseColu
|
|
|
337
467
|
export declare interface ComponentMap {
|
|
338
468
|
}
|
|
339
469
|
|
|
340
|
-
|
|
341
|
-
|
|
470
|
+
/**
|
|
471
|
+
* 组件名称联合类型
|
|
472
|
+
* @description 所有支持的组件名称,包括内置组件、用户扩展组件和自定义组件 'custom'
|
|
473
|
+
* - 内置组件:'input' | 'select' | 'date-picker' 等
|
|
474
|
+
* - 扩展组件:通过 ComponentMap 声明的自定义组件名
|
|
475
|
+
* - 'custom':完全自定义渲染组件
|
|
476
|
+
* @public
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```ts
|
|
480
|
+
* type Name = ComponentName
|
|
481
|
+
* // 'input' | 'select' | 'date-picker' | ... | 'custom'
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
342
484
|
export declare type ComponentName = keyof BaseComponentMap | keyof ComponentMap | 'custom';
|
|
343
485
|
|
|
486
|
+
/**
|
|
487
|
+
* 组件全局配置
|
|
488
|
+
* @description RequiredComponentVars 的 Partial 版本,用于 ProComponentProvider 的 props
|
|
489
|
+
* @public
|
|
490
|
+
*/
|
|
344
491
|
export declare type ComponentVars = Partial<RequiredComponentVars>;
|
|
345
492
|
|
|
346
493
|
/**
|
|
347
494
|
* @description 容器组件类型
|
|
348
495
|
*/
|
|
349
|
-
|
|
496
|
+
declare type ContainerComponent = Component<PathProps>;
|
|
350
497
|
|
|
351
498
|
export declare const ContainerFragment: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
352
499
|
|
|
500
|
+
/**
|
|
501
|
+
* 基础数据类型,表示任意对象
|
|
502
|
+
* @description 所有表单数据对象和表格数据对象的基础类型
|
|
503
|
+
*/
|
|
353
504
|
declare type Data = Record<string, any>;
|
|
354
505
|
|
|
506
|
+
/**
|
|
507
|
+
* 递归地将对象的所有属性变为可选
|
|
508
|
+
* @template T - 原始类型
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```ts
|
|
512
|
+
* type T = DeepPartial<{ name: string; address: { city: string } }>
|
|
513
|
+
* // { name?: string; address?: { city?: string } }
|
|
514
|
+
* ```
|
|
515
|
+
*/
|
|
355
516
|
declare type DeepPartial<T> = T extends object ? {
|
|
356
517
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
357
518
|
} : T;
|
|
358
519
|
|
|
359
520
|
declare const _default: {
|
|
521
|
+
/**
|
|
522
|
+
* @qin-ui/antd-vue-pro 安装方法
|
|
523
|
+
* @description 全局注册所有组件(ProForm、ProTable、ProComponentProvider)
|
|
524
|
+
*
|
|
525
|
+
* @param {App} app - Vue 应用实例
|
|
526
|
+
*
|
|
527
|
+
* @example
|
|
528
|
+
* ```ts
|
|
529
|
+
* import { createApp } from 'vue'
|
|
530
|
+
* import QinUI from '@qin-ui/antd-vue-pro'
|
|
531
|
+
*
|
|
532
|
+
* const app = createApp(App)
|
|
533
|
+
* app.use(QinUI) // 全局注册所有组件
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
360
536
|
install(app: App): void;
|
|
361
537
|
};
|
|
362
538
|
export default _default;
|
|
@@ -451,7 +627,34 @@ declare const _default_2: <T extends Table<any> = Table>(__VLS_props: NonNullabl
|
|
|
451
627
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
452
628
|
};
|
|
453
629
|
|
|
454
|
-
|
|
630
|
+
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<{
|
|
631
|
+
props: __VLS_PrettifyLocal_2<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & ({
|
|
632
|
+
grid?: Grid;
|
|
633
|
+
form?: F;
|
|
634
|
+
} & Partial<Omit<FormProps, "model">>) & Partial<{}>> & PublicProps;
|
|
635
|
+
expose(exposed: ShallowUnwrapRef< {}>): void;
|
|
636
|
+
attrs: any;
|
|
637
|
+
slots: Readonly<Partial<Record<F extends Form<infer D extends Data> ? Path<D> : string, Slot<VModelProps & {
|
|
638
|
+
path?: string;
|
|
639
|
+
} & Data & {
|
|
640
|
+
[x: string]: any;
|
|
641
|
+
disabled?: boolean;
|
|
642
|
+
}>> & {
|
|
643
|
+
default: Slot;
|
|
644
|
+
}>> & Partial<Record<F extends Form<infer D extends Data> ? Path<D> : string, Slot<VModelProps & {
|
|
645
|
+
path?: string;
|
|
646
|
+
} & Data & {
|
|
647
|
+
[x: string]: any;
|
|
648
|
+
disabled?: boolean;
|
|
649
|
+
}>> & {
|
|
650
|
+
default: Slot;
|
|
651
|
+
}>;
|
|
652
|
+
emit: {};
|
|
653
|
+
}>) => VNode & {
|
|
654
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
declare const _default_4: DefineComponent<Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props_3> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
455
658
|
|
|
456
659
|
declare type Expand = {
|
|
457
660
|
minExpandRows?: number;
|
|
@@ -462,6 +665,18 @@ declare type ExpandButtonProps = ButtonProps & {
|
|
|
462
665
|
expandStatus: boolean;
|
|
463
666
|
};
|
|
464
667
|
|
|
668
|
+
/**
|
|
669
|
+
* 用 Record<string, any> 扩展对象类型,保留所有原始属性结构,
|
|
670
|
+
* 同时允许访问任意字符串 key。
|
|
671
|
+
* @template D - 原始对象类型
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```ts
|
|
675
|
+
* type T = ExtendWithAny<{ name: string; age: number }>
|
|
676
|
+
* // { name: string; age: number } & Record<string, any>
|
|
677
|
+
* // 可访问任意额外属性: obj.anyKey
|
|
678
|
+
* ```
|
|
679
|
+
*/
|
|
465
680
|
declare type ExtendWithAny<D> = {
|
|
466
681
|
[K in keyof D]: IsRecord<D[K]> extends true ? ExtendWithAny<D[K]> : D[K];
|
|
467
682
|
} & Record<string, any>;
|
|
@@ -469,21 +684,33 @@ declare type ExtendWithAny<D> = {
|
|
|
469
684
|
/**
|
|
470
685
|
* @description 字段配置类型,包含所有字段属性和响应式支持
|
|
471
686
|
* @template D - 数据对象类型
|
|
687
|
+
* @public
|
|
472
688
|
*/
|
|
473
689
|
export declare type Field<C extends ComponentName = ComponentName, D extends Data = Data> = FieldTypeMap<D>[C] | WithFields<D>;
|
|
474
690
|
|
|
475
|
-
|
|
691
|
+
/**
|
|
692
|
+
* 字段查找函数类型,通过自定义函数匹配字段
|
|
693
|
+
* @template D - 表单数据类型
|
|
694
|
+
* @template F - 字段配置类型
|
|
695
|
+
* @example
|
|
696
|
+
* ```ts
|
|
697
|
+
* // 查找 label 为 '姓名' 的字段
|
|
698
|
+
* const findBy: FieldFindBy<MyData> = (field) => field.label === '姓名'
|
|
699
|
+
* ```
|
|
700
|
+
*/
|
|
701
|
+
declare type FieldFindBy<D extends Data, F extends BaseField<D> = BaseField<D>> = (field: Readonly<F>) => boolean;
|
|
476
702
|
|
|
477
703
|
/**
|
|
478
704
|
* @description 字段数组类型
|
|
479
705
|
* @template D - 数据对象类型
|
|
706
|
+
* @public
|
|
480
707
|
*/
|
|
481
708
|
export declare type Fields<D extends Data = Data> = Array<Field<ComponentName, D>>;
|
|
482
709
|
|
|
483
710
|
/**
|
|
484
711
|
* @type {FieldTypeMap} 字段类型集合
|
|
485
712
|
*/
|
|
486
|
-
|
|
713
|
+
declare type FieldTypeMap<D extends Data = Data> = {
|
|
487
714
|
[K in ComponentName]: K extends 'custom' ? WithCommon<{
|
|
488
715
|
slots?: Slots;
|
|
489
716
|
[x: string]: any;
|
|
@@ -495,53 +722,83 @@ export declare type FieldTypeMap<D extends Data = Data> = {
|
|
|
495
722
|
};
|
|
496
723
|
|
|
497
724
|
/**
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
725
|
+
* @qin-ui/antd-vue-pro 的表单实例类型
|
|
726
|
+
*
|
|
727
|
+
* @description 在 core Form 类型的基础上:
|
|
728
|
+
* 1. 将字段类型 F 默认绑定为本地 Field<ComponentName, D>,支持 Ant Design Vue 所有内置组件类型
|
|
729
|
+
* 2. 将底层表单实例 I 绑定为 Ant Design Vue 的 FormInstance,使 formRef 获得完整的类型提示
|
|
730
|
+
* @public
|
|
731
|
+
*
|
|
732
|
+
* @template D - 表单数据类型
|
|
733
|
+
* @template F - 字段配置类型,默认使用本地 Field 类型
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* ```ts
|
|
737
|
+
* interface User { name: string; age: number }
|
|
738
|
+
* const form: Form<User> = useForm({ name: '张三', age: 25 })
|
|
739
|
+
* form.formRef.value?.validate() // 类型安全地访问 Ant Design Vue 的 Form validate 方法
|
|
740
|
+
* ```
|
|
502
741
|
*/
|
|
503
742
|
export declare type Form<D extends Data = Data, F extends Field<ComponentName, D> = Field<ComponentName, D>> = Form_2<D, F, FormInstance>;
|
|
504
743
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
744
|
+
/**
|
|
745
|
+
* 表单实例类型
|
|
746
|
+
* @template D - 表单数据类型
|
|
747
|
+
* @template F - 字段配置类型
|
|
748
|
+
* @template I - 底层 UI 框架 Form 组件实例类型
|
|
749
|
+
*
|
|
750
|
+
* 组合了表单数据操作、字段操作和表单 ref 操作的能力。
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* ```ts
|
|
754
|
+
* // 定义数据类型
|
|
755
|
+
* interface User {
|
|
756
|
+
* name: string
|
|
757
|
+
* age: number
|
|
758
|
+
* address: { city: string; street: string }
|
|
759
|
+
* }
|
|
760
|
+
*
|
|
761
|
+
* // 创建表单实例
|
|
762
|
+
* const form: Form<User> = useForm({
|
|
763
|
+
* name: '张三',
|
|
764
|
+
* age: 25,
|
|
765
|
+
* })
|
|
766
|
+
*
|
|
767
|
+
* // 读取数据
|
|
768
|
+
* form.getFormData('name') // '张三'
|
|
769
|
+
* form.getFormData('address.city') // 支持深层路径
|
|
770
|
+
*
|
|
771
|
+
* // 设置数据
|
|
772
|
+
* form.setFormData('name', '李四')
|
|
773
|
+
* form.setFormData({ name: '王五', age: 30 }) // 批量设置
|
|
774
|
+
*
|
|
775
|
+
* // 字段操作
|
|
776
|
+
* form.getField('name') // 获取字段配置
|
|
777
|
+
* form.setField('name', { label: '用户名' }) // 更新字段配置
|
|
778
|
+
* ```
|
|
779
|
+
*/
|
|
780
|
+
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>>;
|
|
510
781
|
|
|
511
782
|
declare type FormProps = Omit<FormProps_2, 'scrollToFirstError'> & {
|
|
512
|
-
scrollToFirstError?: boolean |
|
|
783
|
+
scrollToFirstError?: boolean | Options<any>;
|
|
513
784
|
};
|
|
514
785
|
|
|
515
786
|
declare type _FormProps = Pick<Partial<FormProps>, 'colon' | 'disabled' | 'hideRequiredMark' | 'labelAlign' | 'labelCol' | 'labelWrap' | 'name' | 'wrapperCol'>;
|
|
516
787
|
|
|
517
788
|
declare type FP<T extends Record<string, any>> = Partial<T & Pick<Base, 'valueFormatter' | 'componentContainer' | 'modelProp'> & AllowedComponentProps>;
|
|
518
789
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
export declare type Grid = boolean | (RowProps & {});
|
|
526
|
-
|
|
527
|
-
export declare const INJECT_COMPONENTS: InjectionKey<Partial<Record<string, Component>>>;
|
|
528
|
-
|
|
529
|
-
export declare const INJECT_CONFIG: {
|
|
530
|
-
[key in keyof RequiredComponentVars]: {
|
|
531
|
-
injectionKey: InjectionKey<RequiredComponentVars[key]>;
|
|
532
|
-
default: RequiredComponentVars[key];
|
|
533
|
-
};
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
export declare type InjectConfigEntry<T = any> = {
|
|
537
|
-
injectionKey: InjectionKey<T>;
|
|
538
|
-
default: T;
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
export declare const InjectionFormKey: InjectionKey<any>;
|
|
790
|
+
/**
|
|
791
|
+
* 根据组件名获取组件类型
|
|
792
|
+
* @template K - 组件名称
|
|
793
|
+
*/
|
|
794
|
+
declare type GetComponentType<K extends ComponentName> = K extends keyof ComponentMap ? ComponentMap[K] : K extends keyof BaseComponentMap ? BaseComponentMap[K] : never;
|
|
542
795
|
|
|
543
|
-
|
|
796
|
+
declare type Grid = boolean | (RowProps & {});
|
|
544
797
|
|
|
798
|
+
/**
|
|
799
|
+
* 判断类型是否为对象(排除函数、数组和 null)
|
|
800
|
+
* @template T - 要判断的类型
|
|
801
|
+
*/
|
|
545
802
|
declare type IsRecord<T> = T extends object ? T extends ((...args: any[]) => any) | any[] | null ? false : true : false;
|
|
546
803
|
|
|
547
804
|
declare type JoinPath<Prefix extends any[], Key extends PropertyKey> = [
|
|
@@ -549,8 +806,34 @@ declare type JoinPath<Prefix extends any[], Key extends PropertyKey> = [
|
|
|
549
806
|
KeyExpandString<Extract<Key, string>>
|
|
550
807
|
];
|
|
551
808
|
|
|
809
|
+
/**
|
|
810
|
+
* 展开字符串联合类型,保留字符串字面量,同时兼容 string
|
|
811
|
+
* @template T - 字符串字面量类型
|
|
812
|
+
*/
|
|
552
813
|
declare type KeyExpandString<T extends string> = T | (string & {});
|
|
553
814
|
|
|
815
|
+
/**
|
|
816
|
+
* 点号分隔的路径字符串类型
|
|
817
|
+
* @template D - 数据对象类型
|
|
818
|
+
*
|
|
819
|
+
* @description 用于类型安全地表示深层对象属性的路径。
|
|
820
|
+
* 例如给定 `{ user: { name: string; address: { city: string } } }`,
|
|
821
|
+
* 路径值可以是 `'user'`、`'user.name'`、`'user.address.city'`。
|
|
822
|
+
*
|
|
823
|
+
* 同时兼容 string 类型,用于运行时动态路径。
|
|
824
|
+
*
|
|
825
|
+
* @example
|
|
826
|
+
* ```ts
|
|
827
|
+
* interface User {
|
|
828
|
+
* name: string
|
|
829
|
+
* age: number
|
|
830
|
+
* address: { city: string; street: string }
|
|
831
|
+
* }
|
|
832
|
+
*
|
|
833
|
+
* type P = KeyPathString<User>
|
|
834
|
+
* // 'name' | 'age' | 'address' | 'address.city' | 'address.street' | string
|
|
835
|
+
* ```
|
|
836
|
+
*/
|
|
554
837
|
declare type KeyPathString<D extends Data> = KeyExpandString<AllowStringKey<D>>;
|
|
555
838
|
|
|
556
839
|
declare type MaybeRefOrComputedRef<T = any> = MaybeRef<T> | ComputedRef<T>;
|
|
@@ -560,28 +843,66 @@ declare type MaybeRefOrComputedRef<T = any> = MaybeRef<T> | ComputedRef<T>;
|
|
|
560
843
|
*/
|
|
561
844
|
declare type NotSupportedRefOrGetterProps = 'component' | 'formItemContainer' | 'componentContainer' | 'valueFormatter' | 'fields' | 'slots' | 'modelProp';
|
|
562
845
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
846
|
+
/**
|
|
847
|
+
* 分页参数
|
|
848
|
+
*
|
|
849
|
+
* @example
|
|
850
|
+
* ```ts
|
|
851
|
+
* const pageParam: PageParam = {
|
|
852
|
+
* current: 1,
|
|
853
|
+
* pageSize: 10,
|
|
854
|
+
* total: 100,
|
|
855
|
+
* }
|
|
856
|
+
* ```
|
|
857
|
+
*/
|
|
572
858
|
declare interface PageParam {
|
|
859
|
+
/** 当前页码 */
|
|
573
860
|
current: number;
|
|
861
|
+
/** 每页条数 */
|
|
574
862
|
pageSize: number;
|
|
863
|
+
/** 总记录数 */
|
|
575
864
|
total: number;
|
|
865
|
+
/** 其他自定义分页属性 */
|
|
576
866
|
[key: string]: any;
|
|
577
867
|
}
|
|
578
868
|
|
|
869
|
+
/**
|
|
870
|
+
* 路径类型,用于类型安全的深层属性访问
|
|
871
|
+
* @template D - 数据对象类型
|
|
872
|
+
*
|
|
873
|
+
* @description 提供对数据对象的深层路径的类型推导。
|
|
874
|
+
* 在 useFormData、useFields 等 API 中作为 path 参数的类型。
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
* ```ts
|
|
878
|
+
* interface User { name: string; address: { city: string } }
|
|
879
|
+
*
|
|
880
|
+
* // 类型安全的路径
|
|
881
|
+
* const path: Path<User> = 'address.city' // ✅
|
|
882
|
+
* const path: Path<User> = 'invalid.path' // ❌ 类型错误
|
|
883
|
+
* ```
|
|
884
|
+
*/
|
|
579
885
|
declare type Path<D extends Data = Data> = KeyPathString<D>;
|
|
580
886
|
|
|
581
|
-
|
|
887
|
+
declare type PathProps = {
|
|
582
888
|
path?: string;
|
|
583
889
|
} & Data;
|
|
584
890
|
|
|
891
|
+
/**
|
|
892
|
+
* 路径数组类型(Path 的数组表示)
|
|
893
|
+
* @template T - 数据对象类型
|
|
894
|
+
* @template Prefix - 前缀路径数组(内部递归使用)
|
|
895
|
+
*
|
|
896
|
+
* @description 与 Path 类似,但以元组数组形式表示路径。
|
|
897
|
+
*
|
|
898
|
+
* @example
|
|
899
|
+
* ```ts
|
|
900
|
+
* interface User { name: string; address: { city: string } }
|
|
901
|
+
*
|
|
902
|
+
* type P = Paths<User>
|
|
903
|
+
* // ['name'] | ['address'] | ['address', 'city']
|
|
904
|
+
* ```
|
|
905
|
+
*/
|
|
585
906
|
declare type Paths<T, Prefix extends any[] = []> = T extends object ? {
|
|
586
907
|
[K in keyof T]: IsRecord<T[K]> extends true ? JoinPath<Prefix, K> | Paths<T[K], JoinPath<Prefix, K>> : JoinPath<Prefix, K>;
|
|
587
908
|
}[keyof T] : never;
|
|
@@ -715,7 +1036,7 @@ export declare const ProForm: SFCWithInstall<(<F extends Form<any> = Form>(__VLS
|
|
|
715
1036
|
} | undefined;
|
|
716
1037
|
validateMessages?: ValidateMessages | undefined;
|
|
717
1038
|
validateOnRuleChange?: boolean | undefined;
|
|
718
|
-
scrollToFirstError?: (boolean |
|
|
1039
|
+
scrollToFirstError?: (boolean | Options<any>) | undefined;
|
|
719
1040
|
onSubmit?: ((e: Event) => void) | undefined;
|
|
720
1041
|
name?: string | undefined;
|
|
721
1042
|
validateTrigger?: string | string[] | undefined;
|
|
@@ -749,28 +1070,23 @@ export declare const ProForm: SFCWithInstall<(<F extends Form<any> = Form>(__VLS
|
|
|
749
1070
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
750
1071
|
})>;
|
|
751
1072
|
|
|
752
|
-
export declare type ProFormInstance = ComponentExposed<typeof
|
|
1073
|
+
export declare type ProFormInstance = ComponentExposed<typeof _default_3>;
|
|
753
1074
|
|
|
754
|
-
export declare type ProFormItemInstance = ComponentExposed<typeof
|
|
1075
|
+
export declare type ProFormItemInstance = ComponentExposed<typeof _default_4>;
|
|
755
1076
|
|
|
756
|
-
export declare type ProFormItemProps = ComponentProps<typeof
|
|
1077
|
+
export declare type ProFormItemProps = ComponentProps<typeof _default_4>;
|
|
757
1078
|
|
|
758
|
-
export declare type ProFormProps = ComponentProps<typeof
|
|
1079
|
+
export declare type ProFormProps = ComponentProps<typeof _default_3>;
|
|
759
1080
|
|
|
760
1081
|
declare type Props = {
|
|
761
|
-
component?: string | Component;
|
|
762
|
-
path?: string;
|
|
763
|
-
};
|
|
764
|
-
|
|
765
|
-
declare type Props_2 = {
|
|
766
1082
|
component?: ContainerComponent;
|
|
767
1083
|
};
|
|
768
1084
|
|
|
769
|
-
declare type
|
|
1085
|
+
declare type Props_2 = {
|
|
770
1086
|
component?: SlotComponentType;
|
|
771
1087
|
};
|
|
772
1088
|
|
|
773
|
-
declare type
|
|
1089
|
+
declare type Props_3 = {
|
|
774
1090
|
grid?: Grid;
|
|
775
1091
|
fields?: Fields;
|
|
776
1092
|
disabled?: boolean;
|
|
@@ -786,18 +1102,50 @@ export declare type ProTableProps = ComponentProps<typeof _default_2>;
|
|
|
786
1102
|
* @description 自定义组件
|
|
787
1103
|
* @example (p, ctx) => h('div', ctx.attrs)
|
|
788
1104
|
*/
|
|
789
|
-
|
|
1105
|
+
declare type RenderComponentType = Component<VModelProps & PathProps>;
|
|
790
1106
|
|
|
791
|
-
|
|
1107
|
+
/**
|
|
1108
|
+
* @qin-ui/antd-vue-pro 全局配置变量类型
|
|
1109
|
+
*
|
|
1110
|
+
* @description 定义可通过 ProComponentProvider 配置的所有组件默认属性。
|
|
1111
|
+
* 支持配置表单、表格、表单项以及所有内置组件的默认属性。
|
|
1112
|
+
*
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```ts
|
|
1115
|
+
* // 通过 ProComponentProvider 配置全局默认值
|
|
1116
|
+
* const componentVars: ComponentVars = {
|
|
1117
|
+
* 'pro-form': {
|
|
1118
|
+
* grid: { gutter: 24 },
|
|
1119
|
+
* labelCol: { span: 4 },
|
|
1120
|
+
* },
|
|
1121
|
+
* 'input': {
|
|
1122
|
+
* placeholder: '请输入内容',
|
|
1123
|
+
* maxlength: 200,
|
|
1124
|
+
* },
|
|
1125
|
+
* 'select': {
|
|
1126
|
+
* placeholder: '请选择',
|
|
1127
|
+
* },
|
|
1128
|
+
* }
|
|
1129
|
+
* ```
|
|
1130
|
+
*/
|
|
1131
|
+
declare type RequiredComponentVars = {
|
|
1132
|
+
/** ProTable 全局默认属性 */
|
|
792
1133
|
'pro-table': PP<TableProps & Pick<ProTableProps, 'control' | 'searchFormConfig' | 'immediateSearch' | 'addIndexColumn' | 'tableContainer'>>;
|
|
1134
|
+
/** ProForm 全局默认属性,grid 必须为 GridProps 对象而非 boolean */
|
|
793
1135
|
'pro-form': PP<Omit<ProFormProps, 'form' | 'grid'> & {
|
|
794
1136
|
grid: Exclude<Grid, undefined | boolean>;
|
|
795
1137
|
}>;
|
|
1138
|
+
/** ProFormItem 全局默认属性 */
|
|
796
1139
|
'pro-form-item': PP<FormItemProps & Pick<ColProps, 'span' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'> & Pick<Base, 'formItemContainer'>>;
|
|
1140
|
+
/** DatePicker date 模式全局默认属性 */
|
|
797
1141
|
'date-picker.date': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
1142
|
+
/** DatePicker week 模式全局默认属性 */
|
|
798
1143
|
'date-picker.week': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
1144
|
+
/** DatePicker month 模式全局默认属性 */
|
|
799
1145
|
'date-picker.month': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
1146
|
+
/** DatePicker year 模式全局默认属性 */
|
|
800
1147
|
'date-picker.year': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
1148
|
+
/** DatePicker quarter 模式全局默认属性 */
|
|
801
1149
|
'date-picker.quarter': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
802
1150
|
} & {
|
|
803
1151
|
[K in Exclude<ComponentName, 'custom'>]: FP<ComponentProps<GetComponentType<K>>>;
|
|
@@ -820,41 +1168,114 @@ declare type SetPageParam = (pageParam: Partial<PageParam> | ((pre: Readonly<Pag
|
|
|
820
1168
|
|
|
821
1169
|
declare type SFCWithInstall<T> = T & Plugin_2;
|
|
822
1170
|
|
|
823
|
-
export declare const SlotComponent: DefineComponent<
|
|
1171
|
+
export declare const SlotComponent: DefineComponent<Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props_2> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
824
1172
|
|
|
825
1173
|
/**
|
|
826
1174
|
* @description 插槽组件类型
|
|
827
1175
|
*/
|
|
828
|
-
|
|
1176
|
+
declare type SlotComponentType = Component<PathProps> | VNode | string | number | boolean | null | undefined | ((...args: any[]) => SlotComponentType);
|
|
829
1177
|
|
|
830
1178
|
/**
|
|
831
1179
|
* @description 插槽对象类型
|
|
832
1180
|
*/
|
|
833
|
-
|
|
1181
|
+
declare type Slots = {
|
|
834
1182
|
[name: string]: SlotComponentType;
|
|
835
1183
|
};
|
|
836
1184
|
|
|
837
1185
|
/**
|
|
838
|
-
*
|
|
1186
|
+
* @qin-ui/antd-vue-pro 的表格实例类型
|
|
1187
|
+
*
|
|
1188
|
+
* @description 在 core Table 类型的基础上,将列类型 C 绑定为本地 Column<T>,
|
|
1189
|
+
* 使 columns 操作获得 Ant Design Vue 表格列的完整属性类型提示(如 title、width、fixed 等)。
|
|
1190
|
+
* @public
|
|
1191
|
+
*
|
|
1192
|
+
* @template D - 搜索表单数据类型
|
|
1193
|
+
* @template T - 表格行数据类型
|
|
1194
|
+
*
|
|
1195
|
+
* @example
|
|
1196
|
+
* ```ts
|
|
1197
|
+
* interface SearchParams { keyword: string }
|
|
1198
|
+
* interface User { name: string; age: number }
|
|
1199
|
+
*
|
|
1200
|
+
* const table: Table<SearchParams, User> = useTable({...})
|
|
1201
|
+
* table.columns.value[0].title // 类型为 string | undefined
|
|
1202
|
+
* table.columns.value[0].width // 类型为 number | undefined(Ant Design Vue 属性)
|
|
1203
|
+
* ```
|
|
839
1204
|
*/
|
|
840
1205
|
export declare type Table<D extends Data = Data, T extends Data = ExtendWithAny<D>> = Table_2<D, T, Column<T>>;
|
|
841
1206
|
|
|
1207
|
+
/**
|
|
1208
|
+
* 表格实例类型
|
|
1209
|
+
* @template D - 搜索表单数据类型
|
|
1210
|
+
* @template T - 表格数据类型(表格行数据类型),默认为 ExtendWithAny<D>
|
|
1211
|
+
* @template C - 列配置类型,继承自 BaseColumn<T>
|
|
1212
|
+
*
|
|
1213
|
+
* 组合了列操作、数据源管理、分页管理和搜索表单的能力。
|
|
1214
|
+
*
|
|
1215
|
+
* @example
|
|
1216
|
+
* ```ts
|
|
1217
|
+
* interface User { name: string; age: number; }
|
|
1218
|
+
* interface SearchParams { keyword: string }
|
|
1219
|
+
*
|
|
1220
|
+
* const table: Table<SearchParams, User> = useTable({
|
|
1221
|
+
* columns: [
|
|
1222
|
+
* { key: 'name', title: '姓名' },
|
|
1223
|
+
* { key: 'age', title: '年龄' },
|
|
1224
|
+
* ],
|
|
1225
|
+
* dataSource: [
|
|
1226
|
+
* { name: '张三', age: 25 },
|
|
1227
|
+
* ],
|
|
1228
|
+
* searchFields: [
|
|
1229
|
+
* { path: 'keyword', label: '关键词', component: 'input' },
|
|
1230
|
+
* ],
|
|
1231
|
+
* })
|
|
1232
|
+
*
|
|
1233
|
+
* // 列操作
|
|
1234
|
+
* table.setColumn('name', { title: '用户名' })
|
|
1235
|
+
* table.appendColumn('name', { key: 'email', title: '邮箱' })
|
|
1236
|
+
* table.deleteColumn('age')
|
|
1237
|
+
*
|
|
1238
|
+
* // 分页操作
|
|
1239
|
+
* table.setPageParam({ current: 2, pageSize: 20 })
|
|
1240
|
+
* table.resetQueryParams()
|
|
1241
|
+
*
|
|
1242
|
+
* // 搜索表单
|
|
1243
|
+
* table.searchForm.getFormData('keyword')
|
|
1244
|
+
* table.searchForm.setFormData('keyword', '张三')
|
|
1245
|
+
* ```
|
|
1246
|
+
*/
|
|
842
1247
|
declare type Table_2<D extends Data = Data, T extends Data = ExtendWithAny<D>, C extends BaseColumn<T> = BaseColumn<T>> = {
|
|
1248
|
+
/** 列配置数组(响应式) */
|
|
843
1249
|
columns: Ref<Columns_2<T, C>>;
|
|
1250
|
+
/** 数据源数组(响应式) */
|
|
844
1251
|
dataSource: Ref<T[]>;
|
|
1252
|
+
/** 分页参数(响应式) */
|
|
845
1253
|
pageParam: Reactive<PageParam>;
|
|
1254
|
+
/** 搜索表单实例 */
|
|
846
1255
|
searchForm: Form_2<D>;
|
|
1256
|
+
/** 设置列配置 */
|
|
847
1257
|
setColumn: SetColumn<T, C>;
|
|
1258
|
+
/** 删除列 */
|
|
848
1259
|
deleteColumn: (path: Path<T> | ColumnFindBy<T, C>, options?: UpdateColumnOptions) => void;
|
|
1260
|
+
/** 在指定列后追加列 */
|
|
849
1261
|
appendColumn: (path: Path<T> | ColumnFindBy<T, C> | undefined, column: C | Columns_2<T, C>, options?: UpdateColumnOptions) => void;
|
|
1262
|
+
/** 在指定列前插入列 */
|
|
850
1263
|
prependColumn: (path: Path<T> | ColumnFindBy<T, C> | undefined, column: C | Columns_2<T, C>, options?: UpdateColumnOptions) => void;
|
|
1264
|
+
/** 设置分页参数 */
|
|
851
1265
|
setPageParam: SetPageParam;
|
|
1266
|
+
/** 重置查询参数(重置分页和搜索条件到初始值) */
|
|
852
1267
|
resetQueryParams: () => void;
|
|
853
1268
|
};
|
|
854
1269
|
|
|
855
|
-
|
|
856
|
-
|
|
1270
|
+
/**
|
|
1271
|
+
* 列更新选项
|
|
1272
|
+
*/
|
|
857
1273
|
declare type UpdateColumnOptions = {
|
|
1274
|
+
/**
|
|
1275
|
+
* @description 是否更新所有匹配的列
|
|
1276
|
+
* - true: 更新所有匹配的列
|
|
1277
|
+
* - false/undefined: 只更新第一个匹配的列
|
|
1278
|
+
*/
|
|
858
1279
|
all?: boolean;
|
|
859
1280
|
};
|
|
860
1281
|
|
|
@@ -862,19 +1283,101 @@ declare type UpdateFieldOptions = {
|
|
|
862
1283
|
all?: boolean;
|
|
863
1284
|
};
|
|
864
1285
|
|
|
865
|
-
/**
|
|
1286
|
+
/**
|
|
1287
|
+
* useFields 返回值类型,固定为本地 Fields<D>
|
|
1288
|
+
* @public
|
|
1289
|
+
*/
|
|
866
1290
|
export declare type UseFields<D extends Data = Data> = ReturnType<typeof useFields<D>>;
|
|
867
1291
|
|
|
868
1292
|
/**
|
|
869
|
-
*
|
|
870
|
-
*
|
|
871
|
-
*
|
|
1293
|
+
* @qin-ui/antd-vue-pro 的字段配置管理 Hook
|
|
1294
|
+
*
|
|
1295
|
+
* @description 类型安全的 re-export。将 core useFields 的泛型参数绑定为本地类型:
|
|
1296
|
+
* - 字段类型 F → Field<ComponentName, D>(支持 Ant Design Vue 组件类型推导)
|
|
1297
|
+
* - FormItem 实例 → Ant Design Vue 的 FormItemInstance
|
|
1298
|
+
*
|
|
1299
|
+
* 提供对字段配置数组的增删改查操作,详见 `@qin-ui/core` 的 useFields 文档。
|
|
1300
|
+
* @public
|
|
1301
|
+
*
|
|
1302
|
+
* @template D - 表单数据类型
|
|
1303
|
+
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* ```ts
|
|
1306
|
+
* interface User { name: string; age: number }
|
|
1307
|
+
*
|
|
1308
|
+
* const { fields, getField, setField } = useFields<User>([
|
|
1309
|
+
* { path: 'name', label: '姓名', component: 'input' },
|
|
1310
|
+
* { path: 'age', label: '年龄', component: 'input-number' },
|
|
1311
|
+
* ])
|
|
1312
|
+
*
|
|
1313
|
+
* // 获取字段(类型安全,包含 Ant Design Vue 组件属性)
|
|
1314
|
+
* getField('name') // 返回值包含 input 组件的所有可选属性
|
|
1315
|
+
* ```
|
|
872
1316
|
*/
|
|
873
1317
|
export declare const useFields: {
|
|
874
1318
|
<D extends Data = Data>(initFields?: Fields<D>): ReturnType<typeof useFields_2<D, Field<ComponentName, D>, FormItemInstance>>;
|
|
875
1319
|
};
|
|
876
1320
|
|
|
877
|
-
|
|
1321
|
+
/**
|
|
1322
|
+
* 字段配置管理 Hook
|
|
1323
|
+
*
|
|
1324
|
+
* @description 提供对字段配置数组的增删改查操作,支持:
|
|
1325
|
+
* - 通过路径字符串或查找函数定位字段
|
|
1326
|
+
* - 深层嵌套字段的遍历和匹配
|
|
1327
|
+
* - 字段配置的合并/覆盖更新
|
|
1328
|
+
* - 字段的添加、插入、删除
|
|
1329
|
+
* - 父级字段查找
|
|
1330
|
+
*
|
|
1331
|
+
* @template D - 表单数据类型,用于路径类型推导
|
|
1332
|
+
* @template F - 字段配置类型,继承自 BaseField<D>
|
|
1333
|
+
* @template FormInstance - 底层 FormItem 组件实例类型
|
|
1334
|
+
*
|
|
1335
|
+
* @param {F[]} [initFields] - 初始字段配置数组
|
|
1336
|
+
*
|
|
1337
|
+
* @returns {object} 字段操作对象
|
|
1338
|
+
* @returns {Ref<F[]>} .fields - 字段配置数组(响应式)
|
|
1339
|
+
* @returns {Function} .getField(path) - 获取字段配置
|
|
1340
|
+
* @returns {Function} .setField(path, field) - 更新字段配置
|
|
1341
|
+
* @returns {Function} .deleteField(path) - 删除字段
|
|
1342
|
+
* @returns {Function} .appendField(path, field) - 在指定字段后追加
|
|
1343
|
+
* @returns {Function} .prependField(path, field) - 在指定字段前插入
|
|
1344
|
+
* @returns {Function} .getParentField(path) - 获取父级字段
|
|
1345
|
+
*
|
|
1346
|
+
* @example
|
|
1347
|
+
* ```ts
|
|
1348
|
+
* interface User { name: string; age: number; address: { city: string } }
|
|
1349
|
+
*
|
|
1350
|
+
* const { fields, getField, setField, deleteField } = useFields<User>([
|
|
1351
|
+
* { path: 'name', label: '姓名', component: 'input' },
|
|
1352
|
+
* { path: 'age', label: '年龄', component: 'input-number' },
|
|
1353
|
+
* {
|
|
1354
|
+
* path: 'address',
|
|
1355
|
+
* label: '地址',
|
|
1356
|
+
* fields: [
|
|
1357
|
+
* { path: 'city', label: '城市' },
|
|
1358
|
+
* ],
|
|
1359
|
+
* },
|
|
1360
|
+
* ])
|
|
1361
|
+
*
|
|
1362
|
+
* // 通过路径获取字段
|
|
1363
|
+
* getField('name') // { path: 'name', label: '姓名', ... }
|
|
1364
|
+
* getField('address.city') // { path: 'city', label: '城市', ... }
|
|
1365
|
+
*
|
|
1366
|
+
* // 通过查找函数获取字段
|
|
1367
|
+
* getField(f => f.label === '姓名')
|
|
1368
|
+
*
|
|
1369
|
+
* // 更新字段(合并模式)
|
|
1370
|
+
* setField('name', { label: '用户名' })
|
|
1371
|
+
*
|
|
1372
|
+
* // 删除字段
|
|
1373
|
+
* deleteField('age')
|
|
1374
|
+
*
|
|
1375
|
+
* // 追加/插入字段
|
|
1376
|
+
* appendField('name', { path: 'email', label: '邮箱', component: 'input' })
|
|
1377
|
+
* prependField('name', { path: 'id', label: 'ID', component: 'input' })
|
|
1378
|
+
* ```
|
|
1379
|
+
*/
|
|
1380
|
+
declare const useFields_2: <D extends Data = Data, F extends BaseField<D> = BaseField<D>, FormInstance = any>(initFields?: F[]) => {
|
|
878
1381
|
fields: Ref<F[], F[]>;
|
|
879
1382
|
getField: {
|
|
880
1383
|
(path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
@@ -903,8 +1406,33 @@ declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = Ba
|
|
|
903
1406
|
};
|
|
904
1407
|
|
|
905
1408
|
/**
|
|
906
|
-
*
|
|
907
|
-
*
|
|
1409
|
+
* 创建 @qin-ui/antd-vue-pro 表单实例的 Hook
|
|
1410
|
+
*
|
|
1411
|
+
* @description 类型安全的 re-export。将 core useForm 的泛型参数绑定为本地类型:
|
|
1412
|
+
* - 字段类型 F → Field<ComponentName, D>(支持 Ant Design Vue 组件类型推导)
|
|
1413
|
+
* - 表单实例 → Ant Design Vue 的 FormInstance
|
|
1414
|
+
*
|
|
1415
|
+
* 使用方式与 core useForm 完全一致,详见 {@link @qin-ui/core} 的 useForm 文档。
|
|
1416
|
+
* @public
|
|
1417
|
+
*
|
|
1418
|
+
* @template D - 表单数据类型
|
|
1419
|
+
*
|
|
1420
|
+
* @example
|
|
1421
|
+
* ```ts
|
|
1422
|
+
* interface User { name: string; age: number }
|
|
1423
|
+
*
|
|
1424
|
+
* const form = useForm<User>(
|
|
1425
|
+
* { name: '张三', age: 25 },
|
|
1426
|
+
* [
|
|
1427
|
+
* { path: 'name', label: '姓名', component: 'input' },
|
|
1428
|
+
* { path: 'age', label: '年龄', component: 'input-number' },
|
|
1429
|
+
* ],
|
|
1430
|
+
* true
|
|
1431
|
+
* )
|
|
1432
|
+
*
|
|
1433
|
+
* // 类型已绑定 Ant Design Vue
|
|
1434
|
+
* await form.formRef.value?.validate() // ✅ 类型正确
|
|
1435
|
+
* ```
|
|
908
1436
|
*/
|
|
909
1437
|
export declare const useForm: {
|
|
910
1438
|
<D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>, initFields?: Field<ComponentName, D>[], root?: boolean): Form<D, Field<ComponentName, D>>;
|
|
@@ -912,9 +1440,43 @@ export declare const useForm: {
|
|
|
912
1440
|
};
|
|
913
1441
|
|
|
914
1442
|
/**
|
|
915
|
-
* 表单数据处理
|
|
916
|
-
*
|
|
917
|
-
* @
|
|
1443
|
+
* 表单数据处理 Hook
|
|
1444
|
+
*
|
|
1445
|
+
* @description 提供响应式表单数据的管理能力,支持:
|
|
1446
|
+
* - 响应式数据存储(基于 Vue reactive)
|
|
1447
|
+
* - 深层路径读写(支持点号分隔,如 'address.city')
|
|
1448
|
+
* - 类型安全的路径提示(传入泛型 D 后,path 参数可获得类型推导)
|
|
1449
|
+
* - 父子表单自动注入(非根表单会从注入中获取数据)
|
|
1450
|
+
* @public
|
|
1451
|
+
*
|
|
1452
|
+
* @template D - 表单数据类型,应为一个对象类型
|
|
1453
|
+
* @param {ExtendWithAny<DeepPartial<D>>} [initFormData] - 初始表单数据
|
|
1454
|
+
*
|
|
1455
|
+
* @returns {object} 表单数据操作对象
|
|
1456
|
+
* @returns {D & Record<string, any>} .formData - 响应式表单数据
|
|
1457
|
+
* @returns {Function} .getFormData(path) - 获取指定路径的数据
|
|
1458
|
+
* @returns {Function} .setFormData(path, value) - 设置指定路径的数据
|
|
1459
|
+
*
|
|
1460
|
+
* @example
|
|
1461
|
+
* ```ts
|
|
1462
|
+
* interface User { name: string; age: number; address: { city: string } }
|
|
1463
|
+
*
|
|
1464
|
+
* const { formData, getFormData, setFormData } = useFormData<User>({
|
|
1465
|
+
* name: '张三',
|
|
1466
|
+
* address: { city: '北京' }
|
|
1467
|
+
* })
|
|
1468
|
+
*
|
|
1469
|
+
* // 读取
|
|
1470
|
+
* getFormData('name') // '张三'
|
|
1471
|
+
* getFormData('address.city') // '北京'
|
|
1472
|
+
* formData.name // '张三'(响应式)
|
|
1473
|
+
*
|
|
1474
|
+
* // 设置
|
|
1475
|
+
* setFormData('name', '李四')
|
|
1476
|
+
* setFormData('address.city', '上海')
|
|
1477
|
+
* setFormData({ name: '王五', age: 30 }) // 批量覆盖
|
|
1478
|
+
* setFormData(prev => ({ ...prev, name: '赵六' })) // 函数式更新
|
|
1479
|
+
* ```
|
|
918
1480
|
*/
|
|
919
1481
|
export declare const useFormData: <D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>) => {
|
|
920
1482
|
formData: Reactive<ExtendWithAny<D>>;
|
|
@@ -933,21 +1495,84 @@ export declare const useFormData: <D extends Data = Data>(initFormData?: ExtendW
|
|
|
933
1495
|
};
|
|
934
1496
|
|
|
935
1497
|
/**
|
|
936
|
-
*
|
|
937
|
-
*
|
|
1498
|
+
* @qin-ui/antd-vue-pro 的表单组件实例引用 Hook
|
|
1499
|
+
*
|
|
1500
|
+
* @description 类型安全的 re-export。将 core useFormRef 的泛型参数绑定为 Ant Design Vue 的 FormInstance,
|
|
1501
|
+
* 使 formRef 获取到完整的 Ant Design Vue Form 组件 API 类型提示。
|
|
1502
|
+
* @public
|
|
1503
|
+
*
|
|
1504
|
+
* @returns {object} 表单组件实例引用管理对象
|
|
1505
|
+
* @returns {Ref<FormInstance | undefined>} .formRef - Ant Design Vue Form 实例的响应式引用
|
|
1506
|
+
* @returns {Function} .setFormRef(inst) - 设置表单组件实例
|
|
1507
|
+
*
|
|
1508
|
+
* @example
|
|
1509
|
+
* ```ts
|
|
1510
|
+
* const { formRef, setFormRef } = useFormRef()
|
|
1511
|
+
* // formRef.value 的类型为 FormInstance | undefined
|
|
1512
|
+
* // 可安全调用 Ant Design Vue 的 Form API
|
|
1513
|
+
* await formRef.value?.validate()
|
|
1514
|
+
* formRef.value?.resetFields()
|
|
1515
|
+
* ```
|
|
938
1516
|
*/
|
|
939
1517
|
export declare const useFormRef: {
|
|
940
1518
|
(): ReturnType<typeof useFormRef_2<FormInstance>>;
|
|
941
1519
|
};
|
|
942
1520
|
|
|
1521
|
+
/**
|
|
1522
|
+
* 表单组件实例引用 Hook
|
|
1523
|
+
*
|
|
1524
|
+
* @description 用于获取和设置底层 UI 框架(如 ant-design-vue、element-plus)的 Form 组件实例。
|
|
1525
|
+
* 在 ProForm 组件内部自动调用 setFormRef 绑定实例,外部可通过 formRef 访问。
|
|
1526
|
+
*
|
|
1527
|
+
* @template F - 底层 Form 组件实例类型,默认为 any
|
|
1528
|
+
*
|
|
1529
|
+
* @returns {object} 表单组件实例引用管理对象
|
|
1530
|
+
* @returns {Ref<F | undefined>} .formRef - 表单组件实例的响应式引用
|
|
1531
|
+
* @returns {Function} .setFormRef(inst) - 设置表单组件实例
|
|
1532
|
+
*
|
|
1533
|
+
* @example
|
|
1534
|
+
* ```ts
|
|
1535
|
+
* const { formRef, setFormRef } = useFormRef<InstanceType<typeof AForm>>()
|
|
1536
|
+
* setFormRef(formComponentInstance)
|
|
1537
|
+
* console.log(formRef.value) // 可通过 formRef 访问底层 Form 实例的方法
|
|
1538
|
+
* ```
|
|
1539
|
+
*/
|
|
943
1540
|
declare const useFormRef_2: <F = any>() => {
|
|
944
1541
|
formRef: Ref<F | undefined, F | undefined>;
|
|
945
1542
|
setFormRef: (inst: F) => void;
|
|
946
1543
|
};
|
|
947
1544
|
|
|
948
1545
|
/**
|
|
949
|
-
*
|
|
950
|
-
*
|
|
1546
|
+
* 创建 @qin-ui/antd-vue-pro 表格实例 of Hook
|
|
1547
|
+
*
|
|
1548
|
+
* @description 类型安全的 re-export。将 core useTable 的列类型绑定为本地 Column<T>,
|
|
1549
|
+
* 使 columns 操作获得 Ant Design Vue 表格列的完整类型提示。
|
|
1550
|
+
*
|
|
1551
|
+
* 使用方式与 core useTable 完全一致,详见 `@qin-ui/core` 的 useTable 文档。
|
|
1552
|
+
* @public
|
|
1553
|
+
*
|
|
1554
|
+
* @template D - 搜索表单数据类型
|
|
1555
|
+
* @template T - 表格行数据类型
|
|
1556
|
+
*
|
|
1557
|
+
* @example
|
|
1558
|
+
* ```ts
|
|
1559
|
+
* interface SearchParams { keyword: string }
|
|
1560
|
+
* interface User { name: string; age: number; email: string }
|
|
1561
|
+
*
|
|
1562
|
+
* const table = useTable<SearchParams, User>({
|
|
1563
|
+
* columns: [
|
|
1564
|
+
* { key: 'name', title: '姓名', width: 120 },
|
|
1565
|
+
* { key: 'age', title: '年龄', width: 80 },
|
|
1566
|
+
* { key: 'email', title: '邮箱' },
|
|
1567
|
+
* ],
|
|
1568
|
+
* dataSource: [],
|
|
1569
|
+
* pageParam: { current: 1, pageSize: 20, total: 0 },
|
|
1570
|
+
* searchParam: { keyword: '' },
|
|
1571
|
+
* searchFields: [
|
|
1572
|
+
* { path: 'keyword', label: '关键词', component: 'input' },
|
|
1573
|
+
* ],
|
|
1574
|
+
* })
|
|
1575
|
+
* ```
|
|
951
1576
|
*/
|
|
952
1577
|
export declare const useTable: <D extends Data = Data, T extends Data = ExtendWithAny<D>>(params: {
|
|
953
1578
|
columns?: Columns<T>;
|
|
@@ -957,14 +1582,14 @@ export declare const useTable: <D extends Data = Data, T extends Data = ExtendWi
|
|
|
957
1582
|
searchFields?: Fields<D>;
|
|
958
1583
|
}) => Table<D, T>;
|
|
959
1584
|
|
|
960
|
-
|
|
1585
|
+
declare type ValueFormatter = {
|
|
961
1586
|
(val: any, oldVal: any): any;
|
|
962
1587
|
} | {
|
|
963
1588
|
get?: (val: any) => any;
|
|
964
1589
|
set?: (val: any, oldVal: any) => any;
|
|
965
1590
|
};
|
|
966
1591
|
|
|
967
|
-
|
|
1592
|
+
declare type VModelProps<T = any> = {
|
|
968
1593
|
value?: T;
|
|
969
1594
|
'onUpdate:value'?: (val: T) => void;
|
|
970
1595
|
};
|
|
@@ -988,7 +1613,7 @@ declare type WithFields<D extends Data = Data> = WithRef<WithCommonBase & BaseWi
|
|
|
988
1613
|
* @description 为对象属性添加响应式支持的类型
|
|
989
1614
|
* @template T - 原始类型
|
|
990
1615
|
*/
|
|
991
|
-
|
|
1616
|
+
declare type WithRef<T> = {
|
|
992
1617
|
[P in keyof T]: P extends NotSupportedRefOrGetterProps ? T[P] : T[P] extends (...args: any[]) => any ? T[P] : MaybeRefOrComputedRef<T[P]>;
|
|
993
1618
|
};
|
|
994
1619
|
|