UNPKG

@iobroker/adapter-react-v5

Version:

React components to develop ioBroker interfaces with react.

87 lines (86 loc) 3.04 kB
/** * Copyright 2018-2024 Denis Haev (bluefox) <dogafox@gmail.com> * * Licensed under the Creative Commons Attribution-NonCommercial License, Version 4.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://creativecommons.org/licenses/by-nc/4.0/legalcode.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import React, { Component, type CSSProperties } from 'react'; import { type RGBColor } from 'react-color'; import type { IobTheme } from '../types'; interface ColorPickerProps { /** Set to true to disable the color picker. */ disabled?: boolean; /** The currently selected color. */ value?: string; /** @deprecated The currently selected color use value */ color?: string; /** The color change callback. */ onChange: (rgba: string) => void; /** Label of the color picker. */ label?: string; /** @deprecated TLabel of the color picker use label */ name?: string; /** Additional styling for this component. */ style?: CSSProperties; /** The CSS class name. */ className?: string; customPalette?: string[]; noInputField?: boolean; barWidth?: number; sx?: Record<string, any>; theme?: IobTheme; } interface ColorPickerState { displayColorPicker: boolean; color: string | RGBColor; anchorEl: HTMLDivElement | null; } /** * A color picker component. */ export declare class ColorPicker extends Component<ColorPickerProps, ColorPickerState> { /** * Constructor for the color picker. * * @param props The properties. */ constructor(props: ColorPickerProps); private handleClick; private handleClose; /** * Convert the given color to hex ('#rrggbb') or rgba ('rgba(r,g,b,a)') format. * * @param color The color to convert. * @param isHex If true, the color will be converted to hex format. * @returns the hex or rgba representation of the given color. */ static getColor(color: string | { rgb: RGBColor; } | RGBColor, isHex?: boolean): string; /** * Convert rgb() or rgba() format to hex format #rrggbb. * * @param rgb The color in rgb() or rgba() format. if not in this format, the color will be returned as is. */ static rgb2hex(rgb: string): string; private handleChange; /** * If the props are updated from outside, they should override the state * * @param _prevProps The previous properties. * @param prevState The previous state. */ componentDidUpdate(_prevProps: ColorPickerProps, prevState: ColorPickerState): void; renderCustomPalette(): React.JSX.Element | null; render(): React.JSX.Element; } export {};