@carefrees/form-utils-vue 0.0.13 → 0.0.15
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 +7 -6
- package/assets/index.css +7 -5
- package/esm/form/form.js +2 -6
- package/esm/index.js +2 -2
- package/esm/interface/index.d.ts +1 -3
- package/esm/layout/layout.js +1 -1
- package/package.json +8 -4
- package/src/form/form.vue +2 -6
- package/src/interface/index.ts +1 -3
package/README.md
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
npm install @carefrees/form-utils-vue # yarn add @carefrees/form-utils-vue # pnpm add @carefrees/form-utils-vue
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
## 加载样式
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import '@carefrees/form-utils-vue/assets/index.css';
|
|
13
|
+
```
|
|
14
|
+
|
|
9
15
|
## 使用
|
|
10
16
|
|
|
11
17
|
### 基本使用
|
|
@@ -15,7 +21,6 @@ npm install @carefrees/form-utils-vue # yarn add @carefrees/form-utils-vue # pnp
|
|
|
15
21
|
import { ref } from "vue";
|
|
16
22
|
import { Form, useForm, FormItem } from "@carefrees/form-utils-vue";
|
|
17
23
|
import "@carefrees/form-utils-vue/assets/index.css"
|
|
18
|
-
import Input from './Input.vue';
|
|
19
24
|
const formData = ref<{ a: string, b: string }>({
|
|
20
25
|
a: '',
|
|
21
26
|
b: ''
|
|
@@ -61,12 +66,9 @@ const onUpdateRules = () => {
|
|
|
61
66
|
rules2.value = [{ required: false, message: "不必填" }]
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
const onValuesChange = (...rest: any[]) => {
|
|
65
|
-
console.log(rest)
|
|
66
|
-
}
|
|
67
69
|
</script>
|
|
68
70
|
<template>
|
|
69
|
-
<Form
|
|
71
|
+
<Form :formData='formData' :form='form'>
|
|
70
72
|
<FormItem label='内容' input='input' name='a' :rules='rules1' />
|
|
71
73
|
<FormItem :input='Input' name='b' :rules='rules2'>
|
|
72
74
|
<template #label>
|
|
@@ -79,7 +81,6 @@ const onValuesChange = (...rest: any[]) => {
|
|
|
79
81
|
<span>extra</span>
|
|
80
82
|
</template>
|
|
81
83
|
</FormItem>
|
|
82
|
-
<FormItem label='Input' input='input' name='c' />
|
|
83
84
|
<FormItem name='d'>
|
|
84
85
|
<template #label>
|
|
85
86
|
<span>d</span>
|
package/assets/index.css
CHANGED
|
@@ -98,7 +98,9 @@ html.dark .carefrees-form {
|
|
|
98
98
|
gap: 8px;
|
|
99
99
|
}
|
|
100
100
|
.carefrees-form-item-container.left .carefrees-form-item-label-warp {
|
|
101
|
-
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: flex-end;
|
|
102
104
|
}
|
|
103
105
|
.carefrees-form-item-container.between {
|
|
104
106
|
gap: 8px;
|
|
@@ -182,7 +184,7 @@ html.dark .carefrees-form {
|
|
|
182
184
|
top: auto;
|
|
183
185
|
left: 0;
|
|
184
186
|
right: 0;
|
|
185
|
-
bottom: -
|
|
187
|
+
bottom: -20px;
|
|
186
188
|
padding-top: 2px;
|
|
187
189
|
font-size: 12px;
|
|
188
190
|
box-sizing: border-box;
|
|
@@ -197,18 +199,18 @@ html.dark .carefrees-form {
|
|
|
197
199
|
top: auto;
|
|
198
200
|
left: 0;
|
|
199
201
|
right: 0;
|
|
200
|
-
bottom: -
|
|
202
|
+
bottom: -20px;
|
|
201
203
|
}
|
|
202
204
|
.carefrees-form-item-body-error.top-left {
|
|
203
205
|
justify-content: start;
|
|
204
|
-
top: -
|
|
206
|
+
top: -20px;
|
|
205
207
|
left: 0px;
|
|
206
208
|
right: 0px;
|
|
207
209
|
bottom: auto;
|
|
208
210
|
}
|
|
209
211
|
.carefrees-form-item-body-error.top-right {
|
|
210
212
|
justify-content: flex-end;
|
|
211
|
-
top: -
|
|
213
|
+
top: -20px;
|
|
212
214
|
left: 0px;
|
|
213
215
|
right: 0px;
|
|
214
216
|
bottom: auto;
|
package/esm/form/form.js
CHANGED
|
@@ -29,7 +29,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
29
29
|
]
|
|
30
30
|
},
|
|
31
31
|
formData: {},
|
|
32
|
-
onValuesChange: {},
|
|
33
32
|
onFinish: {},
|
|
34
33
|
onFinishFailed: {},
|
|
35
34
|
hideData: {},
|
|
@@ -98,7 +97,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
98
97
|
],
|
|
99
98
|
setup (__props, { emit: __emit }) {
|
|
100
99
|
const props = __props;
|
|
101
|
-
const { form, style, formData, hideData, name, onFinish, onFinishFailed,
|
|
100
|
+
const { form, style, formData, hideData, name, onFinish, onFinishFailed, layoutStyle, layoutClass, bgcolor, ...rest } = props;
|
|
102
101
|
const cls = computed(()=>classnames("carefrees-form", props.class));
|
|
103
102
|
const formStyle = computed(()=>{
|
|
104
103
|
if (bgcolor) return [
|
|
@@ -124,9 +123,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
124
123
|
formInstance.value.onFinish = (...rest2)=>{
|
|
125
124
|
emits("finish", ...rest2);
|
|
126
125
|
};
|
|
127
|
-
formInstance.value.onValuesChange = (...rest2)=>{
|
|
128
|
-
emits("valuesChange", ...rest2);
|
|
129
|
-
};
|
|
130
126
|
formInstance.value.onFinishFailed = (...rest2)=>{
|
|
131
127
|
emits("finishFailed", ...rest2);
|
|
132
128
|
};
|
|
@@ -136,7 +132,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
136
132
|
event?.stopPropagation?.();
|
|
137
133
|
formInstance.value.submit?.();
|
|
138
134
|
};
|
|
139
|
-
useFormProvide(formInstance
|
|
135
|
+
useFormProvide(formInstance);
|
|
140
136
|
return (_ctx, _cache)=>(openBlock(), createElementBlock("form", {
|
|
141
137
|
class: normalizeClass(cls.value),
|
|
142
138
|
style: normalizeStyle(formStyle.value),
|
package/esm/index.js
CHANGED
|
@@ -4,10 +4,10 @@ export * from "./utils/index.js";
|
|
|
4
4
|
export * from "./interface/index.js";
|
|
5
5
|
export * from "./interface/layout.js";
|
|
6
6
|
export * from "./interface/layout.formItem.js";
|
|
7
|
-
import * as
|
|
7
|
+
import * as __rspack_external__component_js_7f599402 from "./component.js";
|
|
8
8
|
const src = {
|
|
9
9
|
install: (app)=>{
|
|
10
|
-
for(const c in
|
|
10
|
+
for(const c in __rspack_external__component_js_7f599402)app.use(__rspack_external__component_js_7f599402[c]);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
export { src as default };
|
package/esm/interface/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, StyleValue
|
|
1
|
+
import { Component, StyleValue } from 'vue';
|
|
2
2
|
import { LayoutFormItemProps } from './layout.formItem';
|
|
3
3
|
import { FormLayoutProps } from './layout';
|
|
4
4
|
import type { FormInstanceBase, ValidateErrorEntity, FormItemAttrOptions } from '@carefrees/form-utils-vue-hooks';
|
|
@@ -16,8 +16,6 @@ export interface FormProps<T = any> extends FormLayoutProps {
|
|
|
16
16
|
layoutStyle?: StyleValue;
|
|
17
17
|
/**表单数据*/
|
|
18
18
|
formData?: Object;
|
|
19
|
-
/**值更新触发*/
|
|
20
|
-
onValuesChange?: (changedValues: Partial<T>, values: UnwrapNestedRefs<T>) => void;
|
|
21
19
|
/**提交保存 验证成功*/
|
|
22
20
|
onFinish?: (values: T) => void;
|
|
23
21
|
/**提交保存 验证失败*/
|
package/esm/layout/layout.js
CHANGED
|
@@ -121,7 +121,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
121
121
|
}, [
|
|
122
122
|
isExtra.value || isTitle.value ? (openBlock(), createElementBlock("div", {
|
|
123
123
|
key: 0,
|
|
124
|
-
style: normalizeStyle(
|
|
124
|
+
style: normalizeStyle(__props.headerStyle),
|
|
125
125
|
class: normalizeClass(headerCls.value)
|
|
126
126
|
}, [
|
|
127
127
|
createElementVNode("div", {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carefrees/form-utils-vue",
|
|
3
3
|
"author": "SunLxy <1011771396@qq.com>",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.15",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "esm/index.js",
|
|
7
7
|
"module": "esm/index.js",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/SunLxy/carefrees-form-utils.git"
|
|
19
|
+
},
|
|
16
20
|
"files": [
|
|
17
21
|
"assets",
|
|
18
22
|
"src",
|
|
@@ -24,9 +28,9 @@
|
|
|
24
28
|
"vue": "^3.5.13"
|
|
25
29
|
},
|
|
26
30
|
"dependencies": {
|
|
27
|
-
"@carefrees/form-utils": "^0.0.
|
|
28
|
-
"@carefrees/form-utils-vue-hooks": "^0.0.
|
|
31
|
+
"@carefrees/form-utils": "^0.0.15",
|
|
32
|
+
"@carefrees/form-utils-vue-hooks": "^0.0.15",
|
|
29
33
|
"async-validator": "~4.2.5",
|
|
30
34
|
"classnames": "2.5.1"
|
|
31
35
|
}
|
|
32
|
-
}
|
|
36
|
+
}
|
package/src/form/form.vue
CHANGED
|
@@ -29,7 +29,6 @@ const {
|
|
|
29
29
|
name,
|
|
30
30
|
onFinish,
|
|
31
31
|
onFinishFailed,
|
|
32
|
-
onValuesChange,
|
|
33
32
|
layoutStyle,
|
|
34
33
|
layoutClass,
|
|
35
34
|
bgcolor,
|
|
@@ -61,20 +60,17 @@ const emits = defineEmits(["finish", 'valuesChange', 'finishFailed'])
|
|
|
61
60
|
formInstance.value.onFinish = (...rest) => {
|
|
62
61
|
emits("finish", ...rest)
|
|
63
62
|
};
|
|
64
|
-
|
|
65
|
-
emits("valuesChange", ...rest)
|
|
66
|
-
};
|
|
63
|
+
|
|
67
64
|
formInstance.value.onFinishFailed = (...rest) => {
|
|
68
65
|
emits("finishFailed", ...rest)
|
|
69
66
|
};
|
|
70
67
|
useRegisterForm(formInstance, props.name)
|
|
71
|
-
|
|
72
68
|
const onSubmit = (event: Event) => {
|
|
73
69
|
event?.preventDefault?.();
|
|
74
70
|
event?.stopPropagation?.();
|
|
75
71
|
formInstance.value.submit?.();
|
|
76
72
|
}
|
|
77
73
|
|
|
78
|
-
useFormProvide(formInstance
|
|
74
|
+
useFormProvide(formInstance);
|
|
79
75
|
|
|
80
76
|
</script>
|
package/src/interface/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, StyleValue
|
|
1
|
+
import { Component, StyleValue } from 'vue';
|
|
2
2
|
import { LayoutFormItemProps } from './layout.formItem';
|
|
3
3
|
import { FormLayoutProps } from './layout';
|
|
4
4
|
import type { FormInstanceBase, ValidateErrorEntity, FormItemAttrOptions } from '@carefrees/form-utils-vue-hooks';
|
|
@@ -18,8 +18,6 @@ export interface FormProps<T = any> extends FormLayoutProps {
|
|
|
18
18
|
layoutStyle?: StyleValue;
|
|
19
19
|
/**表单数据*/
|
|
20
20
|
formData?: Object;
|
|
21
|
-
/**值更新触发*/
|
|
22
|
-
onValuesChange?: (changedValues: Partial<T>, values: UnwrapNestedRefs<T>) => void;
|
|
23
21
|
/**提交保存 验证成功*/
|
|
24
22
|
onFinish?: (values: T) => void;
|
|
25
23
|
/**提交保存 验证失败*/
|