@effect-app/vue-components 0.3.2 → 0.4.1
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/OmegaFormStuff.d.ts +13 -0
- package/dist/types/components/OmegaForm/OmegaInput.vue.d.ts +2 -14
- package/dist/types/components/OmegaForm/OmegaWrapper.vue.d.ts +7 -3
- package/dist/types/components/OmegaForm/index.d.ts +2 -42
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +6 -2
- package/dist/vue-components.es11.js +43 -33
- package/dist/vue-components.es5.js +88 -61
- package/dist/vue-components.es6.js +1 -1
- package/dist/vue-components.es7.js +2 -2
- package/package.json +3 -1
- package/src/components/OmegaForm/OmegaFormStuff.ts +12 -1
- package/src/components/OmegaForm/OmegaInput.vue +2 -15
- package/src/components/OmegaForm/OmegaWrapper.vue +61 -23
- package/src/components/OmegaForm/index.ts +3 -3
- package/src/components/OmegaForm/useOmegaForm.ts +50 -4
- package/src/stories/OmegaForm/ComplexForm.vue +39 -33
- package/src/stories/OmegaForm/EmailForm.vue +1 -1
- package/src/stories/OmegaForm/Meta.vue +47 -0
- package/src/stories/OmegaForm/OneHundredWaysToWriteAForm.vue +188 -0
- package/src/stories/OmegaForm/PersistencyForm.vue +6 -6
- package/src/stories/OmegaForm/SimpleForm.vue +1 -1
- package/src/stories/OmegaForm/SimpleFormVuetifyDefault.vue +1 -1
- package/src/stories/OmegaForm/SumExample.vue +3 -5
- package/src/stories/OmegaForm/form.Input.vue +86 -0
- package/src/stories/OmegaForm.stories.ts +24 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<OmegaForm
|
|
3
|
+
:schema="S.Struct({ myString: S.String })"
|
|
4
|
+
:on-submit="console.log"
|
|
5
|
+
>
|
|
6
|
+
<template #internalForm="{ form }">
|
|
7
|
+
<component :is="form.Input" label="myString" name="myString" />
|
|
8
|
+
</template>
|
|
9
|
+
</OmegaForm>
|
|
10
|
+
<OmegaForm :form="exampleForm">
|
|
11
|
+
<exampleForm.Input label="aString" name="aString" />
|
|
12
|
+
<exampleForm.Input label="aStringMin2" name="aStringMin2" />
|
|
13
|
+
<exampleForm.Input label="aStringMin2Max4" name="aStringMin2Max4" />
|
|
14
|
+
<exampleForm.Input
|
|
15
|
+
label="aStringMin2Max3Nullable"
|
|
16
|
+
name="aStringMin2Max3Nullable"
|
|
17
|
+
/>
|
|
18
|
+
<exampleForm.Input label="aNumber" name="aNumber" />
|
|
19
|
+
<exampleForm.Input label="aNumberMin2" name="aNumberMin2" />
|
|
20
|
+
<exampleForm.Input label="aNumberMin2Max" name="aNumberMin2Max" />
|
|
21
|
+
<exampleForm.Input
|
|
22
|
+
label="aNumberMin2Max4Nullable"
|
|
23
|
+
name="aNumberMin2Max4Nullable"
|
|
24
|
+
/>
|
|
25
|
+
<exampleForm.Input
|
|
26
|
+
label="aSelect"
|
|
27
|
+
name="aSelect"
|
|
28
|
+
:options="[
|
|
29
|
+
{ title: 'a', value: 'a' },
|
|
30
|
+
{ title: 'b', value: 'b' },
|
|
31
|
+
{ title: 'c', value: 'c' },
|
|
32
|
+
]"
|
|
33
|
+
/>
|
|
34
|
+
<button>Submit</button>
|
|
35
|
+
<button type="reset" @click.prevent="exampleForm.clear()">Clear</button>
|
|
36
|
+
<button type="button" @click="exampleForm.reset()">Reset</button>
|
|
37
|
+
</OmegaForm>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script setup lang="ts">
|
|
41
|
+
import { S } from "effect-app"
|
|
42
|
+
import { OmegaForm, useOmegaForm } from "../../components/OmegaForm"
|
|
43
|
+
|
|
44
|
+
const schema = S.Struct({
|
|
45
|
+
aString: S.String,
|
|
46
|
+
aStringMin2: S.String.pipe(S.minLength(2)),
|
|
47
|
+
aStringMin2Max4: S.String.pipe(S.minLength(2)).pipe(S.maxLength(4)),
|
|
48
|
+
aStringMin2Max3Nullable: S.UndefinedOr(
|
|
49
|
+
S.String.pipe(S.minLength(2)).pipe(S.maxLength(3)),
|
|
50
|
+
),
|
|
51
|
+
aNumber: S.Number,
|
|
52
|
+
aNumberMin2: S.Number.pipe(S.greaterThan(2)),
|
|
53
|
+
aNumberMin2Max: S.Number.pipe(S.greaterThan(2)).pipe(S.lessThan(4)),
|
|
54
|
+
aNumberMin2Max4Nullable: S.NullOr(S.Number.pipe(S.between(2, 4))),
|
|
55
|
+
aSelect: S.Union(S.Literal("a"), S.Literal("b"), S.Literal("c")),
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const exampleForm = useOmegaForm(
|
|
59
|
+
schema,
|
|
60
|
+
{
|
|
61
|
+
onSubmit: ({
|
|
62
|
+
value,
|
|
63
|
+
}: {
|
|
64
|
+
value: {
|
|
65
|
+
aString: string
|
|
66
|
+
aStringMin2: string
|
|
67
|
+
aStringMin2Max4: string
|
|
68
|
+
aStringMin2Max3Nullable?: string
|
|
69
|
+
aNumber: number
|
|
70
|
+
aNumberMin2: number
|
|
71
|
+
aNumberMin2Max: number
|
|
72
|
+
aNumberMin2Max4Nullable: number | null
|
|
73
|
+
aSelect: "a" | "b" | "c"
|
|
74
|
+
}
|
|
75
|
+
}) => {
|
|
76
|
+
console.log(value)
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
persistency: {
|
|
81
|
+
policies: ["local"],
|
|
82
|
+
overrideDefaultValues: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
)
|
|
86
|
+
</script>
|
|
@@ -9,6 +9,9 @@ import ComplexForm from "./OmegaForm/ComplexForm.vue"
|
|
|
9
9
|
import SimpleFormVuetifyDefault from "./OmegaForm/SimpleFormVuetifyDefault.vue"
|
|
10
10
|
import SumExample from "./OmegaForm/SumExample.vue"
|
|
11
11
|
import PersistencyForm from "./OmegaForm/PersistencyForm.vue"
|
|
12
|
+
import MetaForm from "./OmegaForm/Meta.vue"
|
|
13
|
+
import FormInput from "./OmegaForm/form.Input.vue"
|
|
14
|
+
import OneHundredWaysToWriteAForm from "./OmegaForm/OneHundredWaysToWriteAForm.vue"
|
|
12
15
|
|
|
13
16
|
const mockIntl = {
|
|
14
17
|
locale: ref("en"),
|
|
@@ -19,7 +22,6 @@ const mockIntl = {
|
|
|
19
22
|
const meta: Meta<typeof OmegaForm> = {
|
|
20
23
|
title: "Components/OmegaForm",
|
|
21
24
|
component: OmegaForm,
|
|
22
|
-
tags: ["autodocs"],
|
|
23
25
|
argTypes: {
|
|
24
26
|
schema: { control: "object" },
|
|
25
27
|
onSubmit: { action: "submitted" },
|
|
@@ -40,6 +42,13 @@ const meta: Meta<typeof OmegaForm> = {
|
|
|
40
42
|
export default meta
|
|
41
43
|
type Story = StoryObj<typeof meta>
|
|
42
44
|
|
|
45
|
+
export const AnHundredWayToWriteAFormStory: Story = {
|
|
46
|
+
render: () => ({
|
|
47
|
+
components: { OneHundredWaysToWriteAForm },
|
|
48
|
+
template: "<OneHundredWaysToWriteAForm />",
|
|
49
|
+
}),
|
|
50
|
+
}
|
|
51
|
+
|
|
43
52
|
export const SimpleFormStory: Story = {
|
|
44
53
|
render: () => ({
|
|
45
54
|
components: { SimpleForm },
|
|
@@ -81,3 +90,17 @@ export const PersistencyFormStory: Story = {
|
|
|
81
90
|
template: "<PersistencyForm />",
|
|
82
91
|
}),
|
|
83
92
|
}
|
|
93
|
+
|
|
94
|
+
export const MetaStory: Story = {
|
|
95
|
+
render: () => ({
|
|
96
|
+
components: { MetaForm },
|
|
97
|
+
template: "<MetaForm />",
|
|
98
|
+
}),
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const FormInputStory: Story = {
|
|
102
|
+
render: () => ({
|
|
103
|
+
components: { FormInput },
|
|
104
|
+
template: "<FormInput />",
|
|
105
|
+
}),
|
|
106
|
+
}
|