reka-ui
Version:
Vue port for Radix UI Primitives.
34 lines (32 loc) • 1.23 kB
JavaScript
const require_rolldown_runtime = require('../rolldown-runtime.cjs');
const vue = require_rolldown_runtime.__toESM(require("vue"));
//#region src/shared/useForwardScopeId.ts
/**
* Returns the parent component's `<style scoped>` id (e.g. `data-v-xxxxxxx`) as a
* bindable attribute object, so it can be manually forwarded onto the chosen root
* element of a multi-root component.
*
* Vue only auto-applies the parent's scope id to a **single-root** component's root.
* When a component renders multiple root nodes (e.g. an interactive control plus a
* sibling hidden form input), that fallthrough is dropped and the parent's scoped
* styles can no longer reach the component. Spread the returned object onto the
* element that should stay styleable by the parent.
*
* @example
* ```ts
* const scopeIdAttrs = useForwardScopeId()
* // <Primitive v-bind="{ ...$attrs, ...scopeIdAttrs }" />
* ```
*/
function useForwardScopeId() {
const scopeId = ((0, vue.getCurrentInstance)()?.vnode)?.scopeId;
return scopeId ? { [scopeId]: "" } : {};
}
//#endregion
Object.defineProperty(exports, 'useForwardScopeId', {
enumerable: true,
get: function () {
return useForwardScopeId;
}
});
//# sourceMappingURL=useForwardScopeId.cjs.map