forked from simonwep/pickr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpickr.d.ts
161 lines (120 loc) · 3.56 KB
/
pickr.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
declare class Pickr {
static version: string; // Current version
static utils: any; // See docs
static libs: any; // See docs
constructor(options: Pickr.Options);
static create(options: Pickr.Options): Pickr;
setHSVA(h?: number, s?: number, v?: number, a?: number, silent?: boolean): boolean
setColor(str: string | null, silent?: boolean): boolean;
on(event: Pickr.EventType, cb: Function): Pickr;
off(event: Pickr.EventType, cb: Function): Pickr;
show(): Pickr;
hide(): Pickr;
disable(): Pickr;
enable(): Pickr;
isOpen(): boolean;
getRoot(): object;
getColor(): Pickr.HSVaColor;
getSelectedColor(): Pickr.HSVaColor;
destroy(): void;
destroyAndRemove(): void;
setColorRepresentation(type: Pickr.Representation): boolean;
getColorRepresentation(): Pickr.Representation;
applyColor(silent?: boolean): Pickr;
addSwatch(color: string): boolean;
removeSwatch(index: number): boolean;
}
declare namespace Pickr {
interface Options {
el: string | HTMLElement;
container?: string | HTMLElement;
theme?: Theme;
closeOnScroll?: boolean;
appClass?: string;
useAsButton?: boolean;
padding?: number;
inline?: boolean;
autoReposition?: boolean;
sliders?: Slider;
disabled?: boolean;
lockOpacity?: boolean;
outputPrecision?: number;
comparison?: boolean;
default?: string;
swatches?: Array<string> | null;
defaultRepresentation?: Representation;
showAlways?: boolean;
closeWithKey?: string;
position?: Position;
adjustableNumbers?: boolean;
components?: {
palette?: boolean;
preview?: boolean;
opacity?: boolean;
hue?: boolean;
interaction?: {
hex?: boolean;
rgba?: boolean;
hsla?: boolean;
hsva?: boolean;
cmyk?: boolean;
input?: boolean;
cancel?: boolean;
clear?: boolean;
save?: boolean;
};
};
strings?: {
save?: string;
clear?: string;
cancel?: string;
}
}
interface RoundableNumberArray extends Omit<Array<number>, 'toString'> {
/**
* Uses Number.toFixed to truncate each value to the n-th decimal place.
* @param precision Optional precision / decimal place at which point it should be truncated.
*/
toString(precision?: number): string;
}
interface HSVaColor {
toHSVA(): RoundableNumberArray;
toHSLA(): RoundableNumberArray;
toRGBA(): RoundableNumberArray;
toCMYK(): RoundableNumberArray;
toHEXA(): RoundableNumberArray;
clone(): HSVaColor;
}
type EventType =
'init' |
'hide' |
'show' |
'save' |
'clear' |
'change' |
'changestop' |
'cancel' |
'swatchselect';
type Theme = 'classic' | 'monolith' | 'nano';
type Position =
'top-start' |
'top-middle' |
'top-end' |
'right-start' |
'right-middle' |
'right-end' |
'bottom-start' |
'bottom-middle' |
'bottom-end' |
'left-start' |
'left-middle' |
'left-end';
type Representation =
'HEXA' |
'RGBA' |
'HSVA' |
'HSLA' |
'CMYK';
type Slider = 'v' | 'h';
}
export default Pickr;