import { type Accessor, createContext, useContext } from "solid-js"; export type TextDirection = "ltr" | "rtl"; /** * Default context value — resolves to `"ltr"` when no `` * wraps the consumer. */ const DEFAULT_DIRECTION: Accessor = () => "ltr"; /** * Context carrying the current text direction as an `Accessor`. Provided via * Solid 2's context-as-provider pattern: * ` direction}>`. * * @internal */ export const DirectionContext = createContext>(DEFAULT_DIRECTION); /** * Read the current text direction. Returns an `Accessor` so * consumers stay reactive; call it (e.g. `useDirection()()`) to get the * current value. Defaults to `"ltr"` when no provider is mounted. */ export function useDirection(): Accessor { return useContext(DirectionContext); }