@tmagic/form 1.8.0-beta.10 → 1.8.0-beta.12

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/types/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { App, AppContext, Component, InjectionKey } from "vue";
1
+ import { App, AppContext, Component, ComputedRef, InjectionKey } from "vue";
2
2
  import { FlexLayoutConfig, FormItemConfig, GroupListConfig, TableConfig } from "@tmagic/form-schema";
3
3
  export * from "@tmagic/form-schema";
4
4
 
5
5
  //#region \0rolldown/runtime.js
6
6
  declare namespace schema_d_exports {
7
- export { ChangeRecord, ContainerChangeEventData, FORM_DIFF_CONFIG_KEY, FormDiffConfig, FormLabelSlotProps, FormSlots, ValidateError };
7
+ export { ChangeRecord, ContainerChangeEventData, FORM_DIFF_CONFIG_KEY, FORM_TYPE_MATCH_VALID_KEY, FormDiffConfig, FormLabelSlotProps, FormSlots, ValidateError };
8
8
  }
9
9
  import * as import__tmagic_form_schema from "@tmagic/form-schema";
10
10
  /**
@@ -33,6 +33,7 @@ interface FormDiffConfig {
33
33
  selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
34
34
  }
35
35
  declare const FORM_DIFF_CONFIG_KEY: InjectionKey<FormDiffConfig>;
36
+ declare const FORM_TYPE_MATCH_VALID_KEY: InjectionKey<ComputedRef<boolean>>;
36
37
  interface ValidateError {
37
38
  message: string;
38
39
  field: string;
@@ -107,9 +108,19 @@ interface SubmitFormOptions {
107
108
  appContext?: AppContext | null;
108
109
  /** 等待表单初始化的最长时间(毫秒),超时将以错误 reject。默认 10000ms */
109
110
  timeout?: number;
111
+ /**
112
+ * 调试模式。默认 `false`。
113
+ *
114
+ * - `false`:表单以隐藏方式挂载,初始化完成后自动提交(原有行为)。
115
+ * - `true`:将表单以弹层形式可见地渲染在页面上,需手动点击「确定」才会触发校验/提交,
116
+ * 点击「取消」则以 reject 中断;校验失败时保留弹层并展示错误信息,便于修正后重试。
117
+ * 调试模式下 `timeout` 不生效(等待人工操作)。
118
+ */
119
+ debug?: boolean;
120
+ typeMatchValid?: boolean;
110
121
  }
111
122
  /**
112
- * 开启 `returnChangeRecords` 时 submitForm 的返回结果
123
+ * 开启 `returnChangeNodes` 时 submitForm 的返回结果
113
124
  */
114
125
  interface SubmitFormResult {
115
126
  /** 校验通过后的表单值 */
@@ -144,15 +155,101 @@ interface SubmitFormResult {
144
155
  * initValues: { name: 'foo' },
145
156
  * returnChangeRecords: true,
146
157
  * });
158
+ *
159
+ * // 调试模式:可见地渲染表单,点击「确定」才提交:
160
+ * const values = await submitForm({
161
+ * config: [...],
162
+ * initValues: { name: 'foo' },
163
+ * debug: true,
164
+ * });
147
165
  * ```
148
166
  */
149
167
  declare const submitForm: (options: SubmitFormOptions) => Promise<any>;
168
+ /**
169
+ * validateForm 函数参数(与 Form.vue 组件 props 对齐,取校验所需子集)
170
+ */
171
+ interface ValidateFormOptions {
172
+ /** 表单配置 */
173
+ config: schema_d_exports.FormConfig;
174
+ /** 待校验的表单值 */
175
+ initValues?: Record<string, any>;
176
+ parentValues?: Record<string, any>;
177
+ labelWidth?: string;
178
+ keyProp?: string;
179
+ /**
180
+ * 校验失败时,错误提示前缀是否使用字段的 text 文案(通过 `getTextByName` 从 config 中查找)。
181
+ * 默认 `true`,置为 `false` 时直接使用字段 name。
182
+ */
183
+ useFieldTextInError?: boolean;
184
+ extendState?: (_state: schema_d_exports.FormState) => Record<string, any> | Promise<Record<string, any>>;
185
+ /**
186
+ * 父级应用上下文,用于继承全局组件、指令、provide 等。
187
+ * 通常通过 `app._context` 或 `getCurrentInstance()?.appContext` 获取。
188
+ */
189
+ appContext?: AppContext | null;
190
+ /** 等待表单初始化的最长时间(毫秒),超时将以错误 reject。默认 10000ms */
191
+ timeout?: number;
192
+ /**
193
+ * 调试模式。默认 `false`。
194
+ *
195
+ * - `false`:以隐藏方式挂载,初始化完成后自动校验并 resolve 错误文案(原有静默行为)。
196
+ * - `true`:将表单以弹层形式可见地渲染在页面上,需手动点击「确定」才会触发校验,
197
+ * 点击「取消」则以 reject 中断;校验失败时在弹层内展示错误信息并保留弹层,便于修正后重试,
198
+ * 校验通过则 resolve 空字符串。调试模式下 `timeout` 不生效(等待人工操作)。
199
+ */
200
+ debug?: boolean;
201
+ typeMatchValid?: boolean;
202
+ }
203
+ /**
204
+ * 以命令式方式对一份「表单配置 + 值」做一次静默校验,**不依赖也不影响任何已渲染的表单**。
205
+ *
206
+ * 与 `submitForm` 类似,内部会临时挂载一个不可见的 MForm 实例,等待其初始化完成后调用
207
+ * 实例的 `validate` 方法,返回汇总后的错误文案,随后自动卸载实例。
208
+ *
209
+ * 与 `submitForm` 的区别:
210
+ * - 「静默」:校验失败不抛异常、不触发 `error` 事件、不返回表单值;
211
+ * - 仅用于「探测」配置是否合法,适合源码保存后校验、批量校验组件配置等场景。
212
+ *
213
+ * 由于每次都新建一个独立的 MForm 实例,调用方无需持有任何表单 ref,也不会污染
214
+ * 页面上正在展示的表单状态。
215
+ *
216
+ * @returns 校验通过返回空字符串 `''`,否则返回以 `<br>` 拼接的错误文案。
217
+ * 仅在初始化超时或挂载失败等异常情况下才会 reject。
218
+ *
219
+ * @example
220
+ * ```ts
221
+ * import { validateForm } from '@tmagic/form';
222
+ *
223
+ * const error = await validateForm({
224
+ * config: [...],
225
+ * initValues: { name: 'foo' },
226
+ * appContext: getCurrentInstance()?.appContext,
227
+ * });
228
+ * if (error) {
229
+ * // 配置不合法,error 为错误文案
230
+ * }
231
+ *
232
+ * // 调试模式:可见地渲染表单,点击「确定」才校验,校验失败保留弹层可修正重试:
233
+ * const error = await validateForm({
234
+ * config: [...],
235
+ * initValues: { name: 'foo' },
236
+ * debug: true,
237
+ * });
238
+ * ```
239
+ */
240
+ declare const validateForm: (options: ValidateFormOptions) => Promise<string>;
150
241
  //#endregion
151
242
  //#region temp/packages/form/src/utils/form.d.ts
243
+ type AsyncValidatorFn = (rule: any, value: any, callback: Function, source?: any, options?: any) => any;
244
+ /**
245
+ * 将 async-validator(Element Plus)风格的 validator 适配到当前 UI 库。
246
+ * TDesign 调用签名为 `(val) => boolean | CustomValidateObj | Promise`,无 callback。
247
+ */
248
+ declare const adaptFormValidator: (validator: AsyncValidatorFn) => AsyncValidatorFn;
152
249
  declare const createValues: (mForm: schema_d_exports.FormState | undefined, config?: schema_d_exports.FormConfig | schema_d_exports.TabPaneConfig[], initValue?: schema_d_exports.FormValue, value?: schema_d_exports.FormValue) => schema_d_exports.FormValue;
153
250
  declare const filterFunction: <T = any>(mForm: schema_d_exports.FormState | undefined, config: T | schema_d_exports.FilterFunction<T> | undefined, props: any) => T | undefined;
154
251
  declare const display: (mForm: schema_d_exports.FormState | undefined, config: any, props: any) => any;
155
- declare const getRules: (mForm: schema_d_exports.FormState | undefined, rules: (schema_d_exports.Rule[] | schema_d_exports.Rule) | undefined, props: any) => schema_d_exports.Rule[];
252
+ declare const getRules: (mForm: schema_d_exports.FormState | undefined, r: (schema_d_exports.Rule[] | schema_d_exports.Rule) | undefined, props: any, typeMatchValid?: ComputedRef<boolean>) => schema_d_exports.Rule[];
156
253
  declare const initValue: (mForm: schema_d_exports.FormState | undefined, {
157
254
  initValues,
158
255
  config
@@ -180,7 +277,8 @@ type __VLS_Props$30 = {
180
277
  lastValues?: Record<string, any>; /** 是否开启对比模式 */
181
278
  isCompare?: boolean;
182
279
  parentValues?: Record<string, any>;
183
- labelWidth?: string;
280
+ labelWidth?: string; /** 是否开启类型匹配校验 */
281
+ typeMatchValid?: boolean;
184
282
  disabled?: boolean;
185
283
  height?: string;
186
284
  stepActive?: string | number;
@@ -239,6 +337,23 @@ declare const __VLS_base$5: import("@vue/runtime-core").DefineComponent<__VLS_Pr
239
337
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
240
338
  resetForm: () => void;
241
339
  submitForm: (native?: boolean) => Promise<any>;
340
+ /**
341
+ * 校验:对表单当前值执行校验,返回汇总后的错误文案。
342
+ *
343
+ * 与 `submitForm` 的区别:
344
+ * - 校验失败时不抛异常、不触发 `error` 事件,而是以返回值形式给出错误文案;
345
+ * - 不重置 `changeRecords`,不改变提交语义,仅用于「探测」当前配置是否合法。
346
+ *
347
+ * 注意:本方法只改变「校验结果的返回方式」,并不负责「不污染页面表单状态」——
348
+ * 若需对一份独立的「配置 + 值」做完全不影响页面上已渲染表单的校验,请使用 `validateForm`
349
+ * (内部会新建一个隐藏的 MForm 实例,通过 `initValues` 传入待校验值,用完即卸载)。
350
+ *
351
+ * 典型用途:作为 `validateForm` 内部复用的校验实现;也可在已渲染的表单实例上主动调用,
352
+ * 根据返回的错误文案自行决定后续处理(如记录节点错误状态)。
353
+ *
354
+ * @returns 校验通过返回空字符串 `''`,否则返回以 `<br>` 拼接的错误文案。
355
+ */
356
+ validate: () => Promise<string>;
242
357
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
243
358
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
244
359
  error: (...args: any[]) => void;
@@ -281,7 +396,8 @@ type __VLS_Props$29 = {
281
396
  values?: Object;
282
397
  parentValues?: Object;
283
398
  width?: string | number;
284
- labelWidth?: string;
399
+ labelWidth?: string; /** 是否开启类型匹配校验 */
400
+ typeMatchValid?: boolean;
285
401
  fullscreen?: boolean;
286
402
  disabled?: boolean;
287
403
  title?: string;
@@ -318,6 +434,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
318
434
  readonly isCompare?: boolean | undefined;
319
435
  readonly parentValues?: Record<string, any> | undefined;
320
436
  readonly labelWidth?: string | undefined;
437
+ readonly typeMatchValid?: boolean | undefined;
321
438
  readonly disabled?: boolean | undefined;
322
439
  readonly height?: string | undefined;
323
440
  readonly stepActive?: string | number | undefined;
@@ -360,6 +477,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
360
477
  isCompare?: boolean;
361
478
  parentValues?: Record<string, any>;
362
479
  labelWidth?: string;
480
+ typeMatchValid?: boolean;
363
481
  disabled?: boolean;
364
482
  height?: string;
365
483
  stepActive?: string | number;
@@ -392,6 +510,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
392
510
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
393
511
  resetForm: () => void;
394
512
  submitForm: (native?: boolean) => Promise<any>;
513
+ validate: () => Promise<string>;
395
514
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
396
515
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
397
516
  error: (...args: any[]) => void;
@@ -454,6 +573,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
454
573
  isCompare?: boolean;
455
574
  parentValues?: Record<string, any>;
456
575
  labelWidth?: string;
576
+ typeMatchValid?: boolean;
457
577
  disabled?: boolean;
458
578
  height?: string;
459
579
  stepActive?: string | number;
@@ -477,7 +597,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
477
597
  "onField-input"?: ((...args: any[]) => any) | undefined;
478
598
  "onField-change"?: ((...args: any[]) => any) | undefined;
479
599
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
480
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
600
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
481
601
  values: schema_d_exports.FormValue;
482
602
  lastValuesProcessed: schema_d_exports.FormValue;
483
603
  formState: schema_d_exports.FormState;
@@ -486,6 +606,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
486
606
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
487
607
  resetForm: () => void;
488
608
  submitForm: (native?: boolean) => Promise<any>;
609
+ validate: () => Promise<string>;
489
610
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
490
611
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
491
612
  $slots: import("@tmagic/editor").FormSlots;
@@ -499,6 +620,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
499
620
  readonly isCompare?: boolean | undefined;
500
621
  readonly parentValues?: Record<string, any> | undefined;
501
622
  readonly labelWidth?: string | undefined;
623
+ readonly typeMatchValid?: boolean | undefined;
502
624
  readonly disabled?: boolean | undefined;
503
625
  readonly height?: string | undefined;
504
626
  readonly stepActive?: string | number | undefined;
@@ -541,6 +663,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
541
663
  isCompare?: boolean;
542
664
  parentValues?: Record<string, any>;
543
665
  labelWidth?: string;
666
+ typeMatchValid?: boolean;
544
667
  disabled?: boolean;
545
668
  height?: string;
546
669
  stepActive?: string | number;
@@ -573,6 +696,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
573
696
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
574
697
  resetForm: () => void;
575
698
  submitForm: (native?: boolean) => Promise<any>;
699
+ validate: () => Promise<string>;
576
700
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
577
701
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
578
702
  error: (...args: any[]) => void;
@@ -635,6 +759,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
635
759
  isCompare?: boolean;
636
760
  parentValues?: Record<string, any>;
637
761
  labelWidth?: string;
762
+ typeMatchValid?: boolean;
638
763
  disabled?: boolean;
639
764
  height?: string;
640
765
  stepActive?: string | number;
@@ -658,7 +783,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
658
783
  "onField-input"?: ((...args: any[]) => any) | undefined;
659
784
  "onField-change"?: ((...args: any[]) => any) | undefined;
660
785
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
661
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
786
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
662
787
  values: schema_d_exports.FormValue;
663
788
  lastValuesProcessed: schema_d_exports.FormValue;
664
789
  formState: schema_d_exports.FormState;
@@ -667,6 +792,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
667
792
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
668
793
  resetForm: () => void;
669
794
  submitForm: (native?: boolean) => Promise<any>;
795
+ validate: () => Promise<string>;
670
796
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
671
797
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
672
798
  $slots: import("@tmagic/editor").FormSlots;
@@ -712,7 +838,8 @@ type __VLS_Props$28 = {
712
838
  values?: Object;
713
839
  parentValues?: Object;
714
840
  width?: string | number;
715
- labelWidth?: string;
841
+ labelWidth?: string; /** 是否开启类型匹配校验 */
842
+ typeMatchValid?: boolean;
716
843
  disabled?: boolean;
717
844
  closeOnPressEscape?: boolean;
718
845
  title?: string;
@@ -745,6 +872,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
745
872
  readonly isCompare?: boolean | undefined;
746
873
  readonly parentValues?: Record<string, any> | undefined;
747
874
  readonly labelWidth?: string | undefined;
875
+ readonly typeMatchValid?: boolean | undefined;
748
876
  readonly disabled?: boolean | undefined;
749
877
  readonly height?: string | undefined;
750
878
  readonly stepActive?: string | number | undefined;
@@ -787,6 +915,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
787
915
  isCompare?: boolean;
788
916
  parentValues?: Record<string, any>;
789
917
  labelWidth?: string;
918
+ typeMatchValid?: boolean;
790
919
  disabled?: boolean;
791
920
  height?: string;
792
921
  stepActive?: string | number;
@@ -819,6 +948,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
819
948
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
820
949
  resetForm: () => void;
821
950
  submitForm: (native?: boolean) => Promise<any>;
951
+ validate: () => Promise<string>;
822
952
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
823
953
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
824
954
  error: (...args: any[]) => void;
@@ -881,6 +1011,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
881
1011
  isCompare?: boolean;
882
1012
  parentValues?: Record<string, any>;
883
1013
  labelWidth?: string;
1014
+ typeMatchValid?: boolean;
884
1015
  disabled?: boolean;
885
1016
  height?: string;
886
1017
  stepActive?: string | number;
@@ -904,7 +1035,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
904
1035
  "onField-input"?: ((...args: any[]) => any) | undefined;
905
1036
  "onField-change"?: ((...args: any[]) => any) | undefined;
906
1037
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
907
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1038
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
908
1039
  values: schema_d_exports.FormValue;
909
1040
  lastValuesProcessed: schema_d_exports.FormValue;
910
1041
  formState: schema_d_exports.FormState;
@@ -913,6 +1044,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
913
1044
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
914
1045
  resetForm: () => void;
915
1046
  submitForm: (native?: boolean) => Promise<any>;
1047
+ validate: () => Promise<string>;
916
1048
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
917
1049
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
918
1050
  $slots: import("@tmagic/editor").FormSlots;
@@ -926,6 +1058,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
926
1058
  readonly isCompare?: boolean | undefined;
927
1059
  readonly parentValues?: Record<string, any> | undefined;
928
1060
  readonly labelWidth?: string | undefined;
1061
+ readonly typeMatchValid?: boolean | undefined;
929
1062
  readonly disabled?: boolean | undefined;
930
1063
  readonly height?: string | undefined;
931
1064
  readonly stepActive?: string | number | undefined;
@@ -968,6 +1101,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
968
1101
  isCompare?: boolean;
969
1102
  parentValues?: Record<string, any>;
970
1103
  labelWidth?: string;
1104
+ typeMatchValid?: boolean;
971
1105
  disabled?: boolean;
972
1106
  height?: string;
973
1107
  stepActive?: string | number;
@@ -1000,6 +1134,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1000
1134
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1001
1135
  resetForm: () => void;
1002
1136
  submitForm: (native?: boolean) => Promise<any>;
1137
+ validate: () => Promise<string>;
1003
1138
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1004
1139
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
1005
1140
  error: (...args: any[]) => void;
@@ -1062,6 +1197,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1062
1197
  isCompare?: boolean;
1063
1198
  parentValues?: Record<string, any>;
1064
1199
  labelWidth?: string;
1200
+ typeMatchValid?: boolean;
1065
1201
  disabled?: boolean;
1066
1202
  height?: string;
1067
1203
  stepActive?: string | number;
@@ -1085,7 +1221,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1085
1221
  "onField-input"?: ((...args: any[]) => any) | undefined;
1086
1222
  "onField-change"?: ((...args: any[]) => any) | undefined;
1087
1223
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
1088
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1224
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1089
1225
  values: schema_d_exports.FormValue;
1090
1226
  lastValuesProcessed: schema_d_exports.FormValue;
1091
1227
  formState: schema_d_exports.FormState;
@@ -1094,6 +1230,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1094
1230
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1095
1231
  resetForm: () => void;
1096
1232
  submitForm: (native?: boolean) => Promise<any>;
1233
+ validate: () => Promise<string>;
1097
1234
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1098
1235
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
1099
1236
  $slots: import("@tmagic/editor").FormSlots;
@@ -1141,7 +1278,8 @@ type __VLS_Props$27 = {
1141
1278
  parentValues?: Object;
1142
1279
  width?: number;
1143
1280
  height?: number;
1144
- labelWidth?: string;
1281
+ labelWidth?: string; /** 是否开启类型匹配校验 */
1282
+ typeMatchValid?: boolean;
1145
1283
  disabled?: boolean;
1146
1284
  size?: 'small' | 'default' | 'large';
1147
1285
  confirmText?: string;
@@ -1151,7 +1289,7 @@ type __VLS_Props$27 = {
1151
1289
  useFieldTextInError?: boolean;
1152
1290
  extendState?: (_state: schema_d_exports.FormState) => Record<string, any> | Promise<Record<string, any>>;
1153
1291
  };
1154
- declare var __VLS_16$1: {}, __VLS_18$1: {}, __VLS_20: {};
1292
+ declare var __VLS_16$1: {}, __VLS_18: {}, __VLS_20: {};
1155
1293
  type __VLS_Slots$2 = {} & {
1156
1294
  default?: (props: typeof __VLS_16$1) => any;
1157
1295
  } & {
@@ -1170,6 +1308,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1170
1308
  readonly isCompare?: boolean | undefined;
1171
1309
  readonly parentValues?: Record<string, any> | undefined;
1172
1310
  readonly labelWidth?: string | undefined;
1311
+ readonly typeMatchValid?: boolean | undefined;
1173
1312
  readonly disabled?: boolean | undefined;
1174
1313
  readonly height?: string | undefined;
1175
1314
  readonly stepActive?: string | number | undefined;
@@ -1212,6 +1351,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1212
1351
  isCompare?: boolean;
1213
1352
  parentValues?: Record<string, any>;
1214
1353
  labelWidth?: string;
1354
+ typeMatchValid?: boolean;
1215
1355
  disabled?: boolean;
1216
1356
  height?: string;
1217
1357
  stepActive?: string | number;
@@ -1244,6 +1384,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1244
1384
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1245
1385
  resetForm: () => void;
1246
1386
  submitForm: (native?: boolean) => Promise<any>;
1387
+ validate: () => Promise<string>;
1247
1388
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1248
1389
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
1249
1390
  error: (...args: any[]) => void;
@@ -1306,6 +1447,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1306
1447
  isCompare?: boolean;
1307
1448
  parentValues?: Record<string, any>;
1308
1449
  labelWidth?: string;
1450
+ typeMatchValid?: boolean;
1309
1451
  disabled?: boolean;
1310
1452
  height?: string;
1311
1453
  stepActive?: string | number;
@@ -1329,7 +1471,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1329
1471
  "onField-input"?: ((...args: any[]) => any) | undefined;
1330
1472
  "onField-change"?: ((...args: any[]) => any) | undefined;
1331
1473
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
1332
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1474
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1333
1475
  values: schema_d_exports.FormValue;
1334
1476
  lastValuesProcessed: schema_d_exports.FormValue;
1335
1477
  formState: schema_d_exports.FormState;
@@ -1338,6 +1480,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1338
1480
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1339
1481
  resetForm: () => void;
1340
1482
  submitForm: (native?: boolean) => Promise<any>;
1483
+ validate: () => Promise<string>;
1341
1484
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1342
1485
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
1343
1486
  $slots: import("@tmagic/editor").FormSlots;
@@ -1351,6 +1494,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1351
1494
  readonly isCompare?: boolean | undefined;
1352
1495
  readonly parentValues?: Record<string, any> | undefined;
1353
1496
  readonly labelWidth?: string | undefined;
1497
+ readonly typeMatchValid?: boolean | undefined;
1354
1498
  readonly disabled?: boolean | undefined;
1355
1499
  readonly height?: string | undefined;
1356
1500
  readonly stepActive?: string | number | undefined;
@@ -1393,6 +1537,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1393
1537
  isCompare?: boolean;
1394
1538
  parentValues?: Record<string, any>;
1395
1539
  labelWidth?: string;
1540
+ typeMatchValid?: boolean;
1396
1541
  disabled?: boolean;
1397
1542
  height?: string;
1398
1543
  stepActive?: string | number;
@@ -1425,6 +1570,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1425
1570
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1426
1571
  resetForm: () => void;
1427
1572
  submitForm: (native?: boolean) => Promise<any>;
1573
+ validate: () => Promise<string>;
1428
1574
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1429
1575
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
1430
1576
  error: (...args: any[]) => void;
@@ -1487,6 +1633,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1487
1633
  isCompare?: boolean;
1488
1634
  parentValues?: Record<string, any>;
1489
1635
  labelWidth?: string;
1636
+ typeMatchValid?: boolean;
1490
1637
  disabled?: boolean;
1491
1638
  height?: string;
1492
1639
  stepActive?: string | number;
@@ -1510,7 +1657,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1510
1657
  "onField-input"?: ((...args: any[]) => any) | undefined;
1511
1658
  "onField-change"?: ((...args: any[]) => any) | undefined;
1512
1659
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
1513
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1660
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1514
1661
  values: schema_d_exports.FormValue;
1515
1662
  lastValuesProcessed: schema_d_exports.FormValue;
1516
1663
  formState: schema_d_exports.FormState;
@@ -1519,6 +1666,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1519
1666
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1520
1667
  resetForm: () => void;
1521
1668
  submitForm: (native?: boolean) => Promise<any>;
1669
+ validate: () => Promise<string>;
1522
1670
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1523
1671
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
1524
1672
  $slots: import("@tmagic/editor").FormSlots;
@@ -1959,16 +2107,39 @@ declare const registerField: (tagName: string, component: Component) => void;
1959
2107
  declare const getField: (tagName: string) => Component | undefined;
1960
2108
  declare const deleteField: (tagName: string) => boolean;
1961
2109
  //#endregion
2110
+ //#region temp/packages/form/src/utils/typeMatch.d.ts
2111
+ interface TypeMatchValidateContext {
2112
+ fieldType: string;
2113
+ mForm: schema_d_exports.FormState | undefined;
2114
+ props: any;
2115
+ message?: string;
2116
+ }
2117
+ /** 自定义 type 校验器:返回错误文案;通过则返回 undefined */
2118
+ type TypeMatchValidator = (value: any, context: TypeMatchValidateContext) => string | undefined;
2119
+ /** 注册或覆盖某个字段 type 的 typeMatch 校验规则 */
2120
+ declare const registerTypeMatchRule: (type: string, validator: TypeMatchValidator) => void;
2121
+ /** 批量注册 typeMatch 校验规则 */
2122
+ declare const registerTypeMatchRules: (rules: Record<string, TypeMatchValidator>) => void;
2123
+ /** 获取某个字段 type 的自定义 typeMatch 校验规则 */
2124
+ declare const getTypeMatchRule: (type: string) => TypeMatchValidator | undefined;
2125
+ /** 删除某个字段 type 的自定义 typeMatch 校验规则 */
2126
+ declare const deleteTypeMatchRule: (type: string) => boolean;
2127
+ /** 清空所有自定义 typeMatch 校验规则 */
2128
+ declare const clearTypeMatchRules: () => void;
2129
+ declare const validateTypeMatch: (value: any, mForm: schema_d_exports.FormState | undefined, props: any, message?: string) => string | undefined;
2130
+ //#endregion
1962
2131
  //#region temp/packages/form/src/plugin.d.ts
1963
2132
  interface FormInstallOptions {
2133
+ /** 自定义字段 type 的 typeMatch 校验规则,可覆盖内置规则或扩展业务字段 */
2134
+ typeMatchRules?: Record<string, TypeMatchValidator>;
1964
2135
  [key: string]: any;
1965
2136
  }
1966
2137
  declare const _default$31: {
1967
2138
  install(app: App, opt?: FormInstallOptions): void;
1968
2139
  };
1969
2140
  declare namespace index_d_exports {
1970
- export { ChangeRecord, ContainerChangeEventData, FORM_DIFF_CONFIG_KEY, FormDiffConfig, FormInstallOptions, FormLabelSlotProps, FormSlots, _default as MCascader, _default$1 as MCheckbox, _default$2 as MCheckboxGroup, _default$3 as MColorPicker, _default$4 as MContainer, _default$5 as MDate, _default$6 as MDateTime, _default$7 as MDaterange, _default$8 as MDisplay, _default$9 as MDynamicField, _default$10 as MFieldset, _default$11 as MFlexLayout, _default$12 as MForm, _default$13 as MFormBox, _default$14 as MFormDialog, _default$15 as MFormDrawer, _default$16 as MGroupList, _default$17 as MHidden, _default$18 as MLink, _default$19 as MNumber, _default$20 as MNumberRange, _default$21 as MPanel, _default$22 as MRadioGroup, _default$23 as MRow, _default$24 as MSelect, _default$25 as MSwitch, _default$16 as MTable, _default$16 as MTableGroupList, _default$26 as MTabs, _default$27 as MText, _default$28 as MTextarea, _default$29 as MTime, _default$30 as MTimerange, SubmitFormOptions, SubmitFormResult, ValidateError, createForm, createObjectProp, createValues, datetimeFormatter, _default$31 as default, deleteField as deleteFormField, display, filterFunction, getDataByPage, getField as getFormField, getRules, initValue, registerField as registerFormField, sortArray, sortChange, submitForm, useAddField };
2141
+ export { ChangeRecord, ContainerChangeEventData, FORM_DIFF_CONFIG_KEY, FORM_TYPE_MATCH_VALID_KEY, FormDiffConfig, FormInstallOptions, FormLabelSlotProps, FormSlots, _default as MCascader, _default$1 as MCheckbox, _default$2 as MCheckboxGroup, _default$3 as MColorPicker, _default$4 as MContainer, _default$5 as MDate, _default$6 as MDateTime, _default$7 as MDaterange, _default$8 as MDisplay, _default$9 as MDynamicField, _default$10 as MFieldset, _default$11 as MFlexLayout, _default$12 as MForm, _default$13 as MFormBox, _default$14 as MFormDialog, _default$15 as MFormDrawer, _default$16 as MGroupList, _default$17 as MHidden, _default$18 as MLink, _default$19 as MNumber, _default$20 as MNumberRange, _default$21 as MPanel, _default$22 as MRadioGroup, _default$23 as MRow, _default$24 as MSelect, _default$25 as MSwitch, _default$16 as MTable, _default$16 as MTableGroupList, _default$26 as MTabs, _default$27 as MText, _default$28 as MTextarea, _default$29 as MTime, _default$30 as MTimerange, SubmitFormOptions, SubmitFormResult, TypeMatchValidateContext, TypeMatchValidator, ValidateError, ValidateFormOptions, adaptFormValidator, clearTypeMatchRules, createForm, createObjectProp, createValues, datetimeFormatter, _default$31 as default, deleteField as deleteFormField, deleteTypeMatchRule, display, filterFunction, getDataByPage, getField as getFormField, getRules, getTypeMatchRule, initValue, registerField as registerFormField, registerTypeMatchRule, registerTypeMatchRules, sortArray, sortChange, submitForm, useAddField, validateForm, validateTypeMatch };
1971
2142
  }
1972
2143
  declare const createForm: <T extends [] = []>(config: schema_d_exports.FormConfig | T) => schema_d_exports.FormConfig | T;
1973
2144
  //#endregion
1974
- export { ChangeRecord, ContainerChangeEventData, FORM_DIFF_CONFIG_KEY, FormDiffConfig, type FormInstallOptions, FormLabelSlotProps, FormSlots, _default as MCascader, _default$1 as MCheckbox, _default$2 as MCheckboxGroup, _default$3 as MColorPicker, _default$4 as MContainer, _default$5 as MDate, _default$6 as MDateTime, _default$7 as MDaterange, _default$8 as MDisplay, _default$9 as MDynamicField, _default$10 as MFieldset, _default$11 as MFlexLayout, _default$12 as MForm, _default$13 as MFormBox, _default$14 as MFormDialog, _default$15 as MFormDrawer, _default$16 as MGroupList, _default$16 as MTable, _default$16 as MTableGroupList, _default$17 as MHidden, _default$18 as MLink, _default$19 as MNumber, _default$20 as MNumberRange, _default$21 as MPanel, _default$22 as MRadioGroup, _default$23 as MRow, _default$24 as MSelect, _default$25 as MSwitch, _default$26 as MTabs, _default$27 as MText, _default$28 as MTextarea, _default$29 as MTime, _default$30 as MTimerange, SubmitFormOptions, SubmitFormResult, ValidateError, createForm, createObjectProp, createValues, datetimeFormatter, _default$31 as default, deleteField as deleteFormField, display, filterFunction, getDataByPage, getField as getFormField, getRules, initValue, registerField as registerFormField, sortArray, sortChange, submitForm, useAddField };
2145
+ export { ChangeRecord, ContainerChangeEventData, FORM_DIFF_CONFIG_KEY, FORM_TYPE_MATCH_VALID_KEY, FormDiffConfig, type FormInstallOptions, FormLabelSlotProps, FormSlots, _default as MCascader, _default$1 as MCheckbox, _default$2 as MCheckboxGroup, _default$3 as MColorPicker, _default$4 as MContainer, _default$5 as MDate, _default$6 as MDateTime, _default$7 as MDaterange, _default$8 as MDisplay, _default$9 as MDynamicField, _default$10 as MFieldset, _default$11 as MFlexLayout, _default$12 as MForm, _default$13 as MFormBox, _default$14 as MFormDialog, _default$15 as MFormDrawer, _default$16 as MGroupList, _default$16 as MTable, _default$16 as MTableGroupList, _default$17 as MHidden, _default$18 as MLink, _default$19 as MNumber, _default$20 as MNumberRange, _default$21 as MPanel, _default$22 as MRadioGroup, _default$23 as MRow, _default$24 as MSelect, _default$25 as MSwitch, _default$26 as MTabs, _default$27 as MText, _default$28 as MTextarea, _default$29 as MTime, _default$30 as MTimerange, SubmitFormOptions, SubmitFormResult, type TypeMatchValidateContext, type TypeMatchValidator, ValidateError, ValidateFormOptions, adaptFormValidator, clearTypeMatchRules, createForm, createObjectProp, createValues, datetimeFormatter, _default$31 as default, deleteField as deleteFormField, deleteTypeMatchRule, display, filterFunction, getDataByPage, getField as getFormField, getRules, getTypeMatchRule, initValue, registerField as registerFormField, registerTypeMatchRule, registerTypeMatchRules, sortArray, sortChange, submitForm, useAddField, validateForm, validateTypeMatch };