1+ declare module 'material-ui-color-components' {
2+
3+ enum ColorFormat {
4+ "plain" ,
5+ "hex" ,
6+ "hsl" ,
7+ "rgb" ,
8+ "hsv"
9+ }
10+
11+ interface ColorBase {
12+ css : React . CSSProperties ;
13+ value : number ;
14+ hex : string ;
15+ raw : string | number | object | Array < number | string > ;
16+ name : string ;
17+ alpha : number ;
18+ rgb : [ number , number , number ] ;
19+ hsv : [ number , number , number ] ;
20+ hsl : [ number , number , number ] ;
21+ }
22+
23+ interface ColorError extends ColorBase {
24+ name : "none" ;
25+ error : "Wrong format" | "Not an hex value" ;
26+ value : 0 ;
27+ alpha : 1 ;
28+ format : "unknown" ;
29+ hex : "000000" ;
30+ rgb : [ 0 , 0 , 0 ] ;
31+ hsv : [ 0 , 0 , 0 ] ;
32+ hsl : [ 0 , 0 , 0 ] ;
33+ }
34+
35+ interface ColorType extends ColorBase {
36+ format : ColorFormat ;
37+ }
38+
39+ type Color = ColorType | ColorError ;
40+ type ColorValue = Color | string | number | Array < string | number > ;
41+
42+ interface ColorPickerProps {
43+ value ?: ColorValue ;
44+ defaultValue ?: ColorValue ;
45+ disableTextfield ?: boolean ;
46+ deferred ?: boolean ;
47+ palette ?: Record < string , ColorValue > ;
48+ inputFormats ?: string [ ] ;
49+ onChange : ( color : Color ) => void ;
50+ onOpen ?: ( ) => void ;
51+ openAtStart ?: boolean ;
52+ doPopup ?: ( ) => void ;
53+ }
54+
55+ function ColorPicker (
56+ props : ColorPickerProps
57+ ) : JSX . Element ;
58+
59+ interface ColorButtonProps {
60+ /**
61+ The color to display, could be a css valid string, an integer, or a Color object see ColorType
62+ */
63+ color : ColorValue ;
64+ /**
65+ The size of the button in pixel
66+ */
67+ size ?: number ;
68+ /**
69+ The width of the button's border, not displayed if borderWidth=0
70+ */
71+ borderWidth ?: number ;
72+ /**
73+ The css color of the button's border, not displayed if borderWidth=0
74+ */
75+ borderColor ?: string ;
76+ /**
77+ A tooltip could be added to the button to display the color name or value
78+ */
79+ tooltip ?: string ;
80+ }
81+
82+ function ColorButton ( props : ColorButtonProps ) : JSX . Element ;
83+
84+ interface ColorInputProps {
85+ value ?: ColorValue ;
86+ format ?: string ;
87+ onChange : ( color : Color ) => void ;
88+ }
89+
90+ function ColorInput ( props : ColorInputProps ) : JSX . Element ;
91+
92+ interface ColorPaletteProps < T > {
93+ borderWidth ?: number ;
94+ palette : T ;
95+ onSelect ?: ( color : keyof T ) => void ;
96+ }
97+
98+ function ColorPalette < T extends Record < string , ColorValue > > (
99+ props : ColorPaletteProps < T >
100+ ) : JSX . Element ;
101+
102+ interface ColorBoxProps {
103+ defaultValue ?: ColorValue ;
104+ value ?: ColorValue ;
105+ deferred ?: boolean ;
106+ palette ?: Record < string , ColorValue > ;
107+ inputFormats ?: string [ ] ;
108+ onChange : ( color : Color ) => void ;
109+ }
110+
111+ function ColorBox ( props : ColorBoxProps ) : JSX . Element ;
112+
113+ export {
114+ ColorPicker ,
115+ ColorPickerProps ,
116+ ColorInput ,
117+ ColorInputProps ,
118+ ColorButton ,
119+ ColorButtonProps ,
120+ ColorPalette ,
121+ ColorPaletteProps ,
122+ ColorBox ,
123+ ColorBoxProps ,
124+ Color ,
125+ ColorType ,
126+ ColorValue ,
127+ } ;
128+
129+ }
0 commit comments