UNPKG

3.28 kBTypeScriptView Raw
1// Type definitions for react-color 3.0
2// Project: https://github.com/casesandberg/react-color/, http://casesandberg.github.io/react-color
3// Definitions by: Karol Janyst <https://github.com/LKay>,
4// Marks Polakovs <https://github.com/markspolakovs>,
5// Matthieu Montaudouin <https://github.com/mntdn>,
6// Nokogiri <https://github.com/nkgrnkgr>,
7// 0815Strohhut <https://github.com/0815Strohhut>,
8// Daniel Fürst <https://github.com/dnlfrst>,
9// Erick Tamayo <https://github.com/ericktamayo>,
10// Alexander P. Cerutti <https://github.com/alexandercerutti>
11// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
12// TypeScript Version: 2.8
13
14import { ClassAttributes, ReactNode } from "react";
15import { Classes } from "reactcss";
16
17export interface HSLColor {
18 a?: number | undefined;
19 h: number;
20 l: number;
21 s: number;
22}
23
24export interface RGBColor {
25 a?: number | undefined;
26 b: number;
27 g: number;
28 r: number;
29}
30
31export type Color = string | HSLColor | RGBColor;
32
33export interface ColorResult {
34 hex: string;
35 hsl: HSLColor;
36 rgb: RGBColor;
37}
38
39export type ColorChangeHandler = (color: ColorResult, event: React.ChangeEvent<HTMLInputElement>) => void;
40
41export interface ColorPickerProps<A> extends ClassAttributes<A> {
42 color?: Color | undefined;
43 className?: string | undefined;
44 styles?: Partial<Classes<any>> | undefined;
45 onChange?: ColorChangeHandler | undefined;
46 onChangeComplete?: ColorChangeHandler | undefined;
47}
48
49export interface CustomPickerProps<A> extends ClassAttributes<A> {
50 color?: Color | undefined;
51 pointer?: ReactNode | undefined;
52 className?: string | undefined;
53 styles?: Partial<Classes<any>> | undefined;
54 onChange: ColorChangeHandler;
55}
56
57export { default as AlphaPicker, AlphaPickerProps } from "./lib/components/alpha/Alpha";
58export { default as BlockPicker, BlockPickerProps } from "./lib/components/block/Block";
59export { default as Checkboard, CheckboardProps } from "./lib/components/common/Checkboard";
60export { default as ChromePicker, ChromePickerProps } from "./lib/components/chrome/Chrome";
61export { default as CirclePicker, CirclePickerProps } from "./lib/components/circle/Circle";
62export { default as CompactPicker, CompactPickerProps } from "./lib/components/compact/Compact";
63export { default as GithubPicker, GithubPickerProps } from "./lib/components/github/Github";
64export { default as HuePicker, HuePickerProps } from "./lib/components/hue/Hue";
65export { default as MaterialPicker, MaterialPickerProps } from "./lib/components/material/Material";
66export {
67 default as PhotoshopPicker,
68 PhotoshopPickerProps
69} from "./lib/components/photoshop/Photoshop";
70export { default as SketchPicker, SketchPickerProps } from "./lib/components/sketch/Sketch";
71export { default as SliderPicker, SliderPickerProps } from "./lib/components/slider/Slider";
72export { default as SwatchesPicker, SwatchesPickerProps } from "./lib/components/swatches/Swatches";
73export { default as TwitterPicker, TwitterPickerProps } from "./lib/components/twitter/Twitter";
74export { default as CustomPicker, InjectedColorProps } from "./lib/components/common/ColorWrap";