@tmagic/form 1.8.0-beta.11 → 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;
@@ -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,91 @@ 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
+ * 以命令式方式对一份「表单配置 + 值」做一次静默校验,**不依赖也不影响任何已渲染的表单**。
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>;
166
241
  //#endregion
167
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;
168
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;
169
250
  declare const filterFunction: <T = any>(mForm: schema_d_exports.FormState | undefined, config: T | schema_d_exports.FilterFunction<T> | undefined, props: any) => T | undefined;
170
251
  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[];
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[];
172
253
  declare const initValue: (mForm: schema_d_exports.FormState | undefined, {
173
254
  initValues,
174
255
  config
@@ -196,7 +277,8 @@ type __VLS_Props$30 = {
196
277
  lastValues?: Record<string, any>; /** 是否开启对比模式 */
197
278
  isCompare?: boolean;
198
279
  parentValues?: Record<string, any>;
199
- labelWidth?: string;
280
+ labelWidth?: string; /** 是否开启类型匹配校验 */
281
+ typeMatchValid?: boolean;
200
282
  disabled?: boolean;
201
283
  height?: string;
202
284
  stepActive?: string | number;
@@ -255,6 +337,23 @@ declare const __VLS_base$5: import("@vue/runtime-core").DefineComponent<__VLS_Pr
255
337
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
256
338
  resetForm: () => void;
257
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>;
258
357
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
259
358
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
260
359
  error: (...args: any[]) => void;
@@ -297,7 +396,8 @@ type __VLS_Props$29 = {
297
396
  values?: Object;
298
397
  parentValues?: Object;
299
398
  width?: string | number;
300
- labelWidth?: string;
399
+ labelWidth?: string; /** 是否开启类型匹配校验 */
400
+ typeMatchValid?: boolean;
301
401
  fullscreen?: boolean;
302
402
  disabled?: boolean;
303
403
  title?: string;
@@ -334,6 +434,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
334
434
  readonly isCompare?: boolean | undefined;
335
435
  readonly parentValues?: Record<string, any> | undefined;
336
436
  readonly labelWidth?: string | undefined;
437
+ readonly typeMatchValid?: boolean | undefined;
337
438
  readonly disabled?: boolean | undefined;
338
439
  readonly height?: string | undefined;
339
440
  readonly stepActive?: string | number | undefined;
@@ -376,6 +477,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
376
477
  isCompare?: boolean;
377
478
  parentValues?: Record<string, any>;
378
479
  labelWidth?: string;
480
+ typeMatchValid?: boolean;
379
481
  disabled?: boolean;
380
482
  height?: string;
381
483
  stepActive?: string | number;
@@ -408,6 +510,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
408
510
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
409
511
  resetForm: () => void;
410
512
  submitForm: (native?: boolean) => Promise<any>;
513
+ validate: () => Promise<string>;
411
514
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
412
515
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
413
516
  error: (...args: any[]) => void;
@@ -470,6 +573,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
470
573
  isCompare?: boolean;
471
574
  parentValues?: Record<string, any>;
472
575
  labelWidth?: string;
576
+ typeMatchValid?: boolean;
473
577
  disabled?: boolean;
474
578
  height?: string;
475
579
  stepActive?: string | number;
@@ -493,7 +597,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
493
597
  "onField-input"?: ((...args: any[]) => any) | undefined;
494
598
  "onField-change"?: ((...args: any[]) => any) | undefined;
495
599
  "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")> & {
600
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
497
601
  values: schema_d_exports.FormValue;
498
602
  lastValuesProcessed: schema_d_exports.FormValue;
499
603
  formState: schema_d_exports.FormState;
@@ -502,6 +606,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
502
606
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
503
607
  resetForm: () => void;
504
608
  submitForm: (native?: boolean) => Promise<any>;
609
+ validate: () => Promise<string>;
505
610
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
506
611
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
507
612
  $slots: import("@tmagic/editor").FormSlots;
@@ -515,6 +620,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
515
620
  readonly isCompare?: boolean | undefined;
516
621
  readonly parentValues?: Record<string, any> | undefined;
517
622
  readonly labelWidth?: string | undefined;
623
+ readonly typeMatchValid?: boolean | undefined;
518
624
  readonly disabled?: boolean | undefined;
519
625
  readonly height?: string | undefined;
520
626
  readonly stepActive?: string | number | undefined;
@@ -557,6 +663,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
557
663
  isCompare?: boolean;
558
664
  parentValues?: Record<string, any>;
559
665
  labelWidth?: string;
666
+ typeMatchValid?: boolean;
560
667
  disabled?: boolean;
561
668
  height?: string;
562
669
  stepActive?: string | number;
@@ -589,6 +696,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
589
696
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
590
697
  resetForm: () => void;
591
698
  submitForm: (native?: boolean) => Promise<any>;
699
+ validate: () => Promise<string>;
592
700
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
593
701
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
594
702
  error: (...args: any[]) => void;
@@ -651,6 +759,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
651
759
  isCompare?: boolean;
652
760
  parentValues?: Record<string, any>;
653
761
  labelWidth?: string;
762
+ typeMatchValid?: boolean;
654
763
  disabled?: boolean;
655
764
  height?: string;
656
765
  stepActive?: string | number;
@@ -674,7 +783,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
674
783
  "onField-input"?: ((...args: any[]) => any) | undefined;
675
784
  "onField-change"?: ((...args: any[]) => any) | undefined;
676
785
  "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")> & {
786
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
678
787
  values: schema_d_exports.FormValue;
679
788
  lastValuesProcessed: schema_d_exports.FormValue;
680
789
  formState: schema_d_exports.FormState;
@@ -683,6 +792,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
683
792
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
684
793
  resetForm: () => void;
685
794
  submitForm: (native?: boolean) => Promise<any>;
795
+ validate: () => Promise<string>;
686
796
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
687
797
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
688
798
  $slots: import("@tmagic/editor").FormSlots;
@@ -728,7 +838,8 @@ type __VLS_Props$28 = {
728
838
  values?: Object;
729
839
  parentValues?: Object;
730
840
  width?: string | number;
731
- labelWidth?: string;
841
+ labelWidth?: string; /** 是否开启类型匹配校验 */
842
+ typeMatchValid?: boolean;
732
843
  disabled?: boolean;
733
844
  closeOnPressEscape?: boolean;
734
845
  title?: string;
@@ -761,6 +872,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
761
872
  readonly isCompare?: boolean | undefined;
762
873
  readonly parentValues?: Record<string, any> | undefined;
763
874
  readonly labelWidth?: string | undefined;
875
+ readonly typeMatchValid?: boolean | undefined;
764
876
  readonly disabled?: boolean | undefined;
765
877
  readonly height?: string | undefined;
766
878
  readonly stepActive?: string | number | undefined;
@@ -803,6 +915,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
803
915
  isCompare?: boolean;
804
916
  parentValues?: Record<string, any>;
805
917
  labelWidth?: string;
918
+ typeMatchValid?: boolean;
806
919
  disabled?: boolean;
807
920
  height?: string;
808
921
  stepActive?: string | number;
@@ -835,6 +948,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
835
948
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
836
949
  resetForm: () => void;
837
950
  submitForm: (native?: boolean) => Promise<any>;
951
+ validate: () => Promise<string>;
838
952
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
839
953
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
840
954
  error: (...args: any[]) => void;
@@ -897,6 +1011,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
897
1011
  isCompare?: boolean;
898
1012
  parentValues?: Record<string, any>;
899
1013
  labelWidth?: string;
1014
+ typeMatchValid?: boolean;
900
1015
  disabled?: boolean;
901
1016
  height?: string;
902
1017
  stepActive?: string | number;
@@ -920,7 +1035,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
920
1035
  "onField-input"?: ((...args: any[]) => any) | undefined;
921
1036
  "onField-change"?: ((...args: any[]) => any) | undefined;
922
1037
  "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")> & {
1038
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
924
1039
  values: schema_d_exports.FormValue;
925
1040
  lastValuesProcessed: schema_d_exports.FormValue;
926
1041
  formState: schema_d_exports.FormState;
@@ -929,6 +1044,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
929
1044
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
930
1045
  resetForm: () => void;
931
1046
  submitForm: (native?: boolean) => Promise<any>;
1047
+ validate: () => Promise<string>;
932
1048
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
933
1049
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
934
1050
  $slots: import("@tmagic/editor").FormSlots;
@@ -942,6 +1058,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
942
1058
  readonly isCompare?: boolean | undefined;
943
1059
  readonly parentValues?: Record<string, any> | undefined;
944
1060
  readonly labelWidth?: string | undefined;
1061
+ readonly typeMatchValid?: boolean | undefined;
945
1062
  readonly disabled?: boolean | undefined;
946
1063
  readonly height?: string | undefined;
947
1064
  readonly stepActive?: string | number | undefined;
@@ -984,6 +1101,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
984
1101
  isCompare?: boolean;
985
1102
  parentValues?: Record<string, any>;
986
1103
  labelWidth?: string;
1104
+ typeMatchValid?: boolean;
987
1105
  disabled?: boolean;
988
1106
  height?: string;
989
1107
  stepActive?: string | number;
@@ -1016,6 +1134,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1016
1134
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1017
1135
  resetForm: () => void;
1018
1136
  submitForm: (native?: boolean) => Promise<any>;
1137
+ validate: () => Promise<string>;
1019
1138
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1020
1139
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
1021
1140
  error: (...args: any[]) => void;
@@ -1078,6 +1197,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1078
1197
  isCompare?: boolean;
1079
1198
  parentValues?: Record<string, any>;
1080
1199
  labelWidth?: string;
1200
+ typeMatchValid?: boolean;
1081
1201
  disabled?: boolean;
1082
1202
  height?: string;
1083
1203
  stepActive?: string | number;
@@ -1101,7 +1221,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1101
1221
  "onField-input"?: ((...args: any[]) => any) | undefined;
1102
1222
  "onField-change"?: ((...args: any[]) => any) | undefined;
1103
1223
  "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")> & {
1224
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1105
1225
  values: schema_d_exports.FormValue;
1106
1226
  lastValuesProcessed: schema_d_exports.FormValue;
1107
1227
  formState: schema_d_exports.FormState;
@@ -1110,6 +1230,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1110
1230
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1111
1231
  resetForm: () => void;
1112
1232
  submitForm: (native?: boolean) => Promise<any>;
1233
+ validate: () => Promise<string>;
1113
1234
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1114
1235
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
1115
1236
  $slots: import("@tmagic/editor").FormSlots;
@@ -1157,7 +1278,8 @@ type __VLS_Props$27 = {
1157
1278
  parentValues?: Object;
1158
1279
  width?: number;
1159
1280
  height?: number;
1160
- labelWidth?: string;
1281
+ labelWidth?: string; /** 是否开启类型匹配校验 */
1282
+ typeMatchValid?: boolean;
1161
1283
  disabled?: boolean;
1162
1284
  size?: 'small' | 'default' | 'large';
1163
1285
  confirmText?: string;
@@ -1167,7 +1289,7 @@ type __VLS_Props$27 = {
1167
1289
  useFieldTextInError?: boolean;
1168
1290
  extendState?: (_state: schema_d_exports.FormState) => Record<string, any> | Promise<Record<string, any>>;
1169
1291
  };
1170
- declare var __VLS_16$1: {}, __VLS_18$1: {}, __VLS_20: {};
1292
+ declare var __VLS_16$1: {}, __VLS_18: {}, __VLS_20: {};
1171
1293
  type __VLS_Slots$2 = {} & {
1172
1294
  default?: (props: typeof __VLS_16$1) => any;
1173
1295
  } & {
@@ -1186,6 +1308,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1186
1308
  readonly isCompare?: boolean | undefined;
1187
1309
  readonly parentValues?: Record<string, any> | undefined;
1188
1310
  readonly labelWidth?: string | undefined;
1311
+ readonly typeMatchValid?: boolean | undefined;
1189
1312
  readonly disabled?: boolean | undefined;
1190
1313
  readonly height?: string | undefined;
1191
1314
  readonly stepActive?: string | number | undefined;
@@ -1228,6 +1351,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1228
1351
  isCompare?: boolean;
1229
1352
  parentValues?: Record<string, any>;
1230
1353
  labelWidth?: string;
1354
+ typeMatchValid?: boolean;
1231
1355
  disabled?: boolean;
1232
1356
  height?: string;
1233
1357
  stepActive?: string | number;
@@ -1260,6 +1384,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1260
1384
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1261
1385
  resetForm: () => void;
1262
1386
  submitForm: (native?: boolean) => Promise<any>;
1387
+ validate: () => Promise<string>;
1263
1388
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1264
1389
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
1265
1390
  error: (...args: any[]) => void;
@@ -1322,6 +1447,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1322
1447
  isCompare?: boolean;
1323
1448
  parentValues?: Record<string, any>;
1324
1449
  labelWidth?: string;
1450
+ typeMatchValid?: boolean;
1325
1451
  disabled?: boolean;
1326
1452
  height?: string;
1327
1453
  stepActive?: string | number;
@@ -1345,7 +1471,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1345
1471
  "onField-input"?: ((...args: any[]) => any) | undefined;
1346
1472
  "onField-change"?: ((...args: any[]) => any) | undefined;
1347
1473
  "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")> & {
1474
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1349
1475
  values: schema_d_exports.FormValue;
1350
1476
  lastValuesProcessed: schema_d_exports.FormValue;
1351
1477
  formState: schema_d_exports.FormState;
@@ -1354,6 +1480,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1354
1480
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1355
1481
  resetForm: () => void;
1356
1482
  submitForm: (native?: boolean) => Promise<any>;
1483
+ validate: () => Promise<string>;
1357
1484
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1358
1485
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
1359
1486
  $slots: import("@tmagic/editor").FormSlots;
@@ -1367,6 +1494,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1367
1494
  readonly isCompare?: boolean | undefined;
1368
1495
  readonly parentValues?: Record<string, any> | undefined;
1369
1496
  readonly labelWidth?: string | undefined;
1497
+ readonly typeMatchValid?: boolean | undefined;
1370
1498
  readonly disabled?: boolean | undefined;
1371
1499
  readonly height?: string | undefined;
1372
1500
  readonly stepActive?: string | number | undefined;
@@ -1409,6 +1537,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1409
1537
  isCompare?: boolean;
1410
1538
  parentValues?: Record<string, any>;
1411
1539
  labelWidth?: string;
1540
+ typeMatchValid?: boolean;
1412
1541
  disabled?: boolean;
1413
1542
  height?: string;
1414
1543
  stepActive?: string | number;
@@ -1441,6 +1570,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1441
1570
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1442
1571
  resetForm: () => void;
1443
1572
  submitForm: (native?: boolean) => Promise<any>;
1573
+ validate: () => Promise<string>;
1444
1574
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1445
1575
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
1446
1576
  error: (...args: any[]) => void;
@@ -1503,6 +1633,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1503
1633
  isCompare?: boolean;
1504
1634
  parentValues?: Record<string, any>;
1505
1635
  labelWidth?: string;
1636
+ typeMatchValid?: boolean;
1506
1637
  disabled?: boolean;
1507
1638
  height?: string;
1508
1639
  stepActive?: string | number;
@@ -1526,7 +1657,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1526
1657
  "onField-input"?: ((...args: any[]) => any) | undefined;
1527
1658
  "onField-change"?: ((...args: any[]) => any) | undefined;
1528
1659
  "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")> & {
1660
+ }>, "values" | "changeHandler" | "validate" | "initialized" | "lastValuesProcessed" | "formState" | "changeRecords" | "resetForm" | "submitForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "stepActive" | "useFieldTextInError")> & {
1530
1661
  values: schema_d_exports.FormValue;
1531
1662
  lastValuesProcessed: schema_d_exports.FormValue;
1532
1663
  formState: schema_d_exports.FormState;
@@ -1535,6 +1666,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
1535
1666
  changeHandler: (v: schema_d_exports.FormValue, eventData: ContainerChangeEventData) => void;
1536
1667
  resetForm: () => void;
1537
1668
  submitForm: (native?: boolean) => Promise<any>;
1669
+ validate: () => Promise<string>;
1538
1670
  getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
1539
1671
  } & {} & import("@vue/runtime-core").ComponentCustomProperties & {} & {
1540
1672
  $slots: import("@tmagic/editor").FormSlots;
@@ -1975,16 +2107,39 @@ declare const registerField: (tagName: string, component: Component) => void;
1975
2107
  declare const getField: (tagName: string) => Component | undefined;
1976
2108
  declare const deleteField: (tagName: string) => boolean;
1977
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
1978
2131
  //#region temp/packages/form/src/plugin.d.ts
1979
2132
  interface FormInstallOptions {
2133
+ /** 自定义字段 type 的 typeMatch 校验规则,可覆盖内置规则或扩展业务字段 */
2134
+ typeMatchRules?: Record<string, TypeMatchValidator>;
1980
2135
  [key: string]: any;
1981
2136
  }
1982
2137
  declare const _default$31: {
1983
2138
  install(app: App, opt?: FormInstallOptions): void;
1984
2139
  };
1985
2140
  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 };
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 };
1987
2142
  }
1988
2143
  declare const createForm: <T extends [] = []>(config: schema_d_exports.FormConfig | T) => schema_d_exports.FormConfig | T;
1989
2144
  //#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 };
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 };