@dazhicheng/ui 1.5.155 → 1.5.158

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.
@@ -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';
@@ -40,6 +40,10 @@ export declare class FormApi {
40
40
  isFieldValid(fieldName: string): Promise<boolean>;
41
41
  merge(formApi: FormApi): any;
42
42
  mount(formActions: FormActions, componentRefMap: Map<string, unknown>): void;
43
+ /**
44
+ * @description 为 appendFields 新增的字段写入初始值(与 useFormInitial 规则一致,不覆盖已有数据)
45
+ */
46
+ protected seedDefaultsForAppendedFields(fields: FormSchema[]): Promise<void>;
43
47
  /**
44
48
  * @description 增量追加字段到 schema 中,支持通过 position 指定插入位置
45
49
  * @param {FormSchema[]} fields - 要插入的字段 schema 数组
@@ -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, extractFlatSchemas } from './utils';
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 interface UseGroupFormOptions extends Omit<TtFormProps, "schema" | "showDefaultActions"> {
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 从 `schema` 转换而来)。
164
+ * 额外增加 `groupSchema`(由 useGroupForm 传入)。
148
165
  */
149
166
  export type GroupFormApiOptions = Pick<UseGroupFormOptions, "virtual" | "navAnchorProps" | "scrollToFirstError" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "scrollOffset"> & {
150
- /** 分组 schema 树形结构(由 useGroupForm 从 options.schema 传入) */
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): readonly [DefineComponent<Partial<Omit<UseGroupFormOptions, "schema">>>, GroupFormApi];
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, Ref } from 'vue';
2
- import { FieldArrayContext, FieldEntry } from '../types/forms';
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>): Omit<FieldArrayContext<TValue>, "fields"> & {
8
- fields: Ref<FieldEntry<TValue>[]>;
9
- };
7
+ export declare function useFieldArray<TValue extends Record<string, unknown> = Record<string, unknown>>(arrayPath: MaybeRefOrGetter<string>): FieldArrayContext<TValue>;
@@ -28,7 +28,7 @@ declare function __VLS_template(): {
28
28
  readonly fieldMappingTime?: import('./types').FieldMappingTime | undefined;
29
29
  readonly form?: import('vee-validate').FormContext<import('vee-validate').GenericObject> | undefined;
30
30
  readonly layout?: import('./types').FormLayout | undefined;
31
- readonly schema?: (import('./types').FormSlotSchema | FormSchema<keyof import('./types').BaseFormComponentMap>)[] | undefined;
31
+ readonly schema?: (FormSchema<keyof import('./types').BaseFormComponentMap> | import('./types').FormSlotSchema)[] | 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('vee-validate').FormContext<import('vee-validate').GenericObject> | undefined;
117
117
  readonly layout?: import('./types').FormLayout | undefined;
118
- readonly schema?: (import('./types').FormSlotSchema | FormSchema<keyof import('./types').BaseFormComponentMap>)[] | undefined;
118
+ readonly schema?: (FormSchema<keyof import('./types').BaseFormComponentMap> | import('./types').FormSlotSchema)[] | undefined;
119
119
  readonly showCollapseButton?: boolean | undefined;
120
120
  readonly wrapperClass?: import('./types').WrapperClassType | undefined;
121
121
  readonly globalCommonConfig?: import('./types').FormCommonConfig | undefined;
@@ -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;
@@ -364,7 +364,7 @@ export interface FormRenderProps<T extends BaseFormComponentType = BaseFormCompo
364
364
  */
365
365
  layout?: FormLayout;
366
366
  /**
367
- * 表单定义,支持普通字段和自定义插槽混合
367
+ * 表单定义,支持普通字段
368
368
  */
369
369
  schema?: (FormSchema<T> | FormSlotSchema)[];
370
370
  /**
@@ -3,6 +3,7 @@ import { FormSchema, ExtendedFormApi, FormActions, TtFormProps } from './types';
3
3
  type ExtendFormProps = TtFormProps & {
4
4
  formApi?: ExtendedFormApi;
5
5
  };
6
+ export declare function isFormSchema(schema: unknown): schema is FormSchema;
6
7
  export declare const injectFormProps: <T extends [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions] | null | undefined = [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions]>(fallback?: T | undefined) => T extends null ? [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions] | null : [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions], provideFormProps: (contextValue: [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions]) => [ExtendFormProps | ComputedRef<ExtendFormProps>, FormActions];
7
8
  export declare const injectComponentRefMap: <T extends Map<string, unknown> | null | undefined = Map<string, unknown>>(fallback?: T | undefined) => T extends null ? Map<string, unknown> | null : Map<string, unknown>, provideComponentRefMap: (contextValue: Map<string, unknown>) => Map<string, unknown>;
8
9
  /** 提取单个字段默认值:defaultValue 优先,其次 Zod rules */
@@ -15,6 +16,14 @@ export declare function resolveSchemaItemDefaultValue(item: FormSchema): unknown
15
16
  * - 父行合并后会对嵌套数组递归补全(空嵌套数组、部分行缺字段)
16
17
  */
17
18
  export declare function resolveArrayFieldInitialValue(item: FormSchema): unknown;
19
+ /**
20
+ * @description 解析单个字段的初始值(与 useFormInitial.generateInitialValues 单字段逻辑一致)
21
+ */
22
+ export declare function resolveSchemaFieldInitialValue(item: FormSchema): unknown | undefined;
23
+ /**
24
+ * @description appendFields 时判断是否需要为新字段写入初始值(不覆盖已有非空数据)
25
+ */
26
+ export declare function shouldSeedAppendedFieldValue(values: Record<string, unknown>, item: FormSchema): boolean;
18
27
  export declare function useFormInitial(props: ComputedRef<TtFormProps> | TtFormProps): {
19
28
  delegatedSlots: ComputedRef<string[]>;
20
29
  form: import('vee-validate').FormContext<Record<string, unknown>, Record<string, unknown>>;