@tmagic/form 1.8.0-beta.27 → 1.8.0-beta.29

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.
@@ -70,27 +70,60 @@
70
70
  flex-shrink: 0;
71
71
  gap: 8px;
72
72
  }
73
+ }
73
74
 
74
- // 卡片标题吸顶;补不透明背景,避免滚动时正文透出。
75
- // z-index 必须低于吸底 footer,否则标题会盖住「新增」按钮。
76
- > .el-card__header,
77
- > .t-card__header {
78
- position: sticky;
79
- top: var(--m-group-list-header-sticky-top, 0px);
80
- z-index: 7;
81
- background-color: var(--m-group-list-header-bg, #fff);
82
- }
75
+ // 嵌套吸底按钮叠在外层 footer 之上(如「新增条件」叠在「新增条件组」上面)。
76
+ // 每穿过一层「自己渲染了吸底 footer」的列表才多让出一个 footer 高度,外层没有吸底按钮时
77
+ // 内层不能凭空抬高。自定义属性不能自增,所以用 item / list 两个变量交替接力。
78
+ > .m-fields-group-list-item {
79
+ --m-group-list-item-footer-bottom: var(
80
+ --m-group-list-nested-footer-bottom,
81
+ 0px
82
+ );
83
+ }
84
+
85
+ &.is-footer-sticky > .m-fields-group-list-item {
86
+ --m-group-list-item-footer-bottom: calc(
87
+ var(--m-group-list-nested-footer-bottom, 0px) +
88
+ var(--m-group-list-footer-height)
89
+ );
83
90
  }
84
91
 
85
- // 嵌套标题叠在外层标题之下,层级更低以免盖住外层底部分隔线
86
- .m-fields-group-list-item .m-fields-group-list-item {
87
- > .el-card__header,
88
- > .t-card__header {
89
- top: calc(
90
- var(--m-group-list-header-sticky-top, 0px) +
91
- var(--m-group-list-header-height)
92
+ .m-fields-group-list-item .m-fields-group-list {
93
+ --m-group-list-nested-footer-bottom: var(
94
+ --m-group-list-item-footer-bottom,
95
+ 0px
96
+ );
97
+ }
98
+
99
+ // 仅 header.sticky 时标题吸顶;直接子 item,避免外层吸顶带动未开启的内层
100
+ &.is-header-sticky {
101
+ // 从外层 item 接过已累加的偏移;最外层没有该变量时走 fallback
102
+ --m-group-list-nested-sticky-top: var(--m-group-list-child-list-sticky-top);
103
+ --m-group-list-nested-header-z: var(--m-group-list-child-list-header-z);
104
+
105
+ > .m-fields-group-list-item {
106
+ --m-group-list-item-sticky-top: var(
107
+ --m-group-list-nested-sticky-top,
108
+ var(--m-group-list-header-sticky-top, 0px)
92
109
  );
93
- z-index: 6;
110
+ --m-group-list-item-header-z: var(--m-group-list-nested-header-z, 7);
111
+ --m-group-list-child-list-sticky-top: calc(
112
+ var(--m-group-list-item-sticky-top) + var(--m-group-list-header-height)
113
+ );
114
+ --m-group-list-child-list-header-z: calc(
115
+ var(--m-group-list-item-header-z) - 1
116
+ );
117
+
118
+ // 卡片标题吸顶;补不透明背景,避免滚动时正文透出。
119
+ // z-index 必须低于吸底 footer,否则标题会盖住「新增」按钮。
120
+ > .el-card__header,
121
+ > .t-card__header {
122
+ position: sticky;
123
+ top: var(--m-group-list-item-sticky-top);
124
+ z-index: var(--m-group-list-item-header-z);
125
+ background-color: var(--m-group-list-header-bg, #fff);
126
+ }
94
127
  }
95
128
  }
96
129
 
@@ -113,10 +146,10 @@
113
146
  }
114
147
 
115
148
  // 吸底全宽主按钮(event-select / code-select / display-conds 外层列表)
116
- // z-index 高于 item header,避免吸顶标题挡住新增按钮
149
+ // z-index 高于 item header,避免吸顶标题挡住新增按钮;多层时 bottom 由内层 list 累加
117
150
  > .m-fields-group-list-footer.is-sticky-full {
118
151
  position: sticky;
119
- bottom: 0;
152
+ bottom: var(--m-group-list-nested-footer-bottom, 0px);
120
153
  z-index: 7;
121
154
  margin-bottom: 0;
122
155
  padding: var(--m-group-list-footer-padding-top) 0
@@ -133,14 +166,6 @@
133
166
  height: var(--m-group-list-footer-button-height);
134
167
  }
135
168
  }
136
-
137
- // 嵌套吸底按钮叠在外层 footer 之上(如「新增条件」叠在「新增条件组」上面)
138
- .m-fields-group-list-item
139
- .m-fields-group-list
140
- > .m-fields-group-list-footer.is-sticky-full {
141
- bottom: var(--m-group-list-footer-height);
142
- z-index: 7;
143
- }
144
169
  }
145
170
 
146
171
  /** 最外层的groupList需要每个item需要增加空白区域界限时,增加outer-gorup_list可以实现 */
package/src/utils/form.ts CHANGED
@@ -368,11 +368,14 @@ export const filterFunction = <T = any>(
368
368
  props: any,
369
369
  ) => {
370
370
  if (typeof config === 'function') {
371
+ const formValue = readonly(mForm?.values || props.model);
371
372
  return (config as FilterFunction<T>)(mForm, {
372
373
  values: readonly(mForm?.initValues || {}),
373
374
  model: readonly(props.model),
374
375
  parent: readonly(mForm?.parentValues || {}),
375
- formValue: readonly(mForm?.values || props.model),
376
+ formValue,
377
+ // Select.vue / SelectOptionFunction 使用 formValues 别名
378
+ formValues: formValue,
376
379
  prop: props.prop,
377
380
  config: props.config,
378
381
  index: props.index,
@@ -18,7 +18,9 @@
18
18
 
19
19
  import { cloneDeep } from 'lodash-es';
20
20
 
21
- import type { GroupListConfig, TableColumnConfig, TableConfig } from '../schema';
21
+ import { isNumber } from '@tmagic/utils';
22
+
23
+ import type { GroupListConfig, GroupListHeaderConfig, TableColumnConfig, TableConfig } from '../schema';
22
24
 
23
25
  /**
24
26
  * table / group-list 是同一份配置的两种展示形态,可以互相切换(`TableGroupList.vue`)。
@@ -31,6 +33,31 @@ import type { GroupListConfig, TableColumnConfig, TableConfig } from '../schema'
31
33
  /** group-list 形态的 type(兼容驼峰与中划线两种写法) */
32
34
  export const isGroupListType = (type: unknown): boolean => type === 'groupList' || type === 'group-list';
33
35
 
36
+ /**
37
+ * 归一成带单位的 CSS 长度。
38
+ *
39
+ * 配置常常来自 JSON 或表单输入,`'48'` 这类无单位数字串很常见;直接写进 CSS 变量会让
40
+ * 嵌套层的 `calc()` 整体失效、吸顶静默失灵,所以纯数字一律补 `px`。
41
+ */
42
+ const toCssLength = (height: number | string | undefined): string | undefined => {
43
+ const value = `${height ?? ''}`.trim();
44
+ if (!value) return undefined;
45
+
46
+ if (isNumber(value)) return `${value}px`;
47
+ // 走到这里还是 number 的只剩 NaN / Infinity,不写变量,交给样式默认值兜底
48
+ return typeof height === 'number' ? undefined : value;
49
+ };
50
+
51
+ /** header.sticky 开启时把 height 写成 CSS 变量,给嵌套吸顶偏移用 */
52
+ export const getGroupListHeaderVars = (
53
+ header: GroupListHeaderConfig | undefined,
54
+ ): Record<string, string> | undefined => {
55
+ if (!header?.sticky) return undefined;
56
+
57
+ const height = toCssLength(header.height);
58
+ return height ? { '--m-group-list-header-height': height } : undefined;
59
+ };
60
+
34
61
  /** 按 label 文案长度估算 label 宽度(中文按 20px、其他按 8px,最小 80px) */
35
62
  export const calcLabelWidth = (label: string): string => {
36
63
  if (!label) return '0px';
@@ -56,6 +56,18 @@ const builtInTypeMatchRules = new Map<string, TypeMatchValidator>();
56
56
  const isPromise = (value: any): value is Promise<unknown> =>
57
57
  typeof value === 'object' && value !== null && typeof value.then === 'function';
58
58
 
59
+ /**
60
+ * 同步校验无法等待 Promise。调用方会丢掉返回值,这里挂上空 handler,避免变成未捕获 rejection。
61
+ */
62
+ const ignorePromise = (value: any): value is Promise<unknown> => {
63
+ if (!isPromise(value)) return false;
64
+ value.then(
65
+ () => {},
66
+ () => {},
67
+ );
68
+ return true;
69
+ };
70
+
59
71
  /** 注册或覆盖某个字段 type 的 typeMatch 校验规则。`builtIn` 登记不受 `clearTypeMatchRules` / `deleteTypeMatchRule` 影响。 */
60
72
  export const registerTypeMatchRule = (type: string, validator: TypeMatchValidator, builtIn = false): void => {
61
73
  (builtIn ? builtInTypeMatchRules : extraTypeMatchRules).set(toLine(type), validator);
@@ -89,11 +101,14 @@ const resolveConfig = <T = any>(
89
101
  props: any,
90
102
  ): T | undefined => {
91
103
  if (typeof config === 'function') {
104
+ const formValue = readonly(mForm?.values || props.model);
92
105
  return (config as Function)(mForm, {
93
106
  values: readonly(mForm?.initValues || {}),
94
107
  model: readonly(props.model),
95
108
  parent: readonly(mForm?.parentValues || {}),
96
- formValue: readonly(mForm?.values || props.model),
109
+ formValue,
110
+ // Select.vue / SelectOptionFunction 使用 formValues 别名
111
+ formValues: formValue,
97
112
  prop: props.prop,
98
113
  config: props.config,
99
114
  index: props.index,
@@ -200,7 +215,7 @@ const resolveFieldDefaultValue = (mForm: FormState | undefined, props: any): any
200
215
  if (typeof defaultValue === 'undefined' || defaultValue === 'undefined') return undefined;
201
216
  const resolvedDefaultValue = resolveConfig(mForm, defaultValue, props);
202
217
  // resolveConfig 返回 Promise(如 defaultValue 为异步函数)时无法同步获取默认值,回退到通用示例
203
- if (isPromise(resolvedDefaultValue)) {
218
+ if (ignorePromise(resolvedDefaultValue)) {
204
219
  return undefined;
205
220
  }
206
221
  return resolvedDefaultValue;
@@ -331,9 +346,21 @@ const flattenSelectOptions = (options: any[]): any[] => {
331
346
  return values;
332
347
  };
333
348
 
334
- const resolveOptions = (props: any): any[] => {
335
- const { options } = props.config || {};
336
- return Array.isArray(options) ? options : [];
349
+ /**
350
+ * 解析字段 options:静态数组原样返回;函数型与 `display` / `type` 一样当场求值。
351
+ *
352
+ * 函数返回 Promise、非数组或抛错时当作「还没有可选项」,交由调用方按空 options 跳过枚举。
353
+ * `remote` / `allowCreate` 仍由 `validateSelectValue` 单独放行,不在这里区分。
354
+ */
355
+ const resolveOptions = (mForm: FormState | undefined, props: any): any[] => {
356
+ let resolved: unknown;
357
+ try {
358
+ resolved = resolveConfig(mForm, props.config?.options, props);
359
+ } catch {
360
+ return [];
361
+ }
362
+ if (ignorePromise(resolved) || !Array.isArray(resolved)) return [];
363
+ return resolved;
337
364
  };
338
365
 
339
366
  const includesOptionValue = (optionValues: any[], value: any) => optionValues.some((item) => Object.is(item, value));
@@ -440,9 +467,6 @@ const validateSelectValue = (
440
467
  return undefined;
441
468
  }
442
469
 
443
- // 仅当 options 为静态数组时才校验值是否在可选项中,动态 options(函数形式)跳过
444
- const isStaticOptions = Array.isArray(config.options);
445
-
446
470
  if (config.multiple) {
447
471
  if (!Array.isArray(value)) {
448
472
  return defaultMessage(
@@ -451,13 +475,13 @@ const validateSelectValue = (
451
475
  optionExampleSuggestion(optionValues, '["选项1", "选项2"]', true),
452
476
  );
453
477
  }
454
- if (isStaticOptions && value.some((item) => !includesOptionValue(optionValues, item))) {
478
+ if (value.some((item) => !includesOptionValue(optionValues, item))) {
455
479
  return defaultMessage(message, `${value} 不在可选项中`, optionSuggestion(optionValues));
456
480
  }
457
481
  return undefined;
458
482
  }
459
483
 
460
- if (isStaticOptions && !includesOptionValue(optionValues, value)) {
484
+ if (!includesOptionValue(optionValues, value)) {
461
485
  return defaultMessage(message, `${value} 不在可选项中`, optionSuggestion(optionValues));
462
486
  }
463
487
  return undefined;
@@ -470,7 +494,7 @@ const validateCascaderValue = (
470
494
  mForm: FormState | undefined,
471
495
  message: string | undefined,
472
496
  ): string | undefined => {
473
- const options = resolveOptions(props) as CascaderOption[];
497
+ const options = resolveOptions(mForm, props) as CascaderOption[];
474
498
 
475
499
  if (!options.length) {
476
500
  return;
@@ -478,7 +502,7 @@ const validateCascaderValue = (
478
502
 
479
503
  const valueSeparator = resolveConfig<string | undefined>(mForm, config.valueSeparator, props);
480
504
  // resolveConfig 返回 Promise(如 valueSeparator 为异步函数)时无法同步确定分隔符,跳过校验
481
- if (isPromise(valueSeparator)) {
505
+ if (ignorePromise(valueSeparator)) {
482
506
  return undefined;
483
507
  }
484
508
  const emitPath = config.emitPath !== false;
@@ -631,12 +655,12 @@ const validateBuiltinTypeMatch = (
631
655
  }
632
656
 
633
657
  if (fieldType === 'select') {
634
- const optionValues = flattenSelectOptions(resolveOptions(props));
658
+ const optionValues = flattenSelectOptions(resolveOptions(mForm, props));
635
659
  return validateSelectValue(value, config, optionValues, message);
636
660
  }
637
661
 
638
662
  if (fieldType === 'radio-group') {
639
- const optionValues = flattenSelectOptions(resolveOptions(props));
663
+ const optionValues = flattenSelectOptions(resolveOptions(mForm, props));
640
664
 
641
665
  if (optionValues.length === 0) {
642
666
  return undefined;
@@ -649,7 +673,7 @@ const validateBuiltinTypeMatch = (
649
673
  }
650
674
 
651
675
  if (fieldType === 'checkbox-group') {
652
- const optionValues = flattenSelectOptions(resolveOptions(props));
676
+ const optionValues = flattenSelectOptions(resolveOptions(mForm, props));
653
677
 
654
678
  if (optionValues.length === 0) {
655
679
  return undefined;
@@ -727,12 +751,19 @@ export const validateTypeMatch = (
727
751
  }
728
752
 
729
753
  const rawFieldType = 'type' in (props.config || {}) ? props.config.type : '';
730
- if (typeof rawFieldType !== 'string' || !rawFieldType) {
754
+ let resolvedType: unknown;
755
+ try {
756
+ resolvedType = resolveConfig<string>(mForm, rawFieldType, props);
757
+ } catch {
758
+ return undefined;
759
+ }
760
+ // 函数型 type 与 Container 的 resolveItemType 对齐;异步 type 无法同步判定,跳过
761
+ if (ignorePromise(resolvedType) || typeof resolvedType !== 'string' || !resolvedType) {
731
762
  return undefined;
732
763
  }
733
764
 
734
765
  // 统一将驼峰形式(如 radioGroup)归一化为连字符形式(radio-group),与内置规则的 key 保持一致
735
- const fieldType = toLine(rawFieldType);
766
+ const fieldType = toLine(resolvedType);
736
767
 
737
768
  const customValidator = getTypeMatchRule(fieldType);
738
769
 
@@ -10,7 +10,7 @@ import * as import__tmagic_form_schema from "@tmagic/form-schema";
10
10
  * 所有层级的 Container(含嵌套在 fieldset / panel 等容器组件内部的 Container)通过 `inject` 获取,
11
11
  * 无需逐层透传 prop。
12
12
  */
13
- interface FormDiffConfig {
13
+ export interface FormDiffConfig {
14
14
  /**
15
15
  * 自定义"是否展示对比内容"的判断函数(仅在对比模式下生效)。
16
16
  *
@@ -30,8 +30,8 @@ interface FormDiffConfig {
30
30
  */
31
31
  selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
32
32
  }
33
- declare const FORM_DIFF_CONFIG_KEY: InjectionKey<FormDiffConfig>;
34
- declare const FORM_TYPE_MATCH_VALID_KEY: InjectionKey<ComputedRef<boolean>>;
33
+ export declare const FORM_DIFF_CONFIG_KEY: InjectionKey<FormDiffConfig>;
34
+ export declare const FORM_TYPE_MATCH_VALID_KEY: InjectionKey<ComputedRef<boolean>>;
35
35
  /**
36
36
  * 宿主业务上下文,由 `MForm`(或更外层的 Editor)通过 `provide` 下发。
37
37
  *
@@ -40,21 +40,21 @@ declare const FORM_TYPE_MATCH_VALID_KEY: InjectionKey<ComputedRef<boolean>>;
40
40
  *
41
41
  * 配置回调统一通过 `mForm.xxx` 读取,由 formState 的读穿 Proxy 落到这里。
42
42
  */
43
- declare const FORM_CONTEXT_KEY: InjectionKey<ComputedRef<FormContext>>;
44
- interface ValidateError {
43
+ export declare const FORM_CONTEXT_KEY: InjectionKey<ComputedRef<FormContext>>;
44
+ export interface ValidateError {
45
45
  message: string;
46
46
  field: string;
47
47
  }
48
- interface ChangeRecord {
48
+ export interface ChangeRecord {
49
49
  propPath?: string;
50
50
  value: any;
51
51
  }
52
- interface ContainerChangeEventData {
52
+ export interface ContainerChangeEventData {
53
53
  modifyKey?: string;
54
54
  changeRecords?: ChangeRecord[];
55
55
  }
56
56
  /** 自定义 label slot 的作用域参数 */
57
- interface FormLabelSlotProps {
57
+ export interface FormLabelSlotProps {
58
58
  /** 当前表单项配置 */
59
59
  config: FormItemConfig;
60
60
  /** 经处理后的类型 */
@@ -67,7 +67,7 @@ interface FormLabelSlotProps {
67
67
  disabled?: boolean;
68
68
  }
69
69
  /** Form / Container 暴露的具名 slot 定义 */
70
- interface FormSlots {
70
+ export interface FormSlots {
71
71
  label(_props: FormLabelSlotProps): any;
72
72
  }
73
73
  //#endregion
@@ -78,7 +78,7 @@ interface FormSlots {
78
78
  * 用读穿 Proxy 而非 `{ ...a, ...b }`:展开会立即执行 accessor,
79
79
  * 而宿主允许用 `{ get stage() { ... } }` 这类读时求值的描述符。
80
80
  */
81
- declare const mergeFormContexts: (...layers: (schema_d_exports.FormContext | undefined | null)[]) => schema_d_exports.FormContext;
81
+ export declare const mergeFormContexts: (...layers: (schema_d_exports.FormContext | undefined | null)[]) => schema_d_exports.FormContext;
82
82
  /**
83
83
  * 将 coreState 与宿主业务上下文关联:读取时优先 core,miss 再读穿到 context。
84
84
  *
@@ -91,7 +91,7 @@ declare const mergeFormContexts: (...layers: (schema_d_exports.FormContext | und
91
91
  *
92
92
  * 独立成文件,避免与 `form.ts` ↔ `typeMatch.ts` 形成循环依赖。
93
93
  */
94
- declare const createFormStateProxy: (coreState: schema_d_exports.FormState, getContext: (() => schema_d_exports.FormContext) | Ref<schema_d_exports.FormContext>) => schema_d_exports.FormState;
94
+ export declare const createFormStateProxy: (coreState: schema_d_exports.FormState, getContext: (() => schema_d_exports.FormContext) | Ref<schema_d_exports.FormContext>) => schema_d_exports.FormState;
95
95
  //#endregion
96
96
  //#region temp/packages/form/src/utils/form.d.ts
97
97
  type AsyncValidatorFn = (rule: any, value: any, callback: Function, source?: any, options?: any) => any;
@@ -99,9 +99,9 @@ type AsyncValidatorFn = (rule: any, value: any, callback: Function, source?: any
99
99
  * 将 async-validator(Element Plus)风格的 validator 适配到当前 UI 库。
100
100
  * TDesign 调用签名为 `(val) => boolean | CustomValidateObj | Promise`,无 callback。
101
101
  */
102
- declare const adaptFormValidator: (validator: AsyncValidatorFn) => AsyncValidatorFn;
103
- 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;
104
- declare const createFormStateBase: (ui?: {
102
+ export declare const adaptFormValidator: (validator: AsyncValidatorFn) => AsyncValidatorFn;
103
+ export 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;
104
+ export declare const createFormStateBase: (ui?: {
105
105
  $message?: any;
106
106
  $messageBox?: any;
107
107
  }) => {
@@ -119,45 +119,45 @@ declare const createFormStateBase: (ui?: {
119
119
  * 供 `Container.vue` 与无渲染校验(`collectValidatableFields`)共用,两者对「该不该下钻」
120
120
  * 的判断必须一致。
121
121
  */
122
- declare const isValidName: (name: unknown) => boolean;
122
+ export declare const isValidName: (name: unknown) => boolean;
123
123
  /**
124
124
  * 在 `prop` 后追加一段路径。
125
125
  *
126
126
  * 用于容器把 `prop` 透传给子级时再拼上索引 / key(如 group-list 的行、table 的行)。
127
127
  */
128
- declare const appendProp: (prop: string | undefined, key: string | number) => string;
128
+ export declare const appendProp: (prop: string | undefined, key: string | number) => string;
129
129
  /**
130
130
  * 由父级 `prop` 与配置项 `name` 拼出该配置项的完整 `prop`(即 FormItem 的 prop)。
131
131
  *
132
132
  * 调用方传入的 name 已按 `config.name || ''` 归一化,空 name 表示该配置项不占据值路径上的一层,
133
133
  * 此时沿用父级 `prop`。
134
134
  */
135
- declare const getItemProp: (prop?: string | undefined, name?: string | number | undefined) => string;
135
+ export declare const getItemProp: (prop?: string | undefined, name?: string | number | undefined) => string;
136
136
  /**
137
137
  * 归一化配置项的 `type`:求值动态 type、剥离容器语义的 type、驼峰转中划线、补默认值。
138
138
  *
139
139
  * 供 `Container.vue` 与无渲染校验共用,保证两者分派到的 type 完全一致。
140
140
  */
141
- declare const resolveItemType: (mForm: schema_d_exports.FormState | undefined, config: any, props: any) => string;
142
- declare const filterFunction: <T = any>(mForm: schema_d_exports.FormState | undefined, config: T | schema_d_exports.FilterFunction<T> | undefined, props: any) => T | undefined;
143
- declare const display: (mForm: schema_d_exports.FormState | undefined, config: any, props: any) => any;
144
- declare const getRules: (mForm: schema_d_exports.FormState | undefined, r: (schema_d_exports.Rule[] | schema_d_exports.Rule) | undefined, props: any, typeMatchValid?: MaybeRef<boolean>) => schema_d_exports.Rule[];
141
+ export declare const resolveItemType: (mForm: schema_d_exports.FormState | undefined, config: any, props: any) => string;
142
+ export declare const filterFunction: <T = any>(mForm: schema_d_exports.FormState | undefined, config: T | schema_d_exports.FilterFunction<T> | undefined, props: any) => T | undefined;
143
+ export declare const display: (mForm: schema_d_exports.FormState | undefined, config: any, props: any) => any;
144
+ export declare const getRules: (mForm: schema_d_exports.FormState | undefined, r: (schema_d_exports.Rule[] | schema_d_exports.Rule) | undefined, props: any, typeMatchValid?: MaybeRef<boolean>) => schema_d_exports.Rule[];
145
145
  /**
146
146
  * 与 `getRules` 相同,但 validator 保持 async-validator(Element Plus)原生签名,不做 UI 库适配。
147
147
  *
148
148
  * 供无渲染校验(`validateValues`)使用:它直接把规则交给 async-validator 执行,
149
149
  * 不经过 TDesign 的 `validator(val)` 调用约定,因此不能套 `adaptFormValidator`。
150
150
  */
151
- declare const getNativeRules: (mForm: schema_d_exports.FormState | undefined, r: (schema_d_exports.Rule[] | schema_d_exports.Rule) | undefined, props: any, typeMatchValid?: MaybeRef<boolean>) => schema_d_exports.Rule[];
152
- declare const initValue: (mForm: schema_d_exports.FormState | undefined, { initValues, config }: {
151
+ export declare const getNativeRules: (mForm: schema_d_exports.FormState | undefined, r: (schema_d_exports.Rule[] | schema_d_exports.Rule) | undefined, props: any, typeMatchValid?: MaybeRef<boolean>) => schema_d_exports.Rule[];
152
+ export declare const initValue: (mForm: schema_d_exports.FormState | undefined, { initValues, config }: {
153
153
  initValues: schema_d_exports.FormValue;
154
154
  config: schema_d_exports.FormConfig;
155
155
  }) => Promise<schema_d_exports.FormValue>;
156
- declare const datetimeFormatter: (v: string | Date, defaultValue?: string, format?: string) => string | number;
157
- declare const getDataByPage: (data: any[] | undefined, pagecontext: number, pagesize: number) => any[];
158
- declare const sortArray: (data: any[], newIndex: number, oldIndex: number, sortKey?: string) => any[];
159
- declare const sortChange: (data: any[], { prop, order }: schema_d_exports.SortProp) => void;
160
- declare const createObjectProp: (prop: string, key: string, name?: string | number) => string;
156
+ export declare const datetimeFormatter: (v: string | Date, defaultValue?: string, format?: string) => string | number;
157
+ export declare const getDataByPage: (data: any[] | undefined, pagecontext: number, pagesize: number) => any[];
158
+ export declare const sortArray: (data: any[], newIndex: number, oldIndex: number, sortKey?: string) => any[];
159
+ export declare const sortChange: (data: any[], { prop, order }: schema_d_exports.SortProp) => void;
160
+ export declare const createObjectProp: (prop: string, key: string, name?: string | number) => string;
161
161
  //#endregion
162
162
  //#region temp/packages/form/src/utils/collectFields.d.ts
163
163
  /** 一个参与校验的字段:与渲染式校验中「一个带 rules 的 TMagicFormItem」一一对应 */
@@ -172,13 +172,13 @@ interface CollectedField {
172
172
  model: schema_d_exports.FormValue;
173
173
  }
174
174
  /** 已登记的 innerConfig 回调自身抛错时抛出(机制故障,不是漏登记) */
175
- declare class FieldInnerConfigError extends Error {
175
+ export declare class FieldInnerConfigError extends Error {
176
176
  readonly code = "FIELD_INNER_CONFIG";
177
177
  readonly type: string;
178
178
  readonly prop: string;
179
179
  constructor(type: string, prop: string, cause: unknown);
180
180
  }
181
- declare const isFieldInnerConfigError: (error: unknown) => error is FieldInnerConfigError;
181
+ export declare const isFieldInnerConfigError: (error: unknown) => error is FieldInnerConfigError;
182
182
  /**
183
183
  * 遍历模式。同一套遍历规则服务两个用途,避免两条链路各写一份而产生偏差:
184
184
  *
@@ -229,7 +229,7 @@ type ContainerWalker = (_ctx: WalkContext, _node: WalkNode, _itemProp: string) =
229
229
  * `typeMatch` 的字段会补上 `{ typeMatch: true }`,按字段 type 校验值形态
230
230
  * @returns 带规则的字段列表
231
231
  */
232
- declare const collectValidatableFields: (mForm: schema_d_exports.FormState | undefined, config: schema_d_exports.FormConfig, values: schema_d_exports.FormValue, typeMatchValid?: boolean) => CollectedField[];
232
+ export declare const collectValidatableFields: (mForm: schema_d_exports.FormState | undefined, config: schema_d_exports.FormConfig, values: schema_d_exports.FormValue, typeMatchValid?: boolean) => CollectedField[];
233
233
  /**
234
234
  * 执行「一份 config + 一份 values」中所有叶子字段登记的值初始化写入,就地改写 `values`。
235
235
  *
@@ -248,7 +248,7 @@ declare const collectValidatableFields: (mForm: schema_d_exports.FormState | und
248
248
  * @param config - 表单配置
249
249
  * @param values - 表单值(会被就地修改)
250
250
  */
251
- declare const applyMountValueEffects: (mForm: schema_d_exports.FormState | undefined, config: schema_d_exports.FormConfig, values: schema_d_exports.FormValue) => void;
251
+ export declare const applyMountValueEffects: (mForm: schema_d_exports.FormState | undefined, config: schema_d_exports.FormConfig, values: schema_d_exports.FormValue) => void;
252
252
  //#endregion
253
253
  //#region temp/packages/form/src/utils/fieldInnerConfig.d.ts
254
254
  /** innerConfig 回调的入参:字段自身的配置、所在层级的 model、完整字段路径与表单状态 */
@@ -331,7 +331,7 @@ type FieldMountValueEffect = (_ctx: FieldMountValueEffectContext) => void;
331
331
  * @param type - 字段 type
332
332
  * @returns 是否为叶子
333
333
  */
334
- declare const isLeafFieldType: (type: string) => boolean;
334
+ export declare const isLeafFieldType: (type: string) => boolean;
335
335
  //#endregion
336
336
  //#region temp/packages/form/src/utils/typeMatch.d.ts
337
337
  interface TypeMatchValidateContext {
@@ -347,28 +347,28 @@ interface TypeMatchValidateContext {
347
347
  */
348
348
  type TypeMatchValidator = (value: any, context: TypeMatchValidateContext) => string | undefined | Promise<string | undefined>;
349
349
  /** 获取某个字段 type 的 typeMatch 校验规则(业务侧优先于内置) */
350
- declare const getTypeMatchRule: (type: string) => TypeMatchValidator | undefined;
350
+ export declare const getTypeMatchRule: (type: string) => TypeMatchValidator | undefined;
351
351
  /** 删除业务侧 typeMatch 校验规则(不影响内置) */
352
- declare const deleteTypeMatchRule: (type: string) => boolean;
352
+ export declare const deleteTypeMatchRule: (type: string) => boolean;
353
353
  /** 清空业务侧 typeMatch 校验规则(不影响内置) */
354
- declare const clearTypeMatchRules: () => void;
354
+ export declare const clearTypeMatchRules: () => void;
355
355
  /**
356
356
  * 将值格式化为可读的参考示例字符串。
357
357
  */
358
- declare const stringifyExampleValue: (value: any) => string;
358
+ export declare const stringifyExampleValue: (value: any) => string;
359
359
  /** 参考建议中可选值全量展示上限;超出时仅举例 EXAMPLE_SUGGESTION_COUNT 个并标明总数。 */
360
- declare const MAX_SUGGESTION_OPTIONS = 20;
360
+ export declare const MAX_SUGGESTION_OPTIONS = 20;
361
361
  /**
362
362
  * 生成可选项参考建议;无可选值时返回空字符串(不追加建议)。
363
363
  * 未超过 MAX_SUGGESTION_OPTIONS 时全部列举;超过时仅举例前 EXAMPLE_SUGGESTION_COUNT 个并标明总数,避免 AI 误以为仅有举例值合法。
364
364
  */
365
- declare const optionSuggestion: (optionValues: any[]) => string;
365
+ export declare const optionSuggestion: (optionValues: any[]) => string;
366
366
  /**
367
367
  * 校验取值与字段 type 是否匹配;通过返回 undefined,否则返回错误文案。
368
368
  *
369
369
  * 命中的自定义规则是异步校验器时返回 Promise,内置规则始终同步返回。
370
370
  */
371
- declare const validateTypeMatch: (value: any, mForm: schema_d_exports.FormState | undefined, props: any, message?: string) => string | undefined | Promise<string | undefined>;
371
+ export declare const validateTypeMatch: (value: any, mForm: schema_d_exports.FormState | undefined, props: any, message?: string) => string | undefined | Promise<string | undefined>;
372
372
  //#endregion
373
373
  //#region temp/packages/form/src/utils/registerField.d.ts
374
374
  /**
@@ -416,7 +416,7 @@ type HeadlessFieldOptions = Omit<FieldOptions, 'component' | 'container'>;
416
416
  * @param tables - 待合并的登记表,`undefined` 会被跳过
417
417
  * @returns 合并后的登记表
418
418
  */
419
- declare const mergeFieldOptions: (...tables: Array<Record<string, HeadlessFieldOptions | FieldOptions> | undefined>) => Record<string, FieldOptions>;
419
+ export declare const mergeFieldOptions: (...tables: Array<Record<string, HeadlessFieldOptions | FieldOptions> | undefined>) => Record<string, FieldOptions>;
420
420
  /**
421
421
  * 按字段 type 取已登记的渲染组件(`codeSelect` 与 `code-select` 等价)。
422
422
  *
@@ -435,29 +435,29 @@ declare const getField: (type: string) => Component | undefined;
435
435
  * @param [options] - 登记项;省略或空对象视为叶子
436
436
  * @param [app] - Vue 应用;省略则不调用 `app.component`
437
437
  */
438
- declare const registerField: (type: string, options?: FieldOptions, app?: App) => void;
438
+ export declare const registerField: (type: string, options?: FieldOptions, app?: App) => void;
439
439
  /**
440
440
  * 批量登记字段。
441
441
  *
442
442
  * @param fields - type 到登记项的映射
443
443
  * @param [app] - Vue 应用;省略则不调用 `app.component`
444
444
  */
445
- declare const registerFields: (fields: Record<string, FieldOptions>, app?: App) => void;
445
+ export declare const registerFields: (fields: Record<string, FieldOptions>, app?: App) => void;
446
446
  /**
447
447
  * 登记内置字段(`clearFields` / `unregisterField` 不会清掉)。
448
448
  *
449
449
  * @param fields - type 到登记项的映射
450
450
  * @param [app] - Vue 应用;省略则不调用 `app.component`
451
451
  */
452
- declare const registerBuiltInFields: (fields: Record<string, FieldOptions>, app?: App) => void;
452
+ export declare const registerBuiltInFields: (fields: Record<string, FieldOptions>, app?: App) => void;
453
453
  /**
454
454
  * 删除业务侧对指定 type 的登记(不影响内置;主要用于单测)。
455
455
  *
456
456
  * @param type - 字段 type
457
457
  */
458
- declare const unregisterField: (type: string) => void;
458
+ export declare const unregisterField: (type: string) => void;
459
459
  /** 清空业务侧登记(不影响内置;主要用于单测)。 */
460
- declare const clearFields: () => void;
460
+ export declare const clearFields: () => void;
461
461
  //#endregion
462
462
  //#region temp/packages/form/src/utils/builtInFields.d.ts
463
463
  /**
@@ -466,7 +466,7 @@ declare const clearFields: () => void;
466
466
  * 本模块只导出数据,不登记。调用方自行 `registerBuiltInFields(builtInFields)`,
467
467
  * 或 `app.use(MagicForm)`(install 里会登记叠上 Vue 组件后的表)。
468
468
  */
469
- declare const builtInFields: Record<string, HeadlessFieldOptions>;
469
+ export declare const builtInFields: Record<string, HeadlessFieldOptions>;
470
470
  //#endregion
471
471
  //#region temp/packages/form/src/utils/validateValues.d.ts
472
472
  /** 构造无渲染 formState 所需的参数(与 MForm 的同名 props 对齐) */
@@ -488,7 +488,7 @@ interface HeadlessFormStateOptions {
488
488
  * 差异:没有真实的表单实例,因此 `$emit` 为空实现、`fields` 注册表始终为空
489
489
  * (该注册表在整个仓库中只写不读,不参与校验)。
490
490
  */
491
- declare const createHeadlessFormState: (options: HeadlessFormStateOptions) => schema_d_exports.FormState;
491
+ export declare const createHeadlessFormState: (options: HeadlessFormStateOptions) => schema_d_exports.FormState;
492
492
  /** `validateValues` 参数 */
493
493
  interface ValidateValuesOptions extends HeadlessFormStateOptions {
494
494
  /** 是否开启类型匹配校验 */
@@ -527,7 +527,7 @@ interface ValidateValuesResult {
527
527
  * });
528
528
  * ```
529
529
  */
530
- declare const validateValues: (options: ValidateValuesOptions) => Promise<ValidateValuesResult>;
530
+ export declare const validateValues: (options: ValidateValuesOptions) => Promise<ValidateValuesResult>;
531
531
  //#endregion
532
532
  //#region temp/packages/form/src/utils/validateError.d.ts
533
533
  /**
@@ -537,7 +537,7 @@ declare const validateValues: (options: ValidateValuesOptions) => Promise<Valida
537
537
  * @param config - 表单配置数组
538
538
  * @returns 找到的 text 值,如果未找到则返回 undefined
539
539
  */
540
- declare const getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
540
+ export declare const getTextByName: (name: string, config?: schema_d_exports.FormConfig) => string | undefined;
541
541
  /**
542
542
  * 将校验返回的 invalidFields 汇总为可读的错误文案(多条以 `<br>` 拼接)。
543
543
  *
@@ -552,7 +552,7 @@ declare const getTextByName: (name: string, config?: schema_d_exports.FormConfig
552
552
  * @param [options.useFieldTextInError=true] - 错误前缀是否使用字段 text
553
553
  * @returns 拼接后的错误文案;无错误时为空串
554
554
  */
555
- declare const formatValidateError: (invalidFields: Record<string, any>, { config, useFieldTextInError }?: {
555
+ export declare const formatValidateError: (invalidFields: Record<string, any>, { config, useFieldTextInError }?: {
556
556
  config?: schema_d_exports.FormConfig;
557
557
  useFieldTextInError?: boolean;
558
558
  }) => string;
@@ -668,15 +668,15 @@ interface ValidateFormOptions {
668
668
  *
669
669
  * `@tmagic/form/headless` 不支持 `dialog: true`。
670
670
  */
671
- declare const submitForm: (options: SubmitFormOptions) => Promise<any>;
671
+ export declare const submitForm: (options: SubmitFormOptions) => Promise<any>;
672
672
  /**
673
673
  * 以命令式方式对一份「表单配置 + 值」做一次静默校验(无渲染)。
674
674
  *
675
675
  * `@tmagic/form/headless` 不支持 `dialog: true`。
676
676
  */
677
- declare const validateForm: (options: ValidateFormOptions) => Promise<string>;
677
+ export declare const validateForm: (options: ValidateFormOptions) => Promise<string>;
678
678
  declare namespace headless_d_exports {
679
679
  export { ChangeRecord, CollectedField, ContainerChangeEventData, FORM_CONTEXT_KEY, FORM_DIFF_CONFIG_KEY, FORM_TYPE_MATCH_VALID_KEY, FieldInnerConfig, FieldInnerConfigContext, FieldInnerConfigError, FieldInnerConfigResult, FieldMountValueEffect, FieldMountValueEffectContext, FieldOptions, FormDiffConfig, FormLabelSlotProps, FormSlots, HeadlessFieldOptions, HeadlessFormStateOptions, MAX_SUGGESTION_OPTIONS, SubmitFormOptions, SubmitFormResult, TypeMatchValidateContext, TypeMatchValidator, ValidateError, ValidateFormOptions, ValidateValuesOptions, ValidateValuesResult, adaptFormValidator, appendProp, applyMountValueEffects, builtInFields, clearFields, clearTypeMatchRules, collectValidatableFields, createFormStateBase, createFormStateProxy, createHeadlessFormState, createObjectProp, createValues, datetimeFormatter, deleteTypeMatchRule, display, filterFunction, formatValidateError, getDataByPage, getField as getFormField, getItemProp, getNativeRules, getRules, getTextByName, getTypeMatchRule, initValue, isFieldInnerConfigError, isLeafFieldType, isValidName, mergeFieldOptions, mergeFormContexts, optionSuggestion, registerBuiltInFields, registerField, registerFields, resolveItemType, sortArray, sortChange, stringifyExampleValue, submitForm, unregisterField, validateForm, validateTypeMatch, validateValues };
680
680
  }
681
681
  //#endregion
682
- export { ChangeRecord, type CollectedField, ContainerChangeEventData, FORM_CONTEXT_KEY, FORM_DIFF_CONFIG_KEY, FORM_TYPE_MATCH_VALID_KEY, type FieldInnerConfig, type FieldInnerConfigContext, FieldInnerConfigError, type FieldInnerConfigResult, type FieldMountValueEffect, type FieldMountValueEffectContext, type FieldOptions, FormDiffConfig, FormLabelSlotProps, FormSlots, type HeadlessFieldOptions, type HeadlessFormStateOptions, MAX_SUGGESTION_OPTIONS, type SubmitFormOptions, type SubmitFormResult, type TypeMatchValidateContext, type TypeMatchValidator, ValidateError, type ValidateFormOptions, type ValidateValuesOptions, type ValidateValuesResult, adaptFormValidator, appendProp, applyMountValueEffects, builtInFields, clearFields, clearTypeMatchRules, collectValidatableFields, createFormStateBase, createFormStateProxy, createHeadlessFormState, createObjectProp, createValues, datetimeFormatter, deleteTypeMatchRule, display, filterFunction, formatValidateError, getDataByPage, getField as getFormField, getItemProp, getNativeRules, getRules, getTextByName, getTypeMatchRule, initValue, isFieldInnerConfigError, isLeafFieldType, isValidName, mergeFieldOptions, mergeFormContexts, optionSuggestion, registerBuiltInFields, registerField, registerFields, resolveItemType, sortArray, sortChange, stringifyExampleValue, submitForm, unregisterField, validateForm, validateTypeMatch, validateValues };
682
+ export { type CollectedField, type FieldInnerConfig, type FieldInnerConfigContext, type FieldInnerConfigResult, type FieldMountValueEffect, type FieldMountValueEffectContext, type FieldOptions, type HeadlessFieldOptions, type HeadlessFormStateOptions, type SubmitFormOptions, type SubmitFormResult, type TypeMatchValidateContext, type TypeMatchValidator, type ValidateFormOptions, type ValidateValuesOptions, type ValidateValuesResult, getField as getFormField };