@skyux/colorpicker 5.5.0 → 5.6.2
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/bundles/skyux-colorpicker.umd.js +391 -392
- package/documentation.json +88 -110
- package/esm2015/lib/modules/colorpicker/colorpicker-input.directive.js +9 -9
- package/esm2015/lib/modules/colorpicker/colorpicker-input.directive.js.map +1 -1
- package/esm2015/lib/modules/colorpicker/colorpicker-slider.directive.js +5 -5
- package/esm2015/lib/modules/colorpicker/colorpicker-slider.directive.js.map +1 -1
- package/esm2015/lib/modules/colorpicker/colorpicker-text.directive.js +3 -3
- package/esm2015/lib/modules/colorpicker/colorpicker-text.directive.js.map +1 -1
- package/esm2015/lib/modules/colorpicker/colorpicker.component.js +13 -13
- package/esm2015/lib/modules/colorpicker/colorpicker.component.js.map +1 -1
- package/esm2015/lib/modules/colorpicker/colorpicker.module.js +1 -1
- package/esm2015/lib/modules/colorpicker/colorpicker.module.js.map +1 -1
- package/esm2015/lib/modules/colorpicker/colorpicker.service.js +22 -24
- package/esm2015/lib/modules/colorpicker/colorpicker.service.js.map +1 -1
- package/esm2015/lib/modules/colorpicker/types/colorpicker-result.js.map +1 -1
- package/esm2015/lib/modules/shared/sky-colorpicker-resources.module.js +2 -2
- package/esm2015/lib/modules/shared/sky-colorpicker-resources.module.js.map +1 -1
- package/esm2015/testing/colorpicker-fixture.js.map +1 -1
- package/fesm2015/skyux-colorpicker-testing.js.map +1 -1
- package/fesm2015/skyux-colorpicker.js +86 -88
- package/fesm2015/skyux-colorpicker.js.map +1 -1
- package/lib/modules/colorpicker/colorpicker-input.directive.d.ts +1 -1
- package/lib/modules/colorpicker/colorpicker.component.d.ts +4 -4
- package/lib/modules/colorpicker/colorpicker.service.d.ts +1 -2
- package/package.json +16 -14
|
@@ -12,9 +12,9 @@ import * as i4 from '@skyux/indicators';
|
|
|
12
12
|
import { SkyIconModule } from '@skyux/indicators';
|
|
13
13
|
import * as i3 from '@skyux/theme';
|
|
14
14
|
import { SkyThemeModule } from '@skyux/theme';
|
|
15
|
+
import { NG_VALUE_ACCESSOR, NG_VALIDATORS, NgControl } from '@angular/forms';
|
|
15
16
|
import { Subject, fromEvent } from 'rxjs';
|
|
16
17
|
import { takeUntil } from 'rxjs/operators';
|
|
17
|
-
import { NG_VALUE_ACCESSOR, NG_VALIDATORS, NgControl } from '@angular/forms';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* NOTICE: DO NOT MODIFY THIS FILE!
|
|
@@ -82,41 +82,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
82
82
|
}]
|
|
83
83
|
}] });
|
|
84
84
|
|
|
85
|
+
// spell-checker:ignore colorpicker
|
|
85
86
|
/**
|
|
86
|
-
*
|
|
87
|
+
* @internal
|
|
87
88
|
*/
|
|
88
|
-
|
|
89
|
-
(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
89
|
+
class SliderPosition {
|
|
90
|
+
constructor(hue, saturation, value, alpha) {
|
|
91
|
+
this.hue = hue;
|
|
92
|
+
this.saturation = saturation;
|
|
93
|
+
this.value = value;
|
|
94
|
+
this.alpha = alpha;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
class SliderDimension {
|
|
101
|
+
constructor(hue, saturation, value, alpha) {
|
|
102
|
+
this.hue = hue;
|
|
103
|
+
this.saturation = saturation;
|
|
104
|
+
this.value = value;
|
|
105
|
+
this.alpha = alpha;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
107
108
|
|
|
108
109
|
// spell-checker:ignore hsva, hsla, cmyk, denormalize, colorpicker,Injectable
|
|
109
110
|
/**
|
|
110
111
|
* @internal
|
|
111
112
|
*/
|
|
112
113
|
class SkyColorpickerService {
|
|
113
|
-
constructor() { }
|
|
114
114
|
hsla2hsva(hsla) {
|
|
115
115
|
const alpha = Math.min(hsla.alpha, 1);
|
|
116
116
|
const hue = Math.min(hsla.hue, 1);
|
|
117
117
|
const lightness = Math.min(hsla.lightness, 1);
|
|
118
118
|
const saturation = Math.min(hsla.saturation, 1);
|
|
119
|
-
|
|
119
|
+
const hsva = {
|
|
120
120
|
hue: hue,
|
|
121
121
|
saturation: saturation,
|
|
122
122
|
value: lightness,
|
|
@@ -138,7 +138,7 @@ class SkyColorpickerService {
|
|
|
138
138
|
const hue = hsva.hue;
|
|
139
139
|
const saturation = hsva.saturation;
|
|
140
140
|
const value = hsva.value;
|
|
141
|
-
|
|
141
|
+
const hsla = {
|
|
142
142
|
hue: hue,
|
|
143
143
|
saturation: saturation,
|
|
144
144
|
lightness: value,
|
|
@@ -185,7 +185,7 @@ class SkyColorpickerService {
|
|
|
185
185
|
return hsva;
|
|
186
186
|
}
|
|
187
187
|
rgbaToCmyk(rgba) {
|
|
188
|
-
|
|
188
|
+
const cmyk = { cyan: 0, magenta: 0, yellow: 0, key: 0 };
|
|
189
189
|
const key = 1 - Math.max(rgba.red, rgba.green, rgba.blue);
|
|
190
190
|
if (key === 1) {
|
|
191
191
|
cmyk.key = 1;
|
|
@@ -252,7 +252,7 @@ class SkyColorpickerService {
|
|
|
252
252
|
return rgba;
|
|
253
253
|
}
|
|
254
254
|
stringToHsva(colorString, hex8) {
|
|
255
|
-
|
|
255
|
+
const stringParsers = [
|
|
256
256
|
{
|
|
257
257
|
// tslint:disable max-line-length
|
|
258
258
|
re: /(rgb)a?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*%?,\s*(\d{1,3})\s*%?(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
|
|
@@ -320,12 +320,12 @@ class SkyColorpickerService {
|
|
|
320
320
|
});
|
|
321
321
|
}
|
|
322
322
|
let hsva = undefined;
|
|
323
|
-
for (
|
|
323
|
+
for (const key in stringParsers) {
|
|
324
324
|
/* istanbul ignore else */ /* for in must be filtered by an if */
|
|
325
|
-
if (
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
325
|
+
if (Object.prototype.hasOwnProperty.call(stringParsers, key)) {
|
|
326
|
+
const parser = stringParsers[key];
|
|
327
|
+
const match = parser.re.exec(colorString);
|
|
328
|
+
const color = match && parser.parse(match);
|
|
329
329
|
if (color) {
|
|
330
330
|
if ('red' in color) {
|
|
331
331
|
hsva = this.rgbaToHsva(color);
|
|
@@ -343,35 +343,34 @@ class SkyColorpickerService {
|
|
|
343
343
|
if (['hsla', 'hex', 'cmyk'].indexOf(outputFormat) === -1) {
|
|
344
344
|
outputFormat = 'rgba';
|
|
345
345
|
}
|
|
346
|
-
|
|
346
|
+
const color = {
|
|
347
347
|
hsla: () => {
|
|
348
|
-
|
|
348
|
+
const hsla = this.denormalizeHSLA(this.hsva2hsla(hsva));
|
|
349
349
|
return `hsla(${hsla.hue},${hsla.saturation}%,${hsla.lightness}%,${hsla.alpha})`;
|
|
350
350
|
},
|
|
351
351
|
hex: () => {
|
|
352
352
|
return this.hexText(this.denormalizeRGBA(this.hsvaToRgba(hsva)), allowHex8);
|
|
353
353
|
},
|
|
354
354
|
cmyk: () => {
|
|
355
|
-
|
|
355
|
+
const cmyk = this.denormalizeCMYK(this.rgbaToCmyk(this.hsvaToRgba(hsva)));
|
|
356
356
|
return `cmyk(${cmyk.cyan}%,${cmyk.magenta}%,${cmyk.yellow}%,${cmyk.key}%)`;
|
|
357
357
|
},
|
|
358
358
|
rgba: () => {
|
|
359
|
-
|
|
359
|
+
const rgba = this.denormalizeRGBA(this.hsvaToRgba(hsva));
|
|
360
360
|
return `rgba(${rgba.red},${rgba.green},${rgba.blue},${rgba.alpha})`;
|
|
361
361
|
},
|
|
362
362
|
};
|
|
363
363
|
return color[outputFormat]();
|
|
364
364
|
}
|
|
365
365
|
skyColorpickerOut(color) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
formatColor = {
|
|
366
|
+
const cmykText = this.outputFormat(color, 'cmyk', true);
|
|
367
|
+
const hslaText = this.outputFormat(color, 'hsla', true);
|
|
368
|
+
const rgbaText = this.outputFormat(color, 'rgba', true);
|
|
369
|
+
const rgba = this.hsvaToRgba(color);
|
|
370
|
+
const hsla = this.hsva2hsla(color);
|
|
371
|
+
const cmyk = this.rgbaToCmyk(rgba);
|
|
372
|
+
const hex = this.outputFormat(color, 'hex', false);
|
|
373
|
+
const formatColor = {
|
|
375
374
|
cmykText: cmykText,
|
|
376
375
|
hslaText: hslaText,
|
|
377
376
|
rgbaText: rgbaText,
|
|
@@ -445,31 +444,30 @@ SkyColorpickerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", ve
|
|
|
445
444
|
SkyColorpickerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyColorpickerService });
|
|
446
445
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyColorpickerService, decorators: [{
|
|
447
446
|
type: Injectable
|
|
448
|
-
}]
|
|
447
|
+
}] });
|
|
449
448
|
|
|
450
|
-
// spell-checker:ignore colorpicker
|
|
451
449
|
/**
|
|
452
|
-
*
|
|
453
|
-
*/
|
|
454
|
-
class SliderPosition {
|
|
455
|
-
constructor(hue, saturation, value, alpha) {
|
|
456
|
-
this.hue = hue;
|
|
457
|
-
this.saturation = saturation;
|
|
458
|
-
this.value = value;
|
|
459
|
-
this.alpha = alpha;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* @internal
|
|
450
|
+
* Specifies the commands to provide the colorpicker.
|
|
464
451
|
*/
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
452
|
+
var SkyColorpickerMessageType;
|
|
453
|
+
(function (SkyColorpickerMessageType) {
|
|
454
|
+
/**
|
|
455
|
+
* Opens the colorpicker.
|
|
456
|
+
*/
|
|
457
|
+
SkyColorpickerMessageType[SkyColorpickerMessageType["Open"] = 0] = "Open";
|
|
458
|
+
/**
|
|
459
|
+
* Resets the selection in the colorpicker.
|
|
460
|
+
*/
|
|
461
|
+
SkyColorpickerMessageType[SkyColorpickerMessageType["Reset"] = 1] = "Reset";
|
|
462
|
+
/**
|
|
463
|
+
* Toggles whether to display a reset button beside the colorpicker.
|
|
464
|
+
*/
|
|
465
|
+
SkyColorpickerMessageType[SkyColorpickerMessageType["ToggleResetButton"] = 2] = "ToggleResetButton";
|
|
466
|
+
/**
|
|
467
|
+
* Closes the colorpicker.
|
|
468
|
+
*/
|
|
469
|
+
SkyColorpickerMessageType[SkyColorpickerMessageType["Close"] = 3] = "Close";
|
|
470
|
+
})(SkyColorpickerMessageType || (SkyColorpickerMessageType = {}));
|
|
473
471
|
|
|
474
472
|
// spell-checker:ignore Colorpicker
|
|
475
473
|
/**
|
|
@@ -487,10 +485,10 @@ class SkyColorpickerSliderDirective {
|
|
|
487
485
|
};
|
|
488
486
|
}
|
|
489
487
|
setCursor(event) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
488
|
+
const height = this.el.nativeElement.offsetHeight;
|
|
489
|
+
const width = this.el.nativeElement.offsetWidth;
|
|
490
|
+
const xAxis = Math.max(0, Math.min(this.getX(event), width));
|
|
491
|
+
const yAxis = Math.max(0, Math.min(this.getY(event), height));
|
|
494
492
|
if (this.xAxis !== undefined && this.yAxis !== undefined) {
|
|
495
493
|
this.newColorContrast.emit({
|
|
496
494
|
xCoordinate: xAxis / width,
|
|
@@ -576,8 +574,8 @@ class SkyColorpickerTextDirective {
|
|
|
576
574
|
this.newColorContrast = new EventEmitter();
|
|
577
575
|
}
|
|
578
576
|
changeInput(event) {
|
|
579
|
-
|
|
580
|
-
|
|
577
|
+
const element = event.target;
|
|
578
|
+
const elementValue = parseFloat(element.value);
|
|
581
579
|
if (this.maxRange === undefined) {
|
|
582
580
|
this.newColorContrast.emit({
|
|
583
581
|
color: element.value,
|
|
@@ -796,19 +794,19 @@ class SkyColorpickerComponent {
|
|
|
796
794
|
this.update();
|
|
797
795
|
}
|
|
798
796
|
set red(change) {
|
|
799
|
-
|
|
797
|
+
const rgba = this.service.hsvaToRgba(this.hsva);
|
|
800
798
|
rgba.red = change.colorValue / change.maxRange;
|
|
801
799
|
this.hsva = this.service.rgbaToHsva(rgba);
|
|
802
800
|
this.update();
|
|
803
801
|
}
|
|
804
802
|
set green(change) {
|
|
805
|
-
|
|
803
|
+
const rgba = this.service.hsvaToRgba(this.hsva);
|
|
806
804
|
rgba.green = change.colorValue / change.maxRange;
|
|
807
805
|
this.hsva = this.service.rgbaToHsva(rgba);
|
|
808
806
|
this.update();
|
|
809
807
|
}
|
|
810
808
|
set blue(change) {
|
|
811
|
-
|
|
809
|
+
const rgba = this.service.hsvaToRgba(this.hsva);
|
|
812
810
|
rgba.blue = change.colorValue / change.maxRange;
|
|
813
811
|
this.hsva = this.service.rgbaToHsva(rgba);
|
|
814
812
|
this.update();
|
|
@@ -830,17 +828,17 @@ class SkyColorpickerComponent {
|
|
|
830
828
|
this.update();
|
|
831
829
|
}
|
|
832
830
|
update() {
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
831
|
+
const hsla = this.service.hsva2hsla(this.hsva);
|
|
832
|
+
const dHsla = this.service.denormalizeHSLA(hsla);
|
|
833
|
+
const rgba = this.service.hsvaToRgba(this.hsva);
|
|
834
|
+
const dRgba = this.service.denormalizeRGBA(rgba);
|
|
835
|
+
const hsva = {
|
|
838
836
|
hue: this.hsva.hue,
|
|
839
837
|
saturation: 1,
|
|
840
838
|
value: 1,
|
|
841
839
|
alpha: 1,
|
|
842
840
|
};
|
|
843
|
-
|
|
841
|
+
const hueRgba = this.service.denormalizeRGBA(this.service.hsvaToRgba(hsva));
|
|
844
842
|
this.hslaText = dHsla;
|
|
845
843
|
this.rgbaText = dRgba;
|
|
846
844
|
this.hexText = this.service.hexText(dRgba, this.alphaChannel === 'hex8');
|
|
@@ -1072,10 +1070,11 @@ class SkyColorpickerInputDirective {
|
|
|
1072
1070
|
* levels.
|
|
1073
1071
|
*/
|
|
1074
1072
|
this.allowTransparency = true;
|
|
1075
|
-
|
|
1073
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1076
1074
|
this._onChange = (_) => { };
|
|
1077
|
-
|
|
1075
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1078
1076
|
this._onTouched = () => { };
|
|
1077
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1079
1078
|
this._validatorChange = () => { };
|
|
1080
1079
|
}
|
|
1081
1080
|
/**
|
|
@@ -1177,7 +1176,7 @@ class SkyColorpickerInputDirective {
|
|
|
1177
1176
|
this.skyColorpickerInput.initialColor = value;
|
|
1178
1177
|
}
|
|
1179
1178
|
this.skyColorpickerInput.lastAppliedColor = value;
|
|
1180
|
-
|
|
1179
|
+
const control = this.injector.get(NgControl)
|
|
1181
1180
|
.control;
|
|
1182
1181
|
if (control) {
|
|
1183
1182
|
control.setValue(this.modelValue, { emitEvent: false });
|
|
@@ -1185,7 +1184,7 @@ class SkyColorpickerInputDirective {
|
|
|
1185
1184
|
}
|
|
1186
1185
|
}
|
|
1187
1186
|
validate(control) {
|
|
1188
|
-
|
|
1187
|
+
const value = control.value;
|
|
1189
1188
|
if (!value) {
|
|
1190
1189
|
return;
|
|
1191
1190
|
}
|
|
@@ -1232,9 +1231,8 @@ class SkyColorpickerInputDirective {
|
|
|
1232
1231
|
if (color && typeof color !== 'string') {
|
|
1233
1232
|
return color;
|
|
1234
1233
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
formatColor = this.service.skyColorpickerOut(hsva);
|
|
1234
|
+
const hsva = this.service.stringToHsva(color, this.alphaChannel === 'hex8');
|
|
1235
|
+
const formatColor = this.service.skyColorpickerOut(hsva);
|
|
1238
1236
|
return formatColor;
|
|
1239
1237
|
}
|
|
1240
1238
|
getString(key) {
|