import { type Color } from 'chroma-js'; import { ControllerBase, type ControllerHost } from './Abstracts/ControllerBase'; export interface RGB { r: number; g: number; b: number; } export interface RGBA extends RGB { a: number; } export interface HSL { h: number; s: number; l: number; } export interface HSLA extends HSL { a: number; } export interface HSV { h: number; s: number; v: number; } export interface HSVA extends HSV { a: number; } export interface LAB { l: number; a: number; b: number; } export interface LABA extends LAB { alpha: number; } export interface LCH { l: number; c: number; h: number; } export interface LCHA extends LCH { alpha: number; } export interface OKLAB { l: number; a: number; b: number; } export interface OKLABA extends OKLAB { alpha: number; } export interface OKLCH { l: number; c: number; h: number; } export interface OKLCHA extends OKLCH { alpha: number; } export type { Color }; export type ColorValue = string | number | Color | HSVA | HSV | RGB | RGBA | HSL | HSLA | LAB | LABA | LCH | LCHA | OKLAB | OKLABA | OKLCH | OKLCHA; /** * The config options for a ColorController. * * @public */ export interface IColorControllerConfig { applyColorToState({ h, s, v }: { h: number; s: number; v: number; }): void; extractColorFromState(controller: ColorController): ColorValue; maintains?: 'hue' | 'saturation'; } /** * ColorController - This controller is used to manage color state and transformations. * * @public */ export declare class ColorController extends ControllerBase { private readonly _applyColorToState; private readonly _extractColorFromState; private readonly _maintains; private readonly _getColorProcesses; private _saturation; private _hue; private _color; private _previousColor; private _format; /** * Constructs a new instance of the `ColorController` class. * * @public */ constructor(host: ControllerHost, config: IColorControllerConfig); /** * Gets the maintains strategy. * * @public */ get maintains(): 'hue' | 'saturation'; /** * Gets the current hue value. * * @public */ get hue(): number; /** * Sets the hue value and updates the host. * * @public */ set hue(value: number); /** * Gets the current color value. * * @public */ get value(): ColorValue; /** * Gets the current color in the stored format. * * @public */ get color(): ColorValue; /** * Sets the color value and updates the host. * * @public */ set color(color: ColorValue); /** * Applies color from state using the configured extraction callback. * * @public */ applyColorFromState(): void; /** * Gets the color in a specific format. * * @param format - The desired color format. * @returns The color value in the specified format. * @public */ getColor(format: string): ColorValue; /** * Sets the color directly from a Color object. * * @param color - The color to set. * @public */ setColor(color: Color): void; /** * Gets the color as an HSL string. * * @returns The HSL string representation. * @public */ getHslString(): string; /** * Saves the current color as the previous color. * * @public */ savePreviousColor(): void; /** * Restores the previously saved color. * * @public */ restorePreviousColor(): void; /** * Processes color changes based on the maintains strategy. * * @param currentColor - The current color. * @param nextColor - The next color value. * @param format - The color format. * @param isString - Whether the color is a string. * @private */ private setColorProcess; /** * Sets color while maintaining the hue value. * * @param nextColor - The next color value. * @param format - The color format. * @param isString - Whether the color is a string. * @private */ private setColorMaintainHue; /** * Sets color while maintaining the saturation value. * * @param currentColor - The current color. * @param nextColor - The next color value. * @param format - The color format. * @param isString - Whether the color is a string. * @private */ private setColorMaintainSaturation; /** * Gets the hexadecimal color value. * * @param color - The color to convert. * @param isString - Whether to return as string. * @returns The hex color value. * @private */ private getHexValue; /** * Gets the RGB color value. * * @param color - The color to convert. * @param isString - Whether to return as string. * @returns The RGB color value. * @private */ private getRgbValue; /** * Gets the percentage RGB color value. * * @param color - The color to convert. * @param isString - Whether to return as string. * @returns The percentage RGB color value. * @private */ private getPrgbValue; /** * Gets the 8-digit hexadecimal color value (with alpha). * * @param color - The color to convert. * @param isString - Whether to return as string. * @returns The hex8 color value. * @private */ private getHex8Value; /** * Gets the named color value. * * @param color - The color to convert. * @returns The named color value or CSS string. * @private */ private getNameValue; /** * Gets the HSL color value. * * @param color - The color to convert. * @param isString - Whether to return as string. * @returns The HSL color value. * @private */ private getHslValue; /** * Gets the HSV color value. * * @param color - The color to convert. * @param isString - Whether to return as string. * @returns The HSV color value. * @private */ private getHsvValue; /** * Gets the LAB color value. * * @param color - The color to convert. * @param isString - Whether to return as string. * @returns The LAB color value. * @private */ private getLabValue; /** * Gets the LCH color value. * * @param color - The color to convert. * @param isString - Whether to return as string. * @returns The LCH color value. * @private */ private getLchValue; /** * Gets the OKLAB color value. * * @param color - The color to convert. * @param isString - Whether to return as string. * @returns The OKLAB color value. * @private */ private getOklabValue; /** * Gets the OKLCH color value. * * @param color - The color to convert. * @param isString - Whether to return as string. * @returns The OKLCH color value. * @private */ private getOklchValue; /** * Determines if a color value is in OKLCH format based on value ranges. * OKLCH uses L in 0-1 range, while LCH uses L in 0-100 range. * * @param color - The color object to check. * @returns True if the color appears to be in OKLCH format. * @private */ private isOklch; /** * Determines if a color value is in OKLAB format based on value ranges. * OKLAB uses L in 0-1 range, while LAB uses L in 0-100 range. * * @param color - The color object to check. * @returns True if the color appears to be in OKLAB format. * @private */ private isOklab; } //# sourceMappingURL=ColorController.d.ts.map