@longhongguo/form-create-ant-design-vue 3.3.7 → 3.3.9
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/auto-import.js +3 -1
- package/dist/form-create.css +47 -7
- package/dist/form-create.esm.css +47 -7
- package/dist/form-create.esm.js +2 -2
- package/dist/form-create.esm.js.map +1 -1
- package/dist/form-create.js +2 -2
- package/dist/form-create.js.map +1 -1
- package/package.json +1 -1
- package/src/core/alias.js +3 -0
- package/src/core/manager.js +28 -2
- package/src/parsers/card.js +38 -0
- package/src/parsers/index.js +2 -0
- package/src/parsers/select.js +8 -0
- package/src/style/index.css +47 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longhongguo/form-create-ant-design-vue",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.09",
|
|
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
package/src/core/manager.js
CHANGED
|
@@ -87,8 +87,15 @@ export default {
|
|
|
87
87
|
// 预览模式下:对 upload 组件设置 disabled
|
|
88
88
|
// wangEditor 组件使用只读模式(readOnly),允许复制和点击链接
|
|
89
89
|
// textarea 组件使用只读模式(readOnly),允许复制和自适应高度
|
|
90
|
-
//
|
|
91
|
-
|
|
90
|
+
// select 组件使用 disabled 实现只读效果(通过 CSS 样式来保持外观)
|
|
91
|
+
// 如果组件单独设置了 readOnly 属性,也应用相同的预览模式逻辑
|
|
92
|
+
const isPreviewMode = this.$handle.preview === true
|
|
93
|
+
// 从 rule.props 或 ctx.prop.props 中读取 readOnly 属性
|
|
94
|
+
const isReadOnly =
|
|
95
|
+
ctx.rule.props?.readOnly === true || ctx.prop.props?.readOnly === true
|
|
96
|
+
const shouldApplyPreviewStyle = isPreviewMode || isReadOnly
|
|
97
|
+
|
|
98
|
+
if (shouldApplyPreviewStyle) {
|
|
92
99
|
if (ctx.rule.type === 'upload') {
|
|
93
100
|
if (ctx.prop.props) {
|
|
94
101
|
ctx.prop.props.disabled = true
|
|
@@ -112,6 +119,25 @@ export default {
|
|
|
112
119
|
// 移除 rows 属性,让 autoSize 完全控制高度
|
|
113
120
|
delete ctx.prop.props.rows
|
|
114
121
|
}
|
|
122
|
+
} else if (ctx.rule.type === 'select') {
|
|
123
|
+
// select 组件在预览模式下使用 disabled 实现只读效果
|
|
124
|
+
// 注意:Ant Design Vue 的 Select 组件不支持 readOnly 属性
|
|
125
|
+
// 所以在预览模式下使用 disabled,并通过 CSS 样式来保持外观
|
|
126
|
+
// 强制设置 disabled = true,覆盖用户可能设置的 disabled: false
|
|
127
|
+
if (ctx.prop.props) {
|
|
128
|
+
ctx.prop.props.disabled = true
|
|
129
|
+
// 如果原本设置了 readOnly,保留这个标记以便 CSS 识别
|
|
130
|
+
if (isReadOnly) {
|
|
131
|
+
// 可以在这里添加一个标记,但 Select 组件不支持 readOnly
|
|
132
|
+
// 所以我们通过 disabled 来实现,CSS 会处理样式
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} else if (ctx.rule.type === 'input') {
|
|
136
|
+
// input 组件支持 readOnly 属性
|
|
137
|
+
// 如果设置了 readOnly,直接使用组件的 readOnly 属性
|
|
138
|
+
if (ctx.prop.props && isReadOnly) {
|
|
139
|
+
ctx.prop.props.readOnly = true
|
|
140
|
+
}
|
|
115
141
|
}
|
|
116
142
|
}
|
|
117
143
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
name: 'aCard',
|
|
3
|
+
mergeProp(ctx) {
|
|
4
|
+
// 确保 children 存在
|
|
5
|
+
if (!ctx.rule.children) {
|
|
6
|
+
ctx.rule.children = []
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// 为 Card 容器的所有子组件设置 col: false,避免被 a-col 包装
|
|
10
|
+
// 这样子组件可以直接作为 Card 的子元素
|
|
11
|
+
if (ctx.rule.children && Array.isArray(ctx.rule.children)) {
|
|
12
|
+
ctx.rule.children.forEach((child) => {
|
|
13
|
+
if (
|
|
14
|
+
child &&
|
|
15
|
+
typeof child === 'object' &&
|
|
16
|
+
child.type !== 'DragTool' &&
|
|
17
|
+
child.type !== 'DragBox'
|
|
18
|
+
) {
|
|
19
|
+
// 只有当 col 未设置或为默认值时才设置
|
|
20
|
+
if (child.col === undefined || child.col === null) {
|
|
21
|
+
child.col = false
|
|
22
|
+
} else if (
|
|
23
|
+
child.col &&
|
|
24
|
+
typeof child.col === 'object' &&
|
|
25
|
+
child.col.show !== false
|
|
26
|
+
) {
|
|
27
|
+
child.col.show = false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
render(children, ctx) {
|
|
34
|
+
// 使用默认渲染,通过 alias 映射到 aCard 组件
|
|
35
|
+
return ctx.$render.defaultRender(ctx, children)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
package/src/parsers/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import space from './space'
|
|
|
18
18
|
import spin from './spin'
|
|
19
19
|
import div from './div'
|
|
20
20
|
import alert from './alert'
|
|
21
|
+
import card from './card'
|
|
21
22
|
import accTable from './accTable'
|
|
22
23
|
|
|
23
24
|
export default [
|
|
@@ -41,5 +42,6 @@ export default [
|
|
|
41
42
|
spin,
|
|
42
43
|
div,
|
|
43
44
|
alert,
|
|
45
|
+
card,
|
|
44
46
|
accTable
|
|
45
47
|
]
|
package/src/parsers/select.js
CHANGED
|
@@ -17,6 +17,14 @@ export default {
|
|
|
17
17
|
props.disabled = true
|
|
18
18
|
props.loading = true
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
// readOnly 属性的处理:如果设置了 readOnly,强制设置 disabled = true
|
|
22
|
+
// 从 rule.props 或 ctx.prop.props 中读取 readOnly
|
|
23
|
+
const isReadOnly =
|
|
24
|
+
ctx.rule.props?.readOnly === true || props.readOnly === true
|
|
25
|
+
if (isReadOnly) {
|
|
26
|
+
props.disabled = true
|
|
27
|
+
}
|
|
20
28
|
},
|
|
21
29
|
render(children, ctx) {
|
|
22
30
|
// 检测 loading 状态(与 mergeProp 中的逻辑保持一致)
|
package/src/style/index.css
CHANGED
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/* 移除组件边框 */
|
|
51
|
+
/* 预览模式或只读模式的样式 */
|
|
51
52
|
.form-create.is-preview .ant-input,
|
|
52
53
|
.form-create.is-preview .ant-input-number,
|
|
53
54
|
.form-create.is-preview .ant-select-selector,
|
|
@@ -61,7 +62,17 @@
|
|
|
61
62
|
.form-create.is-preview .ant-input-wrapper,
|
|
62
63
|
.form-create.is-preview .ant-input-affix-wrapper,
|
|
63
64
|
.form-create.is-preview .ant-input-group-wrapper,
|
|
64
|
-
.form-create.is-preview .ant-input-group
|
|
65
|
+
.form-create.is-preview .ant-input-group,
|
|
66
|
+
/* 只读模式的样式(通过 readOnly 属性或 disabled 属性识别) */
|
|
67
|
+
.ant-input[readonly],
|
|
68
|
+
.ant-input[readonly] ~ .ant-input-wrapper,
|
|
69
|
+
.ant-input[readonly] ~ .ant-input-affix-wrapper,
|
|
70
|
+
.ant-textarea[readonly],
|
|
71
|
+
.ant-select-disabled .ant-select-selector,
|
|
72
|
+
.ant-picker-disabled,
|
|
73
|
+
.ant-cascader-disabled .ant-cascader-picker,
|
|
74
|
+
input[readonly].ant-input,
|
|
75
|
+
textarea[readonly].ant-input {
|
|
65
76
|
border: none !important;
|
|
66
77
|
box-shadow: none !important;
|
|
67
78
|
background: transparent !important;
|
|
@@ -76,7 +87,13 @@
|
|
|
76
87
|
.form-create.is-preview .ant-textarea:focus,
|
|
77
88
|
.form-create.is-preview .ant-input-wrapper:focus,
|
|
78
89
|
.form-create.is-preview .ant-input-affix-wrapper:focus,
|
|
79
|
-
.form-create.is-preview .ant-input-affix-wrapper-focused
|
|
90
|
+
.form-create.is-preview .ant-input-affix-wrapper-focused,
|
|
91
|
+
/* 只读模式:移除焦点状态边框 */
|
|
92
|
+
.ant-input[readonly]:focus,
|
|
93
|
+
.ant-textarea[readonly]:focus,
|
|
94
|
+
.ant-select-disabled.ant-select-focused .ant-select-selector,
|
|
95
|
+
.ant-select-disabled:focus .ant-select-selector,
|
|
96
|
+
.ant-picker-disabled:focus {
|
|
80
97
|
border: none !important;
|
|
81
98
|
box-shadow: none !important;
|
|
82
99
|
outline: none !important;
|
|
@@ -90,7 +107,12 @@
|
|
|
90
107
|
.form-create.is-preview .ant-input-password:hover,
|
|
91
108
|
.form-create.is-preview .ant-textarea:hover,
|
|
92
109
|
.form-create.is-preview .ant-input-wrapper:hover,
|
|
93
|
-
.form-create.is-preview .ant-input-affix-wrapper:hover
|
|
110
|
+
.form-create.is-preview .ant-input-affix-wrapper:hover,
|
|
111
|
+
/* 只读模式:移除悬停状态边框 */
|
|
112
|
+
.ant-input[readonly]:hover,
|
|
113
|
+
.ant-textarea[readonly]:hover,
|
|
114
|
+
.ant-select-disabled:hover .ant-select-selector,
|
|
115
|
+
.ant-picker-disabled:hover {
|
|
94
116
|
border: none !important;
|
|
95
117
|
box-shadow: none !important;
|
|
96
118
|
}
|
|
@@ -280,7 +302,10 @@
|
|
|
280
302
|
|
|
281
303
|
/* 预览模式:隐藏选择器的下拉箭头 */
|
|
282
304
|
.form-create.is-preview .ant-select-arrow,
|
|
283
|
-
.form-create.is-preview .ant-select-suffix
|
|
305
|
+
.form-create.is-preview .ant-select-suffix,
|
|
306
|
+
/* 只读模式:隐藏选择器的下拉箭头 */
|
|
307
|
+
.ant-select-disabled .ant-select-arrow,
|
|
308
|
+
.ant-select-disabled .ant-select-suffix {
|
|
284
309
|
display: none !important;
|
|
285
310
|
}
|
|
286
311
|
|
|
@@ -302,7 +327,15 @@
|
|
|
302
327
|
.form-create.is-preview .ant-input-number[disabled],
|
|
303
328
|
.form-create.is-preview .ant-select-disabled,
|
|
304
329
|
.form-create.is-preview .ant-picker-disabled,
|
|
305
|
-
.form-create.is-preview .ant-textarea[disabled]
|
|
330
|
+
.form-create.is-preview .ant-textarea[disabled],
|
|
331
|
+
/* 只读模式:防止输入框显示为禁用状态的灰色 */
|
|
332
|
+
.ant-input[readonly],
|
|
333
|
+
.ant-input[readonly][disabled],
|
|
334
|
+
.ant-input-number[disabled],
|
|
335
|
+
.ant-textarea[readonly],
|
|
336
|
+
.ant-textarea[readonly][disabled],
|
|
337
|
+
.ant-select-disabled,
|
|
338
|
+
.ant-picker-disabled {
|
|
306
339
|
opacity: 1 !important;
|
|
307
340
|
color: inherit !important;
|
|
308
341
|
background-color: transparent !important;
|
|
@@ -343,11 +376,15 @@
|
|
|
343
376
|
}
|
|
344
377
|
|
|
345
378
|
/* 预览模式:防止选择器显示为禁用状态 */
|
|
346
|
-
.form-create.is-preview .ant-select-disabled .ant-select-selector
|
|
379
|
+
.form-create.is-preview .ant-select-disabled .ant-select-selector,
|
|
380
|
+
/* 只读模式:防止选择器显示为禁用状态 */
|
|
381
|
+
.ant-select-disabled .ant-select-selector {
|
|
347
382
|
opacity: 1 !important;
|
|
348
383
|
color: inherit !important;
|
|
349
384
|
background-color: transparent !important;
|
|
350
385
|
cursor: default !important;
|
|
386
|
+
border: none !important;
|
|
387
|
+
box-shadow: none !important;
|
|
351
388
|
}
|
|
352
389
|
|
|
353
390
|
/* 预览模式:防止日期选择器显示为禁用状态 */
|
|
@@ -444,7 +481,10 @@
|
|
|
444
481
|
}
|
|
445
482
|
|
|
446
483
|
/* 预览模式:禁用选择器下拉 */
|
|
447
|
-
.form-create.is-preview .ant-select-dropdown
|
|
484
|
+
.form-create.is-preview .ant-select-dropdown,
|
|
485
|
+
/* 只读模式:禁用选择器下拉 */
|
|
486
|
+
.ant-select-disabled + .ant-select-dropdown,
|
|
487
|
+
.ant-select.ant-select-disabled ~ .ant-select-dropdown {
|
|
448
488
|
display: none !important;
|
|
449
489
|
}
|
|
450
490
|
|