Skip to content

Commit

Permalink
style: 数组容器、对象容器标题位置默认居中对齐
Browse files Browse the repository at this point in the history
容器统一布局之后,跟随全局配置
generator拖拽出来的对象容器、数组容器默认上对齐
  • Loading branch information
mengshang918 committed Jan 20, 2022
1 parent 92b63df commit 4564f2f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
13 changes: 7 additions & 6 deletions packages/drip-form/src/render/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,16 @@ const Render = ({
if (!currentDataSchema.items[item]) return null
}
}
// 标题的Placement,默认为left,可设置为top/right/bottom/left
const titlePlacement =
properties[item]?.title?.placement || uiSchema?.title?.placement || 'left'

// 当前Field的标题样式, property的样式会覆盖全局标题样式
const titleUi = Object.assign(
{},
{
placement: 'left',
width: '82px',
textAlign: 'left',
verticalAlign: 'center',
requiredFields: false,
},
globalTitleUi,
properties[item]?.title || {}
)
Expand Down Expand Up @@ -267,8 +270,6 @@ const Render = ({
showTitle,
// 当前表单的标题样式
titleUi,
// 当前表单的位置
titlePlacement,
// 是否展示错误
showError,
// 容器样式
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ const unitedSchema = {
type: 'select',
style: { width: '50%' },
options: [
{ label: '上对齐', value: 'left' },
{ label: '上对齐', value: 'top' },
{ label: '居中对齐', value: 'center' },
{ label: '下对齐', value: 'right' },
{ label: '下对齐', value: 'bottom' },
],
vcontrol: 'return props.formData.title.followRootConfig == false',
},
Expand Down
3 changes: 3 additions & 0 deletions packages/generator/src/fields/container/array.field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ const config: Field = {
type: 'array',
title: '数组容器',
ui: {
title: {
verticalAlign: 'top',
},
type: 'array',
mode: 'add',
addTitle: '添加一行数据',
Expand Down
3 changes: 3 additions & 0 deletions packages/generator/src/fields/container/object.field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const config: Field = {
type: 'object',
mode: 'collapse',
active: false,
title: {
verticalAlign: 'top',
},
},
},
propertyConfig: {
Expand Down
4 changes: 2 additions & 2 deletions packages/generator/src/fields/container/root.field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ const unitedSchema = [
type: 'select',
style: { width: '50%' },
options: [
{ label: '上对齐', value: 'left' },
{ label: '上对齐', value: 'top' },
{ label: '居中对齐', value: 'center' },
{ label: '下对齐', value: 'right' },
{ label: '下对齐', value: 'bottom' },
],
},
},
Expand Down

0 comments on commit 4564f2f

Please sign in to comment.