Skip to content

Commit 141a506

Browse files
authored
fix: merge src/types/index.d.ts with root version (#78)
1 parent 2f9fe16 commit 141a506

File tree

3 files changed

+36
-155
lines changed

3 files changed

+36
-155
lines changed

.packito.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"name": "yarn test"
1111
},
1212
"output": "./dist",
13-
"copy": ["README.md", "LICENSE", "index.d.ts"]
13+
"copy": ["README.md", "LICENSE", "src/types/index.d.ts"]
1414
}

index.d.ts

Lines changed: 0 additions & 129 deletions
This file was deleted.

src/types/index.d.ts

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1+
declare module 'material-ui-color' {
2+
3+
enum ColorFormat {
4+
"plain",
5+
"hex",
6+
"hsl",
7+
"rgb",
8+
"hsv"
9+
}
110

211
interface ColorObject {
312
css: React.CSSProperties;
413
value: number;
514
hex: string;
6-
format: "hsl" | "rgb" | "hex";
715
raw: string | number | object | string[] | number[];
816
name: string;
917
aplha: number;
1018
rgb: [number, number, number];
1119
hsv: [number, number, number];
1220
hsl: [number, number, number];
1321
}
14-
interface ColorError {
15-
raw: string | number | object | string[] | number[];
16-
css: React.CSSProperties;
22+
23+
interface ColorError extends ColorObject {
1724
name: "none";
1825
error: "Wrong format" | "Not an hex value";
1926
value: 0;
@@ -24,41 +31,41 @@
2431
hsv: [0, 0, 0];
2532
hsl: [0, 0, 0];
2633
}
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>;
2841

2942
interface ColorPickerProps {
30-
value?: Color | string | number;
43+
value?: ColorValue;
44+
defaultValue?: ColorValue;
3145
disableTextfield?: boolean;
3246
hideTextfield?: boolean;
3347
deferred?: boolean;
3448
palette?: null;
3549
inputFormats?: string[];
50+
disableAlpha?: boolean;
3651
onChange: (color: Color) => void;
3752
onOpen?: () => void;
3853
openAtStart?: boolean;
3954
doPopup?: () => void;
4055
}
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 {
4557
palette: T;
46-
inputFormats?: string[];
47-
onChange: (color: Color | keyof T) => void;
48-
onOpen?: () => void;
49-
openAtStart?: boolean;
50-
doPopup?: () => void;
5158
}
5259

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
5562
): JSX.Element;
5663

5764
interface ColorButtonProps {
5865
/**
5966
The color to display, could be a css valid string, an integer, or a Color object see ColorType
6067
*/
61-
color: Color | string | number;
68+
color: ColorValue;
6269
/**
6370
The size of the button in pixel
6471
*/
@@ -77,35 +84,36 @@
7784
tooltip?: string;
7885
}
7986

80-
declare function ColorButton(props: ColorButtonProps): JSX.Element;
87+
function ColorButton(props: ColorButtonProps): JSX.Element;
8188

8289
interface ColorInputProps {
83-
value?: Color | string | number;
90+
value?: ColorValue;
8491
format?: string;
8592
onChange: (color: Color) => void;
8693
}
8794

88-
declare function ColorInput(props: ColorInputProps): JSX.Element;
95+
function ColorInput(props: ColorInputProps): JSX.Element;
8996

9097
interface ColorPaletteProps<T> {
9198
borderWidth?: number;
9299
palette: T;
93100
onSelect?: (color: keyof T) => void;
94101
}
95102

96-
declare function ColorPalette<T extends Record<string, string>>(
103+
function ColorPalette<T extends Record<string, string>>(
97104
props: ColorPaletteProps<T>
98105
): JSX.Element;
99106

100107
interface ColorBoxProps {
101-
value?: Color | string | number;
108+
defaultValue?: ColorValue;
109+
value?: ColorValue;
102110
deferred?: boolean;
103111
palette?: Record<string, string>;
104112
inputFormats?: string[];
105113
onChange: (color: Color) => void;
106114
}
107115

108-
declare function ColorBox(props: ColorBoxProps): JSX.Element;
116+
function ColorBox(props: ColorBoxProps): JSX.Element;
109117

110118
export {
111119
ColorPicker,
@@ -119,5 +127,7 @@
119127
ColorBox,
120128
ColorBoxProps,
121129
Color,
122-
ColorObject
130+
ColorType,
131+
ColorValue,
123132
};
133+
}

0 commit comments

Comments
 (0)