@volverjs/form-vue 0.0.14-beta.3 → 0.0.14-beta.4
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/dist/index.d.ts +1 -1904
- package/dist/index.es.js +248 -242
- package/dist/index.umd.js +1 -1
- package/dist/{VvForm.d.ts → src/VvForm.d.ts} +6 -1
- package/dist/src/index.d.ts +1919 -0
- package/dist/test-playwright/VvForm.spec.d.ts +1 -0
- package/dist/test-playwright/VvFormField.spec.d.ts +1 -0
- package/dist/test-playwright/VvFormWrapper.spec.d.ts +1 -0
- package/dist/test-vitest/defaultObjectBySchema.test.d.ts +1 -0
- package/dist/test-vitest/useForm.test.d.ts +1 -0
- package/package.json +12 -11
- package/src/VvForm.ts +20 -12
- package/src/VvFormTemplate.ts +99 -101
- package/src/index.ts +1 -0
- /package/dist/{VvFormField.d.ts → src/VvFormField.d.ts} +0 -0
- /package/dist/{VvFormTemplate.d.ts → src/VvFormTemplate.d.ts} +0 -0
- /package/dist/{VvFormWrapper.d.ts → src/VvFormWrapper.d.ts} +0 -0
- /package/dist/{enums.d.ts → src/enums.d.ts} +0 -0
- /package/dist/{types.d.ts → src/types.d.ts} +0 -0
- /package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/volverjs/form-vue/issues"
|
|
21
21
|
},
|
|
22
|
-
"version": "0.0.14-beta.
|
|
22
|
+
"version": "0.0.14-beta.4",
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">= 16.x"
|
|
25
25
|
},
|
|
26
|
-
"packageManager": "pnpm@8.
|
|
26
|
+
"packageManager": "pnpm@8.7.5",
|
|
27
27
|
"type": "module",
|
|
28
28
|
"main": "./dist/index.js",
|
|
29
29
|
"module": "./dist/index.js",
|
|
@@ -35,34 +35,35 @@
|
|
|
35
35
|
"*.d.ts"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@volverjs/ui-vue": "
|
|
38
|
+
"@volverjs/ui-vue": "0.0.10-beta.3",
|
|
39
39
|
"@vueuse/core": "^10.4.1",
|
|
40
40
|
"ts-dot-prop": "^2.1.3",
|
|
41
41
|
"vue": "^3.3.4",
|
|
42
42
|
"zod": "^3.22.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@playwright/experimental-ct-vue": "1.
|
|
45
|
+
"@playwright/experimental-ct-vue": "1.38.0",
|
|
46
46
|
"@testing-library/vue": "^7.0.0",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
48
|
-
"@typescript-eslint/parser": "^6.5.0",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
49
48
|
"@vitejs/plugin-vue": "^4.3.4",
|
|
50
49
|
"@volverjs/style": "^0.1.11",
|
|
51
50
|
"@vue/compiler-sfc": "^3.3.4",
|
|
51
|
+
"@vue/eslint-config-typescript": "^12.0.0",
|
|
52
52
|
"@vue/runtime-core": "^3.3.4",
|
|
53
53
|
"@vue/test-utils": "^2.4.1",
|
|
54
54
|
"copy": "^0.3.2",
|
|
55
|
-
"eslint": "^8.
|
|
55
|
+
"eslint": "^8.49.0",
|
|
56
56
|
"eslint-config-prettier": "^9.0.0",
|
|
57
57
|
"eslint-plugin-prettier": "^5.0.0",
|
|
58
|
-
"
|
|
58
|
+
"eslint-plugin-vue": "^9.17.0",
|
|
59
|
+
"happy-dom": "^11.0.6",
|
|
59
60
|
"prettier": "^3.0.3",
|
|
60
61
|
"typescript": "^5.2.2",
|
|
61
62
|
"vite": "^4.4.9",
|
|
62
63
|
"vite-plugin-dts": "^3.5.3",
|
|
63
64
|
"vite-plugin-eslint": "^1.8.1",
|
|
64
65
|
"vite-plugin-externalize-deps": "^0.7.0",
|
|
65
|
-
"vitest": "^0.34.
|
|
66
|
+
"vitest": "^0.34.4"
|
|
66
67
|
},
|
|
67
68
|
"typesVersions": {
|
|
68
69
|
"*": {
|
|
@@ -83,9 +84,9 @@
|
|
|
83
84
|
"scripts": {
|
|
84
85
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
|
85
86
|
"type-check": "tsc --noEmit",
|
|
86
|
-
"build": "vite build",
|
|
87
87
|
"dev": "vite build --watch",
|
|
88
|
-
"
|
|
88
|
+
"build": "vite build",
|
|
89
|
+
"test": "pnpm run build && pnpm run test-vitest && pnpm run test-playwright",
|
|
89
90
|
"test-vitest": "vitest run",
|
|
90
91
|
"test-vitest-watch": "vitest",
|
|
91
92
|
"test-playwright": "playwright test -c playwright-ct.config.ts",
|
package/src/VvForm.ts
CHANGED
|
@@ -52,6 +52,7 @@ export const defineForm = <Schema extends FormSchema>(
|
|
|
52
52
|
},
|
|
53
53
|
template: {
|
|
54
54
|
type: [Array, Function] as PropType<FormTemplate<Schema>>,
|
|
55
|
+
default: undefined,
|
|
55
56
|
},
|
|
56
57
|
},
|
|
57
58
|
emits: ['invalid', 'valid', 'submit', 'update:modelValue'],
|
|
@@ -160,6 +161,15 @@ export const defineForm = <Schema extends FormSchema>(
|
|
|
160
161
|
}
|
|
161
162
|
},
|
|
162
163
|
render() {
|
|
164
|
+
const defaultSlot = () =>
|
|
165
|
+
this.$slots?.default?.({
|
|
166
|
+
formData: this.formData,
|
|
167
|
+
submit: this.submit,
|
|
168
|
+
validate: this.validate,
|
|
169
|
+
errors: this.errors,
|
|
170
|
+
status: this.status,
|
|
171
|
+
invalid: this.invalid,
|
|
172
|
+
}) ?? this.$slots.default
|
|
163
173
|
return h(
|
|
164
174
|
'form',
|
|
165
175
|
{
|
|
@@ -167,20 +177,18 @@ export const defineForm = <Schema extends FormSchema>(
|
|
|
167
177
|
},
|
|
168
178
|
(this.template ?? options?.template) && VvFormTemplate
|
|
169
179
|
? [
|
|
170
|
-
h(
|
|
171
|
-
|
|
172
|
-
|
|
180
|
+
h(
|
|
181
|
+
VvFormTemplate,
|
|
182
|
+
{
|
|
183
|
+
schema: this.template ?? options?.template,
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
default: defaultSlot,
|
|
187
|
+
},
|
|
188
|
+
),
|
|
173
189
|
]
|
|
174
190
|
: {
|
|
175
|
-
default:
|
|
176
|
-
this.$slots?.default?.({
|
|
177
|
-
formData: this.formData,
|
|
178
|
-
submit: this.submit,
|
|
179
|
-
validate: this.validate,
|
|
180
|
-
errors: this.errors,
|
|
181
|
-
status: this.status,
|
|
182
|
-
invalid: this.invalid,
|
|
183
|
-
}) ?? this.$slots.default,
|
|
191
|
+
default: defaultSlot,
|
|
184
192
|
},
|
|
185
193
|
)
|
|
186
194
|
},
|
package/src/VvFormTemplate.ts
CHANGED
|
@@ -35,119 +35,117 @@ export const defineFormTemplate = <Schema extends FormSchema>(
|
|
|
35
35
|
? templateProps.schema(injectedFormData)
|
|
36
36
|
: templateProps.schema
|
|
37
37
|
let lastIf: boolean | undefined = undefined
|
|
38
|
-
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
const toReturn = normalizedSchema.reduce<
|
|
39
|
+
(VNode | VNode[] | undefined)[]
|
|
40
|
+
>((acc, field) => {
|
|
41
|
+
const normalizedField =
|
|
42
|
+
typeof field === 'function'
|
|
43
|
+
? field(injectedFormData)
|
|
44
|
+
: field
|
|
45
|
+
const {
|
|
46
|
+
vvIs,
|
|
47
|
+
vvName,
|
|
48
|
+
vvSlots,
|
|
49
|
+
vvChildren,
|
|
50
|
+
vvIf,
|
|
51
|
+
vvElseIf,
|
|
52
|
+
vvType,
|
|
53
|
+
vvDefaultValue,
|
|
54
|
+
vvShowValid,
|
|
55
|
+
vvContent,
|
|
56
|
+
...props
|
|
57
|
+
} = normalizedField
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
),
|
|
66
|
-
)
|
|
67
|
-
} else if (typeof vvIf === 'function') {
|
|
68
|
-
lastIf = unref(vvIf(injectedFormData))
|
|
69
|
-
} else {
|
|
70
|
-
lastIf = unref(vvIf)
|
|
71
|
-
}
|
|
72
|
-
if (!lastIf) {
|
|
73
|
-
return acc
|
|
74
|
-
}
|
|
75
|
-
} else if (
|
|
76
|
-
vvElseIf !== undefined &&
|
|
77
|
-
lastIf !== undefined
|
|
78
|
-
) {
|
|
79
|
-
if (lastIf) {
|
|
80
|
-
return acc
|
|
81
|
-
}
|
|
82
|
-
if (typeof vvElseIf === 'string') {
|
|
83
|
-
lastIf = Boolean(
|
|
84
|
-
get(
|
|
85
|
-
Object(injectedFormData.formData.value),
|
|
86
|
-
vvElseIf,
|
|
87
|
-
),
|
|
88
|
-
)
|
|
89
|
-
} else if (typeof vvElseIf === 'function') {
|
|
90
|
-
lastIf = unref(vvElseIf(injectedFormData))
|
|
91
|
-
} else {
|
|
92
|
-
lastIf = unref(vvElseIf)
|
|
93
|
-
}
|
|
94
|
-
if (!lastIf) {
|
|
95
|
-
return acc
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
lastIf = undefined
|
|
99
|
-
}
|
|
100
|
-
// children
|
|
101
|
-
const hChildren = vvChildren
|
|
102
|
-
? h(VvFormTemplate, {
|
|
103
|
-
schema: vvChildren,
|
|
104
|
-
})
|
|
105
|
-
: undefined
|
|
106
|
-
// render
|
|
107
|
-
if (vvName) {
|
|
108
|
-
acc.push(
|
|
109
|
-
h(
|
|
110
|
-
VvFormField,
|
|
111
|
-
{
|
|
112
|
-
name: vvName,
|
|
113
|
-
is: vvIs,
|
|
114
|
-
type: vvType,
|
|
115
|
-
defaultValue: vvDefaultValue,
|
|
116
|
-
showValid: vvShowValid,
|
|
117
|
-
props,
|
|
118
|
-
},
|
|
119
|
-
vvSlots ?? hChildren ?? vvContent,
|
|
59
|
+
// conditions
|
|
60
|
+
if (vvIf !== undefined) {
|
|
61
|
+
if (typeof vvIf === 'string') {
|
|
62
|
+
lastIf = Boolean(
|
|
63
|
+
get(
|
|
64
|
+
Object(injectedFormData.formData.value),
|
|
65
|
+
vvIf,
|
|
120
66
|
),
|
|
121
67
|
)
|
|
68
|
+
} else if (typeof vvIf === 'function') {
|
|
69
|
+
lastIf = unref(vvIf(injectedFormData))
|
|
70
|
+
} else {
|
|
71
|
+
lastIf = unref(vvIf)
|
|
72
|
+
}
|
|
73
|
+
if (!lastIf) {
|
|
122
74
|
return acc
|
|
123
75
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
76
|
+
} else if (vvElseIf !== undefined && lastIf !== undefined) {
|
|
77
|
+
if (lastIf) {
|
|
78
|
+
return acc
|
|
79
|
+
}
|
|
80
|
+
if (typeof vvElseIf === 'string') {
|
|
81
|
+
lastIf = Boolean(
|
|
82
|
+
get(
|
|
83
|
+
Object(injectedFormData.formData.value),
|
|
84
|
+
vvElseIf,
|
|
130
85
|
),
|
|
131
86
|
)
|
|
132
|
-
|
|
87
|
+
} else if (typeof vvElseIf === 'function') {
|
|
88
|
+
lastIf = unref(vvElseIf(injectedFormData))
|
|
89
|
+
} else {
|
|
90
|
+
lastIf = unref(vvElseIf)
|
|
133
91
|
}
|
|
134
|
-
if (
|
|
135
|
-
acc.push(hChildren)
|
|
92
|
+
if (!lastIf) {
|
|
136
93
|
return acc
|
|
137
94
|
}
|
|
95
|
+
} else {
|
|
96
|
+
lastIf = undefined
|
|
97
|
+
}
|
|
98
|
+
// children
|
|
99
|
+
const hChildren = vvChildren
|
|
100
|
+
? h(VvFormTemplate, {
|
|
101
|
+
schema: vvChildren,
|
|
102
|
+
})
|
|
103
|
+
: undefined
|
|
104
|
+
// render
|
|
105
|
+
if (vvName) {
|
|
106
|
+
acc.push(
|
|
107
|
+
h(
|
|
108
|
+
VvFormField,
|
|
109
|
+
{
|
|
110
|
+
name: vvName,
|
|
111
|
+
is: vvIs,
|
|
112
|
+
type: vvType,
|
|
113
|
+
defaultValue: vvDefaultValue,
|
|
114
|
+
showValid: vvShowValid,
|
|
115
|
+
props,
|
|
116
|
+
},
|
|
117
|
+
vvSlots ?? hChildren ?? vvContent,
|
|
118
|
+
),
|
|
119
|
+
)
|
|
120
|
+
return acc
|
|
121
|
+
}
|
|
122
|
+
if (vvIs) {
|
|
123
|
+
acc.push(
|
|
124
|
+
h(
|
|
125
|
+
vvIs as Component,
|
|
126
|
+
props,
|
|
127
|
+
vvSlots ?? hChildren ?? vvContent,
|
|
128
|
+
),
|
|
129
|
+
)
|
|
130
|
+
return acc
|
|
131
|
+
}
|
|
132
|
+
if (vvChildren) {
|
|
133
|
+
acc.push(hChildren)
|
|
138
134
|
return acc
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
135
|
+
}
|
|
136
|
+
return acc
|
|
137
|
+
}, [])
|
|
138
|
+
toReturn.push(
|
|
139
|
+
templateSlots?.default?.({
|
|
140
|
+
formData: injectedFormData?.formData.value,
|
|
141
|
+
submit: injectedFormData?.submit,
|
|
142
|
+
validate: injectedFormData?.validate,
|
|
143
|
+
errors: injectedFormData?.errors.value,
|
|
144
|
+
status: injectedFormData?.status.value,
|
|
145
|
+
invalid: injectedFormData?.invalid.value,
|
|
146
|
+
}),
|
|
150
147
|
)
|
|
148
|
+
return toReturn
|
|
151
149
|
}
|
|
152
150
|
},
|
|
153
151
|
})
|
package/src/index.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|