@effect-app/vue-components 0.4.2 → 0.4.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/types/components/OmegaForm/OmegaFormInput.vue.d.ts +26 -0
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +6 -4
- package/dist/vue-components.es.js +11 -11
- package/dist/vue-components.es10.js +3 -3
- package/dist/vue-components.es11.js +14 -14
- package/dist/vue-components.es13.js +7 -2
- package/dist/vue-components.es14.js +2 -88
- package/dist/vue-components.es15.js +88 -5
- package/dist/vue-components.es17.js +5 -96
- package/dist/vue-components.es18.js +32 -11
- package/dist/vue-components.es19.js +2 -2
- package/dist/vue-components.es2.js +11 -11
- package/dist/vue-components.es20.js +2 -115
- package/dist/vue-components.es21.js +98 -0
- package/dist/vue-components.es22.js +11 -4
- package/dist/vue-components.es23.js +4 -0
- package/dist/vue-components.es24.js +117 -0
- package/dist/vue-components.es26.js +6 -0
- package/dist/vue-components.es4.js +46 -36
- package/dist/vue-components.es5.js +34 -148
- package/dist/vue-components.es6.js +128 -211
- package/dist/vue-components.es7.js +216 -5
- package/dist/vue-components.es8.js +6 -46
- package/dist/vue-components.es9.js +3 -2
- package/package.json +3 -3
- package/src/components/OmegaForm/OmegaFormInput.vue +45 -0
- package/src/components/OmegaForm/useOmegaForm.ts +12 -35
- package/src/stories/OmegaForm/form.Input.vue +14 -2
- package/dist/vue-components.es12.js +0 -9
- package/dist/vue-components.es16.js +0 -4
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<OmegaInput
|
|
3
|
+
v-bind="$props"
|
|
4
|
+
:form="form"
|
|
5
|
+
:name="name"
|
|
6
|
+
:label="label"
|
|
7
|
+
:validators="validators"
|
|
8
|
+
:options="options"
|
|
9
|
+
:type="type"
|
|
10
|
+
>
|
|
11
|
+
<template #default="slotProps">
|
|
12
|
+
<slot v-bind="slotProps"></slot>
|
|
13
|
+
</template>
|
|
14
|
+
</OmegaInput>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts" generic="From, To extends Record<PropertyKey, any>">
|
|
18
|
+
import { inject } from "vue"
|
|
19
|
+
import type {
|
|
20
|
+
FieldValidators,
|
|
21
|
+
NestedKeyOf,
|
|
22
|
+
TypeOverride,
|
|
23
|
+
} from "./OmegaFormStuff"
|
|
24
|
+
import type { InputProps } from "./InputProps"
|
|
25
|
+
import OmegaInput from "./OmegaInput.vue"
|
|
26
|
+
import { OmegaFormKey } from "./useOmegaForm" // Import the injection key
|
|
27
|
+
|
|
28
|
+
const form = inject(OmegaFormKey)
|
|
29
|
+
if (!form) {
|
|
30
|
+
throw new Error("OmegaFormInput must be used within an OmegaForm context")
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
defineProps<{
|
|
34
|
+
name: NestedKeyOf<To>
|
|
35
|
+
label: string
|
|
36
|
+
validators?: FieldValidators<From>
|
|
37
|
+
options?: { title: string; value: string }[]
|
|
38
|
+
type?: TypeOverride
|
|
39
|
+
}>()
|
|
40
|
+
|
|
41
|
+
defineSlots<{
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
default: (props: InputProps<To>) => any
|
|
44
|
+
}>()
|
|
45
|
+
</script>
|
|
@@ -13,20 +13,17 @@ import {
|
|
|
13
13
|
type FormProps,
|
|
14
14
|
type MetaRecord,
|
|
15
15
|
type OmegaFormApi,
|
|
16
|
-
type OmegaInputProps,
|
|
17
16
|
} from "./OmegaFormStuff"
|
|
18
17
|
import {
|
|
19
18
|
computed,
|
|
20
19
|
onBeforeUnmount,
|
|
21
20
|
onMounted,
|
|
22
21
|
onUnmounted,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
type DefineComponent,
|
|
26
|
-
type Component,
|
|
22
|
+
provide,
|
|
23
|
+
type InjectionKey,
|
|
27
24
|
} from "vue"
|
|
28
25
|
import { isObject } from "effect/Predicate"
|
|
29
|
-
import
|
|
26
|
+
import OmegaFormInput from "./OmegaFormInput.vue"
|
|
30
27
|
|
|
31
28
|
type keysRule<T> =
|
|
32
29
|
| {
|
|
@@ -55,8 +52,12 @@ interface OF<To, From> extends OmegaFormApi<To, From> {
|
|
|
55
52
|
filterItems?: FilterItems
|
|
56
53
|
clear: () => void
|
|
57
54
|
}
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
|
|
56
|
+
export const OmegaFormKey = Symbol("OmegaForm") as InjectionKey<OF<any, any>>
|
|
57
|
+
|
|
58
|
+
export interface OmegaFormReturn<To extends Record<PropertyKey, any>, From>
|
|
59
|
+
extends OF<To, From> {
|
|
60
|
+
Input: typeof OmegaFormInput<From, To>
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
export const useOmegaForm = <
|
|
@@ -285,33 +286,9 @@ export const useOmegaForm = <
|
|
|
285
286
|
clear,
|
|
286
287
|
})
|
|
287
288
|
|
|
288
|
-
|
|
289
|
-
Input: defineComponent({
|
|
290
|
-
name: "FormInput",
|
|
291
|
-
inheritAttrs: true,
|
|
292
|
-
setup(_, { attrs, slots }) {
|
|
293
|
-
const name = attrs.name as NestedKeyOf<To>
|
|
294
|
-
const label = attrs.label as string
|
|
295
|
-
if (!name || !label) {
|
|
296
|
-
throw new Error("OmegaForm.Input requires name and label props")
|
|
297
|
-
}
|
|
289
|
+
provide(OmegaFormKey, formWithExtras)
|
|
298
290
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
OmegaInput as Component,
|
|
302
|
-
{
|
|
303
|
-
...attrs,
|
|
304
|
-
name,
|
|
305
|
-
label,
|
|
306
|
-
form: formWithExtras,
|
|
307
|
-
},
|
|
308
|
-
slots,
|
|
309
|
-
)
|
|
310
|
-
},
|
|
311
|
-
}) as any as DefineComponent<
|
|
312
|
-
Omit<OmegaInputProps<From, To>, "form">,
|
|
313
|
-
{},
|
|
314
|
-
{}
|
|
315
|
-
>,
|
|
291
|
+
return Object.assign(formWithExtras, {
|
|
292
|
+
Input: OmegaFormInput,
|
|
316
293
|
})
|
|
317
294
|
}
|
|
@@ -4,11 +4,23 @@
|
|
|
4
4
|
:on-submit="console.log"
|
|
5
5
|
>
|
|
6
6
|
<template #internalForm="{ form }">
|
|
7
|
-
<component :is="form.Input" label="myString" name="myString"
|
|
7
|
+
<component :is="form.Input" label="myString" name="myString">
|
|
8
|
+
<template #default="{ field }">
|
|
9
|
+
<div>
|
|
10
|
+
<input v-model="field.state.value" />
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
</component>
|
|
8
14
|
</template>
|
|
9
15
|
</OmegaForm>
|
|
10
16
|
<OmegaForm :form="exampleForm">
|
|
11
|
-
<exampleForm.Input label="aString" name="aString"
|
|
17
|
+
<exampleForm.Input label="aString" name="aString">
|
|
18
|
+
<template #default="{ field }">
|
|
19
|
+
<div>
|
|
20
|
+
<input v-model="field.state.value" />
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
</exampleForm.Input>
|
|
12
24
|
<exampleForm.Input label="aStringMin2" name="aStringMin2" />
|
|
13
25
|
<exampleForm.Input label="aStringMin2Max4" name="aStringMin2Max4" />
|
|
14
26
|
<exampleForm.Input
|