diff --git a/packages/form/src/containers/Container.vue b/packages/form/src/containers/Container.vue index 68965711..ea68c307 100644 --- a/packages/form/src/containers/Container.vue +++ b/packages/form/src/containers/Container.vue @@ -312,6 +312,7 @@ const type = computed((): string => { }); } if (type === 'form') return ''; + if (type === 'container') return ''; return type?.replace(/([A-Z])/g, '-$1').toLowerCase() || (items.value ? '' : 'text'); }); diff --git a/packages/form/src/fields/Text.vue b/packages/form/src/fields/Text.vue index 2f9fb71a..7e9fd178 100644 --- a/packages/form/src/fields/Text.vue +++ b/packages/form/src/fields/Text.vue @@ -11,15 +11,14 @@ @input="inputHandler" @keyup="keyUpHandler($event)" > - - diff --git a/packages/form/src/index.ts b/packages/form/src/index.ts index 398a9928..38947bd5 100644 --- a/packages/form/src/index.ts +++ b/packages/form/src/index.ts @@ -49,6 +49,7 @@ import Timerange from './fields/Timerange.vue'; import { setConfig } from './utils/config'; import Form from './Form.vue'; import FormDialog from './FormDialog.vue'; +import type { FormConfig } from './schema'; import './theme/index.scss'; @@ -88,6 +89,10 @@ export { default as MSelect } from './fields/Select.vue'; export { default as MCascader } from './fields/Cascader.vue'; export { default as MDynamicField } from './fields/DynamicField.vue'; +export const createForm = function (config: FormConfig) { + return config; +}; + export interface InstallOptions { [key: string]: any; } diff --git a/packages/form/src/schema.ts b/packages/form/src/schema.ts index 4e1bcb12..aa8dcc34 100644 --- a/packages/form/src/schema.ts +++ b/packages/form/src/schema.ts @@ -320,8 +320,9 @@ export interface TextConfig extends FormItem, Input { | string | { text: string; + value?: 0 | 1; type: 'button'; - handler: ( + handler?: ( mForm: FormState | undefined, data: { model: any; diff --git a/packages/form/src/theme/index.scss b/packages/form/src/theme/index.scss index 34e65f24..61bcb5cd 100644 --- a/packages/form/src/theme/index.scss +++ b/packages/form/src/theme/index.scss @@ -2,6 +2,7 @@ @use "./form-drawer.scss"; @use "./form.scss"; @use "./date-time.scss"; +@use "./text.scss"; @use "./link.scss"; @use "./fieldset.scss"; @use "./group-list.scss"; diff --git a/packages/form/src/theme/text.scss b/packages/form/src/theme/text.scss new file mode 100644 index 00000000..baddc5f4 --- /dev/null +++ b/packages/form/src/theme/text.scss @@ -0,0 +1,6 @@ +.m-form-validate__warning { + color: var(--el-color-warning); + font-size: 12px; + width: 100%; + line-height: 1.4; +} diff --git a/packages/form/src/utils/createForm.ts b/packages/form/src/utils/createForm.ts deleted file mode 100644 index df420830..00000000 --- a/packages/form/src/utils/createForm.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making TMagicEditor available. - * - * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { FormConfig } from '../schema'; - -export const createForm = function (config: FormConfig) { - return config; -}; - -export default createForm; diff --git a/packages/form/tests/unit/utils/createForm.spec.ts b/packages/form/tests/unit/utils/createForm.spec.ts index 6ad60a88..1fc7d800 100644 --- a/packages/form/tests/unit/utils/createForm.spec.ts +++ b/packages/form/tests/unit/utils/createForm.spec.ts @@ -20,7 +20,7 @@ import { describe, expect, test } from 'vitest'; import { FormConfig } from '@tmagic/form'; -import createForm from '../../../src/utils/createForm'; +import { createForm } from '../../../src'; describe('createForm', () => { test('正常创建', () => {