@longhongguo/form-create-ant-design-vue 3.2.70 → 3.2.71

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.70",
3
+ "version": "3.2.71",
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",
@@ -8,27 +8,31 @@ export default {
8
8
  ctx.rule.wrap = {}
9
9
  }
10
10
  ctx.rule.wrap.title = false
11
-
11
+
12
12
  const props = ctx.prop.props || {}
13
-
13
+
14
14
  // 读取 containerMode 配置
15
- const containerMode =
16
- ctx.rule.containerMode ??
17
- ctx.rule.props?.containerMode ??
18
- ctx.prop.props?.containerMode ??
15
+ const containerMode =
16
+ ctx.rule.containerMode ??
17
+ ctx.rule.props?.containerMode ??
18
+ ctx.prop.props?.containerMode ??
19
19
  true
20
-
20
+
21
21
  // 如果不是容器模式,清空 children
22
22
  if (!containerMode) {
23
23
  ctx.rule.children = []
24
24
  }
25
-
25
+
26
26
  if (!hasProperty(props, 'spinning')) {
27
- props.spinning = ctx.prop.props?.spinning ?? ctx.rule.props?.spinning ?? false
27
+ props.spinning =
28
+ ctx.prop.props?.spinning ?? ctx.rule.props?.spinning ?? false
28
29
  }
29
-
30
+
30
31
  // 如果没有子组件且不是容器模式,spinning 不应该为 true(避免显示空加载状态)
31
- const hasChildren = ctx.rule.children && Array.isArray(ctx.rule.children) && ctx.rule.children.length > 0
32
+ const hasChildren =
33
+ ctx.rule.children &&
34
+ Array.isArray(ctx.rule.children) &&
35
+ ctx.rule.children.length > 0
32
36
  if (!containerMode && !hasChildren && props.spinning) {
33
37
  // 独立模式下如果没有内容,不建议显示加载状态
34
38
  // 但这里不强制修改,让用户自己控制
@@ -36,7 +40,9 @@ export default {
36
40
 
37
41
  // 支持从多个位置读取配置
38
42
  const bindField =
39
- ctx.rule.bindField || ctx.rule.props?.bindField || ctx.prop.props?.bindField
43
+ ctx.rule.bindField ||
44
+ ctx.rule.props?.bindField ||
45
+ ctx.prop.props?.bindField
40
46
  let bindMode =
41
47
  ctx.rule.bindMode || ctx.rule.props?.bindMode || ctx.prop.props?.bindMode
42
48
 
@@ -86,28 +92,62 @@ export default {
86
92
  ctx.rule.children = []
87
93
  }
88
94
 
95
+ // 检查是否有真实的子组件(用于判断是否需要自适应)
96
+ const hasRealChildren =
97
+ ctx.rule.children &&
98
+ Array.isArray(ctx.rule.children) &&
99
+ ctx.rule.children.some((child) => {
100
+ if (!child || typeof child !== 'object') return false
101
+ return child.type !== 'DragTool' && child.type !== 'DragBox'
102
+ })
103
+
104
+ // 如果有子组件,设置 wrap 的 class 和样式让整个布局自适应内容
105
+ if (hasRealChildren) {
106
+ // 添加 class 用于样式控制
107
+ if (!ctx.rule.wrap.class) {
108
+ ctx.rule.wrap.class = ''
109
+ }
110
+ const wrapClass =
111
+ typeof ctx.rule.wrap.class === 'string'
112
+ ? ctx.rule.wrap.class.split(' ').filter(Boolean)
113
+ : Array.isArray(ctx.rule.wrap.class)
114
+ ? ctx.rule.wrap.class
115
+ : []
116
+ if (!wrapClass.includes('_fc-spin-wrap-fit')) {
117
+ wrapClass.push('_fc-spin-wrap-fit')
118
+ ctx.rule.wrap.class = wrapClass.join(' ')
119
+ }
120
+
121
+ // 设置样式
122
+ if (!ctx.rule.wrap.style) {
123
+ ctx.rule.wrap.style = {}
124
+ }
125
+ ctx.rule.wrap.style.width = 'fit-content'
126
+ ctx.rule.wrap.style.display = 'inline-block'
127
+ }
128
+
89
129
  // 确保子组件不被 a-col 包装
90
130
  if (ctx.rule.children && Array.isArray(ctx.rule.children)) {
91
- ctx.rule.children.forEach((child) => {
92
- if (
93
- child &&
94
- typeof child === 'object' &&
95
- child.type !== 'DragTool' &&
96
- child.type !== 'DragBox'
97
- ) {
98
- // 只有当 col 未设置或为默认值时才设置
99
- if (child.col === undefined || child.col === null) {
100
- child.col = false
101
- } else if (
102
- child.col &&
103
- typeof child.col === 'object' &&
104
- child.col.show !== false
131
+ ctx.rule.children.forEach((child) => {
132
+ if (
133
+ child &&
134
+ typeof child === 'object' &&
135
+ child.type !== 'DragTool' &&
136
+ child.type !== 'DragBox'
105
137
  ) {
106
- child.col.show = false
138
+ // 只有当 col 未设置或为默认值时才设置
139
+ if (child.col === undefined || child.col === null) {
140
+ child.col = false
141
+ } else if (
142
+ child.col &&
143
+ typeof child.col === 'object' &&
144
+ child.col.show !== false
145
+ ) {
146
+ child.col.show = false
147
+ }
107
148
  }
108
- }
109
- })
110
- }
149
+ })
150
+ }
111
151
  }
112
152
  },
113
153
  render(children, ctx) {
@@ -130,7 +170,8 @@ export default {
130
170
  }
131
171
 
132
172
  // 如果有 delay,设置 delay prop
133
- const delay = ctx.rule.delay || ctx.rule.props?.delay || ctx.prop.props?.delay
173
+ const delay =
174
+ ctx.rule.delay || ctx.rule.props?.delay || ctx.prop.props?.delay
134
175
  if (delay != null) {
135
176
  ctx.prop.props.delay = delay
136
177
  }
@@ -147,12 +188,12 @@ export default {
147
188
  }
148
189
 
149
190
  // 读取 containerMode 配置
150
- const containerMode =
151
- ctx.rule.containerMode ??
152
- ctx.rule.props?.containerMode ??
153
- ctx.prop.props?.containerMode ??
191
+ const containerMode =
192
+ ctx.rule.containerMode ??
193
+ ctx.rule.props?.containerMode ??
194
+ ctx.prop.props?.containerMode ??
154
195
  true
155
-
196
+
156
197
  // 如果不是容器模式,不渲染 children,直接使用 defaultRender
157
198
  if (!containerMode) {
158
199
  return ctx.$render.defaultRender(ctx, undefined)
@@ -160,15 +201,42 @@ export default {
160
201
 
161
202
  // 容器模式:使用传入的 children 参数
162
203
  // children 参数已经是渲染好的 vnodes,直接传递给 a-spin
163
- const childrenNodes = children && Array.isArray(children) ? children : (children || [])
204
+ const childrenNodes =
205
+ children && Array.isArray(children) ? children : children || []
206
+
207
+ // 检查是否有子组件(排除设计器内部组件)
208
+ const hasRealChildren =
209
+ childrenNodes &&
210
+ Array.isArray(childrenNodes) &&
211
+ childrenNodes.some((node) => {
212
+ if (!node || typeof node !== 'object') return false
213
+ const nodeType = node.type?.name || node.type
214
+ return nodeType !== 'DragTool' && nodeType !== 'DragBox'
215
+ })
216
+
217
+ // 添加 class 标识,用于样式控制(当有子组件时)
218
+ if (hasRealChildren) {
219
+ if (!ctx.prop.class) {
220
+ ctx.prop.class = []
221
+ }
222
+ if (!Array.isArray(ctx.prop.class)) {
223
+ ctx.prop.class = [ctx.prop.class]
224
+ }
225
+ if (!ctx.prop.class.includes('_fc-spin-container')) {
226
+ ctx.prop.class.push('_fc-spin-container')
227
+ }
228
+ }
164
229
 
165
- // spin 容器包装在 col 中,确保它占满整行(span: 24)
230
+ // 始终包装在 col
231
+ // 通过 CSS 类让有子组件时自适应内容
166
232
  return ctx.vNode.col(
167
- { props: { span: 24 } },
233
+ {
234
+ props: { span: 24 },
235
+ class: hasRealChildren ? '_fc-spin-col-fit' : ''
236
+ },
168
237
  {
169
238
  default: () => [ctx.vNode.make('a-spin', ctx.prop, childrenNodes)]
170
239
  }
171
240
  )
172
241
  }
173
242
  }
174
-
@@ -501,3 +501,45 @@
501
501
  .ant-flex._fc-flex-vertical > .ant-form-item {
502
502
  width: var(--fc-child-width, 100%) !important;
503
503
  }
504
+
505
+ /* Spin 容器自适应子组件尺寸 - 让整个布局链自适应 */
506
+ /* 通过 form-item 的 class 控制整个布局 */
507
+ .ant-form-item._fc-spin-wrap-fit {
508
+ width: fit-content !important;
509
+ display: inline-block !important;
510
+ }
511
+
512
+ .ant-form-item._fc-spin-wrap-fit .ant-form-item-control {
513
+ width: fit-content !important;
514
+ flex: none !important;
515
+ }
516
+
517
+ .ant-form-item._fc-spin-wrap-fit .ant-form-item-control-input {
518
+ width: fit-content !important;
519
+ }
520
+
521
+ .ant-form-item._fc-spin-wrap-fit .ant-form-item-control-input-content {
522
+ width: fit-content !important;
523
+ display: inline-block !important;
524
+ }
525
+
526
+ /* col 自适应 */
527
+ .ant-form-item._fc-spin-wrap-fit .ant-col._fc-spin-col-fit {
528
+ width: fit-content !important;
529
+ flex: 0 0 auto !important;
530
+ max-width: 100% !important;
531
+ }
532
+
533
+ /* Spin 组件自适应 */
534
+ .ant-form-item._fc-spin-wrap-fit .ant-spin._fc-spin-container {
535
+ display: inline-block !important;
536
+ width: fit-content !important;
537
+ height: fit-content !important;
538
+ }
539
+
540
+ /* 确保 Spin 容器内的内容决定容器大小 */
541
+ .ant-form-item._fc-spin-wrap-fit .ant-spin._fc-spin-container .ant-spin-container {
542
+ display: inline-block !important;
543
+ width: fit-content !important;
544
+ height: fit-content !important;
545
+ }