UNPKG

vuestic-ui

Version:
33 lines (32 loc) 892 B
import { inject, ref, computed, onMounted, onBeforeUnmount } from "vue"; import { u as useComponentUuid } from "../useComponentUuid.mjs"; import { F as FormServiceKey } from "./consts.mjs"; const useFormChild = (context) => { const formContext = inject(FormServiceKey, null); if (!formContext) { return { forceDirty: ref(false), forceHideErrorMessages: ref(false), forceHideErrors: ref(false), forceHideLoading: ref(false), fields: computed(() => []), registerField: () => { }, unregisterField: () => { }, immediate: computed(() => false) }; } const uid = useComponentUuid(); onMounted(() => { formContext.registerField(uid, context); }); onBeforeUnmount(() => { formContext.unregisterField(uid); }); return formContext; }; export { useFormChild as u }; //# sourceMappingURL=useFormChild.mjs.map