Skip to content

Commit

Permalink
feat(Form): FormItem 支持自定义 content 样式 (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanchun committed Mar 29, 2024
1 parent f752734 commit 5e64cad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/form/formItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{ label }}
</slot>
</span>
<div :class="`${prefixCls}-content`">
<div :class="`${prefixCls}-content`" :style="contentStyle">
<slot></slot>
<transition name="fes-fade">
<div v-if="formItemShowMessage" :class="`${prefixCls}-error`">
Expand Down
13 changes: 11 additions & 2 deletions components/form/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
type ToRefs,
type Ref,
type ComponentObjectPropsOptions,
type CSSProperties,
} from 'vue';
import { FORM_LAYOUT, LABEL_POSITION, FORM_ITEM_ALIGN } from './const';
import type { RuleItem, Rules } from 'async-validator';
Expand Down Expand Up @@ -40,12 +41,12 @@ export const formProps = {
>,
default: LABEL_POSITION.LEFT,
},
labelWidth: [String, Number] as PropType<string | number>,
labelClass: String,
showMessage: {
type: Boolean,
default: true,
},
labelWidth: [String, Number] as PropType<string | number>,
labelClass: String,
disabled: {
type: Boolean,
default: false,
Expand All @@ -69,6 +70,14 @@ export const formItemProps = {
label: String,
labelWidth: [String, Number] as PropType<string | number>,
labelClass: String,
contentStyle: {
type: [String, Array, Object] as PropType<
string | CSSProperties[] | CSSProperties
>,
default() {
return {};
},
},
span: {
type: Number,
default: null as number,
Expand Down
11 changes: 10 additions & 1 deletion docs/.vitepress/components/form/basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<FRadio :value="2">女</FRadio>
</FRadioGroup>
</FFormItem>
<FFormItem label="这是一段长的表单项描述" align="center">
<FFormItem label="这是一段长的表单项描述">
<FInput placeholder="请输入"></FInput>
</FFormItem>
<FFormItem label="年龄范围">
Expand All @@ -41,6 +41,15 @@
<FCheckbox :value="61 - 65">61 - 65</FCheckbox>
</FCheckboxGroup>
</FFormItem>
<FFormItem label="上传" :contentStyle="{ display: 'block' }">
<FUpload>
<template #tip>
<div class="f-upload__tip">
只能上传 jpg/png 等图片文件,且不超过 5KB
</div>
</template>
</FUpload>
</FFormItem>
<FFormItem label=" ">
<FButton type="primary">Submit</FButton>
</FFormItem>
Expand Down

0 comments on commit 5e64cad

Please sign in to comment.