@skyux/colorpicker 5.1.2 → 5.5.0

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.
Files changed (93) hide show
  1. package/README.md +6 -4
  2. package/bundles/skyux-colorpicker.umd.js +29 -26
  3. package/documentation.json +123 -32
  4. package/esm2015/index.js +16 -0
  5. package/esm2015/index.js.map +1 -0
  6. package/esm2015/lib/modules/colorpicker/colorpicker-classes.js +24 -0
  7. package/esm2015/lib/modules/colorpicker/colorpicker-classes.js.map +1 -0
  8. package/esm2015/lib/modules/colorpicker/colorpicker-input.directive.js +264 -0
  9. package/esm2015/lib/modules/colorpicker/colorpicker-input.directive.js.map +1 -0
  10. package/esm2015/lib/modules/colorpicker/colorpicker-slider.directive.js +98 -0
  11. package/esm2015/lib/modules/colorpicker/colorpicker-slider.directive.js.map +1 -0
  12. package/esm2015/lib/modules/colorpicker/colorpicker-text.directive.js +51 -0
  13. package/esm2015/lib/modules/colorpicker/colorpicker-text.directive.js.map +1 -0
  14. package/esm2015/{modules → lib/modules}/colorpicker/colorpicker.component.js +7 -6
  15. package/esm2015/lib/modules/colorpicker/colorpicker.component.js.map +1 -0
  16. package/esm2015/lib/modules/colorpicker/colorpicker.module.js +61 -0
  17. package/esm2015/lib/modules/colorpicker/colorpicker.module.js.map +1 -0
  18. package/esm2015/lib/modules/colorpicker/colorpicker.service.js +344 -0
  19. package/esm2015/lib/modules/colorpicker/colorpicker.service.js.map +1 -0
  20. package/esm2015/lib/modules/colorpicker/types/colorpicker-axis.js +2 -0
  21. package/esm2015/lib/modules/colorpicker/types/colorpicker-axis.js.map +1 -0
  22. package/esm2015/lib/modules/colorpicker/types/colorpicker-cmyk.js +2 -0
  23. package/esm2015/lib/modules/colorpicker/types/colorpicker-cmyk.js.map +1 -0
  24. package/esm2015/lib/modules/colorpicker/types/colorpicker-color.js +2 -0
  25. package/esm2015/lib/modules/colorpicker/types/colorpicker-color.js.map +1 -0
  26. package/esm2015/lib/modules/colorpicker/types/colorpicker-hsla.js +2 -0
  27. package/esm2015/lib/modules/colorpicker/types/colorpicker-hsla.js.map +1 -0
  28. package/esm2015/lib/modules/colorpicker/types/colorpicker-hsva.js +2 -0
  29. package/esm2015/lib/modules/colorpicker/types/colorpicker-hsva.js.map +1 -0
  30. package/esm2015/lib/modules/colorpicker/types/colorpicker-message-type.js +23 -0
  31. package/esm2015/lib/modules/colorpicker/types/colorpicker-message-type.js.map +1 -0
  32. package/esm2015/lib/modules/colorpicker/types/colorpicker-message.js +2 -0
  33. package/esm2015/lib/modules/colorpicker/types/colorpicker-message.js.map +1 -0
  34. package/esm2015/lib/modules/colorpicker/types/colorpicker-output.js +2 -0
  35. package/esm2015/lib/modules/colorpicker/types/colorpicker-output.js.map +1 -0
  36. package/esm2015/lib/modules/colorpicker/types/colorpicker-result.js +2 -0
  37. package/esm2015/lib/modules/colorpicker/types/colorpicker-result.js.map +1 -0
  38. package/esm2015/lib/modules/colorpicker/types/colorpicker-rgba.js +2 -0
  39. package/esm2015/lib/modules/colorpicker/types/colorpicker-rgba.js.map +1 -0
  40. package/esm2015/lib/modules/shared/sky-colorpicker-resources.module.js +69 -0
  41. package/esm2015/lib/modules/shared/sky-colorpicker-resources.module.js.map +1 -0
  42. package/esm2015/skyux-colorpicker.js +2 -2
  43. package/esm2015/skyux-colorpicker.js.map +1 -0
  44. package/esm2015/testing/colorpicker-fixture.js +1 -1
  45. package/esm2015/testing/colorpicker-fixture.js.map +1 -0
  46. package/esm2015/testing/public-api.js +1 -1
  47. package/esm2015/testing/public-api.js.map +1 -0
  48. package/esm2015/testing/skyux-colorpicker-testing.js +1 -1
  49. package/esm2015/testing/skyux-colorpicker-testing.js.map +1 -0
  50. package/fesm2015/skyux-colorpicker-testing.js.map +1 -1
  51. package/fesm2015/skyux-colorpicker.js +29 -26
  52. package/fesm2015/skyux-colorpicker.js.map +1 -1
  53. package/index.d.ts +13 -0
  54. package/{modules → lib/modules}/colorpicker/colorpicker-classes.d.ts +0 -0
  55. package/{modules → lib/modules}/colorpicker/colorpicker-input.directive.d.ts +3 -0
  56. package/{modules → lib/modules}/colorpicker/colorpicker-slider.directive.d.ts +0 -0
  57. package/{modules → lib/modules}/colorpicker/colorpicker-text.directive.d.ts +0 -0
  58. package/{modules → lib/modules}/colorpicker/colorpicker.component.d.ts +1 -1
  59. package/{modules → lib/modules}/colorpicker/colorpicker.module.d.ts +0 -0
  60. package/{modules → lib/modules}/colorpicker/colorpicker.service.d.ts +0 -0
  61. package/{modules → lib/modules}/colorpicker/types/colorpicker-axis.d.ts +0 -0
  62. package/{modules → lib/modules}/colorpicker/types/colorpicker-cmyk.d.ts +0 -0
  63. package/{modules → lib/modules}/colorpicker/types/colorpicker-color.d.ts +0 -0
  64. package/{modules → lib/modules}/colorpicker/types/colorpicker-hsla.d.ts +0 -0
  65. package/{modules → lib/modules}/colorpicker/types/colorpicker-hsva.d.ts +0 -0
  66. package/{modules → lib/modules}/colorpicker/types/colorpicker-message-type.d.ts +0 -0
  67. package/{modules → lib/modules}/colorpicker/types/colorpicker-message.d.ts +0 -0
  68. package/{modules → lib/modules}/colorpicker/types/colorpicker-output.d.ts +0 -0
  69. package/{modules → lib/modules}/colorpicker/types/colorpicker-result.d.ts +0 -0
  70. package/{modules → lib/modules}/colorpicker/types/colorpicker-rgba.d.ts +0 -0
  71. package/{modules → lib/modules}/shared/sky-colorpicker-resources.module.d.ts +0 -0
  72. package/package.json +23 -9
  73. package/skyux-colorpicker.d.ts +1 -1
  74. package/LICENSE +0 -21
  75. package/esm2015/modules/colorpicker/colorpicker-classes.js +0 -24
  76. package/esm2015/modules/colorpicker/colorpicker-input.directive.js +0 -258
  77. package/esm2015/modules/colorpicker/colorpicker-slider.directive.js +0 -98
  78. package/esm2015/modules/colorpicker/colorpicker-text.directive.js +0 -51
  79. package/esm2015/modules/colorpicker/colorpicker.module.js +0 -61
  80. package/esm2015/modules/colorpicker/colorpicker.service.js +0 -344
  81. package/esm2015/modules/colorpicker/types/colorpicker-axis.js +0 -2
  82. package/esm2015/modules/colorpicker/types/colorpicker-cmyk.js +0 -2
  83. package/esm2015/modules/colorpicker/types/colorpicker-color.js +0 -2
  84. package/esm2015/modules/colorpicker/types/colorpicker-hsla.js +0 -2
  85. package/esm2015/modules/colorpicker/types/colorpicker-hsva.js +0 -2
  86. package/esm2015/modules/colorpicker/types/colorpicker-message-type.js +0 -23
  87. package/esm2015/modules/colorpicker/types/colorpicker-message.js +0 -2
  88. package/esm2015/modules/colorpicker/types/colorpicker-output.js +0 -2
  89. package/esm2015/modules/colorpicker/types/colorpicker-result.js +0 -2
  90. package/esm2015/modules/colorpicker/types/colorpicker-rgba.js +0 -2
  91. package/esm2015/modules/shared/sky-colorpicker-resources.module.js +0 -69
  92. package/esm2015/public-api.js +0 -16
  93. package/public-api.d.ts +0 -13
@@ -0,0 +1,264 @@
1
+ import { Directive, ElementRef, forwardRef, HostListener, Injector, Input, Renderer2, } from '@angular/core';
2
+ import { NG_VALIDATORS, NG_VALUE_ACCESSOR, NgControl, } from '@angular/forms';
3
+ import { SkyLibResourcesService } from '@skyux/i18n';
4
+ import { SkyColorpickerService } from './colorpicker.service';
5
+ import { SkyColorpickerComponent } from './colorpicker.component';
6
+ import * as i0 from "@angular/core";
7
+ import * as i1 from "./colorpicker.service";
8
+ import * as i2 from "@skyux/i18n";
9
+ // tslint:disable:no-forward-ref no-use-before-declare
10
+ const SKY_COLORPICKER_VALUE_ACCESSOR = {
11
+ provide: NG_VALUE_ACCESSOR,
12
+ useExisting: forwardRef(() => SkyColorpickerInputDirective),
13
+ multi: true,
14
+ };
15
+ const SKY_COLORPICKER_VALIDATOR = {
16
+ provide: NG_VALIDATORS,
17
+ useExisting: forwardRef(() => SkyColorpickerInputDirective),
18
+ multi: true,
19
+ };
20
+ // tslint:enable
21
+ const SKY_COLORPICKER_DEFAULT_COLOR = '#FFFFFF';
22
+ /**
23
+ * Creates the colorpicker element and dropdown.
24
+ */
25
+ export class SkyColorpickerInputDirective {
26
+ constructor(elementRef, renderer, service, resourcesService, injector) {
27
+ this.elementRef = elementRef;
28
+ this.renderer = renderer;
29
+ this.service = service;
30
+ this.resourcesService = resourcesService;
31
+ this.injector = injector;
32
+ /**
33
+ * This property is deprecated and does not affect the colorpicker.
34
+ * We recommend against using it.
35
+ * @deprecated
36
+ * @default "rgba"
37
+ */
38
+ this.returnFormat = 'rgba';
39
+ /**
40
+ * Specifies the format to use for the color when the colorpicker uses a native input
41
+ * element such as a standard text input or a button. This property accepts `rgba`, `hex`,
42
+ * or `hsla`, but we do not recommend using it because users never see or use its value.
43
+ * Instead, if you need to access this format value, see the demo for an example.
44
+ *@default "rgba"
45
+ */
46
+ this.outputFormat = 'rgba';
47
+ /**
48
+ * Specifies an array of colors to load as preset choices. The colorpicker displays the
49
+ * colors in a series of 12 boxes for users to select.
50
+ */
51
+ this.presetColors = ['#333', '#888', '#EFEFEF', '#FFF'];
52
+ /**
53
+ * Specifies the type of transparency to use in the transparency slider.
54
+ *@default "hex6"
55
+ */
56
+ this.alphaChannel = 'hex6';
57
+ /**
58
+ * Indicates whether to display a transparency slider for users to select transparency
59
+ * levels.
60
+ */
61
+ this.allowTransparency = true;
62
+ /*istanbul ignore next */
63
+ this._onChange = (_) => { };
64
+ /*istanbul ignore next */
65
+ this._onTouched = () => { };
66
+ this._validatorChange = () => { };
67
+ }
68
+ /**
69
+ * Specifies an initial color to load in the colorpicker. Use a reactive or
70
+ * template-driven form to set this value. This property is deprecated. As an alternative,
71
+ * we recommend the `formControlName` property on reactive forms or `ngModel` on
72
+ * template-driven forms. See the demo for examples.
73
+ * @deprecated
74
+ */
75
+ set initialColor(value) {
76
+ /* istanbul ignore else */
77
+ if (!this._initialColor && !this.modelValue) {
78
+ this.writeValue(value);
79
+ }
80
+ this._initialColor = value;
81
+ }
82
+ get initialColor() {
83
+ return this._initialColor || SKY_COLORPICKER_DEFAULT_COLOR;
84
+ }
85
+ changeInput(event) {
86
+ const value = event.target.value;
87
+ this.skyColorpickerInput.updatePickerValues(value);
88
+ this.skyColorpickerInput.backgroundColorForDisplay = value;
89
+ }
90
+ onChange(event) {
91
+ const newValue = event.target.value;
92
+ this.modelValue = this.formatter(newValue);
93
+ this._validatorChange();
94
+ this._onChange(this.modelValue);
95
+ this.writeModelValue(this.modelValue);
96
+ }
97
+ /* istanbul ignore next */
98
+ onBlur() {
99
+ /*istanbul ignore next */
100
+ this._onTouched();
101
+ }
102
+ ngOnInit() {
103
+ const element = this.elementRef.nativeElement;
104
+ this.renderer.addClass(element, 'sky-form-control');
105
+ this.skyColorpickerInput.initialColor = this.initialColor;
106
+ this.skyColorpickerInput.returnFormat = this.returnFormat;
107
+ this.pickerChangedSubscription =
108
+ this.skyColorpickerInput.selectedColorChanged.subscribe((newColor) => {
109
+ /* istanbul ignore else */
110
+ if (newColor) {
111
+ this.modelValue = this.formatter(newColor);
112
+ this.writeModelValue(this.modelValue);
113
+ }
114
+ this._onChange(newColor);
115
+ });
116
+ this.skyColorpickerInput.updatePickerValues(this.initialColor);
117
+ /* Sanity check */
118
+ /* istanbul ignore else */
119
+ if (!this._disabled) {
120
+ this.skyColorpickerInput.backgroundColorForDisplay = this.initialColor;
121
+ }
122
+ /// Set aria-label as default, if not set
123
+ if (!element.getAttribute('aria-label')) {
124
+ this.renderer.setAttribute(element, 'aria-label', this.getString('skyux_colorpicker_input_default_label'));
125
+ }
126
+ const typeAttr = element.getAttribute('type');
127
+ if (typeAttr && typeAttr === 'hidden') {
128
+ this.skyColorpickerInput.isVisible = false;
129
+ }
130
+ else {
131
+ this.skyColorpickerInput.isVisible = true;
132
+ }
133
+ element.setAttribute('readonly', 'true');
134
+ this.renderer.addClass(element, 'sky-colorpicker-input');
135
+ }
136
+ ngOnDestroy() {
137
+ this.pickerChangedSubscription.unsubscribe();
138
+ }
139
+ setColorPickerDefaults() {
140
+ this.skyColorpickerInput.setDialog(this, this.elementRef, this.initialColor, this.outputFormat, this.presetColors, this.alphaChannel, this.allowTransparency);
141
+ }
142
+ ngOnChanges() {
143
+ this._validatorChange();
144
+ this.skyColorpickerInput.returnFormat = this.returnFormat;
145
+ this.setColorPickerDefaults();
146
+ }
147
+ registerOnChange(fn) {
148
+ this._onChange = fn;
149
+ }
150
+ registerOnTouched(fn) {
151
+ this._onTouched = fn;
152
+ }
153
+ registerOnValidatorChange(fn) {
154
+ this._validatorChange = fn;
155
+ }
156
+ writeValue(value) {
157
+ if (this.skyColorpickerInput &&
158
+ value &&
159
+ value !== this.skyColorpickerInput.lastAppliedColor) {
160
+ this.modelValue = this.formatter(value);
161
+ this.writeModelValue(this.modelValue);
162
+ if (!this._initialColor) {
163
+ this._initialColor = value;
164
+ this.skyColorpickerInput.initialColor = value;
165
+ }
166
+ this.skyColorpickerInput.lastAppliedColor = value;
167
+ let control = this.injector.get(NgControl)
168
+ .control;
169
+ if (control) {
170
+ control.setValue(this.modelValue, { emitEvent: false });
171
+ }
172
+ }
173
+ }
174
+ validate(control) {
175
+ let value = control.value;
176
+ if (!value) {
177
+ return;
178
+ }
179
+ // Validation
180
+ }
181
+ /**
182
+ * Implemented as part of ControlValueAccessor.
183
+ */
184
+ setDisabledState(isDisabled) {
185
+ this._disabled = isDisabled;
186
+ this.skyColorpickerInput.disabled = isDisabled;
187
+ if (this._disabled) {
188
+ this.skyColorpickerInput.backgroundColorForDisplay = '#fff';
189
+ }
190
+ else {
191
+ this.skyColorpickerInput.backgroundColorForDisplay = this.modelValue.hex;
192
+ }
193
+ }
194
+ writeModelValue(model) {
195
+ const setElementValue = model.rgbaText;
196
+ const element = this.elementRef.nativeElement;
197
+ let output;
198
+ // tslint:disable-next-line:switch-default
199
+ switch (this.outputFormat) {
200
+ case 'rgba':
201
+ output = model.rgbaText;
202
+ break;
203
+ case 'hsla':
204
+ output = model.hslaText;
205
+ break;
206
+ case 'cmyk':
207
+ output = model.cmykText;
208
+ break;
209
+ case 'hex':
210
+ output = model.hex;
211
+ break;
212
+ }
213
+ this.skyColorpickerInput.updatePickerValues(output);
214
+ this.skyColorpickerInput.backgroundColorForDisplay = output;
215
+ this.renderer.setStyle(element, 'background-color', setElementValue);
216
+ this.renderer.setProperty(element, 'value', output);
217
+ }
218
+ formatter(color) {
219
+ if (color && typeof color !== 'string') {
220
+ return color;
221
+ }
222
+ let formatColor;
223
+ let hsva = this.service.stringToHsva(color, this.alphaChannel === 'hex8');
224
+ formatColor = this.service.skyColorpickerOut(hsva);
225
+ return formatColor;
226
+ }
227
+ getString(key) {
228
+ // TODO: Need to implement the async `getString` method in a breaking change.
229
+ return this.resourcesService.getStringForLocale({ locale: 'en-US' }, key);
230
+ }
231
+ }
232
+ SkyColorpickerInputDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyColorpickerInputDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1.SkyColorpickerService }, { token: i2.SkyLibResourcesService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Directive });
233
+ SkyColorpickerInputDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyColorpickerInputDirective, selector: "[skyColorpickerInput]", inputs: { skyColorpickerInput: "skyColorpickerInput", initialColor: "initialColor", returnFormat: "returnFormat", outputFormat: "outputFormat", presetColors: "presetColors", alphaChannel: "alphaChannel", allowTransparency: "allowTransparency" }, host: { listeners: { "input": "changeInput($event)", "change": "onChange($event)", "blur": "onBlur()" } }, providers: [SKY_COLORPICKER_VALUE_ACCESSOR, SKY_COLORPICKER_VALIDATOR], usesOnChanges: true, ngImport: i0 });
234
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyColorpickerInputDirective, decorators: [{
235
+ type: Directive,
236
+ args: [{
237
+ selector: '[skyColorpickerInput]',
238
+ providers: [SKY_COLORPICKER_VALUE_ACCESSOR, SKY_COLORPICKER_VALIDATOR],
239
+ }]
240
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1.SkyColorpickerService }, { type: i2.SkyLibResourcesService }, { type: i0.Injector }]; }, propDecorators: { skyColorpickerInput: [{
241
+ type: Input
242
+ }], initialColor: [{
243
+ type: Input
244
+ }], returnFormat: [{
245
+ type: Input
246
+ }], outputFormat: [{
247
+ type: Input
248
+ }], presetColors: [{
249
+ type: Input
250
+ }], alphaChannel: [{
251
+ type: Input
252
+ }], allowTransparency: [{
253
+ type: Input
254
+ }], changeInput: [{
255
+ type: HostListener,
256
+ args: ['input', ['$event']]
257
+ }], onChange: [{
258
+ type: HostListener,
259
+ args: ['change', ['$event']]
260
+ }], onBlur: [{
261
+ type: HostListener,
262
+ args: ['blur']
263
+ }] } });
264
+ //# sourceMappingURL=colorpicker-input.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorpicker-input.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/colorpicker/src/lib/modules/colorpicker/colorpicker-input.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,KAAK,EAIL,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAGL,aAAa,EACb,iBAAiB,EAEjB,SAAS,GAEV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAIrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;;;;AAMlE,sDAAsD;AACtD,MAAM,8BAA8B,GAAG;IACrC,OAAO,EAAE,iBAAiB;IAC1B,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,4BAA4B,CAAC;IAC3D,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF,MAAM,yBAAyB,GAAG;IAChC,OAAO,EAAE,aAAa;IACtB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAA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QAAQ,EAAE;YACtC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,WAAiC,CAAC;QACtC,IAAI,IAAI,GAAuB,IAAI,CAAC,OAAO,CAAC,YAAY,CACtD,KAAK,EACL,IAAI,CAAC,YAAY,KAAK,MAAM,CAC7B,CAAC;QAEF,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAEnD,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,SAAS,CAAC,GAAW;QAC3B,6EAA6E;QAC7E,OAAO,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5E,CAAC;;0HAzRU,4BAA4B;8GAA5B,4BAA4B,iZAF5B,CAAC,8BAA8B,EAAE,yBAAyB,CAAC;4FAE3D,4BAA4B;kBAJxC,SAAS;mBAAC;oBACT,QAAQ,EAAE,uBAAuB;oBACjC,SAAS,EAAE,CAAC,8BAA8B,EAAE,yBAAyB,CAAC;iBACvE;yNAaQ,mBAAmB;sBADzB,KAAK;gBAWK,YAAY;sBADtB,KAAK;gBAoBC,YAAY;sBADlB,KAAK;gBAWC,YAAY;sBADlB,KAAK;gBAQC,YAAY;sBADlB,KAAK;gBAQC,YAAY;sBADlB,KAAK;gBAQC,iBAAiB;sBADvB,KAAK;gBAgBC,WAAW;sBADjB,YAAY;uBAAC,OAAO,EAAE,CAAC,QAAQ,CAAC;gBAQ1B,QAAQ;sBADd,YAAY;uBAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC;gBAW3B,MAAM;sBADZ,YAAY;uBAAC,MAAM","sourcesContent":["import {\n Directive,\n ElementRef,\n forwardRef,\n HostListener,\n Injector,\n Input,\n OnChanges,\n OnDestroy,\n OnInit,\n Renderer2,\n} from '@angular/core';\n\nimport {\n AbstractControl,\n ControlValueAccessor,\n NG_VALIDATORS,\n NG_VALUE_ACCESSOR,\n Validator,\n NgControl,\n FormControl,\n} from '@angular/forms';\n\nimport { SkyLibResourcesService } from '@skyux/i18n';\n\nimport { Subscription } from 'rxjs';\n\nimport { SkyColorpickerService } from './colorpicker.service';\n\nimport { SkyColorpickerComponent } from './colorpicker.component';\n\nimport { SkyColorpickerHsva } from './types/colorpicker-hsva';\n\nimport { SkyColorpickerOutput } from './types/colorpicker-output';\n\n// tslint:disable:no-forward-ref no-use-before-declare\nconst SKY_COLORPICKER_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => SkyColorpickerInputDirective),\n multi: true,\n};\n\nconst SKY_COLORPICKER_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyColorpickerInputDirective),\n multi: true,\n};\n// tslint:enable\nconst SKY_COLORPICKER_DEFAULT_COLOR = '#FFFFFF';\n\n/**\n * Creates the colorpicker element and dropdown.\n */\n@Directive({\n selector: '[skyColorpickerInput]',\n providers: [SKY_COLORPICKER_VALUE_ACCESSOR, SKY_COLORPICKER_VALIDATOR],\n})\nexport class SkyColorpickerInputDirective\n implements OnInit, OnChanges, ControlValueAccessor, Validator, OnDestroy\n{\n public pickerChangedSubscription: Subscription;\n\n /**\n * Creates the colorpicker element and dropdown. Place this attribute on an `input` element\n * or `button` element, wrap the element in a `sky-colorpicker` component, and set the attribute\n * to the instance of the `sky-colorpicker` component.\n * @required\n */\n @Input()\n public skyColorpickerInput: SkyColorpickerComponent;\n\n /**\n * Specifies an initial color to load in the colorpicker. Use a reactive or\n * template-driven form to set this value. This property is deprecated. As an alternative,\n * we recommend the `formControlName` property on reactive forms or `ngModel` on\n * template-driven forms. See the demo for examples.\n * @deprecated\n */\n @Input()\n public set initialColor(value: string) {\n /* istanbul ignore else */\n if (!this._initialColor && !this.modelValue) {\n this.writeValue(value);\n }\n this._initialColor = value;\n }\n\n public get initialColor(): string {\n return this._initialColor || SKY_COLORPICKER_DEFAULT_COLOR;\n }\n\n /**\n * This property is deprecated and does not affect the colorpicker.\n * We recommend against using it.\n * @deprecated\n * @default \"rgba\"\n */\n @Input()\n public returnFormat = 'rgba';\n\n /**\n * Specifies the format to use for the color when the colorpicker uses a native input\n * element such as a standard text input or a button. This property accepts `rgba`, `hex`,\n * or `hsla`, but we do not recommend using it because users never see or use its value.\n * Instead, if you need to access this format value, see the demo for an example.\n *@default \"rgba\"\n */\n @Input()\n public outputFormat = 'rgba';\n\n /**\n * Specifies an array of colors to load as preset choices. The colorpicker displays the\n * colors in a series of 12 boxes for users to select.\n */\n @Input()\n public presetColors = ['#333', '#888', '#EFEFEF', '#FFF'];\n\n /**\n * Specifies the type of transparency to use in the transparency slider.\n *@default \"hex6\"\n */\n @Input()\n public alphaChannel = 'hex6';\n\n /**\n * Indicates whether to display a transparency slider for users to select transparency\n * levels.\n */\n @Input()\n public allowTransparency = true;\n\n private _disabled: boolean;\n private _initialColor: string;\n private modelValue: SkyColorpickerOutput;\n\n constructor(\n private elementRef: ElementRef,\n private renderer: Renderer2,\n private service: SkyColorpickerService,\n private resourcesService: SkyLibResourcesService,\n private injector: Injector\n ) {}\n\n @HostListener('input', ['$event'])\n public changeInput(event: any) {\n const value = event.target.value;\n this.skyColorpickerInput.updatePickerValues(value);\n this.skyColorpickerInput.backgroundColorForDisplay = value;\n }\n\n @HostListener('change', ['$event'])\n public onChange(event: any) {\n const newValue = event.target.value;\n this.modelValue = this.formatter(newValue);\n this._validatorChange();\n this._onChange(this.modelValue);\n this.writeModelValue(this.modelValue);\n }\n\n /* istanbul ignore next */\n @HostListener('blur')\n public onBlur() {\n /*istanbul ignore next */\n this._onTouched();\n }\n\n public ngOnInit() {\n const element = this.elementRef.nativeElement;\n\n this.renderer.addClass(element, 'sky-form-control');\n this.skyColorpickerInput.initialColor = this.initialColor;\n this.skyColorpickerInput.returnFormat = this.returnFormat;\n\n this.pickerChangedSubscription =\n this.skyColorpickerInput.selectedColorChanged.subscribe(\n (newColor: SkyColorpickerOutput) => {\n /* istanbul ignore else */\n if (newColor) {\n this.modelValue = this.formatter(newColor);\n this.writeModelValue(this.modelValue);\n }\n this._onChange(newColor);\n }\n );\n\n this.skyColorpickerInput.updatePickerValues(this.initialColor);\n\n /* Sanity check */\n /* istanbul ignore else */\n if (!this._disabled) {\n this.skyColorpickerInput.backgroundColorForDisplay = this.initialColor;\n }\n\n /// Set aria-label as default, if not set\n if (!element.getAttribute('aria-label')) {\n this.renderer.setAttribute(\n element,\n 'aria-label',\n this.getString('skyux_colorpicker_input_default_label')\n );\n }\n\n const typeAttr = element.getAttribute('type');\n if (typeAttr && typeAttr === 'hidden') {\n this.skyColorpickerInput.isVisible = false;\n } else {\n this.skyColorpickerInput.isVisible = true;\n }\n\n element.setAttribute('readonly', 'true');\n this.renderer.addClass(element, 'sky-colorpicker-input');\n }\n\n public ngOnDestroy() {\n this.pickerChangedSubscription.unsubscribe();\n }\n\n public setColorPickerDefaults() {\n this.skyColorpickerInput.setDialog(\n this,\n this.elementRef,\n this.initialColor,\n this.outputFormat,\n this.presetColors,\n this.alphaChannel,\n this.allowTransparency\n );\n }\n\n public ngOnChanges(): void {\n this._validatorChange();\n this.skyColorpickerInput.returnFormat = this.returnFormat;\n this.setColorPickerDefaults();\n }\n\n public registerOnChange(fn: (value: any) => any): void {\n this._onChange = fn;\n }\n public registerOnTouched(fn: () => any): void {\n this._onTouched = fn;\n }\n public registerOnValidatorChange(fn: () => void): void {\n this._validatorChange = fn;\n }\n\n public writeValue(value: any) {\n if (\n this.skyColorpickerInput &&\n value &&\n value !== this.skyColorpickerInput.lastAppliedColor\n ) {\n this.modelValue = this.formatter(value);\n this.writeModelValue(this.modelValue);\n\n if (!this._initialColor) {\n this._initialColor = value;\n this.skyColorpickerInput.initialColor = value;\n }\n this.skyColorpickerInput.lastAppliedColor = value;\n let control: FormControl = this.injector.get<NgControl>(NgControl)\n .control as FormControl;\n if (control) {\n control.setValue(this.modelValue, { emitEvent: false });\n }\n }\n }\n\n public validate(control: AbstractControl): { [key: string]: any } {\n let value = control.value;\n if (!value) {\n return;\n }\n // Validation\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public setDisabledState(isDisabled: boolean): void {\n this._disabled = isDisabled;\n this.skyColorpickerInput.disabled = isDisabled;\n if (this._disabled) {\n this.skyColorpickerInput.backgroundColorForDisplay = '#fff';\n } else {\n this.skyColorpickerInput.backgroundColorForDisplay = this.modelValue.hex;\n }\n }\n\n private writeModelValue(model: SkyColorpickerOutput) {\n const setElementValue = model.rgbaText;\n const element = this.elementRef.nativeElement;\n\n let output: string;\n // tslint:disable-next-line:switch-default\n switch (this.outputFormat) {\n case 'rgba':\n output = model.rgbaText;\n break;\n\n case 'hsla':\n output = model.hslaText;\n break;\n\n case 'cmyk':\n output = model.cmykText;\n break;\n\n case 'hex':\n output = model.hex;\n break;\n }\n\n this.skyColorpickerInput.updatePickerValues(output);\n this.skyColorpickerInput.backgroundColorForDisplay = output;\n\n this.renderer.setStyle(element, 'background-color', setElementValue);\n this.renderer.setProperty(element, 'value', output);\n }\n\n private formatter(color: any) {\n if (color && typeof color !== 'string') {\n return color;\n }\n\n let formatColor: SkyColorpickerOutput;\n let hsva: SkyColorpickerHsva = this.service.stringToHsva(\n color,\n this.alphaChannel === 'hex8'\n );\n\n formatColor = this.service.skyColorpickerOut(hsva);\n\n return formatColor;\n }\n\n private getString(key: string): string {\n // TODO: Need to implement the async `getString` method in a breaking change.\n return this.resourcesService.getStringForLocale({ locale: 'en-US' }, key);\n }\n\n /*istanbul ignore next */\n private _onChange = (_: any) => {};\n /*istanbul ignore next */\n private _onTouched = () => {};\n private _validatorChange = () => {};\n}\n"]}
@@ -0,0 +1,98 @@
1
+ // spell-checker:ignore Colorpicker
2
+ import { Directive, Input, Output, ElementRef, EventEmitter, HostListener, } from '@angular/core';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * @internal
6
+ */
7
+ export class SkyColorpickerSliderDirective {
8
+ constructor(el) {
9
+ this.el = el;
10
+ this.newColorContrast = new EventEmitter();
11
+ this.listenerMove = (event) => {
12
+ this.move(event);
13
+ };
14
+ this.listenerStop = () => {
15
+ this.stop();
16
+ };
17
+ }
18
+ setCursor(event) {
19
+ let height = this.el.nativeElement.offsetHeight;
20
+ let width = this.el.nativeElement.offsetWidth;
21
+ let xAxis = Math.max(0, Math.min(this.getX(event), width));
22
+ let yAxis = Math.max(0, Math.min(this.getY(event), height));
23
+ if (this.xAxis !== undefined && this.yAxis !== undefined) {
24
+ this.newColorContrast.emit({
25
+ xCoordinate: xAxis / width,
26
+ yCoordinate: 1 - yAxis / height,
27
+ xAxis: this.xAxis,
28
+ yAxis: this.yAxis,
29
+ });
30
+ }
31
+ else {
32
+ this.newColorContrast.emit({
33
+ xCoordinate: xAxis / width,
34
+ maxRange: this.xAxis,
35
+ });
36
+ }
37
+ /* // No vertical bars
38
+ if (this.xAxis === undefined && this.yAxis !== undefined) {
39
+ this.newColorContrast.emit({ yCoordinate: yAxis / height, maxRange: this.yAxis });
40
+ } */
41
+ }
42
+ move(event) {
43
+ event.preventDefault();
44
+ this.setCursor(event);
45
+ }
46
+ start(event) {
47
+ this.setCursor(event);
48
+ document.addEventListener('mousemove', this.listenerMove);
49
+ document.addEventListener('touchmove', this.listenerMove);
50
+ document.addEventListener('mouseup', this.listenerStop);
51
+ document.addEventListener('touchend', this.listenerStop);
52
+ }
53
+ stop() {
54
+ document.removeEventListener('mousemove', this.listenerMove);
55
+ document.removeEventListener('touchmove', this.listenerMove);
56
+ document.removeEventListener('mouseup', this.listenerStop);
57
+ document.removeEventListener('touchend', this.listenerStop);
58
+ }
59
+ getX(event) {
60
+ /* Ignoring event.touches as tests are not run on a touch device. */
61
+ /* istanbul ignore next */
62
+ return ((event.pageX !== undefined ? event.pageX : event.touches[0].pageX) -
63
+ this.el.nativeElement.getBoundingClientRect().left -
64
+ window.pageXOffset);
65
+ }
66
+ getY(event) {
67
+ /* Ignoring event.touches as tests are not run on a touch device. */
68
+ /* istanbul ignore next */
69
+ return ((event.pageY !== undefined ? event.pageY : event.touches[0].pageY) -
70
+ this.el.nativeElement.getBoundingClientRect().top -
71
+ window.pageYOffset);
72
+ }
73
+ }
74
+ SkyColorpickerSliderDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyColorpickerSliderDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
75
+ SkyColorpickerSliderDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyColorpickerSliderDirective, selector: "[skyColorpickerSlider]", inputs: { skyColorpickerSlider: "skyColorpickerSlider", color: "color", xAxis: "xAxis", yAxis: "yAxis" }, outputs: { newColorContrast: "newColorContrast" }, host: { listeners: { "touchstart": "start($event)", "mousedown": "start($event)" } }, ngImport: i0 });
76
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyColorpickerSliderDirective, decorators: [{
77
+ type: Directive,
78
+ args: [{
79
+ selector: '[skyColorpickerSlider]',
80
+ }]
81
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { newColorContrast: [{
82
+ type: Output
83
+ }], skyColorpickerSlider: [{
84
+ type: Input
85
+ }], color: [{
86
+ type: Input
87
+ }], xAxis: [{
88
+ type: Input
89
+ }], yAxis: [{
90
+ type: Input
91
+ }], start: [{
92
+ type: HostListener,
93
+ args: ['touchstart', ['$event']]
94
+ }, {
95
+ type: HostListener,
96
+ args: ['mousedown', ['$event']]
97
+ }] } });
98
+ //# sourceMappingURL=colorpicker-slider.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorpicker-slider.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/colorpicker/src/lib/modules/colorpicker/colorpicker-slider.directive.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,EACN,UAAU,EACV,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAC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AAM,CAAC,WAAW,CACnB,CAAC;IACJ,CAAC;IACM,IAAI,CAAC,KAAU;QACpB,oEAAoE;QACpE,0BAA0B;QAC1B,OAAO,CACL,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YAClE,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,qBAAqB,EAAE,CAAC,GAAG;YACjD,MAAM,CAAC,WAAW,CACnB,CAAC;IACJ,CAAC;;2HAtFU,6BAA6B;+GAA7B,6BAA6B;4FAA7B,6BAA6B;kBAHzC,SAAS;mBAAC;oBACT,QAAQ,EAAE,wBAAwB;iBACnC;iGAGQ,gBAAgB;sBADtB,MAAM;gBAGA,oBAAoB;sBAD1B,KAAK;gBAGC,KAAK;sBADX,KAAK;gBAGC,KAAK;sBADX,KAAK;gBAGC,KAAK;sBADX,KAAK;gBA6CC,KAAK;sBAFX,YAAY;uBAAC,YAAY,EAAE,CAAC,QAAQ,CAAC;;sBACrC,YAAY;uBAAC,WAAW,EAAE,CAAC,QAAQ,CAAC","sourcesContent":["// spell-checker:ignore Colorpicker\nimport {\n Directive,\n Input,\n Output,\n ElementRef,\n EventEmitter,\n HostListener,\n} from '@angular/core';\n\nimport { SkyColorpickerChangeAxis } from './types/colorpicker-axis';\n\n/**\n * @internal\n */\n@Directive({\n selector: '[skyColorpickerSlider]',\n})\nexport class SkyColorpickerSliderDirective {\n @Output()\n public newColorContrast = new EventEmitter<SkyColorpickerChangeAxis>();\n @Input()\n public skyColorpickerSlider: string;\n @Input()\n public color: string;\n @Input()\n public xAxis: number;\n @Input()\n public yAxis: number;\n\n private listenerMove: any;\n private listenerStop: any;\n\n constructor(private el: ElementRef) {\n this.listenerMove = (event: any) => {\n this.move(event);\n };\n this.listenerStop = () => {\n this.stop();\n };\n }\n\n public setCursor(event: any) {\n let height = this.el.nativeElement.offsetHeight;\n let width = this.el.nativeElement.offsetWidth;\n let xAxis = Math.max(0, Math.min(this.getX(event), width));\n let yAxis = Math.max(0, Math.min(this.getY(event), height));\n if (this.xAxis !== undefined && this.yAxis !== undefined) {\n this.newColorContrast.emit({\n xCoordinate: xAxis / width,\n yCoordinate: 1 - yAxis / height,\n xAxis: this.xAxis,\n yAxis: this.yAxis,\n } as SkyColorpickerChangeAxis);\n } else {\n this.newColorContrast.emit({\n xCoordinate: xAxis / width,\n maxRange: this.xAxis,\n } as SkyColorpickerChangeAxis);\n }\n /* // No vertical bars\n if (this.xAxis === undefined && this.yAxis !== undefined) {\n this.newColorContrast.emit({ yCoordinate: yAxis / height, maxRange: this.yAxis });\n } */\n }\n\n public move(event: any) {\n event.preventDefault();\n this.setCursor(event);\n }\n @HostListener('touchstart', ['$event'])\n @HostListener('mousedown', ['$event'])\n public start(event: MouseEvent) {\n this.setCursor(event);\n document.addEventListener('mousemove', this.listenerMove);\n document.addEventListener('touchmove', this.listenerMove);\n document.addEventListener('mouseup', this.listenerStop);\n document.addEventListener('touchend', this.listenerStop);\n }\n\n public stop() {\n document.removeEventListener('mousemove', this.listenerMove);\n document.removeEventListener('touchmove', this.listenerMove);\n document.removeEventListener('mouseup', this.listenerStop);\n document.removeEventListener('touchend', this.listenerStop);\n }\n\n public getX(event: any): number {\n /* Ignoring event.touches as tests are not run on a touch device. */\n /* istanbul ignore next */\n return (\n (event.pageX !== undefined ? event.pageX : event.touches[0].pageX) -\n this.el.nativeElement.getBoundingClientRect().left -\n window.pageXOffset\n );\n }\n public getY(event: any): number {\n /* Ignoring event.touches as tests are not run on a touch device. */\n /* istanbul ignore next */\n return (\n (event.pageY !== undefined ? event.pageY : event.touches[0].pageY) -\n this.el.nativeElement.getBoundingClientRect().top -\n window.pageYOffset\n );\n }\n}\n"]}
@@ -0,0 +1,51 @@
1
+ // spell-checker:ignore Colorpicker
2
+ import { Directive, Input, Output, EventEmitter, HostListener, } from '@angular/core';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * @internal
6
+ */
7
+ export class SkyColorpickerTextDirective {
8
+ constructor() {
9
+ this.newColorContrast = new EventEmitter();
10
+ }
11
+ changeInput(event) {
12
+ let element = event.target;
13
+ let elementValue = parseFloat(element.value);
14
+ if (this.maxRange === undefined) {
15
+ this.newColorContrast.emit({
16
+ color: element.value,
17
+ colorValue: undefined,
18
+ maxRange: undefined,
19
+ });
20
+ }
21
+ if (!isNaN(elementValue) &&
22
+ elementValue >= 0 &&
23
+ elementValue <= this.maxRange) {
24
+ this.newColorContrast.emit({
25
+ color: this.color,
26
+ colorValue: elementValue,
27
+ maxRange: this.maxRange,
28
+ });
29
+ }
30
+ }
31
+ }
32
+ SkyColorpickerTextDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyColorpickerTextDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
33
+ SkyColorpickerTextDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyColorpickerTextDirective, selector: "[skyColorpickerText]", inputs: { skyColorpickerText: "skyColorpickerText", color: "color", maxRange: "maxRange" }, outputs: { newColorContrast: "newColorContrast" }, host: { listeners: { "input": "changeInput($event)" } }, ngImport: i0 });
34
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyColorpickerTextDirective, decorators: [{
35
+ type: Directive,
36
+ args: [{
37
+ selector: '[skyColorpickerText]',
38
+ }]
39
+ }], propDecorators: { newColorContrast: [{
40
+ type: Output
41
+ }], skyColorpickerText: [{
42
+ type: Input
43
+ }], color: [{
44
+ type: Input
45
+ }], maxRange: [{
46
+ type: Input
47
+ }], changeInput: [{
48
+ type: HostListener,
49
+ args: ['input', ['$event']]
50
+ }] } });
51
+ //# sourceMappingURL=colorpicker-text.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorpicker-text.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/colorpicker/src/lib/modules/colorpicker/colorpicker-text.directive.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAC;;AAIvB;;GAEG;AAIH,MAAM,OAAO,2BAA2B;IAHxC;QAKS,qBAAgB,GAAG,IAAI,YAAY,EAA6B,CAAC;KAgCzE;IAvBQ,WAAW,CAAC,KAAY;QAC7B,IAAI,OAAO,GAAuC,KAAK,CAAC,MAAM,CAAC;QAC/D,IAAI,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC/B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;gBACzB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,SAAS;gBACrB,QAAQ,EAAE,SAAS;aACS,CAAC,CAAC;SACjC;QAED,IACE,CAAC,KAAK,CAAC,YAAY,CAAC;YACpB,YAAY,IAAI,CAAC;YACjB,YAAY,IAAI,IAAI,CAAC,QAAQ,EAC7B;YACA,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;gBACzB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,UAAU,EAAE,YAAY;gBACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACK,CAAC,CAAC;SACjC;IACH,CAAC;;yHAjCU,2BAA2B;6GAA3B,2BAA2B;4FAA3B,2BAA2B;kBAHvC,SAAS;mBAAC;oBACT,QAAQ,EAAE,sBAAsB;iBACjC;8BAGQ,gBAAgB;sBADtB,MAAM;gBAGA,kBAAkB;sBADxB,KAAK;gBAGC,KAAK;sBADX,KAAK;gBAGC,QAAQ;sBADd,KAAK;gBAIC,WAAW;sBADjB,YAAY;uBAAC,OAAO,EAAE,CAAC,QAAQ,CAAC","sourcesContent":["// spell-checker:ignore Colorpicker\nimport {\n Directive,\n Input,\n Output,\n EventEmitter,\n HostListener,\n} from '@angular/core';\n\nimport { SkyColorpickerChangeColor } from './types/colorpicker-color';\n\n/**\n * @internal\n */\n@Directive({\n selector: '[skyColorpickerText]',\n})\nexport class SkyColorpickerTextDirective {\n @Output()\n public newColorContrast = new EventEmitter<SkyColorpickerChangeColor>();\n @Input()\n public skyColorpickerText: any;\n @Input()\n public color: string;\n @Input()\n public maxRange: number;\n\n @HostListener('input', ['$event'])\n public changeInput(event: Event) {\n let element: HTMLInputElement = <HTMLInputElement>event.target;\n let elementValue = parseFloat(element.value);\n if (this.maxRange === undefined) {\n this.newColorContrast.emit({\n color: element.value,\n colorValue: undefined,\n maxRange: undefined,\n } as SkyColorpickerChangeColor);\n }\n\n if (\n !isNaN(elementValue) &&\n elementValue >= 0 &&\n elementValue <= this.maxRange\n ) {\n this.newColorContrast.emit({\n color: this.color,\n colorValue: elementValue,\n maxRange: this.maxRange,\n } as SkyColorpickerChangeColor);\n }\n }\n}\n"]}