@effect-app/vue-components 2.6.2 → 2.7.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/InputProps.d.ts +10 -4
- package/dist/types/components/OmegaForm/OmegaTaggedUnion.vue.d.ts +16 -9
- package/dist/types/components/OmegaForm/OmegaTaggedUnionInternal.vue.d.ts +2 -9
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +2 -1
- package/dist/vue-components.es10.js +231 -170
- package/dist/vue-components.es11.js +2 -2
- package/dist/vue-components.es12.js +137 -115
- package/dist/vue-components.es16.js +11 -10
- package/dist/vue-components.es17.js +10 -5
- package/dist/vue-components.es18.js +5 -55
- package/dist/vue-components.es19.js +50 -63
- package/dist/vue-components.es20.js +68 -6
- package/dist/vue-components.es21.js +4 -4
- package/dist/vue-components.es22.js +6 -3
- package/dist/vue-components.es23.js +3 -3
- package/dist/vue-components.es24.js +3 -2
- package/dist/vue-components.es25.js +1 -1
- package/dist/vue-components.es26.js +1 -1
- package/dist/vue-components.es27.js +1 -1
- package/dist/vue-components.es28.js +2 -17
- package/dist/vue-components.es29.js +16 -10
- package/dist/vue-components.es31.js +1 -1
- package/dist/vue-components.es32.js +1 -1
- package/dist/vue-components.es36.js +1 -1
- package/dist/vue-components.es40.js +4 -23
- package/dist/vue-components.es41.js +23 -5
- package/dist/vue-components.es42.js +5 -21
- package/dist/vue-components.es43.js +16 -25
- package/dist/vue-components.es44.js +23 -15
- package/dist/vue-components.es45.js +17 -7
- package/dist/vue-components.es46.js +12 -5
- package/dist/vue-components.es47.js +5 -19
- package/dist/vue-components.es48.js +19 -9
- package/dist/vue-components.es49.js +9 -31
- package/dist/vue-components.es5.js +1 -1
- package/dist/vue-components.es50.js +25 -42
- package/dist/vue-components.es51.js +38 -16
- package/dist/vue-components.es52.js +26 -11
- package/dist/vue-components.es53.js +11 -4
- package/dist/vue-components.es54.js +1 -1
- package/dist/vue-components.es56.js +1 -1
- package/dist/vue-components.es58.js +3 -3
- package/dist/vue-components.es59.js +1 -1
- package/dist/vue-components.es8.js +33 -41
- package/dist/vue-components.es9.js +7 -6
- package/package.json +3 -3
- package/src/components/OmegaForm/InputProps.ts +17 -8
- package/src/components/OmegaForm/OmegaFormStuff.ts +52 -0
- package/src/components/OmegaForm/OmegaTaggedUnion.vue +27 -39
- package/src/components/OmegaForm/OmegaTaggedUnionInternal.vue +4 -3
- package/src/components/OmegaForm/useOmegaForm.ts +139 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DeepKeys, DeepValue, FieldApi, FieldAsyncValidateOrFn, FieldValidateAsyncFn, FieldValidateFn, FieldValidateOrFn, FormAsyncValidateOrFn, FormValidateOrFn, StandardSchemaV1 } from "@tanstack/vue-form";
|
|
2
|
+
import { type IsUnion } from "effect-app/utils";
|
|
2
3
|
export type OmegaFieldInternalApi<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = FieldApi<From, TName, DeepValue<From, TName>, FieldValidateOrFn<From, TName, DeepValue<From, TName>> | undefined, StandardSchemaV1<DeepValue<From, TName>, unknown> | FieldValidateFn<From, TName>, StandardSchemaV1<DeepValue<From, TName>, unknown> | FieldValidateAsyncFn<From, TName>, FieldValidateOrFn<From, TName, DeepValue<From, TName>>, FieldAsyncValidateOrFn<From, TName, DeepValue<From, TName>>, FieldValidateOrFn<From, TName, DeepValue<From, TName>> | undefined, FieldAsyncValidateOrFn<From, TName, DeepValue<From, TName>> | undefined, FieldValidateOrFn<From, TName, DeepValue<From, TName>> | undefined, FieldAsyncValidateOrFn<From, TName, DeepValue<From, TName>> | undefined, FormValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, any, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, Record<string, any> | undefined>;
|
|
3
4
|
export type InputProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = {
|
|
4
5
|
inputProps: {
|
|
@@ -28,17 +29,19 @@ export type VuetifyInputProps<From extends Record<PropertyKey, any>, TName exten
|
|
|
28
29
|
}[];
|
|
29
30
|
};
|
|
30
31
|
} & Pick<InputProps<From, TName>, "field" | "state">;
|
|
31
|
-
export type ExtractTagValue<From extends Record<PropertyKey, any>, TName extends DeepKeys<From
|
|
32
|
+
export type ExtractTagValue<From extends Record<PropertyKey, any>, TName extends DeepKeys<From> | undefined> = IsUnion<TName> extends true ? From extends {
|
|
33
|
+
_tag: infer Tag;
|
|
34
|
+
} ? Tag : never : DeepValue<From, TName> extends infer U ? U extends {
|
|
32
35
|
_tag: infer Tag;
|
|
33
36
|
} ? Tag : never : never;
|
|
34
37
|
export type ExtractUnionBranch<T, Tag> = T extends {
|
|
35
38
|
_tag: Tag;
|
|
36
39
|
} ? T : never;
|
|
37
|
-
export type TaggedUnionOption<From extends Record<PropertyKey, any>, TName extends DeepKeys<From
|
|
40
|
+
export type TaggedUnionOption<From extends Record<PropertyKey, any>, TName extends DeepKeys<From> | undefined> = {
|
|
38
41
|
readonly title: string;
|
|
39
42
|
readonly value: ExtractTagValue<From, TName> | null;
|
|
40
43
|
};
|
|
41
|
-
export type TaggedUnionOptionsArray<From extends Record<PropertyKey, any>, TName extends DeepKeys<From
|
|
44
|
+
export type TaggedUnionOptionsArray<From extends Record<PropertyKey, any>, TName extends DeepKeys<From> | undefined> = readonly [
|
|
42
45
|
{
|
|
43
46
|
readonly title: string;
|
|
44
47
|
readonly value: null;
|
|
@@ -47,7 +50,10 @@ export type TaggedUnionOptionsArray<From extends Record<PropertyKey, any>, TName
|
|
|
47
50
|
readonly title: string;
|
|
48
51
|
readonly value: ExtractTagValue<From, TName>;
|
|
49
52
|
}>
|
|
50
|
-
]
|
|
53
|
+
] | ReadonlyArray<{
|
|
54
|
+
readonly title: string;
|
|
55
|
+
readonly value: ExtractTagValue<From, TName>;
|
|
56
|
+
}>;
|
|
51
57
|
export type TaggedUnionProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = {
|
|
52
58
|
name: TName;
|
|
53
59
|
options: TaggedUnionOptionsArray<From, TName>;
|
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
import { type DeepKeys
|
|
2
|
-
import { type
|
|
1
|
+
import { type DeepKeys } from "@tanstack/vue-form";
|
|
2
|
+
import { type TaggedUnionOption } from "./InputProps";
|
|
3
3
|
import { type useOmegaForm } from "./useOmegaForm";
|
|
4
|
-
declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From> | undefined = DeepKeys<From>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
5
5
|
props: __VLS_PrettifyLocal<{
|
|
6
|
-
name
|
|
6
|
+
name?: Name;
|
|
7
7
|
form: ReturnType<typeof useOmegaForm<From, To>>;
|
|
8
8
|
type?: "select" | "radio";
|
|
9
|
-
options:
|
|
9
|
+
options: TaggedUnionOption<From, Name>[];
|
|
10
10
|
label?: string;
|
|
11
11
|
}> & import("vue").PublicProps;
|
|
12
12
|
expose: (exposed: {}) => void;
|
|
13
13
|
attrs: any;
|
|
14
14
|
slots: {
|
|
15
15
|
[x: string]: ((props: {
|
|
16
|
-
field: import("./InputProps").OmegaFieldInternalApi<From,
|
|
17
|
-
state: NonNullable<
|
|
16
|
+
field: import("./InputProps").OmegaFieldInternalApi<From, any>;
|
|
17
|
+
state: NonNullable<import("@tanstack/vue-form").DeepValue<From, any>>;
|
|
18
18
|
}) => any) | undefined;
|
|
19
19
|
[x: number]: ((props: {
|
|
20
|
-
field: import("./InputProps").OmegaFieldInternalApi<From,
|
|
21
|
-
state: NonNullable<
|
|
20
|
+
field: import("./InputProps").OmegaFieldInternalApi<From, any>;
|
|
21
|
+
state: NonNullable<import("@tanstack/vue-form").DeepValue<From, any>>;
|
|
22
22
|
}) => any) | undefined;
|
|
23
|
+
} & {
|
|
24
|
+
OmegaCustomInput?: (props: {
|
|
25
|
+
field: import("@tanstack/vue-form").FieldApi<From, any, import("@tanstack/vue-form").DeepValue<From, any>, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").StandardSchemaV1<From, To>, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, Record<string, any> | undefined>;
|
|
26
|
+
state: import("@tanstack/vue-form").FieldState<From, any, import("@tanstack/vue-form").DeepValue<From, any>, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").StandardSchemaV1<From, To>, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined>;
|
|
27
|
+
}) => any;
|
|
23
28
|
} & {
|
|
24
29
|
default?: (props: {}) => any;
|
|
30
|
+
} & {
|
|
31
|
+
OmegaCommon?: (props: {}) => any;
|
|
25
32
|
};
|
|
26
33
|
emit: {};
|
|
27
34
|
}>) => import("vue").VNode & {
|
|
@@ -4,21 +4,14 @@ declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends R
|
|
|
4
4
|
props: __VLS_PrettifyLocal<{
|
|
5
5
|
state: DeepValue<From, Name>;
|
|
6
6
|
field: OmegaFieldInternalApi<From, Name>;
|
|
7
|
+
name?: DeepKeys<From>;
|
|
7
8
|
}> & import("vue").PublicProps;
|
|
8
9
|
expose: (exposed: {}) => void;
|
|
9
10
|
attrs: any;
|
|
10
11
|
slots: {
|
|
11
12
|
[x: string]: ((props: {
|
|
12
13
|
field: OmegaFieldInternalApi<From, Name>;
|
|
13
|
-
state: NonNullable<
|
|
14
|
-
}) => any) | undefined;
|
|
15
|
-
[x: number]: ((props: {
|
|
16
|
-
field: OmegaFieldInternalApi<From, Name>;
|
|
17
|
-
state: NonNullable<NonNullable<DeepValue<From, Name>>>;
|
|
18
|
-
}) => any) | undefined;
|
|
19
|
-
[x: symbol]: ((props: {
|
|
20
|
-
field: OmegaFieldInternalApi<From, Name>;
|
|
21
|
-
state: NonNullable<NonNullable<DeepValue<From, Name>>>;
|
|
14
|
+
state: NonNullable<DeepValue<From, Name>>;
|
|
22
15
|
}) => any) | undefined;
|
|
23
16
|
};
|
|
24
17
|
emit: {};
|
|
@@ -113,9 +113,10 @@ export interface OmegaFormReturn<From extends Record<PropertyKey, any>, To exten
|
|
|
113
113
|
};
|
|
114
114
|
TaggedUnion: <Name extends OmegaFormReturn<From, To, TypeProps>["_keys"]>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
115
115
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & {
|
|
116
|
-
name
|
|
116
|
+
name?: Name;
|
|
117
117
|
type?: "select" | "radio";
|
|
118
118
|
options: import("./InputProps").TaggedUnionOptionsArray<From, Name>;
|
|
119
|
+
_debugName?: [NoInfer<Name>];
|
|
119
120
|
label?: string;
|
|
120
121
|
} & {}> & import("vue").PublicProps;
|
|
121
122
|
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
|
|
@@ -1,271 +1,332 @@
|
|
|
1
|
-
import { useForm as
|
|
2
|
-
import { Data as
|
|
3
|
-
import { runtimeFiberAsPromise as
|
|
4
|
-
import { isObject as
|
|
5
|
-
import { computed as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { generateMetaFromSchema as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { trace as
|
|
14
|
-
import { context as
|
|
15
|
-
|
|
1
|
+
import { useForm as Z } from "@tanstack/vue-form";
|
|
2
|
+
import { Data as G, S as v, Effect as S, Fiber as O, Option as U, Array as _ } from "effect-app";
|
|
3
|
+
import { runtimeFiberAsPromise as Q } from "./vue-components.es17.js";
|
|
4
|
+
import { isObject as X } from "./vue-components.es18.js";
|
|
5
|
+
import { computed as T, onUnmounted as W, onMounted as Y, onBeforeUnmount as C, watch as B, ref as ee, h as H } from "vue";
|
|
6
|
+
import te from "./vue-components.es19.js";
|
|
7
|
+
import re from "./vue-components.es20.js";
|
|
8
|
+
import ne from "./vue-components.es21.js";
|
|
9
|
+
import { generateMetaFromSchema as se } from "./vue-components.es12.js";
|
|
10
|
+
import oe from "./vue-components.es6.js";
|
|
11
|
+
import ie from "./vue-components.es8.js";
|
|
12
|
+
import ae from "./vue-components.es22.js";
|
|
13
|
+
import { trace as q } from "./vue-components.es23.js";
|
|
14
|
+
import { context as L } from "./vue-components.es24.js";
|
|
15
|
+
const F = (c) => {
|
|
16
|
+
const a = c.ast;
|
|
17
|
+
if (a._tag === "Union") {
|
|
18
|
+
const o = a.types.map((u) => {
|
|
19
|
+
const l = v.make(u);
|
|
20
|
+
return F(l).ast;
|
|
21
|
+
}), m = {
|
|
22
|
+
...a,
|
|
23
|
+
types: o
|
|
24
|
+
};
|
|
25
|
+
return v.make(m);
|
|
26
|
+
}
|
|
27
|
+
if (a._tag === "Transformation") {
|
|
28
|
+
const o = v.make(a.from), m = v.make(a.to), u = F(o), l = F(m), f = {
|
|
29
|
+
...a,
|
|
30
|
+
from: u.ast,
|
|
31
|
+
to: l.ast
|
|
32
|
+
};
|
|
33
|
+
return v.make(f);
|
|
34
|
+
}
|
|
35
|
+
if (a._tag === "TypeLiteral") {
|
|
36
|
+
const o = a.propertySignatures.map((u) => {
|
|
37
|
+
const l = u.type;
|
|
38
|
+
let f = l;
|
|
39
|
+
if (l._tag === "TypeLiteral" || l._tag === "Union" || l._tag === "Transformation") {
|
|
40
|
+
const w = v.make(l);
|
|
41
|
+
f = F(w).ast;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
...u,
|
|
45
|
+
type: f,
|
|
46
|
+
isOptional: !0
|
|
47
|
+
};
|
|
48
|
+
}), m = {
|
|
49
|
+
...a,
|
|
50
|
+
propertySignatures: o
|
|
51
|
+
};
|
|
52
|
+
return v.make(m);
|
|
53
|
+
}
|
|
54
|
+
return c;
|
|
55
|
+
};
|
|
56
|
+
class le extends G.TaggedError("FormErrors") {
|
|
16
57
|
}
|
|
17
|
-
const
|
|
58
|
+
const D = (c) => function(o) {
|
|
18
59
|
return {
|
|
19
60
|
render() {
|
|
20
|
-
return
|
|
21
|
-
form:
|
|
61
|
+
return H(o, {
|
|
62
|
+
form: c,
|
|
22
63
|
...this.$attrs
|
|
23
64
|
}, this.$slots);
|
|
24
65
|
}
|
|
25
66
|
};
|
|
26
|
-
},
|
|
67
|
+
}, ce = (c) => function(o) {
|
|
27
68
|
return {
|
|
28
69
|
setup() {
|
|
29
|
-
const { fieldMap:
|
|
30
|
-
const
|
|
31
|
-
Object.entries(
|
|
32
|
-
([
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
35
|
-
const
|
|
36
|
-
return
|
|
37
|
-
label:
|
|
38
|
-
inputId:
|
|
70
|
+
const { fieldMap: m, form: u } = c, l = u.useStore((y) => y.errors), f = u.useStore((y) => y.fieldMeta), w = u.useStore((y) => y.errorMap), E = T(() => {
|
|
71
|
+
const y = _.filterMap(
|
|
72
|
+
Object.entries(f.value),
|
|
73
|
+
([A, h]) => {
|
|
74
|
+
const k = h.errors ?? [];
|
|
75
|
+
if (!k.length) return U.none();
|
|
76
|
+
const i = m.value.get(A);
|
|
77
|
+
return i ? U.some({
|
|
78
|
+
label: i.label,
|
|
79
|
+
inputId: i.id,
|
|
39
80
|
// Only show the first error
|
|
40
|
-
errors: [
|
|
41
|
-
}) :
|
|
81
|
+
errors: [k[0]?.message].filter(Boolean)
|
|
82
|
+
}) : U.none();
|
|
42
83
|
}
|
|
43
|
-
),
|
|
44
|
-
if (
|
|
45
|
-
for (const [
|
|
46
|
-
if (
|
|
47
|
-
for (const
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
52
|
-
|
|
53
|
-
label:
|
|
54
|
-
inputId:
|
|
55
|
-
errors: [
|
|
84
|
+
), g = [];
|
|
85
|
+
if (w.value.onSubmit) {
|
|
86
|
+
for (const [A, h] of Object.entries(w.value.onSubmit))
|
|
87
|
+
if (_.isArray(h) && h.length)
|
|
88
|
+
for (const k of h) {
|
|
89
|
+
const i = k;
|
|
90
|
+
if (i?.path && _.isArray(i.path) && i.path.length) {
|
|
91
|
+
const M = i.path.join(".");
|
|
92
|
+
if (!m.value.has(M)) {
|
|
93
|
+
g.push({
|
|
94
|
+
label: M,
|
|
95
|
+
inputId: M,
|
|
96
|
+
errors: [i.message].filter(Boolean)
|
|
56
97
|
});
|
|
57
98
|
break;
|
|
58
99
|
}
|
|
59
100
|
}
|
|
60
101
|
}
|
|
61
102
|
}
|
|
62
|
-
return [...
|
|
103
|
+
return [...y, ...g];
|
|
63
104
|
});
|
|
64
105
|
return {
|
|
65
|
-
generalErrors:
|
|
66
|
-
errors:
|
|
106
|
+
generalErrors: l,
|
|
107
|
+
errors: E
|
|
67
108
|
};
|
|
68
109
|
},
|
|
69
|
-
render({ errors:
|
|
70
|
-
return
|
|
71
|
-
errors:
|
|
72
|
-
generalErrors:
|
|
110
|
+
render({ errors: m, generalErrors: u }) {
|
|
111
|
+
return H(o, {
|
|
112
|
+
errors: m,
|
|
113
|
+
generalErrors: u,
|
|
73
114
|
...this.$attrs
|
|
74
115
|
}, this.$slots);
|
|
75
116
|
}
|
|
76
117
|
};
|
|
77
|
-
},
|
|
78
|
-
if (!
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
return
|
|
82
|
-
const e = window.location.pathname, t = Object.keys(
|
|
118
|
+
}, Fe = (c, a, o) => {
|
|
119
|
+
if (!c) throw new Error("Schema is required");
|
|
120
|
+
const m = v.standardSchemaV1(c), u = v.decode(c), { meta: l } = se(c), f = T(() => {
|
|
121
|
+
if (o?.persistency?.id)
|
|
122
|
+
return o.persistency.id;
|
|
123
|
+
const e = window.location.pathname, t = Object.keys(l);
|
|
83
124
|
return `${e}-${t.join("-")}`;
|
|
84
|
-
}),
|
|
125
|
+
}), w = () => {
|
|
85
126
|
const e = new URLSearchParams(window.location.search);
|
|
86
|
-
e.delete(
|
|
127
|
+
e.delete(f.value);
|
|
87
128
|
const t = new URL(window.location.href);
|
|
88
129
|
t.search = e.toString(), window.history.replaceState({}, "", t.toString());
|
|
89
130
|
};
|
|
90
|
-
function
|
|
91
|
-
for (const
|
|
92
|
-
t[
|
|
131
|
+
function E(e, t) {
|
|
132
|
+
for (const n in t)
|
|
133
|
+
t[n] && X(t[n]) ? (e[n] || (e[n] = {}), E(e[n], t[n])) : e[n] = t[n];
|
|
93
134
|
return e;
|
|
94
135
|
}
|
|
95
|
-
const
|
|
136
|
+
const y = (e) => {
|
|
96
137
|
if (!e) return;
|
|
97
138
|
const t = { ...e };
|
|
98
|
-
for (const
|
|
99
|
-
const s =
|
|
100
|
-
s && !s.required && s.nullableOrUndefined && s.type !== "boolean" && (
|
|
139
|
+
for (const n in l) {
|
|
140
|
+
const s = l[n], r = t[n], p = (r == null || r === !1 || r === "" || Number.isNaN(r)) && r !== !1 && r !== 0;
|
|
141
|
+
s && !s.required && s.nullableOrUndefined && s.type !== "boolean" && (r === void 0 || p) && (t[n] = s.nullableOrUndefined === "undefined" ? void 0 : null);
|
|
101
142
|
}
|
|
102
143
|
return t;
|
|
103
|
-
},
|
|
144
|
+
}, g = (e) => {
|
|
104
145
|
const t = {};
|
|
146
|
+
if (typeof e?.make == "function")
|
|
147
|
+
try {
|
|
148
|
+
return e.make({});
|
|
149
|
+
} catch {
|
|
150
|
+
}
|
|
151
|
+
const n = e?.members || (e?.ast?._tag === "Union" && e.ast.types ? e.ast.types.map((s) => v.make(s)) : null);
|
|
152
|
+
if (n && _.isArray(n)) {
|
|
153
|
+
for (const s of n) {
|
|
154
|
+
const r = g(s);
|
|
155
|
+
if (Object.keys(r).length > 0 && s?.fields && Object.entries(s.fields).some(
|
|
156
|
+
([p, K]) => p === "_tag" || p === "type" || p === "kind" ? K?.ast?.defaultValue !== void 0 : !1
|
|
157
|
+
))
|
|
158
|
+
return r;
|
|
159
|
+
}
|
|
160
|
+
return {};
|
|
161
|
+
}
|
|
105
162
|
if (e?.fields && typeof e.fields == "object")
|
|
106
|
-
for (const [
|
|
107
|
-
if (
|
|
163
|
+
for (const [s, r] of Object.entries(e.fields)) {
|
|
164
|
+
if (r?.ast?.defaultValue)
|
|
108
165
|
try {
|
|
109
|
-
const
|
|
110
|
-
|
|
166
|
+
const p = r.ast.defaultValue();
|
|
167
|
+
p !== void 0 && (t[s] = p);
|
|
111
168
|
} catch {
|
|
112
169
|
}
|
|
113
|
-
const
|
|
114
|
-
Object.keys(
|
|
170
|
+
const d = g(r);
|
|
171
|
+
Object.keys(d).length > 0 && (t[s] && typeof t[s] == "object" ? Object.assign(t[s], d) : t[s] || (t[s] = d));
|
|
115
172
|
}
|
|
116
173
|
return t;
|
|
117
|
-
},
|
|
174
|
+
}, A = (e = {}) => {
|
|
175
|
+
let t = {};
|
|
118
176
|
try {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
} catch (t) {
|
|
124
|
-
window.location.hostname === "localhost" && console.warn("schema.make() failed, extracting defaults from AST:", t);
|
|
177
|
+
const n = c.make(e);
|
|
178
|
+
t = v.encodeSync(F(c))(n);
|
|
179
|
+
} catch (n) {
|
|
180
|
+
window.location.hostname === "localhost" && console.warn("schema.make() failed, extracting defaults from AST:", n);
|
|
125
181
|
try {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
} catch (
|
|
129
|
-
|
|
182
|
+
const s = g(c);
|
|
183
|
+
t = v.encodeSync(F(c))(s);
|
|
184
|
+
} catch (s) {
|
|
185
|
+
window.location.hostname === "localhost" && console.warn("Could not extract defaults from AST:", s);
|
|
130
186
|
}
|
|
131
187
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
188
|
+
return E(t, e);
|
|
189
|
+
}, h = T(() => {
|
|
190
|
+
const e = A(
|
|
191
|
+
y(
|
|
192
|
+
a?.defaultValues
|
|
193
|
+
)
|
|
194
|
+
);
|
|
195
|
+
if (e && !o?.persistency?.overrideDefaultValues)
|
|
135
196
|
return e;
|
|
136
197
|
let t;
|
|
137
|
-
const
|
|
138
|
-
if (!
|
|
139
|
-
if (
|
|
198
|
+
const n = o?.persistency;
|
|
199
|
+
if (!n?.policies || n.policies.length === 0) return {};
|
|
200
|
+
if (n.policies.includes("querystring"))
|
|
140
201
|
try {
|
|
141
|
-
const
|
|
142
|
-
|
|
202
|
+
const r = new URLSearchParams(window.location.search).get(f.value);
|
|
203
|
+
w(), r && (t = JSON.parse(r));
|
|
143
204
|
} catch (s) {
|
|
144
205
|
console.error(s);
|
|
145
206
|
}
|
|
146
207
|
if (
|
|
147
208
|
// query string has higher priority than local/session storage
|
|
148
|
-
!t && (
|
|
209
|
+
!t && (n.policies.includes("local") || n.policies.includes("session"))
|
|
149
210
|
) {
|
|
150
|
-
const s =
|
|
211
|
+
const s = n.policies.includes("local") ? localStorage : sessionStorage;
|
|
151
212
|
if (s)
|
|
152
213
|
try {
|
|
153
|
-
const
|
|
154
|
-
s.getItem(
|
|
214
|
+
const r = JSON.parse(
|
|
215
|
+
s.getItem(f.value) || "{}"
|
|
155
216
|
);
|
|
156
|
-
s.removeItem(
|
|
157
|
-
} catch (
|
|
158
|
-
console.error(
|
|
217
|
+
s.removeItem(f.value), t = r;
|
|
218
|
+
} catch (r) {
|
|
219
|
+
console.error(r);
|
|
159
220
|
}
|
|
160
221
|
}
|
|
161
|
-
return t ??=
|
|
162
|
-
}),
|
|
163
|
-
...
|
|
222
|
+
return t ??= A({}), e ? E(e, t) : t;
|
|
223
|
+
}), k = (e, t) => e ? L.with(q.setSpan(L.active(), e), t) : t(), i = Z({
|
|
224
|
+
...a,
|
|
164
225
|
validators: {
|
|
165
|
-
onSubmit:
|
|
166
|
-
...
|
|
226
|
+
onSubmit: m,
|
|
227
|
+
...a?.validators || {}
|
|
167
228
|
},
|
|
168
|
-
onSubmit:
|
|
169
|
-
const s = await
|
|
229
|
+
onSubmit: a?.onSubmit ? ({ formApi: e, meta: t, value: n }) => k(t?.currentSpan, async () => {
|
|
230
|
+
const s = await S.runPromise(u(n)), r = a.onSubmit({
|
|
170
231
|
formApi: e,
|
|
171
232
|
meta: t,
|
|
172
233
|
value: s
|
|
173
234
|
});
|
|
174
|
-
return
|
|
175
|
-
|
|
235
|
+
return O.isFiber(r) && O.isRuntimeFiber(r) ? await Q(r) : S.isEffect(r) ? await S.runPromise(
|
|
236
|
+
r.pipe(
|
|
176
237
|
// meta?.currentSpan
|
|
177
238
|
// ? Effect.withParentSpan(meta.currentSpan)
|
|
178
239
|
// : (_) => _,
|
|
179
|
-
|
|
240
|
+
S.flatMap((d) => O.join(d))
|
|
180
241
|
)
|
|
181
|
-
) :
|
|
242
|
+
) : r;
|
|
182
243
|
}) : void 0,
|
|
183
|
-
defaultValues:
|
|
184
|
-
}),
|
|
185
|
-
Object.keys(
|
|
186
|
-
|
|
244
|
+
defaultValues: h.value
|
|
245
|
+
}), M = () => {
|
|
246
|
+
Object.keys(l).forEach((e) => {
|
|
247
|
+
i.setFieldValue(e, void 0);
|
|
187
248
|
});
|
|
188
|
-
},
|
|
189
|
-
const s =
|
|
190
|
-
return s.reduce((
|
|
191
|
-
}, {}),
|
|
249
|
+
}, V = (e) => e.reduce((t, n) => {
|
|
250
|
+
const s = n.split(".");
|
|
251
|
+
return s.reduce((r, d, p) => (p === s.length - 1 ? r[d] = i.getFieldValue(n) : r[d] = r[d] ?? {}, r[d]), t), t;
|
|
252
|
+
}, {}), j = (e) => {
|
|
192
253
|
if (e) {
|
|
193
|
-
if (
|
|
194
|
-
return
|
|
195
|
-
if (
|
|
196
|
-
const t = Object.keys(
|
|
197
|
-
return
|
|
254
|
+
if (_.isArray(e.keys))
|
|
255
|
+
return V(e.keys);
|
|
256
|
+
if (_.isArray(e.banKeys)) {
|
|
257
|
+
const t = Object.keys(l).filter((n) => e.banKeys?.includes(n));
|
|
258
|
+
return V(t);
|
|
198
259
|
}
|
|
199
|
-
return
|
|
260
|
+
return i.store.state.values;
|
|
200
261
|
}
|
|
201
|
-
},
|
|
202
|
-
const e =
|
|
262
|
+
}, x = () => {
|
|
263
|
+
const e = o?.persistency;
|
|
203
264
|
if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
204
265
|
const t = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
205
266
|
if (!t) return;
|
|
206
|
-
const
|
|
207
|
-
return t.setItem(
|
|
267
|
+
const n = j(e);
|
|
268
|
+
return t.setItem(f.value, JSON.stringify(n));
|
|
208
269
|
}
|
|
209
|
-
},
|
|
210
|
-
const e =
|
|
270
|
+
}, N = () => {
|
|
271
|
+
const e = o?.persistency;
|
|
211
272
|
if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
212
|
-
const t =
|
|
213
|
-
|
|
273
|
+
const t = j(e), n = new URLSearchParams(window.location.search);
|
|
274
|
+
n.set(f.value, JSON.stringify(t));
|
|
214
275
|
const s = new URL(window.location.href);
|
|
215
|
-
s.search =
|
|
276
|
+
s.search = n.toString(), window.history.replaceState({}, "", s.toString());
|
|
216
277
|
}
|
|
217
278
|
}, I = (e) => {
|
|
218
|
-
|
|
279
|
+
i.store.state.isDirty && e.preventDefault();
|
|
219
280
|
};
|
|
220
|
-
if (
|
|
221
|
-
window.addEventListener("beforeunload",
|
|
222
|
-
}),
|
|
223
|
-
window.removeEventListener("beforeunload",
|
|
224
|
-
}),
|
|
225
|
-
const e =
|
|
226
|
-
|
|
227
|
-
|
|
281
|
+
if (W(x), Y(() => {
|
|
282
|
+
window.addEventListener("beforeunload", x), window.addEventListener("blur", N), o?.preventWindowExit && o.preventWindowExit !== "nope" && window.addEventListener("beforeunload", I);
|
|
283
|
+
}), C(() => {
|
|
284
|
+
window.removeEventListener("beforeunload", x), window.removeEventListener("blur", N), o?.preventWindowExit && o.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", I);
|
|
285
|
+
}), o?.preventWindowExit === "prevent-and-reset") {
|
|
286
|
+
const e = i.useStore((r) => r.isSubmitting), t = i.useStore((r) => r.submissionAttempts), n = i.useStore((r) => r.canSubmit), s = i.useStore((r) => r.values);
|
|
287
|
+
B([e, t], ([r, d], [p]) => {
|
|
288
|
+
p && !r && d > 0 && n.value && i.reset(s.value);
|
|
228
289
|
});
|
|
229
290
|
}
|
|
230
|
-
const $ = (e) =>
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
(t) =>
|
|
291
|
+
const $ = (e) => S.currentSpan.pipe(
|
|
292
|
+
S.option,
|
|
293
|
+
S.flatMap(
|
|
294
|
+
(t) => S.promise(() => i.handleSubmit(U.isSome(t) ? { currentSpan: t.value, ...e } : e))
|
|
234
295
|
)
|
|
235
|
-
),
|
|
236
|
-
const t =
|
|
296
|
+
), J = (e) => e?.checkErrors ? $(e?.meta).pipe(S.flatMap(S.fnUntraced(function* () {
|
|
297
|
+
const t = i.getAllErrors();
|
|
237
298
|
if (Object.keys(t.fields).length || t.form.errors.length)
|
|
238
|
-
return yield* new
|
|
239
|
-
}))) : $(e?.meta),
|
|
240
|
-
i18nNamespace:
|
|
241
|
-
ignorePreventCloseEvents:
|
|
242
|
-
meta:
|
|
243
|
-
clear:
|
|
299
|
+
return yield* new le({ form: t.form, fields: t.fields });
|
|
300
|
+
}))) : $(e?.meta), z = i.handleSubmit, P = ee(/* @__PURE__ */ new Map()), b = Object.assign(i, {
|
|
301
|
+
i18nNamespace: o?.i18nNamespace,
|
|
302
|
+
ignorePreventCloseEvents: o?.ignorePreventCloseEvents,
|
|
303
|
+
meta: l,
|
|
304
|
+
clear: M,
|
|
244
305
|
handleSubmit: (e) => {
|
|
245
|
-
const t =
|
|
246
|
-
return
|
|
306
|
+
const t = q.getSpan(L.active());
|
|
307
|
+
return z({ currentSpan: t, ...e });
|
|
247
308
|
},
|
|
248
309
|
// /** @experimental */
|
|
249
|
-
handleSubmitEffect:
|
|
310
|
+
handleSubmitEffect: J,
|
|
250
311
|
registerField: (e) => {
|
|
251
|
-
|
|
312
|
+
B(e, (t) => P.value.set(t.name, { label: t.label, id: t.id }), { immediate: !0 }), W(() => P.value.delete(e.value.name));
|
|
252
313
|
}
|
|
253
|
-
}),
|
|
254
|
-
return Object.assign(
|
|
314
|
+
}), R = { form: b, fieldMap: P };
|
|
315
|
+
return Object.assign(b, {
|
|
255
316
|
// Type-level properties for performance optimization (not used at runtime)
|
|
256
317
|
_paths: void 0,
|
|
257
318
|
_keys: void 0,
|
|
258
|
-
errorContext:
|
|
259
|
-
Form:
|
|
260
|
-
Input:
|
|
261
|
-
TaggedUnion:
|
|
262
|
-
Field:
|
|
263
|
-
Errors:
|
|
264
|
-
Array:
|
|
265
|
-
AutoGen:
|
|
319
|
+
errorContext: R,
|
|
320
|
+
Form: D(b)(ae),
|
|
321
|
+
Input: D(b)(o?.input ?? oe),
|
|
322
|
+
TaggedUnion: D(b)(ie),
|
|
323
|
+
Field: i.Field,
|
|
324
|
+
Errors: ce(R)(ne),
|
|
325
|
+
Array: D(b)(te),
|
|
326
|
+
AutoGen: D(b)(re)
|
|
266
327
|
});
|
|
267
328
|
};
|
|
268
329
|
export {
|
|
269
|
-
|
|
270
|
-
|
|
330
|
+
le as FormErrors,
|
|
331
|
+
Fe as useOmegaForm
|
|
271
332
|
};
|