@effect-app/vue-components 1.8.3 → 1.8.5
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 +0 -1
- package/dist/types/components/OmegaForm/OmegaErrorsInternal.vue.d.ts +0 -1
- package/dist/types/components/OmegaForm/OmegaInput.vue.d.ts +0 -1
- package/dist/types/components/OmegaForm/OmegaInternalInput.vue.d.ts +6 -1
- package/dist/types/components/OmegaForm/index.d.ts +0 -1
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +6 -1
- package/dist/types/components/OmegaForm/useRegisterField.d.ts +7 -0
- package/dist/vue-components.es.js +24 -26
- package/dist/vue-components.es10.js +23 -352
- package/dist/vue-components.es11.js +2 -27
- package/dist/vue-components.es12.js +11 -2
- package/dist/vue-components.es13.js +1 -1
- package/dist/vue-components.es14.js +1 -1
- package/dist/vue-components.es17.js +5 -5
- package/dist/vue-components.es18.js +2 -2
- package/dist/vue-components.es19.js +1 -1
- package/dist/vue-components.es2.js +19 -21
- package/dist/vue-components.es20.js +1 -1
- package/dist/vue-components.es24.js +135 -11
- package/dist/vue-components.es26.js +44 -0
- package/dist/vue-components.es27.js +2 -42
- package/dist/vue-components.es28.js +1 -1
- package/dist/vue-components.es29.js +89 -2
- package/dist/vue-components.es31.js +9 -0
- package/dist/vue-components.es32.js +31 -7
- package/dist/vue-components.es34.js +6 -0
- package/dist/vue-components.es35.js +23 -4
- package/dist/vue-components.es36.js +5 -23
- package/dist/vue-components.es37.js +21 -5
- package/dist/vue-components.es38.js +25 -16
- package/dist/vue-components.es39.js +15 -23
- package/dist/vue-components.es4.js +2 -2
- package/dist/vue-components.es40.js +7 -17
- package/dist/vue-components.es41.js +5 -12
- package/dist/vue-components.es42.js +19 -5
- package/dist/vue-components.es43.js +9 -19
- package/dist/vue-components.es44.js +31 -9
- package/dist/vue-components.es45.js +42 -25
- package/dist/vue-components.es46.js +16 -38
- package/dist/vue-components.es47.js +11 -26
- package/dist/vue-components.es48.js +65 -11
- package/dist/vue-components.es49.js +45 -54
- package/dist/vue-components.es5.js +10 -9
- package/dist/vue-components.es50.js +15 -54
- package/dist/vue-components.es51.js +31 -15
- package/dist/vue-components.es52.js +26 -30
- package/dist/vue-components.es53.js +42 -29
- package/dist/vue-components.es54.js +2 -42
- package/dist/vue-components.es55.js +44 -2
- package/dist/vue-components.es56.js +2 -44
- package/dist/vue-components.es6.js +31 -53
- package/dist/vue-components.es7.js +219 -27
- package/dist/vue-components.es8.js +28 -211
- package/dist/vue-components.es9.js +355 -29
- package/package.json +1 -1
- package/src/components/OmegaForm/InputProps.ts +0 -1
- package/src/components/OmegaForm/OmegaErrorsInternal.vue +1 -2
- package/src/components/OmegaForm/OmegaInput.vue +1 -0
- package/src/components/OmegaForm/OmegaInternalInput.vue +14 -59
- package/src/components/OmegaForm/index.ts +0 -1
- package/src/components/OmegaForm/useOmegaForm.ts +42 -13
- package/src/components/OmegaForm/useRegisterField.ts +15 -0
- package/dist/types/components/OmegaForm/OmegaErrorsContext.d.ts +0 -38
- package/dist/vue-components.es25.js +0 -137
- package/dist/vue-components.es30.js +0 -92
- package/dist/vue-components.es33.js +0 -33
- package/dist/vue-components.es57.js +0 -4
- package/src/components/OmegaForm/OmegaErrorsContext.ts +0 -67
|
@@ -1,31 +1,223 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { useForm as T } from "@tanstack/vue-form";
|
|
2
|
+
import { Data as W, S as U, Effect as l, Array as g, Option as E, Fiber as F } from "effect-app";
|
|
3
|
+
import { runtimeFiberAsPromise as k } from "./vue-components.es13.js";
|
|
4
|
+
import { isObject as z } from "./vue-components.es14.js";
|
|
5
|
+
import { computed as $, onUnmounted as A, onMounted as Q, onBeforeUnmount as X, watch as N, h as D } from "vue";
|
|
6
|
+
import { usePreventClose as Y } from "./vue-components.es8.js";
|
|
7
|
+
import Z from "./vue-components.es15.js";
|
|
8
|
+
import C from "./vue-components.es16.js";
|
|
9
|
+
import ee from "./vue-components.es17.js";
|
|
10
|
+
import { generateMetaFromSchema as re } from "./vue-components.es9.js";
|
|
11
|
+
import te from "./vue-components.es5.js";
|
|
12
|
+
import se from "./vue-components.es18.js";
|
|
13
|
+
import { trace as _ } from "./vue-components.es19.js";
|
|
14
|
+
import { context as M } from "./vue-components.es20.js";
|
|
15
|
+
class ne extends W.TaggedError("FormErrors") {
|
|
16
|
+
}
|
|
17
|
+
const h = (c) => function(o) {
|
|
11
18
|
return {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
showErrorsOn: t ?? "onSubmit"
|
|
19
|
+
render() {
|
|
20
|
+
return D(o, {
|
|
21
|
+
form: c,
|
|
22
|
+
...this.$attrs
|
|
23
|
+
}, this.$slots);
|
|
24
|
+
}
|
|
19
25
|
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
26
|
+
}, oe = (c) => function(o) {
|
|
27
|
+
return {
|
|
28
|
+
setup() {
|
|
29
|
+
return {
|
|
30
|
+
...c
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
render({ errors: S, generalErrors: w, showErrors: v }) {
|
|
34
|
+
return D(o, {
|
|
35
|
+
errors: S,
|
|
36
|
+
generalErrors: w,
|
|
37
|
+
showErrors: v,
|
|
38
|
+
...this.$attrs
|
|
39
|
+
}, this.$slots);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}, ye = (c, a, o) => {
|
|
43
|
+
if (!c) throw new Error("Schema is required");
|
|
44
|
+
const S = U.standardSchemaV1(c), w = U.decode(c), { filterItems: v, meta: p } = re(c), m = $(() => {
|
|
45
|
+
if (o?.persistency?.id)
|
|
46
|
+
return o.persistency.id;
|
|
47
|
+
const e = window.location.pathname, r = Object.keys(p);
|
|
48
|
+
return `${e}-${r.join("-")}`;
|
|
49
|
+
}), R = () => {
|
|
50
|
+
const e = new URLSearchParams(window.location.search);
|
|
51
|
+
e.delete(m.value);
|
|
52
|
+
const r = new URL(window.location.href);
|
|
53
|
+
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
54
|
+
};
|
|
55
|
+
function j(e, r) {
|
|
56
|
+
for (const t in r)
|
|
57
|
+
r[t] && z(r[t]) ? (e[t] || (e[t] = {}), j(e[t], r[t])) : e[t] = r[t];
|
|
58
|
+
return e;
|
|
59
|
+
}
|
|
60
|
+
const x = $(() => {
|
|
61
|
+
if (a?.defaultValues && !o?.persistency?.overrideDefaultValues)
|
|
62
|
+
return a?.defaultValues;
|
|
63
|
+
let e;
|
|
64
|
+
const r = o?.persistency;
|
|
65
|
+
if (!r?.policies || r.policies.length === 0) return {};
|
|
66
|
+
if (r.policies.includes("querystring"))
|
|
67
|
+
try {
|
|
68
|
+
const s = new URLSearchParams(window.location.search).get(m.value);
|
|
69
|
+
R(), s && (e = JSON.parse(s));
|
|
70
|
+
} catch (t) {
|
|
71
|
+
console.error(t);
|
|
72
|
+
}
|
|
73
|
+
if (
|
|
74
|
+
// query string has higher priority than local/session storage
|
|
75
|
+
!e && (r.policies.includes("local") || r.policies.includes("session"))
|
|
76
|
+
) {
|
|
77
|
+
const t = r.policies.includes("local") ? localStorage : sessionStorage;
|
|
78
|
+
if (t)
|
|
79
|
+
try {
|
|
80
|
+
const s = JSON.parse(
|
|
81
|
+
t.getItem(m.value) || "{}"
|
|
82
|
+
);
|
|
83
|
+
t.removeItem(m.value), e = s;
|
|
84
|
+
} catch (s) {
|
|
85
|
+
console.error(s);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (e ??= {}, a?.defaultValues == null)
|
|
89
|
+
return e;
|
|
90
|
+
{
|
|
91
|
+
const t = a?.defaultValues;
|
|
92
|
+
return j(t, e);
|
|
93
|
+
}
|
|
94
|
+
}), H = (e, r) => e ? M.with(_.setSpan(M.active(), e), r) : r(), u = T({
|
|
95
|
+
...a,
|
|
96
|
+
validators: {
|
|
97
|
+
onSubmit: S,
|
|
98
|
+
...a?.validators || {}
|
|
99
|
+
},
|
|
100
|
+
onSubmit: a?.onSubmit ? ({ formApi: e, meta: r, value: t }) => H(r?.currentSpan, async () => {
|
|
101
|
+
const s = await l.runPromise(w(t)), n = a.onSubmit({
|
|
102
|
+
formApi: e,
|
|
103
|
+
meta: r,
|
|
104
|
+
value: s
|
|
105
|
+
});
|
|
106
|
+
return F.isFiber(n) && F.isRuntimeFiber(n) ? await k(n) : l.isEffect(n) ? await l.runPromise(
|
|
107
|
+
n.pipe(
|
|
108
|
+
// meta?.currentSpan
|
|
109
|
+
// ? Effect.withParentSpan(meta.currentSpan)
|
|
110
|
+
// : (_) => _,
|
|
111
|
+
l.flatMap((d) => F.join(d))
|
|
112
|
+
)
|
|
113
|
+
) : n;
|
|
114
|
+
}) : void 0,
|
|
115
|
+
defaultValues: x.value
|
|
116
|
+
}), J = () => {
|
|
117
|
+
Object.keys(p).forEach((e) => {
|
|
118
|
+
u.setFieldValue(e, void 0);
|
|
119
|
+
});
|
|
120
|
+
}, V = (e) => e.reduce((r, t) => {
|
|
121
|
+
const s = t.split(".");
|
|
122
|
+
return s.reduce((n, d, G) => (G === s.length - 1 ? n[d] = u.getFieldValue(t) : n[d] = n[d] ?? {}, n[d]), r), r;
|
|
123
|
+
}, {}), O = (e) => {
|
|
124
|
+
if (e) {
|
|
125
|
+
if (g.isArray(e.keys))
|
|
126
|
+
return V(e.keys);
|
|
127
|
+
if (g.isArray(e.banKeys)) {
|
|
128
|
+
const r = Object.keys(p).filter((t) => e.banKeys?.includes(t));
|
|
129
|
+
return V(r);
|
|
130
|
+
}
|
|
131
|
+
return u.store.state.values;
|
|
132
|
+
}
|
|
133
|
+
}, b = () => {
|
|
134
|
+
const e = o?.persistency;
|
|
135
|
+
if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
136
|
+
const r = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
137
|
+
if (!r) return;
|
|
138
|
+
const t = O(e);
|
|
139
|
+
return r.setItem(m.value, JSON.stringify(t));
|
|
140
|
+
}
|
|
141
|
+
}, P = () => {
|
|
142
|
+
const e = o?.persistency;
|
|
143
|
+
if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
144
|
+
const r = O(e), t = new URLSearchParams(window.location.search);
|
|
145
|
+
t.set(m.value, JSON.stringify(r));
|
|
146
|
+
const s = new URL(window.location.href);
|
|
147
|
+
s.search = t.toString(), window.history.replaceState({}, "", s.toString());
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
A(b), Q(() => {
|
|
151
|
+
window.addEventListener("beforeunload", b), window.addEventListener("blur", P);
|
|
152
|
+
}), X(() => {
|
|
153
|
+
window.removeEventListener("beforeunload", b), window.removeEventListener("blur", P);
|
|
154
|
+
});
|
|
155
|
+
const I = (e) => l.currentSpan.pipe(
|
|
156
|
+
l.option,
|
|
157
|
+
l.flatMap(
|
|
158
|
+
(r) => l.promise(() => u.handleSubmit(E.isSome(r) ? { currentSpan: r.value, ...e } : e))
|
|
159
|
+
)
|
|
160
|
+
), q = (e) => e?.checkErrors ? I(e?.meta).pipe(l.flatMap(l.fnUntraced(function* () {
|
|
161
|
+
const r = u.getAllErrors();
|
|
162
|
+
if (Object.keys(r.fields).length || r.form.errors.length)
|
|
163
|
+
return yield* new ne({ form: r.form, fields: r.fields });
|
|
164
|
+
}))) : I(e?.meta), B = u.handleSubmit, f = /* @__PURE__ */ new Map(), i = Object.assign(u, {
|
|
165
|
+
i18nNamespace: o?.i18nNamespace,
|
|
166
|
+
meta: p,
|
|
167
|
+
filterItems: v,
|
|
168
|
+
clear: J,
|
|
169
|
+
handleSubmit: (e) => {
|
|
170
|
+
const r = _.getSpan(M.active());
|
|
171
|
+
return B({ currentSpan: r, ...e });
|
|
172
|
+
},
|
|
173
|
+
// /** @experimental */
|
|
174
|
+
handleSubmitEffect: q,
|
|
175
|
+
registerField: (e) => {
|
|
176
|
+
N(e, (r) => f.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), A(() => f.delete(e.value.name));
|
|
177
|
+
}
|
|
178
|
+
}), y = i.useStore((e) => e.errors), K = i.useStore(
|
|
179
|
+
(e) => g.filterMap(
|
|
180
|
+
Object.entries(e.fieldMeta),
|
|
181
|
+
([r, t]) => (t.errors ?? []).length && f.get(r)?.id ? E.some({
|
|
182
|
+
label: f.get(r).label,
|
|
183
|
+
inputId: f.get(r).id,
|
|
184
|
+
errors: (t.errors ?? []).map((s) => s.message).filter(Boolean)
|
|
185
|
+
}) : E.none()
|
|
186
|
+
)
|
|
187
|
+
);
|
|
188
|
+
N(
|
|
189
|
+
() => [i.filterItems, y.value],
|
|
190
|
+
() => {
|
|
191
|
+
const e = i.filterItems, r = y.value;
|
|
192
|
+
return e ? r ? (Object.values(r).filter(
|
|
193
|
+
(s) => !!s
|
|
194
|
+
).flatMap(
|
|
195
|
+
(s) => Object.values(s).flat().map((n) => n.message)
|
|
196
|
+
).some((s) => s === e.message) && e.items.forEach((s) => {
|
|
197
|
+
const n = i.getFieldMeta(s);
|
|
198
|
+
n && i.setFieldMeta(s, {
|
|
199
|
+
...n,
|
|
200
|
+
errorMap: {
|
|
201
|
+
onSubmit: [
|
|
202
|
+
{ path: [s], message: e.message }
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}), {}) : {} : {};
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
const L = { generalErrors: y, errors: K };
|
|
210
|
+
return o?.ignorePreventCloseEvents || Y(() => i.useStore((e) => e.isDirty)), Object.assign(i, {
|
|
211
|
+
errorContext: L,
|
|
212
|
+
Form: h(i)(se),
|
|
213
|
+
Input: h(i)(o?.input ?? te),
|
|
214
|
+
Field: u.Field,
|
|
215
|
+
Errors: oe(L)(ee),
|
|
216
|
+
Array: h(i)(Z),
|
|
217
|
+
AutoGen: h(i)(C)
|
|
218
|
+
});
|
|
219
|
+
};
|
|
27
220
|
export {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
g as useOmegaErrors
|
|
221
|
+
ne as FormErrors,
|
|
222
|
+
ye as useOmegaForm
|
|
31
223
|
};
|
|
@@ -1,215 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
const p = (l) => function(o) {
|
|
19
|
-
return {
|
|
20
|
-
render() {
|
|
21
|
-
return M(o, {
|
|
22
|
-
form: l,
|
|
23
|
-
...this.$attrs
|
|
24
|
-
}, this.$slots);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}, oe = (l) => function(o) {
|
|
28
|
-
return {
|
|
29
|
-
setup() {
|
|
30
|
-
return {
|
|
31
|
-
...l
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
render({ errors: h, generalErrors: S, showErrors: w }) {
|
|
35
|
-
return M(o, {
|
|
36
|
-
errors: h,
|
|
37
|
-
generalErrors: S,
|
|
38
|
-
showErrors: w,
|
|
39
|
-
...this.$attrs
|
|
40
|
-
}, this.$slots);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}, Ee = (l, a, o) => {
|
|
44
|
-
if (!l) throw new Error("Schema is required");
|
|
45
|
-
const h = L.standardSchemaV1(l), S = L.decode(l), { filterItems: w, meta: d } = re(l), m = A(() => {
|
|
46
|
-
if (o?.persistency?.id)
|
|
47
|
-
return o.persistency.id;
|
|
48
|
-
const e = window.location.pathname, r = Object.keys(d);
|
|
49
|
-
return `${e}-${r.join("-")}`;
|
|
50
|
-
}), U = () => {
|
|
51
|
-
const e = new URLSearchParams(window.location.search);
|
|
52
|
-
e.delete(m.value);
|
|
53
|
-
const r = new URL(window.location.href);
|
|
54
|
-
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
55
|
-
};
|
|
56
|
-
function g(e, r) {
|
|
57
|
-
for (const t in r)
|
|
58
|
-
r[t] && G(r[t]) ? (e[t] || (e[t] = {}), g(e[t], r[t])) : e[t] = r[t];
|
|
59
|
-
return e;
|
|
60
|
-
}
|
|
61
|
-
const $ = A(() => {
|
|
62
|
-
if (a?.defaultValues && !o?.persistency?.overrideDefaultValues)
|
|
63
|
-
return a?.defaultValues;
|
|
64
|
-
let e;
|
|
65
|
-
const r = o?.persistency;
|
|
66
|
-
if (!r?.policies || r.policies.length === 0) return {};
|
|
67
|
-
if (r.policies.includes("querystring"))
|
|
68
|
-
try {
|
|
69
|
-
const s = new URLSearchParams(window.location.search).get(m.value);
|
|
70
|
-
U(), s && (e = JSON.parse(s));
|
|
71
|
-
} catch (t) {
|
|
72
|
-
console.error(t);
|
|
73
|
-
}
|
|
74
|
-
if (
|
|
75
|
-
// query string has higher priority than local/session storage
|
|
76
|
-
!e && (r.policies.includes("local") || r.policies.includes("session"))
|
|
77
|
-
) {
|
|
78
|
-
const t = r.policies.includes("local") ? localStorage : sessionStorage;
|
|
79
|
-
if (t)
|
|
80
|
-
try {
|
|
81
|
-
const s = JSON.parse(
|
|
82
|
-
t.getItem(m.value) || "{}"
|
|
83
|
-
);
|
|
84
|
-
t.removeItem(m.value), e = s;
|
|
85
|
-
} catch (s) {
|
|
86
|
-
console.error(s);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (e ??= {}, a?.defaultValues == null)
|
|
90
|
-
return e;
|
|
91
|
-
{
|
|
92
|
-
const t = a?.defaultValues;
|
|
93
|
-
return g(t, e);
|
|
94
|
-
}
|
|
95
|
-
}), N = (e, r) => e ? E.with(I.setSpan(E.active(), e), r) : r(), u = J({
|
|
96
|
-
...a,
|
|
97
|
-
validators: {
|
|
98
|
-
onSubmit: h,
|
|
99
|
-
...a?.validators || {}
|
|
100
|
-
},
|
|
101
|
-
onSubmit: a?.onSubmit ? ({ formApi: e, meta: r, value: t }) => N(r?.currentSpan, async () => {
|
|
102
|
-
const s = await c.runPromise(S(t)), n = a.onSubmit({
|
|
103
|
-
formApi: e,
|
|
104
|
-
meta: r,
|
|
105
|
-
value: s
|
|
106
|
-
});
|
|
107
|
-
return y.isFiber(n) && y.isRuntimeFiber(n) ? await B(n) : c.isEffect(n) ? await c.runPromise(
|
|
108
|
-
n.pipe(
|
|
109
|
-
// meta?.currentSpan
|
|
110
|
-
// ? Effect.withParentSpan(meta.currentSpan)
|
|
111
|
-
// : (_) => _,
|
|
112
|
-
c.flatMap((f) => y.join(f))
|
|
113
|
-
)
|
|
114
|
-
) : n;
|
|
115
|
-
}) : void 0,
|
|
116
|
-
defaultValues: $.value
|
|
117
|
-
}), _ = () => {
|
|
118
|
-
Object.keys(d).forEach((e) => {
|
|
119
|
-
u.setFieldValue(e, void 0);
|
|
120
|
-
});
|
|
121
|
-
}, F = (e) => e.reduce((r, t) => {
|
|
122
|
-
const s = t.split(".");
|
|
123
|
-
return s.reduce((n, f, H) => (H === s.length - 1 ? n[f] = u.getFieldValue(t) : n[f] = n[f] ?? {}, n[f]), r), r;
|
|
124
|
-
}, {}), O = (e) => {
|
|
125
|
-
if (e) {
|
|
126
|
-
if (Array.isArray(e.keys))
|
|
127
|
-
return F(e.keys);
|
|
128
|
-
if (Array.isArray(e.banKeys)) {
|
|
129
|
-
const r = Object.keys(d).filter((t) => e.banKeys?.includes(t));
|
|
130
|
-
return F(r);
|
|
131
|
-
}
|
|
132
|
-
return u.store.state.values;
|
|
133
|
-
}
|
|
134
|
-
}, v = () => {
|
|
135
|
-
const e = o?.persistency;
|
|
136
|
-
if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
137
|
-
const r = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
138
|
-
if (!r) return;
|
|
139
|
-
const t = O(e);
|
|
140
|
-
return r.setItem(m.value, JSON.stringify(t));
|
|
141
|
-
}
|
|
142
|
-
}, V = () => {
|
|
143
|
-
const e = o?.persistency;
|
|
144
|
-
if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
145
|
-
const r = O(e), t = new URLSearchParams(window.location.search);
|
|
146
|
-
t.set(m.value, JSON.stringify(r));
|
|
147
|
-
const s = new URL(window.location.href);
|
|
148
|
-
s.search = t.toString(), window.history.replaceState({}, "", s.toString());
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
T(v), W(() => {
|
|
152
|
-
window.addEventListener("beforeunload", v), window.addEventListener("blur", V);
|
|
153
|
-
}), z(() => {
|
|
154
|
-
window.removeEventListener("beforeunload", v), window.removeEventListener("blur", V);
|
|
155
|
-
});
|
|
156
|
-
const j = (e) => c.currentSpan.pipe(
|
|
157
|
-
c.option,
|
|
158
|
-
c.flatMap(
|
|
159
|
-
(r) => c.promise(() => u.handleSubmit(k.isSome(r) ? { currentSpan: r.value, ...e } : e))
|
|
160
|
-
)
|
|
161
|
-
), D = (e) => e?.checkErrors ? j(e?.meta).pipe(c.flatMap(c.fnUntraced(function* () {
|
|
162
|
-
const r = u.getAllErrors();
|
|
163
|
-
if (Object.keys(r.fields).length || r.form.errors.length)
|
|
164
|
-
return yield* new ne({ form: r.form, fields: r.fields });
|
|
165
|
-
}))) : j(e?.meta), R = u.handleSubmit, i = Object.assign(u, {
|
|
166
|
-
i18nNamespace: o?.i18nNamespace,
|
|
167
|
-
meta: d,
|
|
168
|
-
filterItems: w,
|
|
169
|
-
clear: _,
|
|
170
|
-
handleSubmit: (e) => {
|
|
171
|
-
const r = I.getSpan(E.active());
|
|
172
|
-
return R({ currentSpan: r, ...e });
|
|
173
|
-
},
|
|
174
|
-
// /** @experimental */
|
|
175
|
-
handleSubmitEffect: D
|
|
176
|
-
}), x = q(
|
|
177
|
-
i.store,
|
|
178
|
-
(e) => e.submissionAttempts
|
|
179
|
-
), b = i.useStore((e) => e.errors);
|
|
180
|
-
Q(
|
|
181
|
-
() => [i.filterItems, b.value],
|
|
182
|
-
() => {
|
|
183
|
-
const e = i.filterItems, r = b.value;
|
|
184
|
-
return e ? r ? (Object.values(r).filter(
|
|
185
|
-
(s) => !!s
|
|
186
|
-
).flatMap(
|
|
187
|
-
(s) => Object.values(s).flat().map((n) => n.message)
|
|
188
|
-
).some((s) => s === e.message) && e.items.forEach((s) => {
|
|
189
|
-
const n = i.getFieldMeta(s);
|
|
190
|
-
n && i.setFieldMeta(s, {
|
|
191
|
-
...n,
|
|
192
|
-
errorMap: {
|
|
193
|
-
onSubmit: [
|
|
194
|
-
{ path: [s], message: e.message }
|
|
195
|
-
]
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}), {}) : {} : {};
|
|
199
|
-
}
|
|
200
|
-
);
|
|
201
|
-
const P = C(x, b, o?.showErrorsOn);
|
|
202
|
-
return o?.ignorePreventCloseEvents || X(() => i.useStore((e) => e.isDirty)), Object.assign(i, {
|
|
203
|
-
errorContext: P,
|
|
204
|
-
Form: p(i)(se),
|
|
205
|
-
Input: p(i)(o?.input ?? te),
|
|
206
|
-
Field: u.Field,
|
|
207
|
-
Errors: oe(P)(ee),
|
|
208
|
-
Array: p(i)(Y),
|
|
209
|
-
AutoGen: p(i)(Z)
|
|
1
|
+
import r from "./vue-components.es23.js";
|
|
2
|
+
import { inject as c, provide as l } from "vue";
|
|
3
|
+
import { onMountedWithCleanup as u } from "./vue-components.es12.js";
|
|
4
|
+
const f = () => r(), i = Symbol("DialogBus"), p = () => c(i, null), g = () => {
|
|
5
|
+
const e = f();
|
|
6
|
+
return l(i, e), e;
|
|
7
|
+
}, d = (e) => {
|
|
8
|
+
const o = p();
|
|
9
|
+
if (!o)
|
|
10
|
+
return;
|
|
11
|
+
const s = e();
|
|
12
|
+
u(() => {
|
|
13
|
+
const n = (t) => {
|
|
14
|
+
s.value && (confirm("Es sind ungespeicherte Änderungen vorhanden. Wirklich schließen?") || (t.prevent = !0));
|
|
15
|
+
};
|
|
16
|
+
return o.on("dialog-closing", n), () => o.off("dialog-closing", n);
|
|
210
17
|
});
|
|
18
|
+
}, h = (e) => {
|
|
19
|
+
const o = g();
|
|
20
|
+
return () => {
|
|
21
|
+
const n = {};
|
|
22
|
+
o.emit("dialog-closing", n), n.prevent ? typeof n.prevent == "object" && "then" in n.prevent && n.prevent.then((t) => {
|
|
23
|
+
t !== !1 && e();
|
|
24
|
+
}) : e();
|
|
25
|
+
};
|
|
211
26
|
};
|
|
212
27
|
export {
|
|
213
|
-
|
|
214
|
-
|
|
28
|
+
p as injectBus,
|
|
29
|
+
g as provideBus,
|
|
30
|
+
h as useOnClose,
|
|
31
|
+
d as usePreventClose
|
|
215
32
|
};
|