UNPKG

1.96 kBTypeScriptView Raw
1import * as React from 'react';
2import type { IColorPickerProps, IColorPicker } from './ColorPicker.types';
3import type { IColor } from '../../utilities/color/interfaces';
4declare type ColorComponent = keyof Pick<IColor, 'r' | 'g' | 'b' | 'a' | 't' | 'hex'>;
5export interface IColorPickerState {
6 /** Most recently selected color */
7 color: IColor;
8 /** Color component currently being edited via a text field (if intermediate value is invalid) */
9 editingColor?: {
10 /** Which color component is being edited */
11 component: ColorComponent;
12 /** Currently entered value, which is not valid */
13 value: string;
14 };
15}
16/**
17 * {@docCategory ColorPicker}
18 */
19export declare class ColorPickerBase extends React.Component<IColorPickerProps, IColorPickerState> implements IColorPicker {
20 static defaultProps: Partial<IColorPickerProps>;
21 private _textChangeHandlers;
22 /**
23 * Strings displayed in the UI as text field labels (these are in a separate object for convenient
24 * indexing by short color component name).
25 */
26 private _textLabels;
27 /** Strings besides red/green/blue/alpha/hex, with defaults for all values except the deprecated `hue` */
28 private _strings;
29 constructor(props: IColorPickerProps);
30 get color(): IColor;
31 componentDidUpdate(prevProps: Readonly<IColorPickerProps>, prevState: Readonly<IColorPickerState>): void;
32 render(): JSX.Element;
33 private _getDisplayValue;
34 private _getTooltipValue;
35 private _onSVChanged;
36 private _onHChanged;
37 /** Callback for when the alpha/transparency slider changes */
38 private _onATChanged;
39 private _onTextChange;
40 private _onBlur;
41 /**
42 * Update the displayed color and call change handlers if appropriate.
43 * @param ev - Event if call was triggered by an event (undefined if triggered by props change)
44 * @param newColor - Updated color
45 */
46 private _updateColor;
47}
48export {};