import { html, nothing, type TemplateResult } from 'lit'; import type { NuiType } from '../../types/nui-type.js'; import type { SelectOption } from './types.js'; export interface NuiSelectViewState { value: string; options: SelectOption[]; placeholder: string; disabled: boolean; invalid: boolean; fluid: boolean; size: 'small' | '' | 'large'; variant: '' | 'filled' | 'borderless'; selectClass: string; open: boolean; nuiType: NuiType; } export interface NuiSelectHandlers { onToggle: () => void; onSelect: (value: string) => void; onKeydown: (e: KeyboardEvent) => void; } export function renderSelect( state: NuiSelectViewState, handlers: NuiSelectHandlers, ): TemplateResult { const getTriggerClass = () => ['nui-select', state.selectClass].filter(Boolean).join(' '); const selectedLabel = state.options.find((o) => o.value === state.value)?.label ?? state.placeholder; const hasValue = Boolean(state.value); return html`