@effect-app/vue-components 0.4.6 → 0.6.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.
Files changed (48) hide show
  1. package/dist/types/components/OmegaForm/OmegaAutoGen.vue.d.ts +30 -0
  2. package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +1 -1
  3. package/dist/types/components/OmegaForm/OmegaWrapper.vue.d.ts +5 -5
  4. package/dist/types/components/OmegaForm/index.d.ts +2 -6
  5. package/dist/types/components/OmegaForm/useOmegaForm.d.ts +1 -1
  6. package/dist/vue-components.es.js +24 -27
  7. package/dist/vue-components.es10.js +6 -23
  8. package/dist/vue-components.es11.js +76 -43
  9. package/dist/vue-components.es15.js +1 -1
  10. package/dist/vue-components.es17.js +2 -5
  11. package/dist/vue-components.es18.js +5 -32
  12. package/dist/vue-components.es19.js +32 -2
  13. package/dist/vue-components.es2.js +16 -19
  14. package/dist/vue-components.es20.js +98 -2
  15. package/dist/vue-components.es21.js +11 -96
  16. package/dist/vue-components.es22.js +2 -11
  17. package/dist/vue-components.es23.js +1 -1
  18. package/dist/vue-components.es24.js +2 -115
  19. package/dist/vue-components.es25.js +117 -0
  20. package/dist/{vue-components.es26.js → vue-components.es27.js} +1 -1
  21. package/dist/vue-components.es3.js +3 -3
  22. package/dist/vue-components.es4.js +2 -2
  23. package/dist/vue-components.es5.js +78 -36
  24. package/dist/vue-components.es6.js +34 -131
  25. package/dist/vue-components.es7.js +128 -211
  26. package/dist/vue-components.es8.js +216 -6
  27. package/dist/vue-components.es9.js +4 -4
  28. package/package.json +9 -3
  29. package/src/components/OmegaForm/OmegaAutoGen.vue +110 -0
  30. package/src/components/OmegaForm/OmegaErrors.vue +3 -3
  31. package/src/components/OmegaForm/OmegaFormStuff.ts +1 -1
  32. package/src/components/OmegaForm/OmegaInternalInput.vue +9 -6
  33. package/src/components/OmegaForm/OmegaWrapper.vue +59 -12
  34. package/src/components/OmegaForm/index.ts +2 -19
  35. package/src/components/OmegaForm/useOmegaForm.ts +1 -1
  36. package/src/env.d.ts +0 -8
  37. package/src/stories/OmegaForm/ComplexForm.vue +0 -87
  38. package/src/stories/OmegaForm/EmailForm.vue +0 -48
  39. package/src/stories/OmegaForm/Meta.vue +0 -47
  40. package/src/stories/OmegaForm/OneHundredWaysToWriteAForm.vue +0 -188
  41. package/src/stories/OmegaForm/PersistencyForm.vue +0 -58
  42. package/src/stories/OmegaForm/SimpleForm.vue +0 -30
  43. package/src/stories/OmegaForm/SimpleFormVuetifyDefault.vue +0 -15
  44. package/src/stories/OmegaForm/SumExample.vue +0 -37
  45. package/src/stories/OmegaForm/form.Input.vue +0 -98
  46. package/src/stories/OmegaForm.stories.ts +0 -106
  47. package/src/stories/README.md +0 -29
  48. package/src/stories/tsconfig.json +0 -4
@@ -1,87 +0,0 @@
1
- <template>
2
- <OmegaForm :form="exampleForm">
3
- <OmegaInput label="aString" :form="exampleForm" name="aString" />
4
- <OmegaInput label="aStringMin2" :form="exampleForm" name="aStringMin2" />
5
- <OmegaInput
6
- label="aStringMin2Max4"
7
- :form="exampleForm"
8
- name="aStringMin2Max4"
9
- />
10
- <OmegaInput
11
- label="aStringMin2Max3Nullable"
12
- :form="exampleForm"
13
- name="aStringMin2Max3Nullable"
14
- />
15
- <OmegaInput label="aNumber" :form="exampleForm" name="aNumber" />
16
- <OmegaInput label="aNumberMin2" :form="exampleForm" name="aNumberMin2" />
17
- <OmegaInput
18
- label="aNumberMin2Max"
19
- :form="exampleForm"
20
- name="aNumberMin2Max"
21
- />
22
- <OmegaInput
23
- label="aNumberMin2Max4Nullable"
24
- :form="exampleForm"
25
- name="aNumberMin2Max4Nullable"
26
- />
27
- <OmegaInput
28
- label="aSelect"
29
- :form="exampleForm"
30
- name="aSelect"
31
- :options="[
32
- { title: 'a', value: 'a' },
33
- { title: 'b', value: 'b' },
34
- { title: 'c', value: 'c' },
35
- ]"
36
- />
37
- <button>Submit</button>
38
- <button type="reset" @click.prevent="exampleForm.clear()">Clear</button>
39
- <button type="button" @click="exampleForm.reset()">Reset</button>
40
- </OmegaForm>
41
- </template>
42
-
43
- <script setup lang="ts">
44
- import { S } from "effect-app"
45
- import { OmegaForm, OmegaInput, useOmegaForm } from "../../components/OmegaForm"
46
-
47
- const exampleForm = useOmegaForm(
48
- S.Struct({
49
- aString: S.String,
50
- aStringMin2: S.String.pipe(S.minLength(2)),
51
- aStringMin2Max4: S.String.pipe(S.minLength(2)).pipe(S.maxLength(4)),
52
- aStringMin2Max3Nullable: S.UndefinedOr(
53
- S.String.pipe(S.minLength(2)).pipe(S.maxLength(3)),
54
- ),
55
- aNumber: S.Number,
56
- aNumberMin2: S.Number.pipe(S.greaterThan(2)),
57
- aNumberMin2Max: S.Number.pipe(S.greaterThan(2)).pipe(S.lessThan(4)),
58
- aNumberMin2Max4Nullable: S.NullOr(S.Number.pipe(S.between(2, 4))),
59
- aSelect: S.Union(S.Literal("a"), S.Literal("b"), S.Literal("c")),
60
- }),
61
- {
62
- onSubmit: ({
63
- value,
64
- }: {
65
- value: {
66
- aString: string
67
- aStringMin2: string
68
- aStringMin2Max4: string
69
- aStringMin2Max3Nullable?: string
70
- aNumber: number
71
- aNumberMin2: number
72
- aNumberMin2Max: number
73
- aNumberMin2Max4Nullable: number | null
74
- aSelect: "a" | "b" | "c"
75
- }
76
- }) => {
77
- console.log(value)
78
- },
79
- },
80
- {
81
- persistency: {
82
- policies: ["local"],
83
- overrideDefaultValues: true,
84
- },
85
- },
86
- )
87
- </script>
@@ -1,48 +0,0 @@
1
- <template>
2
- <OmegaForm
3
- :schema="schema"
4
- :on-submit="onSubmit"
5
- :default-values="defaultValues"
6
- >
7
- <template #internalForm="{ form }">
8
- <OmegaInput label="email" name="email" :form="form" />
9
- <OmegaInput label="confirm" name="confirm" :form="form" />
10
- <button>submit</button>
11
- <OmegaErrors />
12
- </template>
13
- </OmegaForm>
14
- </template>
15
-
16
- <script setup lang="ts">
17
- import { S } from "effect-app"
18
- import { OmegaForm, OmegaInput, OmegaErrors } from "../../components/OmegaForm"
19
-
20
- const schema = S.Struct({
21
- email: S.Email,
22
- confirm: S.Email,
23
- }).pipe(
24
- S.filter(
25
- form => {
26
- if (form.email !== form.confirm) {
27
- return false
28
- }
29
- return true
30
- },
31
- {
32
- message: () => "Email and confirmation must match",
33
- jsonSchema: {
34
- items: ["confirm"],
35
- },
36
- },
37
- ),
38
- )
39
-
40
- const defaultValues = {
41
- email: "mimmo@asd.it",
42
- confirm: "amerelli@asd.it",
43
- }
44
-
45
- const onSubmit = ({ value }: { value: { email: string; confirm: string } }) => {
46
- console.log(value)
47
- }
48
- </script>
@@ -1,47 +0,0 @@
1
- <template>
2
- <OmegaForm
3
- :schema="
4
- S.Struct({
5
- a: S.NullOr(S.String),
6
- b: S.UndefinedOr(S.Number),
7
- c: S.NullishOr(S.Number),
8
- d: S.String,
9
- e: S.Number,
10
- f: S.Number,
11
- struct: S.Struct({
12
- a: S.NullOr(S.String),
13
- b: S.UndefinedOr(S.Number),
14
- c: S.NullishOr(S.Number),
15
- d: S.String,
16
- e: S.Number,
17
- f: S.Number,
18
- }),
19
- })
20
- "
21
- >
22
- <template #internalForm="{ form }">
23
- <ul>
24
- <li v-for="key in Object.keys(form.meta)" :key="key">
25
- {{ key }}: {{ (form.meta as any)[key] }}
26
- </li>
27
- </ul>
28
- <OmegaInput label="a" :form="form" name="a" />
29
- <OmegaInput label="b" :form="form" name="b" />
30
- <OmegaInput label="c" :form="form" name="c" />
31
- <OmegaInput label="d" :form="form" name="d" />
32
- <OmegaInput label="e" :form="form" name="e" />
33
- <OmegaInput label="f" :form="form" name="f" />
34
- <OmegaInput label="struct.a" :form="form" name="struct.a" />
35
- <OmegaInput label="struct.b" :form="form" name="struct.b" />
36
- <OmegaInput label="struct.c" :form="form" name="struct.c" />
37
- <OmegaInput label="struct.d" :form="form" name="struct.d" />
38
- <OmegaInput label="struct.e" :form="form" name="struct.e" />
39
- <OmegaInput label="struct.f" :form="form" name="struct.f" />
40
- </template>
41
- </OmegaForm>
42
- </template>
43
-
44
- <script setup lang="ts">
45
- import { OmegaForm, OmegaInput } from "../../components/OmegaForm"
46
- import { S } from "effect-app"
47
- </script>
@@ -1,188 +0,0 @@
1
- <template>
2
- <div class="container">
3
- <h1>One hundred ways to write a form</h1>
4
- <p>
5
- OmegaForm is a powerful and flexible form library that wraps
6
- <a href="https://tanstack.com/form/latest" target="_blank">TanStack Form</a>
7
- and uses
8
- <a href="https://effect.website/docs/schema/introduction/" target="_blank">
9
- Effect Schema
10
- </a>
11
- as the schema definition. All of this allows you to create forms in a
12
- declarative way.
13
- We also use
14
- <a href="https://vuetifyjs.com/" target="_blank">Vuetify</a> as peer dependency
15
- for the UI components, but you can use any other UI library you want or custom inputs.
16
- Here are some examples of how to write forms using
17
- different approaches
18
- </p>
19
- <p>for our example, we will use the following dependencies</p>
20
- <pre v-highlightjs><code class="javascript">{{ `import { S } from "effect-app"
21
- import { OmegaForm, OmegaInput, useOmegaForm } from "@effect-app/vue-components"` }}</code></pre>
22
-
23
- <h2>Simplest way</h2>
24
- <p>Now, let's write a form using the following schema:</p>
25
- <pre v-highlightjs><code class="typescript">{{ `const schema = S.Struct({
26
- name: S.String,
27
- age: S.Number,
28
- })` }}</code></pre>
29
-
30
- <p>Now, let's write in the template the form using the following schema:</p>
31
- <pre
32
- v-highlightjs
33
- ><code class="vue">{{ `<OmegaForm :schema="schema" :on-submit="console.log">
34
- <template #internalForm="{ form }">
35
- <OmegaInput label="name" :form="form" name="name" />
36
- <OmegaInput label="age" :form="form" name="age" />
37
- </template>
38
- </OmegaForm>` }}</code></pre>
39
-
40
- <OmegaForm :schema="schema" :on-submit="console.log">
41
- <template #internalForm="{ form }">
42
- <OmegaInput label="name" :form="form" name="name" />
43
- <OmegaInput label="age" :form="form" name="age" />
44
- </template>
45
- </OmegaForm>
46
-
47
- <p>
48
- <code>OmegaInput</code>
49
- is a component that will render a form input based on the schema. It's
50
- alread embedded inside the
51
- <code>OmegaForm</code>
52
- component, so you don't need to import it separately or pass form as a prop:
53
- </p>
54
- <pre v-highlightjs><code class="vue">{{ `<OmegaForm :schema="schema">
55
- <template #internalForm="{ form }">
56
- <component :is="form.Input" label="name" name="name" />
57
- <component :is="form.Input" label="age" name="age" />
58
- </template>
59
- </OmegaForm>` }}</code></pre>
60
- <p>you can also register to the values via the `subscribe` prop</p>
61
- <pre
62
- v-highlightjs
63
- ><code class="vue">{{ `<OmegaForm :schema="schema" :subscribe="['values']">
64
- <template #internalForm="{ form, subscribedValues: { values } }">
65
- <component :is="form.Input" label="name" name="name" />
66
- <component :is="form.Input" label="age" name="age" />
67
- <pre>\{\{ values \}\}</pre>
68
- </template>
69
- </OmegaForm>` }}</code></pre>
70
-
71
- <OmegaForm :schema="schema" :subscribe="['values']">
72
- <template #internalForm="{ form, subscribedValues: { values } }">
73
- <component :is="form.Input" label="name" name="name" />
74
- <component :is="form.Input" label="age" name="age" />
75
- <pre>{{ values }}</pre>
76
- </template>
77
- </OmegaForm>
78
-
79
- <h2>Using the useOmegaForm hook</h2>
80
- <p>
81
- The useOmegaForm hook is a hook that returns the form instance and the
82
- values. It's a good way to create a form in a functional way.
83
- </p>
84
- <pre
85
- v-highlightjs
86
- ><code class="typescript">{{ `const form = useOmegaForm(schema)` }}</code></pre>
87
- <p>
88
- Now, you can use the form instance to create the form in the template.
89
- </p>
90
- <pre v-highlightjs><code class="vue">{{ `<OmegaForm :form="form">
91
- <form.Input" label="name" name="name" />
92
- <form.Input" label="age" name="age" />
93
- </OmegaForm>` }}</code></pre>
94
-
95
- <p>you can still register to the values via the `subscribe` prop</p>
96
- <pre
97
- v-highlightjs
98
- ><code class="vue">{{ `<OmegaForm :form="form" :subscribe="['values']">
99
- <template #externalForm="{ subscribedValues: { values } }">
100
- <form.Input" label="name" name="name" />
101
- <form.Input" label="age" name="age" />
102
- <pre>\{\{ values \}\}</pre>
103
- </template>
104
- </OmegaForm>` }}</code></pre>
105
- <p>
106
- <strong>Note:</strong> the template name is <code>externalForm</code>
107
- because the form is not inside the component, it's outside. And you don't
108
- have access to the form instance inside the template variables anymore.
109
- </p>
110
-
111
- <h3>Using custom inputs</h3>
112
- <p>
113
- You can use custom inputs by passing an OmegaInput a child component.
114
- </p>
115
- <pre v-highlightjs><code class="vue">{{ `<OmegaForm :form="form">
116
- <form.Input label="name" name="name">
117
- <template #default="{ field, label }">
118
- <label :for="name">\{\{ label \}\}</label>
119
- <input
120
- :id="name"
121
- v-model="field.state.value"
122
- :name="name"
123
- style="border: 1px solid red"
124
- @change="(e) => field.handleChange(e.target.value)"
125
- />
126
- </template>
127
- </form.Input>
128
- </OmegaForm>` }}</code></pre>
129
- <OmegaForm :form="form">
130
- <form.Input label="name" name="name">
131
- <template #default="{ field, label, name }">
132
- <label :for="name">{{ label }}</label>
133
- <input
134
- :id="name"
135
- v-model="field.state.value"
136
- :name="name"
137
- style="border: 1px solid red"
138
- @change="(e: any) => field.handleChange(e.target.value)"
139
- />
140
- </template>
141
- </form.Input>
142
- </OmegaForm>
143
- <h3>Known issues</h3>
144
- <p>
145
- You can't write something like this:
146
- </p>
147
- <pre v-highlightjs><code class="vue">{{ `<OmegaForm :schema="schema">
148
- <template #internalForm="{ form }">
149
- <form.Input label="name" name="name" />
150
- <form.Input label="age" name="age" />
151
- </template>
152
- </OmegaForm>` }}</code></pre>
153
- <p>
154
- because When Vue's template compiler encounters <code>form.Input</code>, it try to resolve or analyze the form object and its Input property earlier in the rendering pipeline. Since form.Input is provided by the parent OmegaForm through the slot, this direct usage inside the slot might create a tighter, more immediate dependency loop that the compiler/renderer detects or falls into, leading to the stack overflow.
155
- </p>
156
- </div>
157
- </template>
158
-
159
- <script setup lang="ts">
160
- import { S } from "effect-app"
161
- import { OmegaForm, OmegaInput, useOmegaForm } from "../../components/OmegaForm"
162
-
163
- const schema = S.Struct({
164
- name: S.String,
165
- age: S.Number,
166
- })
167
- const form = useOmegaForm(schema)
168
- </script>
169
-
170
- <style scoped>
171
- p,
172
- pre {
173
- margin-bottom: 1rem;
174
- }
175
- form {
176
- margin-bottom: 2rem;
177
- }
178
-
179
- .container {
180
- max-width: 1200px;
181
- margin: 0 auto;
182
- padding: 0 1rem;
183
- }
184
-
185
- h1, h2, h3 {
186
- text-wrap: balance;
187
- }
188
- </style>
@@ -1,58 +0,0 @@
1
- <template>
2
- <OmegaForm
3
- :form="addForm"
4
- :subscribe="['errors', 'values']"
5
- show-errors-on="onChange"
6
- >
7
- <template #externalForm="{ subscribedValues: { errors, values: vvv } }">
8
- <div>Errors: {{ errors }}</div>
9
- <div>Values: {{ vvv }}</div>
10
- <OmegaInput label="first" :form="addForm" name="first" />
11
- <div>+</div>
12
- <OmegaInput label="second" :form="addForm" name="second" />
13
- <br />
14
- <hr />
15
- <br />
16
- <OmegaInput label="third.fourth" :form="addForm" name="third.fourth" />
17
- <OmegaInput label="third.fifth" :form="addForm" name="third.fifth" />
18
- </template>
19
- </OmegaForm>
20
-
21
- <!-- Technically you can do this only with a subscribe but only inside OmegaForm Context -->
22
- <div>
23
- <div>Sum: {{ sum }}</div>
24
- </div>
25
- </template>
26
-
27
- <script setup lang="ts">
28
- import { S } from "effect-app"
29
- import { OmegaForm, OmegaInput, useOmegaForm } from "../../components/OmegaForm"
30
- import { ref, watch } from "vue"
31
-
32
- const sum = ref(0)
33
- const AddSchema = S.Struct({
34
- first: S.Number,
35
- second: S.Number.pipe(S.greaterThan(3)),
36
- third: S.Struct({
37
- fourth: S.Number,
38
- fifth: S.Number,
39
- }),
40
- })
41
-
42
- const addForm = useOmegaForm(
43
- AddSchema,
44
- {},
45
- {
46
- persistency: {
47
- policies: ["session", "querystring"],
48
- keys: ["first", "third.fourth"],
49
- },
50
- },
51
- )
52
-
53
- const values = addForm.useStore(({ values }) => values)
54
-
55
- watch(values, ({ first, second }) => {
56
- sum.value = first + second
57
- })
58
- </script>
@@ -1,30 +0,0 @@
1
- <template>
2
- <OmegaForm :schema="schema" :on-submit="onSubmit" :subscribe="['values']">
3
- <template #internalForm="{ form, subscribedValues: { values } }">
4
- <div>values: {{ values }}</div>
5
- <OmegaInput label="asder2" name="asder2" :form="form">
6
- <template #default="inputProps">
7
- <label :for="inputProps.name">{{ inputProps.label }}</label>
8
- <input
9
- :id="inputProps.name"
10
- v-model="inputProps.field.state.value"
11
- :name="inputProps.name"
12
- style="border: 1px solid red"
13
- @change="(e: any) => inputProps.field.handleChange(e.target.value)"
14
- />
15
- </template>
16
- </OmegaInput>
17
- <button>submit</button>
18
- </template>
19
- </OmegaForm>
20
- </template>
21
-
22
- <script setup lang="ts">
23
- import { S } from "effect-app"
24
- import { OmegaForm, OmegaInput } from "../../components/OmegaForm"
25
-
26
- const schema = S.Struct({ asder2: S.String })
27
- const onSubmit = ({ value }: { value: { asder2: string } }) => {
28
- console.log(value)
29
- }
30
- </script>
@@ -1,15 +0,0 @@
1
- <template>
2
- <OmegaForm :schema="schema" :subscribe="['values']">
3
- <template #internalForm="{ form, subscribedValues: { values } }">
4
- <OmegaInput label="aString" :form="form" name="aString" />
5
- <pre>{{ values }}</pre>
6
- </template>
7
- </OmegaForm>
8
- </template>
9
-
10
- <script setup lang="ts">
11
- import { S } from "effect-app"
12
- import { OmegaForm, OmegaInput } from "../../components/OmegaForm"
13
-
14
- const schema = S.Struct({ aString: S.UndefinedOr(S.String) })
15
- </script>
@@ -1,37 +0,0 @@
1
- <template>
2
- <OmegaForm :form="addForm">
3
- <OmegaInput label="first" :form="addForm" name="first" />
4
- <div>+</div>
5
- <OmegaInput label="second" :form="addForm" name="second" />
6
- </OmegaForm>
7
-
8
- <!-- Technically you can do this only with a subscribe but only inside OmegaForm Context -->
9
- <div>
10
- <div>Sum: {{ sum }}</div>
11
- </div>
12
- </template>
13
-
14
- <script setup lang="ts">
15
- import { S } from "effect-app"
16
- import { OmegaForm, OmegaInput, useOmegaForm } from "../../components/OmegaForm"
17
- import { ref, watch } from "vue"
18
-
19
- const sum = ref(0)
20
- const AddSchema = S.Struct({
21
- first: S.Number,
22
- second: S.Number,
23
- })
24
-
25
- const addForm = useOmegaForm(AddSchema, {
26
- defaultValues: {
27
- first: 0,
28
- second: 0,
29
- },
30
- })
31
-
32
- const values = addForm.useStore(({ values }) => values)
33
-
34
- watch(values, ({ first, second }) => {
35
- sum.value = first + second
36
- })
37
- </script>
@@ -1,98 +0,0 @@
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 #default="{ field }">
9
- <div>
10
- <input v-model="field.state.value" />
11
- </div>
12
- </template>
13
- </component>
14
- </template>
15
- </OmegaForm>
16
- <OmegaForm :form="exampleForm">
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>
24
- <exampleForm.Input label="aStringMin2" name="aStringMin2" />
25
- <exampleForm.Input label="aStringMin2Max4" name="aStringMin2Max4" />
26
- <exampleForm.Input
27
- label="aStringMin2Max3Nullable"
28
- name="aStringMin2Max3Nullable"
29
- />
30
- <exampleForm.Input label="aNumber" name="aNumber" />
31
- <exampleForm.Input label="aNumberMin2" name="aNumberMin2" />
32
- <exampleForm.Input label="aNumberMin2Max" name="aNumberMin2Max" />
33
- <exampleForm.Input
34
- label="aNumberMin2Max4Nullable"
35
- name="aNumberMin2Max4Nullable"
36
- />
37
- <exampleForm.Input
38
- label="aSelect"
39
- name="aSelect"
40
- :options="[
41
- { title: 'a', value: 'a' },
42
- { title: 'b', value: 'b' },
43
- { title: 'c', value: 'c' },
44
- ]"
45
- />
46
- <button>Submit</button>
47
- <button type="reset" @click.prevent="exampleForm.clear()">Clear</button>
48
- <button type="button" @click="exampleForm.reset()">Reset</button>
49
- </OmegaForm>
50
- </template>
51
-
52
- <script setup lang="ts">
53
- import { S } from "effect-app"
54
- import { OmegaForm, useOmegaForm } from "../../components/OmegaForm"
55
-
56
- const schema = S.Struct({
57
- aString: S.String,
58
- aStringMin2: S.String.pipe(S.minLength(2)),
59
- aStringMin2Max4: S.String.pipe(S.minLength(2)).pipe(S.maxLength(4)),
60
- aStringMin2Max3Nullable: S.UndefinedOr(
61
- S.String.pipe(S.minLength(2)).pipe(S.maxLength(3)),
62
- ),
63
- aNumber: S.Number,
64
- aNumberMin2: S.Number.pipe(S.greaterThan(2)),
65
- aNumberMin2Max: S.Number.pipe(S.greaterThan(2)).pipe(S.lessThan(4)),
66
- aNumberMin2Max4Nullable: S.NullOr(S.Number.pipe(S.between(2, 4))),
67
- aSelect: S.Union(S.Literal("a"), S.Literal("b"), S.Literal("c")),
68
- })
69
-
70
- const exampleForm = useOmegaForm(
71
- schema,
72
- {
73
- onSubmit: ({
74
- value,
75
- }: {
76
- value: {
77
- aString: string
78
- aStringMin2: string
79
- aStringMin2Max4: string
80
- aStringMin2Max3Nullable?: string
81
- aNumber: number
82
- aNumberMin2: number
83
- aNumberMin2Max: number
84
- aNumberMin2Max4Nullable: number | null
85
- aSelect: "a" | "b" | "c"
86
- }
87
- }) => {
88
- console.log(value)
89
- },
90
- },
91
- {
92
- persistency: {
93
- policies: ["local"],
94
- overrideDefaultValues: true,
95
- },
96
- },
97
- )
98
- </script>