@longhongguo/form-create-ant-design-vue 3.2.54 → 3.2.55

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.54",
3
+ "version": "3.2.55",
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
@@ -27,6 +27,7 @@ export default {
27
27
  frame: 'fcFrame',
28
28
  col: PRE + 'Col',
29
29
  row: PRE + 'Row',
30
+ flex: PRE + 'Flex',
30
31
  tree: PRE + 'Tree',
31
32
  autoComplete: PRE + 'AutoComplete',
32
33
  transfer: PRE + 'Transfer',
@@ -3,38 +3,68 @@ export default {
3
3
  mergeProp(ctx) {
4
4
  // 从 props 中读取 flex 布局配置
5
5
  const props = ctx.rule.props || {}
6
-
7
- // 获取 flex 布局相关配置
8
6
  const flexDirection = props.flexDirection || ctx.rule.flexDirection || 'row'
9
7
  const flexWrap = props.flexWrap || ctx.rule.flexWrap || 'nowrap'
10
8
  const justifyContent =
11
9
  props.justifyContent || ctx.rule.justifyContent || 'flex-start'
12
10
  const alignItems = props.alignItems || ctx.rule.alignItems || 'flex-start'
13
- const alignContent =
14
- props.alignContent || ctx.rule.alignContent || 'flex-start'
15
11
 
16
- // flex 样式设置到 ctx.prop.props.style,而不是直接修改 ctx.rule.style
17
- // 这样可以避免触发递归更新
12
+ // 映射 CSS flexbox 值到 Ant Design Vue Flex 组件的 props
13
+ const vertical =
14
+ flexDirection === 'column' || flexDirection === 'column-reverse'
15
+ const wrap = flexWrap === 'wrap'
16
+
17
+ // 映射 justifyContent 到 justify
18
+ const justifyMap = {
19
+ 'flex-start': 'start',
20
+ 'flex-end': 'end',
21
+ center: 'center',
22
+ 'space-between': 'space-between',
23
+ 'space-around': 'space-around',
24
+ 'space-evenly': 'space-evenly'
25
+ }
26
+ const justify = justifyMap[justifyContent] || 'start'
27
+
28
+ // 映射 alignItems 到 align
29
+ const alignMap = {
30
+ 'flex-start': 'start',
31
+ 'flex-end': 'end',
32
+ center: 'center',
33
+ baseline: 'baseline',
34
+ stretch: 'stretch'
35
+ }
36
+ const align = alignMap[alignItems] || 'start'
37
+
38
+ // 设置到 prop.props,用于传递给 a-flex 组件
18
39
  if (!ctx.prop.props) {
19
40
  ctx.prop.props = {}
20
41
  }
21
42
 
22
- // 获取现有的 style(来自 rule.style prop.props.style)
23
- const existingStyle = ctx.rule.style || ctx.prop.props.style || {}
24
-
25
- // 合并 flex 样式和现有样式
26
- const flexStyle = {
27
- display: 'flex',
28
- flexDirection,
29
- flexWrap,
30
- justifyContent,
31
- alignItems,
32
- alignContent,
33
- ...existingStyle
43
+ // 映射 Ant Design Vue Flex 组件的 props
44
+ ctx.prop.props.vertical = vertical
45
+ ctx.prop.props.wrap = wrap
46
+ ctx.prop.props.justify = justify
47
+ ctx.prop.props.align = align
48
+
49
+ // 如果设置了 gap,也传递
50
+ if (props.gap !== undefined) {
51
+ ctx.prop.props.gap = props.gap
34
52
  }
35
53
 
36
- // 设置到 prop.props.style,这样不会触发 rule 的响应式更新
37
- ctx.prop.props.style = flexStyle
54
+ // 合并其他样式到 props.style(用于非 Flex 组件控制的样式,如 padding, margin 等)
55
+ const existingStyle = ctx.rule.style || {}
56
+ // 排除已经被 Flex 组件处理的样式
57
+ const {
58
+ display,
59
+ flexDirection: _fd,
60
+ flexWrap: _fw,
61
+ justifyContent: _jc,
62
+ alignItems: _ai,
63
+ ...otherStyles
64
+ } = existingStyle
65
+ if (Object.keys(otherStyles).length > 0) {
66
+ ctx.prop.props.style = otherStyles
67
+ }
38
68
 
39
69
  // 确保 children 存在
40
70
  if (!ctx.rule.children) {
@@ -42,18 +72,17 @@ export default {
42
72
  }
43
73
  },
44
74
  render(children, ctx) {
45
- // 复制 prop,避免修改原始对象
75
+ // 使用 Ant Design Vue 的 Flex 组件
46
76
  const prop = { ...ctx.prop }
47
77
 
48
- // 确保 type 'div'
78
+ // type 设置为 'a-flex',form-create 会自动识别
49
79
  if (prop.type === 'flex') {
50
- prop.type = 'div'
80
+ prop.type = 'a-flex'
51
81
  }
52
82
 
53
- // style 已经在 mergeProp 中设置到 prop.props.style 了,直接使用
54
83
  // children 会通过 form-create 的机制自动渲染
55
84
  const childrenNodes = children || []
56
85
 
57
- return ctx.vNode.make('div', prop, childrenNodes)
86
+ return ctx.vNode.make('a-flex', prop, childrenNodes)
58
87
  }
59
88
  }