@thednp/color-picker 0.0.1-alpha1
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 +21 -0
- package/README.md +89 -0
- package/dist/css/color-picker.css +338 -0
- package/dist/js/color-picker-element-esm.js +2 -0
- package/dist/js/color-picker-element.js +3051 -0
- package/dist/js/color-picker-element.min.js +2 -0
- package/dist/js/color-picker.esm.js +2998 -0
- package/dist/js/color-picker.esm.min.js +2 -0
- package/dist/js/color-picker.js +3006 -0
- package/dist/js/color-picker.min.js +2 -0
- package/package.json +79 -0
- package/src/js/color-picker-element.js +61 -0
- package/src/js/color-picker.js +1333 -0
- package/src/js/color.js +860 -0
- package/src/js/index.js +12 -0
- package/src/js/util/colorNames.js +156 -0
- package/src/js/util/getColorControl.js +49 -0
- package/src/js/util/getColorForm.js +58 -0
- package/src/js/util/init.js +14 -0
- package/src/js/util/templates.js +9 -0
- package/src/js/util/vHidden.js +2 -0
- package/src/js/version.js +6 -0
- package/types/cp.d.ts +411 -0
- package/types/index.d.ts +41 -0
- package/types/source/source.ts +4 -0
- package/types/source/types.d.ts +67 -0
package/types/cp.d.ts
ADDED
@@ -0,0 +1,411 @@
|
|
1
|
+
declare module "color-picker/src/js/util/colorNames" {
|
2
|
+
export default colorNames;
|
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[]}
|
7
|
+
*/
|
8
|
+
const colorNames: string[];
|
9
|
+
}
|
10
|
+
declare module "color-picker/src/js/color" {
|
11
|
+
/**
|
12
|
+
* Returns a new `Color` instance.
|
13
|
+
* @see https://github.com/bgrins/TinyColor
|
14
|
+
* @class
|
15
|
+
*/
|
16
|
+
export default class Color {
|
17
|
+
/**
|
18
|
+
* @constructor
|
19
|
+
* @param {CP.ColorInput} input
|
20
|
+
* @param {CP.ColorOptions=} config
|
21
|
+
*/
|
22
|
+
constructor(input: CP.ColorInput, config?: CP.ColorOptions | undefined);
|
23
|
+
/** @type {CP.ColorInput} */
|
24
|
+
originalInput: CP.ColorInput;
|
25
|
+
/** @type {number} */
|
26
|
+
r: number;
|
27
|
+
/** @type {number} */
|
28
|
+
g: number;
|
29
|
+
/** @type {number} */
|
30
|
+
b: number;
|
31
|
+
/** @type {number} */
|
32
|
+
a: number;
|
33
|
+
/** @type {boolean} */
|
34
|
+
ok: boolean;
|
35
|
+
/** @type {number} */
|
36
|
+
roundA: number;
|
37
|
+
/** @type {CP.ColorFormats} */
|
38
|
+
format: CP.ColorFormats;
|
39
|
+
/**
|
40
|
+
* Checks if the current input value is a valid colour.
|
41
|
+
* @returns {boolean} the query result
|
42
|
+
*/
|
43
|
+
get isValid(): boolean;
|
44
|
+
/**
|
45
|
+
* Checks if the current colour requires a light text colour.
|
46
|
+
* @returns {boolean} the query result
|
47
|
+
*/
|
48
|
+
get isDark(): boolean;
|
49
|
+
/**
|
50
|
+
* Returns the perceived luminance of a color.
|
51
|
+
* @see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
52
|
+
* @returns {number} a number in [0-1] range
|
53
|
+
*/
|
54
|
+
get luminance(): number;
|
55
|
+
/**
|
56
|
+
* Returns the perceived brightness of the color.
|
57
|
+
* @returns {number} a number in [0-255] range
|
58
|
+
*/
|
59
|
+
get brightness(): number;
|
60
|
+
/**
|
61
|
+
* Returns the color as a RGBA object.
|
62
|
+
* @returns {CP.RGBA}
|
63
|
+
*/
|
64
|
+
toRgb(): CP.RGBA;
|
65
|
+
/**
|
66
|
+
* Returns the RGBA values concatenated into a string.
|
67
|
+
* @returns {string} the CSS valid color in RGB/RGBA format
|
68
|
+
*/
|
69
|
+
toRgbString(): string;
|
70
|
+
/**
|
71
|
+
* Returns the HEX value of the color.
|
72
|
+
* @returns {string} the hexadecimal color format
|
73
|
+
*/
|
74
|
+
toHex(): string;
|
75
|
+
/**
|
76
|
+
* Returns the HEX value of the color.
|
77
|
+
* @returns {string} the CSS valid color in hexadecimal format
|
78
|
+
*/
|
79
|
+
toHexString(): string;
|
80
|
+
/**
|
81
|
+
* Returns the color as a HSVA object.
|
82
|
+
* @returns {CP.HSVA} the `{h,s,v,a}` object
|
83
|
+
*/
|
84
|
+
toHsv(): CP.HSVA;
|
85
|
+
/**
|
86
|
+
* Returns the color as a HSLA object.
|
87
|
+
* @returns {CP.HSLA}
|
88
|
+
*/
|
89
|
+
toHsl(): CP.HSLA;
|
90
|
+
/**
|
91
|
+
* Returns the HSLA values concatenated into a string.
|
92
|
+
* @returns {string} the CSS valid color in HSL/HSLA format
|
93
|
+
*/
|
94
|
+
toHslString(): string;
|
95
|
+
/**
|
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
|
99
|
+
*/
|
100
|
+
setAlpha(alpha: number): Color;
|
101
|
+
/**
|
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
|
105
|
+
*/
|
106
|
+
saturate(amount?: number | undefined): Color;
|
107
|
+
/**
|
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
|
111
|
+
*/
|
112
|
+
desaturate(amount?: number | undefined): Color;
|
113
|
+
/**
|
114
|
+
* Completely desaturates a color into greyscale.
|
115
|
+
* Same as calling `desaturate(100)`
|
116
|
+
* @returns {Color} a new `Color` instance
|
117
|
+
*/
|
118
|
+
greyscale(): Color;
|
119
|
+
/** Returns a clone of the current `Color` instance. */
|
120
|
+
clone(): Color;
|
121
|
+
/**
|
122
|
+
* Returns the color value in CSS valid string format.
|
123
|
+
* @returns {string}
|
124
|
+
*/
|
125
|
+
toString(): string;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
declare module "color-picker/src/js/util/vHidden" {
|
129
|
+
export default vHidden;
|
130
|
+
const vHidden: "v-hidden";
|
131
|
+
}
|
132
|
+
declare module "color-picker/src/js/util/getColorForm" {
|
133
|
+
/**
|
134
|
+
* Returns the color form.
|
135
|
+
* @param {CP.ColorPicker} self the `ColorPicker` instance
|
136
|
+
* @returns {HTMLElement | Element}
|
137
|
+
*/
|
138
|
+
export default function getColorForm(self: CP.ColorPicker): HTMLElement | Element;
|
139
|
+
}
|
140
|
+
declare module "color-picker/src/js/util/getColorControl" {
|
141
|
+
/**
|
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
|
148
|
+
* @returns {HTMLElement | Element}
|
149
|
+
*/
|
150
|
+
export default function getColorControl(iteration: number, id: number, width: number, height: number, labelledby?: string | undefined): HTMLElement | Element;
|
151
|
+
}
|
152
|
+
declare module "color-picker/src/js/color-picker" {
|
153
|
+
/**
|
154
|
+
* Color Picker
|
155
|
+
* @see http://thednp.github.io/color-picker
|
156
|
+
*/
|
157
|
+
export default class ColorPicker {
|
158
|
+
/**
|
159
|
+
* Returns a new ColorPicker instance.
|
160
|
+
* @param {HTMLInputElement | string} target the target `<input>` element
|
161
|
+
*/
|
162
|
+
constructor(target: HTMLInputElement | string);
|
163
|
+
/** @type {HTMLInputElement} */
|
164
|
+
input: HTMLInputElement;
|
165
|
+
/** @type {HTMLElement} */
|
166
|
+
parent: HTMLElement;
|
167
|
+
/** @type {number} */
|
168
|
+
id: number;
|
169
|
+
/** @type {HTMLCanvasElement?} */
|
170
|
+
dragElement: HTMLCanvasElement | null;
|
171
|
+
/** @type {boolean} */
|
172
|
+
isOpen: boolean;
|
173
|
+
/** @type {Record<string, number>} */
|
174
|
+
controlPositions: Record<string, number>;
|
175
|
+
/** @type {Record<string, string>} */
|
176
|
+
colorLabels: Record<string, string>;
|
177
|
+
/** @type {Array<string> | false} */
|
178
|
+
keywords: Array<string> | false;
|
179
|
+
/** @type {Color} */
|
180
|
+
color: Color;
|
181
|
+
/** @type {Record<string, string>} */
|
182
|
+
componentLabels: Record<string, string>;
|
183
|
+
/** Shows the `ColorPicker` dropdown. */
|
184
|
+
showPicker(): void;
|
185
|
+
/**
|
186
|
+
* Toggle the `ColorPicker` dropdown visibility.
|
187
|
+
* @param {Event} e
|
188
|
+
* @this {ColorPicker}
|
189
|
+
*/
|
190
|
+
togglePicker(this: ColorPicker, e: Event): void;
|
191
|
+
/** Toggles the visibility of the `ColorPicker` presets menu. */
|
192
|
+
toggleMenu(): void;
|
193
|
+
/**
|
194
|
+
* Handles all `ColorPicker` click listeners.
|
195
|
+
* @param {Partial<Event>} e
|
196
|
+
* @this {ColorPicker}
|
197
|
+
*/
|
198
|
+
menuClickHandler(this: ColorPicker, e: Partial<Event>): void;
|
199
|
+
/**
|
200
|
+
* Handles all `ColorPicker` click listeners.
|
201
|
+
* @param {KeyboardEvent} e
|
202
|
+
* @this {ColorPicker}
|
203
|
+
*/
|
204
|
+
menuKeyHandler(this: ColorPicker, e: KeyboardEvent): void;
|
205
|
+
/**
|
206
|
+
* Handles the `ColorPicker` touchstart / mousedown events listeners.
|
207
|
+
* @param {TouchEvent} e
|
208
|
+
* @this {ColorPicker}
|
209
|
+
*/
|
210
|
+
pointerDown(this: ColorPicker, e: TouchEvent): void;
|
211
|
+
/**
|
212
|
+
* Handles the `ColorPicker` touchmove / mousemove events listeners.
|
213
|
+
* @param {TouchEvent} e
|
214
|
+
*/
|
215
|
+
pointerMove(e: TouchEvent): void;
|
216
|
+
/**
|
217
|
+
* Handles the `ColorPicker` touchend / mouseup events listeners.
|
218
|
+
* @param {TouchEvent} e
|
219
|
+
* @this {ColorPicker}
|
220
|
+
*/
|
221
|
+
pointerUp(this: ColorPicker, { target }: TouchEvent): void;
|
222
|
+
/**
|
223
|
+
* Handles the `ColorPicker` scroll listener when open.
|
224
|
+
* @param {Event} e
|
225
|
+
* @this {ColorPicker}
|
226
|
+
*/
|
227
|
+
handleScroll(this: ColorPicker, e: Event): void;
|
228
|
+
/**
|
229
|
+
* Handles the `focusout` listener of the `ColorPicker`.
|
230
|
+
* @param {FocusEvent} e
|
231
|
+
* @this {ColorPicker}
|
232
|
+
*/
|
233
|
+
handleFocusOut(this: ColorPicker, { relatedTarget }: FocusEvent): void;
|
234
|
+
/** Handles the event listeners of the color form. */
|
235
|
+
changeHandler(): void;
|
236
|
+
/**
|
237
|
+
* Handles the `focusout` listener of the `ColorPicker`.
|
238
|
+
* @param {KeyboardEvent} e
|
239
|
+
* @this {ColorPicker}
|
240
|
+
*/
|
241
|
+
handleDismiss(this: ColorPicker, { code }: KeyboardEvent): void;
|
242
|
+
/**
|
243
|
+
* Handles the `Space` and `Enter` keys inputs.
|
244
|
+
* @param {KeyboardEvent} e
|
245
|
+
* @this {ColorPicker}
|
246
|
+
*/
|
247
|
+
keyHandler(this: ColorPicker, e: KeyboardEvent): void;
|
248
|
+
/**
|
249
|
+
* Handles the `ColorPicker` events listeners associated with the color knobs.
|
250
|
+
* @param {KeyboardEvent} e
|
251
|
+
*/
|
252
|
+
handleKnobs(e: KeyboardEvent): void;
|
253
|
+
/** @type {HTMLElement} */
|
254
|
+
pickerToggle: HTMLElement;
|
255
|
+
/** @type {HTMLElement} */
|
256
|
+
menuToggle: HTMLElement;
|
257
|
+
/** @type {HTMLElement} */
|
258
|
+
colorMenu: HTMLElement;
|
259
|
+
/** @type {HTMLElement} */
|
260
|
+
colorPicker: HTMLElement;
|
261
|
+
/** @type {HTMLElement} */
|
262
|
+
controls: HTMLElement;
|
263
|
+
/** @type {HTMLInputElement[]} */
|
264
|
+
inputs: HTMLInputElement[];
|
265
|
+
/** @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;
|
291
|
+
/**
|
292
|
+
* Sets a new color value.
|
293
|
+
* @param {string} v new color value
|
294
|
+
*/
|
295
|
+
set value(arg: string);
|
296
|
+
/** Returns the current color value */
|
297
|
+
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. */
|
315
|
+
get hex(): string;
|
316
|
+
/** Returns the current color value in {h,s,v,a} object format. */
|
317
|
+
get hsv(): CP.HSVA;
|
318
|
+
/** Returns the current color value in {h,s,l,a} object format. */
|
319
|
+
get hsl(): CP.HSLA;
|
320
|
+
/** Returns the current color value in {r,g,b,a} object format. */
|
321
|
+
get rgb(): CP.RGBA;
|
322
|
+
/** Returns the current color brightness. */
|
323
|
+
get brightness(): number;
|
324
|
+
/** Returns the current color luminance. */
|
325
|
+
get luminance(): number;
|
326
|
+
/** Checks if the current colour requires a light text color. */
|
327
|
+
get isDark(): boolean;
|
328
|
+
/** Checks if the current input value is a valid color. */
|
329
|
+
get isValid(): boolean;
|
330
|
+
/** Updates `ColorPicker` visuals. */
|
331
|
+
updateVisuals(): void;
|
332
|
+
/**
|
333
|
+
* Updates `ColorPicker` first control:
|
334
|
+
* * `lightness` and `saturation` for HEX/RGB;
|
335
|
+
* * `lightness` and `hue` for HSL.
|
336
|
+
*
|
337
|
+
* @param {Record<string, number>} offsets
|
338
|
+
*/
|
339
|
+
changeControl1(offsets: Record<string, number>): void;
|
340
|
+
/**
|
341
|
+
* Updates `ColorPicker` second control:
|
342
|
+
* * `hue` for HEX/RGB;
|
343
|
+
* * `saturation` for HSL.
|
344
|
+
*
|
345
|
+
* @param {Record<string, number>} offset
|
346
|
+
*/
|
347
|
+
changeControl2(offset: Record<string, number>): void;
|
348
|
+
/**
|
349
|
+
* Updates `ColorPicker` last control,
|
350
|
+
* the `alpha` channel for RGB/HSL.
|
351
|
+
*
|
352
|
+
* @param {Record<string, number>} offset
|
353
|
+
*/
|
354
|
+
changeAlpha(offset: Record<string, number>): void;
|
355
|
+
/** Update opened dropdown position on scroll. */
|
356
|
+
updateDropdownPosition(): void;
|
357
|
+
/** Update control knobs' positions. */
|
358
|
+
setControlPositions(): void;
|
359
|
+
/** Update the visual appearance label. */
|
360
|
+
setColorAppearence(): void;
|
361
|
+
/** Updates the control knobs positions. */
|
362
|
+
updateControls(): void;
|
363
|
+
/**
|
364
|
+
* Update all color form inputs.
|
365
|
+
* @param {boolean=} isPrevented when `true`, the component original event is prevented
|
366
|
+
*/
|
367
|
+
updateInputs(isPrevented?: boolean | undefined): void;
|
368
|
+
/** Show the dropdown. */
|
369
|
+
show(): void;
|
370
|
+
/**
|
371
|
+
* Hides the currently opened dropdown.
|
372
|
+
* @param {boolean=} focusPrevented
|
373
|
+
*/
|
374
|
+
hide(focusPrevented?: boolean | undefined): void;
|
375
|
+
dispose(): void;
|
376
|
+
}
|
377
|
+
import Color from "color-picker/src/js/color";
|
378
|
+
}
|
379
|
+
declare module "color-picker/src/js/color-picker-element" {
|
380
|
+
export default ColorPickerElement;
|
381
|
+
/**
|
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
|
+
*
|
387
|
+
* @example
|
388
|
+
* <color-picker>
|
389
|
+
* <input type="text">
|
390
|
+
* </color-picker>
|
391
|
+
*/
|
392
|
+
class ColorPickerElement extends HTMLElement {
|
393
|
+
/** @type {ColorPicker?} */
|
394
|
+
colorPicker: ColorPicker | null;
|
395
|
+
/** @type {HTMLInputElement} */
|
396
|
+
input: HTMLInputElement;
|
397
|
+
/** @type {boolean} */
|
398
|
+
isDisconnected: boolean;
|
399
|
+
get value(): string;
|
400
|
+
get color(): Color | null;
|
401
|
+
connectedCallback(): void;
|
402
|
+
disconnectedCallback(): void;
|
403
|
+
}
|
404
|
+
import ColorPicker from "color-picker/src/js/color-picker";
|
405
|
+
import Color from "color-picker/src/js/color";
|
406
|
+
}
|
407
|
+
declare module "color-picker/types/source/source" {
|
408
|
+
export { default as Color } from "color-picker/src/js/color";
|
409
|
+
export { default as ColorPicker } from "color-picker/src/js/color-picker";
|
410
|
+
export { default as ColorPickerElement } from "color-picker/src/js/color-picker-element";
|
411
|
+
}
|
package/types/index.d.ts
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
export as namespace CP;
|
2
|
+
export {Color, ColorPicker, ColorPickerElement};
|
3
|
+
|
4
|
+
export {
|
5
|
+
HSL,
|
6
|
+
HSLA,
|
7
|
+
RGB,
|
8
|
+
RGBA,
|
9
|
+
HSV,
|
10
|
+
HSVA,
|
11
|
+
ColorObject,
|
12
|
+
ColorFormats,
|
13
|
+
ColorInput,
|
14
|
+
ColorOptions,
|
15
|
+
GetInstance,
|
16
|
+
InitCallback,
|
17
|
+
} from './source/types';
|
18
|
+
|
19
|
+
import './cp';
|
20
|
+
import { default as Color } from "color-picker/src/js/color";
|
21
|
+
import { default as ColorPicker } from "color-picker/src/js/color-picker";
|
22
|
+
import { default as ColorPickerElement } from "color-picker/src/js/color-picker-element";
|
23
|
+
|
24
|
+
declare module "@thednp/color-picker" {
|
25
|
+
export default ColorPicker;
|
26
|
+
}
|
27
|
+
|
28
|
+
declare module "@thednp/color-picker/src/js/color" {
|
29
|
+
export default Color;
|
30
|
+
}
|
31
|
+
|
32
|
+
declare module "@thednp/color-picker/src/js/color-picker" {
|
33
|
+
export default ColorPicker;
|
34
|
+
}
|
35
|
+
|
36
|
+
declare module "@thednp/color-picker/src/js/color-picker-element" {
|
37
|
+
export default ColorPickerElement;
|
38
|
+
}
|
39
|
+
|
40
|
+
export * as SHORTER from "shorter-js";
|
41
|
+
export * as EventListener from "event-listener.js";
|
@@ -0,0 +1,4 @@
|
|
1
|
+
// export { default as Color } from "../../types/source/types";
|
2
|
+
export { default as Color } from "../../src/js/color";
|
3
|
+
export { default as ColorPicker } from "../../src/js/color-picker";
|
4
|
+
export { default as ColorPickerElement } from "../../src/js/color-picker-element";
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/**
|
2
|
+
* A `Color` compatible object.
|
3
|
+
*/
|
4
|
+
export interface ColorObject {
|
5
|
+
r: number;
|
6
|
+
g: number;
|
7
|
+
b: number;
|
8
|
+
a: number;
|
9
|
+
ok: boolean;
|
10
|
+
format: ColorFormats;
|
11
|
+
}
|
12
|
+
|
13
|
+
/**
|
14
|
+
* A representation of additive color mixing.
|
15
|
+
* Projection of primary color lights on a white screen shows secondary
|
16
|
+
* colors where two overlap; the combination of all three of red, green,
|
17
|
+
* and blue in equal intensities makes white.
|
18
|
+
*/
|
19
|
+
export interface RGB {
|
20
|
+
r: number;
|
21
|
+
g: number;
|
22
|
+
b: number;
|
23
|
+
}
|
24
|
+
|
25
|
+
export interface RGBA extends RGB {
|
26
|
+
a: number;
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* The HSL model describes colors in terms of hue, saturation,
|
31
|
+
* and lightness (also called luminance).
|
32
|
+
* @link https://en.wikibooks.org/wiki/Color_Models:_RGB,_HSV,_HSL#HSL
|
33
|
+
*/
|
34
|
+
export interface HSL {
|
35
|
+
// h: number | string;
|
36
|
+
// s: number | string;
|
37
|
+
// l: number | string;
|
38
|
+
h: number;
|
39
|
+
s: number;
|
40
|
+
l: number;
|
41
|
+
}
|
42
|
+
|
43
|
+
export interface HSLA extends HSL {
|
44
|
+
a: number;
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* The HSV, or HSB, model describes colors in terms of
|
49
|
+
* hue, saturation, and value (brightness).
|
50
|
+
* @link https://en.wikibooks.org/wiki/Color_Models:_RGB,_HSV,_HSL#HSV
|
51
|
+
*/
|
52
|
+
export interface HSV {
|
53
|
+
h: number;
|
54
|
+
s: number;
|
55
|
+
v: number;
|
56
|
+
}
|
57
|
+
|
58
|
+
export interface HSVA extends HSV {
|
59
|
+
a: number;
|
60
|
+
}
|
61
|
+
|
62
|
+
export interface ColorOptions { format: ColorFormats; }
|
63
|
+
export type ColorInput = string | number | RGB | RGBA | HSL | HSLA | HSV | HSVA | ColorObject;
|
64
|
+
export type ColorFormats = string | 'rgb' | 'hex' | 'hex3' | 'hex6' | 'hsl' | 'hsv';
|
65
|
+
|
66
|
+
export type GetInstance<T> = (element: string | HTMLInputElement) => T | null;
|
67
|
+
export type InitCallback<T> = (element: string | HTMLInputElement, config?: ColorOptions) => T;
|