Skip to content

Commit

Permalink
feat(form-item): support string format for labelWidth/wrapperWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Apr 16, 2021
1 parent 98922c8 commit 228e259
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions packages/antd/docs/components/FormItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -1068,8 +1068,8 @@ export default () => {
| tooltip | ReactNode | 问号提示 | - |
| labelAlign | `"left"` \| `"right"` | 标签文本对齐方式 | `"right"` |
| labelWrap | boolean | 标签换⾏,否则出现省略号,hover 有 tooltip | false |
| labelWidth | number | 标签固定宽度 | - |
| wrapperWidth | number | 内容固定宽度 | - |
| labelWidth | `number \| string` | 标签固定宽度 | - |
| wrapperWidth | `number \| string` | 内容固定宽度 | - |
| labelCol | number | 标签⽹格所占列数,和内容列数加起来总和为 24 | - |
| wrapperCol | number | 内容⽹格所占列数,和标签列数加起来总和为 24 | - |
| wrapperAlign | `"left"` \| `"right"` | 内容文本对齐方式⻬ | `"left"` |
Expand Down
12 changes: 6 additions & 6 deletions packages/antd/src/form-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface IFormItemProps {
labelStyle?: React.CSSProperties
labelAlign?: 'left' | 'right'
labelWrap?: boolean
labelWidth?: number
wrapperWidth?: number
labelWidth?: number | string
wrapperWidth?: number | string
labelCol?: number
wrapperCol?: number
wrapperAlign?: 'left' | 'right'
Expand Down Expand Up @@ -128,12 +128,12 @@ export const BaseItem: React.FC<IFormItemProps> = (props) => {
let enableCol = false
if (labelWidth || wrapperWidth) {
if (labelWidth) {
labelStyle.width = `${labelWidth}px`
labelStyle.maxWidth = `${labelWidth}px`
labelStyle.width = labelWidth
labelStyle.maxWidth = labelWidth
}
if (wrapperWidth) {
wrapperStyle.width = `${wrapperWidth}px`
wrapperStyle.maxWidth = `${wrapperWidth}px`
wrapperStyle.width = wrapperWidth
wrapperStyle.maxWidth = wrapperWidth
}
// 栅格模式
} else if (labelCol || wrapperCol) {
Expand Down
4 changes: 2 additions & 2 deletions packages/next/docs/components/FormItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,8 @@ export default () => {
| tooltip | ReactNode | 问号提示 | - |
| labelAlign | `"left"` \| `"right"` | 标签文本对齐方式 | `"right"` |
| labelWrap | boolean | 标签换⾏,否则出现省略号,hover 有 tooltip | false |
| labelWidth | number | 标签固定宽度 | - |
| wrapperWidth | number | 内容固定宽度 | - |
| labelWidth | `number \| string` | 标签固定宽度 | - |
| wrapperWidth | `number \| string` | 内容固定宽度 | - |
| labelCol | number | 标签⽹格所占列数,和内容列数加起来总和为 24 | - |
| wrapperCol | number | 内容⽹格所占列数,和标签列数加起来总和为 24 | - |
| wrapperAlign | `"left"` \| `"right"` | 内容文本对齐方式⻬ | `"left"` |
Expand Down
12 changes: 6 additions & 6 deletions packages/next/src/form-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface IFormItemProps {
labelStyle?: React.CSSProperties
labelAlign?: 'left' | 'right'
labelWrap?: boolean
labelWidth?: number
wrapperWidth?: number
labelWidth?: number | string
wrapperWidth?: number | string
labelCol?: number
wrapperCol?: number
wrapperAlign?: 'left' | 'right'
Expand Down Expand Up @@ -128,12 +128,12 @@ export const BaseItem: React.FC<IFormItemProps> = (props) => {
let enableCol = false
if (labelWidth || wrapperWidth) {
if (labelWidth) {
labelStyle.width = `${labelWidth}px`
labelStyle.maxWidth = `${labelWidth}px`
labelStyle.width = labelWidth
labelStyle.maxWidth = labelWidth
}
if (wrapperWidth) {
wrapperStyle.width = `${wrapperWidth}px`
wrapperStyle.maxWidth = `${wrapperWidth}px`
wrapperStyle.width = wrapperWidth
wrapperStyle.maxWidth = wrapperWidth
}
// 栅格模式
} else if (labelCol || wrapperCol) {
Expand Down

0 comments on commit 228e259

Please sign in to comment.