@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.
@@ -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
+ }