@volverjs/form-vue 1.0.0-beta.2 → 1.0.0-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.es.js +163 -162
- package/dist/index.umd.js +1 -1
- package/dist/src/VvForm.d.ts +34 -50
- package/dist/src/VvFormTemplate.d.ts +7 -46
- package/dist/src/VvFormWrapper.d.ts +17 -47
- package/dist/src/index.d.ts +174 -429
- package/dist/src/utils.d.ts +1 -1
- package/package.json +10 -10
- package/src/VvForm.ts +2 -2
- package/src/index.ts +2 -0
- package/src/utils.ts +5 -3
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type z } from 'zod';
|
|
2
2
|
import type { FormSchema } from './types';
|
|
3
|
-
export declare const defaultObjectBySchema: <Schema extends FormSchema>(schema: Schema, original?: Partial<z.TypeOf<Schema>>) => Partial<z.TypeOf<Schema>>;
|
|
3
|
+
export declare const defaultObjectBySchema: <Schema extends FormSchema>(schema: Schema, original?: Partial<z.TypeOf<Schema>> & Record<string, unknown>) => Partial<z.TypeOf<Schema>>;
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/volverjs/form-vue/issues"
|
|
21
21
|
},
|
|
22
|
-
"version": "1.0.0-beta.
|
|
22
|
+
"version": "1.0.0-beta.4",
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">= 16.x"
|
|
25
25
|
},
|
|
@@ -35,32 +35,32 @@
|
|
|
35
35
|
"*.d.ts"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@volverjs/ui-vue": "
|
|
38
|
+
"@volverjs/ui-vue": "^0.0.9",
|
|
39
39
|
"@vueuse/core": "^10.5.0",
|
|
40
40
|
"ts-dot-prop": "^2.1.3",
|
|
41
|
-
"vue": "^3.3.
|
|
41
|
+
"vue": "^3.3.7",
|
|
42
42
|
"zod": "^3.22.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@playwright/experimental-ct-vue": "1.39.0",
|
|
46
|
-
"@testing-library/vue": "^
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
46
|
+
"@testing-library/vue": "^8.0.0",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
|
48
48
|
"@vitejs/plugin-vue": "^4.4.0",
|
|
49
49
|
"@volverjs/style": "^0.1.11",
|
|
50
|
-
"@vue/compiler-sfc": "^3.3.
|
|
50
|
+
"@vue/compiler-sfc": "^3.3.7",
|
|
51
51
|
"@vue/eslint-config-typescript": "^12.0.0",
|
|
52
|
-
"@vue/runtime-core": "^3.3.
|
|
52
|
+
"@vue/runtime-core": "^3.3.7",
|
|
53
53
|
"@vue/test-utils": "^2.4.1",
|
|
54
54
|
"copy": "^0.3.2",
|
|
55
55
|
"eslint": "^8.52.0",
|
|
56
56
|
"eslint-config-prettier": "^9.0.0",
|
|
57
57
|
"eslint-plugin-prettier": "^5.0.1",
|
|
58
|
-
"eslint-plugin-vue": "^9.
|
|
59
|
-
"happy-dom": "^12.
|
|
58
|
+
"eslint-plugin-vue": "^9.18.1",
|
|
59
|
+
"happy-dom": "^12.10.3",
|
|
60
60
|
"prettier": "^3.0.3",
|
|
61
61
|
"typescript": "^5.2.2",
|
|
62
62
|
"vite": "^4.5.0",
|
|
63
|
-
"vite-plugin-dts": "^3.6.
|
|
63
|
+
"vite-plugin-dts": "^3.6.3",
|
|
64
64
|
"vite-plugin-eslint": "^1.8.1",
|
|
65
65
|
"vite-plugin-externalize-deps": "^0.7.0",
|
|
66
66
|
"vitest": "^0.34.6"
|
package/src/VvForm.ts
CHANGED
|
@@ -39,6 +39,7 @@ export const defineForm = <Schema extends FormSchema>(
|
|
|
39
39
|
) => {
|
|
40
40
|
const errors = ref<z.inferFormattedError<Schema> | undefined>()
|
|
41
41
|
const status = ref<FormStatus | undefined>()
|
|
42
|
+
const invalid = computed(() => status.value === FormStatus.invalid)
|
|
42
43
|
const formData = ref<Partial<z.infer<Schema> | undefined>>()
|
|
43
44
|
|
|
44
45
|
const validate = async (value = formData.value) => {
|
|
@@ -167,8 +168,6 @@ export const defineForm = <Schema extends FormSchema>(
|
|
|
167
168
|
}
|
|
168
169
|
})
|
|
169
170
|
|
|
170
|
-
const invalid = computed(() => status.value === FormStatus.invalid)
|
|
171
|
-
|
|
172
171
|
provide(provideKey, {
|
|
173
172
|
formData,
|
|
174
173
|
submit,
|
|
@@ -229,6 +228,7 @@ export const defineForm = <Schema extends FormSchema>(
|
|
|
229
228
|
return {
|
|
230
229
|
errors,
|
|
231
230
|
status,
|
|
231
|
+
invalid,
|
|
232
232
|
formData,
|
|
233
233
|
validate,
|
|
234
234
|
submit,
|
package/src/index.ts
CHANGED
|
@@ -52,6 +52,7 @@ const _formFactory = <Schema extends FormSchema>(
|
|
|
52
52
|
VvForm,
|
|
53
53
|
errors,
|
|
54
54
|
status,
|
|
55
|
+
invalid,
|
|
55
56
|
formData,
|
|
56
57
|
validate,
|
|
57
58
|
submit,
|
|
@@ -69,6 +70,7 @@ const _formFactory = <Schema extends FormSchema>(
|
|
|
69
70
|
formFieldInjectionKey,
|
|
70
71
|
errors,
|
|
71
72
|
status,
|
|
73
|
+
invalid,
|
|
72
74
|
formData,
|
|
73
75
|
validate,
|
|
74
76
|
submit,
|
package/src/utils.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type { FormSchema } from './types'
|
|
|
14
14
|
|
|
15
15
|
export const defaultObjectBySchema = <Schema extends FormSchema>(
|
|
16
16
|
schema: Schema,
|
|
17
|
-
original: Partial<z.infer<Schema>> = {},
|
|
17
|
+
original: Partial<z.infer<Schema>> & Record<string, unknown> = {},
|
|
18
18
|
): Partial<z.infer<Schema>> => {
|
|
19
19
|
const getInnerType = <Type extends ZodTypeAny>(
|
|
20
20
|
schema:
|
|
@@ -74,9 +74,11 @@ export const defaultObjectBySchema = <Schema extends FormSchema>(
|
|
|
74
74
|
originalValue.map((element: unknown) =>
|
|
75
75
|
defaultObjectBySchema(
|
|
76
76
|
arrayType,
|
|
77
|
-
element && typeof element === 'object'
|
|
77
|
+
(element && typeof element === 'object'
|
|
78
78
|
? element
|
|
79
|
-
: undefined
|
|
79
|
+
: undefined) as Partial<
|
|
80
|
+
typeof arrayType
|
|
81
|
+
>,
|
|
80
82
|
),
|
|
81
83
|
) ?? defaultValue,
|
|
82
84
|
]
|