@thednp/color-picker 0.0.1-alpha1 → 0.0.1-alpha2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +40 -19
- package/dist/css/color-picker.css +481 -337
- package/dist/css/color-picker.min.css +2 -0
- package/dist/css/color-picker.rtl.css +506 -0
- package/dist/css/color-picker.rtl.min.css +2 -0
- package/dist/js/color-picker-element-esm.js +3810 -2
- package/dist/js/color-picker-element-esm.min.js +2 -0
- package/dist/js/color-picker-element.js +2009 -1242
- package/dist/js/color-picker-element.min.js +2 -2
- package/dist/js/color-picker-esm.js +3704 -0
- package/dist/js/color-picker-esm.min.js +2 -0
- package/dist/js/color-picker.js +1962 -1256
- package/dist/js/color-picker.min.js +2 -2
- package/package.json +18 -9
- package/src/js/color-palette.js +62 -0
- package/src/js/color-picker-element.js +55 -13
- package/src/js/color-picker.js +686 -595
- package/src/js/color.js +615 -349
- package/src/js/index.js +0 -9
- package/src/js/util/colorNames.js +2 -152
- package/src/js/util/colorPickerLabels.js +22 -0
- package/src/js/util/getColorControls.js +103 -0
- package/src/js/util/getColorForm.js +27 -19
- package/src/js/util/getColorMenu.js +95 -0
- package/src/js/util/isValidJSON.js +13 -0
- package/src/js/util/nonColors.js +5 -0
- package/src/js/util/templates.js +1 -0
- package/src/scss/color-picker.rtl.scss +23 -0
- package/src/scss/color-picker.scss +430 -0
- package/types/cp.d.ts +263 -160
- package/types/index.d.ts +9 -2
- package/types/source/source.ts +2 -1
- package/types/source/types.d.ts +28 -5
- package/dist/js/color-picker.esm.js +0 -2998
- package/dist/js/color-picker.esm.min.js +0 -2
- package/src/js/util/getColorControl.js +0 -49
- package/src/js/util/init.js +0 -14
package/types/cp.d.ts
CHANGED
@@ -1,25 +1,24 @@
|
|
1
|
-
declare module "color-picker/src/js/util/
|
2
|
-
export default
|
1
|
+
declare module "color-picker/src/js/util/nonColors" {
|
2
|
+
export default nonColors;
|
3
3
|
/**
|
4
|
-
* A
|
5
|
-
* @see https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
|
6
|
-
* @type {string[]}
|
4
|
+
* A list of explicit default non-color values.
|
7
5
|
*/
|
8
|
-
const
|
6
|
+
const nonColors: string[];
|
9
7
|
}
|
10
8
|
declare module "color-picker/src/js/color" {
|
9
|
+
export default Color;
|
11
10
|
/**
|
11
|
+
* @class
|
12
12
|
* Returns a new `Color` instance.
|
13
13
|
* @see https://github.com/bgrins/TinyColor
|
14
|
-
* @class
|
15
14
|
*/
|
16
|
-
|
15
|
+
class Color {
|
17
16
|
/**
|
18
17
|
* @constructor
|
19
|
-
* @param {CP.ColorInput} input
|
20
|
-
* @param {CP.
|
18
|
+
* @param {CP.ColorInput} input the given colour value
|
19
|
+
* @param {CP.ColorFormats=} config the given format
|
21
20
|
*/
|
22
|
-
constructor(input: CP.ColorInput, config?: CP.
|
21
|
+
constructor(input: CP.ColorInput, config?: CP.ColorFormats | undefined);
|
23
22
|
/** @type {CP.ColorInput} */
|
24
23
|
originalInput: CP.ColorInput;
|
25
24
|
/** @type {number} */
|
@@ -32,8 +31,6 @@ declare module "color-picker/src/js/color" {
|
|
32
31
|
a: number;
|
33
32
|
/** @type {boolean} */
|
34
33
|
ok: boolean;
|
35
|
-
/** @type {number} */
|
36
|
-
roundA: number;
|
37
34
|
/** @type {CP.ColorFormats} */
|
38
35
|
format: CP.ColorFormats;
|
39
36
|
/**
|
@@ -47,139 +44,268 @@ declare module "color-picker/src/js/color" {
|
|
47
44
|
*/
|
48
45
|
get isDark(): boolean;
|
49
46
|
/**
|
50
|
-
* Returns the perceived luminance of a
|
47
|
+
* Returns the perceived luminance of a colour.
|
51
48
|
* @see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
52
|
-
* @returns {number} a number in [0
|
49
|
+
* @returns {number} a number in the [0, 1] range
|
53
50
|
*/
|
54
51
|
get luminance(): number;
|
55
52
|
/**
|
56
|
-
* Returns the perceived brightness of the
|
57
|
-
* @returns {number} a number in [0
|
53
|
+
* Returns the perceived brightness of the colour.
|
54
|
+
* @returns {number} a number in the [0, 255] range
|
58
55
|
*/
|
59
56
|
get brightness(): number;
|
60
57
|
/**
|
61
|
-
* Returns the
|
62
|
-
* @returns {CP.RGBA}
|
58
|
+
* Returns the colour as an RGBA object.
|
59
|
+
* @returns {CP.RGBA} an {r,g,b,a} object with [0, 255] ranged values
|
63
60
|
*/
|
64
61
|
toRgb(): CP.RGBA;
|
65
62
|
/**
|
66
|
-
* Returns the RGBA values concatenated into a string.
|
67
|
-
*
|
63
|
+
* Returns the RGBA values concatenated into a CSS3 Module string format.
|
64
|
+
* * rgb(255,255,255)
|
65
|
+
* * rgba(255,255,255,0.5)
|
66
|
+
* @returns {string} the CSS valid colour in RGB/RGBA format
|
68
67
|
*/
|
69
68
|
toRgbString(): string;
|
70
69
|
/**
|
71
|
-
* Returns the
|
72
|
-
*
|
70
|
+
* Returns the RGBA values concatenated into a CSS4 Module string format.
|
71
|
+
* * rgb(255 255 255)
|
72
|
+
* * rgb(255 255 255 / 50%)
|
73
|
+
* @returns {string} the CSS valid colour in CSS4 RGB format
|
73
74
|
*/
|
74
|
-
|
75
|
+
toRgbCSS4String(): string;
|
75
76
|
/**
|
76
|
-
* Returns the
|
77
|
-
*
|
77
|
+
* Returns the hexadecimal value of the colour. When the parameter is *true*
|
78
|
+
* it will find a 3 characters shorthand of the decimal value.
|
79
|
+
*
|
80
|
+
* @param {boolean=} allow3Char when `true` returns shorthand HEX
|
81
|
+
* @returns {string} the hexadecimal colour format
|
82
|
+
*/
|
83
|
+
toHex(allow3Char?: boolean | undefined): string;
|
84
|
+
/**
|
85
|
+
* Returns the CSS valid hexadecimal vaue of the colour. When the parameter is *true*
|
86
|
+
* it will find a 3 characters shorthand of the value.
|
87
|
+
*
|
88
|
+
* @param {boolean=} allow3Char when `true` returns shorthand HEX
|
89
|
+
* @returns {string} the CSS valid colour in hexadecimal format
|
78
90
|
*/
|
79
|
-
toHexString(): string;
|
91
|
+
toHexString(allow3Char?: boolean | undefined): string;
|
80
92
|
/**
|
81
|
-
* Returns the
|
82
|
-
* @
|
93
|
+
* Returns the HEX8 value of the colour.
|
94
|
+
* @param {boolean=} allow4Char when `true` returns shorthand HEX
|
95
|
+
* @returns {string} the CSS valid colour in hexadecimal format
|
96
|
+
*/
|
97
|
+
toHex8(allow4Char?: boolean | undefined): string;
|
98
|
+
/**
|
99
|
+
* Returns the HEX8 value of the colour.
|
100
|
+
* @param {boolean=} allow4Char when `true` returns shorthand HEX
|
101
|
+
* @returns {string} the CSS valid colour in hexadecimal format
|
102
|
+
*/
|
103
|
+
toHex8String(allow4Char?: boolean | undefined): string;
|
104
|
+
/**
|
105
|
+
* Returns the colour as a HSVA object.
|
106
|
+
* @returns {CP.HSVA} the `{h,s,v,a}` object with [0, 1] ranged values
|
83
107
|
*/
|
84
108
|
toHsv(): CP.HSVA;
|
85
109
|
/**
|
86
|
-
* Returns the
|
87
|
-
* @returns {CP.HSLA}
|
110
|
+
* Returns the colour as an HSLA object.
|
111
|
+
* @returns {CP.HSLA} the `{h,s,l,a}` object with [0, 1] ranged values
|
88
112
|
*/
|
89
113
|
toHsl(): CP.HSLA;
|
90
114
|
/**
|
91
|
-
* Returns the HSLA values concatenated into a string.
|
92
|
-
*
|
115
|
+
* Returns the HSLA values concatenated into a CSS3 Module format string.
|
116
|
+
* * `hsl(150, 100%, 50%)`
|
117
|
+
* * `hsla(150, 100%, 50%, 0.5)`
|
118
|
+
* @returns {string} the CSS valid colour in HSL/HSLA format
|
93
119
|
*/
|
94
120
|
toHslString(): string;
|
95
121
|
/**
|
96
|
-
*
|
97
|
-
*
|
98
|
-
*
|
122
|
+
* Returns the HSLA values concatenated into a CSS4 Module format string.
|
123
|
+
* * `hsl(150deg 100% 50%)`
|
124
|
+
* * `hsl(150deg 100% 50% / 50%)`
|
125
|
+
* @returns {string} the CSS valid colour in CSS4 HSL format
|
126
|
+
*/
|
127
|
+
toHslCSS4String(): string;
|
128
|
+
/**
|
129
|
+
* Returns the colour as an HWBA object.
|
130
|
+
* @returns {CP.HWBA} the `{h,w,b,a}` object with [0, 1] ranged values
|
131
|
+
*/
|
132
|
+
toHwb(): CP.HWBA;
|
133
|
+
/**
|
134
|
+
* Returns the HWBA values concatenated into a string.
|
135
|
+
* @returns {string} the CSS valid colour in HWB format
|
136
|
+
*/
|
137
|
+
toHwbString(): string;
|
138
|
+
/**
|
139
|
+
* Sets the alpha value of the current colour.
|
140
|
+
* @param {number} alpha a new alpha value in the [0, 1] range.
|
141
|
+
* @returns {Color} the `Color` instance
|
99
142
|
*/
|
100
143
|
setAlpha(alpha: number): Color;
|
101
144
|
/**
|
102
|
-
* Saturate the
|
103
|
-
* @param {number=} amount a value in [0
|
104
|
-
* @returns {Color}
|
145
|
+
* Saturate the colour with a given amount.
|
146
|
+
* @param {number=} amount a value in the [0, 100] range
|
147
|
+
* @returns {Color} the `Color` instance
|
105
148
|
*/
|
106
149
|
saturate(amount?: number | undefined): Color;
|
107
150
|
/**
|
108
|
-
* Desaturate the
|
109
|
-
* @param {number=} amount a value in [0
|
110
|
-
* @returns {Color}
|
151
|
+
* Desaturate the colour with a given amount.
|
152
|
+
* @param {number=} amount a value in the [0, 100] range
|
153
|
+
* @returns {Color} the `Color` instance
|
111
154
|
*/
|
112
155
|
desaturate(amount?: number | undefined): Color;
|
113
156
|
/**
|
114
|
-
* Completely desaturates a
|
157
|
+
* Completely desaturates a colour into greyscale.
|
115
158
|
* Same as calling `desaturate(100)`
|
116
|
-
* @returns {Color}
|
159
|
+
* @returns {Color} the `Color` instance
|
117
160
|
*/
|
118
161
|
greyscale(): Color;
|
162
|
+
/**
|
163
|
+
* Increase the colour lightness with a given amount.
|
164
|
+
* @param {number=} amount a value in the [0, 100] range
|
165
|
+
* @returns {Color} the `Color` instance
|
166
|
+
*/
|
167
|
+
lighten(amount?: number | undefined): Color;
|
168
|
+
/**
|
169
|
+
* Decrease the colour lightness with a given amount.
|
170
|
+
* @param {number=} amount a value in the [0, 100] range
|
171
|
+
* @returns {Color} the `Color` instance
|
172
|
+
*/
|
173
|
+
darken(amount?: number | undefined): Color;
|
174
|
+
/**
|
175
|
+
* Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
|
176
|
+
* Values outside of this range will be wrapped into this range.
|
177
|
+
*
|
178
|
+
* @param {number=} amount a value in the [0, 100] range
|
179
|
+
* @returns {Color} the `Color` instance
|
180
|
+
*/
|
181
|
+
spin(amount?: number | undefined): Color;
|
119
182
|
/** Returns a clone of the current `Color` instance. */
|
120
183
|
clone(): Color;
|
121
184
|
/**
|
122
|
-
* Returns the
|
123
|
-
* @
|
185
|
+
* Returns the colour value in CSS valid string format.
|
186
|
+
* @param {boolean=} allowShort when *true*, HEX values can be shorthand
|
187
|
+
* @returns {string} the CSS valid colour in the configured format
|
124
188
|
*/
|
125
|
-
toString(): string;
|
189
|
+
toString(allowShort?: boolean | undefined): string;
|
126
190
|
}
|
127
191
|
}
|
192
|
+
declare module "color-picker/src/js/color-palette" {
|
193
|
+
/**
|
194
|
+
* @class
|
195
|
+
* Returns a color palette with a given set of parameters.
|
196
|
+
* @example
|
197
|
+
* new ColorPalette(0, 12, 10);
|
198
|
+
* // => { hue: 0, hueSteps: 12, lightSteps: 10, colors: array }
|
199
|
+
*/
|
200
|
+
export default class ColorPalette {
|
201
|
+
/**
|
202
|
+
* The `hue` parameter is optional, which would be set to 0.
|
203
|
+
* @param {number[]} args represeinting hue, hueSteps, lightSteps
|
204
|
+
* * `args.hue` the starting Hue [0, 360]
|
205
|
+
* * `args.hueSteps` Hue Steps Count [5, 13]
|
206
|
+
* * `args.lightSteps` Lightness Steps Count [8, 10]
|
207
|
+
*/
|
208
|
+
constructor(...args: number[]);
|
209
|
+
hue: number;
|
210
|
+
hueSteps: number;
|
211
|
+
lightSteps: number;
|
212
|
+
colors: string[];
|
213
|
+
}
|
214
|
+
}
|
215
|
+
declare module "color-picker/src/js/util/colorPickerLabels" {
|
216
|
+
export default colorPickerLabels;
|
217
|
+
/** @type {Record<string, string>} */
|
218
|
+
const colorPickerLabels: Record<string, string>;
|
219
|
+
}
|
220
|
+
declare module "color-picker/src/js/util/colorNames" {
|
221
|
+
export default colorNames;
|
222
|
+
/**
|
223
|
+
* A list of 17 color names used for WAI-ARIA compliance.
|
224
|
+
* @type {string[]}
|
225
|
+
*/
|
226
|
+
const colorNames: string[];
|
227
|
+
}
|
128
228
|
declare module "color-picker/src/js/util/vHidden" {
|
129
229
|
export default vHidden;
|
130
230
|
const vHidden: "v-hidden";
|
131
231
|
}
|
132
232
|
declare module "color-picker/src/js/util/getColorForm" {
|
133
233
|
/**
|
134
|
-
* Returns the color form
|
234
|
+
* Returns the color form for `ColorPicker`.
|
235
|
+
*
|
135
236
|
* @param {CP.ColorPicker} self the `ColorPicker` instance
|
136
|
-
* @returns {HTMLElement | Element}
|
237
|
+
* @returns {HTMLElement | Element} a new `<div>` element with color component `<input>`
|
137
238
|
*/
|
138
239
|
export default function getColorForm(self: CP.ColorPicker): HTMLElement | Element;
|
139
240
|
}
|
140
|
-
declare module "color-picker/src/js/util/
|
241
|
+
declare module "color-picker/src/js/util/getColorControls" {
|
141
242
|
/**
|
142
|
-
* Returns
|
143
|
-
*
|
144
|
-
* @param {
|
145
|
-
* @
|
146
|
-
|
147
|
-
|
243
|
+
* Returns all color controls for `ColorPicker`.
|
244
|
+
*
|
245
|
+
* @param {CP.ColorPicker} self the `ColorPicker` instance
|
246
|
+
* @returns {HTMLElement | Element} color controls
|
247
|
+
*/
|
248
|
+
export default function getColorControls(self: CP.ColorPicker): HTMLElement | Element;
|
249
|
+
}
|
250
|
+
declare module "color-picker/src/js/util/getColorMenu" {
|
251
|
+
/**
|
252
|
+
* Returns a color-defaults with given values and class.
|
253
|
+
* @param {CP.ColorPicker} self
|
254
|
+
* @param {CP.ColorPalette | string[]} colorsSource
|
255
|
+
* @param {string} menuClass
|
148
256
|
* @returns {HTMLElement | Element}
|
149
257
|
*/
|
150
|
-
export default function
|
258
|
+
export default function getColorMenu(self: CP.ColorPicker, colorsSource: CP.ColorPalette | string[], menuClass: string): HTMLElement | Element;
|
259
|
+
}
|
260
|
+
declare module "color-picker/src/js/util/isValidJSON" {
|
261
|
+
/**
|
262
|
+
* Check if a string is valid JSON string.
|
263
|
+
* @param {string} str the string input
|
264
|
+
* @returns {boolean} the query result
|
265
|
+
*/
|
266
|
+
export default function isValidJSON(str: string): boolean;
|
267
|
+
}
|
268
|
+
declare module "color-picker/src/js/version" {
|
269
|
+
export default Version;
|
270
|
+
const Version: string;
|
151
271
|
}
|
152
272
|
declare module "color-picker/src/js/color-picker" {
|
153
273
|
/**
|
154
|
-
* Color Picker
|
274
|
+
* Color Picker Web Component
|
155
275
|
* @see http://thednp.github.io/color-picker
|
156
276
|
*/
|
157
277
|
export default class ColorPicker {
|
158
278
|
/**
|
159
|
-
* Returns a new ColorPicker instance.
|
279
|
+
* Returns a new `ColorPicker` instance. The target of this constructor
|
280
|
+
* must be an `HTMLInputElement`.
|
281
|
+
*
|
160
282
|
* @param {HTMLInputElement | string} target the target `<input>` element
|
283
|
+
* @param {CP.ColorPickerOptions=} config instance options
|
161
284
|
*/
|
162
|
-
constructor(target: HTMLInputElement | string);
|
163
|
-
/** @type {HTMLInputElement} */
|
285
|
+
constructor(target: HTMLInputElement | string, config?: CP.ColorPickerOptions | undefined);
|
164
286
|
input: HTMLInputElement;
|
165
287
|
/** @type {HTMLElement} */
|
166
288
|
parent: HTMLElement;
|
167
289
|
/** @type {number} */
|
168
290
|
id: number;
|
169
|
-
/** @type {
|
170
|
-
dragElement:
|
291
|
+
/** @type {HTMLElement?} */
|
292
|
+
dragElement: HTMLElement | null;
|
171
293
|
/** @type {boolean} */
|
172
294
|
isOpen: boolean;
|
173
295
|
/** @type {Record<string, number>} */
|
174
296
|
controlPositions: Record<string, number>;
|
175
297
|
/** @type {Record<string, string>} */
|
176
298
|
colorLabels: Record<string, string>;
|
177
|
-
/** @type {
|
178
|
-
|
179
|
-
/** @type {
|
180
|
-
|
299
|
+
/** @type {string[]=} */
|
300
|
+
colorKeywords: string[] | undefined;
|
301
|
+
/** @type {(ColorPalette | string[])=} */
|
302
|
+
colorPresets: (ColorPalette | string[]) | undefined;
|
181
303
|
/** @type {Record<string, string>} */
|
182
304
|
componentLabels: Record<string, string>;
|
305
|
+
/** @type {Color} */
|
306
|
+
color: Color;
|
307
|
+
/** @type {CP.ColorFormats} */
|
308
|
+
format: CP.ColorFormats;
|
183
309
|
/** Shows the `ColorPicker` dropdown. */
|
184
310
|
showPicker(): void;
|
185
311
|
/**
|
@@ -191,62 +317,69 @@ declare module "color-picker/src/js/color-picker" {
|
|
191
317
|
/** Toggles the visibility of the `ColorPicker` presets menu. */
|
192
318
|
toggleMenu(): void;
|
193
319
|
/**
|
194
|
-
*
|
320
|
+
* The `ColorPicker` click event listener for the colour menu presets / defaults.
|
195
321
|
* @param {Partial<Event>} e
|
196
322
|
* @this {ColorPicker}
|
197
323
|
*/
|
198
324
|
menuClickHandler(this: ColorPicker, e: Partial<Event>): void;
|
199
325
|
/**
|
200
|
-
*
|
326
|
+
* The `ColorPicker` keyboard event listener for menu navigation.
|
201
327
|
* @param {KeyboardEvent} e
|
202
328
|
* @this {ColorPicker}
|
203
329
|
*/
|
204
330
|
menuKeyHandler(this: ColorPicker, e: KeyboardEvent): void;
|
205
331
|
/**
|
206
|
-
*
|
332
|
+
* The `ColorPicker` *touchstart* / *mousedown* events listener for control knobs.
|
207
333
|
* @param {TouchEvent} e
|
208
334
|
* @this {ColorPicker}
|
209
335
|
*/
|
210
336
|
pointerDown(this: ColorPicker, e: TouchEvent): void;
|
211
337
|
/**
|
212
|
-
*
|
338
|
+
* The `ColorPicker` *touchmove* / *mousemove* events listener for control knobs.
|
213
339
|
* @param {TouchEvent} e
|
214
340
|
*/
|
215
341
|
pointerMove(e: TouchEvent): void;
|
216
342
|
/**
|
217
|
-
*
|
343
|
+
* The `ColorPicker` *touchend* / *mouseup* events listener for control knobs.
|
218
344
|
* @param {TouchEvent} e
|
219
345
|
* @this {ColorPicker}
|
220
346
|
*/
|
221
347
|
pointerUp(this: ColorPicker, { target }: TouchEvent): void;
|
222
348
|
/**
|
223
|
-
*
|
349
|
+
* Updates `ColorPicker` control positions on:
|
350
|
+
* * initialization
|
351
|
+
* * window resize
|
352
|
+
*/
|
353
|
+
update(): void;
|
354
|
+
/**
|
355
|
+
* The `ColorPicker` *scroll* event listener when open.
|
224
356
|
* @param {Event} e
|
225
357
|
* @this {ColorPicker}
|
226
358
|
*/
|
227
359
|
handleScroll(this: ColorPicker, e: Event): void;
|
228
360
|
/**
|
229
|
-
*
|
361
|
+
* The `ColorPicker` *focusout* event listener when open.
|
230
362
|
* @param {FocusEvent} e
|
231
363
|
* @this {ColorPicker}
|
232
364
|
*/
|
233
365
|
handleFocusOut(this: ColorPicker, { relatedTarget }: FocusEvent): void;
|
234
|
-
/**
|
366
|
+
/** The event listener of the colour form inputs. */
|
235
367
|
changeHandler(): void;
|
236
368
|
/**
|
237
|
-
*
|
369
|
+
* The `ColorPicker` *keyup* event listener when open.
|
238
370
|
* @param {KeyboardEvent} e
|
239
371
|
* @this {ColorPicker}
|
240
372
|
*/
|
241
373
|
handleDismiss(this: ColorPicker, { code }: KeyboardEvent): void;
|
242
374
|
/**
|
243
|
-
*
|
375
|
+
* The `Space` & `Enter` keys specific event listener.
|
376
|
+
* Toggle visibility of the `ColorPicker` / the presets menu, showing one will hide the other.
|
244
377
|
* @param {KeyboardEvent} e
|
245
378
|
* @this {ColorPicker}
|
246
379
|
*/
|
247
|
-
|
380
|
+
keyToggle(this: ColorPicker, e: KeyboardEvent): void;
|
248
381
|
/**
|
249
|
-
*
|
382
|
+
* The `ColorPicker` *keydown* event listener for control knobs.
|
250
383
|
* @param {KeyboardEvent} e
|
251
384
|
*/
|
252
385
|
handleKnobs(e: KeyboardEvent): void;
|
@@ -255,77 +388,44 @@ declare module "color-picker/src/js/color-picker" {
|
|
255
388
|
/** @type {HTMLElement} */
|
256
389
|
menuToggle: HTMLElement;
|
257
390
|
/** @type {HTMLElement} */
|
258
|
-
colorMenu: HTMLElement;
|
259
|
-
/** @type {HTMLElement} */
|
260
391
|
colorPicker: HTMLElement;
|
261
392
|
/** @type {HTMLElement} */
|
262
|
-
|
393
|
+
colorMenu: HTMLElement;
|
263
394
|
/** @type {HTMLInputElement[]} */
|
264
395
|
inputs: HTMLInputElement[];
|
396
|
+
controls: Element | HTMLElement;
|
397
|
+
/** @type {(HTMLElement | Element)[]} */
|
398
|
+
controlKnobs: (HTMLElement | Element)[];
|
265
399
|
/** @type {(HTMLElement)[]} */
|
266
|
-
|
267
|
-
/** @type {HTMLCanvasElement[]} */
|
268
|
-
visuals: HTMLCanvasElement[];
|
269
|
-
/** @type {HTMLLabelElement[]} */
|
270
|
-
knobLabels: HTMLLabelElement[];
|
271
|
-
/** @type {HTMLLabelElement} */
|
272
|
-
appearance: HTMLLabelElement;
|
273
|
-
/** @type {number} */
|
274
|
-
width1: number;
|
275
|
-
/** @type {number} */
|
276
|
-
height1: number;
|
277
|
-
/** @type {number} */
|
278
|
-
width2: number;
|
279
|
-
/** @type {number} */
|
280
|
-
height2: number;
|
281
|
-
/** @type {*} */
|
282
|
-
ctx1: any;
|
283
|
-
/** @type {*} */
|
284
|
-
ctx2: any;
|
285
|
-
/** @type {number} */
|
286
|
-
width3: number;
|
287
|
-
/** @type {number} */
|
288
|
-
height3: number;
|
289
|
-
/** @type {*} */
|
290
|
-
ctx3: any;
|
400
|
+
visuals: (HTMLElement)[];
|
291
401
|
/**
|
292
|
-
* Sets a new
|
293
|
-
* @param {string} v new
|
402
|
+
* Sets a new colour value.
|
403
|
+
* @param {string} v new colour value
|
294
404
|
*/
|
295
405
|
set value(arg: string);
|
296
|
-
/** Returns the current
|
406
|
+
/** Returns the current colour value */
|
297
407
|
get value(): string;
|
298
|
-
/** Check if the
|
299
|
-
get required(): boolean;
|
300
|
-
/**
|
301
|
-
* Returns the colour format.
|
302
|
-
* @returns {CP.ColorFormats | string}
|
303
|
-
*/
|
304
|
-
get format(): string;
|
305
|
-
/** Returns the input name. */
|
306
|
-
get name(): string | null;
|
307
|
-
/**
|
308
|
-
* Returns the label associated to the input.
|
309
|
-
* @returns {HTMLLabelElement?}
|
310
|
-
*/
|
311
|
-
get label(): HTMLLabelElement | null;
|
312
|
-
/** Check if the color presets include any non-color. */
|
408
|
+
/** Check if the colour presets include any non-colour. */
|
313
409
|
get includeNonColor(): boolean;
|
314
|
-
/**
|
410
|
+
/** Check if the parent of the target is a `ColorPickerElement` instance. */
|
411
|
+
get isCE(): boolean;
|
412
|
+
/** Returns hexadecimal value of the current colour. */
|
315
413
|
get hex(): string;
|
316
|
-
/** Returns the current
|
414
|
+
/** Returns the current colour value in {h,s,v,a} object format. */
|
317
415
|
get hsv(): CP.HSVA;
|
318
|
-
/** Returns the current
|
416
|
+
/** Returns the current colour value in {h,s,l,a} object format. */
|
319
417
|
get hsl(): CP.HSLA;
|
320
|
-
/** Returns the current
|
418
|
+
/** Returns the current colour value in {h,w,b,a} object format. */
|
419
|
+
get hwb(): CP.HWBA;
|
420
|
+
/** Returns the current colour value in {r,g,b,a} object format. */
|
321
421
|
get rgb(): CP.RGBA;
|
322
|
-
/** Returns the current
|
422
|
+
/** Returns the current colour brightness. */
|
323
423
|
get brightness(): number;
|
324
|
-
/** Returns the current
|
424
|
+
/** Returns the current colour luminance. */
|
325
425
|
get luminance(): number;
|
326
|
-
/** Checks if the current colour requires a light text
|
426
|
+
/** Checks if the current colour requires a light text colour. */
|
327
427
|
get isDark(): boolean;
|
328
|
-
/** Checks if the current input value is a valid
|
428
|
+
/** Checks if the current input value is a valid colour. */
|
329
429
|
get isValid(): boolean;
|
330
430
|
/** Updates `ColorPicker` visuals. */
|
331
431
|
updateVisuals(): void;
|
@@ -334,71 +434,73 @@ declare module "color-picker/src/js/color-picker" {
|
|
334
434
|
* * `lightness` and `saturation` for HEX/RGB;
|
335
435
|
* * `lightness` and `hue` for HSL.
|
336
436
|
*
|
337
|
-
* @param {
|
437
|
+
* @param {number} X the X component of the offset
|
438
|
+
* @param {number} Y the Y component of the offset
|
338
439
|
*/
|
339
|
-
changeControl1(
|
440
|
+
changeControl1(X: number, Y: number): void;
|
340
441
|
/**
|
341
442
|
* Updates `ColorPicker` second control:
|
342
|
-
* * `hue` for HEX/RGB;
|
443
|
+
* * `hue` for HEX/RGB/HWB;
|
343
444
|
* * `saturation` for HSL.
|
344
445
|
*
|
345
|
-
* @param {
|
446
|
+
* @param {number} Y the Y offset
|
346
447
|
*/
|
347
|
-
changeControl2(
|
448
|
+
changeControl2(Y: number): void;
|
348
449
|
/**
|
349
450
|
* Updates `ColorPicker` last control,
|
350
|
-
* the `alpha` channel
|
451
|
+
* the `alpha` channel.
|
351
452
|
*
|
352
|
-
* @param {
|
453
|
+
* @param {number} Y
|
353
454
|
*/
|
354
|
-
changeAlpha(
|
355
|
-
/**
|
455
|
+
changeAlpha(Y: number): void;
|
456
|
+
/** Updates the open dropdown position on *scroll* event. */
|
356
457
|
updateDropdownPosition(): void;
|
357
|
-
/**
|
458
|
+
/** Updates control knobs' positions. */
|
358
459
|
setControlPositions(): void;
|
359
|
-
/** Update the visual appearance label. */
|
360
|
-
|
361
|
-
/** Updates the control knobs positions. */
|
460
|
+
/** Update the visual appearance label and control knob labels. */
|
461
|
+
updateAppearance(): void;
|
462
|
+
/** Updates the control knobs actual positions. */
|
362
463
|
updateControls(): void;
|
363
464
|
/**
|
364
|
-
*
|
465
|
+
* Updates all color form inputs.
|
365
466
|
* @param {boolean=} isPrevented when `true`, the component original event is prevented
|
366
467
|
*/
|
367
468
|
updateInputs(isPrevented?: boolean | undefined): void;
|
368
|
-
/**
|
469
|
+
/** Shows the `ColorPicker` dropdown or the presets menu. */
|
369
470
|
show(): void;
|
370
471
|
/**
|
371
|
-
* Hides the currently
|
472
|
+
* Hides the currently open `ColorPicker` dropdown.
|
372
473
|
* @param {boolean=} focusPrevented
|
373
474
|
*/
|
374
475
|
hide(focusPrevented?: boolean | undefined): void;
|
476
|
+
/** Removes `ColorPicker` from target `<input>`. */
|
375
477
|
dispose(): void;
|
376
478
|
}
|
479
|
+
import ColorPalette from "color-picker/src/js/color-palette";
|
377
480
|
import Color from "color-picker/src/js/color";
|
378
481
|
}
|
379
482
|
declare module "color-picker/src/js/color-picker-element" {
|
380
483
|
export default ColorPickerElement;
|
381
484
|
/**
|
382
|
-
*
|
383
|
-
* @see https://codepen.io/thednp/pen/yLVzZzW
|
384
|
-
* @see https://www.eyecon.ro/colorpicker/
|
385
|
-
* @see http://www.dematte.at/colorPicker/
|
386
|
-
*
|
485
|
+
* `ColorPickerElement` Web Component.
|
387
486
|
* @example
|
388
487
|
* <color-picker>
|
389
488
|
* <input type="text">
|
390
489
|
* </color-picker>
|
391
490
|
*/
|
392
491
|
class ColorPickerElement extends HTMLElement {
|
393
|
-
/** @type {ColorPicker?} */
|
394
|
-
colorPicker: ColorPicker | null;
|
395
|
-
/** @type {HTMLInputElement} */
|
396
|
-
input: HTMLInputElement;
|
397
492
|
/** @type {boolean} */
|
398
493
|
isDisconnected: boolean;
|
399
|
-
|
400
|
-
|
494
|
+
/**
|
495
|
+
* Returns the current color value.
|
496
|
+
* @returns {string?}
|
497
|
+
*/
|
498
|
+
get value(): string | null;
|
401
499
|
connectedCallback(): void;
|
500
|
+
/** @type {HTMLInputElement} */
|
501
|
+
input: HTMLInputElement | undefined;
|
502
|
+
colorPicker: ColorPicker | undefined;
|
503
|
+
color: Color | undefined;
|
402
504
|
disconnectedCallback(): void;
|
403
505
|
}
|
404
506
|
import ColorPicker from "color-picker/src/js/color-picker";
|
@@ -406,6 +508,7 @@ declare module "color-picker/src/js/color-picker-element" {
|
|
406
508
|
}
|
407
509
|
declare module "color-picker/types/source/source" {
|
408
510
|
export { default as Color } from "color-picker/src/js/color";
|
511
|
+
export { default as ColorPalette } from "color-picker/src/js/color-palette";
|
409
512
|
export { default as ColorPicker } from "color-picker/src/js/color-picker";
|
410
513
|
export { default as ColorPickerElement } from "color-picker/src/js/color-picker-element";
|
411
514
|
}
|