{"version":3,"file":"index.mjs","sources":["../../../../../../packages/hooks/use-custom-field-value/index.ts"],"sourcesContent":["import { inject, watch } from 'vue'\n\nimport type { InjectionKey, Ref } from 'vue'\n\nexport type CustomFieldInjectionValue = {\n  customValue: Ref<(() => unknown) | undefined>\n  resetValidation: () => void\n  validateWithTrigger: (trigger: 'onBlur' | 'onChange' | 'onSubmit') => void\n}\n\nexport const CUSTOM_FIELD_INJECTION_KEY: InjectionKey<CustomFieldInjectionValue> =\n  Symbol('xzxField')\n\nexport function useCustomFieldValue(customValue: () => unknown) {\n  const field = inject(CUSTOM_FIELD_INJECTION_KEY, null)\n\n  if (field && !field.customValue.value) {\n    field.customValue.value = customValue\n\n    watch(customValue, () => {\n      field.resetValidation()\n      field.validateWithTrigger('onChange')\n    })\n  }\n}\n"],"names":[],"mappings":";;AAUa,MAAA,0BAAA,GACX,OAAO,UAAU,EAAA;AAEZ,SAAS,oBAAoB,WAA4B,EAAA;AAC9D,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,0BAAA,EAA4B,IAAI,CAAA,CAAA;AAErD,EAAA,IAAI,KAAS,IAAA,CAAC,KAAM,CAAA,WAAA,CAAY,KAAO,EAAA;AACrC,IAAA,KAAA,CAAM,YAAY,KAAQ,GAAA,WAAA,CAAA;AAE1B,IAAA,KAAA,CAAM,aAAa,MAAM;AACvB,MAAA,KAAA,CAAM,eAAgB,EAAA,CAAA;AACtB,MAAA,KAAA,CAAM,oBAAoB,UAAU,CAAA,CAAA;AAAA,KACrC,CAAA,CAAA;AAAA,GACH;AACF;;;;"}