From 79815a5a63563622071a524006096bbcd7727d0b Mon Sep 17 00:00:00 2001 From: xz8la8 <174785876@qq.com> Date: Thu, 1 Apr 2021 12:09:06 +0800 Subject: [PATCH] =?UTF-8?q?chore(form):=20=E4=BC=98=E5=8C=96=E5=B8=83?= =?UTF-8?q?=E5=B1=80=20-=20sula@v1.2.0-beta.42?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/private/formLayout.md | 10 +++++ docs/private/formLayout.tsx | 48 ++++++++++++++++++++++ packages/sula/package.json | 2 +- packages/sula/src/form/utils/layoutUtil.ts | 9 ++-- 4 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 docs/private/formLayout.md create mode 100644 docs/private/formLayout.tsx diff --git a/docs/private/formLayout.md b/docs/private/formLayout.md new file mode 100644 index 0000000..2f79d8f --- /dev/null +++ b/docs/private/formLayout.md @@ -0,0 +1,10 @@ +--- +group: + title: 对内测试 + order: 99 +title: Form布局 +order: 1 +--- + + + diff --git a/docs/private/formLayout.tsx b/docs/private/formLayout.tsx new file mode 100644 index 0000000..5518eee --- /dev/null +++ b/docs/private/formLayout.tsx @@ -0,0 +1,48 @@ +import React from 'react'; +import { Form } from 'sula'; + +export default class LayoutDemo extends React.Component { + render() { + return ( +
+ ); + } +} diff --git a/packages/sula/package.json b/packages/sula/package.json index dc8b2ac..c849051 100644 --- a/packages/sula/package.json +++ b/packages/sula/package.json @@ -1,6 +1,6 @@ { "name": "sula", - "version": "1.2.0-beta.41", + "version": "1.2.0-beta.42", "module": "./es/index.js", "main": "./es/index.js", "types": "./es/index.d.ts", diff --git a/packages/sula/src/form/utils/layoutUtil.ts b/packages/sula/src/form/utils/layoutUtil.ts index 65a54c6..a2bda72 100644 --- a/packages/sula/src/form/utils/layoutUtil.ts +++ b/packages/sula/src/form/utils/layoutUtil.ts @@ -10,16 +10,13 @@ export function getItemLayout( const finalSpan = getItemSpan(itemLayout, matchedPonint); - let finalOffset = offset; - let finalGutter = gutter; + let finalOffset = isNumber(offset) ? offset : 0; + let finalGutter = isNumber(gutter) ? gutter : 24; let finalWrapperCol; let finalLabelCol; if (layout === 'vertical' || layout === 'horizontal') { - finalOffset = finalOffset || 0; - finalGutter = finalGutter || 24; - // 只有水平布局需要设置 wrapperCol 和 labelCol if (layout === 'horizontal') { finalLabelCol = labelCol || { span: 8 }; @@ -35,7 +32,7 @@ export function getItemLayout( labelCol: finalLabelCol, span: finalSpan, offset: finalOffset, - gutter: finalGutter || 0, + gutter: finalGutter, }; }