@thednp/color-picker 1.0.1 → 2.0.0-alpha1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.cjs +199 -0
- package/.lgtm.yml +9 -0
- package/.prettierrc.json +15 -0
- package/.stylelintrc.json +236 -0
- package/LICENSE +0 -0
- package/README.md +54 -72
- package/compile.js +48 -0
- package/cypress/downloads/downloads.htm +0 -0
- package/cypress/e2e/color-palette.cy.ts +128 -0
- package/cypress/e2e/color-picker.cy.ts +920 -0
- package/cypress/fixtures/colorNamesFrench.js +3 -0
- package/cypress/fixtures/componentLabelsFrench.js +21 -0
- package/cypress/fixtures/format.js +3 -0
- package/cypress/fixtures/getCEMarkup.js +29 -0
- package/cypress/fixtures/getMarkup.js +28 -0
- package/cypress/fixtures/getRandomInt.js +6 -0
- package/cypress/fixtures/sampleWebcolors.js +18 -0
- package/cypress/fixtures/testSample.js +8 -0
- package/cypress/plugins/esbuild-istanbul.ts +50 -0
- package/cypress/plugins/tsCompile.ts +34 -0
- package/cypress/support/commands.ts +0 -0
- package/cypress/support/e2e.ts +21 -0
- package/cypress/test.html +23 -0
- package/cypress.config.ts +29 -0
- package/dist/css/color-picker.css +14 -38
- package/dist/css/color-picker.min.css +2 -2
- package/dist/css/color-picker.rtl.css +14 -38
- package/dist/css/color-picker.rtl.min.css +2 -2
- package/dist/js/color-picker.cjs +8 -0
- package/dist/js/color-picker.cjs.map +1 -0
- package/dist/js/color-picker.d.ts +278 -0
- package/dist/js/color-picker.js +5 -3570
- package/dist/js/color-picker.js.map +1 -0
- package/dist/js/color-picker.mjs +2631 -0
- package/dist/js/color-picker.mjs.map +1 -0
- package/dts.config.ts +15 -0
- package/package.json +64 -74
- package/src/scss/_variables.scss +0 -1
- package/src/scss/color-picker.rtl.scss +4 -0
- package/src/scss/color-picker.scss +74 -38
- package/src/ts/colorPalette.ts +89 -0
- package/src/{js/color-picker.js → ts/index.ts} +489 -486
- package/src/ts/interface/colorPickerLabels.ts +20 -0
- package/src/ts/interface/colorPickerOptions.ts +11 -0
- package/src/ts/interface/paletteOptions.ts +6 -0
- package/src/ts/util/colorNames.ts +21 -0
- package/src/{js/util/colorPickerLabels.js → ts/util/colorPickerLabels.ts} +4 -2
- package/src/ts/util/getColorControls.ts +90 -0
- package/src/{js/util/getColorForm.js → ts/util/getColorForm.ts} +28 -18
- package/src/{js/util/getColorMenu.js → ts/util/getColorMenu.ts} +21 -30
- package/src/ts/util/isValidJSON.ts +19 -0
- package/src/{js/util/setMarkup.js → ts/util/setMarkup.ts} +57 -48
- package/src/{js/util/vHidden.js → ts/util/vHidden.ts} +0 -0
- package/tsconfig.json +29 -0
- package/vite.config.ts +34 -0
- package/dist/js/color-esm.js +0 -1164
- package/dist/js/color-esm.min.js +0 -2
- package/dist/js/color-palette-esm.js +0 -1235
- package/dist/js/color-palette-esm.min.js +0 -2
- package/dist/js/color-palette.js +0 -1243
- package/dist/js/color-palette.min.js +0 -2
- package/dist/js/color-picker-element-esm.js +0 -3718
- package/dist/js/color-picker-element-esm.min.js +0 -2
- package/dist/js/color-picker-element.js +0 -3726
- package/dist/js/color-picker-element.min.js +0 -2
- package/dist/js/color-picker-esm.js +0 -3565
- package/dist/js/color-picker-esm.min.js +0 -2
- package/dist/js/color-picker.min.js +0 -2
- package/dist/js/color.js +0 -1172
- package/dist/js/color.min.js +0 -2
- package/src/js/color-palette.js +0 -75
- package/src/js/color-picker-element.js +0 -107
- package/src/js/color.js +0 -1104
- package/src/js/index.js +0 -8
- package/src/js/util/colorNames.js +0 -6
- package/src/js/util/getColorControls.js +0 -103
- package/src/js/util/isValidJSON.js +0 -13
- package/src/js/util/nonColors.js +0 -5
- package/src/js/util/roundPart.js +0 -9
- package/src/js/util/setCSSProperties.js +0 -12
- package/src/js/util/tabindex.js +0 -3
- package/src/js/util/toggleCEAttr.js +0 -70
- package/src/js/util/version.js +0 -5
- package/src/js/version.js +0 -5
- package/types/cp.d.ts +0 -558
- package/types/index.d.ts +0 -44
- package/types/source/source.ts +0 -4
- package/types/source/types.d.ts +0 -92
package/types/cp.d.ts
DELETED
@@ -1,558 +0,0 @@
|
|
1
|
-
declare module "color-picker/src/js/util/nonColors" {
|
2
|
-
export default nonColors;
|
3
|
-
/**
|
4
|
-
* A list of explicit default non-color values.
|
5
|
-
*/
|
6
|
-
const nonColors: string[];
|
7
|
-
}
|
8
|
-
declare module "color-picker/src/js/util/roundPart" {
|
9
|
-
/**
|
10
|
-
* Round colour components, for all formats except HEX.
|
11
|
-
* @param {number} v one of the colour components
|
12
|
-
* @returns {number} the rounded number
|
13
|
-
*/
|
14
|
-
export default function roundPart(v: number): number;
|
15
|
-
}
|
16
|
-
declare module "color-picker/src/js/color" {
|
17
|
-
/**
|
18
|
-
* @class
|
19
|
-
* Returns a new `Color` instance.
|
20
|
-
* @see https://github.com/bgrins/TinyColor
|
21
|
-
*/
|
22
|
-
export default class Color {
|
23
|
-
/**
|
24
|
-
* @constructor
|
25
|
-
* @param {CP.ColorInput} input the given colour value
|
26
|
-
* @param {CP.ColorFormats=} config the given format
|
27
|
-
*/
|
28
|
-
constructor(input: CP.ColorInput, config?: CP.ColorFormats | undefined);
|
29
|
-
/** @type {CP.ColorInput} */
|
30
|
-
originalInput: CP.ColorInput;
|
31
|
-
/** @type {number} */
|
32
|
-
r: number;
|
33
|
-
/** @type {number} */
|
34
|
-
g: number;
|
35
|
-
/** @type {number} */
|
36
|
-
b: number;
|
37
|
-
/** @type {number} */
|
38
|
-
a: number;
|
39
|
-
/** @type {boolean} */
|
40
|
-
ok: boolean;
|
41
|
-
/** @type {CP.ColorFormats} */
|
42
|
-
format: CP.ColorFormats;
|
43
|
-
/**
|
44
|
-
* Checks if the current input value is a valid colour.
|
45
|
-
* @returns {boolean} the query result
|
46
|
-
*/
|
47
|
-
get isValid(): boolean;
|
48
|
-
/**
|
49
|
-
* Checks if the current colour requires a light text colour.
|
50
|
-
* @returns {boolean} the query result
|
51
|
-
*/
|
52
|
-
get isDark(): boolean;
|
53
|
-
/**
|
54
|
-
* Returns the perceived luminance of a colour.
|
55
|
-
* @see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
56
|
-
* @returns {number} a number in the [0, 1] range
|
57
|
-
*/
|
58
|
-
get luminance(): number;
|
59
|
-
/**
|
60
|
-
* Returns the perceived brightness of the colour.
|
61
|
-
* @returns {number} a number in the [0, 255] range
|
62
|
-
*/
|
63
|
-
get brightness(): number;
|
64
|
-
/**
|
65
|
-
* Returns the colour as an RGBA object.
|
66
|
-
* @returns {CP.RGBA} an {r,g,b,a} object with [0, 255] ranged values
|
67
|
-
*/
|
68
|
-
toRgb(): CP.RGBA;
|
69
|
-
/**
|
70
|
-
* Returns the RGBA values concatenated into a CSS3 Module string format.
|
71
|
-
* * rgb(255,255,255)
|
72
|
-
* * rgba(255,255,255,0.5)
|
73
|
-
* @returns {string} the CSS valid colour in RGB/RGBA format
|
74
|
-
*/
|
75
|
-
toRgbString(): string;
|
76
|
-
/**
|
77
|
-
* Returns the RGBA values concatenated into a CSS4 Module string format.
|
78
|
-
* * rgb(255 255 255)
|
79
|
-
* * rgb(255 255 255 / 50%)
|
80
|
-
* @returns {string} the CSS valid colour in CSS4 RGB format
|
81
|
-
*/
|
82
|
-
toRgbCSS4String(): string;
|
83
|
-
/**
|
84
|
-
* Returns the hexadecimal value of the colour. When the parameter is *true*
|
85
|
-
* it will find a 3 characters shorthand of the decimal value.
|
86
|
-
*
|
87
|
-
* @param {boolean=} allow3Char when `true` returns shorthand HEX
|
88
|
-
* @returns {string} the hexadecimal colour format
|
89
|
-
*/
|
90
|
-
toHex(allow3Char?: boolean | undefined): string;
|
91
|
-
/**
|
92
|
-
* Returns the CSS valid hexadecimal vaue of the colour. When the parameter is *true*
|
93
|
-
* it will find a 3 characters shorthand of the value.
|
94
|
-
*
|
95
|
-
* @param {boolean=} allow3Char when `true` returns shorthand HEX
|
96
|
-
* @returns {string} the CSS valid colour in hexadecimal format
|
97
|
-
*/
|
98
|
-
toHexString(allow3Char?: boolean | undefined): string;
|
99
|
-
/**
|
100
|
-
* Returns the HEX8 value of the colour.
|
101
|
-
* @param {boolean=} allow4Char when `true` returns shorthand HEX
|
102
|
-
* @returns {string} the CSS valid colour in hexadecimal format
|
103
|
-
*/
|
104
|
-
toHex8(allow4Char?: boolean | undefined): string;
|
105
|
-
/**
|
106
|
-
* Returns the HEX8 value of the colour.
|
107
|
-
* @param {boolean=} allow4Char when `true` returns shorthand HEX
|
108
|
-
* @returns {string} the CSS valid colour in hexadecimal format
|
109
|
-
*/
|
110
|
-
toHex8String(allow4Char?: boolean | undefined): string;
|
111
|
-
/**
|
112
|
-
* Returns the colour as a HSVA object.
|
113
|
-
* @returns {CP.HSVA} the `{h,s,v,a}` object with [0, 1] ranged values
|
114
|
-
*/
|
115
|
-
toHsv(): CP.HSVA;
|
116
|
-
/**
|
117
|
-
* Returns the colour as an HSLA object.
|
118
|
-
* @returns {CP.HSLA} the `{h,s,l,a}` object with [0, 1] ranged values
|
119
|
-
*/
|
120
|
-
toHsl(): CP.HSLA;
|
121
|
-
/**
|
122
|
-
* Returns the HSLA values concatenated into a CSS3 Module format string.
|
123
|
-
* * `hsl(150, 100%, 50%)`
|
124
|
-
* * `hsla(150, 100%, 50%, 0.5)`
|
125
|
-
* @returns {string} the CSS valid colour in HSL/HSLA format
|
126
|
-
*/
|
127
|
-
toHslString(): string;
|
128
|
-
/**
|
129
|
-
* Returns the HSLA values concatenated into a CSS4 Module format string.
|
130
|
-
* * `hsl(150deg 100% 50%)`
|
131
|
-
* * `hsl(150deg 100% 50% / 50%)`
|
132
|
-
* @returns {string} the CSS valid colour in CSS4 HSL format
|
133
|
-
*/
|
134
|
-
toHslCSS4String(): string;
|
135
|
-
/**
|
136
|
-
* Returns the colour as an HWBA object.
|
137
|
-
* @returns {CP.HWBA} the `{h,w,b,a}` object with [0, 1] ranged values
|
138
|
-
*/
|
139
|
-
toHwb(): CP.HWBA;
|
140
|
-
/**
|
141
|
-
* Returns the HWBA values concatenated into a string.
|
142
|
-
* @returns {string} the CSS valid colour in HWB format
|
143
|
-
*/
|
144
|
-
toHwbString(): string;
|
145
|
-
/**
|
146
|
-
* Sets the alpha value of the current colour.
|
147
|
-
* @param {number} alpha a new alpha value in the [0, 1] range.
|
148
|
-
* @returns {Color} the `Color` instance
|
149
|
-
*/
|
150
|
-
setAlpha(alpha: number): Color;
|
151
|
-
/**
|
152
|
-
* Saturate the colour with a given amount.
|
153
|
-
* @param {number=} amount a value in the [0, 100] range
|
154
|
-
* @returns {Color} the `Color` instance
|
155
|
-
*/
|
156
|
-
saturate(amount?: number | undefined): Color;
|
157
|
-
/**
|
158
|
-
* Desaturate the colour with a given amount.
|
159
|
-
* @param {number=} amount a value in the [0, 100] range
|
160
|
-
* @returns {Color} the `Color` instance
|
161
|
-
*/
|
162
|
-
desaturate(amount?: number | undefined): Color;
|
163
|
-
/**
|
164
|
-
* Completely desaturates a colour into greyscale.
|
165
|
-
* Same as calling `desaturate(100)`
|
166
|
-
* @returns {Color} the `Color` instance
|
167
|
-
*/
|
168
|
-
greyscale(): Color;
|
169
|
-
/**
|
170
|
-
* Increase the colour lightness with a given amount.
|
171
|
-
* @param {number=} amount a value in the [0, 100] range
|
172
|
-
* @returns {Color} the `Color` instance
|
173
|
-
*/
|
174
|
-
lighten(amount?: number | undefined): Color;
|
175
|
-
/**
|
176
|
-
* Decrease the colour lightness with a given amount.
|
177
|
-
* @param {number=} amount a value in the [0, 100] range
|
178
|
-
* @returns {Color} the `Color` instance
|
179
|
-
*/
|
180
|
-
darken(amount?: number | undefined): Color;
|
181
|
-
/**
|
182
|
-
* Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
|
183
|
-
* Values outside of this range will be wrapped into this range.
|
184
|
-
*
|
185
|
-
* @param {number=} amount a value in the [0, 100] range
|
186
|
-
* @returns {Color} the `Color` instance
|
187
|
-
*/
|
188
|
-
spin(amount?: number | undefined): Color;
|
189
|
-
/** Returns a clone of the current `Color` instance. */
|
190
|
-
clone(): Color;
|
191
|
-
/**
|
192
|
-
* Returns the colour value in CSS valid string format.
|
193
|
-
* @param {boolean=} allowShort when *true*, HEX values can be shorthand
|
194
|
-
* @returns {string} the CSS valid colour in the configured format
|
195
|
-
*/
|
196
|
-
toString(allowShort?: boolean | undefined): string;
|
197
|
-
}
|
198
|
-
}
|
199
|
-
declare module "color-picker/src/js/color-palette" {
|
200
|
-
/**
|
201
|
-
* @class
|
202
|
-
* Returns a color palette with a given set of parameters.
|
203
|
-
* @example
|
204
|
-
* new ColorPalette(0, 12, 10);
|
205
|
-
* // => { hue: 0, hueSteps: 12, lightSteps: 10, colors: Array<Color> }
|
206
|
-
*/
|
207
|
-
export default class ColorPalette {
|
208
|
-
/**
|
209
|
-
* The `hue` parameter is optional, which would be set to 0.
|
210
|
-
* @param {number[]} args represeinting hue, hueSteps, lightSteps
|
211
|
-
* * `args.hue` the starting Hue [0, 360]
|
212
|
-
* * `args.hueSteps` Hue Steps Count [5, 24]
|
213
|
-
* * `args.lightSteps` Lightness Steps Count [5, 12]
|
214
|
-
*/
|
215
|
-
constructor(...args: number[]);
|
216
|
-
hue: number;
|
217
|
-
hueSteps: number;
|
218
|
-
lightSteps: number;
|
219
|
-
colors: any;
|
220
|
-
}
|
221
|
-
}
|
222
|
-
declare module "color-picker/src/js/util/colorPickerLabels" {
|
223
|
-
export default colorPickerLabels;
|
224
|
-
/** @type {Record<string, string>} */
|
225
|
-
const colorPickerLabels: Record<string, string>;
|
226
|
-
}
|
227
|
-
declare module "color-picker/src/js/util/colorNames" {
|
228
|
-
export default colorNames;
|
229
|
-
/**
|
230
|
-
* A list of 17 color names used for WAI-ARIA compliance.
|
231
|
-
* @type {string[]}
|
232
|
-
*/
|
233
|
-
const colorNames: string[];
|
234
|
-
}
|
235
|
-
declare module "color-picker/src/js/util/tabindex" {
|
236
|
-
export default tabIndex;
|
237
|
-
const tabIndex: "tabindex";
|
238
|
-
}
|
239
|
-
declare module "color-picker/src/js/util/isValidJSON" {
|
240
|
-
/**
|
241
|
-
* Check if a string is valid JSON string.
|
242
|
-
* @param {string} str the string input
|
243
|
-
* @returns {boolean} the query result
|
244
|
-
*/
|
245
|
-
export default function isValidJSON(str: string): boolean;
|
246
|
-
}
|
247
|
-
declare module "color-picker/src/js/util/vHidden" {
|
248
|
-
export default vHidden;
|
249
|
-
const vHidden: "v-hidden";
|
250
|
-
}
|
251
|
-
declare module "color-picker/src/js/util/getColorForm" {
|
252
|
-
/**
|
253
|
-
* Returns the color form for `ColorPicker`.
|
254
|
-
*
|
255
|
-
* @param {CP.ColorPicker} self the `ColorPicker` instance
|
256
|
-
* @returns {HTMLElement | Element} a new `<div>` element with color component `<input>`
|
257
|
-
*/
|
258
|
-
export default function getColorForm(self: CP.ColorPicker): HTMLElement | Element;
|
259
|
-
}
|
260
|
-
declare module "color-picker/src/js/util/getColorControls" {
|
261
|
-
/**
|
262
|
-
* Returns all color controls for `ColorPicker`.
|
263
|
-
*
|
264
|
-
* @param {CP.ColorPicker} self the `ColorPicker` instance
|
265
|
-
* @returns {HTMLElement | Element} color controls
|
266
|
-
*/
|
267
|
-
export default function getColorControls(self: CP.ColorPicker): HTMLElement | Element;
|
268
|
-
}
|
269
|
-
declare module "color-picker/src/js/util/setCSSProperties" {
|
270
|
-
/**
|
271
|
-
* Helps setting CSS variables to the color-menu.
|
272
|
-
* @param {HTMLElement} element
|
273
|
-
* @param {Record<string,any>} props
|
274
|
-
*/
|
275
|
-
export default function setCSSProperties(element: HTMLElement, props: Record<string, any>): void;
|
276
|
-
}
|
277
|
-
declare module "color-picker/src/js/util/getColorMenu" {
|
278
|
-
/**
|
279
|
-
* Returns a color-defaults with given values and class.
|
280
|
-
* @param {CP.ColorPicker} self
|
281
|
-
* @param {CP.ColorPalette | string[]} colorsSource
|
282
|
-
* @param {string} menuClass
|
283
|
-
* @returns {HTMLElement | Element}
|
284
|
-
*/
|
285
|
-
export default function getColorMenu(self: CP.ColorPicker, colorsSource: CP.ColorPalette | string[], menuClass: string): HTMLElement | Element;
|
286
|
-
}
|
287
|
-
declare module "color-picker/src/js/util/setMarkup" {
|
288
|
-
/**
|
289
|
-
* Generate HTML markup and update instance properties.
|
290
|
-
* @param {CP.ColorPicker} self
|
291
|
-
*/
|
292
|
-
export default function setMarkup(self: CP.ColorPicker): void;
|
293
|
-
}
|
294
|
-
declare module "color-picker/src/js/util/version" {
|
295
|
-
export default Version;
|
296
|
-
const Version: string;
|
297
|
-
}
|
298
|
-
declare module "color-picker/src/js/color-picker" {
|
299
|
-
/**
|
300
|
-
* Color Picker Web Component
|
301
|
-
* @see http://thednp.github.io/color-picker
|
302
|
-
*/
|
303
|
-
export default class ColorPicker {
|
304
|
-
/**
|
305
|
-
* Returns a new `ColorPicker` instance. The target of this constructor
|
306
|
-
* must be an `HTMLInputElement`.
|
307
|
-
*
|
308
|
-
* @param {HTMLInputElement | string} target the target `<input>` element
|
309
|
-
* @param {CP.ColorPickerOptions=} config instance options
|
310
|
-
*/
|
311
|
-
constructor(target: HTMLInputElement | string, config?: CP.ColorPickerOptions | undefined);
|
312
|
-
input: HTMLInputElement;
|
313
|
-
/** @type {HTMLElement} */
|
314
|
-
parent: HTMLElement;
|
315
|
-
/** @type {number} */
|
316
|
-
id: number;
|
317
|
-
/** @type {HTMLElement?} */
|
318
|
-
dragElement: HTMLElement | null;
|
319
|
-
/** @type {boolean} */
|
320
|
-
isOpen: boolean;
|
321
|
-
/** @type {Record<string, number>} */
|
322
|
-
controlPositions: Record<string, number>;
|
323
|
-
/** @type {Record<string, string>} */
|
324
|
-
colorLabels: Record<string, string>;
|
325
|
-
/** @type {string[]=} */
|
326
|
-
colorKeywords: string[] | undefined;
|
327
|
-
/** @type {(ColorPalette | string[])=} */
|
328
|
-
colorPresets: (ColorPalette | string[]) | undefined;
|
329
|
-
/** @type {Record<string, string>} */
|
330
|
-
componentLabels: Record<string, string>;
|
331
|
-
/** @type {Color} */
|
332
|
-
color: Color;
|
333
|
-
/** @type {CP.ColorFormats} */
|
334
|
-
format: CP.ColorFormats;
|
335
|
-
/** Shows the `ColorPicker` dropdown. */
|
336
|
-
showPicker(): void;
|
337
|
-
/**
|
338
|
-
* Toggle the `ColorPicker` dropdown visibility.
|
339
|
-
* @param {Event=} e
|
340
|
-
* @this {ColorPicker}
|
341
|
-
*/
|
342
|
-
togglePicker(this: ColorPicker, e?: Event | undefined): void;
|
343
|
-
/**
|
344
|
-
* Toggles the visibility of the `ColorPicker` presets menu.
|
345
|
-
* @param {Event=} e
|
346
|
-
* @this {ColorPicker}
|
347
|
-
*/
|
348
|
-
toggleMenu(this: ColorPicker, e?: Event | undefined): void;
|
349
|
-
/**
|
350
|
-
* The `ColorPicker` click event listener for the colour menu presets / defaults.
|
351
|
-
* @param {Event} e
|
352
|
-
* @this {ColorPicker}
|
353
|
-
*/
|
354
|
-
menuClickHandler(this: ColorPicker, e: Event): void;
|
355
|
-
/**
|
356
|
-
* The `ColorPicker` keyboard event listener for menu navigation.
|
357
|
-
* @param {KeyboardEvent} e
|
358
|
-
* @this {ColorPicker}
|
359
|
-
*/
|
360
|
-
menuKeyHandler(this: ColorPicker, e: KeyboardEvent): void;
|
361
|
-
/**
|
362
|
-
* The `ColorPicker` *touchstart* / *mousedown* events listener for control knobs.
|
363
|
-
* @param {PointerEvent} e
|
364
|
-
* @this {ColorPicker}
|
365
|
-
*/
|
366
|
-
pointerDown(this: ColorPicker, e: PointerEvent): void;
|
367
|
-
/**
|
368
|
-
* The `ColorPicker` *touchmove* / *mousemove* events listener for control knobs.
|
369
|
-
* @param {PointerEvent} e
|
370
|
-
*/
|
371
|
-
pointerMove(e: PointerEvent): void;
|
372
|
-
/**
|
373
|
-
* The `ColorPicker` *touchend* / *mouseup* events listener for control knobs.
|
374
|
-
* @param {PointerEvent} e
|
375
|
-
* @this {ColorPicker}
|
376
|
-
*/
|
377
|
-
pointerUp(this: ColorPicker, { target }: PointerEvent): void;
|
378
|
-
/**
|
379
|
-
* Updates `ColorPicker` control positions on:
|
380
|
-
* * initialization
|
381
|
-
* * window resize
|
382
|
-
*/
|
383
|
-
update(): void;
|
384
|
-
/**
|
385
|
-
* The `ColorPicker` *scroll* event listener when open.
|
386
|
-
* @param {Event} e
|
387
|
-
* @this {ColorPicker}
|
388
|
-
*/
|
389
|
-
handleScroll(this: ColorPicker, e: Event): void;
|
390
|
-
/**
|
391
|
-
* The `ColorPicker` *focusout* event listener when open.
|
392
|
-
* @param {FocusEvent} e
|
393
|
-
* @this {ColorPicker}
|
394
|
-
*/
|
395
|
-
handleFocusOut(this: ColorPicker, { relatedTarget }: FocusEvent): void;
|
396
|
-
/** The event listener of the colour form inputs. */
|
397
|
-
changeHandler(): void;
|
398
|
-
/**
|
399
|
-
* The `ColorPicker` *keyup* event listener when open.
|
400
|
-
* @param {KeyboardEvent} e
|
401
|
-
* @this {ColorPicker}
|
402
|
-
*/
|
403
|
-
handleDismiss(this: ColorPicker, { code }: KeyboardEvent): void;
|
404
|
-
/**
|
405
|
-
* The `ColorPicker` *keydown* event listener for control knobs.
|
406
|
-
* @param {KeyboardEvent} e
|
407
|
-
*/
|
408
|
-
handleKnobs(e: KeyboardEvent): void;
|
409
|
-
/** @type {HTMLElement} */
|
410
|
-
pickerToggle: HTMLElement;
|
411
|
-
/** @type {HTMLElement} */
|
412
|
-
menuToggle: HTMLElement;
|
413
|
-
/** @type {HTMLElement} */
|
414
|
-
colorPicker: HTMLElement;
|
415
|
-
/** @type {HTMLElement} */
|
416
|
-
colorMenu: HTMLElement;
|
417
|
-
/** @type {HTMLInputElement[]} */
|
418
|
-
inputs: HTMLInputElement[];
|
419
|
-
controls: any;
|
420
|
-
/** @type {(HTMLElement | Element)[]} */
|
421
|
-
controlKnobs: (HTMLElement | Element)[];
|
422
|
-
/** @type {(HTMLElement)[]} */
|
423
|
-
visuals: (HTMLElement)[];
|
424
|
-
/**
|
425
|
-
* Sets a new colour value.
|
426
|
-
* @param {string} v new colour value
|
427
|
-
*/
|
428
|
-
set value(arg: string);
|
429
|
-
/** Returns the current colour value */
|
430
|
-
get value(): string;
|
431
|
-
/** Check if the colour presets include any non-colour. */
|
432
|
-
get hasNonColor(): boolean;
|
433
|
-
/** Check if the parent of the target is a `ColorPickerElement` instance. */
|
434
|
-
get isCE(): boolean;
|
435
|
-
/** Returns hexadecimal value of the current colour. */
|
436
|
-
get hex(): string;
|
437
|
-
/** Returns the current colour value in {h,s,v,a} object format. */
|
438
|
-
get hsv(): CP.HSVA;
|
439
|
-
/** Returns the current colour value in {h,s,l,a} object format. */
|
440
|
-
get hsl(): CP.HSLA;
|
441
|
-
/** Returns the current colour value in {h,w,b,a} object format. */
|
442
|
-
get hwb(): CP.HWBA;
|
443
|
-
/** Returns the current colour value in {r,g,b,a} object format. */
|
444
|
-
get rgb(): CP.RGBA;
|
445
|
-
/** Returns the current colour brightness. */
|
446
|
-
get brightness(): number;
|
447
|
-
/** Returns the current colour luminance. */
|
448
|
-
get luminance(): number;
|
449
|
-
/** Checks if the current colour requires a light text colour. */
|
450
|
-
get isDark(): boolean;
|
451
|
-
/** Checks if the current input value is a valid colour. */
|
452
|
-
get isValid(): boolean;
|
453
|
-
/** Returns the colour appearance, usually the closest colour name for the current value. */
|
454
|
-
get appearance(): string | undefined;
|
455
|
-
/** Updates `ColorPicker` visuals. */
|
456
|
-
updateVisuals(): void;
|
457
|
-
/**
|
458
|
-
* Updates `ColorPicker` first control:
|
459
|
-
* * `lightness` and `saturation` for HEX/RGB;
|
460
|
-
* * `lightness` and `hue` for HSL.
|
461
|
-
*
|
462
|
-
* @param {number} X the X component of the offset
|
463
|
-
* @param {number} Y the Y component of the offset
|
464
|
-
*/
|
465
|
-
changeControl1(X: number, Y: number): void;
|
466
|
-
/**
|
467
|
-
* Updates `ColorPicker` second control:
|
468
|
-
* * `hue` for HEX/RGB/HWB;
|
469
|
-
* * `saturation` for HSL.
|
470
|
-
*
|
471
|
-
* @param {number} Y the Y offset
|
472
|
-
*/
|
473
|
-
changeControl2(Y: number): void;
|
474
|
-
/**
|
475
|
-
* Updates `ColorPicker` last control,
|
476
|
-
* the `alpha` channel.
|
477
|
-
*
|
478
|
-
* @param {number} Y
|
479
|
-
*/
|
480
|
-
changeAlpha(Y: number): void;
|
481
|
-
/** Updates the open dropdown position on *scroll* event. */
|
482
|
-
updateDropdownPosition(): void;
|
483
|
-
/** Updates control knobs' positions. */
|
484
|
-
setControlPositions(): void;
|
485
|
-
/** Update the visual appearance label and control knob labels. */
|
486
|
-
updateAppearance(): void;
|
487
|
-
/** Updates the control knobs actual positions. */
|
488
|
-
updateControls(): void;
|
489
|
-
/**
|
490
|
-
* Updates all color form inputs.
|
491
|
-
* @param {boolean=} isPrevented when `true`, the component original event is prevented
|
492
|
-
*/
|
493
|
-
updateInputs(isPrevented?: boolean | undefined): void;
|
494
|
-
/**
|
495
|
-
* Hides the currently open `ColorPicker` dropdown.
|
496
|
-
* @param {boolean=} focusPrevented
|
497
|
-
*/
|
498
|
-
hide(focusPrevented?: boolean | undefined): void;
|
499
|
-
/** Removes `ColorPicker` from target `<input>`. */
|
500
|
-
dispose(): void;
|
501
|
-
}
|
502
|
-
import ColorPalette from "color-picker/src/js/color-palette";
|
503
|
-
import Color from "color-picker/src/js/color";
|
504
|
-
}
|
505
|
-
declare module "color-picker/src/js/util/toggleCEAttr" {
|
506
|
-
/**
|
507
|
-
* A small utility to toggle `ColorPickerElement` attributes
|
508
|
-
* when `connectedCallback` or `disconnectedCallback` methods
|
509
|
-
* are called and helps the instance keep its value and settings instact.
|
510
|
-
*
|
511
|
-
* @param {CP.ColorPickerElement} self ColorPickerElement instance
|
512
|
-
* @param {Function=} callback when `true`, attributes are added
|
513
|
-
*
|
514
|
-
* @example
|
515
|
-
* const attributes = [
|
516
|
-
* // essentials
|
517
|
-
* 'value', 'format',
|
518
|
-
* // presets menus
|
519
|
-
* 'color-presets', 'color-keywords',
|
520
|
-
* // labels
|
521
|
-
* 'color-labels', 'component-labels',
|
522
|
-
* ];
|
523
|
-
*/
|
524
|
-
export default function toggleCEAttr(self: CP.ColorPickerElement, callback?: Function | undefined): void;
|
525
|
-
}
|
526
|
-
declare module "color-picker/src/js/color-picker-element" {
|
527
|
-
export default ColorPickerElement;
|
528
|
-
/**
|
529
|
-
* `ColorPickerElement` Web Component.
|
530
|
-
* @example
|
531
|
-
* <label for="UNIQUE_ID">Label</label>
|
532
|
-
* <color-picker data-id="UNIQUE_ID" data-value="red" data-format="hex">
|
533
|
-
* </color-picker>
|
534
|
-
* // or
|
535
|
-
* <label for="UNIQUE_ID">Label</label>
|
536
|
-
* <color-picker data-id="UNIQUE_ID" data-value="red" data-format="hex"></color-picker>
|
537
|
-
*/
|
538
|
-
class ColorPickerElement extends HTMLElement {
|
539
|
-
/**
|
540
|
-
* Returns the current color value.
|
541
|
-
* @returns {string | undefined}
|
542
|
-
*/
|
543
|
-
get value(): string | undefined;
|
544
|
-
connectedCallback(): void;
|
545
|
-
/** @type {HTMLInputElement} */
|
546
|
-
input: HTMLInputElement | undefined;
|
547
|
-
colorPicker: ColorPicker | undefined;
|
548
|
-
/** @this {ColorPickerElement} */
|
549
|
-
disconnectedCallback(this: ColorPickerElement): void;
|
550
|
-
}
|
551
|
-
import ColorPicker from "color-picker/src/js/color-picker";
|
552
|
-
}
|
553
|
-
declare module "color-picker/types/source/source" {
|
554
|
-
export { default as Color } from "color-picker/src/js/color";
|
555
|
-
export { default as ColorPalette } from "color-picker/src/js/color-palette";
|
556
|
-
export { default as ColorPicker } from "color-picker/src/js/color-picker";
|
557
|
-
export { default as ColorPickerElement } from "color-picker/src/js/color-picker-element";
|
558
|
-
}
|
package/types/index.d.ts
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
export as namespace CP;
|
2
|
-
export {Color, ColorPicker, ColorPalette, ColorPickerElement};
|
3
|
-
|
4
|
-
export {
|
5
|
-
HSL,
|
6
|
-
HSLA,
|
7
|
-
RGB,
|
8
|
-
RGBA,
|
9
|
-
HSV,
|
10
|
-
HSVA,
|
11
|
-
HWB,
|
12
|
-
HWBA,
|
13
|
-
ColorPickerOptions,
|
14
|
-
ColorObject,
|
15
|
-
ColorFormats,
|
16
|
-
ColorInput,
|
17
|
-
GetInstance,
|
18
|
-
InitCallback,
|
19
|
-
} from './source/types';
|
20
|
-
|
21
|
-
import { default as Color } from "color-picker/src/js/color";
|
22
|
-
import { default as ColorPalette } from "color-picker/src/js/color-palette";
|
23
|
-
import { default as ColorPicker } from "color-picker/src/js/color-picker";
|
24
|
-
import { default as ColorPickerElement } from "color-picker/src/js/color-picker-element";
|
25
|
-
|
26
|
-
declare module "@thednp/color-picker" {
|
27
|
-
export default ColorPicker;
|
28
|
-
}
|
29
|
-
|
30
|
-
declare module "@thednp/color-picker/src/js/color" {
|
31
|
-
export default Color;
|
32
|
-
}
|
33
|
-
|
34
|
-
declare module "@thednp/color-picker/src/js/color-palette" {
|
35
|
-
export default ColorPalette;
|
36
|
-
}
|
37
|
-
|
38
|
-
declare module "@thednp/color-picker/src/js/color-picker" {
|
39
|
-
export default ColorPicker;
|
40
|
-
}
|
41
|
-
|
42
|
-
declare module "@thednp/color-picker/src/js/color-picker-element" {
|
43
|
-
export default ColorPickerElement;
|
44
|
-
}
|
package/types/source/source.ts
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
export { default as Color } from "../../src/js/color";
|
2
|
-
export { default as ColorPalette } from "../../src/js/color-palette";
|
3
|
-
export { default as ColorPicker } from "../../src/js/color-picker";
|
4
|
-
export { default as ColorPickerElement } from "../../src/js/color-picker-element";
|
package/types/source/types.d.ts
DELETED
@@ -1,92 +0,0 @@
|
|
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;
|
36
|
-
s: number;
|
37
|
-
l: number;
|
38
|
-
}
|
39
|
-
|
40
|
-
export interface HSLA extends HSL {
|
41
|
-
a: number;
|
42
|
-
}
|
43
|
-
|
44
|
-
/**
|
45
|
-
* The HSV, or HSB, model describes colors in terms of
|
46
|
-
* hue, saturation, and value (brightness).
|
47
|
-
* @link https://en.wikibooks.org/wiki/Color_Models:_RGB,_HSV,_HSL#HSV
|
48
|
-
*/
|
49
|
-
export interface HSV {
|
50
|
-
h: number;
|
51
|
-
s: number;
|
52
|
-
v: number;
|
53
|
-
}
|
54
|
-
|
55
|
-
export interface HSVA extends HSV {
|
56
|
-
a: number;
|
57
|
-
}
|
58
|
-
|
59
|
-
/**
|
60
|
-
* The HWB model describes colors in terms of
|
61
|
-
* hue, whiteness, and blackness.
|
62
|
-
* @link https://www.w3.org/TR/css-color-4/#hwb-to-rgb
|
63
|
-
* @link http://alvyray.com/Papers/CG/hwb2rgb.htm
|
64
|
-
*/
|
65
|
-
export interface HWB {
|
66
|
-
h: number;
|
67
|
-
w: number;
|
68
|
-
b: number;
|
69
|
-
}
|
70
|
-
|
71
|
-
export interface HWBA extends HWB {
|
72
|
-
a: number;
|
73
|
-
}
|
74
|
-
|
75
|
-
export interface ColorPickerOptions {
|
76
|
-
colorLabels?: string[];
|
77
|
-
componentLabels?: Record<string, string>;
|
78
|
-
format?: ColorFormats;
|
79
|
-
colorPresets?: string[] | {
|
80
|
-
hue: number,
|
81
|
-
lightSteps: number,
|
82
|
-
hueSteps: number,
|
83
|
-
colors: string[],
|
84
|
-
};
|
85
|
-
colorKeywords?: string[];
|
86
|
-
}
|
87
|
-
|
88
|
-
export type ColorInput = string | RGB | RGBA | HSL | HSLA | HSV | HSVA | HWB | ColorObject;
|
89
|
-
export type ColorFormats = string | 'rgb' | 'hex' | 'hex3' | 'hex4' | 'hex6' | 'hex8' | 'hsl' | 'hsv' | 'hwb';
|
90
|
-
|
91
|
-
export type GetInstance<T, ET> = (target: ET | string, component: string) => T | null;
|
92
|
-
export type InitCallback<T> = (element: HTMLInputElement | string ) => T;
|