@effect-app/vue-components 1.8.7 → 1.8.8

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.
@@ -120,7 +120,6 @@ export declare const duplicateSchema: <From, To>(schema: S.Schema<To, From, neve
120
120
  export declare const generateMetaFromSchema: <From, To>(schema: S.Schema<To, From, never>) => {
121
121
  schema: S.Schema<To, From, never>;
122
122
  meta: MetaRecord<To>;
123
- filterItems?: FilterItems;
124
123
  };
125
124
  export declare const generateInputStandardSchemaFromFieldMeta: (meta: FieldMeta) => StandardSchemaV1<any, any>;
126
125
  export declare const nullableInput: <A, I, R>(schema: S.Schema<A, I, R>, defaultValue: () => A) => S.transform<import("effect/Schema").NullOr<S.Schema<A, I, R>> & {
@@ -2,7 +2,7 @@ import { type DeepKeys, DeepValue, StandardSchemaV1Issue, ValidationError, Valid
2
2
  import { Effect, Order, S } from "effect-app";
3
3
  import { ComputedRef, type InjectionKey } from "vue";
4
4
  import { MergedInputProps } from "./InputProps";
5
- import { BaseProps, DefaultTypeProps, type FilterItems, type FormProps, type MetaRecord, type NestedKeyOf, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState, OmegaInputProps, ShowErrorsOn } from "./OmegaFormStuff";
5
+ import { BaseProps, DefaultTypeProps, type FormProps, type MetaRecord, type NestedKeyOf, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState, OmegaInputProps, ShowErrorsOn } from "./OmegaFormStuff";
6
6
  type keysRule<T> = {
7
7
  keys?: NestedKeyOf<T>[];
8
8
  banKeys?: "You should only use one of banKeys or keys, not both, moron";
@@ -41,7 +41,6 @@ export type OmegaConfig<T> = {
41
41
  };
42
42
  export interface OF<From, To> extends OmegaFormApi<From, To> {
43
43
  meta: MetaRecord<From>;
44
- filterItems?: FilterItems;
45
44
  clear: () => void;
46
45
  i18nNamespace?: string;
47
46
  registerField: (field: ComputedRef<{
@@ -1,29 +1,29 @@
1
- import { useForm as k } from "@tanstack/vue-form";
2
- import { Data as B, S as L, Effect as l, Fiber as b, Option as G, Array as O } from "effect-app";
3
- import { runtimeFiberAsPromise as T } from "./vue-components.es12.js";
4
- import { isObject as W } from "./vue-components.es13.js";
5
- import { computed as I, onUnmounted as U, onMounted as z, onBeforeUnmount as Q, ref as X, watch as $, h as N } from "vue";
6
- import { usePreventClose as Y } from "./vue-components.es8.js";
7
- import Z from "./vue-components.es14.js";
8
- import C from "./vue-components.es15.js";
9
- import ee from "./vue-components.es16.js";
10
- import { generateMetaFromSchema as re } from "./vue-components.es9.js";
11
- import te from "./vue-components.es5.js";
12
- import se from "./vue-components.es17.js";
13
- import { trace as A } from "./vue-components.es18.js";
14
- import { context as y } from "./vue-components.es19.js";
15
- class ne extends B.TaggedError("FormErrors") {
1
+ import { useForm as J } from "@tanstack/vue-form";
2
+ import { Data as q, S as U, Effect as a, Fiber as y, Option as K, Array as L } from "effect-app";
3
+ import { runtimeFiberAsPromise as k } from "./vue-components.es12.js";
4
+ import { isObject as B } from "./vue-components.es13.js";
5
+ import { computed as O, onUnmounted as M, onMounted as G, onBeforeUnmount as T, ref as W, watch as z, h as A } from "vue";
6
+ import { usePreventClose as Q } from "./vue-components.es8.js";
7
+ import X from "./vue-components.es14.js";
8
+ import Y from "./vue-components.es15.js";
9
+ import Z from "./vue-components.es16.js";
10
+ import { generateMetaFromSchema as C } from "./vue-components.es9.js";
11
+ import ee from "./vue-components.es5.js";
12
+ import re from "./vue-components.es17.js";
13
+ import { trace as $ } from "./vue-components.es18.js";
14
+ import { context as b } from "./vue-components.es19.js";
15
+ class te extends q.TaggedError("FormErrors") {
16
16
  }
17
- const p = (c) => function(i) {
17
+ const p = (c) => function(n) {
18
18
  return {
19
19
  render() {
20
- return N(i, {
20
+ return A(n, {
21
21
  form: c,
22
22
  ...this.$attrs
23
23
  }, this.$slots);
24
24
  }
25
25
  };
26
- }, ie = (c) => function(i) {
26
+ }, se = (c) => function(n) {
27
27
  return {
28
28
  setup() {
29
29
  return {
@@ -31,41 +31,41 @@ const p = (c) => function(i) {
31
31
  };
32
32
  },
33
33
  render({ fieldMap: h, form: S }) {
34
- return N(i, {
34
+ return A(n, {
35
35
  form: S,
36
36
  fieldMap: h,
37
37
  ...this.$attrs
38
38
  }, this.$slots);
39
39
  }
40
40
  };
41
- }, ye = (c, a, i) => {
41
+ }, ve = (c, o, n) => {
42
42
  if (!c) throw new Error("Schema is required");
43
- const h = L.standardSchemaV1(c), S = L.decode(c), { filterItems: _, meta: d } = re(c), m = I(() => {
44
- if (i?.persistency?.id)
45
- return i.persistency.id;
46
- const e = window.location.pathname, r = Object.keys(d);
43
+ const h = U.standardSchemaV1(c), S = U.decode(c), { meta: f } = C(c), d = O(() => {
44
+ if (n?.persistency?.id)
45
+ return n.persistency.id;
46
+ const e = window.location.pathname, r = Object.keys(f);
47
47
  return `${e}-${r.join("-")}`;
48
- }), D = () => {
48
+ }), N = () => {
49
49
  const e = new URLSearchParams(window.location.search);
50
- e.delete(m.value);
50
+ e.delete(d.value);
51
51
  const r = new URL(window.location.href);
52
52
  r.search = e.toString(), window.history.replaceState({}, "", r.toString());
53
53
  };
54
- function g(e, r) {
54
+ function E(e, r) {
55
55
  for (const t in r)
56
- r[t] && W(r[t]) ? (e[t] || (e[t] = {}), g(e[t], r[t])) : e[t] = r[t];
56
+ r[t] && B(r[t]) ? (e[t] || (e[t] = {}), E(e[t], r[t])) : e[t] = r[t];
57
57
  return e;
58
58
  }
59
- const R = I(() => {
60
- if (a?.defaultValues && !i?.persistency?.overrideDefaultValues)
61
- return a?.defaultValues;
59
+ const _ = O(() => {
60
+ if (o?.defaultValues && !n?.persistency?.overrideDefaultValues)
61
+ return o?.defaultValues;
62
62
  let e;
63
- const r = i?.persistency;
63
+ const r = n?.persistency;
64
64
  if (!r?.policies || r.policies.length === 0) return {};
65
65
  if (r.policies.includes("querystring"))
66
66
  try {
67
- const s = new URLSearchParams(window.location.search).get(m.value);
68
- D(), s && (e = JSON.parse(s));
67
+ const s = new URLSearchParams(window.location.search).get(d.value);
68
+ N(), s && (e = JSON.parse(s));
69
69
  } catch (t) {
70
70
  console.error(t);
71
71
  }
@@ -77,137 +77,114 @@ const p = (c) => function(i) {
77
77
  if (t)
78
78
  try {
79
79
  const s = JSON.parse(
80
- t.getItem(m.value) || "{}"
80
+ t.getItem(d.value) || "{}"
81
81
  );
82
- t.removeItem(m.value), e = s;
82
+ t.removeItem(d.value), e = s;
83
83
  } catch (s) {
84
84
  console.error(s);
85
85
  }
86
86
  }
87
- if (e ??= {}, a?.defaultValues == null)
87
+ if (e ??= {}, o?.defaultValues == null)
88
88
  return e;
89
89
  {
90
- const t = a?.defaultValues;
91
- return g(t, e);
90
+ const t = o?.defaultValues;
91
+ return E(t, e);
92
92
  }
93
- }), x = (e, r) => e ? y.with(A.setSpan(y.active(), e), r) : r(), u = k({
94
- ...a,
93
+ }), D = (e, r) => e ? b.with($.setSpan(b.active(), e), r) : r(), l = J({
94
+ ...o,
95
95
  validators: {
96
96
  onSubmit: h,
97
- ...a?.validators || {}
97
+ ...o?.validators || {}
98
98
  },
99
- onSubmit: a?.onSubmit ? ({ formApi: e, meta: r, value: t }) => x(r?.currentSpan, async () => {
100
- const s = await l.runPromise(S(t)), n = a.onSubmit({
99
+ onSubmit: o?.onSubmit ? ({ formApi: e, meta: r, value: t }) => D(r?.currentSpan, async () => {
100
+ const s = await a.runPromise(S(t)), i = o.onSubmit({
101
101
  formApi: e,
102
102
  meta: r,
103
103
  value: s
104
104
  });
105
- return b.isFiber(n) && b.isRuntimeFiber(n) ? await T(n) : l.isEffect(n) ? await l.runPromise(
106
- n.pipe(
105
+ return y.isFiber(i) && y.isRuntimeFiber(i) ? await k(i) : a.isEffect(i) ? await a.runPromise(
106
+ i.pipe(
107
107
  // meta?.currentSpan
108
108
  // ? Effect.withParentSpan(meta.currentSpan)
109
109
  // : (_) => _,
110
- l.flatMap((f) => b.join(f))
110
+ a.flatMap((m) => y.join(m))
111
111
  )
112
- ) : n;
112
+ ) : i;
113
113
  }) : void 0,
114
- defaultValues: R.value
115
- }), H = () => {
116
- Object.keys(d).forEach((e) => {
117
- u.setFieldValue(e, void 0);
114
+ defaultValues: _.value
115
+ }), I = () => {
116
+ Object.keys(f).forEach((e) => {
117
+ l.setFieldValue(e, void 0);
118
118
  });
119
- }, E = (e) => e.reduce((r, t) => {
119
+ }, g = (e) => e.reduce((r, t) => {
120
120
  const s = t.split(".");
121
- return s.reduce((n, f, K) => (K === s.length - 1 ? n[f] = u.getFieldValue(t) : n[f] = n[f] ?? {}, n[f]), r), r;
121
+ return s.reduce((i, m, H) => (H === s.length - 1 ? i[m] = l.getFieldValue(t) : i[m] = i[m] ?? {}, i[m]), r), r;
122
122
  }, {}), F = (e) => {
123
123
  if (e) {
124
- if (O.isArray(e.keys))
125
- return E(e.keys);
126
- if (O.isArray(e.banKeys)) {
127
- const r = Object.keys(d).filter((t) => e.banKeys?.includes(t));
128
- return E(r);
124
+ if (L.isArray(e.keys))
125
+ return g(e.keys);
126
+ if (L.isArray(e.banKeys)) {
127
+ const r = Object.keys(f).filter((t) => e.banKeys?.includes(t));
128
+ return g(r);
129
129
  }
130
- return u.store.state.values;
130
+ return l.store.state.values;
131
131
  }
132
- }, v = () => {
133
- const e = i?.persistency;
132
+ }, w = () => {
133
+ const e = n?.persistency;
134
134
  if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
135
135
  const r = e.policies.includes("local") ? localStorage : sessionStorage;
136
136
  if (!r) return;
137
137
  const t = F(e);
138
- return r.setItem(m.value, JSON.stringify(t));
138
+ return r.setItem(d.value, JSON.stringify(t));
139
139
  }
140
140
  }, V = () => {
141
- const e = i?.persistency;
141
+ const e = n?.persistency;
142
142
  if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
143
143
  const r = F(e), t = new URLSearchParams(window.location.search);
144
- t.set(m.value, JSON.stringify(r));
144
+ t.set(d.value, JSON.stringify(r));
145
145
  const s = new URL(window.location.href);
146
146
  s.search = t.toString(), window.history.replaceState({}, "", s.toString());
147
147
  }
148
148
  };
149
- U(v), z(() => {
150
- window.addEventListener("beforeunload", v), window.addEventListener("blur", V);
151
- }), Q(() => {
152
- window.removeEventListener("beforeunload", v), window.removeEventListener("blur", V);
149
+ M(w), G(() => {
150
+ window.addEventListener("beforeunload", w), window.addEventListener("blur", V);
151
+ }), T(() => {
152
+ window.removeEventListener("beforeunload", w), window.removeEventListener("blur", V);
153
153
  });
154
- const j = (e) => l.currentSpan.pipe(
155
- l.option,
156
- l.flatMap(
157
- (r) => l.promise(() => u.handleSubmit(G.isSome(r) ? { currentSpan: r.value, ...e } : e))
154
+ const P = (e) => a.currentSpan.pipe(
155
+ a.option,
156
+ a.flatMap(
157
+ (r) => a.promise(() => l.handleSubmit(K.isSome(r) ? { currentSpan: r.value, ...e } : e))
158
158
  )
159
- ), J = (e) => e?.checkErrors ? j(e?.meta).pipe(l.flatMap(l.fnUntraced(function* () {
160
- const r = u.getAllErrors();
159
+ ), R = (e) => e?.checkErrors ? P(e?.meta).pipe(a.flatMap(a.fnUntraced(function* () {
160
+ const r = l.getAllErrors();
161
161
  if (Object.keys(r.fields).length || r.form.errors.length)
162
- return yield* new ne({ form: r.form, fields: r.fields });
163
- }))) : j(e?.meta), q = u.handleSubmit, w = X(/* @__PURE__ */ new Map()), o = Object.assign(u, {
164
- i18nNamespace: i?.i18nNamespace,
165
- meta: d,
166
- filterItems: _,
167
- clear: H,
162
+ return yield* new te({ form: r.form, fields: r.fields });
163
+ }))) : P(e?.meta), x = l.handleSubmit, v = W(/* @__PURE__ */ new Map()), u = Object.assign(l, {
164
+ i18nNamespace: n?.i18nNamespace,
165
+ meta: f,
166
+ clear: I,
168
167
  handleSubmit: (e) => {
169
- const r = A.getSpan(y.active());
170
- return q({ currentSpan: r, ...e });
168
+ const r = $.getSpan(b.active());
169
+ return x({ currentSpan: r, ...e });
171
170
  },
172
171
  // /** @experimental */
173
- handleSubmitEffect: J,
172
+ handleSubmitEffect: R,
174
173
  registerField: (e) => {
175
- $(e, (r) => w.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), U(() => w.value.delete(e.value.name));
174
+ z(e, (r) => v.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), M(() => v.value.delete(e.value.name));
176
175
  }
177
- }), M = o.useStore((e) => e.errors);
178
- $(
179
- () => [o.filterItems, M.value],
180
- () => {
181
- const e = o.filterItems, r = M.value;
182
- return e ? r ? (Object.values(r).filter(
183
- (s) => !!s
184
- ).flatMap(
185
- (s) => Object.values(s).flat().map((n) => n.message)
186
- ).some((s) => s === e.message) && e.items.forEach((s) => {
187
- const n = o.getFieldMeta(s);
188
- n && o.setFieldMeta(s, {
189
- ...n,
190
- errorMap: {
191
- onSubmit: [
192
- { path: [s], message: e.message }
193
- ]
194
- }
195
- });
196
- }), {}) : {} : {};
197
- }
198
- );
199
- const P = { form: o, fieldMap: w };
200
- return i?.ignorePreventCloseEvents || Y(() => o.useStore((e) => e.isDirty)), Object.assign(o, {
201
- errorContext: P,
202
- Form: p(o)(se),
203
- Input: p(o)(i?.input ?? te),
204
- Field: u.Field,
205
- Errors: ie(P)(ee),
206
- Array: p(o)(Z),
207
- AutoGen: p(o)(C)
176
+ }), j = { form: u, fieldMap: v };
177
+ return n?.ignorePreventCloseEvents || Q(() => u.useStore((e) => e.isDirty)), Object.assign(u, {
178
+ errorContext: j,
179
+ Form: p(u)(re),
180
+ Input: p(u)(n?.input ?? ee),
181
+ Field: l.Field,
182
+ Errors: se(j)(Z),
183
+ Array: p(u)(X),
184
+ AutoGen: p(u)(Y)
208
185
  });
209
186
  };
210
187
  export {
211
- ne as FormErrors,
212
- ye as useOmegaForm
188
+ te as FormErrors,
189
+ ve as useOmegaForm
213
190
  };
@@ -1,162 +1,163 @@
1
- import { S as n, Option as c, pipe as q } from "effect-app";
2
- import { getMetadataFromSchema as U } from "@effect-app/vue/form";
3
- import { useIntl as _, getTransformationFrom as N } from "./vue-components.es3.js";
4
- const w = n.NonEmptyArray(n.String), E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKeyword" || i === n.Null.ast), g = (e) => !e || !n.AST.isUnion(e) ? !1 : e.types.find((i) => i._tag === "UndefinedKeyword") ? "undefined" : e.types.find((i) => i === n.Null.ast) ? "null" : !1, m = ({ meta: e = {}, parent: i = "", property: t, propertySignatures: p }, o = {}) => {
1
+ import { S as n, Option as L } from "effect-app";
2
+ import { getMetadataFromSchema as M } from "@effect-app/vue/form";
3
+ import { useIntl as U, getTransformationFrom as _ } from "./vue-components.es3.js";
4
+ n.NonEmptyArray(n.String);
5
+ const E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKeyword" || i === n.Null.ast), f = (e) => !e || !n.AST.isUnion(e) ? !1 : e.types.find((i) => i._tag === "UndefinedKeyword") ? "undefined" : e.types.find((i) => i === n.Null.ast) ? "null" : !1, u = ({ meta: e = {}, parent: i = "", property: t, propertySignatures: d }, o = {}) => {
5
6
  if (t && t._tag === "Transformation")
6
- return m({
7
+ return u({
7
8
  parent: i,
8
9
  meta: e,
9
10
  property: t.from
10
11
  });
11
12
  if (t?._tag === "TypeLiteral" && "propertySignatures" in t)
12
- return m({
13
+ return u({
13
14
  meta: e,
14
15
  propertySignatures: t.propertySignatures
15
16
  });
16
- if (p) {
17
- for (const r of p) {
18
- const l = i ? `${i}.${r.name.toString()}` : r.name.toString(), a = g(r.type), u = !a, A = r.type;
17
+ if (d) {
18
+ for (const r of d) {
19
+ const p = i ? `${i}.${r.name.toString()}` : r.name.toString(), a = f(r.type), l = !a, O = r.type;
19
20
  if (n.AST.isUnion(r.type)) {
20
- const T = r.type.types.filter(
21
+ const S = r.type.types.filter(
21
22
  (s) => s._tag !== "UndefinedKeyword" && s !== n.Null.ast
22
- ).map(N);
23
- if (T.some(
23
+ ).map(_);
24
+ if (S.some(
24
25
  (s) => "propertySignatures" in s
25
26
  )) {
26
27
  if (!a) {
27
- const s = m({
28
- parent: l,
28
+ const s = u({
29
+ parent: p,
29
30
  property: r.type,
30
- meta: { required: u, nullableOrUndefined: a }
31
+ meta: { required: l, nullableOrUndefined: a }
31
32
  });
32
- o[l] = s;
33
+ o[p] = s;
33
34
  }
34
- for (const s of T)
35
+ for (const s of S)
35
36
  "propertySignatures" in s && Object.assign(
36
37
  o,
37
- m({
38
- parent: l,
38
+ u({
39
+ parent: p,
39
40
  propertySignatures: s.propertySignatures,
40
- meta: { required: u, nullableOrUndefined: a }
41
+ meta: { required: l, nullableOrUndefined: a }
41
42
  })
42
43
  );
43
44
  } else {
44
- const s = T.filter(n.AST.isTupleType);
45
+ const s = S.filter(n.AST.isTupleType);
45
46
  if (s.length > 0) {
46
- const f = s[0];
47
- if (o[l] = {
47
+ const y = s[0];
48
+ if (o[p] = {
48
49
  type: "multiple",
49
- members: f.elements,
50
- rest: f.rest,
51
- required: u,
50
+ members: y.elements,
51
+ rest: y.rest,
52
+ required: l,
52
53
  nullableOrUndefined: a
53
- }, f.rest && f.rest.length > 0) {
54
- const d = f.rest[0];
55
- if (d.type._tag === "TypeLiteral" && "propertySignatures" in d.type)
56
- for (const y of d.type.propertySignatures) {
57
- const b = `${l}.${y.name.toString()}`, S = m({
58
- parent: b,
59
- property: y.type,
54
+ }, y.rest && y.rest.length > 0) {
55
+ const g = y.rest[0];
56
+ if (g.type._tag === "TypeLiteral" && "propertySignatures" in g.type)
57
+ for (const m of g.type.propertySignatures) {
58
+ const T = `${p}.${m.name.toString()}`, c = u({
59
+ parent: T,
60
+ property: m.type,
60
61
  meta: {
61
- required: !g(y.type),
62
- nullableOrUndefined: g(y.type)
62
+ required: !f(m.type),
63
+ nullableOrUndefined: f(m.type)
63
64
  }
64
65
  });
65
- if (S && typeof S == "object" && "type" in S && (o[b] = S, S.type === "multiple" && n.AST.isTupleType(y.type) && y.type.rest && y.type.rest.length > 0)) {
66
- const O = y.type.rest[0];
67
- if (O.type._tag === "TypeLiteral" && "propertySignatures" in O.type)
68
- for (const x of O.type.propertySignatures) {
69
- const M = `${b}.${x.name.toString()}`, v = m({
70
- parent: M,
71
- property: x.type,
66
+ if (c && typeof c == "object" && "type" in c && (o[T] = c, c.type === "multiple" && n.AST.isTupleType(m.type) && m.type.rest && m.type.rest.length > 0)) {
67
+ const v = m.type.rest[0];
68
+ if (v.type._tag === "TypeLiteral" && "propertySignatures" in v.type)
69
+ for (const h of v.type.propertySignatures) {
70
+ const A = `${T}.${h.name.toString()}`, x = u({
71
+ parent: A,
72
+ property: h.type,
72
73
  meta: {
73
- required: !g(x.type),
74
- nullableOrUndefined: g(x.type)
74
+ required: !f(h.type),
75
+ nullableOrUndefined: f(h.type)
75
76
  }
76
77
  });
77
- v && typeof v == "object" && "type" in v && (o[M] = v);
78
+ x && typeof x == "object" && "type" in x && (o[A] = x);
78
79
  }
79
80
  }
80
81
  }
81
82
  }
82
83
  } else {
83
- const f = m({
84
- parent: l,
84
+ const y = u({
85
+ parent: p,
85
86
  property: r.type,
86
- meta: { required: u, nullableOrUndefined: a }
87
+ meta: { required: l, nullableOrUndefined: a }
87
88
  });
88
- o[l] = f;
89
+ o[p] = y;
89
90
  }
90
91
  }
91
- } else if ("propertySignatures" in A)
92
+ } else if ("propertySignatures" in O)
92
93
  Object.assign(
93
94
  o,
94
- m({
95
- parent: l,
96
- propertySignatures: A.propertySignatures,
97
- meta: { required: u, nullableOrUndefined: a }
95
+ u({
96
+ parent: p,
97
+ propertySignatures: O.propertySignatures,
98
+ meta: { required: l, nullableOrUndefined: a }
98
99
  })
99
100
  );
100
101
  else if (n.AST.isTupleType(r.type))
101
102
  if (r.type.rest.length > 0 && r.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in r.type.rest[0].type) {
102
- const h = r.type.rest[0].type;
103
- if (h._tag === "TypeLiteral" && "propertySignatures" in h)
104
- for (const s of h.propertySignatures) {
105
- const f = `${l}.${s.name.toString()}`;
103
+ const b = r.type.rest[0].type;
104
+ if (b._tag === "TypeLiteral" && "propertySignatures" in b)
105
+ for (const s of b.propertySignatures) {
106
+ const y = `${p}.${s.name.toString()}`;
106
107
  if (n.AST.isTupleType(s.type) && s.type.rest.length > 0) {
107
- const d = s.type.rest[0].type;
108
- if (d._tag === "TypeLiteral" && "propertySignatures" in d)
109
- for (const y of d.propertySignatures) {
110
- const b = `${f}.${y.name.toString()}`, S = m({
111
- parent: b,
112
- property: y.type,
108
+ const g = s.type.rest[0].type;
109
+ if (g._tag === "TypeLiteral" && "propertySignatures" in g)
110
+ for (const m of g.propertySignatures) {
111
+ const T = `${y}.${m.name.toString()}`, c = u({
112
+ parent: T,
113
+ property: m.type,
113
114
  meta: {
114
- required: !g(y.type),
115
- nullableOrUndefined: g(y.type)
115
+ required: !f(m.type),
116
+ nullableOrUndefined: f(m.type)
116
117
  }
117
118
  });
118
- o[b] = S;
119
+ o[T] = c;
119
120
  }
120
121
  else
121
- o[f] = {
122
+ o[y] = {
122
123
  type: "multiple",
123
124
  members: s.type.elements,
124
125
  rest: s.type.rest,
125
- required: !g(s.type),
126
- nullableOrUndefined: g(s.type)
126
+ required: !f(s.type),
127
+ nullableOrUndefined: f(s.type)
127
128
  };
128
129
  } else {
129
- const d = m({
130
- parent: f,
130
+ const g = u({
131
+ parent: y,
131
132
  property: s.type,
132
133
  meta: {
133
- required: !g(s.type),
134
- nullableOrUndefined: g(s.type)
134
+ required: !f(s.type),
135
+ nullableOrUndefined: f(s.type)
135
136
  }
136
137
  });
137
- o[f] = d;
138
+ o[y] = g;
138
139
  }
139
140
  }
140
141
  } else
141
- o[l] = {
142
+ o[p] = {
142
143
  type: "multiple",
143
144
  members: r.type.elements,
144
145
  rest: r.type.rest,
145
- required: u,
146
+ required: l,
146
147
  nullableOrUndefined: a
147
148
  };
148
149
  else {
149
- const T = m({
150
- parent: l,
150
+ const S = u({
151
+ parent: p,
151
152
  property: r.type,
152
153
  meta: {
153
154
  // an empty string is valid for a S.String field, so we should not mark it as required
154
155
  // TODO: handle this better via the createMeta minLength parsing
155
- required: u && (r.type._tag !== "StringKeyword" || U(r.type).minLength),
156
+ required: l && (r.type._tag !== "StringKeyword" || M(r.type).minLength),
156
157
  nullableOrUndefined: a
157
158
  }
158
159
  });
159
- o[l] = T;
160
+ o[p] = S;
160
161
  }
161
162
  }
162
163
  return o;
@@ -165,19 +166,19 @@ const w = n.NonEmptyArray(n.String), E = (e) => n.AST.isUnion(e) && e.types.find
165
166
  const r = E(t);
166
167
  if (Object.hasOwnProperty.call(e, "required") || (e.required = !r), n.AST.isUnion(t)) {
167
168
  const a = t.types.find(
168
- (u) => u._tag !== "UndefinedKeyword" && u !== n.Null.ast
169
+ (l) => l._tag !== "UndefinedKeyword" && l !== n.Null.ast
169
170
  );
170
- return "propertySignatures" in a ? m({
171
+ return "propertySignatures" in a ? u({
171
172
  propertySignatures: a.propertySignatures,
172
173
  parent: i,
173
174
  meta: e
174
175
  }) : t.types.every(n.AST.isLiteral) ? {
175
176
  ...e,
176
177
  type: "select",
177
- members: t.types.map((u) => u.literal)
178
+ members: t.types.map((l) => l.literal)
178
179
  } : {
179
180
  ...e,
180
- ...m({
181
+ ...u({
181
182
  parent: i,
182
183
  meta: e,
183
184
  property: a
@@ -191,11 +192,11 @@ const w = n.NonEmptyArray(n.String), E = (e) => n.AST.isUnion(e) && e.types.find
191
192
  members: t.elements,
192
193
  rest: t.rest
193
194
  };
194
- const l = n.AST.getAnnotation(
195
+ const p = n.AST.getAnnotation(
195
196
  t,
196
197
  n.AST.JSONSchemaAnnotationId
197
- ).pipe(c.getOrElse(() => ({})));
198
- return e = { ...e, ...l }, "from" in t ? m({
198
+ ).pipe(L.getOrElse(() => ({})));
199
+ return e = { ...e, ...p }, "from" in t ? u({
199
200
  parent: i,
200
201
  meta: e,
201
202
  property: t.from
@@ -203,48 +204,34 @@ const w = n.NonEmptyArray(n.String), E = (e) => n.AST.isUnion(e) && e.types.find
203
204
  t,
204
205
  n.AST.TitleAnnotationId
205
206
  ).pipe(
206
- c.getOrElse(() => "unknown")
207
+ L.getOrElse(() => "unknown")
207
208
  ), e);
208
209
  }
209
210
  return o;
210
- }, L = (e) => {
211
+ }, q = (e) => {
211
212
  const i = e.ast, t = {};
212
213
  if (i._tag === "Transformation" || i._tag === "Refinement")
213
- return L(n.make(i.from));
214
+ return q(n.make(i.from));
214
215
  if ("propertySignatures" in i) {
215
- const p = m({
216
+ const d = u({
216
217
  propertySignatures: i.propertySignatures
217
218
  });
218
- if (Object.values(p).every((r) => r && "type" in r))
219
- return p;
220
- const o = (r, l = "") => {
219
+ if (Object.values(d).every((r) => r && "type" in r))
220
+ return d;
221
+ const o = (r, p = "") => {
221
222
  for (const a in r) {
222
- const u = l ? `${l}.${a}` : a;
223
- r[a] && typeof r[a] == "object" && "type" in r[a] ? t[u] = r[a] : r[a] && typeof r[a] == "object" && o(r[a], u);
223
+ const l = p ? `${p}.${a}` : a;
224
+ r[a] && typeof r[a] == "object" && "type" in r[a] ? t[l] = r[a] : r[a] && typeof r[a] == "object" && o(r[a], l);
224
225
  }
225
226
  };
226
- o(p);
227
+ o(d);
227
228
  }
228
229
  return t;
229
- }, P = (e) => n.extend(e, n.Struct({})), F = (e) => {
230
- const i = L(e), t = q(
231
- e.ast,
232
- c.liftPredicate((p) => p._tag === "Refinement" && "filter" in p),
233
- c.flatMap((p) => n.AST.getJSONSchemaAnnotation(p)),
234
- c.filter((p) => "items" in p),
235
- c.filterMap(({ items: p }) => n.decodeUnknownOption(w)(p)),
236
- c.zipWith(
237
- n.AST.getMessageAnnotation(e.ast),
238
- (p, o) => ({
239
- items: p,
240
- message: o("")
241
- })
242
- ),
243
- c.getOrUndefined
244
- );
245
- return { schema: e, meta: i, filterItems: t };
246
- }, j = (e) => {
247
- const { trans: i } = _();
230
+ }, K = (e) => n.extend(e, n.Struct({})), I = (e) => {
231
+ const i = q(e);
232
+ return { schema: e, meta: i };
233
+ }, P = (e) => {
234
+ const { trans: i } = U();
248
235
  let t;
249
236
  switch (e.type) {
250
237
  case "string":
@@ -326,12 +313,12 @@ const w = n.NonEmptyArray(n.String), E = (e) => n.AST.isUnion(e) && e.types.find
326
313
  message: () => i("validation.empty")
327
314
  })
328
315
  ) : t = n.NullishOr(t), n.standardSchemaV1(t);
329
- }, R = (e, i) => n.NullOr(e).pipe(
316
+ }, F = (e, i) => n.NullOr(e).pipe(
330
317
  n.transform(n.typeSchema(e), {
331
318
  decode: (t) => t ?? i(),
332
319
  encode: (t) => t
333
320
  })
334
- ), k = [
321
+ ), N = [
335
322
  "button",
336
323
  "checkbox",
337
324
  "color",
@@ -347,12 +334,12 @@ const w = n.NonEmptyArray(n.String), E = (e) => n.AST.isUnion(e) && e.types.find
347
334
  "text",
348
335
  "time",
349
336
  "url"
350
- ], J = (e) => k.includes(e) ? e : "text";
337
+ ], j = (e) => N.includes(e) ? e : "text";
351
338
  export {
352
- m as createMeta,
353
- P as duplicateSchema,
354
- j as generateInputStandardSchemaFromFieldMeta,
355
- F as generateMetaFromSchema,
356
- J as getInputType,
357
- R as nullableInput
339
+ u as createMeta,
340
+ K as duplicateSchema,
341
+ P as generateInputStandardSchemaFromFieldMeta,
342
+ I as generateMetaFromSchema,
343
+ j as getInputType,
344
+ F as nullableInput
358
345
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "1.8.7",
3
+ "version": "1.8.8",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^3.18.0",
@@ -1,4 +1,4 @@
1
- import { type Effect, Option, pipe, type Record, S } from "effect-app"
1
+ import { type Effect, Option, type Record, S } from "effect-app"
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
  import { getMetadataFromSchema } from "@effect-app/vue/form"
4
4
  import { type DeepKeys, type FieldAsyncValidateOrFn, type FieldValidateOrFn, type FormApi, type FormAsyncValidateOrFn, type FormOptions, type FormState, type FormValidateOrFn, type StandardSchemaV1, type VueFormApi } from "@tanstack/vue-form"
@@ -650,27 +650,10 @@ export const generateMetaFromSchema = <From, To>(
650
650
  ): {
651
651
  schema: S.Schema<To, From, never>
652
652
  meta: MetaRecord<To>
653
- filterItems?: FilterItems
654
653
  } => {
655
654
  const meta = flattenMeta(schema)
656
655
 
657
- const filterItems = pipe(
658
- schema.ast,
659
- Option.liftPredicate((s) => s._tag === "Refinement" && "filter" in s),
660
- Option.flatMap((s) => S.AST.getJSONSchemaAnnotation(s)),
661
- Option.filter((s) => "items" in s),
662
- Option.filterMap(({ items }) => S.decodeUnknownOption(isArrayOfString)(items)),
663
- Option.zipWith(
664
- S.AST.getMessageAnnotation(schema.ast),
665
- (items, message) => ({
666
- items,
667
- message: message("" as unknown as S.ParseResult.ParseIssue)
668
- })
669
- ),
670
- Option.getOrUndefined
671
- )
672
-
673
- return { schema, meta, filterItems }
656
+ return { schema, meta }
674
657
  }
675
658
 
676
659
  export const generateInputStandardSchemaFromFieldMeta = (
@@ -12,7 +12,7 @@ import { MergedInputProps } from "./InputProps"
12
12
  import OmegaArray from "./OmegaArray.vue"
13
13
  import OmegaAutoGen from "./OmegaAutoGen.vue"
14
14
  import OmegaErrorsInternal from "./OmegaErrorsInternal.vue"
15
- import { BaseProps, DefaultTypeProps, type FilterItems, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState, OmegaInputProps, ShowErrorsOn } from "./OmegaFormStuff"
15
+ import { BaseProps, DefaultTypeProps, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState, OmegaInputProps, ShowErrorsOn } from "./OmegaFormStuff"
16
16
  import OmegaInput from "./OmegaInput.vue"
17
17
  import OmegaForm from "./OmegaWrapper.vue"
18
18
 
@@ -109,7 +109,6 @@ export type OmegaConfig<T> = {
109
109
 
110
110
  export interface OF<From, To> extends OmegaFormApi<From, To> {
111
111
  meta: MetaRecord<From>
112
- filterItems?: FilterItems
113
112
  clear: () => void
114
113
  i18nNamespace?: string
115
114
  registerField: (
@@ -605,7 +604,7 @@ export const useOmegaForm = <
605
604
  const standardSchema = S.standardSchemaV1(schema)
606
605
  const decode = S.decode(schema)
607
606
 
608
- const { filterItems, meta } = generateMetaFromSchema(schema)
607
+ const { meta } = generateMetaFromSchema(schema)
609
608
 
610
609
  const persistencyKey = computed(() => {
611
610
  if (omegaConfig?.persistency?.id) {
@@ -862,7 +861,6 @@ export const useOmegaForm = <
862
861
  const formWithExtras: OF<From, To> = Object.assign(form, {
863
862
  i18nNamespace: omegaConfig?.i18nNamespace,
864
863
  meta,
865
- filterItems,
866
864
  clear,
867
865
  handleSubmit: (meta?: Record<string, any>) => {
868
866
  const span = api.trace.getSpan(api.context.active())
@@ -876,47 +874,6 @@ export const useOmegaForm = <
876
874
  }
877
875
  })
878
876
 
879
- const errors = formWithExtras.useStore((state) => state.errors)
880
-
881
- watch(
882
- () => [formWithExtras.filterItems, errors.value],
883
- () => {
884
- const filterItems: FilterItems | undefined = formWithExtras.filterItems
885
- const currentErrors = errors.value
886
- if (!filterItems) return {}
887
- if (!currentErrors) return {}
888
- const errorList = Object
889
- .values(currentErrors)
890
- .filter(
891
- (fieldErrors): fieldErrors is Record<string, StandardSchemaV1Issue[]> => Boolean(fieldErrors)
892
- )
893
- .flatMap((fieldErrors) =>
894
- Object
895
- .values(fieldErrors)
896
- .flat()
897
- .map((issue: StandardSchemaV1Issue) => issue.message)
898
- )
899
-
900
- if (errorList.some((e) => e === filterItems.message)) {
901
- // TODO: Investigate if filterItems.items should be typed based on DeepKeys<To>.
902
- filterItems.items.forEach((item: keyof From) => {
903
- const m = formWithExtras.getFieldMeta(item as any)
904
- if (m) {
905
- formWithExtras.setFieldMeta(item as any, {
906
- ...m,
907
- errorMap: {
908
- onSubmit: [
909
- { path: [item as string], message: filterItems.message }
910
- ]
911
- }
912
- })
913
- }
914
- })
915
- }
916
- return {}
917
- }
918
- )
919
-
920
877
  const errorContext = { form: formWithExtras, fieldMap }
921
878
 
922
879
  if (!omegaConfig?.ignorePreventCloseEvents) {