@carefrees/form-utils-vue 0.0.11 → 0.0.12
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/README.md +56 -2
- package/assets/index.css +23 -12
- package/esm/component.js +3 -0
- package/esm/form/form.js +156 -0
- package/esm/form/form.vue.d.ts +10 -7
- package/esm/form/index.d.ts +12 -12
- package/esm/form/index.js +4 -0
- package/esm/formItem/form.Item.base.js +162 -0
- package/esm/formItem/form.Item.base.vue.d.ts +6 -8
- package/esm/formItem/form.hide.item.js +126 -0
- package/esm/formItem/form.hide.item.vue.d.ts +6 -8
- package/esm/formItem/formItem.js +155 -0
- package/esm/formItem/formItem.vue.d.ts +6 -9
- package/esm/formItem/index.d.ts +24 -37
- package/esm/formItem/index.js +8 -0
- package/esm/hooks/attr/attr.FormItem.d.ts +5 -5
- package/esm/hooks/attr/attr.FormItem.js +97 -0
- package/esm/hooks/index.js +13 -0
- package/esm/hooks/register/register.FormHideItem.d.ts +2 -2
- package/esm/hooks/register/register.FormHideItem.js +42 -0
- package/esm/hooks/register/register.FormItem.d.ts +9 -6
- package/esm/hooks/register/register.FormItem.js +67 -0
- package/esm/hooks/register/register.FormList.d.ts +3 -3
- package/esm/hooks/register/register.FormList.js +42 -0
- package/esm/hooks/register/register.form.d.ts +1 -1
- package/esm/hooks/register/register.form.js +10 -0
- package/esm/hooks/useAttrs.d.ts +1 -0
- package/esm/hooks/useAttrs.js +26 -0
- package/esm/hooks/useEffect.js +12 -0
- package/esm/hooks/useForm.d.ts +1 -1
- package/esm/hooks/useForm.js +17 -0
- package/esm/hooks/useFormItem.js +17 -0
- package/esm/hooks/useFormItemParentName.js +47 -0
- package/esm/hooks/useFormList.js +17 -0
- package/esm/hooks/useHtmlFor.d.ts +1 -1
- package/esm/hooks/useHtmlFor.js +7 -0
- package/esm/hooks/useMultipleForm.d.ts +1 -1
- package/esm/hooks/useMultipleForm.js +18 -0
- package/esm/index.d.ts +1 -1
- package/esm/index.js +13 -0
- package/esm/instance/ruleIntsnace.d.ts +1 -1
- package/esm/instance/ruleIntsnace.js +65 -0
- package/esm/interface/index.d.ts +2 -0
- package/esm/interface/index.js +0 -0
- package/esm/interface/layout.formItem.js +0 -0
- package/esm/interface/layout.js +0 -0
- package/esm/layout/index.d.ts +24 -33
- package/esm/layout/index.js +8 -0
- package/esm/layout/layout.form.rows.js +21 -0
- package/esm/layout/layout.form.rows.vue.d.ts +8 -5
- package/esm/layout/layout.formItem.js +195 -0
- package/esm/layout/layout.formItem.vue.d.ts +6 -9
- package/esm/layout/layout.js +160 -0
- package/esm/layout/layout.vue.d.ts +6 -8
- package/esm/utils/index.js +1 -0
- package/esm/utils/withInstall.d.ts +2 -2
- package/esm/utils/withInstall.js +15 -0
- package/package.json +6 -8
- package/src/form/form.vue +8 -1
- package/src/interface/index.ts +2 -0
- package/esm/component.mjs +0 -12
- package/esm/form/form.vue.mjs +0 -110
- package/esm/form/form.vue2.mjs +0 -4
- package/esm/form/index.mjs +0 -6
- package/esm/formItem/form.Item.base.vue.mjs +0 -114
- package/esm/formItem/form.Item.base.vue2.mjs +0 -4
- package/esm/formItem/form.hide.item.vue.mjs +0 -78
- package/esm/formItem/form.hide.item.vue2.mjs +0 -4
- package/esm/formItem/formItem.vue.mjs +0 -102
- package/esm/formItem/formItem.vue2.mjs +0 -4
- package/esm/formItem/index.mjs +0 -12
- package/esm/hooks/attr/attr.FormItem.mjs +0 -120
- package/esm/hooks/register/register.FormHideItem.mjs +0 -38
- package/esm/hooks/register/register.FormItem.mjs +0 -55
- package/esm/hooks/register/register.FormList.mjs +0 -43
- package/esm/hooks/register/register.form.mjs +0 -12
- package/esm/hooks/useAttrs.mjs +0 -43
- package/esm/hooks/useEffect.mjs +0 -14
- package/esm/hooks/useForm.mjs +0 -26
- package/esm/hooks/useFormItem.mjs +0 -26
- package/esm/hooks/useFormItemParentName.mjs +0 -37
- package/esm/hooks/useFormList.mjs +0 -26
- package/esm/hooks/useHtmlFor.mjs +0 -11
- package/esm/hooks/useMultipleForm.mjs +0 -27
- package/esm/index.mjs +0 -59
- package/esm/instance/ruleIntsnace.mjs +0 -73
- package/esm/layout/index.mjs +0 -12
- package/esm/layout/layout.form.rows.vue.mjs +0 -31
- package/esm/layout/layout.form.rows.vue2.mjs +0 -4
- package/esm/layout/layout.formItem.vue.mjs +0 -216
- package/esm/layout/layout.formItem.vue2.mjs +0 -4
- package/esm/layout/layout.vue.mjs +0 -166
- package/esm/layout/layout.vue2.mjs +0 -4
- package/esm/utils/withInstall.mjs +0 -22
- package/lib/component.d.ts +0 -3
- package/lib/component.js +0 -12
- package/lib/form/form.vue.d.ts +0 -19
- package/lib/form/form.vue.js +0 -110
- package/lib/form/form.vue2.js +0 -4
- package/lib/form/index.d.ts +0 -37
- package/lib/form/index.js +0 -6
- package/lib/formItem/form.Item.base.vue.d.ts +0 -16
- package/lib/formItem/form.Item.base.vue.js +0 -114
- package/lib/formItem/form.Item.base.vue2.js +0 -4
- package/lib/formItem/form.hide.item.vue.d.ts +0 -16
- package/lib/formItem/form.hide.item.vue.js +0 -78
- package/lib/formItem/form.hide.item.vue2.js +0 -4
- package/lib/formItem/formItem.vue.d.ts +0 -18
- package/lib/formItem/formItem.vue.js +0 -102
- package/lib/formItem/formItem.vue2.js +0 -4
- package/lib/formItem/index.d.ts +0 -71
- package/lib/formItem/index.js +0 -12
- package/lib/hooks/attr/attr.FormItem.d.ts +0 -97
- package/lib/hooks/attr/attr.FormItem.js +0 -120
- package/lib/hooks/index.d.ts +0 -13
- package/lib/hooks/register/register.FormHideItem.d.ts +0 -9
- package/lib/hooks/register/register.FormHideItem.js +0 -38
- package/lib/hooks/register/register.FormItem.d.ts +0 -23
- package/lib/hooks/register/register.FormItem.js +0 -55
- package/lib/hooks/register/register.FormList.d.ts +0 -9
- package/lib/hooks/register/register.FormList.js +0 -43
- package/lib/hooks/register/register.form.d.ts +0 -3
- package/lib/hooks/register/register.form.js +0 -12
- package/lib/hooks/useAttrs.d.ts +0 -24
- package/lib/hooks/useAttrs.js +0 -43
- package/lib/hooks/useEffect.d.ts +0 -2
- package/lib/hooks/useEffect.js +0 -14
- package/lib/hooks/useForm.d.ts +0 -8
- package/lib/hooks/useForm.js +0 -26
- package/lib/hooks/useFormItem.d.ts +0 -7
- package/lib/hooks/useFormItem.js +0 -26
- package/lib/hooks/useFormItemParentName.d.ts +0 -18
- package/lib/hooks/useFormItemParentName.js +0 -37
- package/lib/hooks/useFormList.d.ts +0 -7
- package/lib/hooks/useFormList.js +0 -26
- package/lib/hooks/useHtmlFor.d.ts +0 -2
- package/lib/hooks/useHtmlFor.js +0 -11
- package/lib/hooks/useMultipleForm.d.ts +0 -7
- package/lib/hooks/useMultipleForm.js +0 -27
- package/lib/index.d.ts +0 -11
- package/lib/index.js +0 -59
- package/lib/instance/ruleIntsnace.d.ts +0 -49
- package/lib/instance/ruleIntsnace.js +0 -73
- package/lib/interface/index.d.ts +0 -36
- package/lib/interface/layout.d.ts +0 -28
- package/lib/interface/layout.formItem.d.ts +0 -39
- package/lib/layout/index.d.ts +0 -65
- package/lib/layout/index.js +0 -12
- package/lib/layout/layout.form.rows.vue.d.ts +0 -10
- package/lib/layout/layout.form.rows.vue.js +0 -31
- package/lib/layout/layout.form.rows.vue2.js +0 -4
- package/lib/layout/layout.formItem.vue.d.ts +0 -18
- package/lib/layout/layout.formItem.vue.js +0 -216
- package/lib/layout/layout.formItem.vue2.js +0 -4
- package/lib/layout/layout.vue.d.ts +0 -16
- package/lib/layout/layout.vue.js +0 -166
- package/lib/layout/layout.vue2.js +0 -4
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/withInstall.d.ts +0 -3
- package/lib/utils/withInstall.js +0 -22
- package/src/vite-env.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
-
# 表单工具
|
|
1
|
+
# vue 表单工具
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 安装
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @carefrees/form-utils-vue # yarn add @carefrees/form-utils-vue # pnpm add @carefrees/form-utils-vue
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## 使用
|
|
10
|
+
|
|
11
|
+
### 基本使用
|
|
12
|
+
|
|
13
|
+
```vue
|
|
14
|
+
<script lang="ts" setup>
|
|
15
|
+
import { reactive } from "vue";
|
|
16
|
+
import { Form, useForm, FormItem } from "@carefrees/form-utils-vue";
|
|
17
|
+
import "@carefrees/form-utils-vue/assets/index.css"
|
|
18
|
+
const formData = reactive({})
|
|
19
|
+
const form = useForm();
|
|
20
|
+
const onSubmit = async () => {
|
|
21
|
+
try {
|
|
22
|
+
console.log(form, formData)
|
|
23
|
+
const result = await form.value.validate()
|
|
24
|
+
if (result) {
|
|
25
|
+
console.log(result)
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.log(error)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const onSetValue = () => {
|
|
32
|
+
form.value.updatedFieldValue('b', '123')
|
|
33
|
+
}
|
|
34
|
+
const onValuesChange = (...rest: any[]) => {
|
|
35
|
+
console.log(rest)
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
<template>
|
|
39
|
+
<Form @valuesChange='onValuesChange' :formData='formData' :form='form'>
|
|
40
|
+
<FormItem label='内容' input='input' name='a' :rules='[{ required: true, message: "必填" }]' />
|
|
41
|
+
<FormItem input='input' name='b'>
|
|
42
|
+
<template #label>
|
|
43
|
+
<span>s内容2</span>
|
|
44
|
+
</template>
|
|
45
|
+
<template #helpText>
|
|
46
|
+
<span>helpText</span>
|
|
47
|
+
</template>
|
|
48
|
+
<template #extra>
|
|
49
|
+
<span>extra</span>
|
|
50
|
+
</template>
|
|
51
|
+
</FormItem>
|
|
52
|
+
<FormItem label='Input' input='input' name='c' />
|
|
53
|
+
<button type='button' @click='onSubmit'>点击</button>
|
|
54
|
+
<button type='button' @click='onSetValue'>设置值</button>
|
|
55
|
+
</Form>
|
|
56
|
+
</template>
|
|
57
|
+
```
|
package/assets/index.css
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
/* 表单 */
|
|
2
|
+
html.dark .carefrees-form {
|
|
3
|
+
--form-color: #e3e3e3;
|
|
4
|
+
--form-header-color: #e3e3e3;
|
|
5
|
+
--form-font-size: 14px;
|
|
6
|
+
--form-border-color: #e0e0e0;
|
|
7
|
+
}
|
|
8
|
+
/* 表单 */
|
|
2
9
|
.carefrees-form {
|
|
10
|
+
--form-color: rgba(0, 0, 0, 0.88);
|
|
11
|
+
--form-header-color: #1d2129;
|
|
12
|
+
--form-font-size: 14px;
|
|
13
|
+
--form-border-color: #e0e0e0;
|
|
14
|
+
|
|
3
15
|
box-sizing: border-box;
|
|
4
|
-
|
|
5
|
-
|
|
16
|
+
font-size: var(--form-font-size);
|
|
17
|
+
color: var(--form-color, rgba(0, 0, 0, 0.88));
|
|
6
18
|
}
|
|
7
19
|
|
|
8
20
|
/* 布局 */
|
|
@@ -19,7 +31,7 @@
|
|
|
19
31
|
}
|
|
20
32
|
|
|
21
33
|
.carefrees-form-layout.bordered {
|
|
22
|
-
border: 1px solid #e0e0e0;
|
|
34
|
+
border: 1px solid var(--form-border-color, #e0e0e0);
|
|
23
35
|
}
|
|
24
36
|
.carefrees-form-layout.bordered .carefrees-form-layout-header {
|
|
25
37
|
padding-inline-start: 8px;
|
|
@@ -31,7 +43,7 @@
|
|
|
31
43
|
justify-content: space-between;
|
|
32
44
|
align-items: center;
|
|
33
45
|
flex-direction: row;
|
|
34
|
-
border-bottom: 1px solid #e0e0e0;
|
|
46
|
+
border-bottom: 1px solid var(--form-border-color, #e0e0e0);
|
|
35
47
|
padding-top: 5px;
|
|
36
48
|
padding-bottom: 5px;
|
|
37
49
|
margin-block-end: 4px;
|
|
@@ -43,13 +55,13 @@
|
|
|
43
55
|
.carefrees-form-layout-header-title {
|
|
44
56
|
font-size: 14px;
|
|
45
57
|
font-weight: 600;
|
|
46
|
-
color: #1d2129;
|
|
58
|
+
color: var(--form-header-color, #1d2129);
|
|
47
59
|
box-sizing: border-box;
|
|
48
60
|
}
|
|
49
61
|
.carefrees-form-layout-header-extra {
|
|
50
62
|
font-size: 14px;
|
|
51
63
|
font-weight: 500;
|
|
52
|
-
color: #1d2129;
|
|
64
|
+
color: var(--form-header-color, #1d2129);
|
|
53
65
|
box-sizing: border-box;
|
|
54
66
|
}
|
|
55
67
|
|
|
@@ -70,7 +82,7 @@
|
|
|
70
82
|
flex-direction: row;
|
|
71
83
|
padding: 8px;
|
|
72
84
|
box-sizing: border-box;
|
|
73
|
-
color: rgba(0, 0, 0, 0.88);
|
|
85
|
+
color: var(--form-color, rgba(0, 0, 0, 0.88));
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
.carefrees-form-item-container {
|
|
@@ -84,10 +96,9 @@
|
|
|
84
96
|
.carefrees-form-item-container.left {
|
|
85
97
|
flex-direction: row;
|
|
86
98
|
gap: 8px;
|
|
87
|
-
text-align: left;
|
|
88
99
|
}
|
|
89
|
-
.carefrees-form-item-container.left .carefrees-form-item-label {
|
|
90
|
-
|
|
100
|
+
.carefrees-form-item-container.left .carefrees-form-item-label-warp {
|
|
101
|
+
text-align: right;
|
|
91
102
|
}
|
|
92
103
|
.carefrees-form-item-container.between {
|
|
93
104
|
gap: 8px;
|
|
@@ -113,7 +124,7 @@
|
|
|
113
124
|
justify-content: flex-start;
|
|
114
125
|
position: relative;
|
|
115
126
|
font-size: 14px;
|
|
116
|
-
color: rgba(0, 0, 0, 0.88);
|
|
127
|
+
color: var(--form-color, rgba(0, 0, 0, 0.88));
|
|
117
128
|
min-height: 1.4rem;
|
|
118
129
|
}
|
|
119
130
|
|
|
@@ -156,7 +167,7 @@
|
|
|
156
167
|
}
|
|
157
168
|
|
|
158
169
|
.carefrees-form-item-body-input.input-bordered {
|
|
159
|
-
border-bottom: 1px solid #e0e0e0;
|
|
170
|
+
border-bottom: 1px solid var(--form-border-color, #e0e0e0);
|
|
160
171
|
}
|
|
161
172
|
|
|
162
173
|
.carefrees-form-item-body-help {
|
package/esm/component.js
ADDED
package/esm/form/form.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { computed, createElementBlock, createVNode, defineComponent, mergeProps, normalizeClass, normalizeStyle, openBlock, reactive, renderSlot, unref, withCtx } from "vue";
|
|
2
|
+
import { useRegisterForm } from "../hooks/register/register.form.js";
|
|
3
|
+
import { useForm, useFormProvide } from "../hooks/useForm.js";
|
|
4
|
+
import layout from "../layout/layout.js";
|
|
5
|
+
import classnames from "classnames";
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
|
+
name: "Form",
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
__name: "form",
|
|
10
|
+
props: {
|
|
11
|
+
form: {},
|
|
12
|
+
style: {
|
|
13
|
+
type: [
|
|
14
|
+
Boolean,
|
|
15
|
+
null,
|
|
16
|
+
String,
|
|
17
|
+
Object,
|
|
18
|
+
Array
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
class: {},
|
|
22
|
+
layoutClass: {},
|
|
23
|
+
layoutStyle: {
|
|
24
|
+
type: [
|
|
25
|
+
Boolean,
|
|
26
|
+
null,
|
|
27
|
+
String,
|
|
28
|
+
Object,
|
|
29
|
+
Array
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
formData: {},
|
|
33
|
+
onValuesChange: {},
|
|
34
|
+
onFinish: {},
|
|
35
|
+
onFinishFailed: {},
|
|
36
|
+
hideData: {},
|
|
37
|
+
name: {},
|
|
38
|
+
hideRuleData: {},
|
|
39
|
+
bgcolor: {},
|
|
40
|
+
title: {
|
|
41
|
+
type: [
|
|
42
|
+
Object,
|
|
43
|
+
String,
|
|
44
|
+
Number,
|
|
45
|
+
Boolean,
|
|
46
|
+
null,
|
|
47
|
+
Array
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
extra: {
|
|
51
|
+
type: [
|
|
52
|
+
Object,
|
|
53
|
+
String,
|
|
54
|
+
Number,
|
|
55
|
+
Boolean,
|
|
56
|
+
null,
|
|
57
|
+
Array
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
isAllColSpan: {
|
|
61
|
+
type: Boolean
|
|
62
|
+
},
|
|
63
|
+
headerClass: {},
|
|
64
|
+
bodyClass: {},
|
|
65
|
+
headerStyle: {
|
|
66
|
+
type: [
|
|
67
|
+
Boolean,
|
|
68
|
+
null,
|
|
69
|
+
String,
|
|
70
|
+
Object,
|
|
71
|
+
Array
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
bodyStyle: {
|
|
75
|
+
type: [
|
|
76
|
+
Boolean,
|
|
77
|
+
null,
|
|
78
|
+
String,
|
|
79
|
+
Object,
|
|
80
|
+
Array
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
bordered: {
|
|
84
|
+
type: Boolean
|
|
85
|
+
},
|
|
86
|
+
colCount: {},
|
|
87
|
+
gap: {},
|
|
88
|
+
errorLayout: {},
|
|
89
|
+
labelMode: {},
|
|
90
|
+
showColon: {},
|
|
91
|
+
formItemClass: {},
|
|
92
|
+
formItemStyle: {},
|
|
93
|
+
formItemLabelClass: {},
|
|
94
|
+
formItemLabelStyle: {}
|
|
95
|
+
},
|
|
96
|
+
emits: [
|
|
97
|
+
"finish",
|
|
98
|
+
"valuesChange",
|
|
99
|
+
"finishFailed"
|
|
100
|
+
],
|
|
101
|
+
setup (__props, { emit: __emit }) {
|
|
102
|
+
const props = __props;
|
|
103
|
+
const { form, style, formData, hideData, hideRuleData, name, onFinish, onFinishFailed, onValuesChange, layoutStyle, layoutClass, bgcolor, ...rest } = props;
|
|
104
|
+
const cls = computed(()=>classnames("carefrees-form", props.class));
|
|
105
|
+
const formStyle = computed(()=>{
|
|
106
|
+
if (bgcolor) return [
|
|
107
|
+
{
|
|
108
|
+
backgroundColor: bgcolor
|
|
109
|
+
},
|
|
110
|
+
props.style
|
|
111
|
+
];
|
|
112
|
+
return [
|
|
113
|
+
props.style
|
|
114
|
+
];
|
|
115
|
+
});
|
|
116
|
+
const formInstance = useForm(props.form);
|
|
117
|
+
formInstance.value.ctor(reactive(props.formData || {}), reactive(props.hideData || {}), reactive(props.hideRuleData || {}));
|
|
118
|
+
const emits = __emit;
|
|
119
|
+
formInstance.value.onFinish = (...rest2)=>{
|
|
120
|
+
emits("finish", ...rest2);
|
|
121
|
+
};
|
|
122
|
+
formInstance.value.onValuesChange = (...rest2)=>{
|
|
123
|
+
emits("valuesChange", ...rest2);
|
|
124
|
+
};
|
|
125
|
+
formInstance.value.onFinishFailed = (...rest2)=>{
|
|
126
|
+
emits("finishFailed", ...rest2);
|
|
127
|
+
};
|
|
128
|
+
useRegisterForm(formInstance.value, props.name);
|
|
129
|
+
const onSubmit = (event)=>{
|
|
130
|
+
event?.preventDefault?.();
|
|
131
|
+
event?.stopPropagation?.();
|
|
132
|
+
formInstance.value.submit?.();
|
|
133
|
+
};
|
|
134
|
+
useFormProvide(formInstance.value);
|
|
135
|
+
return (_ctx, _cache)=>(openBlock(), createElementBlock("form", {
|
|
136
|
+
class: normalizeClass(cls.value),
|
|
137
|
+
style: normalizeStyle(formStyle.value),
|
|
138
|
+
onSubmit
|
|
139
|
+
}, [
|
|
140
|
+
createVNode(layout, mergeProps(rest, {
|
|
141
|
+
class: unref(layoutClass),
|
|
142
|
+
style: unref(layoutStyle)
|
|
143
|
+
}), {
|
|
144
|
+
default: withCtx(()=>[
|
|
145
|
+
renderSlot(_ctx.$slots, "default")
|
|
146
|
+
]),
|
|
147
|
+
_: 3
|
|
148
|
+
}, 16, [
|
|
149
|
+
"class",
|
|
150
|
+
"style"
|
|
151
|
+
])
|
|
152
|
+
], 38));
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
const form_form = _sfc_main;
|
|
156
|
+
export { form_form as default };
|
package/esm/form/form.vue.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { FormProps } from
|
|
1
|
+
import type { FormProps } from "../interface/index";
|
|
2
2
|
type __VLS_Props = FormProps;
|
|
3
|
-
declare
|
|
3
|
+
declare var __VLS_4: {};
|
|
4
|
+
type __VLS_Slots = {} & {
|
|
5
|
+
default?: (props: typeof __VLS_4) => any;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
4
8
|
finish: (...args: any[]) => void;
|
|
5
9
|
valuesChange: (...args: any[]) => void;
|
|
6
10
|
finishFailed: (...args: any[]) => void;
|
|
7
|
-
}, string, import(
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
8
12
|
onFinish?: ((...args: any[]) => any) | undefined;
|
|
9
13
|
onValuesChange?: ((...args: any[]) => any) | undefined;
|
|
10
14
|
onFinishFailed?: ((...args: any[]) => any) | undefined;
|
|
11
|
-
}>, {}, {}, {}, {}, string, import(
|
|
12
|
-
|
|
13
|
-
}>;
|
|
15
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
14
17
|
export default _default;
|
|
15
|
-
type
|
|
18
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
16
19
|
new (): {
|
|
17
20
|
$slots: S;
|
|
18
21
|
};
|
package/esm/form/index.d.ts
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
export declare const Form: import(
|
|
2
|
-
new (...args: any[]): import(
|
|
1
|
+
export declare const Form: import("../utils").SFCWithInstall<{
|
|
2
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("../index.js").FormProps<any>> & Readonly<{
|
|
3
3
|
onFinish?: ((...args: any[]) => any) | undefined;
|
|
4
4
|
onValuesChange?: ((...args: any[]) => any) | undefined;
|
|
5
5
|
onFinishFailed?: ((...args: any[]) => any) | undefined;
|
|
6
|
-
}>, {}, {}, {}, {}, import(
|
|
6
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
7
|
finish: (...args: any[]) => void;
|
|
8
8
|
valuesChange: (...args: any[]) => void;
|
|
9
9
|
finishFailed: (...args: any[]) => void;
|
|
10
|
-
}, import(
|
|
10
|
+
}, import("vue").PublicProps, {}, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
11
11
|
P: {};
|
|
12
12
|
B: {};
|
|
13
13
|
D: {};
|
|
14
14
|
C: {};
|
|
15
15
|
M: {};
|
|
16
16
|
Defaults: {};
|
|
17
|
-
}, Readonly<import(
|
|
17
|
+
}, Readonly<import("../index.js").FormProps<any>> & Readonly<{
|
|
18
18
|
onFinish?: ((...args: any[]) => any) | undefined;
|
|
19
19
|
onValuesChange?: ((...args: any[]) => any) | undefined;
|
|
20
20
|
onFinishFailed?: ((...args: any[]) => any) | undefined;
|
|
21
21
|
}>, {}, {}, {}, {}, {}>;
|
|
22
|
-
__isFragment?:
|
|
23
|
-
__isTeleport?:
|
|
24
|
-
__isSuspense?:
|
|
25
|
-
} & import(
|
|
22
|
+
__isFragment?: never;
|
|
23
|
+
__isTeleport?: never;
|
|
24
|
+
__isSuspense?: never;
|
|
25
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("../index.js").FormProps<any>> & Readonly<{
|
|
26
26
|
onFinish?: ((...args: any[]) => any) | undefined;
|
|
27
27
|
onValuesChange?: ((...args: any[]) => any) | undefined;
|
|
28
28
|
onFinishFailed?: ((...args: any[]) => any) | undefined;
|
|
29
|
-
}>, {}, {}, {}, {}, import(
|
|
29
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
30
30
|
finish: (...args: any[]) => void;
|
|
31
31
|
valuesChange: (...args: any[]) => void;
|
|
32
32
|
finishFailed: (...args: any[]) => void;
|
|
33
|
-
}, string, {}, {}, string, {}, import(
|
|
33
|
+
}, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
34
34
|
$slots: {
|
|
35
|
-
default
|
|
35
|
+
default?: (props: {}) => any;
|
|
36
36
|
};
|
|
37
37
|
})> & Record<string, any>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { computed, createBlock, createSlots, defineComponent, guardReactiveProps, mergeProps, normalizeClass, normalizeProps, normalizeStyle, openBlock, renderList, renderSlot, resolveDynamicComponent, toValue, unref, useSlots, withCtx } from "vue";
|
|
2
|
+
import { useFormItemAttr } from "../hooks/attr/attr.FormItem.js";
|
|
3
|
+
import layout_formItem from "../layout/layout.formItem.js";
|
|
4
|
+
import { useFormItemParentNameProvide } from "../hooks/useFormItemParentName.js";
|
|
5
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
6
|
+
name: "FormItemBase",
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
__name: "form.Item.base",
|
|
9
|
+
props: {
|
|
10
|
+
noStyle: {
|
|
11
|
+
type: Boolean
|
|
12
|
+
},
|
|
13
|
+
input: {},
|
|
14
|
+
dependencies: {},
|
|
15
|
+
noticeOnlyRuleDataField: {},
|
|
16
|
+
isNoticeParentField: {
|
|
17
|
+
type: Boolean
|
|
18
|
+
},
|
|
19
|
+
noticeWatchField: {},
|
|
20
|
+
preserve: {
|
|
21
|
+
type: Boolean
|
|
22
|
+
},
|
|
23
|
+
useRules: {},
|
|
24
|
+
useAttrs: {},
|
|
25
|
+
inputAttrs: {},
|
|
26
|
+
valuePropName: {},
|
|
27
|
+
getValuePath: {},
|
|
28
|
+
getValueFromEvent: {},
|
|
29
|
+
formatValue: {},
|
|
30
|
+
onAfterUpdate: {},
|
|
31
|
+
trigger: {},
|
|
32
|
+
name: {},
|
|
33
|
+
rules: {},
|
|
34
|
+
sort: {},
|
|
35
|
+
isJoinParentField: {
|
|
36
|
+
type: Boolean
|
|
37
|
+
},
|
|
38
|
+
errorLayout: {},
|
|
39
|
+
required: {
|
|
40
|
+
type: Boolean
|
|
41
|
+
},
|
|
42
|
+
labelMode: {},
|
|
43
|
+
onlyRuleStyle: {
|
|
44
|
+
type: Boolean
|
|
45
|
+
},
|
|
46
|
+
label: {
|
|
47
|
+
type: [
|
|
48
|
+
Object,
|
|
49
|
+
String,
|
|
50
|
+
Number,
|
|
51
|
+
Boolean,
|
|
52
|
+
null,
|
|
53
|
+
Array
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
helpText: {
|
|
57
|
+
type: [
|
|
58
|
+
Object,
|
|
59
|
+
String,
|
|
60
|
+
Number,
|
|
61
|
+
Boolean,
|
|
62
|
+
null,
|
|
63
|
+
Array
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
extra: {
|
|
67
|
+
type: [
|
|
68
|
+
Object,
|
|
69
|
+
String,
|
|
70
|
+
Number,
|
|
71
|
+
Boolean,
|
|
72
|
+
null,
|
|
73
|
+
Array
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
showColon: {
|
|
77
|
+
type: Boolean
|
|
78
|
+
},
|
|
79
|
+
colSpan: {},
|
|
80
|
+
rowSpan: {},
|
|
81
|
+
htmlFor: {},
|
|
82
|
+
validateResult: {},
|
|
83
|
+
style: {
|
|
84
|
+
type: [
|
|
85
|
+
Boolean,
|
|
86
|
+
null,
|
|
87
|
+
String,
|
|
88
|
+
Object,
|
|
89
|
+
Array
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
class: {},
|
|
93
|
+
labelStyle: {
|
|
94
|
+
type: [
|
|
95
|
+
Boolean,
|
|
96
|
+
null,
|
|
97
|
+
String,
|
|
98
|
+
Object,
|
|
99
|
+
Array
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
labelClass: {}
|
|
103
|
+
},
|
|
104
|
+
setup (__props) {
|
|
105
|
+
const props = __props;
|
|
106
|
+
const formAttrs = useFormItemAttr(props);
|
|
107
|
+
useFormItemParentNameProvide({
|
|
108
|
+
name: formAttrs.newName,
|
|
109
|
+
sort: formAttrs.newSort
|
|
110
|
+
});
|
|
111
|
+
const slots = useSlots();
|
|
112
|
+
const isRequired = computed(()=>!!props.required || !!(toValue(formAttrs.ruleInstance?.value?.rules) || [])?.find((item)=>item.required));
|
|
113
|
+
return (_ctx, _cache)=>props.noStyle ? (openBlock(), createBlock(resolveDynamicComponent(props.input), normalizeProps(mergeProps({
|
|
114
|
+
key: 0
|
|
115
|
+
}, toValue(unref(formAttrs).attrsLastData))), null, 16)) : (openBlock(), createBlock(layout_formItem, {
|
|
116
|
+
key: 1,
|
|
117
|
+
label: props.label,
|
|
118
|
+
required: isRequired.value,
|
|
119
|
+
"error-layout": props.errorLayout,
|
|
120
|
+
"label-mode": props.labelMode,
|
|
121
|
+
"only-rule-style": props.onlyRuleStyle,
|
|
122
|
+
"show-colon": props.showColon,
|
|
123
|
+
"col-span": props.colSpan,
|
|
124
|
+
"row-span": props.rowSpan,
|
|
125
|
+
"html-for": unref(formAttrs).htmlFor,
|
|
126
|
+
style: normalizeStyle(props.style),
|
|
127
|
+
class: normalizeClass(props.class),
|
|
128
|
+
"label-style": props.labelStyle,
|
|
129
|
+
"label-class": props.labelClass,
|
|
130
|
+
"validate-result": unref(formAttrs).validateResult
|
|
131
|
+
}, createSlots({
|
|
132
|
+
default: withCtx(()=>[
|
|
133
|
+
(openBlock(), createBlock(resolveDynamicComponent(props.input), normalizeProps(guardReactiveProps(toValue(unref(formAttrs).attrsLastData))), null, 16))
|
|
134
|
+
]),
|
|
135
|
+
_: 2
|
|
136
|
+
}, [
|
|
137
|
+
renderList(slots, (item, name)=>({
|
|
138
|
+
name,
|
|
139
|
+
fn: withCtx((slotProps)=>[
|
|
140
|
+
renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(slotProps)))
|
|
141
|
+
])
|
|
142
|
+
}))
|
|
143
|
+
]), 1032, [
|
|
144
|
+
"label",
|
|
145
|
+
"required",
|
|
146
|
+
"error-layout",
|
|
147
|
+
"label-mode",
|
|
148
|
+
"only-rule-style",
|
|
149
|
+
"show-colon",
|
|
150
|
+
"col-span",
|
|
151
|
+
"row-span",
|
|
152
|
+
"html-for",
|
|
153
|
+
"style",
|
|
154
|
+
"class",
|
|
155
|
+
"label-style",
|
|
156
|
+
"label-class",
|
|
157
|
+
"validate-result"
|
|
158
|
+
]));
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const form_Item_base = _sfc_main;
|
|
162
|
+
export { form_Item_base as default };
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { FormItemProps } from
|
|
2
|
-
|
|
1
|
+
import type { FormItemProps } from "../interface/index";
|
|
2
|
+
type __VLS_Slots = {
|
|
3
3
|
label: (params: any) => any;
|
|
4
4
|
helpText: (params: any) => any;
|
|
5
5
|
extra: (params: any) => any;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
extra: (params: any) => any;
|
|
10
|
-
}>;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_component: import("vue").DefineComponent<FormItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
11
9
|
export default _default;
|
|
12
|
-
type
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
13
11
|
new (): {
|
|
14
12
|
$slots: S;
|
|
15
13
|
};
|