@dazhicheng/ui 1.5.174 → 1.5.175
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/utils.d.ts +1 -0
- package/dist/components/tt-form/src/group-form/groupFormApi.d.ts +39 -11
- package/dist/components/tt-form/src/group-form/lazyContext.d.ts +17 -2
- package/dist/components/tt-form/src/group-form/utils.d.ts +6 -0
- package/dist/index.js +2730 -2663
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ export type ArrayItemResolvedState = {
|
|
|
7
7
|
rules: FormSchema["rules"];
|
|
8
8
|
formItemClass: FormSchema["formItemClass"];
|
|
9
9
|
disabled: FormSchema["disabled"];
|
|
10
|
+
wrapperClass: FormSchema["wrapperClass"];
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
12
13
|
* 对齐 FormField: shouldDisabled = isDisabled || disabled || computedProps.disabled
|
|
@@ -26,6 +26,8 @@ export declare class GroupFormApi extends FormApi {
|
|
|
26
26
|
readonly collapseStates: Record<string, boolean>;
|
|
27
27
|
/** 当前被 ifShow 隐藏的分组 key 集合 */
|
|
28
28
|
readonly hiddenGroupKeys: Set<string>;
|
|
29
|
+
/** 当前被 ifShow 隐藏的字段名集合 */
|
|
30
|
+
readonly hiddenFieldNames: Set<string>;
|
|
29
31
|
/** 导航各分组的错误数量,validate 后自动更新 */
|
|
30
32
|
readonly navErrorCounts: Record<string, number>;
|
|
31
33
|
/** 共享错误缓存,validate 写入 → LazyFormField 挂载时读取恢复 */
|
|
@@ -132,20 +134,28 @@ export declare class GroupFormApi extends FormApi {
|
|
|
132
134
|
*/
|
|
133
135
|
toggleCollapse(key: string): void;
|
|
134
136
|
/**
|
|
135
|
-
* @description
|
|
136
|
-
*
|
|
137
|
+
* @description 设置容器的可见性状态,由 GroupSection 组件在 ifShow 求值后调用。
|
|
138
|
+
* group 隐藏时额外维护 {@link hiddenGroupKeys} 供导航和渲染判断;
|
|
139
|
+
* group / row 隐藏时都会清空其下字段值和校验,并把字段加入 {@link hiddenFieldNames},使隐藏字段不参与校验。
|
|
137
140
|
* 可见性变化后在下一帧调用 {@link syncNavErrorCountsFromForm},使「先 validate 再隐藏再显示」时
|
|
138
141
|
* 导航徽标、{@link errorCacheMap} 与表单项错误展示保持一致。
|
|
139
142
|
* @param {string} key - 分组 key
|
|
140
143
|
* @param {boolean} visible - 是否可见
|
|
144
|
+
* @param {string[]} [fieldNames] - 兼容旧内部调用的字段名列表,传入时按字段集合显隐处理
|
|
141
145
|
*/
|
|
142
|
-
setGroupVisible(key: string, visible: boolean): void;
|
|
146
|
+
setGroupVisible(key: string, visible: boolean, fieldNames?: string[]): void;
|
|
143
147
|
/**
|
|
144
|
-
* @description
|
|
148
|
+
* @description 设置字段集合的可见性状态,用于 row 容器隐藏时同步字段值、校验和错误缓存。
|
|
149
|
+
* @param {string[]} fieldNames - 字段名列表
|
|
150
|
+
* @param {boolean} visible - 是否可见
|
|
151
|
+
*/
|
|
152
|
+
setFieldsVisible(fieldNames: string[], visible: boolean): void;
|
|
153
|
+
/**
|
|
154
|
+
* @description 判断字段是否属于被隐藏的字段集合
|
|
145
155
|
* @param {string} fieldName - 字段名
|
|
146
|
-
* @returns {boolean}
|
|
156
|
+
* @returns {boolean} 是否属于隐藏字段
|
|
147
157
|
*/
|
|
148
|
-
private
|
|
158
|
+
private _isFieldHidden;
|
|
149
159
|
/**
|
|
150
160
|
* @description 判断错误键是否命中字段(支持数组/对象嵌套键)
|
|
151
161
|
* @param {string} errorKey - 错误键(如 a[0].b)
|
|
@@ -219,11 +229,11 @@ export declare class GroupFormApi extends FormApi {
|
|
|
219
229
|
*/
|
|
220
230
|
private _scrollToFirstErrorGroup;
|
|
221
231
|
/**
|
|
222
|
-
* @description
|
|
232
|
+
* @description 从校验结果中剔除属于隐藏字段集合的错误,并重新判定 valid 状态
|
|
223
233
|
* @param {object} result - 校验结果
|
|
224
234
|
* @returns {object} 过滤后的校验结果
|
|
225
235
|
*/
|
|
226
|
-
private
|
|
236
|
+
private _stripHiddenFieldErrors;
|
|
227
237
|
/**
|
|
228
238
|
* @description 对单个字段值执行 rules 校验(纯数据,不挂载组件)。
|
|
229
239
|
* 支持字符串规则("required" / "selectRequired")和 Zod schema。
|
|
@@ -287,10 +297,28 @@ export declare class GroupFormApi extends FormApi {
|
|
|
287
297
|
*/
|
|
288
298
|
private _getGroupFieldNamesWithVisited;
|
|
289
299
|
/**
|
|
290
|
-
* @description
|
|
291
|
-
* @param {string}
|
|
300
|
+
* @description 获取字段所属分组 key,支持数组/对象嵌套路径回溯到 schema 字段。
|
|
301
|
+
* @param {string} fieldName 字段名
|
|
302
|
+
* @returns {string | undefined} 所属分组 key
|
|
303
|
+
*/
|
|
304
|
+
private _getFieldGroupKey;
|
|
305
|
+
/**
|
|
306
|
+
* @description 判断字段所属分组或祖先分组是否仍处于隐藏状态,用于避免字段显示时绕过仍隐藏的父级分组。
|
|
307
|
+
* @param {string} fieldName 字段名
|
|
308
|
+
* @returns {boolean} 是否存在隐藏的所属分组或祖先分组
|
|
309
|
+
*/
|
|
310
|
+
private _hasHiddenGroup;
|
|
311
|
+
/**
|
|
312
|
+
* @description 设置字段隐藏状态
|
|
313
|
+
* @param {string[]} fieldNames 字段名列表
|
|
314
|
+
* @param {boolean} hidden 是否隐藏
|
|
315
|
+
*/
|
|
316
|
+
private _setFieldsHidden;
|
|
317
|
+
/**
|
|
318
|
+
* @description 清空隐藏字段的值、校验状态和虚拟错误缓存,不注销 schema 仍存在的数组字段注册。
|
|
319
|
+
* @param {string[]} fieldNames 字段名列表
|
|
292
320
|
*/
|
|
293
|
-
private
|
|
321
|
+
private _clearHiddenFieldValues;
|
|
294
322
|
/**
|
|
295
323
|
* @description 卸载分组表单时恢复初始schema
|
|
296
324
|
*/
|
|
@@ -35,11 +35,26 @@ export interface RenderScheduler {
|
|
|
35
35
|
*/
|
|
36
36
|
export declare function createRenderScheduler(batchSize?: number): RenderScheduler;
|
|
37
37
|
export declare const RENDER_SCHEDULER_KEY: InjectionKey<RenderScheduler>;
|
|
38
|
+
export type GroupVisibilityPayload = {
|
|
39
|
+
/** 可见性变化来源为分组 */
|
|
40
|
+
type: "group";
|
|
41
|
+
/** 分组 key */
|
|
42
|
+
key: string;
|
|
43
|
+
/** 是否可见 */
|
|
44
|
+
visible: boolean;
|
|
45
|
+
} | {
|
|
46
|
+
/** 可见性变化来源为 row 容器 */
|
|
47
|
+
type: "row";
|
|
48
|
+
/** row 下需要同步隐藏状态的字段名 */
|
|
49
|
+
fieldNames: string[];
|
|
50
|
+
/** 是否可见 */
|
|
51
|
+
visible: boolean;
|
|
52
|
+
};
|
|
38
53
|
/**
|
|
39
54
|
* 分组可见性回调注入 key,由 GroupForm.vue provide,GroupSection.vue inject。
|
|
40
|
-
*
|
|
55
|
+
* 当 group / row 的 ifShow 求值结果变化时,GroupSection 调用此回调通知 API 层同步隐藏状态。
|
|
41
56
|
*/
|
|
42
|
-
export declare const GROUP_VISIBILITY_CALLBACK_KEY: InjectionKey<(
|
|
57
|
+
export declare const GROUP_VISIBILITY_CALLBACK_KEY: InjectionKey<(payload: GroupVisibilityPayload) => void>;
|
|
43
58
|
/**
|
|
44
59
|
* 当外部通过 formApi.setGroupVisible(key, false) 隐藏分组时,
|
|
45
60
|
* GroupSection 读取此集合决定是否渲染,实现 API 驱动的分组显隐。
|
|
@@ -31,6 +31,12 @@ export declare function isSlotSchema(schema: GroupFormSchema): schema is FormSlo
|
|
|
31
31
|
* @returns {string} 用于 :key 的字符串
|
|
32
32
|
*/
|
|
33
33
|
export declare function getSchemaKey(schema: GroupFormSchema, idx: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* 获取字段列表中的有效字段名。
|
|
36
|
+
* @param {FormSchema[]} fields - 字段列表
|
|
37
|
+
* @returns {string[]} 字段名列表
|
|
38
|
+
*/
|
|
39
|
+
export declare function getFieldNames(fields: FormSchema[]): string[];
|
|
34
40
|
/**
|
|
35
41
|
* 递归展平分组 schema,提取所有字段 schema(忽略分组结构)
|
|
36
42
|
* @param {GroupFormSchema[]} schemas - 分组 schema 数组,可包含分组与字段的混合结构
|