@longhongguo/form-create-ant-design-vue 3.2.63 → 3.2.65

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.63",
3
+ "version": "3.2.65",
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",
package/src/core/alias.js CHANGED
@@ -28,6 +28,7 @@ export default {
28
28
  col: PRE + 'Col',
29
29
  row: PRE + 'Row',
30
30
  flex: PRE + 'Flex',
31
+ space: PRE + 'Space',
31
32
  tree: PRE + 'Tree',
32
33
  autoComplete: PRE + 'AutoComplete',
33
34
  transfer: PRE + 'Transfer',
package/src/core/maker.js CHANGED
@@ -102,6 +102,10 @@ function useFlex(maker) {
102
102
  maker.flex = creatorFactory('flex')
103
103
  }
104
104
 
105
+ function useSpace(maker) {
106
+ maker.space = creatorFactory('space')
107
+ }
108
+
105
109
  useAlias(maker)
106
110
  useSlider(maker)
107
111
  useFrame(maker)
@@ -111,5 +115,6 @@ useCusStoreSelect(maker)
111
115
  useCusUserSelect(maker)
112
116
  useText(maker)
113
117
  useFlex(maker)
118
+ useSpace(maker)
114
119
 
115
120
  export default maker
@@ -84,7 +84,7 @@ export default {
84
84
  )
85
85
  })
86
86
 
87
- // 检查父容器是否是 flex 类型,如果是,自动设置 col: false 避免被 a-col 包装
87
+ // 检查父容器是否是 flex 或 space 类型,如果是,自动设置 col: false 避免被 a-col 包装
88
88
  // 需要在合并完 col 后再检查,确保能覆盖默认值
89
89
  if (ctx.parent && ctx.parent.rule) {
90
90
  const parentType = ctx.parent.rule.type
@@ -92,9 +92,12 @@ export default {
92
92
  if (
93
93
  parentType === 'flex' ||
94
94
  parentType === 'a-flex' ||
95
- parentMenu?.name === 'flex'
95
+ parentMenu?.name === 'flex' ||
96
+ parentType === 'space' ||
97
+ parentType === 'a-space' ||
98
+ parentMenu?.name === 'space'
96
99
  ) {
97
- // 如果父容器是 flex,强制设置 col 为 false,禁用 col 包装
100
+ // 如果父容器是 flex 或 space,强制设置 col 为 false,禁用 col 包装
98
101
  ctx.prop.col = false
99
102
  // 同时设置 rule.col 以确保在 makeWrap 中也能识别
100
103
  if (ctx.rule) {
@@ -225,7 +228,7 @@ export default {
225
228
  delete rule.wrap.class
226
229
  delete rule.wrap.title
227
230
 
228
- // 检查父容器是否是 flex 类型,如果是,强制禁用 col 包装
231
+ // 检查父容器是否是 flex 或 space 类型,如果是,强制禁用 col 包装
229
232
  let shouldDisableCol = false
230
233
  if (ctx.parent && ctx.parent.rule) {
231
234
  const parentType = ctx.parent.rule.type
@@ -233,7 +236,10 @@ export default {
233
236
  if (
234
237
  parentType === 'flex' ||
235
238
  parentType === 'a-flex' ||
236
- parentMenu?.name === 'flex'
239
+ parentMenu?.name === 'flex' ||
240
+ parentType === 'space' ||
241
+ parentType === 'a-space' ||
242
+ parentMenu?.name === 'space'
237
243
  ) {
238
244
  shouldDisableCol = true
239
245
  }
@@ -143,21 +143,34 @@ export default {
143
143
  prop.type = 'a-flex'
144
144
  }
145
145
 
146
- // 读取 childFlex 配置
147
- const childFlex = ctx.rule.props?.childFlex ?? ctx.rule.childFlex
148
- if (childFlex !== undefined && childFlex !== null && childFlex !== '') {
149
- // flex 容器添加自定义 class 和 CSS 变量,用于 CSS 选择器
150
- if (!prop.props) {
151
- prop.props = {}
152
- }
153
- // 添加自定义 class
146
+ // 读取 flexDirection 来判断是否是垂直方向
147
+ const props = ctx.rule.props || {}
148
+ const flexDirection = props.flexDirection || ctx.rule.flexDirection || 'row'
149
+ const isVertical =
150
+ flexDirection === 'column' || flexDirection === 'column-reverse'
151
+
152
+ // 初始化 prop.props 和 prop.class(如果需要的话)
153
+ if (!prop.props) {
154
+ prop.props = {}
155
+ }
156
+
157
+ // 添加自定义 class 的辅助函数
158
+ const ensureClass = () => {
154
159
  if (!prop.class) {
155
160
  prop.class = []
156
161
  }
157
162
  if (!Array.isArray(prop.class)) {
158
163
  prop.class = [prop.class]
159
164
  }
160
- prop.class.push('_fc-flex-container')
165
+ }
166
+
167
+ // 读取 childFlex 配置
168
+ const childFlex = ctx.rule.props?.childFlex ?? ctx.rule.childFlex
169
+ if (childFlex !== undefined && childFlex !== null && childFlex !== '') {
170
+ ensureClass()
171
+ if (!prop.class.includes('_fc-flex-container')) {
172
+ prop.class.push('_fc-flex-container')
173
+ }
161
174
 
162
175
  // 通过 CSS 变量传递 flex 值
163
176
  const flexValue = String(childFlex).trim()
@@ -174,6 +187,32 @@ export default {
174
187
  prop.style['--fc-child-flex'] = flexValue
175
188
  }
176
189
 
190
+ // 如果是垂直方向,读取 childWidth 配置(默认 100%)
191
+ if (isVertical) {
192
+ const childWidth =
193
+ ctx.rule.props?.childWidth ?? ctx.rule.childWidth ?? '100%'
194
+
195
+ ensureClass()
196
+ if (!prop.class.includes('_fc-flex-container')) {
197
+ prop.class.push('_fc-flex-container')
198
+ }
199
+ if (!prop.class.includes('_fc-flex-vertical')) {
200
+ prop.class.push('_fc-flex-vertical')
201
+ }
202
+
203
+ // 通过 CSS 变量传递宽度值
204
+ const widthValue = String(childWidth).trim()
205
+ if (!prop.props.style) {
206
+ prop.props.style = {}
207
+ }
208
+ prop.props.style['--fc-child-width'] = widthValue
209
+
210
+ if (!prop.style) {
211
+ prop.style = {}
212
+ }
213
+ prop.style['--fc-child-width'] = widthValue
214
+ }
215
+
177
216
  // children 会通过 form-create 的机制自动渲染
178
217
  const childrenNodes = children || []
179
218
 
@@ -14,6 +14,7 @@ import timeRangePicker from './timeRangePicker'
14
14
  import cusStoreSelect from './cusStoreSelect'
15
15
  import cusUserSelect from './cusUserSelect'
16
16
  import flex from './flex'
17
+ import space from './space'
17
18
 
18
19
  export default [
19
20
  checkbox,
@@ -31,5 +32,6 @@ export default [
31
32
  row,
32
33
  cusStoreSelect,
33
34
  cusUserSelect,
34
- flex
35
+ flex,
36
+ space
35
37
  ]
@@ -0,0 +1,92 @@
1
+ export default {
2
+ name: 'space',
3
+ mergeProp(ctx) {
4
+ // 从 props 中读取 Space 组件配置
5
+ const props = ctx.rule.props || {}
6
+ const direction = props.direction || ctx.rule.direction || 'horizontal'
7
+ const size = props.size || ctx.rule.size || 'small'
8
+ const align = props.align || ctx.rule.align
9
+ const wrap = props.wrap || ctx.rule.wrap || false
10
+
11
+ // 设置到 prop.props,用于传递给 a-space 组件
12
+ if (!ctx.prop.props) {
13
+ ctx.prop.props = {}
14
+ }
15
+
16
+ // 映射 Ant Design Vue Space 组件的 props
17
+ ctx.prop.props.direction = direction
18
+ ctx.prop.props.size = size
19
+ if (align !== undefined && align !== null && align !== '') {
20
+ ctx.prop.props.align = align
21
+ }
22
+ ctx.prop.props.wrap = wrap
23
+
24
+ // 合并样式,确保 Space 容器占满整行
25
+ const existingStyle = ctx.rule.style || {}
26
+ const spaceStyles = {
27
+ width: '100%',
28
+ ...existingStyle
29
+ }
30
+
31
+ // 同时设置到 ctx.prop.style 和 ctx.prop.props.style
32
+ if (!ctx.prop.style) {
33
+ ctx.prop.style = {}
34
+ }
35
+ ctx.prop.style = { ...ctx.prop.style, ...spaceStyles }
36
+
37
+ if (!ctx.prop.props.style) {
38
+ ctx.prop.props.style = {}
39
+ }
40
+ ctx.prop.props.style = { ...ctx.prop.props.style, ...spaceStyles }
41
+
42
+ // 确保 children 存在
43
+ if (!ctx.rule.children) {
44
+ ctx.rule.children = []
45
+ }
46
+
47
+ // 为 space 容器的所有子组件设置 col: false,避免被 a-col 包装
48
+ // Space 组件会自动处理子项间距,不需要 col 包装
49
+ if (ctx.rule.children && Array.isArray(ctx.rule.children)) {
50
+ ctx.rule.children.forEach((child) => {
51
+ if (
52
+ child &&
53
+ typeof child === 'object' &&
54
+ child.type !== 'DragTool' &&
55
+ child.type !== 'DragBox'
56
+ ) {
57
+ // 只有当 col 未设置或为默认值时才设置
58
+ if (child.col === undefined || child.col === null) {
59
+ child.col = false
60
+ } else if (
61
+ child.col &&
62
+ typeof child.col === 'object' &&
63
+ child.col.show !== false
64
+ ) {
65
+ child.col.show = false
66
+ }
67
+ }
68
+ })
69
+ }
70
+ },
71
+ render(children, ctx) {
72
+ // 使用 Ant Design Vue 的 Space 组件
73
+ const prop = { ...ctx.prop }
74
+
75
+ // 将 type 设置为 'a-space',form-create 会自动识别
76
+ if (prop.type === 'space') {
77
+ prop.type = 'a-space'
78
+ }
79
+
80
+ // children 会通过 form-create 的机制自动渲染
81
+ const childrenNodes = children || []
82
+
83
+ // 将 space 容器包装在 col 中,确保它占满整行(span: 24)
84
+ // 这样 space 容器才能有足够的宽度
85
+ return ctx.vNode.col(
86
+ { props: { span: 24 } },
87
+ {
88
+ default: () => [ctx.vNode.make('a-space', prop, childrenNodes)]
89
+ }
90
+ )
91
+ }
92
+ }
@@ -496,3 +496,8 @@
496
496
  .ant-flex._fc-flex-container > .ant-form-item {
497
497
  flex: var(--fc-child-flex) !important;
498
498
  }
499
+
500
+ /* 垂直方向的 Flex 容器子项宽度样式 */
501
+ .ant-flex._fc-flex-vertical > .ant-form-item {
502
+ width: var(--fc-child-width, 100%) !important;
503
+ }
package/types/maker.d.ts CHANGED
@@ -65,7 +65,8 @@ declare enum MakerName {
65
65
  'storeSelect',
66
66
  'cusUserSelect',
67
67
  'userSelect',
68
- 'flex'
68
+ 'flex',
69
+ 'space'
69
70
  }
70
71
 
71
72
  type Maker = {