import { useCallback, useImperativeHandle, useRef, type Ref } from "react"; import { useRemoteUiNode } from "../../remote/semantic-tree"; import { useThemeColors } from "../../theme/theme-context"; import { Box, Text, TextAttributes, useUiHost } from "../../ui"; import { type PromptContext, useDialog } from "../../ui/dialog"; import { ChoiceDialog } from "./choice-dialog"; import { SelectField, openSelectField, type SelectFieldHandle } from "./select-field"; import { Button } from "./button"; import { WEB_CELL_WIDTH } from "../../theme/font-scale"; export interface SelectControl { open(): void; } export interface SelectButtonOption { value: T; label: string; /** Trigger wording when the full label is too wide for a pane header. */ short?: string; description?: string; disabled?: boolean; /** A key that picks this option, shown beside it where there is room (e.g. "1"). */ hint?: string; } export interface SelectButtonProps { /** Names the dimension, e.g. "Prem". Shown before the value on the trigger. */ label: string; value: T; options: readonly SelectButtonOption[]; onChange: (value: T) => void; /** Dialog title. Defaults to `label`. */ title?: string; disabled?: boolean; /** * Draws the value as active. Panes pass `value !== default` so a row of * selects shows at a glance which ones are narrowing what you are looking at. */ emphasized?: boolean; idPrefix?: string; showLabel?: boolean; variant?: "inline" | "field"; width?: number; onFocus?: () => void; /** * Opens the choices from the keyboard. Outside a QueryBar (whose filters are * in the pane menu) the trigger has no key of its own, so a pane gives it a * footer hint or form key that calls `open()`. */ controlRef?: Ref; } /** * Single-select control usable inside a pane body, not just the settings dialog. * Desktop gets a real `