@effect-app/vue-components 0.18.15 → 0.18.17
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/useOmegaForm.d.ts +1 -3
- package/dist/vue-components.es20.js +1 -1
- package/dist/vue-components.es24.js +3 -90
- package/dist/vue-components.es25.js +3 -11
- package/dist/vue-components.es27.js +11 -2
- package/dist/vue-components.es28.js +83 -108
- package/dist/vue-components.es29.js +25 -0
- package/dist/vue-components.es30.js +5 -4
- package/dist/vue-components.es31.js +23 -0
- package/dist/vue-components.es32.js +32 -0
- package/dist/vue-components.es33.js +24 -0
- package/dist/vue-components.es34.js +14 -0
- package/dist/vue-components.es35.js +7 -0
- package/dist/vue-components.es36.js +21 -0
- package/dist/vue-components.es37.js +11 -0
- package/dist/vue-components.es38.js +33 -0
- package/dist/vue-components.es39.js +50 -0
- package/dist/vue-components.es40.js +28 -0
- package/dist/vue-components.es41.js +67 -0
- package/dist/vue-components.es42.js +58 -0
- package/dist/vue-components.es43.js +19 -0
- package/dist/vue-components.es44.js +35 -0
- package/dist/vue-components.es45.js +31 -0
- package/dist/vue-components.es46.js +44 -0
- package/dist/vue-components.es47.js +4 -0
- package/dist/vue-components.es48.js +4 -0
- package/dist/vue-components.es49.js +46 -0
- package/dist/vue-components.es50.js +4 -0
- package/dist/vue-components.es51.js +117 -0
- package/dist/vue-components.es53.js +6 -0
- package/dist/vue-components.es7.js +1 -1
- package/dist/vue-components.es9.js +78 -71
- package/package.json +5 -4
- package/src/components/OmegaForm/useOmegaForm.ts +41 -32
|
@@ -1,38 +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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { useForm as I } from "@tanstack/vue-form";
|
|
2
|
+
import { S as R, Fiber as m, Effect as p } from "effect-app";
|
|
3
|
+
import { runtimeFiberAsPromise as A } from "./vue-components.es22.js";
|
|
4
|
+
import { isObject as N } from "./vue-components.es23.js";
|
|
5
|
+
import { computed as g, onUnmounted as D, onMounted as J, onBeforeUnmount as K, provide as M } from "vue";
|
|
6
|
+
import q from "./vue-components.es6.js";
|
|
7
|
+
import { generateMetaFromSchema as x } from "./vue-components.es10.js";
|
|
8
|
+
import { trace as V } from "./vue-components.es24.js";
|
|
9
|
+
import { context as w } from "./vue-components.es25.js";
|
|
10
|
+
const _ = Symbol("OmegaForm"), X = (d, i, n) => {
|
|
11
|
+
if (!d) throw new Error("Schema is required");
|
|
12
|
+
const j = R.standardSchemaV1(d), { filterItems: E, meta: c } = x(d), o = g(() => {
|
|
13
|
+
if (n?.persistency?.id)
|
|
14
|
+
return n.persistency.id;
|
|
15
|
+
const e = window.location.pathname, r = Object.keys(c);
|
|
14
16
|
return `${e}-${r.join("-")}`;
|
|
15
|
-
}),
|
|
17
|
+
}), L = () => {
|
|
16
18
|
const e = new URLSearchParams(window.location.search);
|
|
17
|
-
e.delete(
|
|
19
|
+
e.delete(o.value);
|
|
18
20
|
const r = new URL(window.location.href);
|
|
19
21
|
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
20
22
|
};
|
|
21
23
|
function S(e, r) {
|
|
22
24
|
for (const t in r)
|
|
23
|
-
r[t] &&
|
|
25
|
+
r[t] && N(r[t]) ? (e[t] || (e[t] = {}), S(e[t], r[t])) : e[t] = r[t];
|
|
24
26
|
return e;
|
|
25
27
|
}
|
|
26
|
-
const P =
|
|
27
|
-
if (i?.defaultValues && !
|
|
28
|
+
const P = g(() => {
|
|
29
|
+
if (i?.defaultValues && !n?.persistency?.overrideDefaultValues)
|
|
28
30
|
return i?.defaultValues;
|
|
29
31
|
let e;
|
|
30
|
-
const r =
|
|
32
|
+
const r = n?.persistency;
|
|
31
33
|
if (!r?.policies || r.policies.length === 0) return {};
|
|
32
34
|
if (r.policies.includes("querystring"))
|
|
33
35
|
try {
|
|
34
|
-
const s = new URLSearchParams(window.location.search).get(
|
|
35
|
-
|
|
36
|
+
const s = new URLSearchParams(window.location.search).get(o.value);
|
|
37
|
+
L(), s && (e = JSON.parse(s));
|
|
36
38
|
} catch (t) {
|
|
37
39
|
console.error(t);
|
|
38
40
|
}
|
|
@@ -44,9 +46,9 @@ const K = Symbol("OmegaForm"), z = (f, i, a) => {
|
|
|
44
46
|
if (t)
|
|
45
47
|
try {
|
|
46
48
|
const s = JSON.parse(
|
|
47
|
-
t.getItem(
|
|
49
|
+
t.getItem(o.value) || "{}"
|
|
48
50
|
);
|
|
49
|
-
t.removeItem(
|
|
51
|
+
t.removeItem(o.value), e = s;
|
|
50
52
|
} catch (s) {
|
|
51
53
|
console.error(s);
|
|
52
54
|
}
|
|
@@ -57,86 +59,91 @@ const K = Symbol("OmegaForm"), z = (f, i, a) => {
|
|
|
57
59
|
const t = i?.defaultValues;
|
|
58
60
|
return S(t, e);
|
|
59
61
|
}
|
|
60
|
-
}),
|
|
62
|
+
}), U = (e, r) => e ? w.with(V.setSpan(w.active(), e), r) : r(), a = I({
|
|
61
63
|
...i,
|
|
62
64
|
validators: {
|
|
63
|
-
onSubmit:
|
|
65
|
+
onSubmit: j,
|
|
64
66
|
...i?.validators || {}
|
|
65
67
|
},
|
|
66
|
-
onSubmit: i?.onSubmit ? ({ formApi: e, meta: r, value: t }) => {
|
|
68
|
+
onSubmit: i?.onSubmit ? ({ formApi: e, meta: r, value: t }) => U(r?.span, async () => {
|
|
67
69
|
const s = i.onSubmit({
|
|
68
70
|
formApi: e,
|
|
69
71
|
meta: r,
|
|
70
72
|
value: t
|
|
71
73
|
});
|
|
72
|
-
return
|
|
74
|
+
return m.isFiber(s) && m.isRuntimeFiber(s) ? await A(s) : p.isEffect(s) ? await p.runPromise(
|
|
73
75
|
s.pipe(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
// meta?.currentSpan
|
|
77
|
+
// ? Effect.withParentSpan(meta.currentSpan)
|
|
78
|
+
// : (_) => _,
|
|
79
|
+
p.flatMap((l) => m.join(l))
|
|
76
80
|
)
|
|
77
81
|
) : s;
|
|
78
|
-
} : void 0,
|
|
82
|
+
}) : void 0,
|
|
79
83
|
defaultValues: P.value
|
|
80
|
-
}),
|
|
81
|
-
Object.keys(
|
|
82
|
-
|
|
84
|
+
}), F = () => {
|
|
85
|
+
Object.keys(c).forEach((e) => {
|
|
86
|
+
a.setFieldValue(e, void 0);
|
|
83
87
|
});
|
|
84
|
-
},
|
|
88
|
+
}, h = (e) => e.reduce((r, t) => {
|
|
85
89
|
const s = t.split(".");
|
|
86
|
-
return s.reduce((
|
|
87
|
-
}, {}),
|
|
90
|
+
return s.reduce((l, u, O) => (O === s.length - 1 ? l[u] = a.getFieldValue(t) : l[u] = l[u] ?? {}, l[u]), r), r;
|
|
91
|
+
}, {}), y = (e) => {
|
|
88
92
|
if (e) {
|
|
89
93
|
if (Array.isArray(e.keys))
|
|
90
|
-
return
|
|
94
|
+
return h(e.keys);
|
|
91
95
|
if (Array.isArray(e.banKeys)) {
|
|
92
|
-
const r = Object.keys(
|
|
93
|
-
return
|
|
96
|
+
const r = Object.keys(c).filter((t) => e.banKeys?.includes(t));
|
|
97
|
+
return h(r);
|
|
94
98
|
}
|
|
95
|
-
return
|
|
99
|
+
return a.store.state.values;
|
|
96
100
|
}
|
|
97
|
-
},
|
|
98
|
-
const e =
|
|
101
|
+
}, f = () => {
|
|
102
|
+
const e = n?.persistency;
|
|
99
103
|
if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
100
104
|
const r = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
101
105
|
if (!r) return;
|
|
102
|
-
const t =
|
|
103
|
-
return r.setItem(
|
|
106
|
+
const t = y(e);
|
|
107
|
+
return r.setItem(o.value, JSON.stringify(t));
|
|
104
108
|
}
|
|
105
|
-
},
|
|
106
|
-
const e =
|
|
109
|
+
}, v = () => {
|
|
110
|
+
const e = n?.persistency;
|
|
107
111
|
if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
108
|
-
const r =
|
|
109
|
-
t.set(
|
|
112
|
+
const r = y(e), t = new URLSearchParams(window.location.search);
|
|
113
|
+
t.set(o.value, JSON.stringify(r));
|
|
110
114
|
const s = new URL(window.location.href);
|
|
111
115
|
s.search = t.toString(), window.history.replaceState({}, "", s.toString());
|
|
112
116
|
}
|
|
113
117
|
};
|
|
114
|
-
|
|
115
|
-
window.addEventListener("beforeunload",
|
|
116
|
-
}),
|
|
117
|
-
window.removeEventListener("beforeunload",
|
|
118
|
+
D(f), J(() => {
|
|
119
|
+
window.addEventListener("beforeunload", f), window.addEventListener("blur", v);
|
|
120
|
+
}), K(() => {
|
|
121
|
+
window.removeEventListener("beforeunload", f), window.removeEventListener("blur", v);
|
|
118
122
|
});
|
|
119
|
-
const
|
|
120
|
-
meta:
|
|
121
|
-
filterItems:
|
|
122
|
-
clear:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
)
|
|
123
|
+
const b = Object.assign(a, {
|
|
124
|
+
meta: c,
|
|
125
|
+
filterItems: E,
|
|
126
|
+
clear: F,
|
|
127
|
+
handleSubmit: () => {
|
|
128
|
+
const e = V.getSpan(w.active());
|
|
129
|
+
return a.handleSubmit({ currentSpan: e, ...c });
|
|
130
|
+
}
|
|
131
|
+
// /** @experimental */
|
|
132
|
+
// handleSubmitEffect: (meta?: Record<string, any>) =>
|
|
133
|
+
// Effect.currentSpan.pipe(
|
|
134
|
+
// Effect.option,
|
|
135
|
+
// Effect
|
|
136
|
+
// .flatMap((span) =>
|
|
137
|
+
// Effect.promise(() => form.handleSubmit(Option.isSome(span) ? { currentSpan: span.value, ...meta } : meta))
|
|
138
|
+
// )
|
|
139
|
+
// )
|
|
133
140
|
});
|
|
134
|
-
return M(
|
|
135
|
-
Input:
|
|
136
|
-
Field:
|
|
141
|
+
return M(_, b), Object.assign(b, {
|
|
142
|
+
Input: q,
|
|
143
|
+
Field: a.Field
|
|
137
144
|
});
|
|
138
145
|
};
|
|
139
146
|
export {
|
|
140
|
-
|
|
141
|
-
|
|
147
|
+
_ as OmegaFormKey,
|
|
148
|
+
X as useOmegaForm
|
|
142
149
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.17",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"@tanstack/vue-form": "1.2.4",
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
"vuetify": "^3.9.7"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
+
"@ben_12/eslint-plugin-dprint": "^1.7.5",
|
|
17
18
|
"@dprint/typescript": "^0.95.11",
|
|
18
|
-
"@ben_12/eslint-plugin-dprint": "^1.7.4",
|
|
19
|
-
"dprint": "^0.50.1",
|
|
20
19
|
"@storybook/vue3": "^9.1.5",
|
|
21
20
|
"@storybook/vue3-vite": "^9.1.5",
|
|
22
21
|
"@types/node": "^24.3.1",
|
|
@@ -26,6 +25,7 @@
|
|
|
26
25
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
27
26
|
"@vue/eslint-config-typescript": "^14.6.0",
|
|
28
27
|
"@vue/test-utils": "^2.4.6",
|
|
28
|
+
"dprint": "^0.50.1",
|
|
29
29
|
"eslint-plugin-prettier": "^5.5.4",
|
|
30
30
|
"eslint-plugin-vue": "^10.4.0",
|
|
31
31
|
"jsdom": "^26.1.0",
|
|
@@ -51,9 +51,10 @@
|
|
|
51
51
|
"./dist/vue-components.css": "./dist/vue-components.css"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
+
"@opentelemetry/api": "^1.9.0",
|
|
54
55
|
"highlight.js": "^11.11.1",
|
|
55
56
|
"vue3-highlightjs": "^1.0.5",
|
|
56
|
-
"@effect-app/vue": "2.55.
|
|
57
|
+
"@effect-app/vue": "2.55.9",
|
|
57
58
|
"effect-app": "3.3.4"
|
|
58
59
|
},
|
|
59
60
|
"scripts": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/consistent-type-imports */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
3
|
|
|
4
|
+
import * as api from "@opentelemetry/api"
|
|
4
5
|
import { type DeepKeys, type FormAsyncValidateOrFn, type FormValidateOrFn, type StandardSchemaV1, useForm } from "@tanstack/vue-form"
|
|
5
6
|
import { Effect, Fiber, S } from "effect-app"
|
|
6
7
|
import { runtimeFiberAsPromise } from "effect-app/utils"
|
|
@@ -35,8 +36,8 @@ export type OmegaConfig<T> = {
|
|
|
35
36
|
interface OF<From, To> extends OmegaFormApi<From, To> {
|
|
36
37
|
meta: MetaRecord<From>
|
|
37
38
|
filterItems?: FilterItems
|
|
38
|
-
/** @experimental */
|
|
39
|
-
handleSubmitEffect: (meta?: Record<string, any>) => Effect.Effect<void, never, never>
|
|
39
|
+
// /** @experimental */
|
|
40
|
+
// handleSubmitEffect: (meta?: Record<string, any>) => Effect.Effect<void, never, never>
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
export const OmegaFormKey = Symbol("OmegaForm") as InjectionKey<OF<any, any>>
|
|
@@ -200,6 +201,10 @@ export const useOmegaForm = <
|
|
|
200
201
|
}
|
|
201
202
|
})
|
|
202
203
|
|
|
204
|
+
const wrapWithSpan = (span: api.Span | undefined, toWrap: () => any) => {
|
|
205
|
+
return span ? api.context.with(api.trace.setSpan(api.context.active(), span), toWrap) : toWrap()
|
|
206
|
+
}
|
|
207
|
+
|
|
203
208
|
const form = useForm<
|
|
204
209
|
From,
|
|
205
210
|
FormValidateOrFn<From> | undefined,
|
|
@@ -218,27 +223,28 @@ export const useOmegaForm = <
|
|
|
218
223
|
...(tanstackFormOptions?.validators || {})
|
|
219
224
|
},
|
|
220
225
|
onSubmit: tanstackFormOptions?.onSubmit
|
|
221
|
-
? ({ formApi, meta, value }) =>
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
226
|
+
? ({ formApi, meta, value }) =>
|
|
227
|
+
wrapWithSpan(meta?.span, async () => {
|
|
228
|
+
const r = tanstackFormOptions.onSubmit!({
|
|
229
|
+
formApi: formApi as OmegaFormApi<From, To>,
|
|
230
|
+
meta,
|
|
231
|
+
value: value as unknown as To
|
|
232
|
+
})
|
|
233
|
+
if (Fiber.isFiber(r) && Fiber.isRuntimeFiber(r)) {
|
|
234
|
+
return await runtimeFiberAsPromise(r)
|
|
235
|
+
}
|
|
236
|
+
if (Effect.isEffect(r)) {
|
|
237
|
+
return await Effect.runPromise(
|
|
238
|
+
r.pipe(
|
|
239
|
+
// meta?.currentSpan
|
|
240
|
+
// ? Effect.withParentSpan(meta.currentSpan)
|
|
241
|
+
// : (_) => _,
|
|
242
|
+
Effect.flatMap((_) => Fiber.join(_))
|
|
243
|
+
)
|
|
237
244
|
)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
245
|
+
}
|
|
246
|
+
return r
|
|
247
|
+
})
|
|
242
248
|
: undefined,
|
|
243
249
|
defaultValues: defaultValues.value as any
|
|
244
250
|
}) satisfies OmegaFormApi<To, From>
|
|
@@ -323,16 +329,19 @@ export const useOmegaForm = <
|
|
|
323
329
|
meta,
|
|
324
330
|
filterItems,
|
|
325
331
|
clear,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
332
|
+
handleSubmit: () => {
|
|
333
|
+
const span = api.trace.getSpan(api.context.active())
|
|
334
|
+
return form.handleSubmit({ currentSpan: span, ...meta })
|
|
335
|
+
}
|
|
336
|
+
// /** @experimental */
|
|
337
|
+
// handleSubmitEffect: (meta?: Record<string, any>) =>
|
|
338
|
+
// Effect.currentSpan.pipe(
|
|
339
|
+
// Effect.option,
|
|
340
|
+
// Effect
|
|
341
|
+
// .flatMap((span) =>
|
|
342
|
+
// Effect.promise(() => form.handleSubmit(Option.isSome(span) ? { currentSpan: span.value, ...meta } : meta))
|
|
343
|
+
// )
|
|
344
|
+
// )
|
|
336
345
|
})
|
|
337
346
|
|
|
338
347
|
provide(OmegaFormKey, formWithExtras)
|