diff --git a/designable/antd/package.json b/designable/antd/package.json index 3c1bfda34bb..12b402a110f 100644 --- a/designable/antd/package.json +++ b/designable/antd/package.json @@ -30,7 +30,7 @@ "start": "webpack-dev-server --config playground/webpack.dev.ts" }, "devDependencies": { - "@designable/react-settings-form": "^0.3.14", + "@designable/react-settings-form": "^0.3.15", "autoprefixer": "^9.0", "file-loader": "^5.0.2", "fs-extra": "^8.1.0", @@ -56,9 +56,9 @@ "react-is": ">=16.8.0 || >=17.0.0" }, "dependencies": { - "@designable/core": "^0.3.14", - "@designable/formily": "^0.3.14", - "@designable/react": "^0.3.14", + "@designable/core": "^0.3.15", + "@designable/formily": "^0.3.15", + "@designable/react": "^0.3.15", "@formily/antd": "2.0.0-beta.69", "@formily/core": "2.0.0-beta.69", "@formily/react": "2.0.0-beta.69", diff --git a/designable/antd/src/schemas/Cascader.ts b/designable/antd/src/schemas/Cascader.ts index 747e4f4bc45..e7b7d7d40ae 100644 --- a/designable/antd/src/schemas/Cascader.ts +++ b/designable/antd/src/schemas/Cascader.ts @@ -65,7 +65,7 @@ export const Cascader: ISchema = { }, size: { type: 'string', - enum: ['large', 'small', 'middle', ''], + enum: ['large', 'small', 'middle', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { diff --git a/designable/antd/src/schemas/DatePicker.ts b/designable/antd/src/schemas/DatePicker.ts index f9250747d60..32b3e51f9f1 100644 --- a/designable/antd/src/schemas/DatePicker.ts +++ b/designable/antd/src/schemas/DatePicker.ts @@ -48,7 +48,7 @@ const CommonDatePickerAPI = { }, size: { type: 'string', - enum: ['large', 'small', 'middle', ''], + enum: ['large', 'small', 'middle', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { diff --git a/designable/antd/src/schemas/FormItem.ts b/designable/antd/src/schemas/FormItem.ts index 3e19599c26e..354cbd7c417 100644 --- a/designable/antd/src/schemas/FormItem.ts +++ b/designable/antd/src/schemas/FormItem.ts @@ -56,7 +56,7 @@ export const FormItem: ISchema = { }, feedbackLayout: { type: 'string', - enum: ['loose', 'terse', 'popover', 'none', ''], + enum: ['loose', 'terse', 'popover', 'none', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { @@ -65,7 +65,7 @@ export const FormItem: ISchema = { }, size: { type: 'string', - enum: ['large', 'small', 'default', ''], + enum: ['large', 'small', 'default', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { @@ -74,7 +74,7 @@ export const FormItem: ISchema = { }, layout: { type: 'string', - enum: ['vertical', 'horizontal', 'inline', ''], + enum: ['vertical', 'horizontal', 'inline', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { @@ -84,7 +84,7 @@ export const FormItem: ISchema = { tooltipLayout: { type: 'string', - enum: ['icon', 'text', ''], + enum: ['icon', 'text', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { @@ -93,7 +93,7 @@ export const FormItem: ISchema = { }, labelAlign: { type: 'string', - enum: ['left', 'right', ''], + enum: ['left', 'right', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { @@ -102,7 +102,7 @@ export const FormItem: ISchema = { }, wrapperAlign: { type: 'string', - enum: ['left', 'right', ''], + enum: ['left', 'right', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { diff --git a/designable/antd/src/schemas/FormLayout.ts b/designable/antd/src/schemas/FormLayout.ts index a334a3373af..366d27b5f3e 100644 --- a/designable/antd/src/schemas/FormLayout.ts +++ b/designable/antd/src/schemas/FormLayout.ts @@ -31,7 +31,7 @@ export const FormLayout: ISchema = { }, feedbackLayout: { type: 'string', - enum: ['loose', 'terse', 'popover', 'none', ''], + enum: ['loose', 'terse', 'popover', 'none', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { @@ -40,7 +40,7 @@ export const FormLayout: ISchema = { }, size: { type: 'string', - enum: ['large', 'small', 'default', ''], + enum: ['large', 'small', 'default', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { @@ -49,7 +49,7 @@ export const FormLayout: ISchema = { }, layout: { type: 'string', - enum: ['vertical', 'horizontal', 'inline', ''], + enum: ['vertical', 'horizontal', 'inline', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { @@ -58,7 +58,7 @@ export const FormLayout: ISchema = { }, tooltipLayout: { type: 'string', - enum: ['icon', 'text', ''], + enum: ['icon', 'text', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { @@ -67,7 +67,7 @@ export const FormLayout: ISchema = { }, labelAlign: { type: 'string', - enum: ['left', 'right', ''], + enum: ['left', 'right', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { @@ -76,7 +76,7 @@ export const FormLayout: ISchema = { }, wrapperAlign: { type: 'string', - enum: ['left', 'right', ''], + enum: ['left', 'right', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { diff --git a/designable/antd/src/schemas/FormTab.ts b/designable/antd/src/schemas/FormTab.ts index 7786da639dd..c3ed37cb1f0 100644 --- a/designable/antd/src/schemas/FormTab.ts +++ b/designable/antd/src/schemas/FormTab.ts @@ -16,7 +16,7 @@ export const FormTab: ISchema = { }, size: { type: 'string', - enum: ['large', 'small', 'default', ''], + enum: ['large', 'small', 'default', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { diff --git a/designable/antd/src/schemas/Input.ts b/designable/antd/src/schemas/Input.ts index 7367aa68840..76a0aeafb5e 100644 --- a/designable/antd/src/schemas/Input.ts +++ b/designable/antd/src/schemas/Input.ts @@ -48,7 +48,7 @@ export const Input: ISchema = { }, size: { type: 'string', - enum: ['large', 'small', 'middle', ''], + enum: ['large', 'small', 'middle', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { diff --git a/designable/antd/src/schemas/NumberPicker.ts b/designable/antd/src/schemas/NumberPicker.ts index 45dfe2b5c3b..7b026706fef 100644 --- a/designable/antd/src/schemas/NumberPicker.ts +++ b/designable/antd/src/schemas/NumberPicker.ts @@ -35,7 +35,7 @@ export const NumberPicker: ISchema = { }, size: { type: 'string', - enum: ['large', 'small', 'middle', ''], + enum: ['large', 'small', 'middle', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { diff --git a/designable/antd/src/schemas/Select.ts b/designable/antd/src/schemas/Select.ts index 66327980a11..eb340cc30c9 100644 --- a/designable/antd/src/schemas/Select.ts +++ b/designable/antd/src/schemas/Select.ts @@ -5,11 +5,11 @@ export const Select: ISchema = { properties: { mode: { type: 'string', - enum: ['multiple', 'tags', ''], + enum: ['multiple', 'tags', null], 'x-decorator': 'FormItem', 'x-component': 'Radio.Group', 'x-component-props': { - defaultValue: '', + defaultValue: null, optionType: 'button', }, }, @@ -138,7 +138,7 @@ export const Select: ISchema = { size: { type: 'string', - enum: ['large', 'small', 'middle', ''], + enum: ['large', 'small', 'middle', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { diff --git a/designable/antd/src/schemas/TimePicker.ts b/designable/antd/src/schemas/TimePicker.ts index 31c7d241aab..7d6af1375cc 100644 --- a/designable/antd/src/schemas/TimePicker.ts +++ b/designable/antd/src/schemas/TimePicker.ts @@ -99,7 +99,7 @@ export const CommonTimePickerAPI = { }, size: { type: 'string', - enum: ['large', 'small', 'middle', ''], + enum: ['large', 'small', 'middle', null], 'x-decorator': 'FormItem', 'x-component': 'Select', }, diff --git a/designable/antd/src/schemas/TreeSelect.ts b/designable/antd/src/schemas/TreeSelect.ts index b74c58a360c..96cc1dfd38e 100644 --- a/designable/antd/src/schemas/TreeSelect.ts +++ b/designable/antd/src/schemas/TreeSelect.ts @@ -128,7 +128,7 @@ export const TreeSelect: ISchema = { }, size: { type: 'string', - enum: ['large', 'small', 'middle', ''], + enum: ['large', 'small', 'middle', null], 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { diff --git a/packages/antd/src/form-item/index.tsx b/packages/antd/src/form-item/index.tsx index ec981bcb117..a83fa28ccc7 100644 --- a/packages/antd/src/form-item/index.tsx +++ b/packages/antd/src/form-item/index.tsx @@ -55,27 +55,27 @@ const useFormItemLayout = (props: IFormItemProps) => { const layout = useFormLayout() return { ...props, - layout: props.layout || layout.layout || 'horizontal', - colon: props.colon || layout.colon, + layout: props.layout ?? layout.layout ?? 'horizontal', + colon: props.colon ?? layout.colon, labelAlign: layout.layout === 'vertical' - ? props.labelAlign || layout.labelAlign || 'left' - : props.labelAlign || layout.labelAlign || 'right', - labelWrap: props.labelWrap || layout.labelWrap, - labelWidth: props.labelWidth || layout.labelWidth, - wrapperWidth: props.wrapperWidth || layout.wrapperWidth, - labelCol: props.labelCol || layout.labelCol, - wrapperCol: props.wrapperCol || layout.wrapperCol, - wrapperAlign: props.wrapperAlign || layout.wrapperAlign, - wrapperWrap: props.wrapperWrap || layout.wrapperWrap, - fullness: props.fullness || layout.fullness, - size: props.size || layout.size, - inset: props.inset || layout.inset, + ? props.labelAlign ?? layout.labelAlign ?? 'left' + : props.labelAlign ?? layout.labelAlign ?? 'right', + labelWrap: props.labelWrap ?? layout.labelWrap, + labelWidth: props.labelWidth ?? layout.labelWidth, + wrapperWidth: props.wrapperWidth ?? layout.wrapperWidth, + labelCol: props.labelCol ?? layout.labelCol, + wrapperCol: props.wrapperCol ?? layout.wrapperCol, + wrapperAlign: props.wrapperAlign ?? layout.wrapperAlign, + wrapperWrap: props.wrapperWrap ?? layout.wrapperWrap, + fullness: props.fullness ?? layout.fullness, + size: props.size ?? layout.size, + inset: props.inset ?? layout.inset, asterisk: props.asterisk, - bordered: props.bordered || layout.bordered, + bordered: props.bordered ?? layout.bordered, feedbackIcon: props.feedbackIcon, - feedbackLayout: props.feedbackLayout || layout.feedbackLayout || 'loose', - tooltipLayout: props.tooltipLayout || layout.tooltipLayout || 'icon', + feedbackLayout: props.feedbackLayout ?? layout.feedbackLayout ?? 'loose', + tooltipLayout: props.tooltipLayout ?? layout.tooltipLayout ?? 'icon', } } @@ -248,7 +248,7 @@ export const BaseItem: React.FC = (props) => { } const renderLabel = () => { - if (!label || label === ' ') return null + if (!label) return null return (
= (props) => { > {renderLabelText()} {renderTooltipIcon()} - {colon ? ':' : ''} + {label !== ' ' && ( + {colon ? ':' : ''} + )}
) } diff --git a/packages/next/src/form-item/index.tsx b/packages/next/src/form-item/index.tsx index 3bd168b00f6..7dde22a3579 100644 --- a/packages/next/src/form-item/index.tsx +++ b/packages/next/src/form-item/index.tsx @@ -55,27 +55,27 @@ const useFormItemLayout = (props: IFormItemProps) => { const layout = useFormLayout() return { ...props, - layout: props.layout || layout.layout || 'horizontal', - colon: props.colon || layout.colon, + layout: props.layout ?? layout.layout ?? 'horizontal', + colon: props.colon ?? layout.colon, labelAlign: layout.layout === 'vertical' - ? props.labelAlign || layout.labelAlign || 'left' - : props.labelAlign || layout.labelAlign || 'right', - labelWrap: props.labelWrap || layout.labelWrap, - labelWidth: props.labelWidth || layout.labelWidth, - wrapperWidth: props.wrapperWidth || layout.wrapperWidth, - labelCol: props.labelCol || layout.labelCol, - wrapperCol: props.wrapperCol || layout.wrapperCol, - wrapperAlign: props.wrapperAlign || layout.wrapperAlign, - wrapperWrap: props.wrapperWrap || layout.wrapperWrap, - fullness: props.fullness || layout.fullness, - size: props.size || layout.size, - inset: props.inset || layout.inset, + ? props.labelAlign ?? layout.labelAlign ?? 'left' + : props.labelAlign ?? layout.labelAlign ?? 'right', + labelWrap: props.labelWrap ?? layout.labelWrap, + labelWidth: props.labelWidth ?? layout.labelWidth, + wrapperWidth: props.wrapperWidth ?? layout.wrapperWidth, + labelCol: props.labelCol ?? layout.labelCol, + wrapperCol: props.wrapperCol ?? layout.wrapperCol, + wrapperAlign: props.wrapperAlign ?? layout.wrapperAlign, + wrapperWrap: props.wrapperWrap ?? layout.wrapperWrap, + fullness: props.fullness ?? layout.fullness, + size: props.size ?? layout.size, + inset: props.inset ?? layout.inset, asterisk: props.asterisk, - bordered: props.bordered || layout.bordered, + bordered: props.bordered ?? layout.bordered, feedbackIcon: props.feedbackIcon, - feedbackLayout: props.feedbackLayout || layout.feedbackLayout || 'loose', - tooltipLayout: props.tooltipLayout || layout.tooltipLayout || 'icon', + feedbackLayout: props.feedbackLayout ?? layout.feedbackLayout ?? 'loose', + tooltipLayout: props.tooltipLayout ?? layout.tooltipLayout ?? 'icon', } } @@ -243,7 +243,7 @@ export const BaseItem: React.FC = (props) => { } const renderLabel = () => { - if (!label || label === ' ') return null + if (!label) return null return (
= (props) => { > {renderLabelText()} {renderTooltipIcon()} - {colon ? ':' : ''} + {label !== ' ' && ( + {colon ? ':' : ''} + )}
) }