@dazhicheng/ui 1.6.18 → 1.6.20
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 +2 -2
- package/dist/components/tt-form/src/formApi.d.ts +11 -2
- package/dist/components/tt-form/src/group-form/LazyFormField.vue.js +162 -114
- package/dist/components/tt-form/src/group-form/groupFormApi.js +8 -14
- package/dist/components/tt-form/src/group-form/lazyContext.d.ts +18 -0
- package/dist/components/tt-form/src/group-form/lazyContext.js +64 -36
- package/dist/components/tt-form/src/group-form/types.d.ts +39 -6
- package/dist/components/tt-form/src/group-form/useGroupForm.d.ts +7 -5
- package/dist/components/tt-form/src/types.d.ts +58 -26
- package/dist/components/tt-form/src/useForm.d.ts +1 -1
- package/dist/components/tt-form/src/useForm.js +5 -5
- package/dist/components/tt-modal-form/props.d.ts +9 -4
- package/dist/components/tt-modal-form/useModalForm.d.ts +1 -1
- package/dist/components/tt-table/index.d.ts +15 -0
- package/dist/components/tt-table/src/Table.vue.d.ts +9 -0
- package/dist/components/tt-table/src/Table.vue.js +240 -242
- package/dist/components/tt-table/src/TableForm.vue.d.ts +15 -4
- package/dist/components/tt-table/src/TableForm.vue.js +232 -202
- package/dist/components/tt-table/src/hooks/usePagination.d.ts +1 -1
- package/dist/components/tt-table/src/hooks/usePagination.js +38 -24
- package/dist/components/tt-table/src/hooks/useTableRender.d.ts +4 -4
- package/dist/components/tt-table/src/props.d.ts +12 -1
- package/dist/components/tt-table/src/props.js +14 -4
- package/dist/components/tt-table/src/types/table.d.ts +8 -0
- package/dist/components/tt-table/src/types/tableForm.d.ts +44 -10
- package/dist/components/tt-table/src/utils/table-form-api.d.ts +11 -11
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { FormCommonConfig, FormSchema, FormSlotSchema, CustomRenderType, FormValuesInput, NoInfer, TtFormProps, WrapperClassType } from '../types';
|
|
2
3
|
import { FormApi } from '../formApi';
|
|
3
4
|
import { TtNavAnchorProps } from '../../../tt-nav-anchor';
|
|
4
5
|
import { GroupFormApi } from './groupFormApi';
|
|
6
|
+
import { InsertPosition } from './utils';
|
|
5
7
|
export type CollapsibleType<TValues extends Record<string, any> = Record<string, any>> = boolean | ((values: TValues, formApi: FormApi) => boolean | PromiseLike<boolean>);
|
|
6
8
|
/** 控制 group / row / slot 是否显示,支持布尔值或函数(接收表单值与 formApi,可返回 Promise) */
|
|
7
9
|
export type IfShowConditionType<TValues extends Record<string, any> = Record<string, any>> = boolean | ((values: TValues, formApi: FormApi) => boolean | PromiseLike<boolean>);
|
|
@@ -105,12 +107,12 @@ export interface UseGroupFormOptionsWithLegacySchema<TValues extends Record<stri
|
|
|
105
107
|
}
|
|
106
108
|
/** groupSchema 与 schema 二选一(至少传一个) */
|
|
107
109
|
export type UseGroupFormOptions<TValues extends Record<string, any> = Record<string, any>> = UseGroupFormOptionsWithGroupSchema<TValues> | UseGroupFormOptionsWithLegacySchema<TValues>;
|
|
108
|
-
export type GroupFormExtraState = Partial<Pick<UseGroupFormOptions, "virtual" | "progressive" | "navAnchorProps" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "scrollOffset">> & {
|
|
110
|
+
export type GroupFormExtraState<TValues extends Record<string, any> = Record<string, any>> = Partial<Pick<UseGroupFormOptions, "virtual" | "progressive" | "navAnchorProps" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "scrollOffset">> & {
|
|
109
111
|
/** 分组 schema 树形结构(store 状态,由 GroupFormApi.setState 维护) */
|
|
110
|
-
groupSchema?: GroupFormSchema[];
|
|
112
|
+
groupSchema?: GroupFormSchema<TValues>[];
|
|
111
113
|
};
|
|
112
114
|
/** 分组表单完整 store 状态类型 */
|
|
113
|
-
export type GroupFormState<TValues extends Record<string, any> = Record<string, any>> = TtFormProps<TValues> & GroupFormExtraState
|
|
115
|
+
export type GroupFormState<TValues extends Record<string, any> = Record<string, any>> = TtFormProps<TValues> & GroupFormExtraState<TValues>;
|
|
114
116
|
/** LazyFormField 组件 props */
|
|
115
117
|
export interface LazyFormFieldProps {
|
|
116
118
|
/** 传给 FormField 的完整 props(通过 v-bind 透传) */
|
|
@@ -174,7 +176,38 @@ export interface GroupSectionProps {
|
|
|
174
176
|
* @description GroupFormApi 构造函数的分组配置选项,复用 UseGroupFormOptions 中同名字段的类型定义,
|
|
175
177
|
* 额外增加 `groupSchema`(由 useGroupForm 传入)。
|
|
176
178
|
*/
|
|
177
|
-
export type GroupFormApiOptions = Pick<UseGroupFormOptions, "virtual" | "progressive" | "navAnchorProps" | "scrollToFirstError" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "scrollOffset"> & {
|
|
179
|
+
export type GroupFormApiOptions<TValues extends Record<string, any> = Record<string, any>> = Pick<UseGroupFormOptions, "virtual" | "progressive" | "navAnchorProps" | "scrollToFirstError" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "scrollOffset"> & {
|
|
178
180
|
/** 分组 schema 树形结构(由 useGroupForm 传入) */
|
|
179
|
-
groupSchema: GroupFormSchema[];
|
|
181
|
+
groupSchema: GroupFormSchema<TValues>[];
|
|
180
182
|
};
|
|
183
|
+
/**
|
|
184
|
+
* 分组表单 api 对外类型。
|
|
185
|
+
*
|
|
186
|
+
* 与 {@link ExtendedFormApi} 同一个思路:`GroupFormApi` 类内部按 `Record<string, any>` 处理,
|
|
187
|
+
* 泛型在这一层收窄。分组独有的 `groupSchema` / `appendFields` 也跟着 `TValues` 走,
|
|
188
|
+
* `useGroupForm<Data>()` 之后再 `setState({ groupSchema })`,回调里依旧能推断出 `Data`。
|
|
189
|
+
*
|
|
190
|
+
* 写成「收窄签名 & 类」而不是 `Omit<类, ...> & 收窄签名`:类带私有成员,是名义类型,
|
|
191
|
+
* `Omit` 会把私有成员抹掉,业务把 api 标注成 `GroupFormApi` 就会报缺属性。
|
|
192
|
+
* 交叉后属性变成重载对,收窄签名在前所以优先匹配,匹配不上再退回类的宽松签名。
|
|
193
|
+
*/
|
|
194
|
+
export type ExtendedGroupFormApi<TValues extends Record<string, any> = Record<string, any>> = {
|
|
195
|
+
/** 设置表单状态,支持 `groupSchema` 等分组扩展字段 */
|
|
196
|
+
setState: (stateOrFn: ((prev: GroupFormState<TValues>) => Partial<GroupFormState<TValues>>) | Partial<GroupFormState<TValues>>) => void;
|
|
197
|
+
/** 读取当前表单状态 */
|
|
198
|
+
getState: () => null | GroupFormState<TValues>;
|
|
199
|
+
/**
|
|
200
|
+
* 获取表单值
|
|
201
|
+
* @param isGroup - 为 true 时返回按分组 key 嵌套的对象,默认 false 返回扁平值
|
|
202
|
+
*/
|
|
203
|
+
getValues: <T = TValues>(isGroup?: boolean) => Promise<T>;
|
|
204
|
+
/** 写入表单值,已声明字段按 `TValues` 校验类型 */
|
|
205
|
+
setValues: (fields: FormValuesInput<TValues>, filterFields?: boolean, shouldValidate?: boolean) => Promise<void>;
|
|
206
|
+
/** 按 fieldName 局部更新已展平的 schema */
|
|
207
|
+
updateSchema: (schema: Partial<FormSchema<TValues>>[]) => void;
|
|
208
|
+
/** 在分组树中增量插入字段或子结构 */
|
|
209
|
+
appendFields: (fields: GroupFormSchema<TValues>[], position?: InsertPosition) => void;
|
|
210
|
+
/** 校验表单,第二个参数控制是否滚动到第一个错误分组 */
|
|
211
|
+
validate: (opts?: any, scrollToError?: boolean) => ReturnType<GroupFormApi["validate"]>;
|
|
212
|
+
useStore: <T = NoInfer<GroupFormState<TValues>>>(selector?: (state: NoInfer<GroupFormState<TValues>>) => T) => Readonly<Ref<T>>;
|
|
213
|
+
} & GroupFormApi;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { DefineComponent } from 'vue';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
|
|
2
|
+
import { ExtendedGroupFormApi, UseGroupFormOptions, UseGroupFormOptionsCommon } from './types';
|
|
3
|
+
type GroupFormOverrideProps<TValues extends Record<string, any> = Record<string, any>> = Partial<UseGroupFormOptionsCommon<TValues>>;
|
|
4
|
+
type UseGroupFormReturn<TValues extends Record<string, any> = Record<string, any>> = readonly [
|
|
5
|
+
DefineComponent<GroupFormOverrideProps<TValues>>,
|
|
6
|
+
ExtendedGroupFormApi<TValues>
|
|
7
|
+
];
|
|
6
8
|
/**
|
|
7
9
|
* @description 返回可渲染的包装组件、扩展后的表单 API,以及分组折叠状态对象。
|
|
8
10
|
*/
|
|
9
|
-
export declare function useGroupForm<TValues extends Record<string, any> = Record<string, any>>(options: UseGroupFormOptions<TValues>): UseGroupFormReturn
|
|
11
|
+
export declare function useGroupForm<TValues extends Record<string, any> = Record<string, any>>(options: UseGroupFormOptions<TValues>): UseGroupFormReturn<TValues>;
|
|
10
12
|
export {};
|
|
@@ -134,12 +134,19 @@ export interface ArraySchemaContext {
|
|
|
134
134
|
export type FormActions = FormContext<GenericObject> & {
|
|
135
135
|
arrayAction?: FormArrayActions;
|
|
136
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* 表单值写入入参。
|
|
139
|
+
*
|
|
140
|
+
* 已声明的字段按 `TValues` 校验类型,同时允许写入嵌套数组路径(如 `list.0.name`)这类
|
|
141
|
+
* 不在 `TValues` 里的键,与 `setValues` 的运行时口径一致。
|
|
142
|
+
*/
|
|
143
|
+
export type FormValuesInput<TValues extends Record<string, any> = Record<string, any>> = Partial<TValues> & Record<string, unknown>;
|
|
137
144
|
/** 表单 schema 回调的公共参数类型 */
|
|
138
|
-
export type CustomRenderType<TValues extends Record<string, any> = Record<string, any>> = ((value: TValues, formApi:
|
|
145
|
+
export type CustomRenderType<TValues extends Record<string, any> = Record<string, any>> = ((value: TValues, formApi: ExtendedFormApi<TValues>) => Component | VNodeChild) | string;
|
|
139
146
|
export type FormSchemaRuleType = "required" | "selectRequired" | null | (Record<never, never> & string) | ZodTypeAny;
|
|
140
|
-
export type FormItemDependenciesCondition<TResult = boolean | PromiseLike<boolean>, TValues extends Record<string, any> = Record<string, any>> = (value: TValues, formApi:
|
|
141
|
-
export type FormItemDependenciesConditionWithRules<TValues extends Record<string, any> = Record<string, any>> = (value: TValues, formApi:
|
|
142
|
-
export type FormItemDependenciesConditionWithProps<TValues extends Record<string, any> = Record<string, any>> = (value: TValues, formApi:
|
|
147
|
+
export type FormItemDependenciesCondition<TResult = boolean | PromiseLike<boolean>, TValues extends Record<string, any> = Record<string, any>> = (value: TValues, formApi: ExtendedFormApi<TValues>) => TResult;
|
|
148
|
+
export type FormItemDependenciesConditionWithRules<TValues extends Record<string, any> = Record<string, any>> = (value: TValues, formApi: ExtendedFormApi<TValues>) => FormSchemaRuleType | PromiseLike<FormSchemaRuleType>;
|
|
149
|
+
export type FormItemDependenciesConditionWithProps<TValues extends Record<string, any> = Record<string, any>> = (value: TValues, formApi: ExtendedFormApi<TValues>) => MaybeComponentProps | PromiseLike<MaybeComponentProps>;
|
|
143
150
|
export interface FormItemDependencies<TValues extends Record<string, any> = Record<string, any>> {
|
|
144
151
|
/**
|
|
145
152
|
* 组件参数
|
|
@@ -190,7 +197,7 @@ export interface FormItemDependencies<TValues extends Record<string, any> = Reco
|
|
|
190
197
|
* - 允许声明 `triggerFields` 作为依赖触发源
|
|
191
198
|
*/
|
|
192
199
|
export type ArrayRegisterDependencies<TValues extends Record<string, any> = Record<string, any>> = Pick<FormItemDependencies<TValues>, "if" | "show" | "rules" | "disabled" | "triggerFields">;
|
|
193
|
-
export type ComponentProps<TValues extends Record<string, any> = Record<string, any>> = ((value: TValues, formApi:
|
|
200
|
+
export type ComponentProps<TValues extends Record<string, any> = Record<string, any>> = ((value: TValues, formApi: ExtendedFormApi<TValues>) => MaybeComponentProps) | MaybeComponentProps;
|
|
194
201
|
export interface FormCommonConfig<TValues extends Record<string, any> = Record<string, any>> {
|
|
195
202
|
/**
|
|
196
203
|
* 在Label后显示一个冒号
|
|
@@ -262,9 +269,9 @@ export interface FormCommonConfig<TValues extends Record<string, any> = Record<s
|
|
|
262
269
|
*/
|
|
263
270
|
wrapperClass?: string;
|
|
264
271
|
}
|
|
265
|
-
export type RenderComponentContentType<TValues extends Record<string, any> = Record<string, any>> = (value: TValues, formApi:
|
|
266
|
-
export type HandleSubmitFn =
|
|
267
|
-
export type HandleResetFn =
|
|
272
|
+
export type RenderComponentContentType<TValues extends Record<string, any> = Record<string, any>> = (value: TValues, formApi: ExtendedFormApi<TValues>) => Record<string, any>;
|
|
273
|
+
export type HandleSubmitFn<TValues extends Record<string, any> = Record<string, any>> = (values: TValues) => Promise<void> | void;
|
|
274
|
+
export type HandleResetFn<TValues extends Record<string, any> = Record<string, any>> = (values: TValues) => Promise<void> | void;
|
|
268
275
|
export type FieldMappingTime = [
|
|
269
276
|
string,
|
|
270
277
|
[
|
|
@@ -486,15 +493,15 @@ export interface TtFormProps<TValues extends Record<string, any> = Record<string
|
|
|
486
493
|
/**
|
|
487
494
|
* 表单重置回调
|
|
488
495
|
*/
|
|
489
|
-
handleReset?: HandleResetFn
|
|
496
|
+
handleReset?: HandleResetFn<TValues>;
|
|
490
497
|
/**
|
|
491
498
|
* 表单提交回调
|
|
492
499
|
*/
|
|
493
|
-
handleSubmit?: HandleSubmitFn
|
|
500
|
+
handleSubmit?: HandleSubmitFn<TValues>;
|
|
494
501
|
/**
|
|
495
502
|
* 表单值变化回调
|
|
496
503
|
*/
|
|
497
|
-
handleValuesChange?: (values:
|
|
504
|
+
handleValuesChange?: (values: TValues, fieldsChanged: string[]) => void;
|
|
498
505
|
/**
|
|
499
506
|
* 重置按钮参数
|
|
500
507
|
*/
|
|
@@ -524,38 +531,63 @@ export interface TtFormProps<TValues extends Record<string, any> = Record<string
|
|
|
524
531
|
*/
|
|
525
532
|
submitOnEnter?: boolean;
|
|
526
533
|
}
|
|
527
|
-
|
|
534
|
+
/**
|
|
535
|
+
* 表单 api 对外类型。
|
|
536
|
+
*
|
|
537
|
+
* `FormApi` 类本身不带泛型(内部按 `Record<string, any>` 处理),泛型只在这一层对外收窄:
|
|
538
|
+
* 凡是吃/吐表单值与 schema 的方法都按 `TValues` 重新声明,其余方法沿用类的签名。
|
|
539
|
+
* 这样 `useForm<Data>()` 之后再调 `setState({ schema })` / `updateSchema` / `appendFields`,
|
|
540
|
+
* schema 里的 `dependencies` 回调依旧能推断出 `Data`。
|
|
541
|
+
*
|
|
542
|
+
* 这里保持 `Omit<类, ...>` 的写法(与改动前一致):`Omit` 会抹掉类的私有成员,所以本类型
|
|
543
|
+
* 不能反向赋给 `FormApi`,但改动前就是这样,业务受影响面没变;换成与类交叉虽然能反向赋值,
|
|
544
|
+
* 代价是同名方法变成重载对、收窄签名匹配失败时静默退回类的宽松签名,
|
|
545
|
+
* `setValues({ age: "1" })` 这种字段类型写错就查不出来了。
|
|
546
|
+
* 分组表单那侧因为改动前直接暴露的是类本身,必须用交叉,见 `ExtendedGroupFormApi`。
|
|
547
|
+
*/
|
|
548
|
+
export type ExtendedFormApi<TValues extends Record<string, any> = Record<string, any>> = Omit<FormApi, "appendFields" | "getState" | "getValues" | "setValues" | "setState" | "updateSchema" | "validate"> & {
|
|
528
549
|
/**
|
|
529
550
|
* @description 设置表单状态,支持扩展字段(如 navAnchorProps、groupSchema 等)
|
|
530
|
-
* @param
|
|
551
|
+
* @param stateOrFn - 新状态或更新函数
|
|
552
|
+
*/
|
|
553
|
+
setState: (stateOrFn: ((prev: TtFormProps<TValues> & Record<string, any>) => Partial<TtFormProps<TValues> & Record<string, any>>) | Partial<TtFormProps<TValues> & Record<string, any>>) => void;
|
|
554
|
+
/**
|
|
555
|
+
* @description 读取当前表单状态
|
|
556
|
+
*/
|
|
557
|
+
getState: () => null | TtFormProps<TValues>;
|
|
558
|
+
/**
|
|
559
|
+
* @description 写入表单值,已声明字段按 `TValues` 校验类型
|
|
560
|
+
*/
|
|
561
|
+
setValues: (fields: FormValuesInput<TValues>, filterFields?: boolean, shouldValidate?: boolean) => Promise<void>;
|
|
562
|
+
/**
|
|
563
|
+
* @description 按 fieldName 局部更新 schema
|
|
531
564
|
*/
|
|
532
|
-
|
|
565
|
+
updateSchema: (schema: Partial<FormSchema<TValues>>[]) => void;
|
|
533
566
|
/**
|
|
534
567
|
* 校验表单,支持通过第二个参数控制是否滚动到第一个错误分组
|
|
568
|
+
*
|
|
569
|
+
* 返回类型直接取 `FormApi.validate`,与运行时实际返回保持一致(`errors` 的值可能是 undefined)。
|
|
535
570
|
* @param {any} [opts] - 原始 validate 选项
|
|
536
571
|
* @param {boolean} [scrollToError] - 是否滚动到第一个错误分组,不传时使用全局配置 scrollToFirstError
|
|
537
572
|
*/
|
|
538
|
-
validate: (opts?: any, scrollToError?: boolean) =>
|
|
539
|
-
valid: boolean;
|
|
540
|
-
errors: Record<string, string>;
|
|
541
|
-
results?: any;
|
|
542
|
-
}>;
|
|
573
|
+
validate: (opts?: any, scrollToError?: boolean) => ReturnType<FormApi["validate"]>;
|
|
543
574
|
/**
|
|
544
575
|
* 获取表单值
|
|
545
576
|
* @param {boolean} [isGroup] - 为 true 时返回按分组 key 嵌套的对象,默认 false 返回扁平值
|
|
546
577
|
* @returns {Promise<T>} 表单值
|
|
547
578
|
*/
|
|
548
|
-
getValues: <T =
|
|
549
|
-
useStore: <T = NoInfer<TtFormProps
|
|
579
|
+
getValues: <T = TValues>(isGroup?: boolean) => Promise<T>;
|
|
580
|
+
useStore: <T = NoInfer<TtFormProps<TValues>>>(selector?: (state: NoInfer<TtFormProps<TValues>>) => T) => Readonly<Ref<T>>;
|
|
550
581
|
/** 滚动到指定分组(仅 useGroupForm 场景下可用) */
|
|
551
582
|
scrollToGroup?: (key: string) => void;
|
|
552
583
|
/**
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
* @param
|
|
584
|
+
* 增量插入字段,无需全量重建 schema。
|
|
585
|
+
*
|
|
586
|
+
* `useGroupForm` 下由 `GroupFormApi` 覆盖,接收的是分组 schema 树节点。
|
|
587
|
+
* @param fields - 要插入的字段或子结构
|
|
588
|
+
* @param position - 插入位置:before/after 匹配 fieldName、slot content 或 group key;省略则追加到末尾
|
|
557
589
|
*/
|
|
558
|
-
appendFields
|
|
590
|
+
appendFields: (fields: FormSchema<TValues>[], position?: {
|
|
559
591
|
before?: string;
|
|
560
592
|
after?: string;
|
|
561
593
|
}) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ExtendedFormApi, TtFormProps } from './types';
|
|
2
|
-
export declare function useForm<TValues extends Record<string, any> = Record<string, any>>(options: TtFormProps<TValues>): readonly [import('vue').DefineSetupFnComponent<TtFormProps<TValues>, {}, {}, TtFormProps<TValues> & {}, import('vue').PublicProps>, ExtendedFormApi];
|
|
2
|
+
export declare function useForm<TValues extends Record<string, any> = Record<string, any>>(options: TtFormProps<TValues>): readonly [import('vue').DefineSetupFnComponent<TtFormProps<TValues>, {}, {}, TtFormProps<TValues> & {}, import('vue').PublicProps>, ExtendedFormApi<TValues>];
|
|
@@ -4,12 +4,12 @@ import { FormApi as A } from "./formApi.js";
|
|
|
4
4
|
import S from "./index.vue2.js";
|
|
5
5
|
/* empty css */
|
|
6
6
|
function C(t) {
|
|
7
|
-
const n = a(t), e = new A(t),
|
|
8
|
-
|
|
7
|
+
const n = a(t), e = new A(t), r = e;
|
|
8
|
+
r.useStore = (m) => p(e.store, m);
|
|
9
9
|
const i = c(
|
|
10
|
-
(
|
|
10
|
+
(m, { attrs: o, slots: s }) => (f(() => {
|
|
11
11
|
e.unmount();
|
|
12
|
-
}), e.setState({ ...
|
|
12
|
+
}), e.setState({ ...m, ...o }), () => u(S, { ...m, ...o, formApi: r }, s)),
|
|
13
13
|
{
|
|
14
14
|
name: "TtForm",
|
|
15
15
|
inheritAttrs: !1
|
|
@@ -21,7 +21,7 @@ function C(t) {
|
|
|
21
21
|
e.setState({ schema: t.schema });
|
|
22
22
|
},
|
|
23
23
|
{ immediate: !0 }
|
|
24
|
-
), [i,
|
|
24
|
+
), [i, r];
|
|
25
25
|
}
|
|
26
26
|
export {
|
|
27
27
|
C as useForm
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExtendedGroupFormApi, TtExtendedFormApi, TtFormProps, UseGroupFormOptions } from '../tt-form';
|
|
2
2
|
import { ModalApiOptions, TtModalExtendedModalApi } from '../tt-modal';
|
|
3
3
|
/** modal-form 使用的表单类型。 */
|
|
4
4
|
export type ModalFormType = "form" | "groupForm";
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* modal-form 对外暴露的表单 API 类型。
|
|
7
|
+
*
|
|
8
|
+
* `TValues` 跟着 `formProps` 走,`getFormApi` 拿到的 api 上 `getValues` / `setState({ schema })`
|
|
9
|
+
* 等方法也按业务的值类型收窄。
|
|
10
|
+
*/
|
|
11
|
+
export type ModalFormApi<TType extends ModalFormType = "form", TValues extends Record<string, any> = Record<string, any>> = TType extends "groupForm" ? ExtendedGroupFormApi<TValues> : TtExtendedFormApi<TValues>;
|
|
7
12
|
/** 根据表单类型收窄的表单配置。 */
|
|
8
13
|
type ModalFormProps<TValues extends Record<string, any>, TType extends ModalFormType> = TType extends "groupForm" ? Partial<UseGroupFormOptions<TValues>> : Partial<TtFormProps<TValues>>;
|
|
9
14
|
export type TtModalFormProps<TType extends ModalFormType = "form", TValues extends Record<string, any> = Record<string, any>> = {
|
|
@@ -40,7 +45,7 @@ export type TtModalFormProps<TType extends ModalFormType = "form", TValues exten
|
|
|
40
45
|
/** modal props */
|
|
41
46
|
modalProps?: ModalApiOptions;
|
|
42
47
|
/** 获取formApi的回调 */
|
|
43
|
-
getFormApi?: (api: ModalFormApi<TType>) => void;
|
|
48
|
+
getFormApi?: (api: ModalFormApi<TType, TValues>) => void;
|
|
44
49
|
/** 获取modalApi的回调 */
|
|
45
50
|
getModalApi?: (api: TtModalExtendedModalApi) => void;
|
|
46
51
|
/** 处理TtSelect(非多选回显值) */
|
|
@@ -2,6 +2,6 @@ import { TtModalExtendedModalApi } from '../tt-modal';
|
|
|
2
2
|
import { ModalFormApi, ModalFormType, TtModalFormProps } from './props';
|
|
3
3
|
/** 创建普通表单或分组表单的弹窗表单。 */
|
|
4
4
|
export declare function useModalForm<TType extends ModalFormType = "form", TValues extends Record<string, any> = Record<string, any>>(options: TtModalFormProps<TType, TValues>): readonly [import('vue').DefineSetupFnComponent<Partial<TtModalFormProps<ModalFormType>>, {}, {}, Partial<TtModalFormProps<ModalFormType>> & {}, import('vue').PublicProps>, {
|
|
5
|
-
readonly formApi: import('vue').Ref<ModalFormApi<TType> | undefined, ModalFormApi<TType> | undefined>;
|
|
5
|
+
readonly formApi: import('vue').Ref<ModalFormApi<TType, TValues> | undefined, ModalFormApi<TType, TValues> | undefined>;
|
|
6
6
|
readonly modalApi: import('vue').Ref<TtModalExtendedModalApi | undefined, TtModalExtendedModalApi | undefined>;
|
|
7
7
|
}];
|
|
@@ -207,6 +207,10 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
|
|
|
207
207
|
type: import('vue').PropType<import('.').TtTableProps["beforeFetch"]>;
|
|
208
208
|
default: null;
|
|
209
209
|
};
|
|
210
|
+
beforePageChange: {
|
|
211
|
+
type: import('vue').PropType<import('.').TtTableProps["beforePageChange"]>;
|
|
212
|
+
default: null;
|
|
213
|
+
};
|
|
210
214
|
data: {
|
|
211
215
|
type: import('vue').PropType<import('.').TtTableProps["data"]>;
|
|
212
216
|
default: () => import('.').TtTableProps["data"];
|
|
@@ -523,6 +527,7 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
|
|
|
523
527
|
api: (...arg: any[]) => Promise<any>;
|
|
524
528
|
afterFetch: ((data: any[], res: Recordable | Recordable[]) => Promise<any[]>) | undefined;
|
|
525
529
|
beforeFetch: ((params: Recordable) => Promise<Recordable>) | undefined;
|
|
530
|
+
beforePageChange: ((page: import("vxe-table").VxeGridPropTypes.PagerConfig) => boolean | Promise<boolean>) | undefined;
|
|
526
531
|
}, true, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
|
|
527
532
|
wrapRef: HTMLDivElement;
|
|
528
533
|
xGrid: (import('vxe-table').VxeGridMethods<any> & {
|
|
@@ -894,6 +899,10 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
|
|
|
894
899
|
type: import('vue').PropType<import('.').TtTableProps["beforeFetch"]>;
|
|
895
900
|
default: null;
|
|
896
901
|
};
|
|
902
|
+
beforePageChange: {
|
|
903
|
+
type: import('vue').PropType<import('.').TtTableProps["beforePageChange"]>;
|
|
904
|
+
default: null;
|
|
905
|
+
};
|
|
897
906
|
data: {
|
|
898
907
|
type: import('vue').PropType<import('.').TtTableProps["data"]>;
|
|
899
908
|
default: () => import('.').TtTableProps["data"];
|
|
@@ -1208,6 +1217,7 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
|
|
|
1208
1217
|
api: (...arg: any[]) => Promise<any>;
|
|
1209
1218
|
afterFetch: ((data: any[], res: Recordable | Recordable[]) => Promise<any[]>) | undefined;
|
|
1210
1219
|
beforeFetch: ((params: Recordable) => Promise<Recordable>) | undefined;
|
|
1220
|
+
beforePageChange: ((page: import("vxe-table").VxeGridPropTypes.PagerConfig) => boolean | Promise<boolean>) | undefined;
|
|
1211
1221
|
}>;
|
|
1212
1222
|
__isFragment?: never;
|
|
1213
1223
|
__isTeleport?: never;
|
|
@@ -1312,6 +1322,10 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
|
|
|
1312
1322
|
type: import('vue').PropType<import('.').TtTableProps["beforeFetch"]>;
|
|
1313
1323
|
default: null;
|
|
1314
1324
|
};
|
|
1325
|
+
beforePageChange: {
|
|
1326
|
+
type: import('vue').PropType<import('.').TtTableProps["beforePageChange"]>;
|
|
1327
|
+
default: null;
|
|
1328
|
+
};
|
|
1315
1329
|
data: {
|
|
1316
1330
|
type: import('vue').PropType<import('.').TtTableProps["data"]>;
|
|
1317
1331
|
default: () => import('.').TtTableProps["data"];
|
|
@@ -1628,6 +1642,7 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
|
|
|
1628
1642
|
api: (...arg: any[]) => Promise<any>;
|
|
1629
1643
|
afterFetch: ((data: any[], res: Recordable | Recordable[]) => Promise<any[]>) | undefined;
|
|
1630
1644
|
beforeFetch: ((params: Recordable) => Promise<Recordable>) | undefined;
|
|
1645
|
+
beforePageChange: ((page: import("vxe-table").VxeGridPropTypes.PagerConfig) => boolean | Promise<boolean>) | undefined;
|
|
1631
1646
|
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
1632
1647
|
$slots: Readonly<{
|
|
1633
1648
|
[key: string]: (props: import('../../../../utils/src').Recordable) => void;
|
|
@@ -393,6 +393,10 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
393
393
|
type: import('vue').PropType<TtTableProps["beforeFetch"]>;
|
|
394
394
|
default: null;
|
|
395
395
|
};
|
|
396
|
+
beforePageChange: {
|
|
397
|
+
type: import('vue').PropType<TtTableProps["beforePageChange"]>;
|
|
398
|
+
default: null;
|
|
399
|
+
};
|
|
396
400
|
data: {
|
|
397
401
|
type: import('vue').PropType<TtTableProps["data"]>;
|
|
398
402
|
default: () => TtTableProps["data"];
|
|
@@ -744,6 +748,10 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
744
748
|
type: import('vue').PropType<TtTableProps["beforeFetch"]>;
|
|
745
749
|
default: null;
|
|
746
750
|
};
|
|
751
|
+
beforePageChange: {
|
|
752
|
+
type: import('vue').PropType<TtTableProps["beforePageChange"]>;
|
|
753
|
+
default: null;
|
|
754
|
+
};
|
|
747
755
|
data: {
|
|
748
756
|
type: import('vue').PropType<TtTableProps["data"]>;
|
|
749
757
|
default: () => TtTableProps["data"];
|
|
@@ -967,6 +975,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
967
975
|
api: (...arg: any[]) => Promise<any>;
|
|
968
976
|
afterFetch: ((data: any[], res: globalThis.Recordable | globalThis.Recordable[]) => Promise<any[]>) | undefined;
|
|
969
977
|
beforeFetch: ((params: globalThis.Recordable) => Promise<globalThis.Recordable>) | undefined;
|
|
978
|
+
beforePageChange: ((page: import("vxe-table").VxeGridPropTypes.PagerConfig) => boolean | Promise<boolean>) | undefined;
|
|
970
979
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
971
980
|
wrapRef: HTMLDivElement;
|
|
972
981
|
xGrid: (import('vxe-table').VxeGridMethods<any> & {
|