@effect-app/vue-components 2.4.9 → 2.4.10

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.
@@ -1,48 +1,57 @@
1
- import { useForm as Z } from "@tanstack/vue-form";
2
- import { Data as G, S as W, Effect as l, Fiber as N, Option as A, Array as g } 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 V, onUnmounted as $, onMounted as Y, onBeforeUnmount as C, watch as R, ref as ee, h as b } from "vue";
6
- import re from "./vue-components.es18.js";
7
- import te from "./vue-components.es19.js";
8
- import se from "./vue-components.es20.js";
9
- import { generateMetaFromSchema as ne } 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 x } from "./vue-components.es22.js";
14
- import { context as L } from "./vue-components.es23.js";
15
- class le extends G.TaggedError("FormErrors") {
1
+ import { useForm as J } from "@tanstack/vue-form";
2
+ import { Data as z, S as k, Effect as l, Fiber as N, Option as P, Array as g } from "effect-app";
3
+ import { runtimeFiberAsPromise as K } from "./vue-components.es16.js";
4
+ import { isObject as T } from "./vue-components.es17.js";
5
+ import { computed as x, onUnmounted as D, onMounted as Z, onBeforeUnmount as G, watch as W, ref as Q, h as B } from "vue";
6
+ import X from "./vue-components.es18.js";
7
+ import Y from "./vue-components.es19.js";
8
+ import C from "./vue-components.es20.js";
9
+ import { generateMetaFromSchema as ee } from "./vue-components.es12.js";
10
+ import re from "./vue-components.es6.js";
11
+ import te from "./vue-components.es8.js";
12
+ import ne from "./vue-components.es21.js";
13
+ import { trace as R } from "./vue-components.es22.js";
14
+ import { context as _ } from "./vue-components.es23.js";
15
+ class se extends z.TaggedError("FormErrors") {
16
16
  }
17
- const ce = (m) => function(i) {
17
+ const E = (c) => function(i) {
18
+ return {
19
+ render() {
20
+ return B(i, {
21
+ form: c,
22
+ ...this.$attrs
23
+ }, this.$slots);
24
+ }
25
+ };
26
+ }, oe = (c) => function(i) {
18
27
  return {
19
28
  setup() {
20
- const { fieldMap: h, form: v } = m, d = v.useStore((c) => c.errors), f = v.useStore((c) => c.fieldMeta), F = v.useStore((c) => c.errorMap), M = V(() => {
21
- const c = g.filterMap(
22
- Object.entries(f.value),
29
+ const { fieldMap: S, form: v } = c, m = v.useStore((u) => u.errors), p = v.useStore((u) => u.fieldMeta), F = v.useStore((u) => u.errorMap), M = x(() => {
30
+ const u = g.filterMap(
31
+ Object.entries(p.value),
23
32
  ([j, o]) => {
24
- const w = o.errors ?? [];
25
- if (!w.length) return A.none();
26
- const a = h.value.get(j);
27
- return a ? A.some({
33
+ const b = o.errors ?? [];
34
+ if (!b.length) return P.none();
35
+ const a = S.value.get(j);
36
+ return a ? P.some({
28
37
  label: a.label,
29
38
  inputId: a.id,
30
39
  // Only show the first error
31
- errors: [w[0]?.message].filter(Boolean)
32
- }) : A.none();
40
+ errors: [b[0]?.message].filter(Boolean)
41
+ }) : P.none();
33
42
  }
34
43
  ), O = [];
35
44
  if (F.value.onSubmit) {
36
45
  for (const [j, o] of Object.entries(F.value.onSubmit))
37
46
  if (g.isArray(o) && o.length)
38
- for (const w of o) {
39
- const a = w;
47
+ for (const b of o) {
48
+ const a = b;
40
49
  if (a?.path && g.isArray(a.path) && a.path.length) {
41
- const y = a.path.join(".");
42
- if (!h.value.has(y)) {
50
+ const w = a.path.join(".");
51
+ if (!S.value.has(w)) {
43
52
  O.push({
44
- label: y,
45
- inputId: y,
53
+ label: w,
54
+ inputId: w,
46
55
  errors: [a.message].filter(Boolean)
47
56
  });
48
57
  break;
@@ -50,206 +59,183 @@ const ce = (m) => function(i) {
50
59
  }
51
60
  }
52
61
  }
53
- return [...c, ...O];
62
+ return [...u, ...O];
54
63
  });
55
64
  return {
56
- generalErrors: d,
65
+ generalErrors: m,
57
66
  errors: M
58
67
  };
59
68
  },
60
- render({ errors: h, generalErrors: v }) {
61
- return b(i, {
62
- errors: h,
69
+ render({ errors: S, generalErrors: v }) {
70
+ return B(i, {
71
+ errors: S,
63
72
  generalErrors: v,
64
73
  ...this.$attrs
65
74
  }, this.$slots);
66
75
  }
67
76
  };
68
- }, Oe = (m, p, i) => {
69
- if (!m) throw new Error("Schema is required");
70
- const h = W.standardSchemaV1(m), v = W.decode(m), { meta: d } = ne(m), f = V(() => {
77
+ }, ye = (c, f, i) => {
78
+ if (!c) throw new Error("Schema is required");
79
+ const S = k.standardSchemaV1(c), v = k.decode(c), { meta: m } = ee(c), p = x(() => {
71
80
  if (i?.persistency?.id)
72
81
  return i.persistency.id;
73
- const e = window.location.pathname, r = Object.keys(d);
82
+ const e = window.location.pathname, r = Object.keys(m);
74
83
  return `${e}-${r.join("-")}`;
75
84
  }), F = () => {
76
85
  const e = new URLSearchParams(window.location.search);
77
- e.delete(f.value);
86
+ e.delete(p.value);
78
87
  const r = new URL(window.location.href);
79
88
  r.search = e.toString(), window.history.replaceState({}, "", r.toString());
80
89
  };
81
90
  function M(e, r) {
82
- for (const s in r)
83
- r[s] && X(r[s]) ? (e[s] || (e[s] = {}), M(e[s], r[s])) : e[s] = r[s];
91
+ for (const n in r)
92
+ r[n] && T(r[n]) ? (e[n] || (e[n] = {}), M(e[n], r[n])) : e[n] = r[n];
84
93
  return e;
85
94
  }
86
- const c = (e) => {
95
+ const u = (e) => {
87
96
  const r = { ...e };
88
- for (const s in d) {
89
- const n = d[s], t = r[s], E = (t == null || t === !1 || t === "" || Number.isNaN(t)) && t !== !1 && t !== 0;
90
- n && !n.required && n.nullableOrUndefined && n.type !== "boolean" && (t === void 0 || E) && (r[s] = n.nullableOrUndefined === "undefined" ? void 0 : null);
97
+ for (const n in m) {
98
+ const s = m[n], t = r[n], y = (t == null || t === !1 || t === "" || Number.isNaN(t)) && t !== !1 && t !== 0;
99
+ s && !s.required && s.nullableOrUndefined && s.type !== "boolean" && (t === void 0 || y) && (r[n] = s.nullableOrUndefined === "undefined" ? void 0 : null);
91
100
  }
92
101
  return r;
93
- }, O = V(() => {
94
- const e = p?.defaultValues ? c(p.defaultValues) : void 0;
102
+ }, O = x(() => {
103
+ const e = f?.defaultValues ? u(f.defaultValues) : void 0;
95
104
  if (e && !i?.persistency?.overrideDefaultValues)
96
105
  return e;
97
106
  let r;
98
- const s = i?.persistency;
99
- if (!s?.policies || s.policies.length === 0) return {};
100
- if (s.policies.includes("querystring"))
107
+ const n = i?.persistency;
108
+ if (!n?.policies || n.policies.length === 0) return {};
109
+ if (n.policies.includes("querystring"))
101
110
  try {
102
- const t = new URLSearchParams(window.location.search).get(f.value);
111
+ const t = new URLSearchParams(window.location.search).get(p.value);
103
112
  F(), t && (r = JSON.parse(t));
104
- } catch (n) {
105
- console.error(n);
113
+ } catch (s) {
114
+ console.error(s);
106
115
  }
107
116
  if (
108
117
  // query string has higher priority than local/session storage
109
- !r && (s.policies.includes("local") || s.policies.includes("session"))
118
+ !r && (n.policies.includes("local") || n.policies.includes("session"))
110
119
  ) {
111
- const n = s.policies.includes("local") ? localStorage : sessionStorage;
112
- if (n)
120
+ const s = n.policies.includes("local") ? localStorage : sessionStorage;
121
+ if (s)
113
122
  try {
114
123
  const t = JSON.parse(
115
- n.getItem(f.value) || "{}"
124
+ s.getItem(p.value) || "{}"
116
125
  );
117
- n.removeItem(f.value), r = t;
126
+ s.removeItem(p.value), r = t;
118
127
  } catch (t) {
119
128
  console.error(t);
120
129
  }
121
130
  }
122
131
  return r ??= {}, e ? M(e, r) : r;
123
- }), j = (e, r) => e ? L.with(x.setSpan(L.active(), e), r) : r(), o = Z({
124
- ...p,
132
+ }), j = (e, r) => e ? _.with(R.setSpan(_.active(), e), r) : r(), o = J({
133
+ ...f,
125
134
  validators: {
126
- onSubmit: h,
127
- ...p?.validators || {}
135
+ onSubmit: S,
136
+ ...f?.validators || {}
128
137
  },
129
- onSubmit: p?.onSubmit ? ({ formApi: e, meta: r, value: s }) => j(r?.currentSpan, async () => {
130
- const n = await l.runPromise(v(s)), t = p.onSubmit({
138
+ onSubmit: f?.onSubmit ? ({ formApi: e, meta: r, value: n }) => j(r?.currentSpan, async () => {
139
+ const s = await l.runPromise(v(n)), t = f.onSubmit({
131
140
  formApi: e,
132
141
  meta: r,
133
- value: n
142
+ value: s
134
143
  });
135
- return N.isFiber(t) && N.isRuntimeFiber(t) ? await Q(t) : l.isEffect(t) ? await l.runPromise(
144
+ return N.isFiber(t) && N.isRuntimeFiber(t) ? await K(t) : l.isEffect(t) ? await l.runPromise(
136
145
  t.pipe(
137
146
  // meta?.currentSpan
138
147
  // ? Effect.withParentSpan(meta.currentSpan)
139
148
  // : (_) => _,
140
- l.flatMap((u) => N.join(u))
149
+ l.flatMap((d) => N.join(d))
141
150
  )
142
151
  ) : t;
143
152
  }) : void 0,
144
153
  defaultValues: O.value
145
- }), w = () => {
146
- Object.keys(d).forEach((e) => {
154
+ }), b = () => {
155
+ Object.keys(m).forEach((e) => {
147
156
  o.setFieldValue(e, void 0);
148
157
  });
149
- }, a = (e) => e.reduce((r, s) => {
150
- const n = s.split(".");
151
- return n.reduce((t, u, E) => (E === n.length - 1 ? t[u] = o.getFieldValue(s) : t[u] = t[u] ?? {}, t[u]), r), r;
152
- }, {}), y = (e) => {
158
+ }, a = (e) => e.reduce((r, n) => {
159
+ const s = n.split(".");
160
+ return s.reduce((t, d, y) => (y === s.length - 1 ? t[d] = o.getFieldValue(n) : t[d] = t[d] ?? {}, t[d]), r), r;
161
+ }, {}), w = (e) => {
153
162
  if (e) {
154
163
  if (g.isArray(e.keys))
155
164
  return a(e.keys);
156
165
  if (g.isArray(e.banKeys)) {
157
- const r = Object.keys(d).filter((s) => e.banKeys?.includes(s));
166
+ const r = Object.keys(m).filter((n) => e.banKeys?.includes(n));
158
167
  return a(r);
159
168
  }
160
169
  return o.store.state.values;
161
170
  }
162
- }, P = () => {
171
+ }, U = () => {
163
172
  const e = i?.persistency;
164
173
  if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
165
174
  const r = e.policies.includes("local") ? localStorage : sessionStorage;
166
175
  if (!r) return;
167
- const s = y(e);
168
- return r.setItem(f.value, JSON.stringify(s));
176
+ const n = w(e);
177
+ return r.setItem(p.value, JSON.stringify(n));
169
178
  }
170
- }, I = () => {
179
+ }, L = () => {
171
180
  const e = i?.persistency;
172
181
  if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
173
- const r = y(e), s = new URLSearchParams(window.location.search);
174
- s.set(f.value, JSON.stringify(r));
175
- const n = new URL(window.location.href);
176
- n.search = s.toString(), window.history.replaceState({}, "", n.toString());
182
+ const r = w(e), n = new URLSearchParams(window.location.search);
183
+ n.set(p.value, JSON.stringify(r));
184
+ const s = new URL(window.location.href);
185
+ s.search = n.toString(), window.history.replaceState({}, "", s.toString());
177
186
  }
178
- }, _ = (e) => {
187
+ }, V = (e) => {
179
188
  o.store.state.isDirty && e.preventDefault();
180
189
  };
181
- if ($(P), Y(() => {
182
- window.addEventListener("beforeunload", P), window.addEventListener("blur", I), i?.preventWindowExit && i.preventWindowExit !== "nope" && window.addEventListener("beforeunload", _);
183
- }), C(() => {
184
- window.removeEventListener("beforeunload", P), window.removeEventListener("blur", I), i?.preventWindowExit && i.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", _);
190
+ if (D(U), Z(() => {
191
+ window.addEventListener("beforeunload", U), window.addEventListener("blur", L), i?.preventWindowExit && i.preventWindowExit !== "nope" && window.addEventListener("beforeunload", V);
192
+ }), G(() => {
193
+ window.removeEventListener("beforeunload", U), window.removeEventListener("blur", L), i?.preventWindowExit && i.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", V);
185
194
  }), i?.preventWindowExit === "prevent-and-reset") {
186
- const e = o.useStore((t) => t.isSubmitting), r = o.useStore((t) => t.submissionAttempts), s = o.useStore((t) => t.canSubmit), n = o.useStore((t) => t.values);
187
- R([e, r], ([t, u], [E]) => {
188
- E && !t && u > 0 && s.value && o.reset(n.value);
195
+ const e = o.useStore((t) => t.isSubmitting), r = o.useStore((t) => t.submissionAttempts), n = o.useStore((t) => t.canSubmit), s = o.useStore((t) => t.values);
196
+ W([e, r], ([t, d], [y]) => {
197
+ y && !t && d > 0 && n.value && o.reset(s.value);
189
198
  });
190
199
  }
191
- const D = (e) => l.currentSpan.pipe(
200
+ const I = (e) => l.currentSpan.pipe(
192
201
  l.option,
193
202
  l.flatMap(
194
- (r) => l.promise(() => o.handleSubmit(A.isSome(r) ? { currentSpan: r.value, ...e } : e))
203
+ (r) => l.promise(() => o.handleSubmit(P.isSome(r) ? { currentSpan: r.value, ...e } : e))
195
204
  )
196
- ), B = (e) => e?.checkErrors ? D(e?.meta).pipe(l.flatMap(l.fnUntraced(function* () {
205
+ ), q = (e) => e?.checkErrors ? I(e?.meta).pipe(l.flatMap(l.fnUntraced(function* () {
197
206
  const r = o.getAllErrors();
198
207
  if (Object.keys(r.fields).length || r.form.errors.length)
199
- return yield* new le({ form: r.form, fields: r.fields });
200
- }))) : D(e?.meta), q = o.handleSubmit, U = ee(/* @__PURE__ */ new Map()), S = Object.assign(o, {
208
+ return yield* new se({ form: r.form, fields: r.fields });
209
+ }))) : I(e?.meta), H = o.handleSubmit, A = Q(/* @__PURE__ */ new Map()), h = Object.assign(o, {
201
210
  i18nNamespace: i?.i18nNamespace,
202
211
  ignorePreventCloseEvents: i?.ignorePreventCloseEvents,
203
- meta: d,
204
- clear: w,
212
+ meta: m,
213
+ clear: b,
205
214
  handleSubmit: (e) => {
206
- const r = x.getSpan(L.active());
207
- return q({ currentSpan: r, ...e });
215
+ const r = R.getSpan(_.active());
216
+ return H({ currentSpan: r, ...e });
208
217
  },
209
218
  // /** @experimental */
210
- handleSubmitEffect: B,
219
+ handleSubmitEffect: q,
211
220
  registerField: (e) => {
212
- R(e, (r) => U.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), $(() => U.value.delete(e.value.name));
221
+ W(e, (r) => A.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), D(() => A.value.delete(e.value.name));
213
222
  }
214
- }), k = { form: S, fieldMap: U }, J = (e, r) => {
215
- const s = i?.input ?? oe;
216
- return b(s, {
217
- ...e,
218
- form: S,
219
- ...r?.attrs
220
- }, r?.slots);
221
- }, z = (e, r) => b(ce(k)(se), {
222
- ...e,
223
- ...r?.attrs
224
- }, r?.slots), K = (e, r) => b(ie, {
225
- ...e,
226
- form: S,
227
- ...r?.attrs
228
- }, r?.slots), T = (e, r) => b(re, {
229
- ...e,
230
- form: S,
231
- ...r?.attrs
232
- }, r?.slots), H = (e, r) => b(te, {
233
- ...e,
234
- form: S,
235
- ...r?.attrs
236
- }, r?.slots);
237
- return Object.assign(S, {
238
- errorContext: k,
239
- Form: (e, r) => b(ae, {
240
- ...e,
241
- form: S,
242
- ...r?.attrs
243
- }, r?.slots),
244
- Input: J,
245
- TaggedUnion: K,
223
+ }), $ = { form: h, fieldMap: A };
224
+ return Object.assign(h, {
225
+ // Type-level properties for performance optimization (not used at runtime)
226
+ _paths: void 0,
227
+ _keys: void 0,
228
+ errorContext: $,
229
+ Form: E(h)(ne),
230
+ Input: E(h)(i?.input ?? re),
231
+ TaggedUnion: E(h)(te),
246
232
  Field: o.Field,
247
- Errors: z,
248
- Array: T,
249
- AutoGen: H
233
+ Errors: oe($)(C),
234
+ Array: E(h)(X),
235
+ AutoGen: E(h)(Y)
250
236
  });
251
237
  };
252
238
  export {
253
- le as FormErrors,
254
- Oe as useOmegaForm
239
+ se as FormErrors,
240
+ ye as useOmegaForm
255
241
  };
@@ -1,7 +1,7 @@
1
1
  import { defineComponent as m, createElementBlock as d, openBlock as u, withModifiers as f, createElementVNode as l, unref as s, renderSlot as a } from "vue";
2
2
  import { useStore as b } from "@tanstack/vue-form";
3
3
  import { usePreventClose as p } from "./vue-components.es11.js";
4
- import { getOmegaStore as c } from "./vue-components.es53.js";
4
+ import { getOmegaStore as c } from "./vue-components.es52.js";
5
5
  const S = ["disabled"], V = /* @__PURE__ */ m({
6
6
  __name: "OmegaWrapper",
7
7
  props: {
@@ -1,6 +1,13 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");if(i.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(i),window.customElements){const e=window.customElements.define;window.customElements.define=function(s,t){const n=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(n&&n.call(this),this.shadowRoot){const a=document.createElement("style");a.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(a)}},e.call(window.customElements,s,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
- import o from "./vue-components.es38.js";
3
-
1
+ import { useStore as u } from "@tanstack/vue-form";
2
+ import { computed as f } from "vue";
3
+ function c(o, t) {
4
+ return f(() => t ? u(o.store, (n) => {
5
+ const r = {};
6
+ for (const e of t)
7
+ r[e] = n[e];
8
+ return r;
9
+ }).value : {});
10
+ }
4
11
  export {
5
- o as default
12
+ c as getOmegaStore
6
13
  };
@@ -1,13 +1,6 @@
1
- import { useStore as u } from "@tanstack/vue-form";
2
- import { computed as f } from "vue";
3
- function c(o, t) {
4
- return f(() => t ? u(o.store, (n) => {
5
- const r = {};
6
- for (const e of t)
7
- r[e] = n[e];
8
- return r;
9
- }).value : {});
10
- }
1
+ (function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");if(i.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(i),window.customElements){const e=window.customElements.define;window.customElements.define=function(s,t){const n=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(n&&n.call(this),this.shadowRoot){const a=document.createElement("style");a.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(a)}},e.call(window.customElements,s,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
+ import o from "./vue-components.es38.js";
3
+
11
4
  export {
12
- c as getOmegaStore
5
+ o as default
13
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "2.4.9",
3
+ "version": "2.4.10",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^3.18.0",
@@ -45,14 +45,15 @@
45
45
  generic="
46
46
  // dprint ignore - somehow with 120 chars, this becomes a mess. should report it.
47
47
  From extends Record<PropertyKey, any>,
48
- To extends Record<PropertyKey, any>
48
+ To extends Record<PropertyKey, any>,
49
+ Name extends DeepKeys<From>
49
50
  "
50
51
  >
51
52
  import { type DeepKeys } from "@tanstack/vue-form"
52
53
  import { computed, onMounted, provide } from "vue"
53
54
  import { type OmegaArrayProps } from "./OmegaFormStuff"
54
55
 
55
- const props = defineProps<OmegaArrayProps<From, To>>()
56
+ const props = defineProps<OmegaArrayProps<From, To, Name>>()
56
57
 
57
58
  defineOptions({
58
59
  inheritAttrs: false
@@ -4,7 +4,7 @@
4
4
  :child="{ name, label, ...attrs }"
5
5
  >
6
6
  <form.Input
7
- :name="name"
7
+ :name="name as FieldPath<From>"
8
8
  :label="label"
9
9
  v-bind="attrs"
10
10
  />
@@ -16,15 +16,16 @@
16
16
  lang="ts"
17
17
  generic="
18
18
  From extends Record<PropertyKey, string>,
19
- To extends Record<PropertyKey, string>
19
+ To extends Record<PropertyKey, string>,
20
+ Name extends DeepKeys<From>
20
21
  "
21
22
  >
22
23
  import { type DeepKeys } from "@tanstack/vue-form"
23
24
  import { Array as A, Order, pipe } from "effect-app"
24
25
  import { computed } from "vue"
25
- import { type FieldMeta, type OmegaAutoGenMeta, type OmegaInputProps } from "./OmegaFormStuff"
26
+ import { type FieldMeta, type FieldPath, type OmegaAutoGenMeta, type OmegaInputProps } from "./OmegaFormStuff"
26
27
 
27
- type NewMeta = OmegaAutoGenMeta<From, To>
28
+ type NewMeta = OmegaAutoGenMeta<From, To, Name>
28
29
 
29
30
  const mapObject = <K extends string, A, B>(fn: (value: A, key: K) => B) => (obj: Record<K, A>): Record<K, B> =>
30
31
  Object.fromEntries(
@@ -51,7 +52,7 @@ const filterMapRecord =
51
52
  )
52
53
 
53
54
  const props = defineProps<{
54
- form: OmegaInputProps<From, To>["form"]
55
+ form: OmegaInputProps<From, To, Name>["form"]
55
56
  pick?: DeepKeys<From>[]
56
57
  omit?: DeepKeys<From>[]
57
58
  labelMap?: (key: DeepKeys<From>) => string | undefined
@@ -27,7 +27,8 @@ import { OmegaFormKey } from "./useOmegaForm"
27
27
 
28
28
  const form = inject(OmegaFormKey) as unknown as OmegaInputProps<
29
29
  From,
30
- To
30
+ To,
31
+ Name
31
32
  >["form"]
32
33
 
33
34
  if (!form) {
@@ -35,7 +36,7 @@ if (!form) {
35
36
  }
36
37
 
37
38
  defineProps<
38
- BaseProps<From> & DefaultTypeProps
39
+ BaseProps<From, Name> & DefaultTypeProps
39
40
  >()
40
41
 
41
42
  defineSlots<{
@@ -17,19 +17,19 @@ export type FieldPath<T> = unknown extends T ? string
17
17
  // technically we cannot have primitive at the root
18
18
  : T extends string | boolean | number | null | undefined | symbol | bigint ? ""
19
19
  // technically we cannot have array at the root
20
- : T extends ReadonlyArray<infer U> ? Compute<FieldPath_<U, `[${number}]`>>
20
+ : T extends ReadonlyArray<infer U> ? FieldPath_<U, `[${number}]`>
21
21
  : {
22
- [K in keyof T]: Compute<FieldPath_<T[K], `${K & string}`>>
22
+ [K in keyof T]: FieldPath_<T[K], `${K & string}`>
23
23
  }[keyof T]
24
24
 
25
25
  export type FieldPath_<T, Path extends string> = unknown extends T ? string
26
26
  : T extends string | boolean | number | null | undefined | symbol | bigint ? Path
27
- : T extends ReadonlyArray<infer U> ? Compute<FieldPath_<U, `${Path}[${number}]`>> | Path
27
+ : T extends ReadonlyArray<infer U> ? FieldPath_<U, `${Path}[${number}]`> | Path
28
28
  : {
29
- [K in keyof T]: Compute<FieldPath_<T[K], `${Path}.${K & string}`>>
29
+ [K in keyof T]: FieldPath_<T[K], `${Path}.${K & string}`>
30
30
  }[keyof T]
31
31
 
32
- export type BaseProps<From, TName extends FieldPath<From> = FieldPath<From>> = {
32
+ export type BaseProps<From, TName extends FieldPath<From>> = {
33
33
  /**
34
34
  * Will fallback to i18n when not specified.
35
35
  * Can also be provided via #label slot for custom HTML labels.
@@ -64,31 +64,34 @@ export type DefaultTypeProps = {
64
64
 
65
65
  export type OmegaInputPropsBase<
66
66
  From extends Record<PropertyKey, any>,
67
- To extends Record<PropertyKey, any>
67
+ To extends Record<PropertyKey, any>,
68
+ Name extends DeepKeys<From>
68
69
  > = {
69
70
  form: OF<From, To> & {
70
71
  meta: MetaRecord<From>
71
72
  i18nNamespace?: string
72
73
  }
73
- } & BaseProps<From>
74
+ } & BaseProps<From, Name>
74
75
 
75
76
  export type OmegaInputProps<
76
77
  From extends Record<PropertyKey, any>,
77
78
  To extends Record<PropertyKey, any>,
79
+ Name extends DeepKeys<From>,
78
80
  TypeProps = DefaultTypeProps
79
81
  > = {
80
82
  form: OmegaFormReturn<From, To, TypeProps> & {
81
83
  meta: MetaRecord<From>
82
84
  i18nNamespace?: string
83
85
  }
84
- } & BaseProps<From>
86
+ } & BaseProps<From, Name>
85
87
 
86
88
  export type OmegaArrayProps<
87
89
  From extends Record<PropertyKey, any>,
88
- To extends Record<PropertyKey, any>
90
+ To extends Record<PropertyKey, any>,
91
+ Name extends DeepKeys<From>
89
92
  > =
90
93
  & Omit<
91
- OmegaInputProps<From, To>,
94
+ OmegaInputProps<From, To, Name>,
92
95
  "validators" | "options" | "label" | "type" | "items" | "name"
93
96
  >
94
97
  & {
@@ -886,8 +889,9 @@ export const nullableInput = <A, I, R>(
886
889
 
887
890
  export type OmegaAutoGenMeta<
888
891
  From extends Record<PropertyKey, any>,
889
- To extends Record<PropertyKey, any>
890
- > = Omit<OmegaInputProps<From, To>, "form">
892
+ To extends Record<PropertyKey, any>,
893
+ Name extends DeepKeys<From>
894
+ > = Omit<OmegaInputProps<From, To, Name>, "form">
891
895
 
892
896
  const supportedInputs = [
893
897
  "button",
@@ -40,7 +40,8 @@
40
40
  generic="
41
41
  // dprint ignore - somehow with 120 chars, this becomes a mess. should report it.
42
42
  From extends Record<PropertyKey, any>,
43
- To extends Record<PropertyKey, any>
43
+ To extends Record<PropertyKey, any>,
44
+ Name extends DeepKeys<From>
44
45
  "
45
46
  >
46
47
  import { type DeepKeys } from "@tanstack/vue-form"
@@ -49,7 +50,7 @@ import { useIntl } from "../../utils"
49
50
  import { type FieldMeta, generateInputStandardSchemaFromFieldMeta, type OmegaInputPropsBase } from "./OmegaFormStuff"
50
51
  import OmegaInternalInput from "./OmegaInternalInput.vue"
51
52
 
52
- const props = defineProps<OmegaInputPropsBase<From, To>>()
53
+ const props = defineProps<OmegaInputPropsBase<From, To, Name>>()
53
54
 
54
55
  // downgrade to *as* DeepKeys<From> to avoid useless and possible infinite recursion in TS
55
56
  const propsName = computed(() => props.name as DeepKeys<From>)