UNPKG

vuestic-ui

Version:
1 lines 1.03 kB
{"version":3,"file":"useCurrentElement.mjs","sources":["../../../../src/composables/useCurrentElement.ts"],"sourcesContent":["import { onMounted, onBeforeUnmount, shallowRef, getCurrentInstance, onUpdated, Ref } from 'vue'\n\n/** Returns ref of current component instance element */\nexport const useCurrentElement = (el?: Ref<HTMLElement | undefined>) => {\n if (el) { return el }\n const vm = getCurrentInstance()!\n const currentEl = shallowRef<HTMLElement>()\n onMounted(() => { currentEl.value = vm.proxy!.$el ?? undefined })\n onUpdated(() => { currentEl.value = vm.proxy!.$el ?? undefined })\n onBeforeUnmount(() => { currentEl.value = vm.proxy!.$el ?? undefined })\n\n return currentEl\n}\n"],"names":[],"mappings":";AAGa,MAAA,oBAAoB,CAAC,OAAsC;AACtE,MAAI,IAAI;AAAS,WAAA;AAAA,EAAG;AACpB,QAAM,KAAK;AACX,QAAM,YAAY;AAClB,YAAU,MAAM;AAAY,cAAA,QAAQ,GAAG,MAAO,OAAO;AAAA,EAAA,CAAW;AAChE,YAAU,MAAM;AAAY,cAAA,QAAQ,GAAG,MAAO,OAAO;AAAA,EAAA,CAAW;AAChE,kBAAgB,MAAM;AAAY,cAAA,QAAQ,GAAG,MAAO,OAAO;AAAA,EAAA,CAAW;AAE/D,SAAA;AACT;"}