@longhongguo/form-create-ant-design-vue 3.2.76 → 3.2.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longhongguo/form-create-ant-design-vue",
3
- "version": "3.2.76",
3
+ "version": "3.2.78",
4
4
  "description": "AntDesignVue版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。",
5
5
  "main": "./dist/form-create.min.js",
6
6
  "module": "./dist/form-create.esm.js",
@@ -0,0 +1,60 @@
1
+ export default {
2
+ name: 'div',
3
+ mergeProp(ctx) {
4
+ // 确保 children 存在
5
+ if (!ctx.rule.children) {
6
+ ctx.rule.children = []
7
+ }
8
+
9
+ // 为 div 容器的所有子组件设置 col: false,避免被 a-col 包装
10
+ // 这样子组件可以直接作为 div 的子元素
11
+ if (ctx.rule.children && Array.isArray(ctx.rule.children)) {
12
+ ctx.rule.children.forEach((child) => {
13
+ if (
14
+ child &&
15
+ typeof child === 'object' &&
16
+ child.type !== 'DragTool' &&
17
+ child.type !== 'DragBox'
18
+ ) {
19
+ // 只有当 col 未设置或为默认值时才设置
20
+ if (child.col === undefined || child.col === null) {
21
+ child.col = false
22
+ } else if (
23
+ child.col &&
24
+ typeof child.col === 'object' &&
25
+ child.col.show !== false
26
+ ) {
27
+ child.col.show = false
28
+ }
29
+ }
30
+ })
31
+ }
32
+ },
33
+ render(children, ctx) {
34
+ // 使用简单的 div 元素作为容器
35
+ const prop = { ...ctx.prop }
36
+
37
+ // 确保 type 是 'div'
38
+ if (prop.type === 'div') {
39
+ prop.type = 'div'
40
+ }
41
+
42
+ // children 会通过 form-create 的机制自动渲染
43
+ const childrenNodes = children || []
44
+
45
+ // 直接返回 div,不使用 a-col 或 a-row 包装
46
+ // 确保样式是自适应(width: 100% 可能会影响布局,所以不设置)
47
+ if (!prop.props) {
48
+ prop.props = {}
49
+ }
50
+ if (!prop.props.style) {
51
+ prop.props.style = {}
52
+ }
53
+ // 宽高自适应,不设置固定值
54
+ // 保留用户自定义的样式
55
+
56
+ // 直接使用 vNode.make 渲染 div,不包装
57
+ return ctx.vNode.make('div', prop, childrenNodes)
58
+ }
59
+ }
60
+
@@ -133,6 +133,28 @@ export default {
133
133
  }
134
134
  })
135
135
  }
136
+
137
+ // 读取 resetMarginBottom 配置,用于重置包裹 flex 的 ant-form-item 的 margin-bottom
138
+ const resetMarginBottom =
139
+ props.resetMarginBottom ?? ctx.rule.resetMarginBottom ?? false
140
+ if (resetMarginBottom) {
141
+ // 将 class 添加到 wrap 配置中,使其应用到包裹 flex 的 ant-form-item 上
142
+ if (!ctx.rule.wrap) {
143
+ ctx.rule.wrap = {}
144
+ }
145
+ if (typeof ctx.rule.wrap === 'object' && !ctx.rule.wrap.class) {
146
+ ctx.rule.wrap.class = ''
147
+ }
148
+ const wrapClass = typeof ctx.rule.wrap === 'object'
149
+ ? (ctx.rule.wrap.class || '').split(' ').filter(Boolean)
150
+ : []
151
+ if (!wrapClass.includes('_fc-reset-margin-bottom')) {
152
+ wrapClass.push('_fc-reset-margin-bottom')
153
+ if (typeof ctx.rule.wrap === 'object') {
154
+ ctx.rule.wrap.class = wrapClass.join(' ')
155
+ }
156
+ }
157
+ }
136
158
  },
137
159
  render(children, ctx) {
138
160
  // 使用 Ant Design Vue 的 Flex 组件
@@ -16,6 +16,7 @@ import cusUserSelect from './cusUserSelect'
16
16
  import flex from './flex'
17
17
  import space from './space'
18
18
  import spin from './spin'
19
+ import div from './div'
19
20
 
20
21
  export default [
21
22
  checkbox,
@@ -35,5 +36,6 @@ export default [
35
36
  cusUserSelect,
36
37
  flex,
37
38
  space,
38
- spin
39
+ spin,
40
+ div
39
41
  ]
@@ -67,6 +67,28 @@ export default {
67
67
  }
68
68
  })
69
69
  }
70
+
71
+ // 读取 resetMarginBottom 配置,用于重置包裹 space 的 ant-form-item 的 margin-bottom
72
+ const resetMarginBottom =
73
+ props.resetMarginBottom ?? ctx.rule.resetMarginBottom ?? false
74
+ if (resetMarginBottom) {
75
+ // 将 class 添加到 wrap 配置中,使其应用到包裹 space 的 ant-form-item 上
76
+ if (!ctx.rule.wrap) {
77
+ ctx.rule.wrap = {}
78
+ }
79
+ if (typeof ctx.rule.wrap === 'object' && !ctx.rule.wrap.class) {
80
+ ctx.rule.wrap.class = ''
81
+ }
82
+ const wrapClass = typeof ctx.rule.wrap === 'object'
83
+ ? (ctx.rule.wrap.class || '').split(' ').filter(Boolean)
84
+ : []
85
+ if (!wrapClass.includes('_fc-reset-margin-bottom')) {
86
+ wrapClass.push('_fc-reset-margin-bottom')
87
+ if (typeof ctx.rule.wrap === 'object') {
88
+ ctx.rule.wrap.class = wrapClass.join(' ')
89
+ }
90
+ }
91
+ }
70
92
  },
71
93
  render(children, ctx) {
72
94
  // 使用 Ant Design Vue 的 Space 组件
@@ -533,3 +533,8 @@
533
533
  .ant-flex._fc-flex-vertical > .ant-form-item {
534
534
  width: var(--fc-child-width, 100%) !important;
535
535
  }
536
+
537
+ /* Flex 和 Space 组件重置包裹它们的 ant-form-item 的 margin-bottom 的样式 */
538
+ .ant-form-item._fc-reset-margin-bottom {
539
+ margin-bottom: 0 !important;
540
+ }