@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.
Files changed (34) hide show
  1. package/dist/types/components/OmegaForm/useOmegaForm.d.ts +1 -3
  2. package/dist/vue-components.es20.js +1 -1
  3. package/dist/vue-components.es24.js +3 -90
  4. package/dist/vue-components.es25.js +3 -11
  5. package/dist/vue-components.es27.js +11 -2
  6. package/dist/vue-components.es28.js +83 -108
  7. package/dist/vue-components.es29.js +25 -0
  8. package/dist/vue-components.es30.js +5 -4
  9. package/dist/vue-components.es31.js +23 -0
  10. package/dist/vue-components.es32.js +32 -0
  11. package/dist/vue-components.es33.js +24 -0
  12. package/dist/vue-components.es34.js +14 -0
  13. package/dist/vue-components.es35.js +7 -0
  14. package/dist/vue-components.es36.js +21 -0
  15. package/dist/vue-components.es37.js +11 -0
  16. package/dist/vue-components.es38.js +33 -0
  17. package/dist/vue-components.es39.js +50 -0
  18. package/dist/vue-components.es40.js +28 -0
  19. package/dist/vue-components.es41.js +67 -0
  20. package/dist/vue-components.es42.js +58 -0
  21. package/dist/vue-components.es43.js +19 -0
  22. package/dist/vue-components.es44.js +35 -0
  23. package/dist/vue-components.es45.js +31 -0
  24. package/dist/vue-components.es46.js +44 -0
  25. package/dist/vue-components.es47.js +4 -0
  26. package/dist/vue-components.es48.js +4 -0
  27. package/dist/vue-components.es49.js +46 -0
  28. package/dist/vue-components.es50.js +4 -0
  29. package/dist/vue-components.es51.js +117 -0
  30. package/dist/vue-components.es53.js +6 -0
  31. package/dist/vue-components.es7.js +1 -1
  32. package/dist/vue-components.es9.js +78 -71
  33. package/package.json +5 -4
  34. package/src/components/OmegaForm/useOmegaForm.ts +41 -32
@@ -1,38 +1,40 @@
1
- import { useForm as U } from "@tanstack/vue-form";
2
- import { S as F, Fiber as p, Effect as o } from "effect-app";
3
- import { runtimeFiberAsPromise as O } from "./vue-components.es22.js";
4
- import { isObject as I } from "./vue-components.es23.js";
5
- import { computed as b, onUnmounted as R, onMounted as A, onBeforeUnmount as D, provide as M } from "vue";
6
- import N from "./vue-components.es6.js";
7
- import { generateMetaFromSchema as J } from "./vue-components.es10.js";
8
- const K = Symbol("OmegaForm"), z = (f, i, a) => {
9
- if (!f) throw new Error("Schema is required");
10
- const g = F.standardSchemaV1(f), { filterItems: V, meta: u } = J(f), l = b(() => {
11
- if (a?.persistency?.id)
12
- return a.persistency.id;
13
- const e = window.location.pathname, r = Object.keys(u);
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
- }), E = () => {
17
+ }), L = () => {
16
18
  const e = new URLSearchParams(window.location.search);
17
- e.delete(l.value);
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] && I(r[t]) ? (e[t] || (e[t] = {}), S(e[t], r[t])) : e[t] = 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 = b(() => {
27
- if (i?.defaultValues && !a?.persistency?.overrideDefaultValues)
28
+ const P = g(() => {
29
+ if (i?.defaultValues && !n?.persistency?.overrideDefaultValues)
28
30
  return i?.defaultValues;
29
31
  let e;
30
- const r = a?.persistency;
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(l.value);
35
- E(), s && (e = JSON.parse(s));
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(l.value) || "{}"
49
+ t.getItem(o.value) || "{}"
48
50
  );
49
- t.removeItem(l.value), e = s;
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
- }), c = U({
62
+ }), U = (e, r) => e ? w.with(V.setSpan(w.active(), e), r) : r(), a = I({
61
63
  ...i,
62
64
  validators: {
63
- onSubmit: g,
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 p.isFiber(s) && p.isRuntimeFiber(s) ? O(s) : o.isEffect(s) ? o.runPromise(
74
+ return m.isFiber(s) && m.isRuntimeFiber(s) ? await A(s) : p.isEffect(s) ? await p.runPromise(
73
75
  s.pipe(
74
- r?.currentSpan ? o.withParentSpan(r.currentSpan) : (n) => n,
75
- o.flatMap((n) => p.join(n))
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
- }), j = () => {
81
- Object.keys(u).forEach((e) => {
82
- c.setFieldValue(e, void 0);
84
+ }), F = () => {
85
+ Object.keys(c).forEach((e) => {
86
+ a.setFieldValue(e, void 0);
83
87
  });
84
- }, w = (e) => e.reduce((r, t) => {
88
+ }, h = (e) => e.reduce((r, t) => {
85
89
  const s = t.split(".");
86
- return s.reduce((n, d, L) => (L === s.length - 1 ? n[d] = c.getFieldValue(t) : n[d] = n[d] ?? {}, n[d]), r), r;
87
- }, {}), h = (e) => {
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 w(e.keys);
94
+ return h(e.keys);
91
95
  if (Array.isArray(e.banKeys)) {
92
- const r = Object.keys(u).filter((t) => e.banKeys?.includes(t));
93
- return w(r);
96
+ const r = Object.keys(c).filter((t) => e.banKeys?.includes(t));
97
+ return h(r);
94
98
  }
95
- return c.store.state.values;
99
+ return a.store.state.values;
96
100
  }
97
- }, m = () => {
98
- const e = a?.persistency;
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 = h(e);
103
- return r.setItem(l.value, JSON.stringify(t));
106
+ const t = y(e);
107
+ return r.setItem(o.value, JSON.stringify(t));
104
108
  }
105
- }, y = () => {
106
- const e = a?.persistency;
109
+ }, v = () => {
110
+ const e = n?.persistency;
107
111
  if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
108
- const r = h(e), t = new URLSearchParams(window.location.search);
109
- t.set(l.value, JSON.stringify(r));
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
- R(m), A(() => {
115
- window.addEventListener("beforeunload", m), window.addEventListener("blur", y);
116
- }), D(() => {
117
- window.removeEventListener("beforeunload", m), window.removeEventListener("blur", y);
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 v = Object.assign(c, {
120
- meta: u,
121
- filterItems: V,
122
- clear: j,
123
- /** @experimental */
124
- handleSubmitEffect: (e) => o.currentSpan.pipe(
125
- o.orDie,
126
- o.flatMap(
127
- (r) => (
128
- // TODO: fix type of handleSubmit, TSubmitMeta is somehow async validator :D
129
- o.promise(() => c.handleSubmit({ currentSpan: r, ...e }))
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(K, v), Object.assign(v, {
135
- Input: N,
136
- Field: c.Field
141
+ return M(_, b), Object.assign(b, {
142
+ Input: q,
143
+ Field: a.Field
137
144
  });
138
145
  };
139
146
  export {
140
- K as OmegaFormKey,
141
- z as useOmegaForm
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.15",
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.7",
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
- const r = tanstackFormOptions.onSubmit!({
223
- formApi: formApi as OmegaFormApi<From, To>,
224
- meta,
225
- value: value as unknown as To
226
- })
227
- if (Fiber.isFiber(r) && Fiber.isRuntimeFiber(r)) {
228
- return runtimeFiberAsPromise(r)
229
- }
230
- if (Effect.isEffect(r)) {
231
- return Effect.runPromise(
232
- r.pipe(
233
- meta?.currentSpan
234
- ? Effect.withParentSpan(meta.currentSpan)
235
- : (_) => _,
236
- Effect.flatMap((_) => Fiber.join(_))
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
- return r
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
- /** @experimental */
327
- handleSubmitEffect: (meta?: Record<string, any>) =>
328
- Effect.currentSpan.pipe(
329
- Effect.orDie,
330
- Effect
331
- .flatMap((span) =>
332
- // TODO: fix type of handleSubmit, TSubmitMeta is somehow async validator :D
333
- Effect.promise(() => form.handleSubmit({ currentSpan: span, ...meta }))
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)