Skip to content

Commit 3b3c68e

Browse files
feat(form-item): add content-classcontent-style props (#7199)
Co-authored-by: 07akioni <[email protected]>
1 parent 5e422f9 commit 3b3c68e

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

CHANGELOG.en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- Add `n-image-preview` component.
3737
- `n-image-group` can be used without `n-image`.
3838
- `n-input-otp` adds `focusOnChar` util method, closes [#7073](https://github.com/tusen-ai/naive-ui/issues/7073).
39+
- `n-form-item` adds `content-class``content-style` props.
3940
- `n-message` adds `border` theme variable, closes [#7105](https://github.com/tusen-ai/naive-ui/issues/7105).
4041
- `n-modal` adds `mask-visible` prop.
4142
- `useModal` add `render` function, closes [#5857](https://github.com/tusen-ai/naive-ui/issues/5857).

CHANGELOG.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- 新增 `n-image-preview` 组件
3838
- `n-image-group` 可以脱离 `n-image` 使用
3939
- `n-input-otp` 增加 `focusOnChar` 方法,关闭 [#7073](https://github.com/tusen-ai/naive-ui/issues/7073)
40+
- `n-form-item` 新增 `content-class``content-style` 属性
4041
- `n-message` 增加 `border` 主题变量,关闭 [#7105](https://github.com/tusen-ai/naive-ui/issues/7105)
4142
- `n-modal` 增加 `mask-visible` 属性
4243
- `useModal` 新增 `render` 函数,关闭 [#5857](https://github.com/tusen-ai/naive-ui/issues/5857)

src/form/demos/enUS/index.demo-entry.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ feedback-style.vue
7878
| feedback | `string` | `undefined` | The feedback message of the form item. If set, it will replace any result of rule-based validation. | |
7979
| feedback-class | `string` | `undefined` | Feedback check vertical display positioning | 2.38.2 |
8080
| feedback-style | `string \| object` | `undefined` | Feedback check horizontal display positioning | 2.38.2 |
81+
| content-class | `string` | `undefined` | The class name of the content | NEXT_VERSION |
82+
| content-style | `string \| object` | `undefined` | The style of the content | NEXT_VERSION |
8183
| first | `boolean` | `false` | Whether to only show the first validation error message. | |
8284
| ignore-path-change | `boolean` | `false` | Usually, changing `path` will cause a re-render and naive-ui will clear the validation result. Setting `ignore-path-change` to `true` will disable that behavior. | |
8385
| label | `string` | `undefined` | Label. | |

src/form/demos/zhCN/index.demo-entry.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ feedback-style.vue
7272
| feedback | `string` | `undefined` | 表项的反馈信息。不设为 `undefined` 时,会覆盖规则验证的结果 | |
7373
| feedback-class | `string` | `undefined` | 反馈校验竖向展示定位 | 2.38.2 |
7474
| feedback-style | `string \| object` | `undefined` | 反馈校验横向展示定位 | 2.38.2 |
75+
| content-class | `string` | `undefined` | 内容的类名 | NEXT_VERSION |
76+
| content-style | `string \| object` | `undefined` | 内容的样式 | NEXT_VERSION |
7577
| first | `boolean` | `false` | 是否只展示首个出错信息 | |
7678
| ignore-path-change | `boolean` | `false` | 通常 `path` 的改变会导致数据来源的变化,所以 naive-ui 会清空验证信息。如果不期望这个行为,可以将其置为 `true` | |
7779
| label | `string` | `undefined` | 标签信息 | |

src/form/src/FormItem.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ export const formItemProps = {
8585
type: Boolean as PropType<boolean | undefined>,
8686
default: undefined
8787
},
88-
labelProps: Object as PropType<LabelHTMLAttributes>
88+
labelProps: Object as PropType<LabelHTMLAttributes>,
89+
contentClass: String,
90+
contentStyle: [String, Object] as PropType<string | CSSProperties>
8991
} as const
9092

9193
export type FormItemSetupProps = ExtractPropTypes<typeof formItemProps>
@@ -610,9 +612,11 @@ export default defineComponent({
610612
<div
611613
class={[
612614
`${mergedClsPrefix}-form-item-blank`,
615+
this.contentClass,
613616
this.mergedValidationStatus
614617
&& `${mergedClsPrefix}-form-item-blank--${this.mergedValidationStatus}`
615618
]}
619+
style={this.contentStyle}
616620
>
617621
{$slots}
618622
</div>

0 commit comments

Comments
 (0)