@effect-app/vue-components 0.26.0 → 0.27.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/vue-components.es20.js +1 -1
- package/dist/vue-components.es24.js +1 -1
- package/dist/vue-components.es25.js +1 -1
- package/dist/vue-components.es27.js +22 -10
- package/dist/vue-components.es28.js +5 -90
- package/dist/vue-components.es29.js +18 -20
- package/dist/vue-components.es30.js +30 -5
- package/dist/vue-components.es31.js +17 -16
- package/dist/vue-components.es32.js +7 -25
- package/dist/vue-components.es33.js +5 -22
- package/dist/vue-components.es34.js +19 -12
- package/dist/vue-components.es35.js +9 -5
- package/dist/vue-components.es36.js +31 -19
- package/dist/vue-components.es37.js +48 -9
- package/dist/vue-components.es38.js +20 -25
- package/dist/vue-components.es39.js +11 -48
- package/dist/vue-components.es40.js +90 -26
- package/dist/vue-components.es41.js +65 -2
- package/dist/vue-components.es42.js +45 -54
- package/dist/vue-components.es43.js +15 -54
- package/dist/vue-components.es44.js +31 -15
- package/dist/vue-components.es45.js +26 -30
- package/dist/vue-components.es46.js +42 -29
- package/dist/vue-components.es47.js +2 -42
- package/dist/vue-components.es7.js +1 -1
- package/dist/vue-components.es9.js +65 -65
- package/package.json +2 -2
- package/src/components/OmegaForm/useOmegaForm.ts +4 -1
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { useForm as
|
|
2
|
-
import { S as
|
|
3
|
-
import { runtimeFiberAsPromise as
|
|
4
|
-
import { isObject as
|
|
5
|
-
import { computed as
|
|
6
|
-
import
|
|
7
|
-
import { generateMetaFromSchema as
|
|
8
|
-
import { trace as
|
|
1
|
+
import { useForm as A } from "@tanstack/vue-form";
|
|
2
|
+
import { S as g, Effect as f, Fiber as p } from "effect-app";
|
|
3
|
+
import { runtimeFiberAsPromise as D } from "./vue-components.es22.js";
|
|
4
|
+
import { isObject as J } from "./vue-components.es23.js";
|
|
5
|
+
import { computed as V, onUnmounted as K, onMounted as M, onBeforeUnmount as q, provide as x } from "vue";
|
|
6
|
+
import _ from "./vue-components.es6.js";
|
|
7
|
+
import { generateMetaFromSchema as $ } from "./vue-components.es10.js";
|
|
8
|
+
import { trace as P } from "./vue-components.es24.js";
|
|
9
9
|
import { context as w } from "./vue-components.es25.js";
|
|
10
|
-
const
|
|
11
|
-
if (!
|
|
12
|
-
const j =
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
15
|
-
const e = window.location.pathname, r = Object.keys(
|
|
10
|
+
const B = Symbol("OmegaForm"), Z = (u, n, o) => {
|
|
11
|
+
if (!u) throw new Error("Schema is required");
|
|
12
|
+
const j = g.standardSchemaV1(u), E = g.decode(u), { filterItems: L, meta: d } = $(u), a = V(() => {
|
|
13
|
+
if (o?.persistency?.id)
|
|
14
|
+
return o.persistency.id;
|
|
15
|
+
const e = window.location.pathname, r = Object.keys(d);
|
|
16
16
|
return `${e}-${r.join("-")}`;
|
|
17
|
-
}),
|
|
17
|
+
}), U = () => {
|
|
18
18
|
const e = new URLSearchParams(window.location.search);
|
|
19
|
-
e.delete(
|
|
19
|
+
e.delete(a.value);
|
|
20
20
|
const r = new URL(window.location.href);
|
|
21
21
|
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
22
22
|
};
|
|
23
23
|
function S(e, r) {
|
|
24
24
|
for (const t in r)
|
|
25
|
-
r[t] &&
|
|
25
|
+
r[t] && J(r[t]) ? (e[t] || (e[t] = {}), S(e[t], r[t])) : e[t] = r[t];
|
|
26
26
|
return e;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
return
|
|
28
|
+
const F = V(() => {
|
|
29
|
+
if (n?.defaultValues && !o?.persistency?.overrideDefaultValues)
|
|
30
|
+
return n?.defaultValues;
|
|
31
31
|
let e;
|
|
32
|
-
const r =
|
|
32
|
+
const r = o?.persistency;
|
|
33
33
|
if (!r?.policies || r.policies.length === 0) return {};
|
|
34
34
|
if (r.policies.includes("querystring"))
|
|
35
35
|
try {
|
|
36
|
-
const s = new URLSearchParams(window.location.search).get(
|
|
37
|
-
|
|
36
|
+
const s = new URLSearchParams(window.location.search).get(a.value);
|
|
37
|
+
U(), s && (e = JSON.parse(s));
|
|
38
38
|
} catch (t) {
|
|
39
39
|
console.error(t);
|
|
40
40
|
}
|
|
@@ -46,88 +46,88 @@ const $ = Symbol("OmegaForm"), Y = (d, i, n) => {
|
|
|
46
46
|
if (t)
|
|
47
47
|
try {
|
|
48
48
|
const s = JSON.parse(
|
|
49
|
-
t.getItem(
|
|
49
|
+
t.getItem(a.value) || "{}"
|
|
50
50
|
);
|
|
51
|
-
t.removeItem(
|
|
51
|
+
t.removeItem(a.value), e = s;
|
|
52
52
|
} catch (s) {
|
|
53
53
|
console.error(s);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
if (e ??= {},
|
|
56
|
+
if (e ??= {}, n?.defaultValues == null)
|
|
57
57
|
return e;
|
|
58
58
|
{
|
|
59
|
-
const t =
|
|
59
|
+
const t = n?.defaultValues;
|
|
60
60
|
return S(t, e);
|
|
61
61
|
}
|
|
62
|
-
}),
|
|
63
|
-
...
|
|
62
|
+
}), N = (e, r) => e ? w.with(P.setSpan(w.active(), e), r) : r(), c = A({
|
|
63
|
+
...n,
|
|
64
64
|
validators: {
|
|
65
65
|
onSubmit: j,
|
|
66
|
-
...
|
|
66
|
+
...n?.validators || {}
|
|
67
67
|
},
|
|
68
|
-
onSubmit:
|
|
69
|
-
const s = i.onSubmit({
|
|
68
|
+
onSubmit: n?.onSubmit ? ({ formApi: e, meta: r, value: t }) => N(r?.currentSpan, async () => {
|
|
69
|
+
const s = await f.runPromise(E(t)), i = n.onSubmit({
|
|
70
70
|
formApi: e,
|
|
71
71
|
meta: r,
|
|
72
|
-
value:
|
|
72
|
+
value: s
|
|
73
73
|
});
|
|
74
|
-
return
|
|
75
|
-
|
|
74
|
+
return p.isFiber(i) && p.isRuntimeFiber(i) ? await D(i) : f.isEffect(i) ? await f.runPromise(
|
|
75
|
+
i.pipe(
|
|
76
76
|
// meta?.currentSpan
|
|
77
77
|
// ? Effect.withParentSpan(meta.currentSpan)
|
|
78
78
|
// : (_) => _,
|
|
79
|
-
|
|
79
|
+
f.flatMap((l) => p.join(l))
|
|
80
80
|
)
|
|
81
|
-
) :
|
|
81
|
+
) : i;
|
|
82
82
|
}) : void 0,
|
|
83
|
-
defaultValues:
|
|
84
|
-
}),
|
|
85
|
-
Object.keys(
|
|
86
|
-
|
|
83
|
+
defaultValues: F.value
|
|
84
|
+
}), O = () => {
|
|
85
|
+
Object.keys(d).forEach((e) => {
|
|
86
|
+
c.setFieldValue(e, void 0);
|
|
87
87
|
});
|
|
88
88
|
}, h = (e) => e.reduce((r, t) => {
|
|
89
89
|
const s = t.split(".");
|
|
90
|
-
return s.reduce((
|
|
90
|
+
return s.reduce((i, l, R) => (R === s.length - 1 ? i[l] = c.getFieldValue(t) : i[l] = i[l] ?? {}, i[l]), r), r;
|
|
91
91
|
}, {}), y = (e) => {
|
|
92
92
|
if (e) {
|
|
93
93
|
if (Array.isArray(e.keys))
|
|
94
94
|
return h(e.keys);
|
|
95
95
|
if (Array.isArray(e.banKeys)) {
|
|
96
|
-
const r = Object.keys(
|
|
96
|
+
const r = Object.keys(d).filter((t) => e.banKeys?.includes(t));
|
|
97
97
|
return h(r);
|
|
98
98
|
}
|
|
99
|
-
return
|
|
99
|
+
return c.store.state.values;
|
|
100
100
|
}
|
|
101
|
-
},
|
|
102
|
-
const e =
|
|
101
|
+
}, m = () => {
|
|
102
|
+
const e = o?.persistency;
|
|
103
103
|
if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
104
104
|
const r = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
105
105
|
if (!r) return;
|
|
106
106
|
const t = y(e);
|
|
107
|
-
return r.setItem(
|
|
107
|
+
return r.setItem(a.value, JSON.stringify(t));
|
|
108
108
|
}
|
|
109
109
|
}, v = () => {
|
|
110
|
-
const e =
|
|
110
|
+
const e = o?.persistency;
|
|
111
111
|
if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
112
112
|
const r = y(e), t = new URLSearchParams(window.location.search);
|
|
113
|
-
t.set(
|
|
113
|
+
t.set(a.value, JSON.stringify(r));
|
|
114
114
|
const s = new URL(window.location.href);
|
|
115
115
|
s.search = t.toString(), window.history.replaceState({}, "", s.toString());
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
|
|
119
|
-
window.addEventListener("beforeunload",
|
|
120
|
-
}),
|
|
121
|
-
window.removeEventListener("beforeunload",
|
|
118
|
+
K(m), M(() => {
|
|
119
|
+
window.addEventListener("beforeunload", m), window.addEventListener("blur", v);
|
|
120
|
+
}), q(() => {
|
|
121
|
+
window.removeEventListener("beforeunload", m), window.removeEventListener("blur", v);
|
|
122
122
|
});
|
|
123
|
-
const
|
|
124
|
-
i18nNamespace:
|
|
125
|
-
meta:
|
|
126
|
-
filterItems:
|
|
127
|
-
clear:
|
|
123
|
+
const I = c.handleSubmit, b = Object.assign(c, {
|
|
124
|
+
i18nNamespace: o?.i18nNamespace,
|
|
125
|
+
meta: d,
|
|
126
|
+
filterItems: L,
|
|
127
|
+
clear: O,
|
|
128
128
|
handleSubmit: (e) => {
|
|
129
|
-
const r =
|
|
130
|
-
return
|
|
129
|
+
const r = P.getSpan(w.active());
|
|
130
|
+
return I({ currentSpan: r, ...e });
|
|
131
131
|
}
|
|
132
132
|
// /** @experimental */
|
|
133
133
|
// handleSubmitEffect: (meta?: Record<string, any>) =>
|
|
@@ -139,12 +139,12 @@ const $ = Symbol("OmegaForm"), Y = (d, i, n) => {
|
|
|
139
139
|
// )
|
|
140
140
|
// )
|
|
141
141
|
});
|
|
142
|
-
return
|
|
143
|
-
Input:
|
|
144
|
-
Field:
|
|
142
|
+
return x(B, b), Object.assign(b, {
|
|
143
|
+
Input: _,
|
|
144
|
+
Field: c.Field
|
|
145
145
|
});
|
|
146
146
|
};
|
|
147
147
|
export {
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
B as OmegaFormKey,
|
|
149
|
+
Z as useOmegaForm
|
|
150
150
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"effect": "^3.17.13",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"vitepress": "^1.6.4",
|
|
30
30
|
"vitest": "^3.2.4",
|
|
31
31
|
"vue-tsc": "^3.0.7",
|
|
32
|
-
"@effect-app/eslint-shared-config": "0.2.
|
|
32
|
+
"@effect-app/eslint-shared-config": "0.2.1"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"src",
|
|
@@ -106,6 +106,7 @@ export const useOmegaForm = <
|
|
|
106
106
|
): OmegaFormReturn<From, To> => {
|
|
107
107
|
if (!schema) throw new Error("Schema is required")
|
|
108
108
|
const standardSchema = S.standardSchemaV1(schema)
|
|
109
|
+
const decode = S.decode(schema)
|
|
109
110
|
|
|
110
111
|
const { filterItems, meta } = generateMetaFromSchema(schema)
|
|
111
112
|
|
|
@@ -231,10 +232,12 @@ export const useOmegaForm = <
|
|
|
231
232
|
onSubmit: tanstackFormOptions?.onSubmit
|
|
232
233
|
? ({ formApi, meta, value }) =>
|
|
233
234
|
wrapWithSpan(meta?.currentSpan, async () => {
|
|
235
|
+
// validators only validate, they don't actually transform, so we have to do that manually here.
|
|
236
|
+
const parsedValue = await Effect.runPromise(decode(value))
|
|
234
237
|
const r = tanstackFormOptions.onSubmit!({
|
|
235
238
|
formApi: formApi as OmegaFormApi<From, To>,
|
|
236
239
|
meta,
|
|
237
|
-
value:
|
|
240
|
+
value: parsedValue
|
|
238
241
|
})
|
|
239
242
|
if (Fiber.isFiber(r) && Fiber.isRuntimeFiber(r)) {
|
|
240
243
|
return await runtimeFiberAsPromise(r)
|