@effect-app/vue-components 2.10.11 → 2.11.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/OmegaFormStuff.d.ts +4 -1
- package/dist/types/components/OmegaForm/OmegaTaggedUnion.vue.d.ts +6 -6
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +2 -0
- package/dist/vue-components.es10.js +138 -134
- package/dist/vue-components.es12.js +206 -191
- package/dist/vue-components.es17.js +1 -1
- package/dist/vue-components.es20.js +2 -2
- package/dist/vue-components.es21.js +2 -2
- package/dist/vue-components.es30.js +41 -191
- package/dist/vue-components.es31.js +4 -0
- package/dist/vue-components.es32.js +2 -42
- package/dist/vue-components.es33.js +111 -2
- package/dist/vue-components.es35.js +7 -111
- package/dist/vue-components.es36.js +34 -0
- package/dist/vue-components.es38.js +187 -27
- package/dist/vue-components.es40.js +1 -1
- package/dist/vue-components.es6.js +38 -28
- package/dist/vue-components.es7.js +1 -1
- package/dist/vue-components.es8.js +42 -26
- package/dist/vue-components.es9.js +16 -10
- package/package.json +1 -1
- package/src/components/OmegaForm/OmegaFormStuff.ts +59 -13
- package/src/components/OmegaForm/OmegaInput.vue +23 -4
- package/src/components/OmegaForm/OmegaTaggedUnion.vue +40 -1
- package/src/components/OmegaForm/OmegaTaggedUnionInternal.vue +9 -2
- package/src/components/OmegaForm/useOmegaForm.ts +14 -2
- package/dist/vue-components.es34.js +0 -4
- package/dist/vue-components.es37.js +0 -9
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Effect, S } from "effect-app";
|
|
2
2
|
import { type DeepKeys, type DeepValue, type FieldAsyncValidateOrFn, type FieldValidateOrFn, type FormApi, type FormAsyncValidateOrFn, type FormOptions, type FormState, type FormValidateOrFn, type StandardSchemaV1, type VueFormApi } from "@tanstack/vue-form";
|
|
3
3
|
import { type RuntimeFiber } from "effect/Fiber";
|
|
4
|
+
import { useIntl } from "../../utils";
|
|
4
5
|
import { type OmegaFieldInternalApi } from "./InputProps";
|
|
5
6
|
import { type OF, type OmegaFormReturn } from "./useOmegaForm";
|
|
6
7
|
export type FieldPath<T> = unknown extends T ? string : T extends string | boolean | number | null | undefined | symbol | bigint ? "" : T extends ReadonlyArray<infer U> ? FieldPath_<U, `[${number}]`> : {
|
|
@@ -142,8 +143,10 @@ export declare const duplicateSchema: <From, To>(schema: S.Schema<To, From, neve
|
|
|
142
143
|
export declare const generateMetaFromSchema: <From, To>(schema: S.Schema<To, From, never>) => {
|
|
143
144
|
schema: S.Schema<To, From, never>;
|
|
144
145
|
meta: MetaRecord<To>;
|
|
146
|
+
unionMeta: Record<string, MetaRecord<To>>;
|
|
147
|
+
unionDefaultValues: Record<string, Record<string, any>>;
|
|
145
148
|
};
|
|
146
|
-
export declare const generateInputStandardSchemaFromFieldMeta: (meta: FieldMeta) => StandardSchemaV1<any, any>;
|
|
149
|
+
export declare const generateInputStandardSchemaFromFieldMeta: (meta: FieldMeta, trans?: ReturnType<typeof useIntl>["trans"]) => StandardSchemaV1<any, any>;
|
|
147
150
|
export declare const nullableInput: <A, I, R>(schema: S.Schema<A, I, R>, defaultValue: () => A) => S.transform<import("effect/Schema").NullOr<S.Schema<A, I, R>> & {
|
|
148
151
|
withDefault: S.PropertySignature<":", A | null, never, ":", I | null, true, R>;
|
|
149
152
|
}, S.SchemaClass<A, A, never>>;
|
|
@@ -13,17 +13,17 @@ declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends R
|
|
|
13
13
|
attrs: any;
|
|
14
14
|
slots: {
|
|
15
15
|
[x: string]: ((props: {
|
|
16
|
-
field: import("./InputProps").OmegaFieldInternalApi<From, `${NonNullable<Name>}._tag
|
|
17
|
-
state: NonNullable<import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag
|
|
16
|
+
field: import("./InputProps").OmegaFieldInternalApi<From, "_tag" | `${NonNullable<Name>}._tag`>;
|
|
17
|
+
state: NonNullable<import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>>;
|
|
18
18
|
}) => any) | undefined;
|
|
19
19
|
[x: number]: ((props: {
|
|
20
|
-
field: import("./InputProps").OmegaFieldInternalApi<From, `${NonNullable<Name>}._tag
|
|
21
|
-
state: NonNullable<import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag
|
|
20
|
+
field: import("./InputProps").OmegaFieldInternalApi<From, "_tag" | `${NonNullable<Name>}._tag`>;
|
|
21
|
+
state: NonNullable<import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>>;
|
|
22
22
|
}) => any) | undefined;
|
|
23
23
|
} & {
|
|
24
24
|
OmegaCustomInput?: (props: {
|
|
25
|
-
field: import("@tanstack/vue-form").FieldApi<From, `${NonNullable<Name>}._tag
|
|
26
|
-
state: import("@tanstack/vue-form").FieldState<From, `${NonNullable<Name>}._tag
|
|
25
|
+
field: import("@tanstack/vue-form").FieldApi<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>, import("@tanstack/vue-form").FieldValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | 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, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>, import("@tanstack/vue-form").FieldValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, "_tag" | `${NonNullable<Name>}._tag`, import("@tanstack/vue-form").DeepValue<From, "_tag" | `${NonNullable<Name>}._tag`>> | 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
27
|
}) => any;
|
|
28
28
|
} & {
|
|
29
29
|
default?: (props: {}) => any;
|
|
@@ -61,6 +61,8 @@ export type OmegaConfig<T> = {
|
|
|
61
61
|
};
|
|
62
62
|
export interface OF<From, To> extends OmegaFormApi<From, To> {
|
|
63
63
|
meta: MetaRecord<From>;
|
|
64
|
+
unionMeta: Record<string, MetaRecord<From>>;
|
|
65
|
+
unionDefaultValues: Record<string, Record<string, any>>;
|
|
64
66
|
clear: () => void;
|
|
65
67
|
i18nNamespace?: string;
|
|
66
68
|
ignorePreventCloseEvents?: boolean;
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import { useForm as
|
|
2
|
-
import { Data as
|
|
3
|
-
import { runtimeFiberAsPromise as
|
|
4
|
-
import { computed as x, onUnmounted as
|
|
5
|
-
import { useIntl as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { generateMetaFromSchema as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { trace as
|
|
1
|
+
import { useForm as T } from "@tanstack/vue-form";
|
|
2
|
+
import { Data as z, S as W, Effect as d, Fiber as $, Option as A, Array as F } from "effect-app";
|
|
3
|
+
import { runtimeFiberAsPromise as G } from "./vue-components.es17.js";
|
|
4
|
+
import { computed as x, onUnmounted as R, onMounted as Z, onBeforeUnmount as Q, watch as N, ref as X, h as q } from "vue";
|
|
5
|
+
import { useIntl as Y } from "./vue-components.es3.js";
|
|
6
|
+
import C from "./vue-components.es18.js";
|
|
7
|
+
import ee from "./vue-components.es19.js";
|
|
8
|
+
import re from "./vue-components.es20.js";
|
|
9
|
+
import { generateMetaFromSchema as te, deepMerge as H, defaultsValueFromSchema as se } from "./vue-components.es12.js";
|
|
10
|
+
import ne 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 J } from "./vue-components.es22.js";
|
|
14
14
|
import { context as U } from "./vue-components.es23.js";
|
|
15
|
-
class
|
|
15
|
+
class ae extends z.TaggedError("FormErrors") {
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const M = (i) => function(s) {
|
|
18
18
|
return {
|
|
19
19
|
render() {
|
|
20
|
-
return
|
|
20
|
+
return q(s, {
|
|
21
21
|
form: i,
|
|
22
22
|
...this.$attrs
|
|
23
23
|
}, this.$slots);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
},
|
|
27
|
-
const { formatMessage: l } =
|
|
28
|
-
return (a) => i.i18nNamespace ? l({ id: `${i.i18nNamespace}.fields.${a}`, defaultMessage:
|
|
29
|
-
},
|
|
26
|
+
}, ce = (i) => {
|
|
27
|
+
const { formatMessage: l } = Y(), s = (a) => a.replace(/([A-Z])/g, " $1").replace(/^./, (g) => g.toUpperCase()).trim(), f = (a) => l ? l({ id: `general.fields.${a}`, defaultMessage: s(a) }) : s(a);
|
|
28
|
+
return (a) => i.i18nNamespace ? l({ id: `${i.i18nNamespace}.fields.${a}`, defaultMessage: f(a) }) : f(a);
|
|
29
|
+
}, le = (i) => function(s) {
|
|
30
30
|
return {
|
|
31
31
|
setup() {
|
|
32
|
-
const { fieldMap:
|
|
33
|
-
const
|
|
34
|
-
Object.entries(
|
|
35
|
-
([
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
const u =
|
|
39
|
-
return u ?
|
|
32
|
+
const { fieldMap: f, form: m } = i, a = m.useStore((p) => p.errors), g = m.useStore((p) => p.fieldMeta), O = m.useStore((p) => p.errorMap), v = ce(m), L = x(() => {
|
|
33
|
+
const p = F.filterMap(
|
|
34
|
+
Object.entries(g.value),
|
|
35
|
+
([o, b]) => {
|
|
36
|
+
const w = b.errors ?? [];
|
|
37
|
+
if (!w.length) return A.none();
|
|
38
|
+
const u = f.value.get(o);
|
|
39
|
+
return u ? A.some({
|
|
40
40
|
label: u.label,
|
|
41
41
|
inputId: u.id,
|
|
42
42
|
// Only show the first error
|
|
43
|
-
errors: [
|
|
44
|
-
}) :
|
|
43
|
+
errors: [w[0]?.message].filter(Boolean)
|
|
44
|
+
}) : A.none();
|
|
45
45
|
}
|
|
46
|
-
),
|
|
47
|
-
if (
|
|
48
|
-
for (const [
|
|
49
|
-
if (F.isArray(
|
|
50
|
-
for (const
|
|
51
|
-
const u =
|
|
46
|
+
), P = [];
|
|
47
|
+
if (O.value.onSubmit) {
|
|
48
|
+
for (const [o, b] of Object.entries(O.value.onSubmit))
|
|
49
|
+
if (F.isArray(b) && b.length)
|
|
50
|
+
for (const w of b) {
|
|
51
|
+
const u = w;
|
|
52
52
|
if (u?.path && F.isArray(u.path) && u.path.length) {
|
|
53
53
|
const y = u.path.join(".");
|
|
54
|
-
if (!
|
|
55
|
-
|
|
56
|
-
label:
|
|
54
|
+
if (!f.value.has(y)) {
|
|
55
|
+
P.push({
|
|
56
|
+
label: v(y),
|
|
57
57
|
inputId: y,
|
|
58
58
|
errors: [u.message].filter(Boolean)
|
|
59
59
|
});
|
|
@@ -62,177 +62,181 @@ const g = (i) => function(n) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
return [...
|
|
65
|
+
return [...p, ...P];
|
|
66
66
|
});
|
|
67
67
|
return {
|
|
68
68
|
generalErrors: a,
|
|
69
|
-
errors:
|
|
69
|
+
errors: L
|
|
70
70
|
};
|
|
71
71
|
},
|
|
72
|
-
render({ errors:
|
|
73
|
-
return
|
|
74
|
-
errors:
|
|
75
|
-
generalErrors:
|
|
72
|
+
render({ errors: f, generalErrors: m }) {
|
|
73
|
+
return q(s, {
|
|
74
|
+
errors: f,
|
|
75
|
+
generalErrors: m,
|
|
76
76
|
...this.$attrs
|
|
77
77
|
}, this.$slots);
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
},
|
|
80
|
+
}, S = (i, l) => i.includes(l), Fe = (i, l, s) => {
|
|
81
81
|
if (!i) throw new Error("Schema is required");
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
return
|
|
82
|
+
const f = W.standardSchemaV1(i), m = W.decode(i), { meta: a, unionDefaultValues: g, unionMeta: O } = te(i), v = x(() => {
|
|
83
|
+
if (s?.persistency?.id)
|
|
84
|
+
return s.persistency.id;
|
|
85
85
|
const e = window.location.pathname, r = Object.keys(a);
|
|
86
86
|
return `${e}-${r.join("-")}`;
|
|
87
|
-
}),
|
|
87
|
+
}), L = () => {
|
|
88
88
|
const e = new URLSearchParams(window.location.search);
|
|
89
|
-
e.delete(
|
|
89
|
+
e.delete(v.value);
|
|
90
90
|
const r = new URL(window.location.href);
|
|
91
91
|
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
92
|
-
},
|
|
92
|
+
}, p = x(() => {
|
|
93
93
|
let e;
|
|
94
|
-
const r =
|
|
94
|
+
const r = s?.persistency;
|
|
95
95
|
if (
|
|
96
96
|
// query string has higher priority than local/session storage
|
|
97
|
-
r?.policies && !e && (
|
|
97
|
+
r?.policies && !e && (S(r.policies, "local") || S(r.policies, "session"))
|
|
98
98
|
) {
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
99
|
+
const n = S(r.policies, "local") ? localStorage : sessionStorage;
|
|
100
|
+
if (n)
|
|
101
101
|
try {
|
|
102
102
|
const t = JSON.parse(
|
|
103
|
-
|
|
103
|
+
n.getItem(v.value) || "{}"
|
|
104
104
|
);
|
|
105
|
-
|
|
105
|
+
n.removeItem(v.value), e = t;
|
|
106
106
|
} catch (t) {
|
|
107
107
|
console.error(t);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
if (r?.policies &&
|
|
110
|
+
if (r?.policies && S(r.policies, "querystring"))
|
|
111
111
|
try {
|
|
112
|
-
const t = new URLSearchParams(window.location.search).get(
|
|
113
|
-
|
|
114
|
-
} catch (
|
|
115
|
-
console.error(
|
|
112
|
+
const t = new URLSearchParams(window.location.search).get(v.value);
|
|
113
|
+
L(), t && (e = H(e || {}, JSON.parse(t)));
|
|
114
|
+
} catch (n) {
|
|
115
|
+
console.error(n);
|
|
116
116
|
}
|
|
117
117
|
e ??= {};
|
|
118
118
|
const c = {
|
|
119
119
|
tanstack: l?.defaultValues || {},
|
|
120
120
|
persistency: e,
|
|
121
|
-
schema:
|
|
121
|
+
schema: se(i)
|
|
122
122
|
};
|
|
123
|
-
return (
|
|
124
|
-
(
|
|
123
|
+
return (s?.defaultValuesPriority || ["tanstack", "persistency", "schema"]).reverse().reduce(
|
|
124
|
+
(n, t) => Object.keys(n).length ? H(n, c[t]) : c[t],
|
|
125
125
|
{}
|
|
126
126
|
);
|
|
127
|
-
}),
|
|
127
|
+
}), P = (e, r) => e ? U.with(J.setSpan(U.active(), e), r) : r(), o = T({
|
|
128
128
|
...l,
|
|
129
129
|
validators: {
|
|
130
|
-
onSubmit:
|
|
130
|
+
onSubmit: f,
|
|
131
131
|
...l?.validators || {}
|
|
132
132
|
},
|
|
133
|
-
onSubmit: l?.onSubmit ? ({ formApi: e, meta: r, value: c }) =>
|
|
134
|
-
const
|
|
133
|
+
onSubmit: l?.onSubmit ? ({ formApi: e, meta: r, value: c }) => P(r?.currentSpan, async () => {
|
|
134
|
+
const n = await d.runPromise(m(c)), t = l.onSubmit({
|
|
135
135
|
formApi: e,
|
|
136
136
|
meta: r,
|
|
137
|
-
value:
|
|
137
|
+
value: n
|
|
138
138
|
});
|
|
139
|
-
return $.isFiber(t) && $.isRuntimeFiber(t) ? await
|
|
139
|
+
return $.isFiber(t) && $.isRuntimeFiber(t) ? await G(t) : d.isEffect(t) ? await d.runPromise(
|
|
140
140
|
t.pipe(
|
|
141
141
|
// meta?.currentSpan
|
|
142
142
|
// ? Effect.withParentSpan(meta.currentSpan)
|
|
143
143
|
// : (_) => _,
|
|
144
|
-
|
|
144
|
+
d.flatMap((h) => $.join(h))
|
|
145
145
|
)
|
|
146
146
|
) : t;
|
|
147
147
|
}) : void 0,
|
|
148
|
-
defaultValues:
|
|
149
|
-
}),
|
|
148
|
+
defaultValues: p.value
|
|
149
|
+
}), b = () => {
|
|
150
150
|
Object.keys(a).forEach((e) => {
|
|
151
|
-
|
|
151
|
+
o.setFieldValue(e, void 0);
|
|
152
152
|
});
|
|
153
|
-
},
|
|
154
|
-
const
|
|
155
|
-
return
|
|
156
|
-
}, {}),
|
|
153
|
+
}, w = (e) => e.reduce((r, c) => {
|
|
154
|
+
const n = c.split(".");
|
|
155
|
+
return n.reduce((t, h, _) => (_ === n.length - 1 ? t[h] = o.getFieldValue(c) : t[h] = t[h] ?? {}, t[h]), r), r;
|
|
156
|
+
}, {}), u = (e) => {
|
|
157
157
|
if (e) {
|
|
158
158
|
if (F.isArray(e.keys))
|
|
159
|
-
return
|
|
159
|
+
return w(e.keys);
|
|
160
160
|
if (F.isArray(e.banKeys)) {
|
|
161
161
|
const r = Object.keys(a).filter((c) => e.banKeys?.includes(c));
|
|
162
|
-
return
|
|
162
|
+
return w(r);
|
|
163
163
|
}
|
|
164
|
-
return
|
|
164
|
+
return o.store.state.values;
|
|
165
165
|
}
|
|
166
|
-
},
|
|
167
|
-
const e =
|
|
168
|
-
if (!(!e?.policies || e.policies.length === 0) && (
|
|
169
|
-
const r =
|
|
166
|
+
}, y = () => {
|
|
167
|
+
const e = s?.persistency;
|
|
168
|
+
if (!(!e?.policies || e.policies.length === 0) && (S(e.policies, "local") || S(e.policies, "session"))) {
|
|
169
|
+
const r = S(e.policies, "local") ? localStorage : sessionStorage;
|
|
170
170
|
if (!r) return;
|
|
171
|
-
const c =
|
|
172
|
-
return r.setItem(
|
|
171
|
+
const c = u(e);
|
|
172
|
+
return r.setItem(v.value, JSON.stringify(c));
|
|
173
173
|
}
|
|
174
|
-
},
|
|
175
|
-
const e =
|
|
176
|
-
if (!(!e?.policies || e.policies.length === 0) &&
|
|
177
|
-
const r =
|
|
178
|
-
c.set(
|
|
179
|
-
const
|
|
180
|
-
|
|
174
|
+
}, V = () => {
|
|
175
|
+
const e = s?.persistency;
|
|
176
|
+
if (!(!e?.policies || e.policies.length === 0) && S(e.policies, "querystring")) {
|
|
177
|
+
const r = u(e), c = new URLSearchParams(window.location.search);
|
|
178
|
+
c.set(v.value, JSON.stringify(r));
|
|
179
|
+
const n = new URL(window.location.href);
|
|
180
|
+
n.search = c.toString(), window.history.replaceState({}, "", n.toString());
|
|
181
181
|
}
|
|
182
|
-
},
|
|
183
|
-
|
|
182
|
+
}, k = (e) => {
|
|
183
|
+
o.store.state.isDirty && e.preventDefault();
|
|
184
184
|
};
|
|
185
|
-
if (
|
|
186
|
-
window.addEventListener("beforeunload",
|
|
187
|
-
}),
|
|
188
|
-
window.removeEventListener("beforeunload",
|
|
189
|
-
}),
|
|
190
|
-
const e =
|
|
191
|
-
|
|
192
|
-
_ && !t &&
|
|
185
|
+
if (R(y), Z(() => {
|
|
186
|
+
window.addEventListener("beforeunload", y), window.addEventListener("blur", V), s?.preventWindowExit && s.preventWindowExit !== "nope" && window.addEventListener("beforeunload", k);
|
|
187
|
+
}), Q(() => {
|
|
188
|
+
window.removeEventListener("beforeunload", y), window.removeEventListener("blur", V), s?.preventWindowExit && s.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", k);
|
|
189
|
+
}), s?.preventWindowExit === "prevent-and-reset") {
|
|
190
|
+
const e = o.useStore((t) => t.isSubmitting), r = o.useStore((t) => t.submissionAttempts), c = o.useStore((t) => t.canSubmit), n = o.useStore((t) => t.values);
|
|
191
|
+
N([e, r], ([t, h], [_]) => {
|
|
192
|
+
_ && !t && h > 0 && c.value && o.reset(n.value);
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
(r) =>
|
|
195
|
+
const I = (e) => d.currentSpan.pipe(
|
|
196
|
+
d.option,
|
|
197
|
+
d.flatMap(
|
|
198
|
+
(r) => d.promise(() => o.handleSubmit(A.isSome(r) ? { currentSpan: r.value, ...e } : e))
|
|
199
199
|
)
|
|
200
|
-
),
|
|
201
|
-
const r =
|
|
200
|
+
), B = (e) => e?.checkErrors ? I(e?.meta).pipe(d.flatMap(d.fnUntraced(function* () {
|
|
201
|
+
const r = o.getAllErrors();
|
|
202
202
|
if (Object.keys(r.fields).length || r.form.errors.length)
|
|
203
|
-
return yield* new
|
|
204
|
-
}))) :
|
|
205
|
-
i18nNamespace:
|
|
206
|
-
ignorePreventCloseEvents:
|
|
203
|
+
return yield* new ae({ form: r.form, fields: r.fields });
|
|
204
|
+
}))) : I(e?.meta), K = o.handleSubmit, j = X(/* @__PURE__ */ new Map()), E = Object.assign(o, {
|
|
205
|
+
i18nNamespace: s?.i18nNamespace,
|
|
206
|
+
ignorePreventCloseEvents: s?.ignorePreventCloseEvents,
|
|
207
207
|
meta: a,
|
|
208
|
-
|
|
208
|
+
unionMeta: O,
|
|
209
|
+
unionDefaultValues: g,
|
|
210
|
+
clear: b,
|
|
209
211
|
handleSubmit: (e) => {
|
|
210
|
-
const r =
|
|
211
|
-
return
|
|
212
|
+
const r = J.getSpan(U.active());
|
|
213
|
+
return K({ currentSpan: r, ...e });
|
|
212
214
|
},
|
|
213
215
|
// /** @experimental */
|
|
214
|
-
handleSubmitEffect:
|
|
216
|
+
handleSubmitEffect: B,
|
|
215
217
|
registerField: (e) => {
|
|
216
|
-
|
|
218
|
+
N(e, (r) => j.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), R(() => {
|
|
219
|
+
j.value.get(e.value.name)?.id === e.value.id && j.value.delete(e.value.name);
|
|
220
|
+
});
|
|
217
221
|
}
|
|
218
|
-
}),
|
|
219
|
-
return Object.assign(
|
|
222
|
+
}), D = { form: E, fieldMap: j };
|
|
223
|
+
return Object.assign(E, {
|
|
220
224
|
// Type-level properties for performance optimization (not used at runtime)
|
|
221
225
|
_paths: void 0,
|
|
222
226
|
_keys: void 0,
|
|
223
227
|
_schema: i,
|
|
224
|
-
errorContext:
|
|
225
|
-
Form:
|
|
226
|
-
Input:
|
|
227
|
-
TaggedUnion:
|
|
228
|
-
Field:
|
|
229
|
-
Errors:
|
|
230
|
-
Array:
|
|
231
|
-
AutoGen:
|
|
228
|
+
errorContext: D,
|
|
229
|
+
Form: M(E)(ie),
|
|
230
|
+
Input: M(E)(s?.input ?? ne),
|
|
231
|
+
TaggedUnion: M(E)(oe),
|
|
232
|
+
Field: o.Field,
|
|
233
|
+
Errors: le(D)(re),
|
|
234
|
+
Array: M(E)(C),
|
|
235
|
+
AutoGen: M(E)(ee)
|
|
232
236
|
});
|
|
233
237
|
};
|
|
234
238
|
export {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
239
|
+
ae as FormErrors,
|
|
240
|
+
ce as useErrorLabel,
|
|
241
|
+
Fe as useOmegaForm
|
|
238
242
|
};
|