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