@tmagic/form 1.8.0-beta.12 → 1.8.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/Form.vue_vue_type_script_setup_true_lang.js +51 -16
- package/dist/es/FormDialog.vue_vue_type_script_setup_true_lang.js +12 -5
- package/dist/es/FormDrawer.vue_vue_type_script_setup_true_lang.js +38 -12
- package/dist/es/containers/Container.vue_vue_type_script_setup_true_lang.js +35 -27
- package/dist/es/containers/GroupList.vue_vue_type_script_setup_true_lang.js +6 -5
- package/dist/es/containers/GroupListItem.vue_vue_type_script_setup_true_lang.js +41 -31
- package/dist/es/containers/Panel.vue_vue_type_script_setup_true_lang.js +16 -10
- package/dist/es/containers/table/ActionsColumn.vue_vue_type_script_setup_true_lang.js +13 -6
- package/dist/es/containers/table/Table.vue_vue_type_script_setup_true_lang.js +4 -2
- package/dist/es/containers/table/useTableColumns.js +5 -1
- package/dist/es/containers/table-group-list/TableGroupList.vue_vue_type_script_setup_true_lang.js +2 -1
- package/dist/es/fields/Cascader.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/fields/Checkbox.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/CheckboxGroup.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/fields/ColorPicker.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/Date.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/fields/DateTime.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/fields/Daterange.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/fields/Display.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/fields/DynamicField.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/Link.vue_vue_type_script_setup_true_lang.js +29 -7
- package/dist/es/fields/Number.vue_vue_type_script_setup_true_lang.js +7 -2
- package/dist/es/fields/NumberRange.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/RadioGroup.vue_vue_type_script_setup_true_lang.js +19 -9
- package/dist/es/fields/Select.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/Switch.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/Text.vue_vue_type_script_setup_true_lang.js +112 -77
- package/dist/es/fields/Textarea.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/Time.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/Timerange.vue_vue_type_script_setup_true_lang.js +6 -3
- package/dist/es/index.js +4 -4
- package/dist/es/plugin.js +3 -1
- package/dist/es/style.css +122 -8
- package/dist/es/submitForm.js +3 -9
- package/dist/es/utils/config.js +4 -1
- package/dist/es/utils/form.js +33 -3
- package/dist/es/utils/typeMatch.js +31 -26
- package/dist/style.css +122 -8
- package/dist/themes/magic-admin.css +499 -0
- package/dist/tmagic-form.umd.cjs +583 -330
- package/package.json +4 -4
- package/src/Form.vue +71 -18
- package/src/FormDialog.vue +14 -3
- package/src/FormDrawer.vue +40 -12
- package/src/containers/Container.vue +19 -6
- package/src/containers/GroupList.vue +1 -1
- package/src/containers/GroupListItem.vue +28 -22
- package/src/containers/Panel.vue +10 -3
- package/src/containers/table/ActionsColumn.vue +10 -4
- package/src/containers/table/Table.vue +1 -0
- package/src/containers/table/useTableColumns.ts +7 -3
- package/src/containers/table-group-list/TableGroupList.vue +7 -1
- package/src/fields/Link.vue +16 -3
- package/src/fields/Number.vue +2 -1
- package/src/fields/RadioGroup.vue +21 -6
- package/src/fields/Text.vue +43 -19
- package/src/plugin.ts +3 -0
- package/src/submitForm.ts +6 -12
- package/src/theme/container.scss +3 -0
- package/src/theme/fieldset.scss +51 -0
- package/src/theme/form.scss +6 -0
- package/src/theme/group-list.scss +9 -7
- package/src/theme/index.scss +1 -0
- package/src/theme/link.scss +17 -0
- package/src/theme/panel.scss +1 -1
- package/src/theme/radio-group.scss +23 -0
- package/src/theme/tabs.scss +2 -2
- package/src/theme/text.scss +38 -0
- package/src/theme/themes/magic-admin/index.scss +95 -0
- package/src/utils/config.ts +7 -1
- package/src/utils/form.ts +37 -0
- package/src/utils/typeMatch.ts +57 -28
- package/types/index.d.ts +72 -3
package/src/utils/typeMatch.ts
CHANGED
|
@@ -21,7 +21,7 @@ import dayjs from 'dayjs';
|
|
|
21
21
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
22
22
|
|
|
23
23
|
import { appendValidateSuggestion } from '@tmagic/design';
|
|
24
|
-
import { getValueByKeyPath } from '@tmagic/utils';
|
|
24
|
+
import { getValueByKeyPath, toLine } from '@tmagic/utils';
|
|
25
25
|
|
|
26
26
|
import type { CascaderOption, FormState, Rule } from '../schema';
|
|
27
27
|
|
|
@@ -44,11 +44,12 @@ export type TypeMatchValidator = (value: any, context: TypeMatchValidateContext)
|
|
|
44
44
|
|
|
45
45
|
const typeMatchRuleRegistry = new Map<string, TypeMatchValidator>();
|
|
46
46
|
|
|
47
|
-
const
|
|
47
|
+
const isPromise = (value: any): value is Promise<unknown> =>
|
|
48
|
+
typeof value === 'object' && value !== null && typeof value.then === 'function';
|
|
48
49
|
|
|
49
50
|
/** 注册或覆盖某个字段 type 的 typeMatch 校验规则 */
|
|
50
51
|
export const registerTypeMatchRule = (type: string, validator: TypeMatchValidator): void => {
|
|
51
|
-
typeMatchRuleRegistry.set(
|
|
52
|
+
typeMatchRuleRegistry.set(toLine(type), validator);
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
/** 批量注册 typeMatch 校验规则 */
|
|
@@ -60,10 +61,10 @@ export const registerTypeMatchRules = (rules: Record<string, TypeMatchValidator>
|
|
|
60
61
|
|
|
61
62
|
/** 获取某个字段 type 的自定义 typeMatch 校验规则 */
|
|
62
63
|
export const getTypeMatchRule = (type: string): TypeMatchValidator | undefined =>
|
|
63
|
-
typeMatchRuleRegistry.get(
|
|
64
|
+
typeMatchRuleRegistry.get(toLine(type));
|
|
64
65
|
|
|
65
66
|
/** 删除某个字段 type 的自定义 typeMatch 校验规则 */
|
|
66
|
-
export const deleteTypeMatchRule = (type: string): boolean => typeMatchRuleRegistry.delete(
|
|
67
|
+
export const deleteTypeMatchRule = (type: string): boolean => typeMatchRuleRegistry.delete(toLine(type));
|
|
67
68
|
|
|
68
69
|
/** 清空所有自定义 typeMatch 校验规则 */
|
|
69
70
|
export const clearTypeMatchRules = (): void => {
|
|
@@ -182,7 +183,12 @@ const toggleSuggestion = (activeValue: any, inactiveValue: any): string =>
|
|
|
182
183
|
const resolveFieldDefaultValue = (mForm: FormState | undefined, props: any): any => {
|
|
183
184
|
const { defaultValue } = props.config || {};
|
|
184
185
|
if (typeof defaultValue === 'undefined' || defaultValue === 'undefined') return undefined;
|
|
185
|
-
|
|
186
|
+
const resolvedDefaultValue = resolveConfig(mForm, defaultValue, props);
|
|
187
|
+
// resolveConfig 返回 Promise(如 defaultValue 为异步函数)时无法同步获取默认值,回退到通用示例
|
|
188
|
+
if (isPromise(resolvedDefaultValue)) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
return resolvedDefaultValue;
|
|
186
192
|
};
|
|
187
193
|
|
|
188
194
|
const isNumberValue = (value: any) => typeof value === 'number' && !Number.isNaN(value);
|
|
@@ -271,13 +277,6 @@ const dateValueFormatErrorMessage = (message: string | undefined, valueFormat: s
|
|
|
271
277
|
dateSuggestion(valueFormat),
|
|
272
278
|
);
|
|
273
279
|
|
|
274
|
-
const resolveFieldType = (mForm: FormState | undefined, props: any): string => {
|
|
275
|
-
let type = 'type' in (props.config || {}) ? props.config.type : '';
|
|
276
|
-
type = type ? resolveConfig<string>(mForm, type, props) || '' : '';
|
|
277
|
-
if (type === 'form' || type === 'container') return '';
|
|
278
|
-
return normalizeType(type || '') || (props.config?.items ? '' : 'text');
|
|
279
|
-
};
|
|
280
|
-
|
|
281
280
|
const resolveToggleValues = (config: any) => {
|
|
282
281
|
const filterIsNumber = config.filter === 'number';
|
|
283
282
|
const { activeValue: configActiveValue, inactiveValue: configInactiveValue } = config;
|
|
@@ -317,13 +316,9 @@ const flattenSelectOptions = (options: any[]): any[] => {
|
|
|
317
316
|
return values;
|
|
318
317
|
};
|
|
319
318
|
|
|
320
|
-
const resolveOptions = (
|
|
319
|
+
const resolveOptions = (props: any): any[] => {
|
|
321
320
|
const { options } = props.config || {};
|
|
322
|
-
|
|
323
|
-
if (typeof options === 'function') {
|
|
324
|
-
return resolveConfig(mForm, options, props) || [];
|
|
325
|
-
}
|
|
326
|
-
return [];
|
|
321
|
+
return Array.isArray(options) ? options : [];
|
|
327
322
|
};
|
|
328
323
|
|
|
329
324
|
const includesOptionValue = (optionValues: any[], value: any) => optionValues.some((item) => Object.is(item, value));
|
|
@@ -404,6 +399,10 @@ const validateSelectValue = (
|
|
|
404
399
|
optionValues: any[],
|
|
405
400
|
message: string | undefined,
|
|
406
401
|
): string | undefined => {
|
|
402
|
+
if (optionValues.length === 0) {
|
|
403
|
+
return undefined;
|
|
404
|
+
}
|
|
405
|
+
|
|
407
406
|
if (config.allowCreate || config.remote) {
|
|
408
407
|
if (config.multiple) {
|
|
409
408
|
if (!Array.isArray(value)) {
|
|
@@ -456,10 +455,19 @@ const validateCascaderValue = (
|
|
|
456
455
|
mForm: FormState | undefined,
|
|
457
456
|
message: string | undefined,
|
|
458
457
|
): string | undefined => {
|
|
458
|
+
const options = resolveOptions(props) as CascaderOption[];
|
|
459
|
+
|
|
460
|
+
if (!options.length) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
|
|
459
464
|
const valueSeparator = resolveConfig<string | undefined>(mForm, config.valueSeparator, props);
|
|
465
|
+
// resolveConfig 返回 Promise(如 valueSeparator 为异步函数)时无法同步确定分隔符,跳过校验
|
|
466
|
+
if (isPromise(valueSeparator)) {
|
|
467
|
+
return undefined;
|
|
468
|
+
}
|
|
460
469
|
const emitPath = config.emitPath !== false;
|
|
461
470
|
const multiple = Boolean(config.multiple);
|
|
462
|
-
const options = resolveOptions(mForm, props) as CascaderOption[];
|
|
463
471
|
const cascaderExample = (fallbackExample: string) =>
|
|
464
472
|
cascaderExampleSuggestion(options, config, valueSeparator, fallbackExample);
|
|
465
473
|
|
|
@@ -603,12 +611,17 @@ const validateBuiltinTypeMatch = (
|
|
|
603
611
|
}
|
|
604
612
|
|
|
605
613
|
if (fieldType === 'select') {
|
|
606
|
-
const optionValues = flattenSelectOptions(resolveOptions(
|
|
614
|
+
const optionValues = flattenSelectOptions(resolveOptions(props));
|
|
607
615
|
return validateSelectValue(value, config, optionValues, message);
|
|
608
616
|
}
|
|
609
617
|
|
|
610
618
|
if (fieldType === 'radio-group') {
|
|
611
|
-
const optionValues = flattenSelectOptions(resolveOptions(
|
|
619
|
+
const optionValues = flattenSelectOptions(resolveOptions(props));
|
|
620
|
+
|
|
621
|
+
if (optionValues.length === 0) {
|
|
622
|
+
return undefined;
|
|
623
|
+
}
|
|
624
|
+
|
|
612
625
|
if (!includesOptionValue(optionValues, value)) {
|
|
613
626
|
return defaultMessage(message, `${value} 不在可选项中`, optionSuggestion(optionValues));
|
|
614
627
|
}
|
|
@@ -616,7 +629,12 @@ const validateBuiltinTypeMatch = (
|
|
|
616
629
|
}
|
|
617
630
|
|
|
618
631
|
if (fieldType === 'checkbox-group') {
|
|
619
|
-
const optionValues = flattenSelectOptions(resolveOptions(
|
|
632
|
+
const optionValues = flattenSelectOptions(resolveOptions(props));
|
|
633
|
+
|
|
634
|
+
if (optionValues.length === 0) {
|
|
635
|
+
return undefined;
|
|
636
|
+
}
|
|
637
|
+
|
|
620
638
|
if (!Array.isArray(value)) {
|
|
621
639
|
return defaultMessage(
|
|
622
640
|
message,
|
|
@@ -679,7 +697,14 @@ export const validateTypeMatch = (
|
|
|
679
697
|
return undefined;
|
|
680
698
|
}
|
|
681
699
|
|
|
682
|
-
const
|
|
700
|
+
const rawFieldType = 'type' in (props.config || {}) ? props.config.type : '';
|
|
701
|
+
if (typeof rawFieldType !== 'string' || !rawFieldType) {
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// 统一将驼峰形式(如 radioGroup)归一化为连字符形式(radio-group),与内置规则的 key 保持一致
|
|
706
|
+
const fieldType = toLine(rawFieldType);
|
|
707
|
+
|
|
683
708
|
const customValidator = getTypeMatchRule(fieldType);
|
|
684
709
|
|
|
685
710
|
// 自定义规则优先:可覆盖内置规则,也可为业务自定义字段 type 扩展校验
|
|
@@ -695,11 +720,15 @@ export const createTypeMatchValidator = (mForm: FormState | undefined, props: an
|
|
|
695
720
|
|
|
696
721
|
return (asyncValidatorRule: any, value: any, callback: Function, source: any, options: any) => {
|
|
697
722
|
const actualValue = props.config?.names ? props.model : value;
|
|
698
|
-
|
|
723
|
+
try {
|
|
724
|
+
const error = validateTypeMatch(actualValue, mForm, props, rule.message);
|
|
699
725
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
726
|
+
if (error) {
|
|
727
|
+
callback(new Error(error));
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
} catch (error) {
|
|
731
|
+
console.error(error);
|
|
703
732
|
}
|
|
704
733
|
|
|
705
734
|
if (originalValidator) {
|
package/types/index.d.ts
CHANGED
|
@@ -200,6 +200,14 @@ interface ValidateFormOptions {
|
|
|
200
200
|
debug?: boolean;
|
|
201
201
|
typeMatchValid?: boolean;
|
|
202
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;
|
|
203
211
|
/**
|
|
204
212
|
* 以命令式方式对一份「表单配置 + 值」做一次静默校验,**不依赖也不影响任何已渲染的表单**。
|
|
205
213
|
*
|
|
@@ -264,6 +272,21 @@ declare const sortChange: (data: any[], {
|
|
|
264
272
|
prop,
|
|
265
273
|
order
|
|
266
274
|
}: schema_d_exports.SortProp) => void;
|
|
275
|
+
/**
|
|
276
|
+
* 将 extendState 返回的扩展字段合并进 formState。
|
|
277
|
+
*
|
|
278
|
+
* - data 描述符(普通字段)通过 `formState[key] = value` 写入,走 reactive proxy 的 set,
|
|
279
|
+
* 触发依赖通知;
|
|
280
|
+
* - accessor 描述符(`{ get stage() { return ... } }`)按原样 defineProperty,调用方
|
|
281
|
+
* 可控制读时求值;强制 `configurable: true` 以便下一次合并可再 define。
|
|
282
|
+
*
|
|
283
|
+
* 注意:formState 上由 props 派生的字段(keyProp / popperClass / config / initValues /
|
|
284
|
+
* isCompare / lastValues / parentValues)是只读 getter(无 setter),extendState 若以
|
|
285
|
+
* 普通字段形式返回同名 key,直接赋值会让 proxy 的 set trap 失败并抛出
|
|
286
|
+
* `TypeError: 'set' on proxy: trap returned falsish`,这里统一跳过并告警;
|
|
287
|
+
* 如确需覆盖,可在 extendState 中以 get 访问器形式返回。
|
|
288
|
+
*/
|
|
289
|
+
declare const applyExtendState: (formState: schema_d_exports.FormState, state: Record<string, any> | null | undefined) => void;
|
|
267
290
|
declare const createObjectProp: (prop: string, key: string, name?: string | number) => string;
|
|
268
291
|
//#endregion
|
|
269
292
|
//#region temp/packages/form/src/utils/useAddField.d.ts
|
|
@@ -327,6 +350,15 @@ type __VLS_Props$30 = {
|
|
|
327
350
|
* 通过 provide 下发,对整棵表单的所有层级 Container 生效,只需在 MForm 这一层传一次。
|
|
328
351
|
*/
|
|
329
352
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
353
|
+
/**
|
|
354
|
+
* 主题名称:对应 `packages/form/src/theme/themes/<theme>/index.scss` 的目录名。
|
|
355
|
+
*
|
|
356
|
+
* 设置后会在表单根元素上追加 `m-form--<theme>` 修饰类,配合按需引入
|
|
357
|
+
* `@tmagic/form/dist/themes/<theme>.css` 即可启用主题样式。
|
|
358
|
+
*
|
|
359
|
+
* 例如:`<MForm theme="magic-admin" />` + `import '@tmagic/form/dist/themes/magic-admin.css'`。
|
|
360
|
+
*/
|
|
361
|
+
theme?: string;
|
|
330
362
|
};
|
|
331
363
|
declare const __VLS_base$5: import("@vue/runtime-core").DefineComponent<__VLS_Props$30, {
|
|
332
364
|
values: import("@vue/reactivity").Ref<schema_d_exports.FormValue, schema_d_exports.FormValue>;
|
|
@@ -414,6 +446,12 @@ type __VLS_Props$29 = {
|
|
|
414
446
|
showCancel?: boolean; /** 透传给内部 `MForm`,控制表单校验失败时错误提示前缀是否使用字段的 text 文案 */
|
|
415
447
|
useFieldTextInError?: boolean; /** 透传给内部 `MForm`,用于扩展 `formState`(如注入 `$message` / `$store` 等) */
|
|
416
448
|
extendState?: (_state: schema_d_exports.FormState) => Record<string, any> | Promise<Record<string, any>>;
|
|
449
|
+
/**
|
|
450
|
+
* 主题名。优先级:传入 `theme` prop > 祖先 `provide(M_THEME_KEY)` > 空串。
|
|
451
|
+
* 计算结果会再次 `provide` 出去,使得 Dialog 被 Teleport 到 body 后,内部子树
|
|
452
|
+
* (包括 `MForm` 以及更深的 popover / dropdown)仍能拿到主题。
|
|
453
|
+
*/
|
|
454
|
+
theme?: string;
|
|
417
455
|
};
|
|
418
456
|
declare var __VLS_19: {}, __VLS_34: {}, __VLS_42: {};
|
|
419
457
|
type __VLS_Slots$4 = {} & {
|
|
@@ -452,6 +490,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
452
490
|
config: any;
|
|
453
491
|
}) => boolean) | undefined;
|
|
454
492
|
readonly selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]) | undefined;
|
|
493
|
+
readonly theme?: string | undefined;
|
|
455
494
|
readonly onError?: ((...args: any[]) => any) | undefined;
|
|
456
495
|
readonly onChange?: ((...args: any[]) => any) | undefined;
|
|
457
496
|
readonly "onField-input"?: ((...args: any[]) => any) | undefined;
|
|
@@ -495,6 +534,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
495
534
|
config: any;
|
|
496
535
|
}) => boolean;
|
|
497
536
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
537
|
+
theme?: string;
|
|
498
538
|
}> & Readonly<{
|
|
499
539
|
onError?: ((...args: any[]) => any) | undefined;
|
|
500
540
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -591,6 +631,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
591
631
|
config: any;
|
|
592
632
|
}) => boolean;
|
|
593
633
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
634
|
+
theme?: string;
|
|
594
635
|
}> & Readonly<{
|
|
595
636
|
onError?: ((...args: any[]) => any) | undefined;
|
|
596
637
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -638,6 +679,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
638
679
|
config: any;
|
|
639
680
|
}) => boolean) | undefined;
|
|
640
681
|
readonly selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]) | undefined;
|
|
682
|
+
readonly theme?: string | undefined;
|
|
641
683
|
readonly onError?: ((...args: any[]) => any) | undefined;
|
|
642
684
|
readonly onChange?: ((...args: any[]) => any) | undefined;
|
|
643
685
|
readonly "onField-input"?: ((...args: any[]) => any) | undefined;
|
|
@@ -681,6 +723,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
681
723
|
config: any;
|
|
682
724
|
}) => boolean;
|
|
683
725
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
726
|
+
theme?: string;
|
|
684
727
|
}> & Readonly<{
|
|
685
728
|
onError?: ((...args: any[]) => any) | undefined;
|
|
686
729
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -777,6 +820,7 @@ declare const __VLS_base$4: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
777
820
|
config: any;
|
|
778
821
|
}) => boolean;
|
|
779
822
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
823
|
+
theme?: string;
|
|
780
824
|
}> & Readonly<{
|
|
781
825
|
onError?: ((...args: any[]) => any) | undefined;
|
|
782
826
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -852,6 +896,12 @@ type __VLS_Props$28 = {
|
|
|
852
896
|
useFieldTextInError?: boolean; /** 关闭前的回调,会暂停 Drawer 的关闭; done 是个 function type 接受一个 boolean 参数, 执行 done 使用 true 参数或不提供参数将会终止关闭 */
|
|
853
897
|
beforeClose?: (_done: (_cancel?: boolean) => void) => void; /** 透传给内部 `MForm`,用于扩展 `formState`(如注入 `$message` / `$store` 等) */
|
|
854
898
|
extendState?: (_state: schema_d_exports.FormState) => Record<string, any> | Promise<Record<string, any>>;
|
|
899
|
+
/**
|
|
900
|
+
* 主题名。优先级:传入 `theme` prop > 祖先 `provide(M_THEME_KEY)` > 空串。
|
|
901
|
+
* 计算结果会再次 `provide` 出去,使得 Drawer 被 Teleport 到 body 后,内部子树
|
|
902
|
+
* (包括 `MForm` 以及更深的 popover / dropdown)仍能拿到主题。
|
|
903
|
+
*/
|
|
904
|
+
theme?: string;
|
|
855
905
|
};
|
|
856
906
|
declare var __VLS_23: {}, __VLS_38: {}, __VLS_46: {};
|
|
857
907
|
type __VLS_Slots$3 = {} & {
|
|
@@ -890,6 +940,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
890
940
|
config: any;
|
|
891
941
|
}) => boolean) | undefined;
|
|
892
942
|
readonly selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]) | undefined;
|
|
943
|
+
readonly theme?: string | undefined;
|
|
893
944
|
readonly onError?: ((...args: any[]) => any) | undefined;
|
|
894
945
|
readonly onChange?: ((...args: any[]) => any) | undefined;
|
|
895
946
|
readonly "onField-input"?: ((...args: any[]) => any) | undefined;
|
|
@@ -933,6 +984,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
933
984
|
config: any;
|
|
934
985
|
}) => boolean;
|
|
935
986
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
987
|
+
theme?: string;
|
|
936
988
|
}> & Readonly<{
|
|
937
989
|
onError?: ((...args: any[]) => any) | undefined;
|
|
938
990
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -1029,6 +1081,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
1029
1081
|
config: any;
|
|
1030
1082
|
}) => boolean;
|
|
1031
1083
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
1084
|
+
theme?: string;
|
|
1032
1085
|
}> & Readonly<{
|
|
1033
1086
|
onError?: ((...args: any[]) => any) | undefined;
|
|
1034
1087
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -1076,6 +1129,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
1076
1129
|
config: any;
|
|
1077
1130
|
}) => boolean) | undefined;
|
|
1078
1131
|
readonly selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]) | undefined;
|
|
1132
|
+
readonly theme?: string | undefined;
|
|
1079
1133
|
readonly onError?: ((...args: any[]) => any) | undefined;
|
|
1080
1134
|
readonly onChange?: ((...args: any[]) => any) | undefined;
|
|
1081
1135
|
readonly "onField-input"?: ((...args: any[]) => any) | undefined;
|
|
@@ -1119,6 +1173,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
1119
1173
|
config: any;
|
|
1120
1174
|
}) => boolean;
|
|
1121
1175
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
1176
|
+
theme?: string;
|
|
1122
1177
|
}> & Readonly<{
|
|
1123
1178
|
onError?: ((...args: any[]) => any) | undefined;
|
|
1124
1179
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -1215,6 +1270,7 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
1215
1270
|
config: any;
|
|
1216
1271
|
}) => boolean;
|
|
1217
1272
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
1273
|
+
theme?: string;
|
|
1218
1274
|
}> & Readonly<{
|
|
1219
1275
|
onError?: ((...args: any[]) => any) | undefined;
|
|
1220
1276
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -1237,8 +1293,11 @@ declare const __VLS_base$3: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
1237
1293
|
}) | undefined>;
|
|
1238
1294
|
saveFetch: import("@vue/reactivity").Ref<boolean, boolean>;
|
|
1239
1295
|
bodyHeight: import("@vue/reactivity").Ref<number, number>;
|
|
1296
|
+
close: () => void;
|
|
1240
1297
|
show: () => void;
|
|
1241
1298
|
hide: () => void;
|
|
1299
|
+
save: () => Promise<void>;
|
|
1300
|
+
cancel: () => void;
|
|
1242
1301
|
handleClose: () => void;
|
|
1243
1302
|
}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
|
|
1244
1303
|
error: (...args: any[]) => void;
|
|
@@ -1326,6 +1385,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
1326
1385
|
config: any;
|
|
1327
1386
|
}) => boolean) | undefined;
|
|
1328
1387
|
readonly selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]) | undefined;
|
|
1388
|
+
readonly theme?: string | undefined;
|
|
1329
1389
|
readonly onError?: ((...args: any[]) => any) | undefined;
|
|
1330
1390
|
readonly onChange?: ((...args: any[]) => any) | undefined;
|
|
1331
1391
|
readonly "onField-input"?: ((...args: any[]) => any) | undefined;
|
|
@@ -1369,6 +1429,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
1369
1429
|
config: any;
|
|
1370
1430
|
}) => boolean;
|
|
1371
1431
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
1432
|
+
theme?: string;
|
|
1372
1433
|
}> & Readonly<{
|
|
1373
1434
|
onError?: ((...args: any[]) => any) | undefined;
|
|
1374
1435
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -1465,6 +1526,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
1465
1526
|
config: any;
|
|
1466
1527
|
}) => boolean;
|
|
1467
1528
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
1529
|
+
theme?: string;
|
|
1468
1530
|
}> & Readonly<{
|
|
1469
1531
|
onError?: ((...args: any[]) => any) | undefined;
|
|
1470
1532
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -1512,6 +1574,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
1512
1574
|
config: any;
|
|
1513
1575
|
}) => boolean) | undefined;
|
|
1514
1576
|
readonly selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]) | undefined;
|
|
1577
|
+
readonly theme?: string | undefined;
|
|
1515
1578
|
readonly onError?: ((...args: any[]) => any) | undefined;
|
|
1516
1579
|
readonly onChange?: ((...args: any[]) => any) | undefined;
|
|
1517
1580
|
readonly "onField-input"?: ((...args: any[]) => any) | undefined;
|
|
@@ -1555,6 +1618,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
1555
1618
|
config: any;
|
|
1556
1619
|
}) => boolean;
|
|
1557
1620
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
1621
|
+
theme?: string;
|
|
1558
1622
|
}> & Readonly<{
|
|
1559
1623
|
onError?: ((...args: any[]) => any) | undefined;
|
|
1560
1624
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -1651,6 +1715,7 @@ declare const __VLS_base$2: import("@vue/runtime-core").DefineComponent<__VLS_Pr
|
|
|
1651
1715
|
config: any;
|
|
1652
1716
|
}) => boolean;
|
|
1653
1717
|
selfDiffFieldTypes?: string[] | ((_defaultTypes: string[]) => string[]);
|
|
1718
|
+
theme?: string;
|
|
1654
1719
|
}> & Readonly<{
|
|
1655
1720
|
onError?: ((...args: any[]) => any) | undefined;
|
|
1656
1721
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
@@ -1789,6 +1854,7 @@ type __VLS_Props$23 = {
|
|
|
1789
1854
|
prop?: string;
|
|
1790
1855
|
size?: string;
|
|
1791
1856
|
disabled?: boolean;
|
|
1857
|
+
hideExpand?: boolean;
|
|
1792
1858
|
};
|
|
1793
1859
|
declare var __VLS_16: {}, __VLS_18: {};
|
|
1794
1860
|
type __VLS_Slots = {} & {
|
|
@@ -2038,7 +2104,9 @@ declare const __VLS_export$4: import("@vue/runtime-core").DefineComponent<__VLS_
|
|
|
2038
2104
|
declare const _default$8: typeof __VLS_export$4;
|
|
2039
2105
|
//#endregion
|
|
2040
2106
|
//#region temp/packages/form/src/fields/Link.vue.d.ts
|
|
2041
|
-
type __VLS_Props$3 = schema_d_exports.FieldProps<schema_d_exports.LinkConfig
|
|
2107
|
+
type __VLS_Props$3 = schema_d_exports.FieldProps<schema_d_exports.LinkConfig> & {
|
|
2108
|
+
theme?: string;
|
|
2109
|
+
};
|
|
2042
2110
|
declare const __VLS_export$3: import("@vue/runtime-core").DefineComponent<__VLS_Props$3, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
|
|
2043
2111
|
change: (...args: any[]) => void;
|
|
2044
2112
|
}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props$3> & Readonly<{
|
|
@@ -2130,6 +2198,7 @@ declare const validateTypeMatch: (value: any, mForm: schema_d_exports.FormState
|
|
|
2130
2198
|
//#endregion
|
|
2131
2199
|
//#region temp/packages/form/src/plugin.d.ts
|
|
2132
2200
|
interface FormInstallOptions {
|
|
2201
|
+
flat?: boolean;
|
|
2133
2202
|
/** 自定义字段 type 的 typeMatch 校验规则,可覆盖内置规则或扩展业务字段 */
|
|
2134
2203
|
typeMatchRules?: Record<string, TypeMatchValidator>;
|
|
2135
2204
|
[key: string]: any;
|
|
@@ -2138,8 +2207,8 @@ declare const _default$31: {
|
|
|
2138
2207
|
install(app: App, opt?: FormInstallOptions): void;
|
|
2139
2208
|
};
|
|
2140
2209
|
declare namespace index_d_exports {
|
|
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 };
|
|
2210
|
+
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, applyExtendState, 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 };
|
|
2142
2211
|
}
|
|
2143
2212
|
declare const createForm: <T extends [] = []>(config: schema_d_exports.FormConfig | T) => schema_d_exports.FormConfig | T;
|
|
2144
2213
|
//#endregion
|
|
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 };
|
|
2214
|
+
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, applyExtendState, 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 };
|