@longhongguo/form-create-ant-design-vue 3.3.31 → 3.3.34

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.3.31",
3
+ "version": "3.3.34",
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",
@@ -84,19 +84,12 @@ export default {
84
84
  )
85
85
  })
86
86
 
87
- // 应用 componentStyle 到组件元素本身(不受父容器影响)
88
- // 注意:这个样式需要在 parser.mergeProp 之后应用才能确保不被覆盖
89
- // 但由于执行顺序限制,我们先在这里设置,parser 应该使用合并方式而不是覆盖
87
+ // 应用 componentStyle 到包裹组件的最顶层父容器(如 .fc-form-col)
88
+ // 这样在 Flex 或 Space 布局中,可以给子元素设置 flex: 1 等样式
90
89
  if (ctx.rule.componentStyle && typeof ctx.rule.componentStyle === 'object') {
91
- // 确保 props 存在
92
- if (!ctx.prop.props) {
93
- ctx.prop.props = {}
94
- }
95
-
96
- // 将 componentStyle 合并到 props.style,直接应用到组件元素本身
97
- // 这样即使 parser 使用 {...existing, ...new} 的方式合并,componentStyle 也会被保留
98
- const existingStyle = ctx.prop.props.style || {}
99
- ctx.prop.props.style = {
90
+ // componentStyle 合并到 prop.style,这会应用到包裹组件的容器上
91
+ const existingStyle = ctx.prop.style || {}
92
+ ctx.prop.style = {
100
93
  ...existingStyle,
101
94
  ...ctx.rule.componentStyle
102
95
  }
@@ -469,7 +462,7 @@ export default {
469
462
  isFalse(col.show) ||
470
463
  shouldDisableCol
471
464
  ? item
472
- : this.makeCol(rule, uni, [item])
465
+ : this.makeCol(rule, uni, [item], ctx)
473
466
  },
474
467
  isTitle(rule) {
475
468
  if (this.options.form.title === false) return false
@@ -551,13 +544,16 @@ export default {
551
544
 
552
545
  return this.$r(_prop, children)
553
546
  },
554
- makeCol(rule, uni, children) {
547
+ makeCol(rule, uni, children, ctx) {
555
548
  const col = rule.col
549
+ // 将 componentStyle 应用到 col 容器上
550
+ const style = ctx?.prop?.style || {}
556
551
  return this.$r(
557
552
  {
558
553
  class: this.$render.mergeClass(col.class, 'fc-form-col'),
559
554
  type: 'col',
560
555
  props: col || { span: 24 },
556
+ style: style,
561
557
  key: `${uni}col`
562
558
  },
563
559
  children
@@ -97,16 +97,20 @@ export default {
97
97
  }
98
98
 
99
99
  // 同时也合并到 props.style,确保样式生效
100
- // 注意:保留 componentStyle(如果存在),它应该在最后应用,优先级最高
101
100
  if (!ctx.prop.props) {
102
101
  ctx.prop.props = {}
103
102
  }
104
- const componentStyle = ctx.rule.componentStyle || {}
105
103
  ctx.prop.props.style = {
106
104
  ...existingPropsStyle,
107
- ...flexStyles,
108
- // componentStyle 最后合并,确保优先级最高
109
- ...componentStyle
105
+ ...flexStyles
106
+ }
107
+
108
+ // componentStyle 应用到 prop.style(包裹容器),最后合并确保优先级最高
109
+ if (ctx.rule.componentStyle && typeof ctx.rule.componentStyle === 'object') {
110
+ ctx.prop.style = {
111
+ ...ctx.prop.style,
112
+ ...ctx.rule.componentStyle
113
+ }
110
114
  }
111
115
 
112
116
  // 确保 children 存在
@@ -245,8 +249,13 @@ export default {
245
249
 
246
250
  // 将 flex 容器包装在 col 中,确保它占满整行(span: 24)
247
251
  // 这样 flex 容器才能有足够的宽度,子项才能自适应展示
252
+ // 应用 componentStyle 到 col 容器(如果存在)
253
+ const componentStyle = ctx.rule.componentStyle || {}
248
254
  return ctx.vNode.col(
249
- { props: { span: 24 } },
255
+ {
256
+ props: { span: 24 },
257
+ style: componentStyle
258
+ },
250
259
  {
251
260
  default: () => [ctx.vNode.make('a-flex', prop, childrenNodes)]
252
261
  }
@@ -37,13 +37,14 @@ export default {
37
37
  if (!ctx.prop.props.style) {
38
38
  ctx.prop.props.style = {}
39
39
  }
40
- // 保留 componentStyle(如果存在),它应该在最后应用,优先级最高
41
- const componentStyle = ctx.rule.componentStyle || {}
42
- ctx.prop.props.style = {
43
- ...ctx.prop.props.style,
44
- ...spaceStyles,
45
- // componentStyle 最后合并,确保优先级最高
46
- ...componentStyle
40
+ ctx.prop.props.style = { ...ctx.prop.props.style, ...spaceStyles }
41
+
42
+ // componentStyle 应用到 prop.style(包裹容器),最后合并确保优先级最高
43
+ if (ctx.rule.componentStyle && typeof ctx.rule.componentStyle === 'object') {
44
+ ctx.prop.style = {
45
+ ...ctx.prop.style,
46
+ ...ctx.rule.componentStyle
47
+ }
47
48
  }
48
49
 
49
50
  // 确保 children 存在
@@ -121,8 +122,13 @@ export default {
121
122
 
122
123
  // 将 space 容器包装在 col 中,确保它占满整行(span: 24)
123
124
  // 这样 space 容器才能有足够的宽度
125
+ // 应用 componentStyle 到 col 容器(如果存在)
126
+ const componentStyle = ctx.rule.componentStyle || {}
124
127
  return ctx.vNode.col(
125
- { props: { span: 24 } },
128
+ {
129
+ props: { span: 24 },
130
+ style: componentStyle
131
+ },
126
132
  {
127
133
  default: () => [ctx.vNode.make(prop.type, prop, childrenNodes)]
128
134
  }