@effect-app/vue-components 2.7.6 → 2.7.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.
@@ -915,11 +915,16 @@ export const generateInputStandardSchemaFromFieldMeta = (
915
915
  case "boolean":
916
916
  schema = S.Boolean
917
917
  break
918
- // todo: switch must be exhaustive or have default case, otherwise falls through with schema undefined.
919
918
 
920
919
  case "unknown":
921
920
  schema = S.Unknown
922
921
  break
922
+
923
+ default:
924
+ // For any unhandled types, use Unknown schema to prevent undefined errors
925
+ console.warn(`Unhandled field type: ${meta}`)
926
+ schema = S.Unknown
927
+ break
923
928
  }
924
929
  if (!meta.required) {
925
930
  schema = S.NullishOr(schema)
@@ -768,6 +768,22 @@ export const useOmegaForm = <
768
768
  try {
769
769
  const instance = schemaObj.make({})
770
770
  // For ExtendedClass, the instance is already in the correct encoded format
771
+ // But we need to check for nullable fields that may have been set to undefined
772
+ // instead of null, and fix them
773
+ if (schemaObj?.fields && typeof schemaObj.fields === "object") {
774
+ for (const [key, fieldSchema] of Object.entries(schemaObj.fields)) {
775
+ // Only fix fields that are undefined in the instance
776
+ if (instance[key] === undefined) {
777
+ const ast = (fieldSchema as any)?.ast
778
+ const nullableOrUndefined = isNullableOrUndefined(ast)
779
+ if (nullableOrUndefined === "null") {
780
+ instance[key] = null
781
+ } else if (nullableOrUndefined === "undefined") {
782
+ instance[key] = undefined
783
+ }
784
+ }
785
+ }
786
+ }
771
787
  return instance
772
788
  } catch {
773
789
  // If make() fails, fall through to manual extraction
@@ -819,7 +835,7 @@ export const useOmegaForm = <
819
835
  }
820
836
  } else {
821
837
  // TODO Should we put to null/undefined only leaves?
822
- const ast = (fieldSchema as any).ast
838
+ const ast = (fieldSchema as any)?.ast
823
839
  const nullableOrUndefined = isNullableOrUndefined(ast)
824
840
  switch (nullableOrUndefined) {
825
841
  case "null":
@@ -853,11 +869,16 @@ export const useOmegaForm = <
853
869
  let result: Partial<From> = {}
854
870
 
855
871
  try {
856
- // First try to use schema.make() if available
872
+ // For filtered schemas (created with S.filter), use the original unfiltered schema's make method
873
+ let schemaToUse = schema as any
874
+ if (schemaToUse?.ast?._tag === "Refinement" && schemaToUse?.from) {
875
+ schemaToUse = schemaToUse.from
876
+ }
877
+
857
878
  // First try to use schema.make() if available
858
879
  // Note: Partial schemas don't have .make() method yet (https://github.com/Effect-TS/effect/issues/4222)
859
- const decoded = (schema as any).make(defaultValues)
860
- result = S.encodeSync(partialRecursive(schema))(decoded)
880
+ const decoded = schemaToUse.make(defaultValues)
881
+ result = S.encodeSync(partialRecursive(schemaToUse))(decoded)
861
882
  } catch (error) {
862
883
  // If make() fails, try to extract defaults from AST
863
884
  if (window.location.hostname === "localhost") {