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