@tmagic/form 1.8.0-beta.11 → 1.8.0-beta.13

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;
@@ -116,9 +117,10 @@ interface SubmitFormOptions {
116
117
  * 调试模式下 `timeout` 不生效(等待人工操作)。
117
118
  */
118
119
  debug?: boolean;
120
+ typeMatchValid?: boolean;
119
121
  }
120
122
  /**
121
- * 开启 `returnChangeRecords` 时 submitForm 的返回结果
123
+ * 开启 `returnChangeNodes` 时 submitForm 的返回结果
122
124
  */
123
125
  interface SubmitFormResult {
124
126
  /** 校验通过后的表单值 */
@@ -163,12 +165,99 @@ interface SubmitFormResult {
163
165
  * ```
164
166
  */
165
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
+ * 返回一份去除了 tab 标签页 lazy 的配置副本。
205
+ *
206
+ * tab 容器开启 lazy 时,非激活标签页的内容不会渲染,导致 validateForm 静默挂载后
207
+ * 无法校验到这些标签页内的字段。校验场景需要一次性渲染全部字段,故在此统一去除 lazy。
208
+ * 处理基于深拷贝,不会污染调用方传入的原始 config。
209
+ */
210
+ declare const stripTabItemsLazy: (config: schema_d_exports.FormConfig) => schema_d_exports.FormConfig;
211
+ /**
212
+ * 以命令式方式对一份「表单配置 + 值」做一次静默校验,**不依赖也不影响任何已渲染的表单**。
213
+ *
214
+ * 与 `submitForm` 类似,内部会临时挂载一个不可见的 MForm 实例,等待其初始化完成后调用
215
+ * 实例的 `validate` 方法,返回汇总后的错误文案,随后自动卸载实例。
216
+ *
217
+ * 与 `submitForm` 的区别:
218
+ * - 「静默」:校验失败不抛异常、不触发 `error` 事件、不返回表单值;
219
+ * - 仅用于「探测」配置是否合法,适合源码保存后校验、批量校验组件配置等场景。
220
+ *
221
+ * 由于每次都新建一个独立的 MForm 实例,调用方无需持有任何表单 ref,也不会污染
222
+ * 页面上正在展示的表单状态。
223
+ *
224
+ * @returns 校验通过返回空字符串 `''`,否则返回以 `<br>` 拼接的错误文案。
225
+ * 仅在初始化超时或挂载失败等异常情况下才会 reject。
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * import { validateForm } from '@tmagic/form';
230
+ *
231
+ * const error = await validateForm({
232
+ * config: [...],
233
+ * initValues: { name: 'foo' },
234
+ * appContext: getCurrentInstance()?.appContext,
235
+ * });
236
+ * if (error) {
237
+ * // 配置不合法,error 为错误文案
238
+ * }
239
+ *
240
+ * // 调试模式:可见地渲染表单,点击「确定」才校验,校验失败保留弹层可修正重试:
241
+ * const error = await validateForm({
242
+ * config: [...],
243
+ * initValues: { name: 'foo' },
244
+ * debug: true,
245
+ * });
246
+ * ```
247
+ */
248
+ declare const validateForm: (options: ValidateFormOptions) => Promise<string>;
166
249
  //#endregion
167
250
  //#region temp/packages/form/src/utils/form.d.ts
251
+ type AsyncValidatorFn = (rule: any, value: any, callback: Function, source?: any, options?: any) => any;
252
+ /**
253
+ * 将 async-validator(Element Plus)风格的 validator 适配到当前 UI 库。
254
+ * TDesign 调用签名为 `(val) => boolean | CustomValidateObj | Promise`,无 callback。
255
+ */
256
+ declare const adaptFormValidator: (validator: AsyncValidatorFn) => AsyncValidatorFn;
168
257
  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;
169
258
  declare const filterFunction: <T = any>(mForm: schema_d_exports.FormState | undefined, config: T | schema_d_exports.FilterFunction<T> | undefined, props: any) => T | undefined;
170
259
  declare const display: (mForm: schema_d_exports.FormState | undefined, config: any, props: any) => any;
171
- 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[];
260
+ 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[];
172
261
  declare const initValue: (mForm: schema_d_exports.FormState | undefined, {
173
262
  initValues,
174
263
  config
@@ -196,7 +285,8 @@ type __VLS_Props$30 = {
196
285
  lastValues?: Record<string, any>; /** 是否开启对比模式 */
197
286
  isCompare?: boolean;
198
287
  parentValues?: Record<string, any>;
199
- labelWidth?: string;
288
+ labelWidth?: string; /** 是否开启类型匹配校验 */
289
+ typeMatchValid?: boolean;
200
290
  disabled?: boolean;
201
291
  height?: string;
202
292
  stepActive?: string | number;
@@ -255,6 +345,23 @@ declare const __VLS_base$5: import("@vue/runtime-core").DefineComponent<__VLS_Pr
255
345
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
256
346
  resetForm: () => void;
257
347
  submitForm: (native?: boolean) => Promise<any>;
348
+ /**
349
+ * 校验:对表单当前值执行校验,返回汇总后的错误文案。
350
+ *
351
+ * 与 `submitForm` 的区别:
352
+ * - 校验失败时不抛异常、不触发 `error` 事件,而是以返回值形式给出错误文案;
353
+ * - 不重置 `changeRecords`,不改变提交语义,仅用于「探测」当前配置是否合法。
354
+ *
355
+ * 注意:本方法只改变「校验结果的返回方式」,并不负责「不污染页面表单状态」——
356
+ * 若需对一份独立的「配置 + 值」做完全不影响页面上已渲染表单的校验,请使用 `validateForm`
357
+ * (内部会新建一个隐藏的 MForm 实例,通过 `initValues` 传入待校验值,用完即卸载)。
358
+ *
359
+ * 典型用途:作为 `validateForm` 内部复用的校验实现;也可在已渲染的表单实例上主动调用,
360
+ * 根据返回的错误文案自行决定后续处理(如记录节点错误状态)。
361
+ *
362
+ * @returns 校验通过返回空字符串 `''`,否则返回以 `<br>` 拼接的错误文案。
363
+ */
364
+ validate: () => Promise<string>;
258
365
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
259
366
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
260
367
  error: (...args: any[]) => void;
@@ -297,7 +404,8 @@ type __VLS_Props$29 = {
297
404
  values?: Object;
298
405
  parentValues?: Object;
299
406
  width?: string | number;
300
- labelWidth?: string;
407
+ labelWidth?: string; /** 是否开启类型匹配校验 */
408
+ typeMatchValid?: boolean;
301
409
  fullscreen?: boolean;
302
410
  disabled?: boolean;
303
411
  title?: string;
@@ -334,6 +442,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
334
442
  readonly isCompare?: boolean | undefined;
335
443
  readonly parentValues?: Record<string, any> | undefined;
336
444
  readonly labelWidth?: string | undefined;
445
+ readonly typeMatchValid?: boolean | undefined;
337
446
  readonly disabled?: boolean | undefined;
338
447
  readonly height?: string | undefined;
339
448
  readonly stepActive?: string | number | undefined;
@@ -376,6 +485,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
376
485
  isCompare?: boolean;
377
486
  parentValues?: Record<string, any>;
378
487
  labelWidth?: string;
488
+ typeMatchValid?: boolean;
379
489
  disabled?: boolean;
380
490
  height?: string;
381
491
  stepActive?: string | number;
@@ -408,6 +518,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
408
518
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
409
519
  resetForm: () => void;
410
520
  submitForm: (native?: boolean) => Promise<any>;
521
+ validate: () => Promise<string>;
411
522
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
412
523
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
413
524
  error: (...args: any[]) => void;
@@ -470,6 +581,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
470
581
  isCompare?: boolean;
471
582
  parentValues?: Record<string, any>;
472
583
  labelWidth?: string;
584
+ typeMatchValid?: boolean;
473
585
  disabled?: boolean;
474
586
  height?: string;
475
587
  stepActive?: string | number;
@@ -493,7 +605,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
493
605
  "onField-input"?: ((...args: any[]) => any) | undefined;
494
606
  "onField-change"?: ((...args: any[]) => any) | undefined;
495
607
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
496
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
608
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
497
609
  values: schema_d_exports.FormValue;
498
610
  lastValuesProcessed: schema_d_exports.FormValue;
499
611
  formState: schema_d_exports.FormState;
@@ -502,6 +614,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
502
614
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
503
615
  resetForm: () => void;
504
616
  submitForm: (native?: boolean) => Promise<any>;
617
+ validate: () => Promise<string>;
505
618
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
506
619
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
507
620
  $slots: import("@tmagic/editor").FormSlots;
@@ -515,6 +628,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
515
628
  readonly isCompare?: boolean | undefined;
516
629
  readonly parentValues?: Record<string, any> | undefined;
517
630
  readonly labelWidth?: string | undefined;
631
+ readonly typeMatchValid?: boolean | undefined;
518
632
  readonly disabled?: boolean | undefined;
519
633
  readonly height?: string | undefined;
520
634
  readonly stepActive?: string | number | undefined;
@@ -557,6 +671,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
557
671
  isCompare?: boolean;
558
672
  parentValues?: Record<string, any>;
559
673
  labelWidth?: string;
674
+ typeMatchValid?: boolean;
560
675
  disabled?: boolean;
561
676
  height?: string;
562
677
  stepActive?: string | number;
@@ -589,6 +704,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
589
704
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
590
705
  resetForm: () => void;
591
706
  submitForm: (native?: boolean) => Promise<any>;
707
+ validate: () => Promise<string>;
592
708
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
593
709
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
594
710
  error: (...args: any[]) => void;
@@ -651,6 +767,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
651
767
  isCompare?: boolean;
652
768
  parentValues?: Record<string, any>;
653
769
  labelWidth?: string;
770
+ typeMatchValid?: boolean;
654
771
  disabled?: boolean;
655
772
  height?: string;
656
773
  stepActive?: string | number;
@@ -674,7 +791,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
674
791
  "onField-input"?: ((...args: any[]) => any) | undefined;
675
792
  "onField-change"?: ((...args: any[]) => any) | undefined;
676
793
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
677
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
794
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
678
795
  values: schema_d_exports.FormValue;
679
796
  lastValuesProcessed: schema_d_exports.FormValue;
680
797
  formState: schema_d_exports.FormState;
@@ -683,6 +800,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
683
800
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
684
801
  resetForm: () => void;
685
802
  submitForm: (native?: boolean) => Promise<any>;
803
+ validate: () => Promise<string>;
686
804
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
687
805
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
688
806
  $slots: import("@tmagic/editor").FormSlots;
@@ -728,7 +846,8 @@ type __VLS_Props$28 = {
728
846
  values?: Object;
729
847
  parentValues?: Object;
730
848
  width?: string | number;
731
- labelWidth?: string;
849
+ labelWidth?: string; /** 是否开启类型匹配校验 */
850
+ typeMatchValid?: boolean;
732
851
  disabled?: boolean;
733
852
  closeOnPressEscape?: boolean;
734
853
  title?: string;
@@ -761,6 +880,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
761
880
  readonly isCompare?: boolean | undefined;
762
881
  readonly parentValues?: Record<string, any> | undefined;
763
882
  readonly labelWidth?: string | undefined;
883
+ readonly typeMatchValid?: boolean | undefined;
764
884
  readonly disabled?: boolean | undefined;
765
885
  readonly height?: string | undefined;
766
886
  readonly stepActive?: string | number | undefined;
@@ -803,6 +923,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
803
923
  isCompare?: boolean;
804
924
  parentValues?: Record<string, any>;
805
925
  labelWidth?: string;
926
+ typeMatchValid?: boolean;
806
927
  disabled?: boolean;
807
928
  height?: string;
808
929
  stepActive?: string | number;
@@ -835,6 +956,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
835
956
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
836
957
  resetForm: () => void;
837
958
  submitForm: (native?: boolean) => Promise<any>;
959
+ validate: () => Promise<string>;
838
960
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
839
961
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
840
962
  error: (...args: any[]) => void;
@@ -897,6 +1019,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
897
1019
  isCompare?: boolean;
898
1020
  parentValues?: Record<string, any>;
899
1021
  labelWidth?: string;
1022
+ typeMatchValid?: boolean;
900
1023
  disabled?: boolean;
901
1024
  height?: string;
902
1025
  stepActive?: string | number;
@@ -920,7 +1043,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
920
1043
  "onField-input"?: ((...args: any[]) => any) | undefined;
921
1044
  "onField-change"?: ((...args: any[]) => any) | undefined;
922
1045
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
923
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1046
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
924
1047
  values: schema_d_exports.FormValue;
925
1048
  lastValuesProcessed: schema_d_exports.FormValue;
926
1049
  formState: schema_d_exports.FormState;
@@ -929,6 +1052,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
929
1052
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
930
1053
  resetForm: () => void;
931
1054
  submitForm: (native?: boolean) => Promise<any>;
1055
+ validate: () => Promise<string>;
932
1056
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
933
1057
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
934
1058
  $slots: import("@tmagic/editor").FormSlots;
@@ -942,6 +1066,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
942
1066
  readonly isCompare?: boolean | undefined;
943
1067
  readonly parentValues?: Record<string, any> | undefined;
944
1068
  readonly labelWidth?: string | undefined;
1069
+ readonly typeMatchValid?: boolean | undefined;
945
1070
  readonly disabled?: boolean | undefined;
946
1071
  readonly height?: string | undefined;
947
1072
  readonly stepActive?: string | number | undefined;
@@ -984,6 +1109,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
984
1109
  isCompare?: boolean;
985
1110
  parentValues?: Record<string, any>;
986
1111
  labelWidth?: string;
1112
+ typeMatchValid?: boolean;
987
1113
  disabled?: boolean;
988
1114
  height?: string;
989
1115
  stepActive?: string | number;
@@ -1016,6 +1142,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1016
1142
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1017
1143
  resetForm: () => void;
1018
1144
  submitForm: (native?: boolean) => Promise<any>;
1145
+ validate: () => Promise<string>;
1019
1146
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1020
1147
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
1021
1148
  error: (...args: any[]) => void;
@@ -1078,6 +1205,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1078
1205
  isCompare?: boolean;
1079
1206
  parentValues?: Record<string, any>;
1080
1207
  labelWidth?: string;
1208
+ typeMatchValid?: boolean;
1081
1209
  disabled?: boolean;
1082
1210
  height?: string;
1083
1211
  stepActive?: string | number;
@@ -1101,7 +1229,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1101
1229
  "onField-input"?: ((...args: any[]) => any) | undefined;
1102
1230
  "onField-change"?: ((...args: any[]) => any) | undefined;
1103
1231
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
1104
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1232
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1105
1233
  values: schema_d_exports.FormValue;
1106
1234
  lastValuesProcessed: schema_d_exports.FormValue;
1107
1235
  formState: schema_d_exports.FormState;
@@ -1110,6 +1238,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1110
1238
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1111
1239
  resetForm: () => void;
1112
1240
  submitForm: (native?: boolean) => Promise<any>;
1241
+ validate: () => Promise<string>;
1113
1242
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1114
1243
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
1115
1244
  $slots: import("@tmagic/editor").FormSlots;
@@ -1157,7 +1286,8 @@ type __VLS_Props$27 = {
1157
1286
  parentValues?: Object;
1158
1287
  width?: number;
1159
1288
  height?: number;
1160
- labelWidth?: string;
1289
+ labelWidth?: string; /** 是否开启类型匹配校验 */
1290
+ typeMatchValid?: boolean;
1161
1291
  disabled?: boolean;
1162
1292
  size?: 'small' | 'default' | 'large';
1163
1293
  confirmText?: string;
@@ -1167,7 +1297,7 @@ type __VLS_Props$27 = {
1167
1297
  useFieldTextInError?: boolean;
1168
1298
  extendState?: (_state: schema_d_exports.FormState) => Record<string, any> | Promise<Record<string, any>>;
1169
1299
  };
1170
- declare var __VLS_16$1: {}, __VLS_18$1: {}, __VLS_20: {};
1300
+ declare var __VLS_16$1: {}, __VLS_18: {}, __VLS_20: {};
1171
1301
  type __VLS_Slots$2 = {} & {
1172
1302
  default?: (props: typeof __VLS_16$1) => any;
1173
1303
  } & {
@@ -1186,6 +1316,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1186
1316
  readonly isCompare?: boolean | undefined;
1187
1317
  readonly parentValues?: Record<string, any> | undefined;
1188
1318
  readonly labelWidth?: string | undefined;
1319
+ readonly typeMatchValid?: boolean | undefined;
1189
1320
  readonly disabled?: boolean | undefined;
1190
1321
  readonly height?: string | undefined;
1191
1322
  readonly stepActive?: string | number | undefined;
@@ -1228,6 +1359,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1228
1359
  isCompare?: boolean;
1229
1360
  parentValues?: Record<string, any>;
1230
1361
  labelWidth?: string;
1362
+ typeMatchValid?: boolean;
1231
1363
  disabled?: boolean;
1232
1364
  height?: string;
1233
1365
  stepActive?: string | number;
@@ -1260,6 +1392,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1260
1392
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1261
1393
  resetForm: () => void;
1262
1394
  submitForm: (native?: boolean) => Promise<any>;
1395
+ validate: () => Promise<string>;
1263
1396
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1264
1397
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
1265
1398
  error: (...args: any[]) => void;
@@ -1322,6 +1455,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1322
1455
  isCompare?: boolean;
1323
1456
  parentValues?: Record<string, any>;
1324
1457
  labelWidth?: string;
1458
+ typeMatchValid?: boolean;
1325
1459
  disabled?: boolean;
1326
1460
  height?: string;
1327
1461
  stepActive?: string | number;
@@ -1345,7 +1479,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1345
1479
  "onField-input"?: ((...args: any[]) => any) | undefined;
1346
1480
  "onField-change"?: ((...args: any[]) => any) | undefined;
1347
1481
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
1348
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1482
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1349
1483
  values: schema_d_exports.FormValue;
1350
1484
  lastValuesProcessed: schema_d_exports.FormValue;
1351
1485
  formState: schema_d_exports.FormState;
@@ -1354,6 +1488,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1354
1488
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1355
1489
  resetForm: () => void;
1356
1490
  submitForm: (native?: boolean) => Promise<any>;
1491
+ validate: () => Promise<string>;
1357
1492
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1358
1493
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
1359
1494
  $slots: import("@tmagic/editor").FormSlots;
@@ -1367,6 +1502,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1367
1502
  readonly isCompare?: boolean | undefined;
1368
1503
  readonly parentValues?: Record<string, any> | undefined;
1369
1504
  readonly labelWidth?: string | undefined;
1505
+ readonly typeMatchValid?: boolean | undefined;
1370
1506
  readonly disabled?: boolean | undefined;
1371
1507
  readonly height?: string | undefined;
1372
1508
  readonly stepActive?: string | number | undefined;
@@ -1409,6 +1545,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1409
1545
  isCompare?: boolean;
1410
1546
  parentValues?: Record<string, any>;
1411
1547
  labelWidth?: string;
1548
+ typeMatchValid?: boolean;
1412
1549
  disabled?: boolean;
1413
1550
  height?: string;
1414
1551
  stepActive?: string | number;
@@ -1441,6 +1578,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1441
1578
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1442
1579
  resetForm: () => void;
1443
1580
  submitForm: (native?: boolean) => Promise<any>;
1581
+ validate: () => Promise<string>;
1444
1582
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1445
1583
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
1446
1584
  error: (...args: any[]) => void;
@@ -1503,6 +1641,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1503
1641
  isCompare?: boolean;
1504
1642
  parentValues?: Record<string, any>;
1505
1643
  labelWidth?: string;
1644
+ typeMatchValid?: boolean;
1506
1645
  disabled?: boolean;
1507
1646
  height?: string;
1508
1647
  stepActive?: string | number;
@@ -1526,7 +1665,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1526
1665
  "onField-input"?: ((...args: any[]) => any) | undefined;
1527
1666
  "onField-change"?: ((...args: any[]) => any) | undefined;
1528
1667
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
1529
- }>, "values" | "changeHandler" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1668
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1530
1669
  values: schema_d_exports.FormValue;
1531
1670
  lastValuesProcessed: schema_d_exports.FormValue;
1532
1671
  formState: schema_d_exports.FormState;
@@ -1535,6 +1674,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1535
1674
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1536
1675
  resetForm: () => void;
1537
1676
  submitForm: (native?: boolean) => Promise<any>;
1677
+ validate: () => Promise<string>;
1538
1678
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1539
1679
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
1540
1680
  $slots: import("@tmagic/editor").FormSlots;
@@ -1975,16 +2115,39 @@ declare const registerField: (tagName: string, component: Component) => void;
1975
2115
  declare const getField: (tagName: string) => Component | undefined;
1976
2116
  declare const deleteField: (tagName: string) => boolean;
1977
2117
  //#endregion
2118
+ //#region temp/packages/form/src/utils/typeMatch.d.ts
2119
+ interface TypeMatchValidateContext {
2120
+ fieldType: string;
2121
+ mForm: schema_d_exports.FormState | undefined;
2122
+ props: any;
2123
+ message?: string;
2124
+ }
2125
+ /** 自定义 type 校验器:返回错误文案;通过则返回 undefined */
2126
+ type TypeMatchValidator = (value: any, context: TypeMatchValidateContext) => string | undefined;
2127
+ /** 注册或覆盖某个字段 type 的 typeMatch 校验规则 */
2128
+ declare const registerTypeMatchRule: (type: string, validator: TypeMatchValidator) => void;
2129
+ /** 批量注册 typeMatch 校验规则 */
2130
+ declare const registerTypeMatchRules: (rules: Record<string, TypeMatchValidator>) => void;
2131
+ /** 获取某个字段 type 的自定义 typeMatch 校验规则 */
2132
+ declare const getTypeMatchRule: (type: string) => TypeMatchValidator | undefined;
2133
+ /** 删除某个字段 type 的自定义 typeMatch 校验规则 */
2134
+ declare const deleteTypeMatchRule: (type: string) => boolean;
2135
+ /** 清空所有自定义 typeMatch 校验规则 */
2136
+ declare const clearTypeMatchRules: () => void;
2137
+ declare const validateTypeMatch: (value: any, mForm: schema_d_exports.FormState | undefined, props: any, message?: string) => string | undefined;
2138
+ //#endregion
1978
2139
  //#region temp/packages/form/src/plugin.d.ts
1979
2140
  interface FormInstallOptions {
2141
+ /** 自定义字段 type 的 typeMatch 校验规则,可覆盖内置规则或扩展业务字段 */
2142
+ typeMatchRules?: Record<string, TypeMatchValidator>;
1980
2143
  [key: string]: any;
1981
2144
  }
1982
2145
  declare const _default$31: {
1983
2146
  install(app: App, opt?: FormInstallOptions): void;
1984
2147
  };
1985
2148
  declare namespace index_d_exports {
1986
- 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 };
2149
+ 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, stripTabItemsLazy, submitForm, useAddField, validateForm, validateTypeMatch };
1987
2150
  }
1988
2151
  declare const createForm: <T extends [] = []>(config: schema_d_exports.FormConfig | T) => schema_d_exports.FormConfig | T;
1989
2152
  //#endregion
1990
- 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 };
2153
+ 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, stripTabItemsLazy, submitForm, useAddField, validateForm, validateTypeMatch };