'use client'; import { createContext, useContext } from 'react'; import type { ComposerSize } from './types'; /** * Propagates the composer's `size` to slot components placed in * `composerSlots.inlineStart` / `inlineEnd` (`ComposerMenuButton`, * `ComposerModelPicker`, `ComposerToolPill`). Without this a host has * to repeat `size` on every slotted control to keep the action bar * visually aligned; with it, an explicit `size` prop on the slot * component still wins, but omitting it inherits the composer's size. */ const ComposerSizeContext = createContext(null); export const ComposerSizeProvider = ComposerSizeContext.Provider; /** * Resolve the effective size for a slotted control: an explicit prop * always wins; otherwise inherit from the composer; final fallback `md`. */ export function useResolvedComposerSize(explicit?: ComposerSize): ComposerSize { const inherited = useContext(ComposerSizeContext); return explicit ?? inherited ?? 'md'; }