@thednp/color-picker 0.0.1-alpha1 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +63 -26
  3. package/dist/css/color-picker.css +504 -337
  4. package/dist/css/color-picker.min.css +2 -0
  5. package/dist/css/color-picker.rtl.css +529 -0
  6. package/dist/css/color-picker.rtl.min.css +2 -0
  7. package/dist/js/color-picker-element-esm.js +3851 -2
  8. package/dist/js/color-picker-element-esm.min.js +2 -0
  9. package/dist/js/color-picker-element.js +2086 -1278
  10. package/dist/js/color-picker-element.min.js +2 -2
  11. package/dist/js/color-picker-esm.js +3742 -0
  12. package/dist/js/color-picker-esm.min.js +2 -0
  13. package/dist/js/color-picker.js +2030 -1286
  14. package/dist/js/color-picker.min.js +2 -2
  15. package/package.json +18 -9
  16. package/src/js/color-palette.js +71 -0
  17. package/src/js/color-picker-element.js +62 -16
  18. package/src/js/color-picker.js +734 -618
  19. package/src/js/color.js +621 -358
  20. package/src/js/index.js +0 -9
  21. package/src/js/util/colorNames.js +2 -152
  22. package/src/js/util/colorPickerLabels.js +22 -0
  23. package/src/js/util/getColorControls.js +103 -0
  24. package/src/js/util/getColorForm.js +26 -19
  25. package/src/js/util/getColorMenu.js +88 -0
  26. package/src/js/util/isValidJSON.js +13 -0
  27. package/src/js/util/nonColors.js +5 -0
  28. package/src/js/util/roundPart.js +9 -0
  29. package/src/js/util/setCSSProperties.js +12 -0
  30. package/src/js/util/tabindex.js +3 -0
  31. package/src/js/util/templates.js +1 -0
  32. package/src/scss/color-picker.rtl.scss +23 -0
  33. package/src/scss/color-picker.scss +449 -0
  34. package/types/cp.d.ts +263 -162
  35. package/types/index.d.ts +9 -2
  36. package/types/source/source.ts +2 -1
  37. package/types/source/types.d.ts +28 -5
  38. package/dist/js/color-picker.esm.js +0 -2998
  39. package/dist/js/color-picker.esm.min.js +0 -2
  40. package/src/js/util/getColorControl.js +0 -49
  41. 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/colorNames" {
2
- export default colorNames;
1
+ declare module "color-picker/src/js/util/nonColors" {
2
+ export default nonColors;
3
3
  /**
4
- * A complete list of web safe colors.
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 colorNames: string[];
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
- export default class Color {
15
+ class Color {
17
16
  /**
18
17
  * @constructor
19
- * @param {CP.ColorInput} input
20
- * @param {CP.ColorOptions=} config
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.ColorOptions | undefined);
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 color.
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-1] range
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 color.
57
- * @returns {number} a number in [0-255] range
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 color as a RGBA object.
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
- * @returns {string} the CSS valid color in RGB/RGBA format
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 HEX value of the color.
72
- * @returns {string} the hexadecimal color format
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
- toHex(): string;
75
+ toRgbCSS4String(): string;
75
76
  /**
76
- * Returns the HEX value of the color.
77
- * @returns {string} the CSS valid color in hexadecimal format
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 color as a HSVA object.
82
- * @returns {CP.HSVA} the `{h,s,v,a}` object
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 color as a HSLA object.
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
- * @returns {string} the CSS valid color in HSL/HSLA format
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
- * Sets the alpha value on the current color.
97
- * @param {number} alpha a new alpha value in [0-1] range.
98
- * @returns {Color} a new `Color` instance
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 color with a given amount.
103
- * @param {number=} amount a value in [0-100] range
104
- * @returns {Color} a new `Color` instance
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 color with a given amount.
109
- * @param {number=} amount a value in [0-100] range
110
- * @returns {Color} a new `Color` instance
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 color into greyscale.
157
+ * Completely desaturates a colour into greyscale.
115
158
  * Same as calling `desaturate(100)`
116
- * @returns {Color} a new `Color` instance
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 color value in CSS valid string format.
123
- * @returns {string}
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/getColorControl" {
241
+ declare module "color-picker/src/js/util/getColorControls" {
141
242
  /**
142
- * Returns a new color control `HTMLElement`.
143
- * @param {number} iteration
144
- * @param {number} id
145
- * @param {number} width
146
- * @param {number} height
147
- * @param {string=} labelledby
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 getColorControl(iteration: number, id: number, width: number, height: number, labelledby?: string | undefined): HTMLElement | Element;
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 {HTMLCanvasElement?} */
170
- dragElement: HTMLCanvasElement | null;
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 {Array<string> | false} */
178
- keywords: Array<string> | false;
179
- /** @type {Color} */
180
- color: Color;
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
- * Handles all `ColorPicker` click listeners.
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
- * Handles all `ColorPicker` click listeners.
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
- * Handles the `ColorPicker` touchstart / mousedown events listeners.
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
- * Handles the `ColorPicker` touchmove / mousemove events listeners.
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
- * Handles the `ColorPicker` touchend / mouseup events listeners.
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
- * Handles the `ColorPicker` scroll listener when open.
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
- * Handles the `focusout` listener of the `ColorPicker`.
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
- /** Handles the event listeners of the color form. */
366
+ /** The event listener of the colour form inputs. */
235
367
  changeHandler(): void;
236
368
  /**
237
- * Handles the `focusout` listener of the `ColorPicker`.
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
- * Handles the `Space` and `Enter` keys inputs.
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
- keyHandler(this: ColorPicker, e: KeyboardEvent): void;
380
+ keyToggle(this: ColorPicker, e: KeyboardEvent): void;
248
381
  /**
249
- * Handles the `ColorPicker` events listeners associated with the color knobs.
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
- controls: HTMLElement;
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
- controlKnobs: (HTMLElement)[];
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 color value.
293
- * @param {string} v new color value
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 color value */
406
+ /** Returns the current colour value */
297
407
  get value(): string;
298
- /** Check if the input is required to have a valid value. */
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. */
313
- get includeNonColor(): boolean;
314
- /** Returns hexadecimal value of the current color. */
408
+ /** Check if the colour presets include any non-colour. */
409
+ get hasNonColor(): boolean;
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 color value in {h,s,v,a} object format. */
414
+ /** Returns the current colour value in {h,s,v,a} object format. */
317
415
  get hsv(): CP.HSVA;
318
- /** Returns the current color value in {h,s,l,a} object format. */
416
+ /** Returns the current colour value in {h,s,l,a} object format. */
319
417
  get hsl(): CP.HSLA;
320
- /** Returns the current color value in {r,g,b,a} object format. */
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 color brightness. */
422
+ /** Returns the current colour brightness. */
323
423
  get brightness(): number;
324
- /** Returns the current color luminance. */
424
+ /** Returns the current colour luminance. */
325
425
  get luminance(): number;
326
- /** Checks if the current colour requires a light text color. */
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 color. */
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,71 @@ 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 {Record<string, number>} offsets
437
+ * @param {number} X the X component of the offset
438
+ * @param {number} Y the Y component of the offset
338
439
  */
339
- changeControl1(offsets: Record<string, number>): void;
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 {Record<string, number>} offset
446
+ * @param {number} Y the Y offset
346
447
  */
347
- changeControl2(offset: Record<string, number>): void;
448
+ changeControl2(Y: number): void;
348
449
  /**
349
450
  * Updates `ColorPicker` last control,
350
- * the `alpha` channel for RGB/HSL.
451
+ * the `alpha` channel.
351
452
  *
352
- * @param {Record<string, number>} offset
453
+ * @param {number} Y
353
454
  */
354
- changeAlpha(offset: Record<string, number>): void;
355
- /** Update opened dropdown position on scroll. */
455
+ changeAlpha(Y: number): void;
456
+ /** Updates the open dropdown position on *scroll* event. */
356
457
  updateDropdownPosition(): void;
357
- /** Update control knobs' positions. */
458
+ /** Updates control knobs' positions. */
358
459
  setControlPositions(): void;
359
- /** Update the visual appearance label. */
360
- setColorAppearence(): void;
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
- * Update all color form inputs.
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
- /** Show the dropdown. */
369
- show(): void;
370
469
  /**
371
- * Hides the currently opened dropdown.
470
+ * Hides the currently open `ColorPicker` dropdown.
372
471
  * @param {boolean=} focusPrevented
373
472
  */
374
473
  hide(focusPrevented?: boolean | undefined): void;
474
+ /** Removes `ColorPicker` from target `<input>`. */
375
475
  dispose(): void;
376
476
  }
477
+ import ColorPalette from "color-picker/src/js/color-palette";
377
478
  import Color from "color-picker/src/js/color";
378
479
  }
379
480
  declare module "color-picker/src/js/color-picker-element" {
380
481
  export default ColorPickerElement;
381
482
  /**
382
- * @see https://codepen.io/dgrammatiko/pen/zLvXwR
383
- * @see https://codepen.io/thednp/pen/yLVzZzW
384
- * @see https://www.eyecon.ro/colorpicker/
385
- * @see http://www.dematte.at/colorPicker/
386
- *
483
+ * `ColorPickerElement` Web Component.
387
484
  * @example
388
485
  * <color-picker>
389
486
  * <input type="text">
390
487
  * </color-picker>
391
488
  */
392
489
  class ColorPickerElement extends HTMLElement {
393
- /** @type {ColorPicker?} */
394
- colorPicker: ColorPicker | null;
395
- /** @type {HTMLInputElement} */
396
- input: HTMLInputElement;
397
490
  /** @type {boolean} */
398
491
  isDisconnected: boolean;
399
- get value(): string;
400
- get color(): Color | null;
492
+ /**
493
+ * Returns the current color value.
494
+ * @returns {string?}
495
+ */
496
+ get value(): string | null;
401
497
  connectedCallback(): void;
498
+ /** @type {HTMLInputElement} */
499
+ input: HTMLInputElement | undefined;
500
+ colorPicker: ColorPicker | undefined;
501
+ color: Color | undefined;
402
502
  disconnectedCallback(): void;
403
503
  }
404
504
  import ColorPicker from "color-picker/src/js/color-picker";
@@ -406,6 +506,7 @@ declare module "color-picker/src/js/color-picker-element" {
406
506
  }
407
507
  declare module "color-picker/types/source/source" {
408
508
  export { default as Color } from "color-picker/src/js/color";
509
+ export { default as ColorPalette } from "color-picker/src/js/color-palette";
409
510
  export { default as ColorPicker } from "color-picker/src/js/color-picker";
410
511
  export { default as ColorPickerElement } from "color-picker/src/js/color-picker-element";
411
512
  }