@effect-app/vue-components 1.5.0 → 1.6.0

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.
Files changed (34) hide show
  1. package/dist/types/components/OmegaForm/InputProps.d.ts +18 -18
  2. package/dist/types/components/OmegaForm/OmegaFormInput.vue.d.ts +2 -2
  3. package/dist/types/components/OmegaForm/OmegaInput.vue.d.ts +1 -4
  4. package/dist/types/components/OmegaForm/OmegaInputVuetify.vue.d.ts +1 -4
  5. package/dist/types/components/OmegaForm/OmegaInternalInput.vue.d.ts +1 -4
  6. package/dist/vue-components.es10.js +12 -13
  7. package/dist/vue-components.es17.js +1 -1
  8. package/dist/vue-components.es18.js +1 -1
  9. package/dist/vue-components.es23.js +50 -50
  10. package/dist/vue-components.es31.js +1 -1
  11. package/dist/vue-components.es34.js +10 -22
  12. package/dist/vue-components.es35.js +23 -5
  13. package/dist/vue-components.es36.js +5 -21
  14. package/dist/vue-components.es37.js +16 -25
  15. package/dist/vue-components.es38.js +23 -15
  16. package/dist/vue-components.es39.js +17 -7
  17. package/dist/vue-components.es40.js +12 -5
  18. package/dist/vue-components.es41.js +5 -19
  19. package/dist/vue-components.es42.js +19 -9
  20. package/dist/vue-components.es43.js +9 -31
  21. package/dist/vue-components.es44.js +25 -42
  22. package/dist/vue-components.es45.js +38 -16
  23. package/dist/vue-components.es46.js +26 -11
  24. package/dist/vue-components.es47.js +1 -1
  25. package/dist/vue-components.es49.js +1 -1
  26. package/dist/vue-components.es5.js +53 -52
  27. package/dist/vue-components.es51.js +3 -3
  28. package/dist/vue-components.es52.js +1 -1
  29. package/package.json +3 -3
  30. package/src/components/OmegaForm/InputProps.ts +18 -15
  31. package/src/components/OmegaForm/OmegaFormInput.vue +2 -2
  32. package/src/components/OmegaForm/OmegaInputVuetify.vue +25 -28
  33. package/src/components/OmegaForm/OmegaInternalInput.vue +32 -21
  34. package/src/components/OmegaForm/createUseFormWithCustomInput.ts +1 -2
@@ -8,14 +8,14 @@
8
8
  :is="inputProps.type === 'boolean' ? 'v-checkbox' : 'v-switch'"
9
9
  v-if="inputProps.type === 'boolean' || inputProps.type === 'switch'"
10
10
  :id="inputProps.id"
11
- :name="inputProps.name"
11
+ :name="field.name"
12
12
  :label="inputProps.label"
13
13
  :error-messages="inputProps.errorMessages"
14
14
  :error="inputProps.error"
15
15
  ripple
16
16
  v-bind="$attrs"
17
- :model-value="vuetifyValue"
18
- @change="(e: any) => inputProps.handleChange(e.target.checked)"
17
+ :model-value="field.state.value"
18
+ @change="(e: any) => field.handleChange(e.target.checked)"
19
19
  />
20
20
  <v-text-field
21
21
  v-if="inputProps.type === 'email' || inputProps.type === 'string' || inputProps.type === 'password'"
@@ -24,13 +24,13 @@
24
24
  :min-length="inputProps.minLength"
25
25
  :max-length="inputProps.maxLength"
26
26
  :type="getInputType(inputProps.type)"
27
- :name="inputProps.name"
27
+ :name="field.name"
28
28
  :label="inputProps.label"
29
29
  :error-messages="inputProps.errorMessages"
30
30
  :error="inputProps.error"
31
31
  v-bind="$attrs"
32
- :model-value="vuetifyValue"
33
- @update:model-value="inputProps.handleChange"
32
+ :model-value="field.state.value"
33
+ @update:model-value="field.handleChange"
34
34
  />
35
35
  <v-textarea
36
36
  v-if="inputProps.type === 'text'"
@@ -38,13 +38,13 @@
38
38
  :required="inputProps.required"
39
39
  :min-length="inputProps.minLength"
40
40
  :max-length="inputProps.maxLength"
41
- :name="inputProps.name"
41
+ :name="field.name"
42
42
  :label="inputProps.label"
43
43
  :error-messages="inputProps.errorMessages"
44
44
  :error="inputProps.error"
45
45
  v-bind="$attrs"
46
- :model-value="vuetifyValue"
47
- @update:model-value="inputProps.handleChange"
46
+ :model-value="field.state.value"
47
+ @update:model-value="field.handleChange"
48
48
  />
49
49
  <component
50
50
  :is="inputProps.type === 'range' ? 'v-slider' : 'v-text-field'"
@@ -54,30 +54,30 @@
54
54
  :min="inputProps.min"
55
55
  :max="inputProps.max"
56
56
  :type="inputProps.type"
57
- :name="inputProps.name"
57
+ :name="field.name"
58
58
  :label="inputProps.label"
59
59
  :error-messages="inputProps.errorMessages"
60
60
  :error="inputProps.error"
61
61
  v-bind="$attrs"
62
- :model-value="vuetifyValue"
62
+ :model-value="field.state.value"
63
63
  @update:model-value="(e: any) => {
64
64
  if (e || e === 0) {
65
- inputProps.handleChange(Number(e) as any)
65
+ field.handleChange(Number(e) as any)
66
66
  } else {
67
- inputProps.handleChange(undefined as any)
67
+ field.handleChange(undefined as any)
68
68
  }
69
69
  }"
70
70
  />
71
71
  <template v-if="inputProps.type === 'radio'">
72
72
  <v-radio-group
73
73
  :id="inputProps.id"
74
- :name="inputProps.name"
74
+ :name="field.name"
75
75
  :label="inputProps.label"
76
76
  :error-messages="inputProps.errorMessages"
77
77
  :error="inputProps.error"
78
78
  v-bind="$attrs"
79
- :model-value="vuetifyValue"
80
- @update:model-value="inputProps.handleChange"
79
+ :model-value="field.state.value"
80
+ @update:model-value="field.handleChange"
81
81
  >
82
82
  <v-radio
83
83
  v-for="option in inputProps.options"
@@ -94,15 +94,15 @@
94
94
  :required="inputProps.required"
95
95
  :multiple="inputProps.type === 'multiple'"
96
96
  :chips="inputProps.type === 'multiple'"
97
- :name="inputProps.name"
97
+ :name="field.name"
98
98
  :label="inputProps.label"
99
99
  :items="inputProps.options"
100
100
  :error-messages="inputProps.errorMessages"
101
101
  :error="inputProps.error"
102
102
  v-bind="$attrs"
103
- :model-value="vuetifyValue"
104
- @clear="inputProps.handleChange(undefined as any)"
105
- @update:model-value="inputProps.handleChange"
103
+ :model-value="field.state.value"
104
+ @clear="field.handleChange(undefined as any)"
105
+ @update:model-value="field.handleChange"
106
106
  />
107
107
 
108
108
  <v-autocomplete
@@ -112,16 +112,16 @@
112
112
  :clearable="inputProps.type === 'autocomplete'"
113
113
  :multiple="inputProps.type === 'autocompletemultiple'"
114
114
  :required="inputProps.required"
115
- :name="inputProps.name"
115
+ :name="field.name"
116
116
  :label="inputProps.label"
117
117
  :items="inputProps.options"
118
118
  :error-messages="inputProps.errorMessages"
119
119
  :error="inputProps.error"
120
120
  :chips="inputProps.type === 'autocompletemultiple'"
121
121
  v-bind="$attrs"
122
- :model-value="vuetifyValue"
123
- @clear="inputProps.handleChange(undefined as any)"
124
- @update:model-value="inputProps.handleChange"
122
+ :model-value="field.state.value"
123
+ @clear="field.handleChange(undefined as any)"
124
+ @update:model-value="field.handleChange"
125
125
  />
126
126
  </div>
127
127
  </template>
@@ -135,10 +135,7 @@ import { type DeepKeys } from "@tanstack/vue-form"
135
135
  import { getInputType } from "../OmegaForm/OmegaFormStuff"
136
136
  import type { InputProps } from "./InputProps"
137
137
 
138
- defineProps<{
139
- inputProps: InputProps<From, Name>
140
- vuetifyValue: unknown
141
- }>()
138
+ defineProps<InputProps<From, Name>>()
142
139
 
143
140
  defineEmits<{
144
141
  (e: "focus", event: Event): void
@@ -1,14 +1,12 @@
1
1
  <template>
2
- <slot v-bind="inputProps">
2
+ <slot v-bind="{ ...inputProps.inputProps, field: inputProps.field }">
3
3
  <div
4
4
  :class="$attrs.class"
5
5
  @focusout="setRealDirty"
6
6
  >
7
7
  <OmegaInputVuetify
8
8
  v-if="vuetified"
9
- :input-props="inputProps"
10
- v-bind="$attrs"
11
- :vuetify-value="inputProps.field.state.value"
9
+ v-bind="{ ...inputProps, ...$attrs }"
12
10
  />
13
11
  </div>
14
12
  </slot>
@@ -69,7 +67,6 @@ const isFalsyButNotZero = (value: unknown): boolean => {
69
67
  }
70
68
 
71
69
  // we remove value and errors when the field is empty and not required
72
-
73
70
  // convert nullish value to null or undefined based on schema
74
71
  const handleChange: OmegaFieldInternalApi<From, Name>["handleChange"] = (value) => {
75
72
  if (isFalsyButNotZero(value) && props.meta?.type !== "boolean") {
@@ -149,22 +146,36 @@ onUnmounted(() => {
149
146
  removeError(id)
150
147
  })
151
148
 
149
+ const wrapField = (field: OmegaFieldInternalApi<From, Name>) => {
150
+ const handler3 = {
151
+ get(_target: any, prop: PropertyKey, _receiver: any) {
152
+ if (prop === "handleChange") {
153
+ return handleChange
154
+ }
155
+ return Reflect.get(...arguments as unknown as [any, any, any])
156
+ }
157
+ }
158
+
159
+ const proxy3 = new Proxy(field, handler3)
160
+ return proxy3 as typeof field
161
+ }
162
+
152
163
  const inputProps: ComputedRef<InputProps<From, Name>> = computed(() => ({
153
- id,
154
- required: props.meta?.required,
155
- minLength: props.meta?.type === "string" && props.meta?.minLength,
156
- maxLength: props.meta?.type === "string" && props.meta?.maxLength,
157
- max: props.meta?.type === "number" && props.meta?.maximum,
158
- min: props.meta?.type === "number" && props.meta?.minimum,
159
- name: props.field.name,
160
- modelValue: props.field.state.value,
161
- handleChange,
162
- errorMessages: showedErrors.value,
163
- error: !!showedErrors.value.length,
164
- field: props.field,
165
- setRealDirty,
166
- type: fieldType.value,
167
- label: `${props.label}${props.meta?.required ? " *" : ""}`,
168
- options: props.options
164
+ inputProps: {
165
+ id,
166
+ required: props.meta?.required,
167
+ minLength: props.meta?.type === "string" && props.meta?.minLength,
168
+ maxLength: props.meta?.type === "string" && props.meta?.maxLength,
169
+ max: props.meta?.type === "number" && props.meta?.maximum,
170
+ min: props.meta?.type === "number" && props.meta?.minimum,
171
+ errorMessages: showedErrors.value,
172
+ error: !!showedErrors.value.length,
173
+ setRealDirty,
174
+ type: fieldType.value,
175
+ label: `${props.label}${props.meta?.required ? " *" : ""}`,
176
+ options: props.options
177
+ },
178
+
179
+ field: wrapField(props.field)
169
180
  }))
170
181
  </script>
@@ -28,8 +28,7 @@ export const createUseFormWithCustomInput = (CustomInputComponent: Component) =>
28
28
  // If we receive inputProps from OmegaInternalInput, use our custom component
29
29
  if (inputProps && "field" in inputProps) {
30
30
  return h(CustomInputComponent, {
31
- inputProps,
32
- vuetifyValue: inputProps.field.state.value
31
+ inputProps
33
32
  })
34
33
  }
35
34
  // Otherwise, pass through the slot content