@effect-app/vue-components 2.7.5 → 2.7.7

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.
@@ -136,6 +136,7 @@ export type CreateMeta = {
136
136
  propertySignatures?: never;
137
137
  property: S.AST.AST;
138
138
  });
139
+ export declare const isNullableOrUndefined: (property: false | S.AST.AST | undefined) => false | "undefined" | "null";
139
140
  export declare const createMeta: <T = any>({ meta, parent, property, propertySignatures }: CreateMeta, acc?: Partial<MetaRecord<T>>) => MetaRecord<T> | FieldMeta;
140
141
  export declare const duplicateSchema: <From, To>(schema: S.Schema<To, From, never>) => S.extend<S.Schema<To, From, never>, S.Struct<{}>>;
141
142
  export declare const generateMetaFromSchema: <From, To>(schema: S.Schema<To, From, never>) => {
@@ -1,14 +1,14 @@
1
1
  import * as o from "./vue-components.es2.js";
2
- import { getTransformationFrom as f, provideIntl as u, useIntl as l, useIntlKey as s } from "./vue-components.es3.js";
2
+ import { getTransformationFrom as f, provideIntl as l, useIntl as u, useIntlKey as s } from "./vue-components.es3.js";
3
3
  import { default as i } from "./vue-components.es4.js";
4
4
  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 S } from "./vue-components.es9.js";
9
- import { useOmegaForm as b } from "./vue-components.es10.js";
10
- import { useOnClose as U, 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, nullableInput as K } from "./vue-components.es12.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
12
  import { createUseFormWithCustomInput as W } from "./vue-components.es13.js";
13
13
  function r(a) {
14
14
  for (const e in o)
@@ -23,7 +23,7 @@ export {
23
23
  g as Dialog,
24
24
  I as OmegaInput,
25
25
  h as OmegaTaggedUnion,
26
- S as OmegaTaggedUnionInternal,
26
+ C as OmegaTaggedUnionInternal,
27
27
  y as OmegaVuetifyInput,
28
28
  P as createMeta,
29
29
  W as createUseFormWithCustomInput,
@@ -33,11 +33,12 @@ export {
33
33
  B as generateMetaFromSchema,
34
34
  D as getInputType,
35
35
  f as getTransformationFrom,
36
- K as nullableInput,
37
- u as provideIntl,
38
- l as useIntl,
36
+ K as isNullableOrUndefined,
37
+ N as nullableInput,
38
+ l as provideIntl,
39
+ u as useIntl,
39
40
  s as useIntlKey,
40
- b as useOmegaForm,
41
- U as useOnClose,
41
+ T as useOmegaForm,
42
+ M as useOnClose,
42
43
  j as usePreventClose
43
44
  };
@@ -1,99 +1,99 @@
1
- import { useForm as G } from "@tanstack/vue-form";
2
- import { Data as z, S as p, Effect as h, Array as g, Fiber as L, Option as D } from "effect-app";
3
- import { runtimeFiberAsPromise as Q } from "./vue-components.es16.js";
4
- import { isObject as X } from "./vue-components.es17.js";
5
- import { computed as j, onUnmounted as R, onMounted as Y, onBeforeUnmount as Z, watch as W, ref as C, h as J } from "vue";
6
- import ee from "./vue-components.es18.js";
7
- import te from "./vue-components.es19.js";
8
- import re from "./vue-components.es20.js";
9
- import { generateMetaFromSchema as ne } from "./vue-components.es12.js";
10
- import se from "./vue-components.es6.js";
11
- import oe from "./vue-components.es8.js";
12
- import ie from "./vue-components.es21.js";
13
- import { trace as H } from "./vue-components.es22.js";
1
+ import { useForm as z } from "@tanstack/vue-form";
2
+ import { Data as Q, S as v, Effect as b, Array as g, Fiber as O, Option as D } from "effect-app";
3
+ import { runtimeFiberAsPromise as X } from "./vue-components.es16.js";
4
+ import { isObject as Y } from "./vue-components.es17.js";
5
+ import { computed as T, onUnmounted as W, onMounted as Z, onBeforeUnmount as C, watch as H, ref as ee, h as B } from "vue";
6
+ import te from "./vue-components.es18.js";
7
+ import re from "./vue-components.es19.js";
8
+ import ne from "./vue-components.es20.js";
9
+ import { generateMetaFromSchema as se, isNullableOrUndefined as J } from "./vue-components.es12.js";
10
+ import oe from "./vue-components.es6.js";
11
+ import ie from "./vue-components.es8.js";
12
+ import ae from "./vue-components.es21.js";
13
+ import { trace as q } from "./vue-components.es22.js";
14
14
  import { context as V } from "./vue-components.es23.js";
15
- const _ = (c) => {
16
- const i = c.ast;
15
+ const _ = (l) => {
16
+ const i = l.ast;
17
17
  if (i._tag === "Union") {
18
- const o = i.types.map((u) => {
19
- const l = p.make(u);
20
- return _(l).ast;
21
- }), m = {
18
+ const o = i.types.map((f) => {
19
+ const c = v.make(f);
20
+ return _(c).ast;
21
+ }), p = {
22
22
  ...i,
23
23
  types: o
24
24
  };
25
- return p.make(m);
25
+ return v.make(p);
26
26
  }
27
27
  if (i._tag === "Transformation") {
28
- const o = p.make(i.from), m = p.make(i.to), u = _(o), l = _(m), f = {
28
+ const o = v.make(i.from), p = v.make(i.to), f = _(o), c = _(p), d = {
29
29
  ...i,
30
- from: u.ast,
31
- to: l.ast
30
+ from: f.ast,
31
+ to: c.ast
32
32
  };
33
- return p.make(f);
33
+ return v.make(d);
34
34
  }
35
35
  if (i._tag === "TypeLiteral") {
36
- const o = i.propertySignatures.map((u) => {
37
- const l = u.type;
38
- let f = l;
39
- if (l._tag === "TypeLiteral" || l._tag === "Union" || l._tag === "Transformation") {
40
- const k = p.make(l);
41
- f = _(k).ast;
36
+ const o = i.propertySignatures.map((f) => {
37
+ const c = f.type;
38
+ let d = c;
39
+ if (c._tag === "TypeLiteral" || c._tag === "Union" || c._tag === "Transformation") {
40
+ const k = v.make(c);
41
+ d = _(k).ast;
42
42
  }
43
43
  return {
44
- ...u,
45
- type: f,
44
+ ...f,
45
+ type: d,
46
46
  isOptional: !0
47
47
  };
48
- }), m = {
48
+ }), p = {
49
49
  ...i,
50
50
  propertySignatures: o
51
51
  };
52
- return p.make(m);
52
+ return v.make(p);
53
53
  }
54
- return c;
54
+ return l;
55
55
  };
56
- class ae extends z.TaggedError("FormErrors") {
56
+ class le extends Q.TaggedError("FormErrors") {
57
57
  }
58
- const M = (c) => function(o) {
58
+ const U = (l) => function(o) {
59
59
  return {
60
60
  render() {
61
- return J(o, {
62
- form: c,
61
+ return B(o, {
62
+ form: l,
63
63
  ...this.$attrs
64
64
  }, this.$slots);
65
65
  }
66
66
  };
67
- }, ce = (c) => function(o) {
67
+ }, ce = (l) => function(o) {
68
68
  return {
69
69
  setup() {
70
- const { fieldMap: m, form: u } = c, l = u.useStore((S) => S.errors), f = u.useStore((S) => S.fieldMeta), k = u.useStore((S) => S.errorMap), w = j(() => {
70
+ const { fieldMap: p, form: f } = l, c = f.useStore((S) => S.errors), d = f.useStore((S) => S.fieldMeta), k = f.useStore((S) => S.errorMap), w = T(() => {
71
71
  const S = g.filterMap(
72
- Object.entries(f.value),
73
- ([x, b]) => {
74
- const a = b.errors ?? [];
72
+ Object.entries(d.value),
73
+ ([x, h]) => {
74
+ const a = h.errors ?? [];
75
75
  if (!a.length) return D.none();
76
- const v = m.value.get(x);
77
- return v ? D.some({
78
- label: v.label,
79
- inputId: v.id,
76
+ const y = p.value.get(x);
77
+ return y ? D.some({
78
+ label: y.label,
79
+ inputId: y.id,
80
80
  // Only show the first error
81
81
  errors: [a[0]?.message].filter(Boolean)
82
82
  }) : D.none();
83
83
  }
84
84
  ), F = [];
85
85
  if (k.value.onSubmit) {
86
- for (const [x, b] of Object.entries(k.value.onSubmit))
87
- if (g.isArray(b) && b.length)
88
- for (const a of b) {
89
- const v = a;
90
- if (v?.path && g.isArray(v.path) && v.path.length) {
91
- const A = v.path.join(".");
92
- if (!m.value.has(A)) {
86
+ for (const [x, h] of Object.entries(k.value.onSubmit))
87
+ if (g.isArray(h) && h.length)
88
+ for (const a of h) {
89
+ const y = a;
90
+ if (y?.path && g.isArray(y.path) && y.path.length) {
91
+ const A = y.path.join(".");
92
+ if (!p.value.has(A)) {
93
93
  F.push({
94
94
  label: A,
95
95
  inputId: A,
96
- errors: [v.message].filter(Boolean)
96
+ errors: [y.message].filter(Boolean)
97
97
  });
98
98
  break;
99
99
  }
@@ -103,49 +103,57 @@ const M = (c) => function(o) {
103
103
  return [...S, ...F];
104
104
  });
105
105
  return {
106
- generalErrors: l,
106
+ generalErrors: c,
107
107
  errors: w
108
108
  };
109
109
  },
110
- render({ errors: m, generalErrors: u }) {
111
- return J(o, {
112
- errors: m,
113
- generalErrors: u,
110
+ render({ errors: p, generalErrors: f }) {
111
+ return B(o, {
112
+ errors: p,
113
+ generalErrors: f,
114
114
  ...this.$attrs
115
115
  }, this.$slots);
116
116
  }
117
117
  };
118
- }, ke = (c, i, o) => {
119
- if (!c) throw new Error("Schema is required");
120
- const m = p.standardSchemaV1(c), u = p.decode(c), { meta: l } = ne(c), f = j(() => {
118
+ }, Ae = (l, i, o) => {
119
+ if (!l) throw new Error("Schema is required");
120
+ const p = v.standardSchemaV1(l), f = v.decode(l), { meta: c } = se(l), d = T(() => {
121
121
  if (o?.persistency?.id)
122
122
  return o.persistency.id;
123
- const e = window.location.pathname, t = Object.keys(l);
123
+ const e = window.location.pathname, t = Object.keys(c);
124
124
  return `${e}-${t.join("-")}`;
125
125
  }), k = () => {
126
126
  const e = new URLSearchParams(window.location.search);
127
- e.delete(f.value);
127
+ e.delete(d.value);
128
128
  const t = new URL(window.location.href);
129
129
  t.search = e.toString(), window.history.replaceState({}, "", t.toString());
130
130
  };
131
131
  function w(e, t) {
132
132
  for (const r in t)
133
- g.isArray(t[r]) ? e[r] = t[r] : t[r] && X(t[r]) ? (e[r] || (e[r] = {}), w(e[r], t[r])) : e[r] = t[r];
133
+ g.isArray(t[r]) ? e[r] = t[r] : t[r] && Y(t[r]) ? (e[r] || (e[r] = {}), w(e[r], t[r])) : e[r] = t[r];
134
134
  return e;
135
135
  }
136
136
  const S = (e) => {
137
137
  const t = {};
138
138
  if (typeof e?.make == "function")
139
139
  try {
140
- return e.make({});
140
+ const n = e.make({});
141
+ if (e?.fields && typeof e.fields == "object") {
142
+ for (const [s, u] of Object.entries(e.fields))
143
+ if (n[s] === void 0) {
144
+ const m = u.ast, M = J(m);
145
+ M === "null" ? n[s] = null : M === "undefined" && (n[s] = void 0);
146
+ }
147
+ }
148
+ return n;
141
149
  } catch {
142
150
  }
143
- const r = e?.members || (e?.ast?._tag === "Union" && e.ast.types ? e.ast.types.map((n) => p.make(n)) : null);
151
+ const r = e?.members || (e?.ast?._tag === "Union" && e.ast.types ? e.ast.types.map((n) => v.make(n)) : null);
144
152
  if (r && g.isArray(r)) {
145
153
  for (const n of r) {
146
154
  const s = S(n);
147
155
  if (Object.keys(s).length > 0 && n?.fields && Object.entries(n.fields).some(
148
- ([y, K]) => y === "_tag" || y === "type" || y === "kind" ? K?.ast?.defaultValue !== void 0 : !1
156
+ ([m, M]) => m === "_tag" || m === "type" || m === "kind" ? M?.ast?.defaultValue !== void 0 : !1
149
157
  ))
150
158
  return s;
151
159
  }
@@ -155,30 +163,41 @@ const M = (c) => function(o) {
155
163
  for (const [n, s] of Object.entries(e.fields)) {
156
164
  if (s?.ast?.defaultValue)
157
165
  try {
158
- const y = s.ast.defaultValue();
159
- y !== void 0 && (t[n] = y);
166
+ const m = s.ast.defaultValue();
167
+ t[n] = m;
160
168
  } catch {
161
169
  }
162
- const d = S(s);
163
- Object.keys(d).length > 0 && (t[n] && typeof t[n] == "object" ? Object.assign(t[n], d) : t[n] || (t[n] = d));
170
+ else {
171
+ const m = s.ast;
172
+ switch (J(m)) {
173
+ case "null":
174
+ t[n] = null;
175
+ break;
176
+ case "undefined":
177
+ t[n] = void 0;
178
+ break;
179
+ }
180
+ }
181
+ const u = S(s);
182
+ Object.keys(u).length > 0 && (t[n] && typeof t[n] == "object" ? Object.assign(t[n], u) : t[n] || (t[n] = u));
164
183
  }
165
184
  return t;
166
185
  }, F = (e = {}) => {
167
186
  let t = {};
168
187
  try {
169
- const r = c.make(e);
170
- t = p.encodeSync(_(c))(r);
188
+ const r = l.make(e);
189
+ t = v.encodeSync(_(S(l)))(r);
171
190
  } catch (r) {
172
191
  window.location.hostname === "localhost" && console.warn("schema.make() failed, extracting defaults from AST:", r);
173
192
  try {
174
- const n = S(c);
175
- t = p.encodeSync(_(c))(n);
193
+ const n = S(l);
194
+ t = v.encodeSync(_(l))(n);
176
195
  } catch (n) {
177
196
  window.location.hostname === "localhost" && console.warn("Could not extract defaults from AST:", n);
178
197
  }
179
198
  }
180
199
  return w(t, e);
181
- }, x = j(() => {
200
+ }, x = T(() => {
182
201
  let e;
183
202
  const t = o?.persistency;
184
203
  if (
@@ -189,16 +208,16 @@ const M = (c) => function(o) {
189
208
  if (r)
190
209
  try {
191
210
  const n = JSON.parse(
192
- r.getItem(f.value) || "{}"
211
+ r.getItem(d.value) || "{}"
193
212
  );
194
- r.removeItem(f.value), e = n;
213
+ r.removeItem(d.value), e = n;
195
214
  } catch (n) {
196
215
  console.error(n);
197
216
  }
198
217
  }
199
218
  if (t?.policies && t.policies.includes("querystring"))
200
219
  try {
201
- const n = new URLSearchParams(window.location.search).get(f.value);
220
+ const n = new URLSearchParams(window.location.search).get(d.value);
202
221
  k(), n && (e = w(e || {}, JSON.parse(n)));
203
222
  } catch (r) {
204
223
  console.error(r);
@@ -206,41 +225,41 @@ const M = (c) => function(o) {
206
225
  return e ??= {}, F(
207
226
  o?.persistency?.overrideDefaultValues ? w(i?.defaultValues || {}, e) : w(e, i?.defaultValues || {})
208
227
  );
209
- }), b = (e, t) => e ? V.with(H.setSpan(V.active(), e), t) : t(), a = G({
228
+ }), h = (e, t) => e ? V.with(q.setSpan(V.active(), e), t) : t(), a = z({
210
229
  ...i,
211
230
  validators: {
212
- onSubmit: m,
231
+ onSubmit: p,
213
232
  ...i?.validators || {}
214
233
  },
215
- onSubmit: i?.onSubmit ? ({ formApi: e, meta: t, value: r }) => b(t?.currentSpan, async () => {
216
- const n = await h.runPromise(u(r)), s = i.onSubmit({
234
+ onSubmit: i?.onSubmit ? ({ formApi: e, meta: t, value: r }) => h(t?.currentSpan, async () => {
235
+ const n = await b.runPromise(f(r)), s = i.onSubmit({
217
236
  formApi: e,
218
237
  meta: t,
219
238
  value: n
220
239
  });
221
- return L.isFiber(s) && L.isRuntimeFiber(s) ? await Q(s) : h.isEffect(s) ? await h.runPromise(
240
+ return O.isFiber(s) && O.isRuntimeFiber(s) ? await X(s) : b.isEffect(s) ? await b.runPromise(
222
241
  s.pipe(
223
242
  // meta?.currentSpan
224
243
  // ? Effect.withParentSpan(meta.currentSpan)
225
244
  // : (_) => _,
226
- h.flatMap((d) => L.join(d))
245
+ b.flatMap((u) => O.join(u))
227
246
  )
228
247
  ) : s;
229
248
  }) : void 0,
230
249
  defaultValues: x.value
231
- }), v = () => {
232
- Object.keys(l).forEach((e) => {
250
+ }), y = () => {
251
+ Object.keys(c).forEach((e) => {
233
252
  a.setFieldValue(e, void 0);
234
253
  });
235
254
  }, A = (e) => e.reduce((t, r) => {
236
255
  const n = r.split(".");
237
- return n.reduce((s, d, y) => (y === n.length - 1 ? s[d] = a.getFieldValue(r) : s[d] = s[d] ?? {}, s[d]), t), t;
238
- }, {}), T = (e) => {
256
+ return n.reduce((s, u, m) => (m === n.length - 1 ? s[u] = a.getFieldValue(r) : s[u] = s[u] ?? {}, s[u]), t), t;
257
+ }, {}), j = (e) => {
239
258
  if (e) {
240
259
  if (g.isArray(e.keys))
241
260
  return A(e.keys);
242
261
  if (g.isArray(e.banKeys)) {
243
- const t = Object.keys(l).filter((r) => e.banKeys?.includes(r));
262
+ const t = Object.keys(c).filter((r) => e.banKeys?.includes(r));
244
263
  return A(t);
245
264
  }
246
265
  return a.store.state.values;
@@ -250,69 +269,69 @@ const M = (c) => function(o) {
250
269
  if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
251
270
  const t = e.policies.includes("local") ? localStorage : sessionStorage;
252
271
  if (!t) return;
253
- const r = T(e);
254
- return t.setItem(f.value, JSON.stringify(r));
272
+ const r = j(e);
273
+ return t.setItem(d.value, JSON.stringify(r));
255
274
  }
256
- }, O = () => {
275
+ }, I = () => {
257
276
  const e = o?.persistency;
258
277
  if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
259
- const t = T(e), r = new URLSearchParams(window.location.search);
260
- r.set(f.value, JSON.stringify(t));
278
+ const t = j(e), r = new URLSearchParams(window.location.search);
279
+ r.set(d.value, JSON.stringify(t));
261
280
  const n = new URL(window.location.href);
262
281
  n.search = r.toString(), window.history.replaceState({}, "", n.toString());
263
282
  }
264
- }, I = (e) => {
283
+ }, $ = (e) => {
265
284
  a.store.state.isDirty && e.preventDefault();
266
285
  };
267
- if (R(P), Y(() => {
268
- window.addEventListener("beforeunload", P), window.addEventListener("blur", O), o?.preventWindowExit && o.preventWindowExit !== "nope" && window.addEventListener("beforeunload", I);
269
- }), Z(() => {
270
- window.removeEventListener("beforeunload", P), window.removeEventListener("blur", O), o?.preventWindowExit && o.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", I);
286
+ if (W(P), Z(() => {
287
+ window.addEventListener("beforeunload", P), window.addEventListener("blur", I), o?.preventWindowExit && o.preventWindowExit !== "nope" && window.addEventListener("beforeunload", $);
288
+ }), C(() => {
289
+ window.removeEventListener("beforeunload", P), window.removeEventListener("blur", I), o?.preventWindowExit && o.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", $);
271
290
  }), o?.preventWindowExit === "prevent-and-reset") {
272
291
  const e = a.useStore((s) => s.isSubmitting), t = a.useStore((s) => s.submissionAttempts), r = a.useStore((s) => s.canSubmit), n = a.useStore((s) => s.values);
273
- W([e, t], ([s, d], [y]) => {
274
- y && !s && d > 0 && r.value && a.reset(n.value);
292
+ H([e, t], ([s, u], [m]) => {
293
+ m && !s && u > 0 && r.value && a.reset(n.value);
275
294
  });
276
295
  }
277
- const $ = (e) => h.currentSpan.pipe(
278
- h.option,
279
- h.flatMap(
280
- (t) => h.promise(() => a.handleSubmit(D.isSome(t) ? { currentSpan: t.value, ...e } : e))
296
+ const N = (e) => b.currentSpan.pipe(
297
+ b.option,
298
+ b.flatMap(
299
+ (t) => b.promise(() => a.handleSubmit(D.isSome(t) ? { currentSpan: t.value, ...e } : e))
281
300
  )
282
- ), q = (e) => e?.checkErrors ? $(e?.meta).pipe(h.flatMap(h.fnUntraced(function* () {
301
+ ), K = (e) => e?.checkErrors ? N(e?.meta).pipe(b.flatMap(b.fnUntraced(function* () {
283
302
  const t = a.getAllErrors();
284
303
  if (Object.keys(t.fields).length || t.form.errors.length)
285
- return yield* new ae({ form: t.form, fields: t.fields });
286
- }))) : $(e?.meta), B = a.handleSubmit, U = C(/* @__PURE__ */ new Map()), E = Object.assign(a, {
304
+ return yield* new le({ form: t.form, fields: t.fields });
305
+ }))) : N(e?.meta), G = a.handleSubmit, L = ee(/* @__PURE__ */ new Map()), E = Object.assign(a, {
287
306
  i18nNamespace: o?.i18nNamespace,
288
307
  ignorePreventCloseEvents: o?.ignorePreventCloseEvents,
289
- meta: l,
290
- clear: v,
308
+ meta: c,
309
+ clear: y,
291
310
  handleSubmit: (e) => {
292
- const t = H.getSpan(V.active());
293
- return B({ currentSpan: t, ...e });
311
+ const t = q.getSpan(V.active());
312
+ return G({ currentSpan: t, ...e });
294
313
  },
295
314
  // /** @experimental */
296
- handleSubmitEffect: q,
315
+ handleSubmitEffect: K,
297
316
  registerField: (e) => {
298
- W(e, (t) => U.value.set(t.name, { label: t.label, id: t.id }), { immediate: !0 }), R(() => U.value.delete(e.value.name));
317
+ H(e, (t) => L.value.set(t.name, { label: t.label, id: t.id }), { immediate: !0 }), W(() => L.value.delete(e.value.name));
299
318
  }
300
- }), N = { form: E, fieldMap: U };
319
+ }), R = { form: E, fieldMap: L };
301
320
  return Object.assign(E, {
302
321
  // Type-level properties for performance optimization (not used at runtime)
303
322
  _paths: void 0,
304
323
  _keys: void 0,
305
- errorContext: N,
306
- Form: M(E)(ie),
307
- Input: M(E)(o?.input ?? se),
308
- TaggedUnion: M(E)(oe),
324
+ errorContext: R,
325
+ Form: U(E)(ae),
326
+ Input: U(E)(o?.input ?? oe),
327
+ TaggedUnion: U(E)(ie),
309
328
  Field: a.Field,
310
- Errors: ce(N)(re),
311
- Array: M(E)(ee),
312
- AutoGen: M(E)(te)
329
+ Errors: ce(R)(ne),
330
+ Array: U(E)(te),
331
+ AutoGen: U(E)(re)
313
332
  });
314
333
  };
315
334
  export {
316
- ae as FormErrors,
317
- ke as useOmegaForm
335
+ le as FormErrors,
336
+ Ae as useOmegaForm
318
337
  };
@@ -379,5 +379,6 @@ export {
379
379
  F as generateInputStandardSchemaFromFieldMeta,
380
380
  j as generateMetaFromSchema,
381
381
  R as getInputType,
382
+ d as isNullableOrUndefined,
382
383
  D as nullableInput
383
384
  };
@@ -1,28 +1,29 @@
1
1
  import { default as a } from "./vue-components.es4.js";
2
2
  import { default as r } from "./vue-components.es5.js";
3
- import { createMeta as n, duplicateSchema as u, generateInputStandardSchemaFromFieldMeta as p, generateMetaFromSchema as f, getInputType as l, nullableInput as d } from "./vue-components.es12.js";
4
- import { useOmegaForm as s } from "./vue-components.es10.js";
5
- import { default as i } from "./vue-components.es6.js";
3
+ import { createMeta as n, duplicateSchema as u, generateInputStandardSchemaFromFieldMeta as f, generateMetaFromSchema as l, getInputType as p, isNullableOrUndefined as d, nullableInput as s } from "./vue-components.es12.js";
4
+ import { useOmegaForm as x } from "./vue-components.es10.js";
5
+ import { default as I } from "./vue-components.es6.js";
6
6
  import { default as c } from "./vue-components.es7.js";
7
- import { default as F } from "./vue-components.es8.js";
8
- import { default as C } from "./vue-components.es9.js";
7
+ import { default as h } from "./vue-components.es8.js";
8
+ import { default as S } from "./vue-components.es9.js";
9
9
  import { useOnClose as M, usePreventClose as T } from "./vue-components.es11.js";
10
10
  import { createUseFormWithCustomInput as y } from "./vue-components.es13.js";
11
11
  export {
12
12
  a as CommandButton,
13
13
  r as Dialog,
14
- i as OmegaInput,
15
- F as OmegaTaggedUnion,
16
- C as OmegaTaggedUnionInternal,
14
+ I as OmegaInput,
15
+ h as OmegaTaggedUnion,
16
+ S as OmegaTaggedUnionInternal,
17
17
  c as OmegaVuetifyInput,
18
18
  n as createMeta,
19
19
  y as createUseFormWithCustomInput,
20
20
  u as duplicateSchema,
21
- p as generateInputStandardSchemaFromFieldMeta,
22
- f as generateMetaFromSchema,
23
- l as getInputType,
24
- d as nullableInput,
25
- s as useOmegaForm,
21
+ f as generateInputStandardSchemaFromFieldMeta,
22
+ l as generateMetaFromSchema,
23
+ p as getInputType,
24
+ d as isNullableOrUndefined,
25
+ s as nullableInput,
26
+ x as useOmegaForm,
26
27
  M as useOnClose,
27
28
  T as usePreventClose
28
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "2.7.5",
3
+ "version": "2.7.7",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^3.18.0",
@@ -53,8 +53,8 @@
53
53
  "highlight.js": "^11.11.1",
54
54
  "mitt": "^3.0.1",
55
55
  "vue3-highlightjs": "^1.0.5",
56
- "effect-app": "3.12.0",
57
- "@effect-app/vue": "2.92.2"
56
+ "@effect-app/vue": "2.92.2",
57
+ "effect-app": "3.12.0"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "pnpm build:run",
@@ -321,7 +321,7 @@ const getNullableOrUndefined = (property: S.AST.AST) => {
321
321
  )
322
322
  }
323
323
 
324
- const isNullableOrUndefined = (property: false | S.AST.AST | undefined) => {
324
+ export const isNullableOrUndefined = (property: false | S.AST.AST | undefined) => {
325
325
  if (!property || !S.AST.isUnion(property)) return false
326
326
  if (property.types.find((_) => _._tag === "UndefinedKeyword")) {
327
327
  return "undefined"
@@ -11,7 +11,7 @@ import { MergedInputProps } from "./InputProps"
11
11
  import OmegaArray from "./OmegaArray.vue"
12
12
  import OmegaAutoGen from "./OmegaAutoGen.vue"
13
13
  import OmegaErrorsInternal from "./OmegaErrorsInternal.vue"
14
- import { BaseProps, DefaultTypeProps, FieldPath, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, OmegaArrayProps, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState } from "./OmegaFormStuff"
14
+ import { BaseProps, DefaultTypeProps, FieldPath, type FormProps, generateMetaFromSchema, isNullableOrUndefined, type MetaRecord, type NestedKeyOf, OmegaArrayProps, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState } from "./OmegaFormStuff"
15
15
  import OmegaInput from "./OmegaInput.vue"
16
16
  import OmegaTaggedUnion from "./OmegaTaggedUnion.vue"
17
17
  import OmegaForm from "./OmegaWrapper.vue"
@@ -768,6 +768,22 @@ export const useOmegaForm = <
768
768
  try {
769
769
  const instance = schemaObj.make({})
770
770
  // For ExtendedClass, the instance is already in the correct encoded format
771
+ // But we need to check for nullable fields that may have been set to undefined
772
+ // instead of null, and fix them
773
+ if (schemaObj?.fields && typeof schemaObj.fields === "object") {
774
+ for (const [key, fieldSchema] of Object.entries(schemaObj.fields)) {
775
+ // Only fix fields that are undefined in the instance
776
+ if (instance[key] === undefined) {
777
+ const ast = (fieldSchema as any).ast
778
+ const nullableOrUndefined = isNullableOrUndefined(ast)
779
+ if (nullableOrUndefined === "null") {
780
+ instance[key] = null
781
+ } else if (nullableOrUndefined === "undefined") {
782
+ instance[key] = undefined
783
+ }
784
+ }
785
+ }
786
+ }
771
787
  return instance
772
788
  } catch {
773
789
  // If make() fails, fall through to manual extraction
@@ -813,12 +829,22 @@ export const useOmegaForm = <
813
829
  if ((fieldSchema as any)?.ast?.defaultValue) {
814
830
  try {
815
831
  const defaultValue = (fieldSchema as any).ast.defaultValue()
816
- if (defaultValue !== undefined) {
817
- result[key] = defaultValue
818
- }
832
+ result[key] = defaultValue
819
833
  } catch {
820
834
  // Silently ignore if defaultValue() throws
821
835
  }
836
+ } else {
837
+ // TODO Should we put to null/undefined only leaves?
838
+ const ast = (fieldSchema as any).ast
839
+ const nullableOrUndefined = isNullableOrUndefined(ast)
840
+ switch (nullableOrUndefined) {
841
+ case "null":
842
+ result[key] = null
843
+ break
844
+ case "undefined":
845
+ result[key] = undefined
846
+ break
847
+ }
822
848
  }
823
849
 
824
850
  // Recursively check nested fields for structs and unions
@@ -847,7 +873,7 @@ export const useOmegaForm = <
847
873
  // First try to use schema.make() if available
848
874
  // Note: Partial schemas don't have .make() method yet (https://github.com/Effect-TS/effect/issues/4222)
849
875
  const decoded = (schema as any).make(defaultValues)
850
- result = S.encodeSync(partialRecursive(schema))(decoded)
876
+ result = S.encodeSync(partialRecursive(extractDefaultsFromAST(schema)))(decoded)
851
877
  } catch (error) {
852
878
  // If make() fails, try to extract defaults from AST
853
879
  if (window.location.hostname === "localhost") {