@vuesax-alpha/nightly
Version:
A Component Library for Vue 3
25 lines (20 loc) • 728 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
const useGroupInject = (key) => {
const instance = vue.getCurrentInstance();
if (!instance) {
throw new Error(
"useInject hook must be called inside setup function or <script setup>"
);
}
const parent = vue.inject(key, void 0);
const index = vue.computed(() => (parent == null ? void 0 : parent.children.indexOf(instance)) || 0);
parent == null ? void 0 : parent.insert(instance);
vue.onUnmounted(() => {
parent == null ? void 0 : parent.remove(instance);
});
return parent ? { ...parent, index } : void 0;
};
exports.useGroupInject = useGroupInject;
//# sourceMappingURL=index.js.map