import { type ComputedRef, computed, inject, provide, toValue } from 'vue' export type ControlSize = 'xs' | 'sm' | 'md' | 'small' | 'medium' export type ControlPosition = 'left' | 'center' | 'right' export const ControlSizeKey = 'sefirot-control-size-key' export const ControlPositionKey = 'sefirot-control-position-key' export function provideControlSize(controlSize: ComputedRef): void { provide(ControlSizeKey, controlSize) } export function provideControlPosition(controlPosition: ControlPosition): void { provide(ControlPositionKey, controlPosition) } export function useControlSize(): ComputedRef { const controlSize = inject | null>(ControlSizeKey, null) || null if (!controlSize) { throw new Error( '[sefirot] Unexpected call to `useControlSize`. This probably means' + ' you are using `` child component outside of ``.' + ' Make sure to wrap the component within `` component.' ) } return computed(() => toValue(controlSize)) } export function useControlPosition(): ControlPosition { const controlPosition = inject(ControlPositionKey, null) || null if (!controlPosition) { throw new Error( '[sefirot] Unexpected call to `useControlPosition`. This probably means' + ' you are using `` child component outside of ``.' + ' Make sure to wrap the component within `` component.' ) } return controlPosition }