@effect-app/vue-components 2.10.5 → 2.10.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.
@@ -25,6 +25,7 @@ export declare class FormErrors<From> extends FormErrors_base<{
25
25
  }>;
26
26
  }> {
27
27
  }
28
+ export declare const useErrorLabel: (form: OF<any, any>) => (propsName: string) => string;
28
29
  export type Policies = "local" | "session" | "querystring";
29
30
  export type defaultValuesPriorityUnion = "tanstack" | "persistency" | "schema";
30
31
  export type OmegaConfig<T> = {
@@ -1,233 +1,238 @@
1
1
  import { useForm as B } from "@tanstack/vue-form";
2
- import { Data as K, S as $, Effect as l, Fiber as x, Option as P, Array as F } from "effect-app";
2
+ import { Data as K, S as V, Effect as f, Fiber as $, Option as P, Array as F } from "effect-app";
3
3
  import { runtimeFiberAsPromise as T } from "./vue-components.es17.js";
4
- import { computed as U, onUnmounted as N, onMounted as G, onBeforeUnmount as z, watch as W, ref as Q, h as H } from "vue";
4
+ import { computed as x, onUnmounted as W, onMounted as z, onBeforeUnmount as G, watch as D, ref as Z, h as H } from "vue";
5
+ import { useIntl as Q } from "./vue-components.es3.js";
5
6
  import X from "./vue-components.es18.js";
6
7
  import Y from "./vue-components.es19.js";
7
- import Z from "./vue-components.es20.js";
8
- import { generateMetaFromSchema as C, deepMerge as D, defaultsValueFromSchema as ee } from "./vue-components.es12.js";
9
- import re from "./vue-components.es6.js";
10
- import te from "./vue-components.es8.js";
11
- import se from "./vue-components.es21.js";
12
- import { trace as R } from "./vue-components.es22.js";
13
- import { context as L } from "./vue-components.es23.js";
14
- class ne extends K.TaggedError("FormErrors") {
8
+ import C from "./vue-components.es20.js";
9
+ import { generateMetaFromSchema as ee, deepMerge as R, defaultsValueFromSchema as re } from "./vue-components.es12.js";
10
+ import te from "./vue-components.es6.js";
11
+ import se from "./vue-components.es8.js";
12
+ import ne from "./vue-components.es21.js";
13
+ import { trace as N } from "./vue-components.es22.js";
14
+ import { context as U } from "./vue-components.es23.js";
15
+ class oe extends K.TaggedError("FormErrors") {
15
16
  }
16
- const g = (a) => function(n) {
17
+ const g = (i) => function(n) {
17
18
  return {
18
19
  render() {
19
20
  return H(n, {
20
- form: a,
21
+ form: i,
21
22
  ...this.$attrs
22
23
  }, this.$slots);
23
24
  }
24
25
  };
25
- }, oe = (a) => function(n) {
26
+ }, ie = (i) => {
27
+ const { formatMessage: l } = Q(), n = (a) => a.replace(/([A-Z])/g, " $1").replace(/^./, (d) => d.toUpperCase()).trim(), m = (a) => l ? l({ id: `general.fields.${a}`, defaultMessage: n(a) }) : n(a);
28
+ return (a) => i.i18nNamespace ? l({ id: `${i.i18nNamespace}.fields.${a}`, defaultMessage: m(a) }) : m(a);
29
+ }, ae = (i) => function(n) {
26
30
  return {
27
31
  setup() {
28
- const { fieldMap: b, form: h } = a, y = h.useStore((d) => d.errors), m = h.useStore((d) => d.fieldMeta), M = h.useStore((d) => d.errorMap), j = U(() => {
29
- const d = F.filterMap(
30
- Object.entries(m.value),
31
- ([O, f]) => {
32
- const S = f.errors ?? [];
33
- if (!S.length) return P.none();
34
- const c = b.value.get(O);
35
- return c ? P.some({
36
- label: c.label,
37
- inputId: c.id,
32
+ const { fieldMap: m, form: p } = i, a = p.useStore((s) => s.errors), d = p.useStore((s) => s.fieldMeta), M = p.useStore((s) => s.errorMap), j = ie(p), A = x(() => {
33
+ const s = F.filterMap(
34
+ Object.entries(d.value),
35
+ ([E, v]) => {
36
+ const h = v.errors ?? [];
37
+ if (!h.length) return P.none();
38
+ const u = m.value.get(E);
39
+ return u ? P.some({
40
+ label: u.label,
41
+ inputId: u.id,
38
42
  // Only show the first error
39
- errors: [S[0]?.message].filter(Boolean)
43
+ errors: [h[0]?.message].filter(Boolean)
40
44
  }) : P.none();
41
45
  }
42
- ), o = [];
46
+ ), O = [];
43
47
  if (M.value.onSubmit) {
44
- for (const [O, f] of Object.entries(M.value.onSubmit))
45
- if (F.isArray(f) && f.length)
46
- for (const S of f) {
47
- const c = S;
48
- if (c?.path && F.isArray(c.path) && c.path.length) {
49
- const E = c.path.join(".");
50
- if (!b.value.has(E)) {
51
- o.push({
52
- label: E,
53
- inputId: E,
54
- errors: [c.message].filter(Boolean)
48
+ for (const [E, v] of Object.entries(M.value.onSubmit))
49
+ if (F.isArray(v) && v.length)
50
+ for (const h of v) {
51
+ const u = h;
52
+ if (u?.path && F.isArray(u.path) && u.path.length) {
53
+ const y = u.path.join(".");
54
+ if (!m.value.has(y)) {
55
+ O.push({
56
+ label: j(y),
57
+ inputId: y,
58
+ errors: [u.message].filter(Boolean)
55
59
  });
56
60
  break;
57
61
  }
58
62
  }
59
63
  }
60
64
  }
61
- return [...d, ...o];
65
+ return [...s, ...O];
62
66
  });
63
67
  return {
64
- generalErrors: y,
65
- errors: j
68
+ generalErrors: a,
69
+ errors: A
66
70
  };
67
71
  },
68
- render({ errors: b, generalErrors: h }) {
72
+ render({ errors: m, generalErrors: p }) {
69
73
  return H(n, {
70
- errors: b,
71
- generalErrors: h,
74
+ errors: m,
75
+ generalErrors: p,
72
76
  ...this.$attrs
73
77
  }, this.$slots);
74
78
  }
75
79
  };
76
- }, v = (a, u) => a.includes(u), be = (a, u, n) => {
77
- if (!a) throw new Error("Schema is required");
78
- const b = $.standardSchemaV1(a), h = $.decode(a), { meta: y } = C(a), m = U(() => {
80
+ }, b = (i, l) => i.includes(l), ge = (i, l, n) => {
81
+ if (!i) throw new Error("Schema is required");
82
+ const m = V.standardSchemaV1(i), p = V.decode(i), { meta: a } = ee(i), d = x(() => {
79
83
  if (n?.persistency?.id)
80
84
  return n.persistency.id;
81
- const e = window.location.pathname, r = Object.keys(y);
85
+ const e = window.location.pathname, r = Object.keys(a);
82
86
  return `${e}-${r.join("-")}`;
83
87
  }), M = () => {
84
88
  const e = new URLSearchParams(window.location.search);
85
- e.delete(m.value);
89
+ e.delete(d.value);
86
90
  const r = new URL(window.location.href);
87
91
  r.search = e.toString(), window.history.replaceState({}, "", r.toString());
88
- }, j = U(() => {
92
+ }, j = x(() => {
89
93
  let e;
90
94
  const r = n?.persistency;
91
95
  if (
92
96
  // query string has higher priority than local/session storage
93
- r?.policies && !e && (v(r.policies, "local") || v(r.policies, "session"))
97
+ r?.policies && !e && (b(r.policies, "local") || b(r.policies, "session"))
94
98
  ) {
95
- const s = v(r.policies, "local") ? localStorage : sessionStorage;
96
- if (s)
99
+ const o = b(r.policies, "local") ? localStorage : sessionStorage;
100
+ if (o)
97
101
  try {
98
102
  const t = JSON.parse(
99
- s.getItem(m.value) || "{}"
103
+ o.getItem(d.value) || "{}"
100
104
  );
101
- s.removeItem(m.value), e = t;
105
+ o.removeItem(d.value), e = t;
102
106
  } catch (t) {
103
107
  console.error(t);
104
108
  }
105
109
  }
106
- if (r?.policies && v(r.policies, "querystring"))
110
+ if (r?.policies && b(r.policies, "querystring"))
107
111
  try {
108
- const t = new URLSearchParams(window.location.search).get(m.value);
109
- M(), t && (e = D(e || {}, JSON.parse(t)));
110
- } catch (s) {
111
- console.error(s);
112
+ const t = new URLSearchParams(window.location.search).get(d.value);
113
+ M(), t && (e = R(e || {}, JSON.parse(t)));
114
+ } catch (o) {
115
+ console.error(o);
112
116
  }
113
117
  e ??= {};
114
- const i = {
115
- tanstack: u?.defaultValues || {},
118
+ const c = {
119
+ tanstack: l?.defaultValues || {},
116
120
  persistency: e,
117
- schema: ee(a)
121
+ schema: re(i)
118
122
  };
119
123
  return (n?.defaultValuesPriority || ["tanstack", "persistency", "schema"]).reverse().reduce(
120
- (s, t) => Object.keys(s).length ? D(s, i[t]) : i[t],
124
+ (o, t) => Object.keys(o).length ? R(o, c[t]) : c[t],
121
125
  {}
122
126
  );
123
- }), d = (e, r) => e ? L.with(R.setSpan(L.active(), e), r) : r(), o = B({
124
- ...u,
127
+ }), A = (e, r) => e ? U.with(N.setSpan(U.active(), e), r) : r(), s = B({
128
+ ...l,
125
129
  validators: {
126
- onSubmit: b,
127
- ...u?.validators || {}
130
+ onSubmit: m,
131
+ ...l?.validators || {}
128
132
  },
129
- onSubmit: u?.onSubmit ? ({ formApi: e, meta: r, value: i }) => d(r?.currentSpan, async () => {
130
- const s = await l.runPromise(h(i)), t = u.onSubmit({
133
+ onSubmit: l?.onSubmit ? ({ formApi: e, meta: r, value: c }) => A(r?.currentSpan, async () => {
134
+ const o = await f.runPromise(p(c)), t = l.onSubmit({
131
135
  formApi: e,
132
136
  meta: r,
133
- value: s
137
+ value: o
134
138
  });
135
- return x.isFiber(t) && x.isRuntimeFiber(t) ? await T(t) : l.isEffect(t) ? await l.runPromise(
139
+ return $.isFiber(t) && $.isRuntimeFiber(t) ? await T(t) : f.isEffect(t) ? await f.runPromise(
136
140
  t.pipe(
137
141
  // meta?.currentSpan
138
142
  // ? Effect.withParentSpan(meta.currentSpan)
139
143
  // : (_) => _,
140
- l.flatMap((p) => x.join(p))
144
+ f.flatMap((S) => $.join(S))
141
145
  )
142
146
  ) : t;
143
147
  }) : void 0,
144
148
  defaultValues: j.value
145
149
  }), O = () => {
146
- Object.keys(y).forEach((e) => {
147
- o.setFieldValue(e, void 0);
150
+ Object.keys(a).forEach((e) => {
151
+ s.setFieldValue(e, void 0);
148
152
  });
149
- }, f = (e) => e.reduce((r, i) => {
150
- const s = i.split(".");
151
- return s.reduce((t, p, A) => (A === s.length - 1 ? t[p] = o.getFieldValue(i) : t[p] = t[p] ?? {}, t[p]), r), r;
152
- }, {}), S = (e) => {
153
+ }, E = (e) => e.reduce((r, c) => {
154
+ const o = c.split(".");
155
+ return o.reduce((t, S, _) => (_ === o.length - 1 ? t[S] = s.getFieldValue(c) : t[S] = t[S] ?? {}, t[S]), r), r;
156
+ }, {}), v = (e) => {
153
157
  if (e) {
154
158
  if (F.isArray(e.keys))
155
- return f(e.keys);
159
+ return E(e.keys);
156
160
  if (F.isArray(e.banKeys)) {
157
- const r = Object.keys(y).filter((i) => e.banKeys?.includes(i));
158
- return f(r);
161
+ const r = Object.keys(a).filter((c) => e.banKeys?.includes(c));
162
+ return E(r);
159
163
  }
160
- return o.store.state.values;
164
+ return s.store.state.values;
161
165
  }
162
- }, c = () => {
166
+ }, h = () => {
163
167
  const e = n?.persistency;
164
- if (!(!e?.policies || e.policies.length === 0) && (v(e.policies, "local") || v(e.policies, "session"))) {
165
- const r = v(e.policies, "local") ? localStorage : sessionStorage;
168
+ if (!(!e?.policies || e.policies.length === 0) && (b(e.policies, "local") || b(e.policies, "session"))) {
169
+ const r = b(e.policies, "local") ? localStorage : sessionStorage;
166
170
  if (!r) return;
167
- const i = S(e);
168
- return r.setItem(m.value, JSON.stringify(i));
171
+ const c = v(e);
172
+ return r.setItem(d.value, JSON.stringify(c));
169
173
  }
170
- }, E = () => {
174
+ }, u = () => {
171
175
  const e = n?.persistency;
172
- if (!(!e?.policies || e.policies.length === 0) && v(e.policies, "querystring")) {
173
- const r = S(e), i = new URLSearchParams(window.location.search);
174
- i.set(m.value, JSON.stringify(r));
175
- const s = new URL(window.location.href);
176
- s.search = i.toString(), window.history.replaceState({}, "", s.toString());
176
+ if (!(!e?.policies || e.policies.length === 0) && b(e.policies, "querystring")) {
177
+ const r = v(e), c = new URLSearchParams(window.location.search);
178
+ c.set(d.value, JSON.stringify(r));
179
+ const o = new URL(window.location.href);
180
+ o.search = c.toString(), window.history.replaceState({}, "", o.toString());
177
181
  }
178
- }, V = (e) => {
179
- o.store.state.isDirty && e.preventDefault();
182
+ }, y = (e) => {
183
+ s.store.state.isDirty && e.preventDefault();
180
184
  };
181
- if (N(c), G(() => {
182
- window.addEventListener("beforeunload", c), window.addEventListener("blur", E), n?.preventWindowExit && n.preventWindowExit !== "nope" && window.addEventListener("beforeunload", V);
183
- }), z(() => {
184
- window.removeEventListener("beforeunload", c), window.removeEventListener("blur", E), n?.preventWindowExit && n.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", V);
185
+ if (W(h), z(() => {
186
+ window.addEventListener("beforeunload", h), window.addEventListener("blur", u), n?.preventWindowExit && n.preventWindowExit !== "nope" && window.addEventListener("beforeunload", y);
187
+ }), G(() => {
188
+ window.removeEventListener("beforeunload", h), window.removeEventListener("blur", u), n?.preventWindowExit && n.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", y);
185
189
  }), n?.preventWindowExit === "prevent-and-reset") {
186
- const e = o.useStore((t) => t.isSubmitting), r = o.useStore((t) => t.submissionAttempts), i = o.useStore((t) => t.canSubmit), s = o.useStore((t) => t.values);
187
- W([e, r], ([t, p], [A]) => {
188
- A && !t && p > 0 && i.value && o.reset(s.value);
190
+ const e = s.useStore((t) => t.isSubmitting), r = s.useStore((t) => t.submissionAttempts), c = s.useStore((t) => t.canSubmit), o = s.useStore((t) => t.values);
191
+ D([e, r], ([t, S], [_]) => {
192
+ _ && !t && S > 0 && c.value && s.reset(o.value);
189
193
  });
190
194
  }
191
- const k = (e) => l.currentSpan.pipe(
192
- l.option,
193
- l.flatMap(
194
- (r) => l.promise(() => o.handleSubmit(P.isSome(r) ? { currentSpan: r.value, ...e } : e))
195
+ const k = (e) => f.currentSpan.pipe(
196
+ f.option,
197
+ f.flatMap(
198
+ (r) => f.promise(() => s.handleSubmit(P.isSome(r) ? { currentSpan: r.value, ...e } : e))
195
199
  )
196
- ), J = (e) => e?.checkErrors ? k(e?.meta).pipe(l.flatMap(l.fnUntraced(function* () {
197
- const r = o.getAllErrors();
200
+ ), J = (e) => e?.checkErrors ? k(e?.meta).pipe(f.flatMap(f.fnUntraced(function* () {
201
+ const r = s.getAllErrors();
198
202
  if (Object.keys(r.fields).length || r.form.errors.length)
199
- return yield* new ne({ form: r.form, fields: r.fields });
200
- }))) : k(e?.meta), q = o.handleSubmit, _ = Q(/* @__PURE__ */ new Map()), w = Object.assign(o, {
203
+ return yield* new oe({ form: r.form, fields: r.fields });
204
+ }))) : k(e?.meta), q = s.handleSubmit, L = Z(/* @__PURE__ */ new Map()), w = Object.assign(s, {
201
205
  i18nNamespace: n?.i18nNamespace,
202
206
  ignorePreventCloseEvents: n?.ignorePreventCloseEvents,
203
- meta: y,
207
+ meta: a,
204
208
  clear: O,
205
209
  handleSubmit: (e) => {
206
- const r = R.getSpan(L.active());
210
+ const r = N.getSpan(U.active());
207
211
  return q({ currentSpan: r, ...e });
208
212
  },
209
213
  // /** @experimental */
210
214
  handleSubmitEffect: J,
211
215
  registerField: (e) => {
212
- W(e, (r) => _.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), N(() => _.value.delete(e.value.name));
216
+ D(e, (r) => L.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), W(() => L.value.delete(e.value.name));
213
217
  }
214
- }), I = { form: w, fieldMap: _ };
218
+ }), I = { form: w, fieldMap: L };
215
219
  return Object.assign(w, {
216
220
  // Type-level properties for performance optimization (not used at runtime)
217
221
  _paths: void 0,
218
222
  _keys: void 0,
219
- _schema: a,
223
+ _schema: i,
220
224
  errorContext: I,
221
- Form: g(w)(se),
222
- Input: g(w)(n?.input ?? re),
223
- TaggedUnion: g(w)(te),
224
- Field: o.Field,
225
- Errors: oe(I)(Z),
225
+ Form: g(w)(ne),
226
+ Input: g(w)(n?.input ?? te),
227
+ TaggedUnion: g(w)(se),
228
+ Field: s.Field,
229
+ Errors: ae(I)(C),
226
230
  Array: g(w)(X),
227
231
  AutoGen: g(w)(Y)
228
232
  });
229
233
  };
230
234
  export {
231
- ne as FormErrors,
232
- be as useOmegaForm
235
+ oe as FormErrors,
236
+ ie as useErrorLabel,
237
+ ge as useOmegaForm
233
238
  };
@@ -1,270 +1,273 @@
1
- import { S as i, Option as M } from "effect-app";
1
+ import { S as r, Option as q } from "effect-app";
2
2
  import { getMetadataFromSchema as k } from "@effect-app/vue/form";
3
- import { useIntl as V, getTransformationFrom as q } from "./vue-components.es3.js";
3
+ import { useIntl as V, getTransformationFrom as _ } from "./vue-components.es3.js";
4
4
  import { isObject as E } from "./vue-components.es16.js";
5
- const $ = (e) => i.AST.isUnion(e) && e.types.find((n) => n._tag === "UndefinedKeyword" || n === i.Null.ast), g = (e) => !e || !i.AST.isUnion(e) ? !1 : e.types.find((n) => n._tag === "UndefinedKeyword") ? "undefined" : e.types.find((n) => n === i.Null.ast) ? "null" : !1, w = (e) => {
5
+ const $ = (e) => r.AST.isUnion(e) && e.types.find((n) => n._tag === "UndefinedKeyword" || n === r.Null.ast), g = (e) => !e || !r.AST.isUnion(e) ? !1 : e.types.find((n) => n._tag === "UndefinedKeyword") ? "undefined" : e.types.find((n) => n === r.Null.ast) ? "null" : !1, L = (e) => {
6
6
  const n = [];
7
7
  for (const t of e)
8
- if (i.AST.isUnion(t)) {
9
- const l = w(t.types);
10
- n.push(...l);
8
+ if (r.AST.isUnion(t)) {
9
+ const p = L(t.types);
10
+ n.push(...p);
11
11
  } else
12
12
  n.push(t);
13
13
  return n;
14
- }, m = ({ meta: e = {}, parent: n = "", property: t, propertySignatures: l }, o = {}) => {
14
+ }, f = ({ meta: e = {}, parent: n = "", property: t, propertySignatures: p }, o = {}) => {
15
15
  if (t && t._tag === "Transformation")
16
- return m({
16
+ return f({
17
17
  parent: n,
18
18
  meta: e,
19
19
  property: t.from
20
20
  });
21
21
  if (t?._tag === "TypeLiteral" && "propertySignatures" in t)
22
- return m({
22
+ return f({
23
23
  meta: e,
24
24
  propertySignatures: t.propertySignatures
25
25
  });
26
- if (l) {
27
- for (const s of l) {
28
- const r = n ? `${n}.${s.name.toString()}` : s.name.toString(), p = g(s.type);
26
+ if (p) {
27
+ for (const s of p) {
28
+ const i = n ? `${n}.${s.name.toString()}` : s.name.toString(), l = g(s.type);
29
29
  let a;
30
- e._isNullableDiscriminatedUnion && s.name.toString() === "_tag" || e.required === !1 ? a = !1 : a = !p;
31
- const f = s.type;
32
- if (i.AST.isUnion(s.type)) {
33
- const S = w(s.type.types).filter(
34
- (u) => u._tag !== "UndefinedKeyword" && u !== i.Null.ast
35
- ).map(q);
36
- if (S.some(
30
+ e._isNullableDiscriminatedUnion && s.name.toString() === "_tag" || e.required === !1 ? a = !1 : a = !l;
31
+ const m = s.type;
32
+ if (r.AST.isUnion(s.type)) {
33
+ const c = L(s.type.types).filter(
34
+ (u) => u._tag !== "UndefinedKeyword" && u !== r.Null.ast
35
+ ).map(_);
36
+ if (c.some(
37
37
  (u) => "propertySignatures" in u
38
38
  )) {
39
- if (!p) {
40
- const u = m({
41
- parent: r,
39
+ if (!l) {
40
+ const u = f({
41
+ parent: i,
42
42
  property: s.type,
43
- meta: { required: a, nullableOrUndefined: p }
43
+ meta: { required: a, nullableOrUndefined: l }
44
44
  });
45
- o[r] = u;
45
+ o[i] = u;
46
46
  }
47
- for (const u of S)
47
+ for (const u of c)
48
48
  if ("propertySignatures" in u) {
49
- const y = p && S.length > 1;
49
+ const y = l && c.length > 1;
50
50
  Object.assign(
51
51
  o,
52
- m({
53
- parent: r,
52
+ f({
53
+ parent: i,
54
54
  propertySignatures: u.propertySignatures,
55
55
  meta: y ? { _isNullableDiscriminatedUnion: !0 } : {}
56
56
  })
57
57
  );
58
58
  }
59
59
  } else {
60
- const u = S.filter(i.AST.isTupleType);
60
+ const u = c.filter(r.AST.isTupleType);
61
61
  if (u.length > 0) {
62
62
  const y = u[0];
63
- if (o[r] = {
63
+ if (o[i] = {
64
64
  type: "multiple",
65
65
  members: y.elements,
66
66
  rest: y.rest,
67
67
  required: a,
68
- nullableOrUndefined: p
68
+ nullableOrUndefined: l
69
69
  }, y.rest && y.rest.length > 0) {
70
- const b = y.rest[0];
71
- if (b.type._tag === "TypeLiteral" && "propertySignatures" in b.type)
72
- for (const c of b.type.propertySignatures) {
73
- const h = `${r}.${c.name.toString()}`, x = m({
70
+ const S = y.rest[0];
71
+ if (S.type._tag === "TypeLiteral" && "propertySignatures" in S.type)
72
+ for (const d of S.type.propertySignatures) {
73
+ const h = `${i}.${d.name.toString()}`, T = f({
74
74
  parent: h,
75
- property: c.type,
75
+ property: d.type,
76
76
  meta: {
77
- required: !g(c.type),
78
- nullableOrUndefined: g(c.type)
77
+ required: !g(d.type),
78
+ nullableOrUndefined: g(d.type)
79
79
  }
80
80
  });
81
- if (x && typeof x == "object" && "type" in x && (o[h] = x, x.type === "multiple" && i.AST.isTupleType(c.type) && c.type.rest && c.type.rest.length > 0)) {
82
- const U = c.type.rest[0];
83
- if (U.type._tag === "TypeLiteral" && "propertySignatures" in U.type)
84
- for (const A of U.type.propertySignatures) {
85
- const L = `${h}.${A.name.toString()}`, O = m({
86
- parent: L,
81
+ if (T && typeof T == "object" && "type" in T && (o[h] = T, T.type === "multiple" && r.AST.isTupleType(d.type) && d.type.rest && d.type.rest.length > 0)) {
82
+ const w = d.type.rest[0];
83
+ if (w.type._tag === "TypeLiteral" && "propertySignatures" in w.type)
84
+ for (const A of w.type.propertySignatures) {
85
+ const M = `${h}.${A.name.toString()}`, O = f({
86
+ parent: M,
87
87
  property: A.type,
88
88
  meta: {
89
89
  required: !g(A.type),
90
90
  nullableOrUndefined: g(A.type)
91
91
  }
92
92
  });
93
- O && typeof O == "object" && "type" in O && (o[L] = O);
93
+ O && typeof O == "object" && "type" in O && (o[M] = O);
94
94
  }
95
95
  }
96
96
  }
97
97
  }
98
98
  } else {
99
- const y = m({
100
- parent: r,
99
+ const y = f({
100
+ parent: i,
101
101
  property: s.type,
102
- meta: { required: a, nullableOrUndefined: p }
102
+ meta: { required: a, nullableOrUndefined: l }
103
103
  });
104
- o[r] = y;
104
+ o[i] = y;
105
105
  }
106
106
  }
107
- } else if ("propertySignatures" in f)
108
- Object.assign(
109
- o,
110
- m({
111
- parent: r,
112
- propertySignatures: f.propertySignatures,
113
- meta: { required: a, nullableOrUndefined: p }
114
- })
115
- );
116
- else if (i.AST.isTupleType(s.type))
117
- if (s.type.rest.length > 0 && s.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in s.type.rest[0].type) {
118
- const S = s.type.rest[0].type;
119
- if (S._tag === "TypeLiteral" && "propertySignatures" in S)
120
- for (const d of S.propertySignatures) {
121
- const u = `${r}.${d.name.toString()}`;
122
- if (i.AST.isTupleType(d.type) && d.type.rest.length > 0) {
123
- const y = d.type.rest[0].type;
124
- if (y._tag === "TypeLiteral" && "propertySignatures" in y)
125
- for (const b of y.propertySignatures) {
126
- const c = `${u}.${b.name.toString()}`, h = m({
127
- parent: c,
128
- property: b.type,
129
- meta: {
130
- required: !g(b.type),
131
- nullableOrUndefined: g(b.type)
132
- }
133
- });
134
- o[c] = h;
135
- }
136
- else
137
- o[u] = {
138
- type: "multiple",
139
- members: d.type.elements,
140
- rest: d.type.rest,
141
- required: !g(d.type),
142
- nullableOrUndefined: g(d.type)
143
- };
144
- } else {
145
- const y = m({
146
- parent: u,
147
- property: d.type,
148
- meta: {
149
- required: !g(d.type),
150
- nullableOrUndefined: g(d.type)
151
- }
152
- });
153
- o[u] = y;
107
+ } else {
108
+ const b = _(m);
109
+ if ("propertySignatures" in b)
110
+ Object.assign(
111
+ o,
112
+ f({
113
+ parent: i,
114
+ propertySignatures: b.propertySignatures,
115
+ meta: { required: a, nullableOrUndefined: l }
116
+ })
117
+ );
118
+ else if (r.AST.isTupleType(s.type))
119
+ if (s.type.rest.length > 0 && s.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in s.type.rest[0].type) {
120
+ const v = s.type.rest[0].type;
121
+ if (v._tag === "TypeLiteral" && "propertySignatures" in v)
122
+ for (const u of v.propertySignatures) {
123
+ const y = `${i}.${u.name.toString()}`;
124
+ if (r.AST.isTupleType(u.type) && u.type.rest.length > 0) {
125
+ const S = u.type.rest[0].type;
126
+ if (S._tag === "TypeLiteral" && "propertySignatures" in S)
127
+ for (const d of S.propertySignatures) {
128
+ const h = `${y}.${d.name.toString()}`, T = f({
129
+ parent: h,
130
+ property: d.type,
131
+ meta: {
132
+ required: !g(d.type),
133
+ nullableOrUndefined: g(d.type)
134
+ }
135
+ });
136
+ o[h] = T;
137
+ }
138
+ else
139
+ o[y] = {
140
+ type: "multiple",
141
+ members: u.type.elements,
142
+ rest: u.type.rest,
143
+ required: !g(u.type),
144
+ nullableOrUndefined: g(u.type)
145
+ };
146
+ } else {
147
+ const S = f({
148
+ parent: y,
149
+ property: u.type,
150
+ meta: {
151
+ required: !g(u.type),
152
+ nullableOrUndefined: g(u.type)
153
+ }
154
+ });
155
+ o[y] = S;
156
+ }
154
157
  }
158
+ } else
159
+ o[i] = {
160
+ type: "multiple",
161
+ members: s.type.elements,
162
+ rest: s.type.rest,
163
+ required: a,
164
+ nullableOrUndefined: l
165
+ };
166
+ else {
167
+ const c = f({
168
+ parent: i,
169
+ property: s.type,
170
+ meta: {
171
+ // an empty string is valid for a S.String field, so we should not mark it as required
172
+ // TODO: handle this better via the createMeta minLength parsing
173
+ required: a && (s.type._tag !== "StringKeyword" || k(s.type).minLength),
174
+ nullableOrUndefined: l
155
175
  }
156
- } else
157
- o[r] = {
158
- type: "multiple",
159
- members: s.type.elements,
160
- rest: s.type.rest,
161
- required: a,
162
- nullableOrUndefined: p
163
- };
164
- else {
165
- const T = m({
166
- parent: r,
167
- property: s.type,
168
- meta: {
169
- // an empty string is valid for a S.String field, so we should not mark it as required
170
- // TODO: handle this better via the createMeta minLength parsing
171
- required: a && (s.type._tag !== "StringKeyword" || k(s.type).minLength),
172
- nullableOrUndefined: p
173
- }
174
- });
175
- o[r] = T;
176
+ });
177
+ o[i] = c;
178
+ }
176
179
  }
177
180
  }
178
181
  return o;
179
182
  }
180
183
  if (t) {
181
184
  const s = $(t);
182
- if (Object.hasOwnProperty.call(e, "required") || (e.required = !s), i.AST.isUnion(t)) {
183
- const p = w(t.types), a = p.find(
184
- (f) => f._tag !== "UndefinedKeyword" && f !== i.Null.ast
185
+ if (Object.hasOwnProperty.call(e, "required") || (e.required = !s), r.AST.isUnion(t)) {
186
+ const l = L(t.types), a = l.find(
187
+ (m) => m._tag !== "UndefinedKeyword" && m !== r.Null.ast
185
188
  );
186
- return "propertySignatures" in a ? m({
189
+ return "propertySignatures" in a ? f({
187
190
  propertySignatures: a.propertySignatures,
188
191
  parent: n,
189
192
  meta: e
190
- }) : p.every(i.AST.isLiteral) ? {
193
+ }) : l.every(r.AST.isLiteral) ? {
191
194
  ...e,
192
195
  type: "select",
193
- members: p.map((f) => f.literal)
196
+ members: l.map((m) => m.literal)
194
197
  } : {
195
198
  ...e,
196
- ...m({
199
+ ...f({
197
200
  parent: n,
198
201
  meta: e,
199
202
  property: a
200
203
  })
201
204
  };
202
205
  }
203
- if (i.AST.isTupleType(t))
206
+ if (r.AST.isTupleType(t))
204
207
  return {
205
208
  ...e,
206
209
  type: "multiple",
207
210
  members: t.elements,
208
211
  rest: t.rest
209
212
  };
210
- const r = i.AST.getAnnotation(
213
+ const i = r.AST.getAnnotation(
211
214
  t,
212
- i.AST.JSONSchemaAnnotationId
213
- ).pipe(M.getOrElse(() => ({})));
214
- return e = { ...e, ...r }, "from" in t ? m({
215
+ r.AST.JSONSchemaAnnotationId
216
+ ).pipe(q.getOrElse(() => ({})));
217
+ return e = { ...e, ...i }, "from" in t ? f({
215
218
  parent: n,
216
219
  meta: e,
217
220
  property: t.from
218
- }) : (e.type = i.AST.getAnnotation(
221
+ }) : (e.type = r.AST.getAnnotation(
219
222
  t,
220
- i.AST.TitleAnnotationId
223
+ r.AST.TitleAnnotationId
221
224
  ).pipe(
222
- M.getOrElse(() => "unknown")
225
+ q.getOrElse(() => "unknown")
223
226
  ), e);
224
227
  }
225
228
  return o;
226
229
  }, N = (e) => {
227
- const n = e.ast, t = {}, l = {};
230
+ const n = e.ast, t = {}, p = {};
228
231
  if (n._tag === "Transformation" || n._tag === "Refinement")
229
- return N(i.make(n.from));
232
+ return N(r.make(n.from));
230
233
  if (n._tag === "Union") {
231
- const r = (n.types || []).filter((a) => a._tag !== "UndefinedKeyword" && a !== i.Null.ast).map(q);
232
- if (r.every((a) => a._tag === "TypeLiteral" && "propertySignatures" in a) && r.length > 0) {
234
+ const i = (n.types || []).filter((a) => a._tag !== "UndefinedKeyword" && a !== r.Null.ast).map(_);
235
+ if (i.every((a) => a._tag === "TypeLiteral" && "propertySignatures" in a) && i.length > 0) {
233
236
  const a = [];
234
- for (const f of r)
235
- if ("propertySignatures" in f) {
236
- const T = f.propertySignatures.find(
237
- (d) => d.name.toString() === "_tag"
237
+ for (const m of i)
238
+ if ("propertySignatures" in m) {
239
+ const b = m.propertySignatures.find(
240
+ (v) => v.name.toString() === "_tag"
238
241
  );
239
- T && i.AST.isLiteral(T.type) && a.push(T.type.literal);
240
- const S = m({
241
- propertySignatures: f.propertySignatures
242
+ b && r.AST.isLiteral(b.type) && a.push(b.type.literal);
243
+ const c = f({
244
+ propertySignatures: m.propertySignatures
242
245
  });
243
- Object.assign(t, S);
246
+ Object.assign(t, c);
244
247
  }
245
248
  return a.length > 0 && (t._tag = {
246
249
  type: "select",
247
250
  members: a,
248
251
  required: !0
249
- }), { meta: t, defaultValues: l };
252
+ }), { meta: t, defaultValues: p };
250
253
  }
251
254
  }
252
255
  if ("propertySignatures" in n) {
253
- const o = m({
256
+ const o = f({
254
257
  propertySignatures: n.propertySignatures
255
258
  });
256
- if (Object.values(o).every((r) => r && "type" in r))
257
- return { meta: o, defaultValues: l };
258
- const s = (r, p = "") => {
259
- for (const a in r) {
260
- const f = p ? `${p}.${a}` : a;
261
- r[a] && typeof r[a] == "object" && "type" in r[a] ? t[f] = r[a] : r[a] && typeof r[a] == "object" && s(r[a], f);
259
+ if (Object.values(o).every((i) => i && "type" in i))
260
+ return { meta: o, defaultValues: p };
261
+ const s = (i, l = "") => {
262
+ for (const a in i) {
263
+ const m = l ? `${l}.${a}` : a;
264
+ i[a] && typeof i[a] == "object" && "type" in i[a] ? t[m] = i[a] : i[a] && typeof i[a] == "object" && s(i[a], m);
262
265
  }
263
266
  };
264
267
  s(o);
265
268
  }
266
- return { meta: t, defaultValues: l };
267
- }, B = (e) => i.extend(e, i.Struct({})), J = (e) => {
269
+ return { meta: t, defaultValues: p };
270
+ }, B = (e) => r.extend(e, r.Struct({})), J = (e) => {
268
271
  const { meta: n } = N(e);
269
272
  return { schema: e, meta: n };
270
273
  }, z = (e) => {
@@ -272,48 +275,48 @@ const $ = (e) => i.AST.isUnion(e) && e.types.find((n) => n._tag === "UndefinedKe
272
275
  let t;
273
276
  switch (e.type) {
274
277
  case "string":
275
- t = i.String.annotations({
278
+ t = r.String.annotations({
276
279
  message: () => n("validation.empty")
277
- }), e.format === "email" && (t = i.compose(
280
+ }), e.format === "email" && (t = r.compose(
278
281
  t,
279
- i.Email.annotations({
282
+ r.Email.annotations({
280
283
  message: () => n("validation.email.invalid")
281
284
  })
282
285
  )), e.required && (t = t.annotations({
283
286
  message: () => n("validation.empty")
284
- }).pipe(i.minLength(1)).annotations({
287
+ }).pipe(r.minLength(1)).annotations({
285
288
  message: () => n("validation.empty")
286
- })), typeof e.maxLength == "number" && (t = t.pipe(i.maxLength(e.maxLength)).annotations({
289
+ })), typeof e.maxLength == "number" && (t = t.pipe(r.maxLength(e.maxLength)).annotations({
287
290
  message: () => n("validation.string.maxLength", {
288
291
  maxLength: e.maxLength
289
292
  })
290
- })), typeof e.minLength == "number" && (t = t.pipe(i.minLength(e.minLength)).annotations({
293
+ })), typeof e.minLength == "number" && (t = t.pipe(r.minLength(e.minLength)).annotations({
291
294
  message: () => n("validation.string.minLength", {
292
295
  minLength: e.minLength
293
296
  })
294
297
  }));
295
298
  break;
296
299
  case "number":
297
- t = i.Number.annotations({
300
+ t = r.Number.annotations({
298
301
  message: () => n("validation.empty")
299
302
  }), e.required && t.annotations({
300
303
  message: () => n("validation.empty")
301
- }), typeof e.minimum == "number" && (t = t.pipe(i.greaterThanOrEqualTo(e.minimum)).annotations({
304
+ }), typeof e.minimum == "number" && (t = t.pipe(r.greaterThanOrEqualTo(e.minimum)).annotations({
302
305
  message: () => n(e.minimum === 0 ? "validation.number.positive" : "validation.number.min", {
303
306
  minimum: e.minimum,
304
307
  isExclusive: !0
305
308
  })
306
- })), typeof e.maximum == "number" && (t = t.pipe(i.lessThanOrEqualTo(e.maximum)).annotations({
309
+ })), typeof e.maximum == "number" && (t = t.pipe(r.lessThanOrEqualTo(e.maximum)).annotations({
307
310
  message: () => n("validation.number.max", {
308
311
  maximum: e.maximum,
309
312
  isExclusive: !0
310
313
  })
311
- })), typeof e.exclusiveMinimum == "number" && (t = t.pipe(i.greaterThan(e.exclusiveMinimum)).annotations({
314
+ })), typeof e.exclusiveMinimum == "number" && (t = t.pipe(r.greaterThan(e.exclusiveMinimum)).annotations({
312
315
  message: () => n(e.exclusiveMinimum === 0 ? "validation.number.positive" : "validation.number.min", {
313
316
  minimum: e.exclusiveMinimum,
314
317
  isExclusive: !1
315
318
  })
316
- })), typeof e.exclusiveMaximum == "number" && (t = t.pipe(i.lessThan(e.exclusiveMaximum)).annotations({
319
+ })), typeof e.exclusiveMaximum == "number" && (t = t.pipe(r.lessThan(e.exclusiveMaximum)).annotations({
317
320
  message: () => n("validation.number.max", {
318
321
  maximum: e.exclusiveMaximum,
319
322
  isExclusive: !1
@@ -321,7 +324,7 @@ const $ = (e) => i.AST.isUnion(e) && e.types.find((n) => n._tag === "UndefinedKe
321
324
  }));
322
325
  break;
323
326
  case "select":
324
- t = i.Literal(...e.members).annotations({
327
+ t = r.Literal(...e.members).annotations({
325
328
  message: () => ({
326
329
  message: n("validation.not_a_valid", {
327
330
  type: "select",
@@ -332,7 +335,7 @@ const $ = (e) => i.AST.isUnion(e) && e.types.find((n) => n._tag === "UndefinedKe
332
335
  });
333
336
  break;
334
337
  case "multiple":
335
- t = i.Array(i.String).annotations({
338
+ t = r.Array(r.String).annotations({
336
339
  message: () => n("validation.not_a_valid", {
337
340
  type: "multiple",
338
341
  message: e.members.join(", ")
@@ -340,22 +343,22 @@ const $ = (e) => i.AST.isUnion(e) && e.types.find((n) => n._tag === "UndefinedKe
340
343
  });
341
344
  break;
342
345
  case "boolean":
343
- t = i.Boolean;
346
+ t = r.Boolean;
344
347
  break;
345
348
  case "unknown":
346
- t = i.Unknown;
349
+ t = r.Unknown;
347
350
  break;
348
351
  default:
349
- console.warn(`Unhandled field type: ${e}`), t = i.Unknown;
352
+ console.warn(`Unhandled field type: ${e}`), t = r.Unknown;
350
353
  break;
351
354
  }
352
355
  return e.required ? t.pipe(
353
- i.annotations({
356
+ r.annotations({
354
357
  message: () => n("validation.empty")
355
358
  })
356
- ) : t = i.NullishOr(t), i.standardSchemaV1(t);
357
- }, C = (e, n) => i.NullOr(e).pipe(
358
- i.transform(i.typeSchema(e), {
359
+ ) : t = r.NullishOr(t), r.standardSchemaV1(t);
360
+ }, C = (e, n) => r.NullOr(e).pipe(
361
+ r.transform(r.typeSchema(e), {
359
362
  decode: (t) => t ?? n(),
360
363
  encode: (t) => t
361
364
  })
@@ -378,71 +381,71 @@ const $ = (e) => i.AST.isUnion(e) && e.types.find((n) => n._tag === "UndefinedKe
378
381
  ], G = (e) => K.includes(e) ? e : "text";
379
382
  function j(e, n) {
380
383
  const t = { ...e };
381
- for (const l in n)
382
- Array.isArray(n[l]) ? t[l] = n[l] : n[l] && E(n[l]) ? t[l] = j(t[l], n[l]) : t[l] = n[l];
384
+ for (const p in n)
385
+ Array.isArray(n[p]) ? t[p] = n[p] : n[p] && E(n[p]) ? t[p] = j(t[p], n[p]) : t[p] = n[p];
383
386
  return t;
384
387
  }
385
- function _(e) {
388
+ function U(e) {
386
389
  return e && "fields" in e && typeof e.fields == "object";
387
390
  }
388
391
  function F(e) {
389
392
  return e && "members" in e && Array.isArray(e.members);
390
393
  }
391
- const v = (e, n = {}) => {
394
+ const x = (e, n = {}) => {
392
395
  const t = e.ast;
393
396
  if (t?.defaultValue)
394
397
  return t.defaultValue();
395
398
  if (g(e.ast) === "null")
396
399
  return null;
397
400
  if (g(e.ast) !== "undefined") {
398
- if (_(e)) {
399
- const l = {};
401
+ if (U(e)) {
402
+ const p = {};
400
403
  for (const [o, s] of Object.entries(e.fields)) {
401
- const r = s?.ast;
402
- if (r?.defaultValue)
404
+ const i = s?.ast;
405
+ if (i?.defaultValue)
403
406
  try {
404
- l[o] = r.defaultValue();
407
+ p[o] = i.defaultValue();
405
408
  continue;
406
409
  } catch {
407
410
  }
408
- const p = v(s, n[o] || {});
409
- p !== void 0 && (l[o] = p);
411
+ const l = x(s, n[o] || {});
412
+ l !== void 0 && (p[o] = l);
410
413
  }
411
- return { ...l, ...n };
414
+ return { ...p, ...n };
412
415
  }
413
- if (e?.from && _(e.from))
414
- return v(e.from, n);
416
+ if (e?.from && U(e.from))
417
+ return x(e.from, n);
415
418
  if (F(e)) {
416
- const l = e.members.reduce((o, s) => (_(s) && Object.entries(s.fields).forEach(([r, p]) => {
417
- const a = p.ast, f = o[r]?.ast;
418
- (!o[r] || a?.defaultValue && !f?.defaultValue) && (o[r] = p);
419
+ const p = e.members.reduce((o, s) => (U(s) && Object.entries(s.fields).forEach(([i, l]) => {
420
+ const a = l.ast, m = o[i]?.ast;
421
+ (!o[i] || a?.defaultValue && !m?.defaultValue) && (o[i] = l);
419
422
  }), o), {});
420
- return Object.entries(l).reduce((o, [s, r]) => (o[s] = v(r, n[s] || {}), o), n);
423
+ return Object.entries(p).reduce((o, [s, i]) => (o[s] = x(i, n[s] || {}), o), n);
421
424
  }
422
425
  if (Object.keys(n).length === 0)
423
426
  switch (e.ast._tag) {
424
427
  case "Refinement":
425
- return v(i.make(e.ast.from), n);
428
+ return x(r.make(e.ast.from), n);
426
429
  case "Transformation": {
427
- const l = i.make(e.ast.from);
428
- return v(l, n);
430
+ const p = r.make(e.ast.from);
431
+ return x(p, n);
429
432
  }
430
433
  case "TypeLiteral": {
431
- const l = { ...n };
434
+ const p = { ...n };
432
435
  for (const o of t.propertySignatures) {
433
- const s = o.name.toString(), r = o.type;
434
- if (r._tag === "Transformation" && r.defaultValue) {
435
- l[s] = r.defaultValue();
436
+ const s = o.name.toString(), i = o.type;
437
+ if (i._tag === "Transformation" && i.defaultValue) {
438
+ p[s] = i.defaultValue();
436
439
  continue;
437
440
  }
438
- if (r.defaultValue) {
439
- l[s] = r.defaultValue();
441
+ if (i.defaultValue) {
442
+ p[s] = i.defaultValue();
440
443
  continue;
441
444
  }
442
- const p = i.make(r), a = v(p, n[s] || {});
443
- a !== void 0 && (l[s] = a);
445
+ const l = r.make(i), a = x(l, n[s] || {});
446
+ a !== void 0 && (p[s] = a);
444
447
  }
445
- return l;
448
+ return p;
446
449
  }
447
450
  case "StringKeyword":
448
451
  return "";
@@ -452,9 +455,9 @@ const v = (e, n = {}) => {
452
455
  }
453
456
  };
454
457
  export {
455
- m as createMeta,
458
+ f as createMeta,
456
459
  j as deepMerge,
457
- v as defaultsValueFromSchema,
460
+ x as defaultsValueFromSchema,
458
461
  B as duplicateSchema,
459
462
  z as generateInputStandardSchemaFromFieldMeta,
460
463
  J as generateMetaFromSchema,
@@ -1,8 +1,8 @@
1
- import { defineComponent as F, computed as n, useAttrs as A, inject as N, createBlock as d, openBlock as p, resolveDynamicComponent as S, withCtx as i, createCommentVNode as w, mergeProps as I, createSlots as P, renderSlot as v, normalizeProps as g, guardReactiveProps as C } from "vue";
2
- import { useIntl as j } from "./vue-components.es3.js";
3
- import { generateInputStandardSchemaFromFieldMeta as z } from "./vue-components.es12.js";
4
- import B from "./vue-components.es7.js";
5
- const U = /* @__PURE__ */ F({
1
+ import { defineComponent as y, computed as o, useAttrs as F, inject as $, createBlock as u, openBlock as i, resolveDynamicComponent as k, withCtx as m, createCommentVNode as A, mergeProps as M, unref as S, createSlots as w, renderSlot as f, normalizeProps as d, guardReactiveProps as c } from "vue";
2
+ import { generateInputStandardSchemaFromFieldMeta as P } from "./vue-components.es12.js";
3
+ import j from "./vue-components.es7.js";
4
+ import { useErrorLabel as B } from "./vue-components.es10.js";
5
+ const D = /* @__PURE__ */ y({
6
6
  inheritAttrs: !1,
7
7
  __name: "OmegaInput",
8
8
  props: {
@@ -12,51 +12,51 @@ const U = /* @__PURE__ */ F({
12
12
  name: {},
13
13
  inputClass: {}
14
14
  },
15
- setup(t) {
16
- const e = t, r = n(() => e.name), $ = A(), b = n(() => {
15
+ setup(a) {
16
+ const e = a, l = o(() => e.name), v = F(), p = o(() => {
17
17
  if (e.inputClass !== null)
18
- return e.inputClass !== void 0 ? e.inputClass : $.class;
19
- }), s = N(
18
+ return e.inputClass !== void 0 ? e.inputClass : v.class;
19
+ }), n = $(
20
20
  "getMetaFromArray",
21
21
  null
22
- ), l = n(() => s?.value && s.value(e.name) ? s.value(r.value) : e.form.meta[r.value]), h = n(() => {
23
- if (!l.value)
22
+ ), r = o(() => n?.value && n.value(e.name) ? n.value(l.value) : e.form.meta[l.value]), g = o(() => {
23
+ if (!r.value)
24
24
  throw console.log(e.name, Object.keys(e.form.meta), e.form.meta), new Error("Meta is undefined");
25
- return z(l.value);
26
- }), { formatMessage: o } = j(), u = (a) => a.replace(/([A-Z])/g, " $1").replace(/^./, (c) => c.toUpperCase()).trim(), f = () => o ? o({ id: `general.fields.${r.value}`, defaultMessage: u(e.name) }) : u(e.name), M = () => e.form.i18nNamespace ? o({ id: `${e.form.i18nNamespace}.fields.${r.value}`, defaultMessage: f() }) : f();
27
- return (a, c) => (p(), d(S(t.form.Field), {
28
- name: t.name,
25
+ return P(r.value);
26
+ }), C = B(e.form);
27
+ return (t, E) => (i(), u(k(a.form.Field), {
28
+ name: a.name,
29
29
  validators: {
30
- onChange: h.value,
31
- ...t.validators
30
+ onChange: g.value,
31
+ ...a.validators
32
32
  }
33
33
  }, {
34
- default: i(({ field: k, state: y }) => [
35
- l.value ? (p(), d(B, I({ key: 0 }, { ...a.$attrs, ...a.$props, inputClass: b.value }, {
36
- field: k,
37
- state: y,
38
- register: t.form.registerField,
39
- label: t.label ?? M(),
40
- meta: l.value
41
- }), P({
42
- default: i((m) => [
43
- v(a.$slots, "default", g(C(m)))
34
+ default: m(({ field: b, state: h }) => [
35
+ r.value ? (i(), u(j, M({ key: 0 }, { ...t.$attrs, ...t.$props, inputClass: p.value }, {
36
+ field: b,
37
+ state: h,
38
+ register: a.form.registerField,
39
+ label: a.label ?? S(C)(l.value),
40
+ meta: r.value
41
+ }), w({
42
+ default: m((s) => [
43
+ f(t.$slots, "default", d(c(s)))
44
44
  ]),
45
45
  _: 2
46
46
  }, [
47
- a.$slots.label ? {
47
+ t.$slots.label ? {
48
48
  name: "label",
49
- fn: i((m) => [
50
- v(a.$slots, "label", g(C(m)))
49
+ fn: m((s) => [
50
+ f(t.$slots, "label", d(c(s)))
51
51
  ]),
52
52
  key: "0"
53
53
  } : void 0
54
- ]), 1040, ["field", "state", "register", "label", "meta"])) : w("", !0)
54
+ ]), 1040, ["field", "state", "register", "label", "meta"])) : A("", !0)
55
55
  ]),
56
56
  _: 3
57
57
  }, 8, ["name", "validators"]));
58
58
  }
59
59
  });
60
60
  export {
61
- U as default
61
+ D as default
62
62
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "2.10.5",
3
+ "version": "2.10.7",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^3.19.3",
@@ -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/vue": "2.93.5",
57
- "effect-app": "3.15.0"
56
+ "effect-app": "3.15.0",
57
+ "@effect-app/vue": "2.93.5"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "pnpm build:run",
@@ -8,12 +8,6 @@ import { getTransformationFrom, useIntl } from "../../utils"
8
8
  import { type OmegaFieldInternalApi } from "./InputProps"
9
9
  import { type OF, type OmegaFormReturn } from "./useOmegaForm"
10
10
 
11
- type Compute<T> =
12
- & {
13
- [K in keyof T]: T[K]
14
- }
15
- & {}
16
-
17
11
  export type FieldPath<T> = unknown extends T ? string
18
12
  // technically we cannot have primitive at the root
19
13
  : T extends string | boolean | number | null | undefined | symbol | bigint ? ""
@@ -507,18 +501,19 @@ export const createMeta = <T = any>(
507
501
  acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
508
502
  }
509
503
  }
510
- } else if ("propertySignatures" in typeToProcess) {
511
- Object.assign(
512
- acc,
513
- createMeta<T>({
514
- parent: key,
515
- propertySignatures: typeToProcess.propertySignatures,
516
- meta: { required: isRequired, nullableOrUndefined }
517
- })
518
- )
519
504
  } else {
520
- // Check if this is an array type
521
- if (S.AST.isTupleType(p.type)) {
505
+ // Unwrap transformations (like ExtendedClass) to check for propertySignatures
506
+ const unwrappedTypeToProcess = getTransformationFrom(typeToProcess)
507
+ if ("propertySignatures" in unwrappedTypeToProcess) {
508
+ Object.assign(
509
+ acc,
510
+ createMeta<T>({
511
+ parent: key,
512
+ propertySignatures: unwrappedTypeToProcess.propertySignatures,
513
+ meta: { required: isRequired, nullableOrUndefined }
514
+ })
515
+ )
516
+ } else if (S.AST.isTupleType(p.type)) {
522
517
  // Check if it has struct elements
523
518
  const hasStructElements = p.type.rest.length > 0
524
519
  && p.type.rest[0].type._tag === "TypeLiteral"
@@ -14,7 +14,7 @@
14
14
  :field="field"
15
15
  :state="state"
16
16
  :register="form.registerField"
17
- :label="label ?? i18n()"
17
+ :label="label ?? errori18n(propsName)"
18
18
  :meta="meta"
19
19
  >
20
20
  <template
@@ -41,9 +41,9 @@
41
41
  >
42
42
  import { type DeepKeys } from "@tanstack/vue-form"
43
43
  import { computed, inject, type Ref, useAttrs } from "vue"
44
- import { useIntl } from "../../utils"
45
44
  import { type FieldMeta, generateInputStandardSchemaFromFieldMeta, type OmegaInputPropsBase } from "./OmegaFormStuff"
46
45
  import OmegaInternalInput from "./OmegaInternalInput.vue"
46
+ import { useErrorLabel } from "./useOmegaForm"
47
47
 
48
48
  const props = defineProps<OmegaInputPropsBase<From, To, Name>>()
49
49
 
@@ -88,19 +88,5 @@ const schema = computed(() => {
88
88
  return generateInputStandardSchemaFromFieldMeta(meta.value)
89
89
  })
90
90
 
91
- const { formatMessage } = useIntl()
92
- const humanize = (str: string) => {
93
- return str
94
- .replace(/([A-Z])/g, " $1") // Add space before capital letters
95
- .replace(/^./, (char) => char.toUpperCase()) // Capitalize the first letter
96
- .trim() // Remove leading/trailing spaces
97
- }
98
- const fallback = () =>
99
- formatMessage
100
- ? formatMessage({ id: `general.fields.${propsName.value}`, defaultMessage: humanize(props.name) })
101
- : humanize(props.name)
102
- const i18n = () =>
103
- props.form.i18nNamespace
104
- ? formatMessage({ id: `${props.form.i18nNamespace}.fields.${propsName.value}`, defaultMessage: fallback() })
105
- : fallback()
91
+ const errori18n = useErrorLabel(props.form)
106
92
  </script>
@@ -6,6 +6,7 @@ import { type DeepKeys, DeepValue, type FormAsyncValidateOrFn, type FormValidate
6
6
  import { Array, Data, Effect, Fiber, Option, Order, S } from "effect-app"
7
7
  import { runtimeFiberAsPromise, UnionToTuples } from "effect-app/utils"
8
8
  import { Component, computed, ComputedRef, ConcreteComponent, h, type InjectionKey, onBeforeUnmount, onMounted, onUnmounted, Ref, ref, watch } from "vue"
9
+ import { useIntl } from "../../utils"
9
10
  import { MergedInputProps } from "./InputProps"
10
11
  import OmegaArray from "./OmegaArray.vue"
11
12
  import OmegaAutoGen from "./OmegaAutoGen.vue"
@@ -63,6 +64,26 @@ const fHoc = (form: OF<any, any>) => {
63
64
  }
64
65
  }
65
66
 
67
+ export const useErrorLabel = (form: OF<any, any>) => {
68
+ const { formatMessage } = useIntl()
69
+ const humanize = (str: string) => {
70
+ return str
71
+ .replace(/([A-Z])/g, " $1") // Add space before capital letters
72
+ .replace(/^./, (char) => char.toUpperCase()) // Capitalize the first letter
73
+ .trim() // Remove leading/trailing spaces
74
+ }
75
+ const fallback = (propsName: string) =>
76
+ formatMessage
77
+ ? formatMessage({ id: `general.fields.${propsName}`, defaultMessage: humanize(propsName) })
78
+ : humanize(propsName)
79
+ const i18n = (propsName: string) =>
80
+ form.i18nNamespace
81
+ ? formatMessage({ id: `${form.i18nNamespace}.fields.${propsName}`, defaultMessage: fallback(propsName) })
82
+ : fallback(propsName)
83
+
84
+ return i18n
85
+ }
86
+
66
87
  const eHoc = (errorProps: {
67
88
  form: OF<any, any>
68
89
  fieldMap: Ref<Map<string, { id: string; label: string }>>
@@ -77,6 +98,8 @@ const eHoc = (errorProps: {
77
98
  const fieldMeta = form.useStore((state) => state.fieldMeta)
78
99
  const errorMap = form.useStore((state) => state.errorMap)
79
100
 
101
+ const errorLabel = useErrorLabel(form)
102
+
80
103
  const errors = computed(() => {
81
104
  // Collect errors from fieldMeta (field-level errors for registered fields)
82
105
  const fieldErrors = Array.filterMap(
@@ -114,7 +137,7 @@ const eHoc = (errorProps: {
114
137
  // Registered fields will already have their errors from fieldMeta
115
138
  if (!fieldMap.value.has(fieldPath)) {
116
139
  submitErrors.push({
117
- label: fieldPath,
140
+ label: errorLabel(fieldPath),
118
141
  inputId: fieldPath,
119
142
  errors: [issAny.message].filter(Boolean)
120
143
  })