@effect-app/vue-components 4.0.0-beta.150 → 4.0.0-beta.151

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.
@@ -91,6 +91,7 @@ export type FieldValidators<T> = {
91
91
  export type BaseFieldMeta = {
92
92
  required: boolean;
93
93
  nullableOrUndefined?: false | "undefined" | "null";
94
+ originalSchema?: StandardSchemaV1<any, any>;
94
95
  /**
95
96
  * True when the schema property is `S.optionalKey` (AST
96
97
  * `context.isOptional`) — i.e. the key should be ABSENT from the submitted
@@ -154,7 +155,7 @@ export type CreateMeta = {
154
155
  property: S.AST.AST;
155
156
  });
156
157
  export declare const isNullableOrUndefined: (property: false | S.AST.AST | undefined) => false | "undefined" | "null";
157
- export declare const createMeta: <T = any>({ meta, parent, property, propertySignatures }: CreateMeta, acc?: Partial<MetaRecord<T>>) => MetaRecord<T> | FieldMeta;
158
+ export declare const createMeta: <T = any>({ meta, parent, property, propertySignatures }: CreateMeta, acc?: Partial<MetaRecord<T>>, fieldAstByPath?: Record<string, S.AST.AST>) => MetaRecord<T> | FieldMeta;
158
159
  export declare const toFormSchema: <From, To>(schema: S.Codec<To, From, never>) => S.Codec<To, From, never>;
159
160
  export declare const duplicateSchema: <From, To>(schema: S.Codec<To, From, never>) => S.Codec<To, From, never, never>;
160
161
  export declare const generateMetaFromSchema: <From, To>(schema: S.Codec<To, From, never>) => {
@@ -72,29 +72,29 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
72
72
  }
73
73
  } else a.AST.isBoolean(e) ? t.type = "boolean" : a.AST.isDeclaration(e) && e.annotations?.typeConstructor?._tag === "Date" ? t.type = "date" : t.type = "unknown";
74
74
  return t;
75
- }, b = ({ meta: e = {}, parent: t = "", property: n, propertySignatures: r }, i = {}) => {
75
+ }, b = ({ meta: e = {}, parent: t = "", property: n, propertySignatures: r }, i = {}, o) => {
76
76
  if (n &&= c(n), n && a.AST.isObjects(n)) return b({
77
77
  meta: e,
78
78
  propertySignatures: n.propertySignatures
79
79
  });
80
80
  if (r) {
81
81
  for (let n of r) {
82
- let r = t ? `${t}.${n.name.toString()}` : n.name.toString(), o = f(n.type), s = n.type.context?.isOptional === !0, l;
83
- l = e._isNullableDiscriminatedUnion && n.name.toString() === "_tag" || e.required === !1 || s ? !1 : !o;
84
- let u = c(n.type);
82
+ let r = t ? `${t}.${n.name.toString()}` : n.name.toString(), s = f(n.type), l = n.type.context?.isOptional === !0, u;
83
+ u = e._isNullableDiscriminatedUnion && n.name.toString() === "_tag" || e.required === !1 || l ? !1 : !s;
84
+ let d = c(n.type);
85
85
  if (a.AST.isUnion(n.type)) {
86
86
  let e = m(n.type.types);
87
87
  if (e.some(a.AST.isObjects)) {
88
- o || (i[r] = b({
88
+ s || (i[r] = b({
89
89
  parent: r,
90
90
  property: n.type,
91
91
  meta: {
92
- required: l,
93
- nullableOrUndefined: o
92
+ required: u,
93
+ nullableOrUndefined: s
94
94
  }
95
95
  }));
96
96
  for (let t of e) if (a.AST.isObjects(t)) {
97
- let n = o && e.length > 1, a = b({
97
+ let n = s && e.length > 1, a = b({
98
98
  parent: r,
99
99
  propertySignatures: t.propertySignatures,
100
100
  meta: n ? { _isNullableDiscriminatedUnion: !0 } : {}
@@ -112,9 +112,9 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
112
112
  type: "multiple",
113
113
  members: e.elements,
114
114
  rest: e.rest,
115
- required: l,
116
- nullableOrUndefined: o
117
- }, e.rest && e.rest.length > 0) {
115
+ required: u,
116
+ nullableOrUndefined: s
117
+ }, o && (o[r] = n.type), e.rest && e.rest.length > 0) {
118
118
  let t = c(e.rest[0]);
119
119
  if (a.AST.isObjects(t)) for (let e of t.propertySignatures) {
120
120
  let t = `${r}.${e.name.toString()}`, n = b({
@@ -125,7 +125,7 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
125
125
  nullableOrUndefined: f(e.type)
126
126
  }
127
127
  });
128
- if (n && typeof n == "object" && "type" in n && (i[t] = n, n.type === "multiple" && a.AST.isArrays(e.type) && e.type.rest && e.type.rest.length > 0)) {
128
+ if (n && typeof n == "object" && "type" in n && (i[t] = n, o && (o[t] = e.type), n.type === "multiple" && a.AST.isArrays(e.type) && e.type.rest && e.type.rest.length > 0)) {
129
129
  let n = c(e.type.rest[0]);
130
130
  if (a.AST.isObjects(n)) for (let e of n.propertySignatures) {
131
131
  let n = `${t}.${e.name.toString()}`, r = b({
@@ -136,7 +136,7 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
136
136
  nullableOrUndefined: f(e.type)
137
137
  }
138
138
  });
139
- r && typeof r == "object" && "type" in r && (i[n] = r);
139
+ r && typeof r == "object" && "type" in r && (i[n] = r, o && (o[n] = e.type));
140
140
  }
141
141
  }
142
142
  }
@@ -145,19 +145,19 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
145
145
  parent: r,
146
146
  property: n.type,
147
147
  meta: {
148
- required: l,
149
- nullableOrUndefined: o
148
+ required: u,
149
+ nullableOrUndefined: s
150
150
  }
151
- });
151
+ }), o && (o[r] = n.type);
152
152
  }
153
- } else if (a.AST.isObjects(u)) Object.assign(i, b({
153
+ } else if (a.AST.isObjects(d)) Object.assign(i, b({
154
154
  parent: r,
155
- propertySignatures: u.propertySignatures,
155
+ propertySignatures: d.propertySignatures,
156
156
  meta: {
157
- required: l,
158
- nullableOrUndefined: o
157
+ required: u,
158
+ nullableOrUndefined: s
159
159
  }
160
- }));
160
+ }, {}, o));
161
161
  else if (a.AST.isArrays(n.type)) if (n.type.rest.length > 0 && a.AST.isObjects(c(n.type.rest[0]))) {
162
162
  let e = c(n.type.rest[0]);
163
163
  if (a.AST.isObjects(e)) for (let t of e.propertySignatures) {
@@ -173,7 +173,7 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
173
173
  required: !f(t.type),
174
174
  nullableOrUndefined: f(t.type)
175
175
  }
176
- });
176
+ }), o && (o[n] = t.type);
177
177
  }
178
178
  else i[e] = {
179
179
  type: "multiple",
@@ -181,7 +181,7 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
181
181
  rest: t.type.rest,
182
182
  required: !f(t.type),
183
183
  nullableOrUndefined: f(t.type)
184
- };
184
+ }, o && (o[e] = t.type);
185
185
  } else i[e] = b({
186
186
  parent: e,
187
187
  property: t.type,
@@ -189,24 +189,24 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
189
189
  required: !f(t.type),
190
190
  nullableOrUndefined: f(t.type)
191
191
  }
192
- });
192
+ }), o && (o[e] = t.type);
193
193
  }
194
194
  } else i[r] = {
195
195
  type: "multiple",
196
196
  members: n.type.elements,
197
197
  rest: n.type.rest,
198
- required: l,
199
- nullableOrUndefined: o
200
- };
198
+ required: u,
199
+ nullableOrUndefined: s
200
+ }, o && (o[r] = n.type);
201
201
  else i[r] = b({
202
202
  parent: r,
203
203
  property: n.type,
204
204
  meta: {
205
- required: l && (!a.AST.isString(u) || !!y(u).minLength),
206
- nullableOrUndefined: o,
207
- ...s ? { isOptionalKey: !0 } : {}
205
+ required: u && (!a.AST.isString(d) || !!y(d).minLength),
206
+ nullableOrUndefined: s,
207
+ ...l ? { isOptionalKey: !0 } : {}
208
208
  }
209
- });
209
+ }), o && (o[r] = n.type);
210
210
  }
211
211
  return i;
212
212
  }
@@ -263,22 +263,45 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
263
263
  }
264
264
  return n;
265
265
  }, S = (e) => {
266
- let t = c(e.ast), n = {}, r = {}, i = {};
266
+ let t = c(e.ast), n = {}, r = {}, i = {}, l = {}, d = (e, t) => {
267
+ let n = a.make(e), r = t ? n : a.NullishOr(n);
268
+ return a.toStandardSchemaV1(r);
269
+ }, f = (e) => {
270
+ for (let [t, n] of Object.entries(l)) {
271
+ let r = e[t];
272
+ if (r) try {
273
+ let e = r.required ?? !0;
274
+ Object.defineProperty(r, "originalSchema", {
275
+ value: d(n, e),
276
+ enumerable: !1,
277
+ configurable: !0,
278
+ writable: !0
279
+ });
280
+ } catch {
281
+ Object.defineProperty(r, "originalSchema", {
282
+ value: a.toStandardSchemaV1(a.Unknown),
283
+ enumerable: !1,
284
+ configurable: !0,
285
+ writable: !0
286
+ });
287
+ }
288
+ }
289
+ };
267
290
  if (a.AST.isUnion(t)) {
268
291
  let e = m(t.types);
269
292
  if (e.every(a.AST.isObjects) && e.length > 0) {
270
293
  let t = [];
271
294
  for (let r of e) if (a.AST.isObjects(r)) {
272
- let e = r.propertySignatures.find((e) => e.name.toString() === "_tag"), c = null, l = e ? u(e.type) : null;
273
- l && a.AST.isLiteral(l) && (c = l.literal, t.push(c), e && a.AST.isUnion(e.type) && s() && c != null && !o.has(c) && (o.add(c), console.warn(`[OmegaForm] Union member with _tag "${c}" uses S.Struct({ _tag: S.Literal("${c}"), ... }). Please migrate to S.TaggedStruct("${c}", { ... }) for cleaner AST handling.`)));
274
- let d = b({ propertySignatures: r.propertySignatures });
275
- c && (i[c] = x(d)), Object.assign(n, d);
295
+ let e = r.propertySignatures.find((e) => e.name.toString() === "_tag"), c = null, d = e ? u(e.type) : null;
296
+ d && a.AST.isLiteral(d) && (c = d.literal, t.push(c), e && a.AST.isUnion(e.type) && s() && c != null && !o.has(c) && (o.add(c), console.warn(`[OmegaForm] Union member with _tag "${c}" uses S.Struct({ _tag: S.Literal("${c}"), ... }). Please migrate to S.TaggedStruct("${c}", { ... }) for cleaner AST handling.`)));
297
+ let f = b({ propertySignatures: r.propertySignatures }, {}, l);
298
+ c && (i[c] = x(f)), Object.assign(n, f);
276
299
  }
277
300
  return t.length > 0 && (n._tag = {
278
301
  type: "select",
279
302
  members: t,
280
303
  required: !0
281
- }), {
304
+ }), f(n), {
282
305
  meta: n,
283
306
  defaultValues: r,
284
307
  unionMeta: i
@@ -286,12 +309,15 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
286
309
  }
287
310
  }
288
311
  if (a.AST.isObjects(t)) {
289
- let e = b({ propertySignatures: t.propertySignatures });
290
- if (Object.values(e).every((e) => e && "type" in e)) return {
291
- meta: e,
292
- defaultValues: r,
293
- unionMeta: i
294
- };
312
+ let e = b({ propertySignatures: t.propertySignatures }, {}, l);
313
+ if (Object.values(e).every((e) => e && "type" in e)) {
314
+ let t = e;
315
+ return f(t), {
316
+ meta: t,
317
+ defaultValues: r,
318
+ unionMeta: i
319
+ };
320
+ }
295
321
  let a = (e, t = "") => {
296
322
  for (let r in e) {
297
323
  let i = t ? `${t}.${r}` : r;
@@ -300,7 +326,7 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
300
326
  };
301
327
  a(e);
302
328
  }
303
- return {
329
+ return f(n), {
304
330
  meta: n,
305
331
  defaultValues: r,
306
332
  unionMeta: i
@@ -22,15 +22,22 @@ var y = /* @__PURE__ */ c({
22
22
  if (!e) return b.value;
23
23
  let t = e;
24
24
  return `${b.value}-${t.type}-${t.minLength ?? ""}-${t.maxLength ?? ""}-${t.minimum ?? ""}-${t.maximum ?? ""}`;
25
- }), { trans: E } = e(), D = i(() => {
25
+ }), { trans: E } = e(), D = (e) => Array.isArray(e?.issues) && e.issues.length > 0, O = (e, t) => ({ "~standard": {
26
+ ...e["~standard"],
27
+ validate: (n) => {
28
+ let r = e["~standard"].validate(n);
29
+ return r && typeof r.then == "function" ? r.then((e) => D(e) ? e : t["~standard"].validate(n)) : D(r) ? r : t["~standard"].validate(n);
30
+ }
31
+ } }), k = i(() => {
26
32
  if (!w.value) throw console.log(y.name, Object.keys(y.form.meta), y.form.meta), Error("Meta is undefined");
27
- return t(w.value, E);
28
- }), O = r(y.form);
33
+ let e = t(w.value, E), n = w.value.originalSchema;
34
+ return n ? O(e, n) : e;
35
+ }), A = r(y.form);
29
36
  return (e, t) => (p(), a(h(c.form.Field), {
30
37
  key: T.value,
31
38
  name: c.name,
32
39
  validators: {
33
- onBlur: D.value,
40
+ onBlur: k.value,
34
41
  ...c.validators
35
42
  }
36
43
  }, {
@@ -42,7 +49,7 @@ var y = /* @__PURE__ */ c({
42
49
  field: t,
43
50
  state: r,
44
51
  register: c.form.registerField,
45
- label: c.label ?? g(O)(b.value),
52
+ label: c.label ?? g(A)(b.value),
46
53
  meta: w.value
47
54
  }), s({
48
55
  default: v((t) => [m(e.$slots, "default", f(l(t)))]),
@@ -77,7 +77,7 @@ var te = class extends S.TaggedError("FormErrors") {}, k = (e) => function(t) {
77
77
  };
78
78
  }, M = (e, t) => e.includes(t), N = O(x.empty()), P = (e, h, x) => {
79
79
  if (!e) throw Error("Schema is required");
80
- let S = i(e), O = E.toStandardSchemaV1(S), A = E.decodeUnknownEffect(S), { meta: P, unionMeta: ne } = r(e), F = m(() => x?.persistency?.id ? x.persistency.id : `${window.location.pathname}-${Object.keys(P).join("-")}`), I = () => {
80
+ let S = i(e), O = E.toStandardSchemaV1(S), A = E.decodeUnknownEffect(S), { meta: P, unionMeta: ne } = r(S), F = m(() => x?.persistency?.id ? x.persistency.id : `${window.location.pathname}-${Object.keys(P).join("-")}`), I = () => {
81
81
  let e = new URLSearchParams(window.location.search);
82
82
  e.delete(F.value);
83
83
  let t = new URL(window.location.href);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "4.0.0-beta.150",
3
+ "version": "4.0.0-beta.151",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^4.0.0-beta.56",
@@ -58,8 +58,8 @@
58
58
  "highlight.js": "^11.11.1",
59
59
  "mitt": "^3.0.1",
60
60
  "vue3-highlightjs": "^1.0.5",
61
- "effect-app": "4.0.0-beta.150",
62
- "@effect-app/vue": "4.0.0-beta.150"
61
+ "@effect-app/vue": "4.0.0-beta.151",
62
+ "effect-app": "4.0.0-beta.151"
63
63
  },
64
64
  "scripts": {
65
65
  "check": "vue-tsc",
@@ -256,6 +256,7 @@ export type FieldValidators<T> = {
256
256
  export type BaseFieldMeta = {
257
257
  required: boolean
258
258
  nullableOrUndefined?: false | "undefined" | "null"
259
+ originalSchema?: StandardSchemaV1<any, any>
259
260
  /**
260
261
  * True when the schema property is `S.optionalKey` (AST
261
262
  * `context.isOptional`) — i.e. the key should be ABSENT from the submitted
@@ -509,7 +510,8 @@ const getFieldMetadataFromAst = (property: S.AST.AST) => {
509
510
 
510
511
  export const createMeta = <T = any>(
511
512
  { meta = {}, parent = "", property, propertySignatures }: CreateMeta,
512
- acc: Partial<MetaRecord<T>> = {}
513
+ acc: Partial<MetaRecord<T>> = {},
514
+ fieldAstByPath?: Record<string, S.AST.AST>
513
515
  ): MetaRecord<T> | FieldMeta => {
514
516
  if (property) {
515
517
  property = unwrapDeclaration(property)
@@ -608,6 +610,9 @@ export const createMeta = <T = any>(
608
610
  required: isRequired,
609
611
  nullableOrUndefined
610
612
  } as FieldMeta
613
+ if (fieldAstByPath) {
614
+ fieldAstByPath[key] = p.type
615
+ }
611
616
 
612
617
  // If the array has struct elements, also create metadata for their properties
613
618
  if (arrayType.rest && arrayType.rest.length > 0) {
@@ -628,6 +633,9 @@ export const createMeta = <T = any>(
628
633
  // add to accumulator if valid
629
634
  if (propMeta && typeof propMeta === "object" && "type" in propMeta) {
630
635
  acc[propKey as NestedKeyOf<T>] = propMeta as FieldMeta
636
+ if (fieldAstByPath) {
637
+ fieldAstByPath[propKey] = prop.type
638
+ }
631
639
 
632
640
  if (
633
641
  propMeta.type === "multiple" && S.AST.isArrays(prop.type) && prop
@@ -651,6 +659,9 @@ export const createMeta = <T = any>(
651
659
  // add to accumulator if valid
652
660
  if (nestedPropMeta && typeof nestedPropMeta === "object" && "type" in nestedPropMeta) {
653
661
  acc[nestedPropKey as NestedKeyOf<T>] = nestedPropMeta as FieldMeta
662
+ if (fieldAstByPath) {
663
+ fieldAstByPath[nestedPropKey] = nestedProp.type
664
+ }
654
665
  }
655
666
  }
656
667
  }
@@ -667,17 +678,24 @@ export const createMeta = <T = any>(
667
678
  meta: { required: isRequired, nullableOrUndefined }
668
679
  })
669
680
  acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
681
+ if (fieldAstByPath) {
682
+ fieldAstByPath[key] = p.type
683
+ }
670
684
  }
671
685
  }
672
686
  } else {
673
687
  if (S.AST.isObjects(typeToProcess)) {
674
688
  Object.assign(
675
689
  acc,
676
- createMeta<T>({
677
- parent: key,
678
- propertySignatures: typeToProcess.propertySignatures,
679
- meta: { required: isRequired, nullableOrUndefined }
680
- })
690
+ createMeta<T>(
691
+ {
692
+ parent: key,
693
+ propertySignatures: typeToProcess.propertySignatures,
694
+ meta: { required: isRequired, nullableOrUndefined }
695
+ },
696
+ {},
697
+ fieldAstByPath
698
+ )
681
699
  )
682
700
  } else if (S.AST.isArrays(p.type)) {
683
701
  // Check if it has struct elements
@@ -708,6 +726,9 @@ export const createMeta = <T = any>(
708
726
  }
709
727
  })
710
728
  acc[nestedKey as NestedKeyOf<T>] = nestedMeta as FieldMeta
729
+ if (fieldAstByPath) {
730
+ fieldAstByPath[nestedKey] = nestedProp.type
731
+ }
711
732
  }
712
733
  } else {
713
734
  // Array with primitive elements - create meta for the array itself
@@ -718,6 +739,9 @@ export const createMeta = <T = any>(
718
739
  required: !isNullableOrUndefined(prop.type),
719
740
  nullableOrUndefined: isNullableOrUndefined(prop.type)
720
741
  } as FieldMeta
742
+ if (fieldAstByPath) {
743
+ fieldAstByPath[propKey] = prop.type
744
+ }
721
745
  }
722
746
  } else {
723
747
  const fieldMeta = createMeta<T>({
@@ -729,6 +753,9 @@ export const createMeta = <T = any>(
729
753
  }
730
754
  })
731
755
  acc[propKey as NestedKeyOf<T>] = fieldMeta as FieldMeta
756
+ if (fieldAstByPath) {
757
+ fieldAstByPath[propKey] = prop.type
758
+ }
732
759
  }
733
760
  }
734
761
  }
@@ -741,6 +768,9 @@ export const createMeta = <T = any>(
741
768
  required: isRequired,
742
769
  nullableOrUndefined
743
770
  } as FieldMeta
771
+ if (fieldAstByPath) {
772
+ fieldAstByPath[key] = p.type
773
+ }
744
774
  }
745
775
  } else {
746
776
  const newMeta = createMeta<T>({
@@ -757,6 +787,9 @@ export const createMeta = <T = any>(
757
787
  })
758
788
 
759
789
  acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
790
+ if (fieldAstByPath) {
791
+ fieldAstByPath[key] = p.type
792
+ }
760
793
  }
761
794
  }
762
795
  }
@@ -861,11 +894,50 @@ const flattenMeta = <T>(meta: MetaRecord<T> | FieldMeta, parentKey: string = "")
861
894
 
862
895
  const metadataFromAst = <From, To>(
863
896
  schema: S.Codec<To, From, never>
864
- ): { meta: MetaRecord<To>; defaultValues: Record<string, any>; unionMeta: Record<string, MetaRecord<To>> } => {
897
+ ): {
898
+ meta: MetaRecord<To>
899
+ defaultValues: Record<string, any>
900
+ unionMeta: Record<string, MetaRecord<To>>
901
+ } => {
865
902
  const ast = unwrapDeclaration(schema.ast)
866
903
  const newMeta: MetaRecord<To> = {}
867
904
  const defaultValues: Record<string, any> = {}
868
905
  const unionMeta: Record<string, MetaRecord<To>> = {}
906
+ const fieldAstByPath: Record<string, S.AST.AST> = {}
907
+
908
+ const toFieldStandardSchema = (
909
+ propertyAst: S.AST.AST,
910
+ required: boolean
911
+ ): StandardSchemaV1<any, any> => {
912
+ const base = S.make(propertyAst)
913
+ const fieldSchema = required ? base : S.NullishOr(base)
914
+ return S.toStandardSchemaV1(fieldSchema as any)
915
+ }
916
+
917
+ const attachOriginalSchemas = (metaRecord: MetaRecord<To>) => {
918
+ for (const [key, fieldAst] of Object.entries(fieldAstByPath)) {
919
+ const fieldMeta = metaRecord[key as NestedKeyOf<To>]
920
+ if (!fieldMeta) {
921
+ continue
922
+ }
923
+ try {
924
+ const required = fieldMeta.required ?? true
925
+ Object.defineProperty(fieldMeta, "originalSchema", {
926
+ value: toFieldStandardSchema(fieldAst, required),
927
+ enumerable: false,
928
+ configurable: true,
929
+ writable: true
930
+ })
931
+ } catch {
932
+ Object.defineProperty(fieldMeta, "originalSchema", {
933
+ value: S.toStandardSchemaV1(S.Unknown),
934
+ enumerable: false,
935
+ configurable: true,
936
+ writable: true
937
+ })
938
+ }
939
+ }
940
+ }
869
941
 
870
942
  // Handle root-level Union types (discriminated unions)
871
943
  if (S.AST.isUnion(ast)) {
@@ -910,9 +982,13 @@ const metadataFromAst = <From, To>(
910
982
  }
911
983
 
912
984
  // Create metadata for this member's properties
913
- const memberMeta = createMeta<To>({
914
- propertySignatures: memberType.propertySignatures
915
- })
985
+ const memberMeta = createMeta<To>(
986
+ {
987
+ propertySignatures: memberType.propertySignatures
988
+ },
989
+ {},
990
+ fieldAstByPath
991
+ )
916
992
 
917
993
  // Store per-tag metadata for reactive lookup
918
994
  if (tagValue) {
@@ -933,17 +1009,28 @@ const metadataFromAst = <From, To>(
933
1009
  } as FieldMeta
934
1010
  }
935
1011
 
1012
+ attachOriginalSchemas(newMeta)
936
1013
  return { meta: newMeta, defaultValues, unionMeta }
937
1014
  }
938
1015
  }
939
1016
 
940
1017
  if (S.AST.isObjects(ast)) {
941
- const meta = createMeta<To>({
942
- propertySignatures: ast.propertySignatures
943
- })
1018
+ const meta = createMeta<To>(
1019
+ {
1020
+ propertySignatures: ast.propertySignatures
1021
+ },
1022
+ {},
1023
+ fieldAstByPath
1024
+ )
944
1025
 
945
1026
  if (Object.values(meta).every((value) => value && "type" in value)) {
946
- return { meta: meta as MetaRecord<To>, defaultValues, unionMeta }
1027
+ const typedMeta = meta as MetaRecord<To>
1028
+ attachOriginalSchemas(typedMeta)
1029
+ return {
1030
+ meta: typedMeta,
1031
+ defaultValues,
1032
+ unionMeta
1033
+ }
947
1034
  }
948
1035
 
949
1036
  const flattenObject = (
@@ -963,6 +1050,7 @@ const metadataFromAst = <From, To>(
963
1050
  flattenObject(meta)
964
1051
  }
965
1052
 
1053
+ attachOriginalSchemas(newMeta)
966
1054
  return { meta: newMeta, defaultValues, unionMeta }
967
1055
  }
968
1056
 
@@ -4,6 +4,7 @@
4
4
  :key="fieldKey"
5
5
  :name="name"
6
6
  :validators="{
7
+ // onChange: schema,
7
8
  onBlur: schema,
8
9
  ...validators
9
10
  }"
@@ -97,12 +98,45 @@ const fieldKey = computed(() => {
97
98
  // Call useIntl during setup to avoid issues when computed re-evaluates
98
99
  const { trans } = useIntl()
99
100
 
101
+ const hasIssues = (result: any): boolean => Array.isArray(result?.issues) && result.issues.length > 0
102
+
103
+ const composeStandardSchemas = (
104
+ omegaSchema: any,
105
+ originalSchema: any
106
+ ) => ({
107
+ "~standard": {
108
+ ...omegaSchema["~standard"],
109
+ validate: (value: unknown) => {
110
+ const omegaResult = omegaSchema["~standard"].validate(value)
111
+ if (omegaResult && typeof omegaResult.then === "function") {
112
+ return omegaResult.then((resolved: any) => {
113
+ if (hasIssues(resolved)) {
114
+ return resolved
115
+ }
116
+ return originalSchema["~standard"].validate(value)
117
+ })
118
+ }
119
+
120
+ if (hasIssues(omegaResult)) {
121
+ return omegaResult
122
+ }
123
+
124
+ return originalSchema["~standard"].validate(value)
125
+ }
126
+ }
127
+ })
128
+
100
129
  const schema = computed(() => {
101
130
  if (!meta.value) {
102
131
  console.log(props.name, Object.keys(props.form.meta), props.form.meta)
103
132
  throw new Error("Meta is undefined")
104
133
  }
105
- return generateInputStandardSchemaFromFieldMeta(meta.value, trans)
134
+ const omegaSchema = generateInputStandardSchemaFromFieldMeta(meta.value, trans)
135
+ const fieldSchema = meta.value.originalSchema
136
+ if (fieldSchema) {
137
+ return composeStandardSchemas(omegaSchema, fieldSchema)
138
+ }
139
+ return omegaSchema
106
140
  })
107
141
 
108
142
  const errori18n = useErrorLabel(props.form)
@@ -688,7 +688,7 @@ export const useOmegaForm = <
688
688
  const standardSchema = S.toStandardSchemaV1(formCompatibleSchema)
689
689
  const decode = S.decodeUnknownEffect(formCompatibleSchema)
690
690
 
691
- const { meta, unionMeta } = generateMetaFromSchema(schema)
691
+ const { meta, unionMeta } = generateMetaFromSchema(formCompatibleSchema)
692
692
 
693
693
  const persistencyKey = computed(() => {
694
694
  if (omegaConfig?.persistency?.id) {