mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-06-05 01:32:10 +08:00
feat(form): 容器组件新增 extendState 属性
FormBox、FormDialog、FormDrawer 新增 extendState 属性,并透传给内部 MForm, 方便外层注入 $message、$store 等扩展上下文到 formState。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
05e512b1fe
commit
2d31b3812f
@ -13,6 +13,7 @@
|
|||||||
:label-position="labelPosition"
|
:label-position="labelPosition"
|
||||||
:inline="inline"
|
:inline="inline"
|
||||||
:prevent-submit-default="preventSubmitDefault"
|
:prevent-submit-default="preventSubmitDefault"
|
||||||
|
:extend-state="extendState"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
></Form>
|
></Form>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
@ -40,7 +41,7 @@ import { computed, ref, watchEffect } from 'vue';
|
|||||||
import { TMagicButton, TMagicScrollbar } from '@tmagic/design';
|
import { TMagicButton, TMagicScrollbar } from '@tmagic/design';
|
||||||
|
|
||||||
import Form from './Form.vue';
|
import Form from './Form.vue';
|
||||||
import type { ContainerChangeEventData, FormConfig, FormValue } from './schema';
|
import type { ContainerChangeEventData, FormConfig, FormState, FormValue } from './schema';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'MFormBox',
|
name: 'MFormBox',
|
||||||
@ -60,6 +61,7 @@ const props = withDefaults(
|
|||||||
inline?: boolean;
|
inline?: boolean;
|
||||||
labelPosition?: string;
|
labelPosition?: string;
|
||||||
preventSubmitDefault?: boolean;
|
preventSubmitDefault?: boolean;
|
||||||
|
extendState?: (_state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
config: () => [],
|
config: () => [],
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
:label-position="labelPosition"
|
:label-position="labelPosition"
|
||||||
:inline="inline"
|
:inline="inline"
|
||||||
:prevent-submit-default="preventSubmitDefault"
|
:prevent-submit-default="preventSubmitDefault"
|
||||||
|
:extend-state="extendState"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
></Form>
|
></Form>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
@ -68,7 +69,7 @@ import { computed, ref } from 'vue';
|
|||||||
import { TMagicButton, TMagicCol, TMagicDialog, TMagicRow } from '@tmagic/design';
|
import { TMagicButton, TMagicCol, TMagicDialog, TMagicRow } from '@tmagic/design';
|
||||||
|
|
||||||
import Form from './Form.vue';
|
import Form from './Form.vue';
|
||||||
import { ContainerChangeEventData, FormConfig, FormValue, StepConfig } from './schema';
|
import { ContainerChangeEventData, FormConfig, FormState, FormValue, StepConfig } from './schema';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'MFormDialog',
|
name: 'MFormDialog',
|
||||||
@ -95,6 +96,8 @@ const props = withDefaults(
|
|||||||
destroyOnClose?: boolean;
|
destroyOnClose?: boolean;
|
||||||
showClose?: boolean;
|
showClose?: boolean;
|
||||||
showCancel?: boolean;
|
showCancel?: boolean;
|
||||||
|
/** 透传给内部 `MForm`,用于扩展 `formState`(如注入 `$message` / `$store` 等) */
|
||||||
|
extendState?: (_state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
config: () => [],
|
config: () => [],
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
:label-position="labelPosition"
|
:label-position="labelPosition"
|
||||||
:inline="inline"
|
:inline="inline"
|
||||||
:prevent-submit-default="preventSubmitDefault"
|
:prevent-submit-default="preventSubmitDefault"
|
||||||
|
:extend-state="extendState"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
></Form>
|
></Form>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
@ -59,7 +60,7 @@ import { ref, watchEffect } from 'vue';
|
|||||||
import { TMagicButton, TMagicCol, TMagicDrawer, TMagicRow } from '@tmagic/design';
|
import { TMagicButton, TMagicCol, TMagicDrawer, TMagicRow } from '@tmagic/design';
|
||||||
|
|
||||||
import Form from './Form.vue';
|
import Form from './Form.vue';
|
||||||
import type { ContainerChangeEventData, FormConfig, FormValue } from './schema';
|
import type { ContainerChangeEventData, FormConfig, FormState, FormValue } from './schema';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'MFormDialog',
|
name: 'MFormDialog',
|
||||||
@ -83,6 +84,8 @@ withDefaults(
|
|||||||
preventSubmitDefault?: boolean;
|
preventSubmitDefault?: boolean;
|
||||||
/** 关闭前的回调,会暂停 Drawer 的关闭; done 是个 function type 接受一个 boolean 参数, 执行 done 使用 true 参数或不提供参数将会终止关闭 */
|
/** 关闭前的回调,会暂停 Drawer 的关闭; done 是个 function type 接受一个 boolean 参数, 执行 done 使用 true 参数或不提供参数将会终止关闭 */
|
||||||
beforeClose?: (_done: (_cancel?: boolean) => void) => void;
|
beforeClose?: (_done: (_cancel?: boolean) => void) => void;
|
||||||
|
/** 透传给内部 `MForm`,用于扩展 `formState`(如注入 `$message` / `$store` 等) */
|
||||||
|
extendState?: (_state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
closeOnPressEscape: true,
|
closeOnPressEscape: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user