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