@pbroom/color-kit/reactColor

UseMultiColorReturn

Collection state and operations returned by useMultiColor.

interfaceimport type { UseMultiColorReturn } from '@pbroom/color-kit/react';use-multi-color.ts:77
interface UseMultiColorReturn {
  state: MultiColorState;
  ids: string[];
  selectedId: string | null;
  selected: ColorState | null;
  setRequested: (id: string, requested: Color, options?: SetRequestedOptions) => void;
  setChannel: (id: string, channel: ColorChannel, value: number, options?: Omit<SetRequestedOptions, 'changedChannel'>) => void;
  setActiveGamut: (gamut: GamutTarget, source?: ColorSource) => void;
  setActiveView: (view: ViewModel, source?: ColorSource) => void;
  select: (id: string, interaction?: ColorInteraction) => void;
  addColor: (id: string, color: string | Color, source?: ColorSource) => void;
  removeColor: (id: string) => void;
  renameColor: (id: string, nextId: string, source?: ColorSource) => void;
}

Properties

stateMultiColorState
The full collection state.
idsstring[]
Entry ids in collection order.
selectedIdstring | null
Id of the selected entry, or null when the collection is empty.
selectedColorState | null
State of the selected entry, or null when nothing is selected.
setRequested(id: string, requested: Color, options?: SetRequestedOptions) => void
Sets the requested OKLCH color of entry id.
setChannel(id: string, channel: ColorChannel, value: number, options?: Omit<SetRequestedOptions, 'changedChannel'>) => void
Sets one OKLCH channel of entry id.
setActiveGamut(gamut: GamutTarget, source?: ColorSource) => void
Sets the display gamut shared by all entries; source defaults to 'user'.
setActiveView(view: ViewModel, source?: ColorSource) => void
Sets the view model shared by all entries; source defaults to 'user'.
select(id: string, interaction?: ColorInteraction) => void
Selects entry id; a no-op for unknown or already selected ids.
addColor(id: string, color: string | Color, source?: ColorSource) => void
Appends an entry (a no-op when id exists). Selects it when nothing is selected.
removeColor(id: string) => void
Removes entry id; removing the selected entry selects the first remaining one.
renameColor(id: string, nextId: string, source?: ColorSource) => void
Renames entry id to nextId, keeping its position and selection; a no-op when id is unknown or nextId is taken.