@dazhicheng/ui 1.5.164 → 1.5.165
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.d.ts +34 -0
- package/dist/components/tt-form/src/form-render/array-register/index.d.ts +3 -0
- package/dist/components/tt-form/src/form-render/array-register/props.d.ts +44 -0
- package/dist/components/tt-form/src/form-render/array-register/types.d.ts +15 -0
- package/dist/components/tt-form/src/form-render/array-register/utils.d.ts +23 -0
- package/dist/components/tt-form/src/group-form/groupFormApi.d.ts +6 -0
- package/dist/components/tt-form/src/index.vue.d.ts +3 -3
- package/dist/components/tt-form/src/types.d.ts +30 -4
- package/dist/components/tt-modal/src/typing.d.ts +1 -1
- package/dist/index.js +5193 -5124
- package/package.json +1 -1
- package/dist/components/tt-form/src/form-render/FormArrayRegister.d.ts +0 -67
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { VNodeChild } from 'vue';
|
|
2
|
+
import { Recordable } from '../../../../../../../utils/src';
|
|
3
|
+
import { ArraySchemaContext, FormSchema } from '../../types';
|
|
4
|
+
import { FieldEntry } from '../../types/forms';
|
|
5
|
+
export declare const FormArrayRegister: import('vue').DefineComponent<{
|
|
6
|
+
disabled?: boolean | undefined;
|
|
7
|
+
hide?: boolean | undefined;
|
|
8
|
+
wrapperClass?: string | undefined;
|
|
9
|
+
arraySchema?: FormSchema[] | ((entry: FieldEntry<Recordable>, currentIndex: number, ctx: ArraySchemaContext) => FormSchema[]) | undefined;
|
|
10
|
+
dependencies?: import('./types').ArrayRegisterDependencies | undefined;
|
|
11
|
+
fieldName: string;
|
|
12
|
+
rules?: import('../../types').FormSchemaRuleType | undefined;
|
|
13
|
+
formItemClass?: (() => string) | string | undefined;
|
|
14
|
+
virtual?: boolean | undefined;
|
|
15
|
+
}, () => VNodeChild, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
|
|
16
|
+
disabled?: boolean | undefined;
|
|
17
|
+
hide?: boolean | undefined;
|
|
18
|
+
wrapperClass?: string | undefined;
|
|
19
|
+
arraySchema?: FormSchema[] | ((entry: FieldEntry<Recordable>, currentIndex: number, ctx: ArraySchemaContext) => FormSchema[]) | undefined;
|
|
20
|
+
dependencies?: import('./types').ArrayRegisterDependencies | undefined;
|
|
21
|
+
fieldName: string;
|
|
22
|
+
rules?: import('../../types').FormSchemaRuleType | undefined;
|
|
23
|
+
formItemClass?: (() => string) | string | undefined;
|
|
24
|
+
virtual?: boolean | undefined;
|
|
25
|
+
}> & Readonly<{}>, {
|
|
26
|
+
readonly disabled: boolean | undefined;
|
|
27
|
+
readonly hide: boolean | undefined;
|
|
28
|
+
readonly wrapperClass: string;
|
|
29
|
+
readonly arraySchema: import('./props').ArraySchemaProp;
|
|
30
|
+
readonly dependencies: import('./types').ArrayRegisterDependencies | undefined;
|
|
31
|
+
readonly rules: import('../../types').FormSchemaRuleType | undefined;
|
|
32
|
+
readonly formItemClass: NonNullable<string | (() => string) | undefined>;
|
|
33
|
+
readonly virtual: boolean;
|
|
34
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { Recordable } from '../../../../../../../utils/src';
|
|
3
|
+
import { FieldEntry } from '../../types/forms';
|
|
4
|
+
import { ArrayRegisterDependencies, ArraySchemaContext, FormSchema } from '../../types';
|
|
5
|
+
export type ArraySchemaProp = FormSchema[] | ((entry: FieldEntry<Recordable>, currentIndex: number, ctx: ArraySchemaContext) => FormSchema[]);
|
|
6
|
+
export declare const formArrayRegisterProps: {
|
|
7
|
+
readonly fieldName: {
|
|
8
|
+
readonly type: PropType<string>;
|
|
9
|
+
readonly required: true;
|
|
10
|
+
};
|
|
11
|
+
readonly hide: {
|
|
12
|
+
readonly type: PropType<boolean | undefined>;
|
|
13
|
+
readonly default: undefined;
|
|
14
|
+
};
|
|
15
|
+
readonly disabled: {
|
|
16
|
+
readonly type: PropType<boolean | undefined>;
|
|
17
|
+
readonly default: undefined;
|
|
18
|
+
};
|
|
19
|
+
readonly dependencies: {
|
|
20
|
+
readonly type: PropType<ArrayRegisterDependencies | undefined>;
|
|
21
|
+
readonly default: undefined;
|
|
22
|
+
};
|
|
23
|
+
readonly arraySchema: {
|
|
24
|
+
readonly type: PropType<ArraySchemaProp>;
|
|
25
|
+
readonly default: () => FormSchema[];
|
|
26
|
+
};
|
|
27
|
+
readonly formItemClass: {
|
|
28
|
+
readonly type: PropType<NonNullable<FormSchema["formItemClass"]>>;
|
|
29
|
+
readonly default: undefined;
|
|
30
|
+
};
|
|
31
|
+
readonly rules: {
|
|
32
|
+
readonly type: PropType<FormSchema["rules"]>;
|
|
33
|
+
readonly default: undefined;
|
|
34
|
+
};
|
|
35
|
+
readonly virtual: {
|
|
36
|
+
readonly type: BooleanConstructor;
|
|
37
|
+
readonly default: false;
|
|
38
|
+
};
|
|
39
|
+
/** useArraySchema 时:每一行数组项的外层容器 class(边框、间距等) */
|
|
40
|
+
readonly wrapperClass: {
|
|
41
|
+
readonly type: PropType<NonNullable<FormSchema["wrapperClass"]>>;
|
|
42
|
+
readonly default: undefined;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ArrayRegisterDependencies, ArrayRegisterSchema } from '../../types';
|
|
2
|
+
import { FieldEntry } from '../../types/forms';
|
|
3
|
+
import { Recordable } from '../../../../../../../utils/src';
|
|
4
|
+
export type ArrayRegisterProps = Pick<ArrayRegisterSchema, "fieldName" | "arraySchema" | "formItemClass" | "rules" | "wrapperClass" | "hide" | "disabled" | "dependencies"> & {
|
|
5
|
+
/**
|
|
6
|
+
* 虚拟滚动/懒渲染开关(来自渲染层,不属于 FormSchema)
|
|
7
|
+
*/
|
|
8
|
+
virtual?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type { ArrayRegisterDependencies };
|
|
11
|
+
export type RowRenderCtx = {
|
|
12
|
+
entry: FieldEntry<Recordable>;
|
|
13
|
+
index: number;
|
|
14
|
+
itemFieldName: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FormSchema } from '../../types';
|
|
2
|
+
import { ArrayRegisterProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 数组子项字段状态(规则/样式/禁用)解析结果。
|
|
5
|
+
*/
|
|
6
|
+
export type ArrayItemResolvedState = {
|
|
7
|
+
rules: FormSchema["rules"];
|
|
8
|
+
formItemClass: FormSchema["formItemClass"];
|
|
9
|
+
disabled: FormSchema["disabled"];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 对齐 FormField: shouldDisabled = isDisabled || disabled || computedProps.disabled
|
|
13
|
+
* 在 useArraySchema 场景下的通用禁用合并。
|
|
14
|
+
*/
|
|
15
|
+
export declare function getMergedDisabled(dynamicDisabled: boolean, ownDisabled?: boolean, outerDisabled?: boolean): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 按“子项 > 外部动态 > 外部静态”优先级解析数组子项状态。
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveArrayItemState(schema: FormSchema, options: {
|
|
20
|
+
dynamicRules: FormSchema["rules"];
|
|
21
|
+
dynamicDisabled: boolean;
|
|
22
|
+
props: ArrayRegisterProps;
|
|
23
|
+
}): ArrayItemResolvedState;
|
|
@@ -44,6 +44,8 @@ export declare class GroupFormApi extends FormApi {
|
|
|
44
44
|
private _fieldToGroupKey;
|
|
45
45
|
/** 子分组 key → 父分组 key 的映射,用于递归向上查找祖先分组是否被隐藏 */
|
|
46
46
|
private _groupParentMap;
|
|
47
|
+
/** 分组 key 构建时的去重集合,用于检测重复 key */
|
|
48
|
+
private _groupKeySet;
|
|
47
49
|
/** 是否已执行过 validate,用于控制导航栏错误同步是否需要重新校验未挂载字段 */
|
|
48
50
|
private _hasValidated;
|
|
49
51
|
/** VirtualGroupForm 组件实例引用,由 useGroupForm 的 h() 渲染时赋值 */
|
|
@@ -280,6 +282,10 @@ export declare class GroupFormApi extends FormApi {
|
|
|
280
282
|
* @returns {string[]} 字段名列表
|
|
281
283
|
*/
|
|
282
284
|
getGroupFieldNames(key: string, includeChildren?: boolean): string[];
|
|
285
|
+
/**
|
|
286
|
+
* @description 获取指定分组字段名(带防环保护),避免异常 schema 导致递归栈溢出
|
|
287
|
+
*/
|
|
288
|
+
private _getGroupFieldNamesWithVisited;
|
|
283
289
|
/**
|
|
284
290
|
* @description 清空分组下的所有字段值
|
|
285
291
|
* @param {string} key 分组 key
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtendedFormApi, TtFormProps
|
|
1
|
+
import { ExtendedFormApi, TtFormProps } from './types';
|
|
2
2
|
import { nextTick } from 'vue';
|
|
3
3
|
interface Props extends TtFormProps {
|
|
4
4
|
formApi?: ExtendedFormApi;
|
|
@@ -28,7 +28,7 @@ declare function __VLS_template(): {
|
|
|
28
28
|
readonly fieldMappingTime?: import('./types').FieldMappingTime | undefined;
|
|
29
29
|
readonly form?: import('./types').FormActions | undefined;
|
|
30
30
|
readonly layout?: import('./types').FormLayout | undefined;
|
|
31
|
-
readonly schema?: (
|
|
31
|
+
readonly schema?: (import('./types').FormSlotSchema | import('./types').FormSchemaItem<keyof import('./types').BaseFormComponentMap>)[] | undefined;
|
|
32
32
|
readonly showCollapseButton?: boolean | undefined;
|
|
33
33
|
readonly wrapperClass?: import('./types').WrapperClassType | undefined;
|
|
34
34
|
readonly globalCommonConfig?: import('./types').FormCommonConfig | undefined;
|
|
@@ -115,7 +115,7 @@ declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {},
|
|
|
115
115
|
readonly fieldMappingTime?: import('./types').FieldMappingTime | undefined;
|
|
116
116
|
readonly form?: import('./types').FormActions | undefined;
|
|
117
117
|
readonly layout?: import('./types').FormLayout | undefined;
|
|
118
|
-
readonly schema?: (
|
|
118
|
+
readonly schema?: (import('./types').FormSlotSchema | import('./types').FormSchemaItem<keyof import('./types').BaseFormComponentMap>)[] | undefined;
|
|
119
119
|
readonly showCollapseButton?: boolean | undefined;
|
|
120
120
|
readonly wrapperClass?: import('./types').WrapperClassType | undefined;
|
|
121
121
|
readonly globalCommonConfig?: import('./types').FormCommonConfig | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ButtonProps, CheckboxProps, CheckboxGroupProps, DatePickerProps, InputProps, InputNumberProps, RadioProps, RadioGroupProps, SelectProps, SelectV2Props, SwitchProps, TimePickerDefaultProps, UploadProps, CascaderProps, ColorPickerProps } from 'element-plus';
|
|
2
2
|
import { FieldOptions, FormContext, GenericObject } from 'vee-validate';
|
|
3
|
-
import { Component, HtmlHTMLAttributes, MaybeRefOrGetter, Ref,
|
|
3
|
+
import { Component, HtmlHTMLAttributes, MaybeRefOrGetter, Ref, VNodeChild } from 'vue';
|
|
4
4
|
import { ZodTypeAny } from 'zod';
|
|
5
5
|
import { TtTextProps } from '../../tt-text';
|
|
6
6
|
import { TtSelectProp } from '../../tt-select';
|
|
@@ -170,6 +170,13 @@ export interface FormItemDependencies {
|
|
|
170
170
|
*/
|
|
171
171
|
immediate?: boolean;
|
|
172
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* `useArraySchema: true` 的数组字段依赖约束:
|
|
175
|
+
* - 允许用 `if/show` 控制可见性
|
|
176
|
+
* - 允许用 `rules/disabled` 动态控制规则与禁用
|
|
177
|
+
* - 允许声明 `triggerFields` 作为依赖触发源
|
|
178
|
+
*/
|
|
179
|
+
export type ArrayRegisterDependencies = Pick<FormItemDependencies, "if" | "show" | "rules" | "disabled" | "triggerFields">;
|
|
173
180
|
type ComponentProps = ((value: Partial<Record<string, any>>, actions: FormActions) => MaybeComponentProps) | MaybeComponentProps;
|
|
174
181
|
export interface FormCommonConfig {
|
|
175
182
|
/**
|
|
@@ -254,6 +261,7 @@ export type FieldMappingTime = [
|
|
|
254
261
|
(((value: any, fieldName: string) => any) | [string, string] | null | string)?
|
|
255
262
|
][];
|
|
256
263
|
export type ArrayToStringFields = Array<[string[], string?] | string | string[]>;
|
|
264
|
+
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
257
265
|
export interface FormSchema<T extends BaseFormComponentType = BaseFormComponentType> extends FormCommonConfig {
|
|
258
266
|
/** 组件 */
|
|
259
267
|
component: Component | T;
|
|
@@ -297,6 +305,21 @@ export interface FormSchema<T extends BaseFormComponentType = BaseFormComponentT
|
|
|
297
305
|
/** 第三参数由 FormArrayRegister 注入;旧写法可忽略 */
|
|
298
306
|
ctx: ArraySchemaContext) => FormSchema[]);
|
|
299
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* 普通字段:不走 `useArraySchema` 渲染链路。
|
|
310
|
+
*/
|
|
311
|
+
export type NonArrayFormSchema<T extends BaseFormComponentType = BaseFormComponentType> = Omit<FormSchema<T>, "useArraySchema" | "arraySchema"> & {
|
|
312
|
+
useArraySchema?: undefined;
|
|
313
|
+
arraySchema?: never;
|
|
314
|
+
};
|
|
315
|
+
export type ArrayRegisterSchema<T extends BaseFormComponentType = BaseFormComponentType> = Pick<FormSchema<T>, "component" | "fieldName" | "arraySchema" | "formItemClass" | "rules" | "wrapperClass" | "hide" | "disabled"> & {
|
|
316
|
+
dependencies?: ArrayRegisterDependencies;
|
|
317
|
+
useArraySchema: true;
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* 表单 schema 项:普通字段 or 数组字段(受 `useArraySchema` 判别约束)。
|
|
321
|
+
*/
|
|
322
|
+
export type FormSchemaItem<T extends BaseFormComponentType = BaseFormComponentType> = NonArrayFormSchema<T> | ArrayRegisterSchema<T>;
|
|
300
323
|
/** 插槽 scope 参数,传递给渲染函数或具名插槽 */
|
|
301
324
|
export interface FormSlotScope {
|
|
302
325
|
/** 当前表单所有字段的值 */
|
|
@@ -314,20 +337,23 @@ export interface FormArraySlotScope extends FormSlotScope {
|
|
|
314
337
|
arrayPath?: string;
|
|
315
338
|
arrayIndex?: number;
|
|
316
339
|
fieldName?: string;
|
|
340
|
+
/** 数组层统一禁用态(外层 disabled 或 dependencies.disabled) */
|
|
341
|
+
disabled?: boolean;
|
|
317
342
|
}
|
|
343
|
+
export type { ArrayRegisterProps } from './form-render/array-register/types';
|
|
318
344
|
/**
|
|
319
345
|
* 自定义插槽 schema,在表单字段之间插入任意自定义内容。
|
|
320
346
|
* content 为字符串时作为具名插槽名,在模板中用 `<template #slotName="{ values, formActions }">` 编写;
|
|
321
347
|
* content 为函数时直接返回 VNode。
|
|
322
348
|
* @property {"slot"} type - 固定为 "slot"
|
|
323
|
-
* @property {string | ((scope: FormSlotScope) =>
|
|
349
|
+
* @property {string | ((scope: FormSlotScope) => VNodeChild)} content - 插槽名或渲染函数
|
|
324
350
|
* @property {WrapperClassType} [wrapperClass] - 容器额外 class(如 col-span-full)
|
|
325
351
|
*/
|
|
326
352
|
export interface FormSlotSchema {
|
|
327
353
|
/** 类型标识 */
|
|
328
354
|
type: "slot";
|
|
329
355
|
/** 插槽名(字符串)或渲染函数 */
|
|
330
|
-
content: string | ((scope: FormSlotScope) =>
|
|
356
|
+
content: string | ((scope: FormSlotScope) => VNodeChild);
|
|
331
357
|
/** 容器额外 class */
|
|
332
358
|
wrapperClass?: WrapperClassType;
|
|
333
359
|
/**
|
|
@@ -390,7 +416,7 @@ export interface FormRenderProps<T extends BaseFormComponentType = BaseFormCompo
|
|
|
390
416
|
/**
|
|
391
417
|
* 表单定义,支持普通字段
|
|
392
418
|
*/
|
|
393
|
-
schema?: (
|
|
419
|
+
schema?: (FormSchemaItem<T> | FormSlotSchema)[];
|
|
394
420
|
/**
|
|
395
421
|
* 是否显示展开/折叠
|
|
396
422
|
*/
|