import { html, nothing, type TemplateResult } from 'lit'; import type { NuiType } from '../../types/nui-type.js'; import { hsbToCssColor, normalizeHsb } from './color-math.js'; import type { ColorFormat, ColorHsb } from './types.js'; export interface NuiColorPickerViewState { format: ColorFormat; inline: boolean; disabled: boolean; invalid: boolean; name: string; inputId: string; tabindex: number; colorPickerClass: string; nuiType: NuiType; overlayVisible: boolean; hsb: ColorHsb; hiddenValue: string; previewColor: string; } export interface ColorPickerRenderHandlers { onPreviewClick: (event: Event) => void; onPreviewKeyDown: (event: KeyboardEvent) => void; } export function getColorPickerClass(colorPickerClass: string): string { return ['nui-color-picker', colorPickerClass].filter(Boolean).join(' '); } function renderPanel(state: NuiColorPickerViewState): TemplateResult { const hsb = normalizeHsb(state.hsb); const hue = Math.round(hsb.h); const saturation = hsb.s; const brightness = hsb.b; return html`
`; } export function renderColorPicker( state: NuiColorPickerViewState, handlers: ColorPickerRenderHandlers, ): TemplateResult { const showPreview = !state.inline; return html`
${ showPreview ? html` ` : nothing } ${renderPanel(state)} ${ state.name ? html` ` : nothing }
`; } export function getPreviewColor(hsb: ColorHsb): string { return hsbToCssColor(hsb); }