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