@volverjs/form-vue 0.0.14-beta.3 → 0.0.14

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.
@@ -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.3",
22
+ "version": "0.0.14",
23
23
  "engines": {
24
24
  "node": ">= 16.x"
25
25
  },
26
- "packageManager": "pnpm@8.6.12",
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": "^0.0.9",
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.37.1",
45
+ "@playwright/experimental-ct-vue": "1.38.0",
46
46
  "@testing-library/vue": "^7.0.0",
47
- "@typescript-eslint/eslint-plugin": "^6.5.0",
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.48.0",
55
+ "eslint": "^8.49.0",
56
56
  "eslint-config-prettier": "^9.0.0",
57
57
  "eslint-plugin-prettier": "^5.0.0",
58
- "happy-dom": "^10.11.2",
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.3"
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
- "test": "pnpm run test-vitest && pnpm run test-playwright",
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(VvFormTemplate, {
171
- schema: this.template ?? options?.template,
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
  },
@@ -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
- return normalizedSchema.reduce<(VNode | VNode[] | undefined)[]>(
39
- (acc, field) => {
40
- const normalizedField =
41
- typeof field === 'function'
42
- ? field(injectedFormData)
43
- : field
44
- const {
45
- vvIs,
46
- vvName,
47
- vvSlots,
48
- vvChildren,
49
- vvIf,
50
- vvElseIf,
51
- vvType,
52
- vvDefaultValue,
53
- vvShowValid,
54
- vvContent,
55
- ...props
56
- } = normalizedField
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
- // conditions
59
- if (vvIf !== undefined) {
60
- if (typeof vvIf === 'string') {
61
- lastIf = Boolean(
62
- get(
63
- Object(injectedFormData.formData.value),
64
- vvIf,
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
- if (vvIs) {
125
- acc.push(
126
- h(
127
- vvIs as Component,
128
- props,
129
- vvSlots ?? hChildren ?? vvContent,
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
- return acc
87
+ } else if (typeof vvElseIf === 'function') {
88
+ lastIf = unref(vvElseIf(injectedFormData))
89
+ } else {
90
+ lastIf = unref(vvElseIf)
133
91
  }
134
- if (vvChildren) {
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
- templateSlots?.default?.({
142
- formData: injectedFormData?.formData.value,
143
- submit: injectedFormData?.submit,
144
- validate: injectedFormData?.validate,
145
- errors: injectedFormData?.errors.value,
146
- status: injectedFormData?.status.value,
147
- invalid: injectedFormData?.invalid.value,
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
@@ -132,6 +132,7 @@ export type {
132
132
  InjectedFormWrapperData,
133
133
  InjectedFormFieldData,
134
134
  FormComposableOptions,
135
+ FormSchema,
135
136
  FormPluginOptions,
136
137
  FormComponent,
137
138
  FormWrapperComponent,
File without changes
File without changes
File without changes
File without changes