@dazhicheng/ui 1.5.155 → 1.5.156
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/index.d.ts +1 -1
- package/dist/components/tt-form/src/group-form/groupFormApi.d.ts +1 -1
- package/dist/components/tt-form/src/group-form/index.d.ts +2 -2
- package/dist/components/tt-form/src/group-form/types.d.ts +23 -6
- package/dist/components/tt-form/src/group-form/useGroupForm.d.ts +9 -2
- package/dist/components/tt-form/src/group-form/utils.d.ts +9 -0
- package/dist/components/tt-form/src/hooks/useFieldArray.d.ts +3 -5
- package/dist/components/tt-form/src/types/forms.d.ts +1 -1
- package/dist/components/tt-form/src/types.d.ts +1 -1
- package/dist/index.js +2660 -2652
- package/package.json +1 -1
|
@@ -12,4 +12,4 @@ type TtExtendedFormApi = ExtendedFormApi;
|
|
|
12
12
|
export type { BaseFormComponentMap, BaseFormComponentType, FormSlotSchema, InferredComponentPropsType, TtExtendedFormApi, TtFormProps, TtFormRenderProps, TtFormSchema, };
|
|
13
13
|
export * as z from 'zod';
|
|
14
14
|
export { useGroupForm } from './src/group-form';
|
|
15
|
-
export type { FormGroupSchema, GroupFormNavAnchorProps, GroupFormSchema, UseGroupFormNavAnchorProps, UseGroupFormOptions, } from './src/group-form';
|
|
15
|
+
export type { FormGroupSchema, GroupFormNavAnchorProps, GroupFormSchema, UseGroupFormNavAnchorProps, UseGroupFormOptions, UseGroupFormOptionsWithGroupSchema, UseGroupFormOptionsWithLegacySchema, } from './src/group-form';
|
|
@@ -71,7 +71,7 @@ export declare class GroupFormApi extends FormApi {
|
|
|
71
71
|
*/
|
|
72
72
|
get navAnchorProps(): Required<Pick<UseGroupFormNavAnchorProps, "show">> & UseGroupFormNavAnchorProps;
|
|
73
73
|
/**
|
|
74
|
-
* @description 覆盖基类 setState,扩展支持 GroupFormExtraState 中的字段(navAnchorProps、groupSchema
|
|
74
|
+
* @description 覆盖基类 setState,扩展支持 GroupFormExtraState 中的字段(navAnchorProps、groupSchema 等)。
|
|
75
75
|
* @param {Partial<GroupFormState> | ((prev: GroupFormState) => Partial<GroupFormState>)} stateOrFn - 新状态或更新函数
|
|
76
76
|
*/
|
|
77
77
|
setState(stateOrFn: ((prev: GroupFormState) => Partial<GroupFormState>) | Partial<GroupFormState>): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { GroupFormApi } from './groupFormApi';
|
|
2
2
|
export { useGroupForm } from './useGroupForm';
|
|
3
|
-
export type { FormGroupSchema, FormRowSchema, GroupFormApiOptions, GroupFormNavAnchorProps, GroupFormSchema, UseGroupFormNavAnchorProps, UseGroupFormOptions, } from './types';
|
|
4
|
-
export { isGroupSchema, isRowSchema, isSlotSchema,
|
|
3
|
+
export type { FormGroupSchema, FormRowSchema, GroupFormApiOptions, GroupFormNavAnchorProps, GroupFormSchema, UseGroupFormNavAnchorProps, UseGroupFormOptions, UseGroupFormOptionsWithGroupSchema, UseGroupFormOptionsWithLegacySchema, } from './types';
|
|
4
|
+
export { extractFlatSchemas, isGroupSchema, isRowSchema, isSlotSchema, resolveGroupSchema } from './utils';
|
|
@@ -62,9 +62,8 @@ export type UseGroupFormNavAnchorProps = Omit<NavAnchorPropsBase, "badgeCounts">
|
|
|
62
62
|
* VirtualGroupForm 组件接收的导航配置;`badgeCounts` 由组件内合并 `navErrorCounts` 与 `extraBadgeCounts` 注入。
|
|
63
63
|
*/
|
|
64
64
|
export type GroupFormNavAnchorProps = UseGroupFormNavAnchorProps;
|
|
65
|
-
/**
|
|
66
|
-
export
|
|
67
|
-
schema: GroupFormSchema[];
|
|
65
|
+
/** useGroupForm 除分组 schema 外的公共选项 */
|
|
66
|
+
export type UseGroupFormOptionsCommon = Omit<TtFormProps, "schema" | "showDefaultActions"> & {
|
|
68
67
|
/** 是否启用虚拟化,默认 true */
|
|
69
68
|
virtual?: boolean;
|
|
70
69
|
/** 滚动容器高度,默认 '100%' */
|
|
@@ -80,9 +79,27 @@ export interface UseGroupFormOptions extends Omit<TtFormProps, "schema" | "showD
|
|
|
80
79
|
navAnchorProps?: UseGroupFormNavAnchorProps;
|
|
81
80
|
/** 滚动到分组时的顶部偏移量(px),用于补偿页面顶部固定元素(如 header)的遮挡,默认 0 */
|
|
82
81
|
scrollOffset?: number;
|
|
82
|
+
};
|
|
83
|
+
/** 推荐:使用 groupSchema 传入分组树 */
|
|
84
|
+
export interface UseGroupFormOptionsWithGroupSchema extends UseGroupFormOptionsCommon {
|
|
85
|
+
/** 分组 schema 树形结构 */
|
|
86
|
+
groupSchema: GroupFormSchema[];
|
|
83
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* @description 已废弃的分组表单入参(兼容旧代码)
|
|
90
|
+
* @deprecated 请改用 {@link UseGroupFormOptionsWithGroupSchema},通过 `groupSchema` 传入分组树
|
|
91
|
+
*/
|
|
92
|
+
export interface UseGroupFormOptionsWithLegacySchema extends UseGroupFormOptionsCommon {
|
|
93
|
+
/**
|
|
94
|
+
* 分组 schema 树形结构
|
|
95
|
+
* @deprecated 请使用 `groupSchema` 替代
|
|
96
|
+
*/
|
|
97
|
+
schema: GroupFormSchema[];
|
|
98
|
+
}
|
|
99
|
+
/** groupSchema 与 schema 二选一(至少传一个) */
|
|
100
|
+
export type UseGroupFormOptions = UseGroupFormOptionsWithGroupSchema | UseGroupFormOptionsWithLegacySchema;
|
|
84
101
|
export type GroupFormExtraState = Partial<Pick<UseGroupFormOptions, "virtual" | "navAnchorProps" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "scrollOffset">> & {
|
|
85
|
-
/** 分组 schema
|
|
102
|
+
/** 分组 schema 树形结构(store 状态,由 GroupFormApi.setState 维护) */
|
|
86
103
|
groupSchema?: GroupFormSchema[];
|
|
87
104
|
};
|
|
88
105
|
/** 分组表单完整 store 状态类型 */
|
|
@@ -144,10 +161,10 @@ export interface GroupSectionProps {
|
|
|
144
161
|
}
|
|
145
162
|
/**
|
|
146
163
|
* @description GroupFormApi 构造函数的分组配置选项,复用 UseGroupFormOptions 中同名字段的类型定义,
|
|
147
|
-
* 额外增加 `groupSchema`(由 useGroupForm
|
|
164
|
+
* 额外增加 `groupSchema`(由 useGroupForm 传入)。
|
|
148
165
|
*/
|
|
149
166
|
export type GroupFormApiOptions = Pick<UseGroupFormOptions, "virtual" | "navAnchorProps" | "scrollToFirstError" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "scrollOffset"> & {
|
|
150
|
-
/** 分组 schema 树形结构(由 useGroupForm
|
|
167
|
+
/** 分组 schema 树形结构(由 useGroupForm 传入) */
|
|
151
168
|
groupSchema: GroupFormSchema[];
|
|
152
169
|
};
|
|
153
170
|
export {};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { DefineComponent } from 'vue';
|
|
2
2
|
import { GroupFormApi } from './groupFormApi';
|
|
3
|
-
import { UseGroupFormOptions } from './types';
|
|
3
|
+
import { UseGroupFormOptions, UseGroupFormOptionsCommon, UseGroupFormOptionsWithLegacySchema } from './types';
|
|
4
|
+
type GroupFormOverrideProps = Partial<UseGroupFormOptionsCommon>;
|
|
5
|
+
type UseGroupFormReturn = readonly [DefineComponent<GroupFormOverrideProps>, GroupFormApi];
|
|
4
6
|
/**
|
|
5
7
|
* @description 返回可渲染的包装组件、扩展后的表单 API,以及分组折叠状态对象。
|
|
6
8
|
*/
|
|
7
|
-
export declare function useGroupForm(options: UseGroupFormOptions):
|
|
9
|
+
export declare function useGroupForm(options: UseGroupFormOptions): UseGroupFormReturn;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated 请改用 `groupSchema` 传入分组树
|
|
12
|
+
*/
|
|
13
|
+
export declare function useGroupForm(options: UseGroupFormOptionsWithLegacySchema): UseGroupFormReturn;
|
|
14
|
+
export {};
|
|
@@ -42,6 +42,15 @@ export declare function getSchemaKey(schema: GroupFormSchema, idx: number): stri
|
|
|
42
42
|
* ]);
|
|
43
43
|
* // 返回: [{ fieldName: 'name' }, { fieldName: 'age' }]
|
|
44
44
|
*/
|
|
45
|
+
export type GroupSchemaSourceOptions = {
|
|
46
|
+
groupSchema?: GroupFormSchema[];
|
|
47
|
+
/** @deprecated 请使用 groupSchema */
|
|
48
|
+
schema?: GroupFormSchema[];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @description 解析分组 schema:优先 `groupSchema`,兼容已废弃的 `schema`
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveGroupSchema(options: GroupSchemaSourceOptions): GroupFormSchema[];
|
|
45
54
|
export declare function extractFlatSchemas(schemas: GroupFormSchema[]): FormSchema[];
|
|
46
55
|
/**
|
|
47
56
|
* 递归收集分组 schema 中 defaultCollapsed 为 true 的分组 key,写入 states
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { MaybeRefOrGetter
|
|
2
|
-
import { FieldArrayContext
|
|
1
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { FieldArrayContext } from '../types/forms';
|
|
3
3
|
/**
|
|
4
4
|
* 与 vee-validate `useFieldArray` API 对齐:稳定 `key`、`entry.value` 可写(支持 v-model),
|
|
5
5
|
* 外部 `resetForm` / `setValues` 时同步行列表;不使用官方 `computedDeep` 与易递归的深拷贝双向 watch。
|
|
6
6
|
*/
|
|
7
|
-
export declare function useFieldArray<TValue extends Record<string, unknown> = Record<string, unknown>>(arrayPath: MaybeRefOrGetter<string>):
|
|
8
|
-
fields: Ref<FieldEntry<TValue>[]>;
|
|
9
|
-
};
|
|
7
|
+
export declare function useFieldArray<TValue extends Record<string, unknown> = Record<string, unknown>>(arrayPath: MaybeRefOrGetter<string>): FieldArrayContext<TValue>;
|
|
@@ -94,7 +94,7 @@ export type FieldEntry<TValue = Recordable> = {
|
|
|
94
94
|
isLast: boolean;
|
|
95
95
|
};
|
|
96
96
|
export type FieldArrayContext<TValue = Recordable> = {
|
|
97
|
-
fields: FieldEntry<TValue>[]
|
|
97
|
+
fields: Ref<FieldEntry<TValue>[]>;
|
|
98
98
|
remove: (idx: number) => void;
|
|
99
99
|
replace: (newArray: TValue[]) => void;
|
|
100
100
|
update: (idx: number, value: TValue) => void;
|