@longhongguo/form-create-ant-design-vue 3.2.60 → 3.2.62

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.60",
3
+ "version": "3.2.62",
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",
@@ -100,6 +100,35 @@ export default {
100
100
  if (ctx.rule) {
101
101
  ctx.rule.col = false
102
102
  }
103
+
104
+ // 读取并应用子组件的 flex 配置(支持等比分配和自由控制)
105
+ // 可以从 props.flex 或 style.flex 读取
106
+ const flexValue = ctx.rule.props?.flex ?? ctx.rule.style?.flex
107
+ if (flexValue !== undefined && flexValue !== null && flexValue !== '') {
108
+ // 确保 style 对象存在
109
+ if (!ctx.prop.style) {
110
+ ctx.prop.style = {}
111
+ }
112
+ if (!ctx.prop.props) {
113
+ ctx.prop.props = {}
114
+ }
115
+ if (!ctx.prop.props.style) {
116
+ ctx.prop.props.style = {}
117
+ }
118
+
119
+ // 转换 flex 值为字符串(CSS flex 值应该是字符串)
120
+ // flex 值可以是数字(如 1, 2)或字符串(如 '1', '2', 'auto', 'none')
121
+ let flexString = flexValue
122
+ if (typeof flexValue === 'number') {
123
+ flexString = String(flexValue)
124
+ } else if (typeof flexValue === 'string') {
125
+ flexString = flexValue.trim()
126
+ }
127
+
128
+ // 应用 flex 值到样式(同时设置到 prop.style 和 prop.props.style)
129
+ ctx.prop.style.flex = flexString
130
+ ctx.prop.props.style.flex = flexString
131
+ }
103
132
  }
104
133
  }
105
134
 
@@ -44,7 +44,8 @@ export default {
44
44
 
45
45
  // 映射 Ant Design Vue Flex 组件的 props
46
46
  ctx.prop.props.vertical = vertical
47
- ctx.prop.props.wrap = wrap
47
+ // 注意:不设置 wrap prop,因为 Ant Design Vue 的 Flex 组件的 wrap prop 类型可能不匹配
48
+ // 换行功能完全通过 CSS 样式来实现
48
49
  ctx.prop.props.justify = justify
49
50
  ctx.prop.props.align = align
50
51
 
@@ -53,55 +54,55 @@ export default {
53
54
  ctx.prop.props.gap = props.gap
54
55
  }
55
56
 
56
- // 直接修改 ctx.rule.style,确保样式能够正确应用
57
- // 因为 form-create 会将 ctx.rule.style 合并到最终的样式对象中
58
- if (!ctx.rule.style) {
59
- ctx.rule.style = {}
60
- }
61
-
62
- // 保留用户设置的 display: 'flex'(如果存在)
63
- const userDisplay = ctx.rule.style.display
64
- const existingStyle = { ...ctx.rule.style }
57
+ // 合并样式(不要直接修改 ctx.rule.style,避免响应式循环)
58
+ const existingStyle = ctx.rule.style || {}
59
+ // 排除已经被 Flex 组件处理的样式
60
+ const {
61
+ display: userDisplay,
62
+ flexDirection: _fd,
63
+ flexWrap: _fw,
64
+ justifyContent: _jc,
65
+ alignItems: _ai,
66
+ alignContent: _ac,
67
+ ...otherStyles
68
+ } = existingStyle
65
69
 
66
70
  // 构建样式对象,确保从 props 读取的配置能够应用到样式中
67
- ctx.rule.style = {
71
+ const flexStyles = {
68
72
  // 保留用户设置的 display,如果没有则设置为 'flex'
69
73
  display: userDisplay || 'flex',
70
74
  // 确保 flex 容器占满整行
71
- width: '100%',
72
75
  // 在样式中设置 flexWrap,确保从 props 读取的配置能够生效
73
- // 这是关键的:将 props.flexWrap 的值直接应用到 style
76
+ // 这是关键的:将 props.flexWrap 的值('wrap' 'nowrap')应用到样式中
74
77
  flexWrap: flexWrap,
75
- // 保留其他用户自定义样式(排除 flex 相关的,避免冲突)
76
- ...Object.keys(existingStyle).reduce((acc, key) => {
77
- // 排除 flex 相关的样式属性,因为我们通过 props 或新的样式设置
78
- if (
79
- ![
80
- 'flexDirection',
81
- 'flexWrap',
82
- 'justifyContent',
83
- 'alignItems',
84
- 'alignContent'
85
- ].includes(key)
86
- ) {
87
- acc[key] = existingStyle[key]
88
- }
89
- return acc
90
- }, {})
78
+ // 合并其他用户自定义样式
79
+ ...otherStyles
91
80
  }
92
81
 
93
82
  // 如果设置了 alignContent,添加到样式中
94
83
  if (alignContent && alignContent !== 'flex-start') {
95
- ctx.rule.style.alignContent = alignContent
84
+ flexStyles.alignContent = alignContent
96
85
  }
97
86
 
98
- // 同时也设置到 ctx.prop.props.style,作为备用
99
- if (!ctx.prop.props.style) {
100
- ctx.prop.props.style = {}
87
+ // 同时设置到 ctx.prop.style 和 ctx.prop.props.style
88
+ // form-create 会将 prop.style 应用到组件上,但有时也需要 prop.props.style
89
+ // 保留已有的 prop.style 和 prop.props.style,然后合并新的样式
90
+ const existingPropStyle = ctx.prop.style || {}
91
+ const existingPropsStyle = ctx.prop.props?.style || {}
92
+
93
+ // 合并样式到 ctx.prop.style(保留已有样式,新的样式优先)
94
+ ctx.prop.style = {
95
+ ...existingPropStyle,
96
+ ...flexStyles
97
+ }
98
+
99
+ // 同时也合并到 props.style,确保样式生效
100
+ if (!ctx.prop.props) {
101
+ ctx.prop.props = {}
101
102
  }
102
103
  ctx.prop.props.style = {
103
- ...ctx.prop.props.style,
104
- ...ctx.rule.style
104
+ ...existingPropsStyle,
105
+ ...flexStyles
105
106
  }
106
107
 
107
108
  // 确保 children 存在