/** @jsxImportSource react */ import { useContext, type PropsWithChildren, type Ref } from "react"; import { accessibilityContext } from "#/components/AccessibilityContext.ts"; import { type DOMElement } from "#/dom.ts"; import { type Styles } from "#/styles.ts"; export type Props = Omit & { /** A label for the element for screen readers. */ readonly "aria-label"?: string; /** Hide the element from screen readers. */ readonly "aria-hidden"?: boolean; /** The role of the element. */ readonly "aria-role"?: | "button" | "checkbox" | "combobox" | "list" | "listbox" | "listitem" | "menu" | "menuitem" | "option" | "progressbar" | "radio" | "radiogroup" | "tab" | "tablist" | "table" | "textbox" | "timer" | "toolbar"; /** The state of the element. */ readonly "aria-state"?: { readonly busy?: boolean; readonly checked?: boolean; readonly disabled?: boolean; readonly expanded?: boolean; readonly multiline?: boolean; readonly multiselectable?: boolean; readonly readonly?: boolean; readonly required?: boolean; readonly selected?: boolean; }; }; /** `` is an essential Ink component to build your layout. It's like `
` in the browser. */ export function Box({ children, ref, backgroundColor, "aria-label": ariaLabel, "aria-hidden": ariaHidden, "aria-role": role, "aria-state": ariaState, ...style }: PropsWithChildren & { readonly ref?: Ref }) { const { isScreenReaderEnabled } = useContext(accessibilityContext); const label = ariaLabel ? {ariaLabel} : undefined; if (isScreenReaderEnabled && ariaHidden) { return null; } const boxElement = ( {isScreenReaderEnabled && label ? label : children} ); return boxElement; }