UNPKG

@ark-ui/vue

Version:

A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.

37 lines (32 loc) 1.15 kB
'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const utils = require('@zag-js/utils'); const vue = require('vue'); function hasVnodeScopeId(vnode) { if (vnode === null || typeof vnode !== "object") return false; const vnodeObj = vnode; return utils.hasProp(vnodeObj, "scopeId") && utils.isString(vnodeObj.scopeId); } function hasTypeScopeId(type) { if (type === null || typeof type !== "object") return false; const typeObj = type; return utils.hasProp(typeObj, "__scopeId") && utils.isString(typeObj.__scopeId); } function getScopeIdFromInstance(instance) { if (hasVnodeScopeId(instance.vnode)) return instance.vnode.scopeId; if (hasTypeScopeId(instance.type)) return instance.type.__scopeId; } function useScopeId() { const instance = vue.getCurrentInstance(); if (!instance) return; let scopeId = getScopeIdFromInstance(instance); if (!scopeId && instance.parent) { let parent = instance.parent; while (parent && !scopeId) { scopeId = getScopeIdFromInstance(parent); parent = parent.parent; } } return scopeId; } exports.useScopeId = useScopeId;