@effect-app/vue-components 2.9.2 → 2.10.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.
Files changed (54) hide show
  1. package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +2 -0
  2. package/dist/types/components/OmegaForm/useOmegaForm.d.ts +1 -0
  3. package/dist/vue-components.es.js +17 -15
  4. package/dist/vue-components.es10.js +91 -93
  5. package/dist/vue-components.es12.js +282 -204
  6. package/dist/vue-components.es16.js +4 -10
  7. package/dist/vue-components.es17.js +10 -97
  8. package/dist/vue-components.es2.js +29 -27
  9. package/dist/vue-components.es20.js +2 -2
  10. package/dist/vue-components.es21.js +2 -2
  11. package/dist/vue-components.es22.js +1 -1
  12. package/dist/vue-components.es23.js +1 -1
  13. package/dist/vue-components.es30.js +191 -41
  14. package/dist/vue-components.es32.js +42 -2
  15. package/dist/vue-components.es33.js +1 -1
  16. package/dist/vue-components.es34.js +2 -111
  17. package/dist/vue-components.es35.js +113 -0
  18. package/dist/vue-components.es37.js +7 -32
  19. package/dist/vue-components.es38.js +34 -0
  20. package/dist/vue-components.es40.js +6 -0
  21. package/dist/vue-components.es41.js +23 -4
  22. package/dist/vue-components.es42.js +5 -23
  23. package/dist/vue-components.es43.js +21 -5
  24. package/dist/vue-components.es44.js +25 -16
  25. package/dist/vue-components.es45.js +15 -23
  26. package/dist/vue-components.es46.js +7 -17
  27. package/dist/vue-components.es47.js +5 -12
  28. package/dist/vue-components.es48.js +19 -5
  29. package/dist/vue-components.es49.js +9 -19
  30. package/dist/vue-components.es50.js +31 -9
  31. package/dist/vue-components.es51.js +42 -25
  32. package/dist/vue-components.es52.js +16 -38
  33. package/dist/vue-components.es53.js +11 -26
  34. package/dist/vue-components.es54.js +65 -11
  35. package/dist/vue-components.es55.js +45 -54
  36. package/dist/vue-components.es56.js +15 -54
  37. package/dist/vue-components.es57.js +31 -15
  38. package/dist/vue-components.es58.js +26 -30
  39. package/dist/vue-components.es59.js +42 -29
  40. package/dist/vue-components.es60.js +2 -42
  41. package/dist/vue-components.es61.js +44 -2
  42. package/dist/vue-components.es62.js +2 -44
  43. package/dist/vue-components.es7.js +1 -1
  44. package/dist/vue-components.es9.js +10 -33
  45. package/package.json +1 -1
  46. package/src/components/OmegaForm/OmegaFormStuff.ts +174 -11
  47. package/src/components/OmegaForm/OmegaTaggedUnionInternal.vue +0 -48
  48. package/src/components/OmegaForm/useOmegaForm.ts +16 -8
  49. package/dist/types/components/OmegaForm/defaultAST.d.ts +0 -4
  50. package/dist/vue-components.es31.js +0 -6
  51. package/dist/vue-components.es36.js +0 -9
  52. package/dist/vue-components.es39.js +0 -194
  53. package/dist/vue-components.es63.js +0 -4
  54. package/src/components/OmegaForm/defaultAST.ts +0 -191
@@ -151,4 +151,6 @@ export type OmegaAutoGenMeta<From extends Record<PropertyKey, any>, To extends R
151
151
  declare const supportedInputs: readonly ["button", "checkbox", "color", "date", "email", "number", "password", "radio", "range", "search", "submit", "tel", "text", "time", "url"];
152
152
  export type SupportedInputs = typeof supportedInputs[number];
153
153
  export declare const getInputType: (input: string) => SupportedInputs;
154
+ export declare function deepMerge(target: any, source: any): any;
155
+ export declare const defaultsValueFromSchema: (schema: S.Schema<any>, record?: Record<string, any>) => any;
154
156
  export {};
@@ -46,6 +46,7 @@ export type OmegaConfig<T> = {
46
46
  */
47
47
  preventWindowExit?: "prevent" | "prevent-and-reset" | "nope";
48
48
  input?: any;
49
+ defaultFromSchema?: "only" | "nope" | "merge";
49
50
  };
50
51
  export interface OF<From, To> extends OmegaFormApi<From, To> {
51
52
  meta: MetaRecord<From>;
@@ -5,11 +5,11 @@ import { default as g } from "./vue-components.es5.js";
5
5
  import { default as I } from "./vue-components.es6.js";
6
6
  import { default as y } from "./vue-components.es7.js";
7
7
  import { default as h } from "./vue-components.es8.js";
8
- import { default as C } from "./vue-components.es9.js";
9
- import { useOmegaForm as T } from "./vue-components.es10.js";
10
- import { useOnClose as M, usePreventClose as j } from "./vue-components.es11.js";
11
- import { createMeta as P, duplicateSchema as k, generateInputStandardSchemaFromFieldMeta as w, generateMetaFromSchema as B, getInputType as D, isNullableOrUndefined as K, nullableInput as N } from "./vue-components.es12.js";
12
- import { createUseFormWithCustomInput as W } from "./vue-components.es13.js";
8
+ import { default as b } from "./vue-components.es9.js";
9
+ import { useOmegaForm as M } from "./vue-components.es10.js";
10
+ import { useOnClose as U, 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, nullableInput 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)) {
@@ -23,22 +23,24 @@ export {
23
23
  g as Dialog,
24
24
  I as OmegaInput,
25
25
  h as OmegaTaggedUnion,
26
- C as OmegaTaggedUnionInternal,
26
+ b as OmegaTaggedUnionInternal,
27
27
  y as OmegaVuetifyInput,
28
28
  P as createMeta,
29
- W as createUseFormWithCustomInput,
29
+ q as createUseFormWithCustomInput,
30
+ V as deepMerge,
30
31
  n as default,
31
- k as duplicateSchema,
32
- w as generateInputStandardSchemaFromFieldMeta,
33
- B as generateMetaFromSchema,
34
- D as getInputType,
32
+ k as defaultsValueFromSchema,
33
+ w as duplicateSchema,
34
+ B as generateInputStandardSchemaFromFieldMeta,
35
+ D as generateMetaFromSchema,
36
+ K as getInputType,
35
37
  f as getTransformationFrom,
36
- K as isNullableOrUndefined,
37
- N as nullableInput,
38
+ N as isNullableOrUndefined,
39
+ W as nullableInput,
38
40
  l as provideIntl,
39
41
  u as useIntl,
40
42
  s as useIntlKey,
41
- T as useOmegaForm,
42
- M as useOnClose,
43
+ M as useOmegaForm,
44
+ U as useOnClose,
43
45
  j as usePreventClose
44
46
  };
@@ -1,55 +1,54 @@
1
- import { useForm as q } from "@tanstack/vue-form";
2
- import { Data as B, S as D, Effect as c, Fiber as A, Option as P, Array as g } from "effect-app";
3
- import { runtimeFiberAsPromise as K } from "./vue-components.es16.js";
4
- import { computed as U, onUnmounted as N, onMounted as T, onBeforeUnmount as G, watch as W, ref as z, h as k } from "vue";
5
- import { deepMerge as O, extractSchemaDefaults as Q } from "./vue-components.es17.js";
1
+ import { useForm as B } from "@tanstack/vue-form";
2
+ import { Data as K, S as N, Effect as c, Fiber as V, Option as _, Array as F } from "effect-app";
3
+ import { runtimeFiberAsPromise as T } from "./vue-components.es17.js";
4
+ import { computed as L, onUnmounted as W, onMounted as G, onBeforeUnmount as z, watch as D, ref as Q, h as H } from "vue";
6
5
  import X from "./vue-components.es18.js";
7
6
  import Y from "./vue-components.es19.js";
8
7
  import Z from "./vue-components.es20.js";
9
- import { generateMetaFromSchema as C } from "./vue-components.es12.js";
8
+ import { generateMetaFromSchema as C, deepMerge as P, defaultsValueFromSchema as R } from "./vue-components.es12.js";
10
9
  import ee from "./vue-components.es6.js";
11
10
  import re from "./vue-components.es8.js";
12
11
  import te from "./vue-components.es21.js";
13
- import { trace as R } from "./vue-components.es22.js";
14
- import { context as L } from "./vue-components.es23.js";
15
- class se extends B.TaggedError("FormErrors") {
12
+ import { trace as k } from "./vue-components.es22.js";
13
+ import { context as x } from "./vue-components.es23.js";
14
+ class se extends K.TaggedError("FormErrors") {
16
15
  }
17
- const E = (l) => function(n) {
16
+ const E = (l) => function(s) {
18
17
  return {
19
18
  render() {
20
- return k(n, {
19
+ return H(s, {
21
20
  form: l,
22
21
  ...this.$attrs
23
22
  }, this.$slots);
24
23
  }
25
24
  };
26
- }, ne = (l) => function(n) {
25
+ }, ne = (l) => function(s) {
27
26
  return {
28
27
  setup() {
29
- const { fieldMap: w, form: v } = l, b = v.useStore((u) => u.errors), m = v.useStore((u) => u.fieldMeta), F = v.useStore((u) => u.errorMap), _ = U(() => {
30
- const u = g.filterMap(
28
+ const { fieldMap: w, form: v } = l, b = v.useStore((u) => u.errors), m = v.useStore((u) => u.fieldMeta), g = v.useStore((u) => u.errorMap), j = L(() => {
29
+ const u = F.filterMap(
31
30
  Object.entries(m.value),
32
31
  ([M, f]) => {
33
32
  const S = f.errors ?? [];
34
- if (!S.length) return P.none();
33
+ if (!S.length) return _.none();
35
34
  const a = w.value.get(M);
36
- return a ? P.some({
35
+ return a ? _.some({
37
36
  label: a.label,
38
37
  inputId: a.id,
39
38
  // Only show the first error
40
39
  errors: [S[0]?.message].filter(Boolean)
41
- }) : P.none();
40
+ }) : _.none();
42
41
  }
43
- ), o = [];
44
- if (F.value.onSubmit) {
45
- for (const [M, f] of Object.entries(F.value.onSubmit))
46
- if (g.isArray(f) && f.length)
42
+ ), n = [];
43
+ if (g.value.onSubmit) {
44
+ for (const [M, f] of Object.entries(g.value.onSubmit))
45
+ if (F.isArray(f) && f.length)
47
46
  for (const S of f) {
48
47
  const a = S;
49
- if (a?.path && g.isArray(a.path) && a.path.length) {
48
+ if (a?.path && F.isArray(a.path) && a.path.length) {
50
49
  const y = a.path.join(".");
51
50
  if (!w.value.has(y)) {
52
- o.push({
51
+ n.push({
53
52
  label: y,
54
53
  inputId: y,
55
54
  errors: [a.message].filter(Boolean)
@@ -59,154 +58,153 @@ const E = (l) => function(n) {
59
58
  }
60
59
  }
61
60
  }
62
- return [...u, ...o];
61
+ return [...u, ...n];
63
62
  });
64
63
  return {
65
64
  generalErrors: b,
66
- errors: _
65
+ errors: j
67
66
  };
68
67
  },
69
68
  render({ errors: w, generalErrors: v }) {
70
- return k(n, {
69
+ return H(s, {
71
70
  errors: w,
72
71
  generalErrors: v,
73
72
  ...this.$attrs
74
73
  }, this.$slots);
75
74
  }
76
75
  };
77
- }, be = (l, d, n) => {
76
+ }, we = (l, d, s) => {
78
77
  if (!l) throw new Error("Schema is required");
79
- const w = D.standardSchemaV1(l), v = D.decode(l), { meta: b } = C(l), m = U(() => {
80
- if (n?.persistency?.id)
81
- return n.persistency.id;
78
+ const w = N.standardSchemaV1(l), v = N.decode(l), { meta: b } = C(l), m = L(() => {
79
+ if (s?.persistency?.id)
80
+ return s.persistency.id;
82
81
  const e = window.location.pathname, r = Object.keys(b);
83
82
  return `${e}-${r.join("-")}`;
84
- }), F = () => {
83
+ }), g = () => {
85
84
  const e = new URLSearchParams(window.location.search);
86
85
  e.delete(m.value);
87
86
  const r = new URL(window.location.href);
88
87
  r.search = e.toString(), window.history.replaceState({}, "", r.toString());
89
- }, _ = U(() => {
88
+ }, j = L(() => {
90
89
  let e;
91
- const r = n?.persistency;
90
+ const r = s?.persistency;
92
91
  if (
93
92
  // query string has higher priority than local/session storage
94
93
  r?.policies && !e && (r.policies.includes("local") || r.policies.includes("session"))
95
94
  ) {
96
- const s = r.policies.includes("local") ? localStorage : sessionStorage;
97
- if (s)
95
+ const i = r.policies.includes("local") ? localStorage : sessionStorage;
96
+ if (i)
98
97
  try {
99
- const i = JSON.parse(
100
- s.getItem(m.value) || "{}"
98
+ const t = JSON.parse(
99
+ i.getItem(m.value) || "{}"
101
100
  );
102
- s.removeItem(m.value), e = i;
103
- } catch (i) {
104
- console.error(i);
101
+ i.removeItem(m.value), e = t;
102
+ } catch (t) {
103
+ console.error(t);
105
104
  }
106
105
  }
107
106
  if (r?.policies && r.policies.includes("querystring"))
108
107
  try {
109
- const i = new URLSearchParams(window.location.search).get(m.value);
110
- F(), i && (e = O(e || {}, JSON.parse(i)));
111
- } catch (s) {
112
- console.error(s);
108
+ const t = new URLSearchParams(window.location.search).get(m.value);
109
+ g(), t && (e = P(e || {}, JSON.parse(t)));
110
+ } catch (i) {
111
+ console.error(i);
113
112
  }
114
- return e ??= {}, Q(
115
- l,
116
- n?.persistency?.overrideDefaultValues ? O(d?.defaultValues || {}, e) : O(e, d?.defaultValues || {})
117
- );
118
- }), u = (e, r) => e ? L.with(R.setSpan(L.active(), e), r) : r(), o = q({
113
+ e ??= {};
114
+ const o = s?.defaultFromSchema === "only" ? R(l) : s?.defaultFromSchema === "nope" ? d?.defaultValues || {} : P(R(l), d?.defaultValues || {});
115
+ return s?.persistency?.overrideDefaultValues ? P(o, e) : P(e, o);
116
+ }), u = (e, r) => e ? x.with(k.setSpan(x.active(), e), r) : r(), n = B({
119
117
  ...d,
120
118
  validators: {
121
119
  onSubmit: w,
122
120
  ...d?.validators || {}
123
121
  },
124
- onSubmit: d?.onSubmit ? ({ formApi: e, meta: r, value: s }) => u(r?.currentSpan, async () => {
125
- const i = await c.runPromise(v(s)), t = d.onSubmit({
122
+ onSubmit: d?.onSubmit ? ({ formApi: e, meta: r, value: o }) => u(r?.currentSpan, async () => {
123
+ const i = await c.runPromise(v(o)), t = d.onSubmit({
126
124
  formApi: e,
127
125
  meta: r,
128
126
  value: i
129
127
  });
130
- return A.isFiber(t) && A.isRuntimeFiber(t) ? await K(t) : c.isEffect(t) ? await c.runPromise(
128
+ return V.isFiber(t) && V.isRuntimeFiber(t) ? await T(t) : c.isEffect(t) ? await c.runPromise(
131
129
  t.pipe(
132
130
  // meta?.currentSpan
133
131
  // ? Effect.withParentSpan(meta.currentSpan)
134
132
  // : (_) => _,
135
- c.flatMap((p) => A.join(p))
133
+ c.flatMap((p) => V.join(p))
136
134
  )
137
135
  ) : t;
138
136
  }) : void 0,
139
- defaultValues: _.value
137
+ defaultValues: j.value
140
138
  }), M = () => {
141
139
  Object.keys(b).forEach((e) => {
142
- o.setFieldValue(e, void 0);
140
+ n.setFieldValue(e, void 0);
143
141
  });
144
- }, f = (e) => e.reduce((r, s) => {
145
- const i = s.split(".");
146
- return i.reduce((t, p, x) => (x === i.length - 1 ? t[p] = o.getFieldValue(s) : t[p] = t[p] ?? {}, t[p]), r), r;
142
+ }, f = (e) => e.reduce((r, o) => {
143
+ const i = o.split(".");
144
+ return i.reduce((t, p, O) => (O === i.length - 1 ? t[p] = n.getFieldValue(o) : t[p] = t[p] ?? {}, t[p]), r), r;
147
145
  }, {}), S = (e) => {
148
146
  if (e) {
149
- if (g.isArray(e.keys))
147
+ if (F.isArray(e.keys))
150
148
  return f(e.keys);
151
- if (g.isArray(e.banKeys)) {
152
- const r = Object.keys(b).filter((s) => e.banKeys?.includes(s));
149
+ if (F.isArray(e.banKeys)) {
150
+ const r = Object.keys(b).filter((o) => e.banKeys?.includes(o));
153
151
  return f(r);
154
152
  }
155
- return o.store.state.values;
153
+ return n.store.state.values;
156
154
  }
157
155
  }, a = () => {
158
- const e = n?.persistency;
156
+ const e = s?.persistency;
159
157
  if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
160
158
  const r = e.policies.includes("local") ? localStorage : sessionStorage;
161
159
  if (!r) return;
162
- const s = S(e);
163
- return r.setItem(m.value, JSON.stringify(s));
160
+ const o = S(e);
161
+ return r.setItem(m.value, JSON.stringify(o));
164
162
  }
165
163
  }, y = () => {
166
- const e = n?.persistency;
164
+ const e = s?.persistency;
167
165
  if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
168
- const r = S(e), s = new URLSearchParams(window.location.search);
169
- s.set(m.value, JSON.stringify(r));
166
+ const r = S(e), o = new URLSearchParams(window.location.search);
167
+ o.set(m.value, JSON.stringify(r));
170
168
  const i = new URL(window.location.href);
171
- i.search = s.toString(), window.history.replaceState({}, "", i.toString());
169
+ i.search = o.toString(), window.history.replaceState({}, "", i.toString());
172
170
  }
173
- }, V = (e) => {
174
- o.store.state.isDirty && e.preventDefault();
171
+ }, U = (e) => {
172
+ n.store.state.isDirty && e.preventDefault();
175
173
  };
176
- if (N(a), T(() => {
177
- window.addEventListener("beforeunload", a), window.addEventListener("blur", y), n?.preventWindowExit && n.preventWindowExit !== "nope" && window.addEventListener("beforeunload", V);
178
- }), G(() => {
179
- window.removeEventListener("beforeunload", a), window.removeEventListener("blur", y), n?.preventWindowExit && n.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", V);
180
- }), n?.preventWindowExit === "prevent-and-reset") {
181
- const e = o.useStore((t) => t.isSubmitting), r = o.useStore((t) => t.submissionAttempts), s = o.useStore((t) => t.canSubmit), i = o.useStore((t) => t.values);
182
- W([e, r], ([t, p], [x]) => {
183
- x && !t && p > 0 && s.value && o.reset(i.value);
174
+ if (W(a), G(() => {
175
+ window.addEventListener("beforeunload", a), window.addEventListener("blur", y), s?.preventWindowExit && s.preventWindowExit !== "nope" && window.addEventListener("beforeunload", U);
176
+ }), z(() => {
177
+ window.removeEventListener("beforeunload", a), window.removeEventListener("blur", y), s?.preventWindowExit && s.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", U);
178
+ }), s?.preventWindowExit === "prevent-and-reset") {
179
+ const e = n.useStore((t) => t.isSubmitting), r = n.useStore((t) => t.submissionAttempts), o = n.useStore((t) => t.canSubmit), i = n.useStore((t) => t.values);
180
+ D([e, r], ([t, p], [O]) => {
181
+ O && !t && p > 0 && o.value && n.reset(i.value);
184
182
  });
185
183
  }
186
184
  const I = (e) => c.currentSpan.pipe(
187
185
  c.option,
188
186
  c.flatMap(
189
- (r) => c.promise(() => o.handleSubmit(P.isSome(r) ? { currentSpan: r.value, ...e } : e))
187
+ (r) => c.promise(() => n.handleSubmit(_.isSome(r) ? { currentSpan: r.value, ...e } : e))
190
188
  )
191
- ), H = (e) => e?.checkErrors ? I(e?.meta).pipe(c.flatMap(c.fnUntraced(function* () {
192
- const r = o.getAllErrors();
189
+ ), J = (e) => e?.checkErrors ? I(e?.meta).pipe(c.flatMap(c.fnUntraced(function* () {
190
+ const r = n.getAllErrors();
193
191
  if (Object.keys(r.fields).length || r.form.errors.length)
194
192
  return yield* new se({ form: r.form, fields: r.fields });
195
- }))) : I(e?.meta), J = o.handleSubmit, j = z(/* @__PURE__ */ new Map()), h = Object.assign(o, {
196
- i18nNamespace: n?.i18nNamespace,
197
- ignorePreventCloseEvents: n?.ignorePreventCloseEvents,
193
+ }))) : I(e?.meta), q = n.handleSubmit, A = Q(/* @__PURE__ */ new Map()), h = Object.assign(n, {
194
+ i18nNamespace: s?.i18nNamespace,
195
+ ignorePreventCloseEvents: s?.ignorePreventCloseEvents,
198
196
  meta: b,
199
197
  clear: M,
200
198
  handleSubmit: (e) => {
201
- const r = R.getSpan(L.active());
202
- return J({ currentSpan: r, ...e });
199
+ const r = k.getSpan(x.active());
200
+ return q({ currentSpan: r, ...e });
203
201
  },
204
202
  // /** @experimental */
205
- handleSubmitEffect: H,
203
+ handleSubmitEffect: J,
206
204
  registerField: (e) => {
207
- W(e, (r) => j.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), N(() => j.value.delete(e.value.name));
205
+ D(e, (r) => A.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), W(() => A.value.delete(e.value.name));
208
206
  }
209
- }), $ = { form: h, fieldMap: j };
207
+ }), $ = { form: h, fieldMap: A };
210
208
  return Object.assign(h, {
211
209
  // Type-level properties for performance optimization (not used at runtime)
212
210
  _paths: void 0,
@@ -214,9 +212,9 @@ const E = (l) => function(n) {
214
212
  _schema: l,
215
213
  errorContext: $,
216
214
  Form: E(h)(te),
217
- Input: E(h)(n?.input ?? ee),
215
+ Input: E(h)(s?.input ?? ee),
218
216
  TaggedUnion: E(h)(re),
219
- Field: o.Field,
217
+ Field: n.Field,
220
218
  Errors: ne($)(Z),
221
219
  Array: E(h)(X),
222
220
  AutoGen: E(h)(Y)
@@ -224,5 +222,5 @@ const E = (l) => function(n) {
224
222
  };
225
223
  export {
226
224
  se as FormErrors,
227
- be as useOmegaForm
225
+ we as useOmegaForm
228
226
  };