Skip to content

Commit

Permalink
feat: 表单布局支持配置外边距
Browse files Browse the repository at this point in the history
对象容器默认下边距20px
  • Loading branch information
mengshang918 committed Jan 20, 2022
1 parent 4564f2f commit 2016881
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/drip-form/src/render/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author: jiangxiaowei
* @Date: 2021-07-30 16:35:48
* @Last Modified by: jiangxiaowei
* @Last Modified time: 2022-01-14 14:49:36
* @Last Modified time: 2022-01-19 17:33:30
*/
import React from 'react'
import type { RenderFnProps } from './type'
Expand Down Expand Up @@ -162,7 +162,9 @@ const Render = ({
: true
// 布局样式
const containerStyle = Object.assign(
{},
type === 'object' && properties[item]?.mode === 'collapse'
? { marginBottom: 20 }
: {},
isRoot ? globalContainerStyle : {},
properties[item]?.containerStyle || {}
)
Expand Down
21 changes: 18 additions & 3 deletions packages/generator/src/components/RightSideBar/Check/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @Author: jiangxiaowei
* @Date: 2021-08-16 11:32:22
* @Last Modified by: jiangxiaowei
* @Last Modified time: 2022-01-16 13:44:17
* @Last Modified time: 2022-01-19 19:08:33
*/
import React, { useMemo, memo, useCallback } from 'react'
import {
Expand Down Expand Up @@ -201,7 +201,13 @@ const CheckConfig = (): JSX.Element => {
type: 'object',
title: '通用校验',
fieldKey: 'common',
ui: { type: 'object', mode: 'collapse' },
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
},
schema: CommonSchema.concat(curTypeSchema),
},
...(bussinessSchema.length > 0
Expand All @@ -210,7 +216,13 @@ const CheckConfig = (): JSX.Element => {
type: 'object',
title: '业务校验',
fieldKey: 'business',
ui: { type: 'object', mode: 'collapse' },
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
},
schema: bussinessSchema,
},
]
Expand All @@ -222,6 +234,9 @@ const CheckConfig = (): JSX.Element => {
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
},
schema: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author: jiangxiaowei
* @Date: 2021-08-16 11:31:04
* @Last Modified by: jiangxiaowei
* @Last Modified time: 2022-01-14 20:34:06
* @Last Modified time: 2022-01-19 00:10:00
*/
// dataSchema2019-09支持的字符串校验关键字
const stringJsonSchema = {
Expand Down Expand Up @@ -222,6 +222,9 @@ const dripFormPluginKeywords = {
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
description: {
type: 'icon',
title: '使用delimiter指定的字符分隔,最少多少,最多多少',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const unitedSchema = {
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
},
schema: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const unitedSchema = {
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
},
title: '布局',
schema: [
Expand All @@ -26,6 +29,15 @@ const unitedSchema = {
},
},
},
{
fieldKey: 'margin',
type: 'string',
title: '组件外边距',
ui: {
type: 'text',
placeholder: '形如0 30px 20px 0 | 0 30px',
},
},
],
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const unitedSchema = {
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
},
title: '标题',
schema: [
Expand Down
6 changes: 6 additions & 0 deletions packages/generator/src/fields/container/array.field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ const config: Field = {
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
style: {
paddingBottom: '20px',
},
Expand All @@ -135,6 +138,9 @@ const config: Field = {
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
vcontrol: 'return props.formData.ui.hasConfirm',
},
schema: [
Expand Down
18 changes: 18 additions & 0 deletions packages/generator/src/fields/container/root.field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ const unitedSchema = [
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
},
schema: [
{
Expand Down Expand Up @@ -216,6 +219,9 @@ const unitedSchema = [
ui: {
mode: 'collapse',
type: 'object',
containerStyle: {
marginBottom: 0,
},
},
schema: [
{
Expand All @@ -237,6 +243,15 @@ const unitedSchema = [
},
},
},
{
fieldKey: 'margin',
type: 'string',
title: '组件外边距',
ui: {
type: 'text',
placeholder: '形如0 30px 20px 0 | 0 30px',
},
},
],
},
{
Expand All @@ -246,6 +261,9 @@ const unitedSchema = [
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
},
schema: [
{
Expand Down
6 changes: 6 additions & 0 deletions packages/generator/src/fields/formItem/upload.field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ const config: Field = {
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
},
schema: [
{
Expand Down Expand Up @@ -229,6 +232,9 @@ const config: Field = {
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
},
schema: [
{
Expand Down
3 changes: 3 additions & 0 deletions packages/generator/src/store/rightSidebar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export const allPropertyConfigSchemaSelector = selector<
ui: {
type: 'object',
mode: 'collapse',
containerStyle: {
marginBottom: 0,
},
},
title: '样式',
schema:
Expand Down
7 changes: 5 additions & 2 deletions packages/hooks/src/useContainerStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author: jiangxiaowei
* @Date: 2021-10-25 11:06:41
* @Last Modified by: jiangxiaowei
* @Last Modified time: 2021-11-05 17:45:17
* @Last Modified time: 2022-01-18 23:40:09
*/
import { useMemo } from 'react'
import type { ContainerStyle } from '@jdfed/utils'
Expand All @@ -13,7 +13,10 @@ const useContainerStyle = (
containerStyle: ContainerStyle
): ContainerStyle => {
const newContainerStyle = useMemo(() => {
return formMode === 'edit' ? containerStyle : {}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { width, ...props } = containerStyle || {}
// generator模式的宽度在@jdfed/form-generator中使用containerHoc控制
return formMode === 'edit' ? containerStyle : props
}, [containerStyle, formMode])

return newContainerStyle
Expand Down

0 comments on commit 2016881

Please sign in to comment.