@dazhicheng/ui 1.5.156 → 1.5.159
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 +4 -2
- package/dist/components/tt-form/src/form-render/FormArrayRegister.d.ts +14 -3
- package/dist/components/tt-form/src/formApi.d.ts +25 -11
- package/dist/components/tt-form/src/group-form/groupFormApi.d.ts +1 -1
- package/dist/components/tt-form/src/hooks/useArrayRegistry.d.ts +2 -2
- package/dist/components/tt-form/src/hooks/useFieldArray.d.ts +2 -2
- package/dist/components/tt-form/src/index.vue.d.ts +4 -4
- package/dist/components/tt-form/src/types/forms.d.ts +17 -20
- package/dist/components/tt-form/src/types.d.ts +30 -6
- package/dist/components/tt-form/src/useFormContext.d.ts +9 -0
- package/dist/components/tt-form/src/utils/array-path.d.ts +11 -1
- package/dist/index.js +7617 -7528
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseFormComponentType, ExtendedFormApi, FormRenderProps, FormSchema, TtFormProps } from './src/types';
|
|
3
3
|
import { COMPONENT_MAP } from './src/config';
|
|
4
4
|
import { useForm } from './src/useForm';
|
|
5
5
|
declare function setConfig(rules?: Record<string, (value: any, params: any, ctx: Record<string, any>) => boolean | string>, modelPropNameMap?: Partial<Record<BaseFormComponentType, string>>): void;
|
|
@@ -9,7 +9,9 @@ export { COMPONENT_MAP, useForm };
|
|
|
9
9
|
type TtFormSchema = FormSchema<BaseFormComponentType>;
|
|
10
10
|
type TtFormRenderProps = FormRenderProps<BaseFormComponentType>;
|
|
11
11
|
type TtExtendedFormApi = ExtendedFormApi;
|
|
12
|
-
export type { BaseFormComponentMap, BaseFormComponentType, FormSlotSchema, InferredComponentPropsType,
|
|
12
|
+
export type { ArraySchemaContext, BaseFormComponentMap, BaseFormComponentType, FormArrayActions, FormSlotSchema, InferredComponentPropsType, NestedArrayHandle, } from './src/types';
|
|
13
|
+
export type { FieldArrayContext, FieldEntry, ResolvedFieldArrayContext } from './src/types/forms';
|
|
14
|
+
export type { TtExtendedFormApi, TtFormProps, TtFormRenderProps, TtFormSchema };
|
|
13
15
|
export * as z from 'zod';
|
|
14
16
|
export { useGroupForm } from './src/group-form';
|
|
15
17
|
export type { FormGroupSchema, GroupFormNavAnchorProps, GroupFormSchema, UseGroupFormNavAnchorProps, UseGroupFormOptions, UseGroupFormOptionsWithGroupSchema, UseGroupFormOptionsWithLegacySchema, } from './src/group-form';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PropType } from 'vue';
|
|
2
2
|
import { Recordable } from '../../../../../../utils/src';
|
|
3
3
|
import { FieldEntry } from '../types/forms';
|
|
4
|
-
import { FormSchema } from '../types';
|
|
5
|
-
type ArraySchemaProp = FormSchema[] | ((entry: FieldEntry<Recordable>, currentIndex: number) => FormSchema[]);
|
|
4
|
+
import { ArraySchemaContext, FormSchema } from '../types';
|
|
5
|
+
type ArraySchemaProp = FormSchema[] | ((entry: FieldEntry<Recordable>, currentIndex: number, ctx?: ArraySchemaContext) => FormSchema[]);
|
|
6
6
|
declare const FormArrayRegister: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
7
7
|
fieldName: {
|
|
8
8
|
type: PropType<string>;
|
|
@@ -24,9 +24,14 @@ declare const FormArrayRegister: import('vue').DefineComponent<import('vue').Ext
|
|
|
24
24
|
type: BooleanConstructor;
|
|
25
25
|
default: boolean;
|
|
26
26
|
};
|
|
27
|
+
/** useArraySchema 时:每一行数组项的外层容器 class(边框、间距等) */
|
|
28
|
+
wrapperClass: {
|
|
29
|
+
type: PropType<NonNullable<FormSchema["wrapperClass"]>>;
|
|
30
|
+
default: undefined;
|
|
31
|
+
};
|
|
27
32
|
}>, () => (import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
28
33
|
[key: string]: any;
|
|
29
|
-
}>[] | undefined)[], {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
34
|
+
}>[] | import("vue/jsx-runtime").JSX.Element | undefined)[], {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
30
35
|
fieldName: {
|
|
31
36
|
type: PropType<string>;
|
|
32
37
|
required: true;
|
|
@@ -47,7 +52,13 @@ declare const FormArrayRegister: import('vue').DefineComponent<import('vue').Ext
|
|
|
47
52
|
type: BooleanConstructor;
|
|
48
53
|
default: boolean;
|
|
49
54
|
};
|
|
55
|
+
/** useArraySchema 时:每一行数组项的外层容器 class(边框、间距等) */
|
|
56
|
+
wrapperClass: {
|
|
57
|
+
type: PropType<NonNullable<FormSchema["wrapperClass"]>>;
|
|
58
|
+
default: undefined;
|
|
59
|
+
};
|
|
50
60
|
}>> & Readonly<{}>, {
|
|
61
|
+
wrapperClass: string;
|
|
51
62
|
rules: import('../types').FormSchemaRuleType | undefined;
|
|
52
63
|
arraySchema: ArraySchemaProp;
|
|
53
64
|
formItemClass: NonNullable<string | (() => string) | undefined>;
|
|
@@ -2,10 +2,10 @@ import { FormState, GenericObject, ResetFormOpts, ValidationOptions } from 'vee-
|
|
|
2
2
|
import { ComponentPublicInstance } from 'vue';
|
|
3
3
|
import { Recordable, StateHandler } from '../../../../../utils/src';
|
|
4
4
|
import { FormActions, FormArrayActions, FormSchema, NestedArrayHandle, TtFormProps } from './types';
|
|
5
|
-
import { FieldArrayContext } from './types/forms';
|
|
5
|
+
import { FieldArrayContext, ResolvedFieldArrayContext } from './types/forms';
|
|
6
6
|
import { Store } from './shared/store';
|
|
7
7
|
export type { ArrayPathSegment } from './utils/array-path';
|
|
8
|
-
export { buildArrayFieldPath } from './utils/array-path';
|
|
8
|
+
export { buildArrayFieldPath, collectArrayFieldPathAliases, normalizeArrayFieldPath } from './utils/array-path';
|
|
9
9
|
export declare class FormApi {
|
|
10
10
|
form: FormActions;
|
|
11
11
|
isMounted: boolean;
|
|
@@ -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 数组
|
|
@@ -143,7 +147,7 @@ export declare class FormApi {
|
|
|
143
147
|
* @param name 需要注册的数组字段
|
|
144
148
|
* @param actions 操作方法
|
|
145
149
|
*/
|
|
146
|
-
registerArrayField(name: string, actions:
|
|
150
|
+
registerArrayField(name: string, actions: ResolvedFieldArrayContext): void;
|
|
147
151
|
unregisterArrayField(name: string): void;
|
|
148
152
|
/** @description 数组字段操作集合 */
|
|
149
153
|
get arrayAction(): {
|
|
@@ -158,27 +162,27 @@ export declare class FormApi {
|
|
|
158
162
|
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
159
163
|
* @param value 要追加的数组项值
|
|
160
164
|
*/
|
|
161
|
-
push: <TValue = unknown>(name: string, value: TValue) => void
|
|
165
|
+
push: <TValue = unknown>(name: string, value: TValue) => void;
|
|
162
166
|
/**
|
|
163
167
|
* @description 删除指定索引的项
|
|
164
168
|
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
165
169
|
* @param idx 要删除的索引位置
|
|
166
170
|
*/
|
|
167
|
-
remove: (name: string, idx: number) => void
|
|
171
|
+
remove: (name: string, idx: number) => void;
|
|
168
172
|
/**
|
|
169
173
|
* @description 整体替换数组值
|
|
170
174
|
* @template TValue 数组项类型
|
|
171
175
|
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
172
176
|
* @param values 新的完整数组字段
|
|
173
177
|
*/
|
|
174
|
-
replace: <TValue = unknown>(name: string, values: TValue[]) => void
|
|
178
|
+
replace: <TValue = unknown>(name: string, values: TValue[]) => void;
|
|
175
179
|
/**
|
|
176
180
|
* @description更新指定索引的项
|
|
177
181
|
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
178
182
|
* @param idx 要更新的索引位置
|
|
179
183
|
* @param value 更新后的数组项值
|
|
180
184
|
*/
|
|
181
|
-
update: <TValue = unknown>(name: string, idx: number, value: TValue) => void
|
|
185
|
+
update: <TValue = unknown>(name: string, idx: number, value: TValue) => void;
|
|
182
186
|
/**
|
|
183
187
|
* @description 在指定索引插入一项
|
|
184
188
|
* @template TValue 数组项类型
|
|
@@ -186,28 +190,28 @@ export declare class FormApi {
|
|
|
186
190
|
* @param idx 插入位置索引
|
|
187
191
|
* @param value 要插入的数组项值
|
|
188
192
|
*/
|
|
189
|
-
insert: <TValue = unknown>(name: string, idx: number, value: TValue) => void
|
|
193
|
+
insert: <TValue = unknown>(name: string, idx: number, value: TValue) => void;
|
|
190
194
|
/**
|
|
191
195
|
* @description 在数组头部新增一项
|
|
192
196
|
* @template TValue 数组项类型
|
|
193
197
|
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
194
198
|
* @param value 要插入到头部的数组项值
|
|
195
199
|
*/
|
|
196
|
-
prepend: <TValue = unknown>(name: string, value: TValue) => void
|
|
200
|
+
prepend: <TValue = unknown>(name: string, value: TValue) => void;
|
|
197
201
|
/**
|
|
198
202
|
* @description 将项从旧索引移动到新索引
|
|
199
203
|
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
200
204
|
* @param oldIdx 原索引位置
|
|
201
205
|
* @param newIdx 新索引位置
|
|
202
206
|
*/
|
|
203
|
-
move: (name: string, oldIdx: number, newIdx: number) => void
|
|
207
|
+
move: (name: string, oldIdx: number, newIdx: number) => void;
|
|
204
208
|
/**
|
|
205
209
|
* @description 交换两个索引位置的项
|
|
206
210
|
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
207
211
|
* @param indexA 第一个索引位置
|
|
208
212
|
* @param indexB 第二个索引位置
|
|
209
213
|
*/
|
|
210
|
-
swap: (name: string, indexA: number, indexB: number) => void
|
|
214
|
+
swap: (name: string, indexA: number, indexB: number) => void;
|
|
211
215
|
/**
|
|
212
216
|
* @description 获取嵌套数组路径下的操作器
|
|
213
217
|
* @param parentPath 父数组路径(如 actions.data),或完整路径(仅传 path)
|
|
@@ -216,7 +220,17 @@ export declare class FormApi {
|
|
|
216
220
|
*/
|
|
217
221
|
at: FormArrayActions["at"];
|
|
218
222
|
};
|
|
223
|
+
/**
|
|
224
|
+
* @description 将业务传入路径规范化为数组注册表键
|
|
225
|
+
*/
|
|
226
|
+
protected _resolveArrayFieldPath(name: string): string;
|
|
227
|
+
private _getRegisteredArrayField;
|
|
219
228
|
private _getArrayFieldActions;
|
|
229
|
+
/**
|
|
230
|
+
* @description 开发环境:数组字段未注册时输出告警与相近路径提示
|
|
231
|
+
*/
|
|
232
|
+
private _warnUnregisteredArrayField;
|
|
233
|
+
private _mutateArrayField;
|
|
220
234
|
/**
|
|
221
235
|
* @description 创建嵌套数组操作器(在原 inline 实现基础上支持链式 `.at`)
|
|
222
236
|
*/
|
|
@@ -271,7 +271,7 @@ export declare class GroupFormApi extends FormApi {
|
|
|
271
271
|
* @description 卸载分组表单时恢复初始schema
|
|
272
272
|
*/
|
|
273
273
|
get arrayAction(): {
|
|
274
|
-
get: <TValue = unknown>(name: string) => Readonly<import('
|
|
274
|
+
get: <TValue = unknown>(name: string) => Readonly<import('../..').FieldArrayContext<TValue>> | undefined;
|
|
275
275
|
push: <TValue = unknown>(name: string, value: TValue) => void;
|
|
276
276
|
remove: (name: string, idx: number) => void;
|
|
277
277
|
replace: <TValue = unknown>(name: string, values: TValue[]) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function useArrayRegistry(name: string): readonly [(actions?:
|
|
1
|
+
import { ResolvedFieldArrayContext } from '../types/forms';
|
|
2
|
+
export declare function useArrayRegistry(name: string): readonly [(actions?: ResolvedFieldArrayContext) => void, () => void];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedFieldArrayContext } 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>):
|
|
7
|
+
export declare function useFieldArray<TValue extends Record<string, unknown> = Record<string, unknown>>(arrayPath: MaybeRefOrGetter<string>): ResolvedFieldArrayContext<TValue>;
|
|
@@ -26,9 +26,9 @@ declare function __VLS_template(): {
|
|
|
26
26
|
readonly componentBindEventMap?: Partial<Record<import('./types').BaseFormComponentType, string>> | undefined;
|
|
27
27
|
readonly componentMap: Record<import('./types').BaseFormComponentType, import('vue').Component>;
|
|
28
28
|
readonly fieldMappingTime?: import('./types').FieldMappingTime | undefined;
|
|
29
|
-
readonly form?: import('
|
|
29
|
+
readonly form?: import('./types').FormActions | undefined;
|
|
30
30
|
readonly layout?: import('./types').FormLayout | undefined;
|
|
31
|
-
readonly schema?: (import('./types').
|
|
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;
|
|
@@ -113,9 +113,9 @@ declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {},
|
|
|
113
113
|
readonly componentBindEventMap?: Partial<Record<import('./types').BaseFormComponentType, string>> | undefined;
|
|
114
114
|
readonly componentMap: Record<import('./types').BaseFormComponentType, import('vue').Component>;
|
|
115
115
|
readonly fieldMappingTime?: import('./types').FieldMappingTime | undefined;
|
|
116
|
-
readonly form?: import('
|
|
116
|
+
readonly form?: import('./types').FormActions | undefined;
|
|
117
117
|
readonly layout?: import('./types').FormLayout | undefined;
|
|
118
|
-
readonly schema?: (import('./types').
|
|
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;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
import { PartialDeep } from 'type-fest';
|
|
3
|
-
import { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref } from 'vue';
|
|
3
|
+
import { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref, UnwrapRef } from 'vue';
|
|
4
4
|
import { FlattenAndSetPathsType, GenericObject, MapValuesPathsToRefs, MaybeArray, MaybePromise } from './common';
|
|
5
5
|
import { Path, PathValue } from './paths';
|
|
6
6
|
import { FieldValidationMetaInfo } from './shared';
|
|
7
|
-
import {
|
|
7
|
+
import { FieldArrayContext as VeeFieldArrayContext, FieldEntry } from 'vee-validate';
|
|
8
8
|
export type ValidationResult<TValue = unknown> = {
|
|
9
9
|
errors: string[];
|
|
10
10
|
valid: boolean;
|
|
@@ -87,27 +87,25 @@ export type PathState<TInput = unknown, TOutput = TInput> = {
|
|
|
87
87
|
};
|
|
88
88
|
validate?: FieldValidator<TOutput>;
|
|
89
89
|
};
|
|
90
|
-
export type FieldEntry
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
replace: (newArray: TValue[]) => void;
|
|
100
|
-
update: (idx: number, value: TValue) => void;
|
|
101
|
-
push: (value: TValue) => void;
|
|
102
|
-
swap: (indexA: number, indexB: number) => void;
|
|
103
|
-
insert: (idx: number, value: TValue) => void;
|
|
104
|
-
prepend: (value: TValue) => void;
|
|
105
|
-
move: (oldIdx: number, newIdx: number) => void;
|
|
90
|
+
export type { FieldEntry };
|
|
91
|
+
/** vee-validate 原始数组上下文(`fields` 为 Ref,用于 `useFieldArray` / 注册表) */
|
|
92
|
+
export type ResolvedFieldArrayContext<TValue = unknown> = VeeFieldArrayContext<TValue>;
|
|
93
|
+
/**
|
|
94
|
+
* 经 FormApi `reactive(Map)` 读取时的数组上下文。
|
|
95
|
+
* `fields` 在运行时由 Vue reactive 自动解包,用法与 vee-validate `<FieldArray>` 插槽一致(`fields.length` / `v-for`)。
|
|
96
|
+
*/
|
|
97
|
+
export type FieldArrayContext<TValue = unknown> = Omit<ResolvedFieldArrayContext<TValue>, "fields"> & {
|
|
98
|
+
fields: UnwrapRef<ResolvedFieldArrayContext<TValue>["fields"]>;
|
|
106
99
|
};
|
|
100
|
+
/**
|
|
101
|
+
* 将注册表中的 `ResolvedFieldArrayContext` 转为对外 `FieldArrayContext`。
|
|
102
|
+
* 注册表为 `reactive(Map)`,运行时 `fields` 已自动解包,需经 `unknown` 断言以匹配类型。
|
|
103
|
+
*/
|
|
104
|
+
export declare function asFieldArrayContext<TValue = unknown>(ctx: ResolvedFieldArrayContext): Readonly<FieldArrayContext<TValue>>;
|
|
107
105
|
export type PrivateFieldArrayContext<TValue = unknown> = {
|
|
108
106
|
reset: () => void;
|
|
109
107
|
path: MaybeRefOrGetter<string>;
|
|
110
|
-
} &
|
|
108
|
+
} & ResolvedFieldArrayContext<TValue>;
|
|
111
109
|
export type PrivateFieldContext<TInput = unknown, TOutput = TInput> = {
|
|
112
110
|
id: number;
|
|
113
111
|
name: MaybeRef<string>;
|
|
@@ -278,4 +276,3 @@ export interface FormContext<TValues extends GenericObject = GenericObject, TOut
|
|
|
278
276
|
handleReset: () => void;
|
|
279
277
|
submitForm: (e?: unknown) => Promise<void>;
|
|
280
278
|
}
|
|
281
|
-
export {};
|
|
@@ -99,7 +99,26 @@ export type NestedArrayHandle<TValue = unknown> = {
|
|
|
99
99
|
at: (index: number, childField: string) => NestedArrayHandle<TValue>;
|
|
100
100
|
};
|
|
101
101
|
export type { ArrayPathSegment } from './utils/array-path';
|
|
102
|
-
export { buildArrayFieldPath } from './utils/array-path';
|
|
102
|
+
export { buildArrayFieldPath, collectArrayFieldPathAliases, normalizeArrayFieldPath } from './utils/array-path';
|
|
103
|
+
/**
|
|
104
|
+
* `useArraySchema` 的 `arraySchema` 回调第三参数:当前数组上下文
|
|
105
|
+
*/
|
|
106
|
+
export interface ArraySchemaContext {
|
|
107
|
+
/** 当前数组字段完整路径(已规范化,与 arrayAction 注册键一致) */
|
|
108
|
+
arrayPath: string;
|
|
109
|
+
/** 当前行路径,如 `feeTickets[0]` */
|
|
110
|
+
itemPath: string;
|
|
111
|
+
/** 当前行索引 */
|
|
112
|
+
index: number;
|
|
113
|
+
/** 当前行 entry */
|
|
114
|
+
entry: FieldEntry<Recordable>;
|
|
115
|
+
/** 表单 arrayAction API */
|
|
116
|
+
arrayAction?: FormArrayActions;
|
|
117
|
+
/** 绑定 {@link arrayPath} 的操作器,可直接 `.push()` / `.remove()` */
|
|
118
|
+
arrayHandle?: NestedArrayHandle;
|
|
119
|
+
/** 表单值代理) */
|
|
120
|
+
form?: Record<string, unknown>;
|
|
121
|
+
}
|
|
103
122
|
export type FormActions = FormContext<GenericObject> & {
|
|
104
123
|
arrayAction?: FormArrayActions;
|
|
105
124
|
};
|
|
@@ -272,8 +291,11 @@ export interface FormSchema<T extends BaseFormComponentType = BaseFormComponentT
|
|
|
272
291
|
* @description 支持直接传入配置数组 或 动态函数生成
|
|
273
292
|
* @example arraySchema: []
|
|
274
293
|
* @example arraySchema: (entry, index) => []
|
|
294
|
+
* @example arraySchema: (entry, index, ctx) => { ctx.arrayHandle?.push({}); return []; }
|
|
275
295
|
*/
|
|
276
|
-
arraySchema?: FormSchema[] | ((entry: FieldEntry<Recordable>, currentIndex: number
|
|
296
|
+
arraySchema?: FormSchema[] | ((entry: FieldEntry<Recordable>, currentIndex: number,
|
|
297
|
+
/** 第三参数由 FormArrayRegister 注入;旧写法可忽略 */
|
|
298
|
+
ctx: ArraySchemaContext) => FormSchema[]);
|
|
277
299
|
}
|
|
278
300
|
/** 插槽 scope 参数,传递给渲染函数或具名插槽 */
|
|
279
301
|
export interface FormSlotScope {
|
|
@@ -286,8 +308,10 @@ export interface FormSlotScope {
|
|
|
286
308
|
* Extra slot props exposed for `useArraySchema: true` fields.
|
|
287
309
|
*/
|
|
288
310
|
export interface FormArraySlotScope extends FormSlotScope {
|
|
289
|
-
arrayEntry?:
|
|
290
|
-
arrayAction?:
|
|
311
|
+
arrayEntry?: FieldEntry<Recordable>;
|
|
312
|
+
arrayAction?: FormArrayActions;
|
|
313
|
+
arrayHandle?: NestedArrayHandle;
|
|
314
|
+
arrayPath?: string;
|
|
291
315
|
arrayIndex?: number;
|
|
292
316
|
fieldName?: string;
|
|
293
317
|
}
|
|
@@ -356,9 +380,9 @@ export interface FormRenderProps<T extends BaseFormComponentType = BaseFormCompo
|
|
|
356
380
|
*/
|
|
357
381
|
fieldMappingTime?: FieldMappingTime;
|
|
358
382
|
/**
|
|
359
|
-
*
|
|
383
|
+
* 表单实例(vee-validate FormContext;数组操作请使用 injectFormProps 中的 formApi.arrayAction)
|
|
360
384
|
*/
|
|
361
|
-
form?:
|
|
385
|
+
form?: FormActions;
|
|
362
386
|
/**
|
|
363
387
|
* 表单项布局
|
|
364
388
|
*/
|
|
@@ -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>>;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
/** 一层嵌套:父路径 + 行索引 + 子字段名 */
|
|
2
2
|
export type ArrayPathSegment = readonly [index: number, field: string];
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 规范化为数组字段注册键:将标识符后的 `.[数字]` 折叠为 `[数字]`。
|
|
5
|
+
* 与 {@link FormArrayRegister} 中 `fieldName[index]` 的拼接方式对齐。
|
|
6
|
+
* @example normalizeArrayFieldPath('feeTickets.[0].feeDetails') => 'feeTickets[0].feeDetails'
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeArrayFieldPath(path: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* 生成同一数组字段的等价路径别名(注册 / 查找时共用)
|
|
11
|
+
*/
|
|
12
|
+
export declare function collectArrayFieldPathAliases(path: string): string[];
|
|
13
|
+
/**
|
|
14
|
+
* 拼接数组子路径;仅传 parentPath 时原样返回(完整路径,会规范化)
|
|
5
15
|
* @returns 如 `actions.data[0].skills`
|
|
6
16
|
*/
|
|
7
17
|
export declare function childArrayPath(parentPath: string, index?: number, childField?: string): string;
|