@pbroom/color-kit/driverMulti color

renameMultiColorEntry

Renames an entry in place, keeping its position, color and selection, and sets its source. No-op when id is unknown, nextId already exists, or the ids are equal.

functionimport { renameMultiColorEntry } from '@pbroom/color-kit/driver';multi-color-state.ts:624
function renameMultiColorEntry(
  model: MultiColorModel,
  id: string,
  nextId: string,
  source?: ColorSource,
): MultiColorModel;

Parameters

idstring
nextIdstring
source?ColorSourcedefault 'programmatic'
Source recorded on the renamed entry.

Returns

MultiColorModel

Example

TypeScript
import { createMultiColorModel, renameMultiColorEntry } from '@pbroom/color-kit/driver';

const model = createMultiColorModel({ colors: { bg: '#ffffff', fg: '#3b82f6' } });
renameMultiColorEntry(model, 'fg', 'text').order; // → ['bg', 'text']
renameMultiColorEntry(model, 'fg', 'bg') === model; // → true