@effect-app/vue-components 2.5.0 → 2.6.1

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.
@@ -677,7 +677,8 @@ export const useOmegaForm = <
677
677
  // Normalize default values based on schema metadata
678
678
  // Convert empty strings to null/undefined for nullable fields
679
679
  // Also initialize missing nullable fields with null/undefined
680
- const normalizeDefaultValues = (values: Partial<From>): Partial<From> => {
680
+ const normalizeDefaultValues = (values?: Partial<From>): Partial<From> | undefined => {
681
+ if (!values) return undefined
681
682
  const normalized: any = { ...values }
682
683
 
683
684
  // Process all fields in the schema metadata
@@ -705,11 +706,22 @@ export const useOmegaForm = <
705
706
  return normalized
706
707
  }
707
708
 
709
+ // Extract default values from schema constructors (e.g., withDefaultConstructor)
710
+ const extractSchemaDefaults = (defaultValues: Partial<From> = {}) => {
711
+ try {
712
+ // Note: Partial schemas don't have .make() method yet (https://github.com/Effect-TS/effect/issues/4222)
713
+ if ("make" in schema && typeof (schema as any).make === "function") {
714
+ return (schema as any).make(defaultValues, { disableValidation: true })
715
+ }
716
+ } catch (error) {
717
+ console.warn("Could not extract schema constructor defaults:", error)
718
+ return {}
719
+ }
720
+ }
721
+
708
722
  const defaultValues = computed(() => {
709
723
  // Normalize tanstack default values at the beginning
710
- const normalizedTanstackDefaults = tanstackFormOptions?.defaultValues
711
- ? normalizeDefaultValues(tanstackFormOptions.defaultValues)
712
- : undefined
724
+ const normalizedTanstackDefaults = extractSchemaDefaults(normalizeDefaultValues(tanstackFormOptions?.defaultValues))
713
725
 
714
726
  if (
715
727
  normalizedTanstackDefaults
@@ -764,7 +776,7 @@ export const useOmegaForm = <
764
776
  }
765
777
 
766
778
  // to be sure we have a valid object at the end of the gathering process
767
- defValuesPatch ??= {}
779
+ defValuesPatch ??= extractSchemaDefaults({})
768
780
 
769
781
  if (!normalizedTanstackDefaults) {
770
782
  // we just return what we gathered from the query/storage