@progress/kendo-angular-inputs 7.5.2 → 8.0.0-dev.202112161434
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/dist/cdn/js/kendo-angular-inputs.js +2 -2
- package/dist/cdn/main.js +1 -1
- package/dist/es/colorpicker/color-contrast-svg.component.js +95 -0
- package/dist/es/colorpicker/color-gradient.component.js +109 -81
- package/dist/es/colorpicker/color-input.component.js +39 -18
- package/dist/es/colorpicker/color-palette.component.js +28 -18
- package/dist/es/colorpicker/colorpicker.component.js +170 -76
- package/dist/es/colorpicker/constants.js +12 -0
- package/dist/es/colorpicker/contrast-validation.component.js +8 -6
- package/dist/es/colorpicker/contrast.component.js +6 -8
- package/dist/es/colorpicker/{models → events}/active-color-click-event.js +0 -0
- package/dist/es/colorpicker/events/cancel-event.js +19 -0
- package/dist/es/colorpicker/events/close-event.js +17 -0
- package/dist/es/colorpicker/{models → events}/kendo-drag-event.js +0 -0
- package/dist/es/colorpicker/events/open-event.js +17 -0
- package/dist/es/colorpicker/events.js +8 -0
- package/dist/es/colorpicker/flatcolorpicker-actions.component.js +50 -0
- package/dist/es/colorpicker/flatcolorpicker-header.component.js +94 -0
- package/dist/es/colorpicker/flatcolorpicker.component.js +553 -0
- package/dist/es/colorpicker/localization/colorgradient-localization.service.js +7 -7
- package/dist/es/colorpicker/localization/colorpalette-localization.service.js +7 -7
- package/dist/es/colorpicker/localization/custom-messages.component.js +1 -1
- package/dist/es/colorpicker/localization/flatcolorpicker-localization.service.js +34 -0
- package/dist/es/colorpicker/localization/localized-colorpicker-messages.directive.js +1 -1
- package/dist/es/colorpicker/localization/messages.js +36 -0
- package/dist/es/colorpicker/models/{color-picker-view.js → actions-layout.js} +0 -0
- package/dist/{es2015/colorpicker/models/color-picker-view.js → es/colorpicker/models/colorpicker-view.js} +0 -0
- package/dist/es/colorpicker/{utils → models}/palette-presets.js +0 -0
- package/dist/es/colorpicker/models.js +1 -2
- package/dist/es/colorpicker/services/flatcolorpicker.service.js +41 -0
- package/dist/es/colorpicker/utils/color-parser.js +18 -5
- package/dist/es/colorpicker/utils/contrast-curve.js +91 -0
- package/dist/es/colorpicker/utils.js +1 -1
- package/dist/es/colorpicker.module.js +9 -1
- package/dist/es/index.js +5 -0
- package/dist/es/main.js +4 -1
- package/dist/es/package-metadata.js +1 -1
- package/dist/es2015/colorpicker/color-contrast-svg.component.d.ts +26 -0
- package/dist/es2015/colorpicker/color-contrast-svg.component.js +97 -0
- package/dist/es2015/colorpicker/color-gradient.component.d.ts +32 -43
- package/dist/es2015/colorpicker/color-gradient.component.js +125 -92
- package/dist/es2015/colorpicker/color-input.component.d.ts +11 -4
- package/dist/es2015/colorpicker/color-input.component.js +52 -32
- package/dist/es2015/colorpicker/color-palette.component.d.ts +8 -3
- package/dist/es2015/colorpicker/color-palette.component.js +28 -18
- package/dist/es2015/colorpicker/colorpicker.component.d.ts +84 -24
- package/dist/es2015/colorpicker/colorpicker.component.js +195 -112
- package/dist/es2015/colorpicker/constants.d.ts +12 -0
- package/dist/es2015/colorpicker/constants.js +12 -0
- package/dist/es2015/colorpicker/contrast-validation.component.d.ts +1 -1
- package/dist/es2015/colorpicker/contrast-validation.component.js +16 -12
- package/dist/es2015/colorpicker/contrast.component.d.ts +1 -3
- package/dist/es2015/colorpicker/contrast.component.js +17 -17
- package/dist/es2015/colorpicker/{models → events}/active-color-click-event.d.ts +0 -0
- package/dist/es2015/colorpicker/{models → events}/active-color-click-event.js +0 -0
- package/dist/es2015/colorpicker/events/cancel-event.d.ts +15 -0
- package/dist/es2015/colorpicker/events/cancel-event.js +14 -0
- package/dist/es2015/colorpicker/events/close-event.d.ts +10 -0
- package/dist/es2015/colorpicker/events/close-event.js +10 -0
- package/dist/es2015/colorpicker/{models → events}/kendo-drag-event.d.ts +0 -0
- package/dist/es2015/colorpicker/{models → events}/kendo-drag-event.js +0 -0
- package/dist/es2015/colorpicker/events/open-event.d.ts +10 -0
- package/dist/es2015/colorpicker/events/open-event.js +10 -0
- package/dist/es2015/colorpicker/events.d.ts +8 -0
- package/dist/es2015/colorpicker/events.js +8 -0
- package/dist/es2015/colorpicker/flatcolorpicker-actions.component.d.ts +18 -0
- package/dist/es2015/colorpicker/flatcolorpicker-actions.component.js +60 -0
- package/dist/es2015/colorpicker/flatcolorpicker-header.component.d.ts +30 -0
- package/dist/es2015/colorpicker/flatcolorpicker-header.component.js +131 -0
- package/dist/es2015/colorpicker/flatcolorpicker.component.d.ts +214 -0
- package/dist/es2015/colorpicker/flatcolorpicker.component.js +593 -0
- package/dist/es2015/colorpicker/localization/colorgradient-localization.service.d.ts +3 -3
- package/dist/es2015/colorpicker/localization/colorgradient-localization.service.js +7 -7
- package/dist/es2015/colorpicker/localization/colorpalette-localization.service.d.ts +3 -3
- package/dist/es2015/colorpicker/localization/colorpalette-localization.service.js +7 -7
- package/dist/es2015/colorpicker/localization/custom-messages.component.js +1 -1
- package/dist/es2015/colorpicker/localization/flatcolorpicker-localization.service.d.ts +14 -0
- package/dist/es2015/colorpicker/localization/flatcolorpicker-localization.service.js +31 -0
- package/dist/es2015/colorpicker/localization/localized-colorpicker-messages.directive.js +1 -1
- package/dist/es2015/colorpicker/localization/messages.d.ts +36 -0
- package/dist/es2015/colorpicker/localization/messages.js +36 -0
- package/dist/es2015/colorpicker/models/actions-layout.d.ts +8 -0
- package/dist/es2015/colorpicker/models/actions-layout.js +4 -0
- package/dist/es2015/colorpicker/models/colorpicker-view.d.ts +8 -0
- package/dist/es2015/colorpicker/models/colorpicker-view.js +4 -0
- package/dist/es2015/colorpicker/models/gradient-settings.d.ts +4 -3
- package/dist/es2015/colorpicker/models/output-format.d.ts +0 -5
- package/dist/es2015/colorpicker/{utils → models}/palette-presets.d.ts +0 -0
- package/dist/es2015/colorpicker/{utils → models}/palette-presets.js +0 -0
- package/dist/es2015/colorpicker/models/palette-settings.d.ts +2 -3
- package/dist/es2015/colorpicker/models/tile-size.d.ts +1 -5
- package/dist/es2015/colorpicker/models.d.ts +10 -10
- package/dist/es2015/colorpicker/models.js +1 -2
- package/dist/es2015/colorpicker/{models/color-picker-view.d.ts → services/flatcolorpicker.service.d.ts} +6 -7
- package/dist/es2015/colorpicker/services/flatcolorpicker.service.js +38 -0
- package/dist/es2015/colorpicker/utils/color-parser.d.ts +8 -2
- package/dist/es2015/colorpicker/utils/color-parser.js +15 -5
- package/dist/es2015/colorpicker/utils/contrast-curve.d.ts +37 -0
- package/dist/es2015/colorpicker/utils/contrast-curve.js +85 -0
- package/dist/es2015/colorpicker/utils.d.ts +1 -1
- package/dist/es2015/colorpicker/utils.js +1 -1
- package/dist/es2015/colorpicker.module.js +9 -1
- package/dist/es2015/index.d.ts +5 -0
- package/dist/es2015/index.js +5 -0
- package/dist/es2015/index.metadata.json +1 -1
- package/dist/es2015/main.d.ts +4 -1
- package/dist/es2015/main.js +4 -1
- package/dist/es2015/package-metadata.js +1 -1
- package/dist/fesm2015/index.js +2207 -1043
- package/dist/fesm5/index.js +2010 -907
- package/dist/npm/colorpicker/color-contrast-svg.component.js +97 -0
- package/dist/npm/colorpicker/color-gradient.component.js +109 -81
- package/dist/npm/colorpicker/color-input.component.js +38 -17
- package/dist/npm/colorpicker/color-palette.component.js +29 -19
- package/dist/npm/colorpicker/colorpicker.component.js +177 -83
- package/dist/npm/colorpicker/constants.js +12 -0
- package/dist/npm/colorpicker/contrast-validation.component.js +8 -6
- package/dist/npm/colorpicker/contrast.component.js +6 -8
- package/dist/npm/colorpicker/{models → events}/active-color-click-event.js +0 -0
- package/dist/npm/colorpicker/events/cancel-event.js +21 -0
- package/dist/npm/colorpicker/events/close-event.js +19 -0
- package/dist/npm/colorpicker/{models → events}/kendo-drag-event.js +0 -0
- package/dist/npm/colorpicker/events/open-event.js +19 -0
- package/dist/npm/colorpicker/events.js +11 -0
- package/dist/npm/colorpicker/flatcolorpicker-actions.component.js +52 -0
- package/dist/npm/colorpicker/flatcolorpicker-header.component.js +96 -0
- package/dist/npm/colorpicker/flatcolorpicker.component.js +555 -0
- package/dist/npm/colorpicker/localization/colorgradient-localization.service.js +7 -7
- package/dist/npm/colorpicker/localization/colorpalette-localization.service.js +7 -7
- package/dist/npm/colorpicker/localization/custom-messages.component.js +1 -1
- package/dist/npm/colorpicker/localization/flatcolorpicker-localization.service.js +36 -0
- package/dist/npm/colorpicker/localization/localized-colorpicker-messages.directive.js +1 -1
- package/dist/npm/colorpicker/localization/messages.js +36 -0
- package/dist/npm/colorpicker/models/{color-picker-view.js → actions-layout.js} +0 -0
- package/dist/npm/colorpicker/models/colorpicker-view.js +6 -0
- package/dist/npm/colorpicker/{utils → models}/palette-presets.js +0 -0
- package/dist/npm/colorpicker/models.js +1 -2
- package/dist/npm/colorpicker/services/flatcolorpicker.service.js +43 -0
- package/dist/npm/colorpicker/utils/color-parser.js +18 -5
- package/dist/npm/colorpicker/utils/contrast-curve.js +93 -0
- package/dist/npm/colorpicker/utils.js +1 -1
- package/dist/npm/colorpicker.module.js +9 -1
- package/dist/npm/index.js +10 -0
- package/dist/npm/main.js +7 -2
- package/dist/npm/package-metadata.js +1 -1
- package/dist/systemjs/kendo-angular-inputs.js +1 -1
- package/package.json +3 -2
- package/dist/es/colorpicker/models/preventable-event.js +0 -29
- package/dist/es2015/colorpicker/models/preventable-event.d.ts +0 -21
- package/dist/es2015/colorpicker/models/preventable-event.js +0 -27
- package/dist/npm/colorpicker/models/preventable-event.js +0 -31
|
@@ -6,16 +6,16 @@ import * as tslib_1 from "tslib";
|
|
|
6
6
|
var ColorGradientComponent_1;
|
|
7
7
|
import { Component, Input, ViewChild, ElementRef, Renderer2, NgZone, Output, EventEmitter, HostBinding, forwardRef, ChangeDetectorRef } from '@angular/core';
|
|
8
8
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { BehaviorSubject, Subject } from 'rxjs';
|
|
10
|
+
import { throttleTime } from 'rxjs/operators';
|
|
11
|
+
import { LocalizationService, L10N_PREFIX } from '@progress/kendo-angular-l10n';
|
|
11
12
|
import { isChanged, isDocumentAvailable, KendoInput } from '@progress/kendo-angular-common';
|
|
12
13
|
import { containsFocus, isUntouched } from '../common/dom-utils';
|
|
14
|
+
import { parseColor, getHSV, getColorFromHSV, getColorFromHue } from './utils';
|
|
15
|
+
import { isPresent, fitIntoBounds } from '../common/utils';
|
|
13
16
|
import { SliderComponent } from '../slider/slider.component';
|
|
14
|
-
import { LocalizationService, L10N_PREFIX } from '@progress/kendo-angular-l10n';
|
|
15
|
-
import { Subject } from 'rxjs';
|
|
16
17
|
import { ColorGradientLocalizationService } from './localization/colorgradient-localization.service';
|
|
17
18
|
import { ColorInputComponent } from './color-input.component';
|
|
18
|
-
import { throttleTime } from 'rxjs/operators';
|
|
19
19
|
import { DEFAULT_GRADIENT_BACKGROUND_COLOR, DEFAULT_OUTPUT_FORMAT, DRAGHANDLE_MOVE_SPEED } from './constants';
|
|
20
20
|
let serial = 0;
|
|
21
21
|
/**
|
|
@@ -29,9 +29,6 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
29
29
|
this.renderer = renderer;
|
|
30
30
|
this.cdr = cdr;
|
|
31
31
|
this.localizationService = localizationService;
|
|
32
|
-
/**
|
|
33
|
-
* @hidden
|
|
34
|
-
*/
|
|
35
32
|
this.hostClasses = true;
|
|
36
33
|
/**
|
|
37
34
|
* @hidden
|
|
@@ -39,18 +36,26 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
39
36
|
this.id = `k-colorgradient-${serial++}`;
|
|
40
37
|
/**
|
|
41
38
|
* Defines whether the alpha slider will be displayed.
|
|
39
|
+
*
|
|
40
|
+
* @default true
|
|
42
41
|
*/
|
|
43
42
|
this.opacity = true;
|
|
44
43
|
/**
|
|
45
44
|
* Sets the disabled state of the ColorGradient.
|
|
45
|
+
*
|
|
46
|
+
* @default false
|
|
46
47
|
*/
|
|
47
48
|
this.disabled = false;
|
|
48
49
|
/**
|
|
49
50
|
* Sets the read-only state of the ColorGradient.
|
|
51
|
+
*
|
|
52
|
+
* @default false
|
|
50
53
|
*/
|
|
51
54
|
this.readonly = false;
|
|
52
55
|
/**
|
|
53
56
|
* Specifies whether the ColorGradient should display a 'Clear color' button.
|
|
57
|
+
*
|
|
58
|
+
* @default false
|
|
54
59
|
*/
|
|
55
60
|
this.clearButton = false;
|
|
56
61
|
/**
|
|
@@ -59,6 +64,16 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
59
64
|
* @default 0
|
|
60
65
|
*/
|
|
61
66
|
this.delay = 0;
|
|
67
|
+
/**
|
|
68
|
+
* Specifies the output format of the ColorGradientComponent.
|
|
69
|
+
* The input value may be in a different format, but it will be parsed into the output `format`
|
|
70
|
+
* after the component processes it.
|
|
71
|
+
*
|
|
72
|
+
* The supported values are:
|
|
73
|
+
* * (Default) `rgba`
|
|
74
|
+
* * `hex`
|
|
75
|
+
*/
|
|
76
|
+
this.format = DEFAULT_OUTPUT_FORMAT;
|
|
62
77
|
/**
|
|
63
78
|
* Fires each time the user selects a new color.
|
|
64
79
|
*/
|
|
@@ -74,17 +89,7 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
74
89
|
* The values are initially set in `ngOnInit` or in `ngOnChanges` and are
|
|
75
90
|
* updated on moving the drag handle or the sliders.
|
|
76
91
|
*/
|
|
77
|
-
this.hsva = {};
|
|
78
|
-
/**
|
|
79
|
-
* Specifies the output format of the ColorGradientComponent.
|
|
80
|
-
* The input value may be in a different format. However, it will be parsed into the output `format`
|
|
81
|
-
* after the component processes it.
|
|
82
|
-
*
|
|
83
|
-
* The supported values are:
|
|
84
|
-
* * (Default) `rgba`
|
|
85
|
-
* * `hex`
|
|
86
|
-
*/
|
|
87
|
-
this.format = DEFAULT_OUTPUT_FORMAT;
|
|
92
|
+
this.hsva = new BehaviorSubject({});
|
|
88
93
|
this._tabindex = 0;
|
|
89
94
|
this.listeners = [];
|
|
90
95
|
this.updateValues = new Subject();
|
|
@@ -94,46 +99,51 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
94
99
|
this.direction = rtl ? 'rtl' : 'ltr';
|
|
95
100
|
});
|
|
96
101
|
}
|
|
97
|
-
/**
|
|
98
|
-
* @hidden
|
|
99
|
-
*/
|
|
100
102
|
get readonlyAttribute() {
|
|
101
103
|
return this.readonly;
|
|
102
104
|
}
|
|
103
|
-
/**
|
|
104
|
-
* @hidden
|
|
105
|
-
*/
|
|
106
105
|
get disabledClass() {
|
|
107
106
|
return this.disabled;
|
|
108
107
|
}
|
|
109
|
-
/**
|
|
110
|
-
* @hidden
|
|
111
|
-
*/
|
|
112
|
-
get hostTabindex() {
|
|
113
|
-
return this.tabindex;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* @hidden
|
|
117
|
-
*/
|
|
118
108
|
get gradientId() {
|
|
119
109
|
return this.id;
|
|
120
110
|
}
|
|
111
|
+
get hostTabindex() {
|
|
112
|
+
return this.tabindex;
|
|
113
|
+
}
|
|
121
114
|
/**
|
|
122
115
|
* Specifies the value of the initially selected color.
|
|
123
116
|
*/
|
|
124
117
|
set value(value) {
|
|
125
|
-
this._value = parseColor(value, this.format);
|
|
118
|
+
this._value = parseColor(value, this.format, this.opacity);
|
|
126
119
|
}
|
|
127
120
|
get value() {
|
|
128
121
|
return this._value;
|
|
129
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Enables the color contrast tool. Accepts the background color that will be compared to the selected value.
|
|
125
|
+
* The tool will calculate the contrast ratio between the two colors.
|
|
126
|
+
*/
|
|
127
|
+
set contrastTool(value) {
|
|
128
|
+
this._contrastTool = parseColor(value, this.format, this.opacity);
|
|
129
|
+
}
|
|
130
|
+
get contrastTool() {
|
|
131
|
+
return this._contrastTool;
|
|
132
|
+
}
|
|
130
133
|
/**
|
|
131
134
|
* Specifies the [tabindex](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) of the component.
|
|
135
|
+
*
|
|
136
|
+
* @default 0
|
|
132
137
|
*/
|
|
133
138
|
set tabindex(value) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
if (isPresent(value)) {
|
|
140
|
+
const tabindex = Number(value);
|
|
141
|
+
this._tabindex = !isNaN(tabindex) ? tabindex : 0;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
// Allows removal of the tabindex attribute
|
|
145
|
+
this._tabindex = value;
|
|
146
|
+
}
|
|
137
147
|
}
|
|
138
148
|
get tabindex() {
|
|
139
149
|
return !this.disabled ? this._tabindex : undefined;
|
|
@@ -152,10 +162,10 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
152
162
|
*/
|
|
153
163
|
get alphaSliderValue() {
|
|
154
164
|
// setting the initial value to undefined to force the slider to recalculate the height of the slider track on the next cdr run
|
|
155
|
-
if (!(isPresent(this.hsva) && isPresent(this.hsva.a))) {
|
|
165
|
+
if (!(isPresent(this.hsva.value) && isPresent(this.hsva.value.a))) {
|
|
156
166
|
return;
|
|
157
167
|
}
|
|
158
|
-
return this.hsva.a * 100;
|
|
168
|
+
return this.hsva.value.a * 100;
|
|
159
169
|
}
|
|
160
170
|
get gradientRect() {
|
|
161
171
|
return this.gradientWrapper.nativeElement.getBoundingClientRect();
|
|
@@ -164,7 +174,7 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
164
174
|
* @hidden
|
|
165
175
|
*/
|
|
166
176
|
get contrastToolVisible() {
|
|
167
|
-
return
|
|
177
|
+
return this.contrastTool && this.contrastTool.length > 0;
|
|
168
178
|
}
|
|
169
179
|
ngAfterViewInit() {
|
|
170
180
|
this.updateUI();
|
|
@@ -195,7 +205,7 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
195
205
|
if (this.disabled) {
|
|
196
206
|
return;
|
|
197
207
|
}
|
|
198
|
-
this.
|
|
208
|
+
this.gradientDragHandle.nativeElement.focus();
|
|
199
209
|
}
|
|
200
210
|
/**
|
|
201
211
|
* @hidden
|
|
@@ -233,7 +243,7 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
233
243
|
return;
|
|
234
244
|
}
|
|
235
245
|
this.renderer.removeClass(this.gradientWrapper.nativeElement, 'k-dragging');
|
|
236
|
-
this.handleValueChange(getColorFromHSV(this.hsva));
|
|
246
|
+
this.handleValueChange(getColorFromHSV(this.hsva.value, this.format, this.opacity));
|
|
237
247
|
}
|
|
238
248
|
/**
|
|
239
249
|
* @hidden
|
|
@@ -278,15 +288,19 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
278
288
|
return;
|
|
279
289
|
}
|
|
280
290
|
this.gradientDragHandle.nativeElement.focus();
|
|
281
|
-
const
|
|
282
|
-
const
|
|
291
|
+
const gradientRect = this.gradientRect;
|
|
292
|
+
const newX = position.clientX - gradientRect.left;
|
|
293
|
+
const newY = position.clientY - gradientRect.top;
|
|
283
294
|
this.ngZone.run(() => this.moveDragHandle(newX, newY));
|
|
284
295
|
}
|
|
285
296
|
/**
|
|
286
297
|
* @hidden
|
|
287
298
|
*/
|
|
288
299
|
handleHueSliderChange(hue) {
|
|
289
|
-
this.
|
|
300
|
+
const hsva = this.hsva.value;
|
|
301
|
+
hsva.h = hue;
|
|
302
|
+
this.hsva.next(hsva);
|
|
303
|
+
this.handleValueChange(getColorFromHSV(this.hsva.value, this.format, this.opacity));
|
|
290
304
|
this.backgroundColor = getColorFromHue(hue);
|
|
291
305
|
this.setAlphaSliderBackground(this.backgroundColor);
|
|
292
306
|
}
|
|
@@ -294,14 +308,16 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
294
308
|
* @hidden
|
|
295
309
|
*/
|
|
296
310
|
handleAlphaSliderChange(alpha) {
|
|
297
|
-
this.hsva.
|
|
298
|
-
|
|
311
|
+
const hsva = this.hsva.value;
|
|
312
|
+
hsva.a = alpha / 100;
|
|
313
|
+
this.hsva.next(hsva);
|
|
314
|
+
this.handleValueChange(getColorFromHSV(this.hsva.value, this.format, this.opacity));
|
|
299
315
|
}
|
|
300
316
|
/**
|
|
301
317
|
* @hidden
|
|
302
318
|
*/
|
|
303
319
|
handleInputsValueChange(color) {
|
|
304
|
-
const parsed = parseColor(color, this.format);
|
|
320
|
+
const parsed = parseColor(color, this.format, this.opacity);
|
|
305
321
|
if (this.value !== parsed) {
|
|
306
322
|
this.handleValueChange(parsed);
|
|
307
323
|
this.updateUI();
|
|
@@ -345,7 +361,7 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
345
361
|
* @hidden
|
|
346
362
|
*/
|
|
347
363
|
get colorGradientHandleAriaLabel() {
|
|
348
|
-
const parsed = parseColor(this.value, this.format);
|
|
364
|
+
const parsed = parseColor(this.value, this.format, this.opacity);
|
|
349
365
|
return `${this.value ? parsed : this.localizationService.get('colorGradientHandle')}`;
|
|
350
366
|
}
|
|
351
367
|
/**
|
|
@@ -368,29 +384,35 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
368
384
|
}
|
|
369
385
|
/**
|
|
370
386
|
* @hidden
|
|
371
|
-
* Used by the
|
|
387
|
+
* Used by the FloatingLabel to determine if the component is empty.
|
|
372
388
|
*/
|
|
373
389
|
isEmpty() {
|
|
374
390
|
return false;
|
|
375
391
|
}
|
|
376
392
|
moveDragHandle(positionX, positionY) {
|
|
377
|
-
const
|
|
378
|
-
const
|
|
393
|
+
const gradientRect = this.gradientRect;
|
|
394
|
+
const gradientRectWidth = gradientRect.width;
|
|
395
|
+
const gradientRectHeight = gradientRect.height;
|
|
396
|
+
const top = fitIntoBounds(positionY, 0, gradientRectHeight);
|
|
397
|
+
const left = fitIntoBounds(positionX, 0, gradientRectWidth);
|
|
379
398
|
this.setDragHandleElementPosition(top, left);
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
this.
|
|
399
|
+
const hsva = this.hsva.value;
|
|
400
|
+
hsva.s = left / gradientRectWidth;
|
|
401
|
+
hsva.v = 1 - top / gradientRectHeight;
|
|
402
|
+
this.hsva.next(hsva);
|
|
403
|
+
this.updateValues.next(getColorFromHSV(this.hsva.value, this.format, this.opacity));
|
|
404
|
+
this.setAlphaSliderBackground(getColorFromHSV(Object.assign({}, this.hsva.value, { a: 1 }), this.format, this.opacity));
|
|
384
405
|
}
|
|
385
406
|
updateUI() {
|
|
386
407
|
if (!isDocumentAvailable()) {
|
|
387
408
|
return;
|
|
388
409
|
}
|
|
389
|
-
this.hsva
|
|
390
|
-
const
|
|
391
|
-
const
|
|
410
|
+
this.hsva.next(this.value ? getHSV(this.value) : { h: 0, s: 0, v: 1, a: 1 });
|
|
411
|
+
const gradientRect = this.gradientRect;
|
|
412
|
+
const top = (1 - this.hsva.value.v) * gradientRect.height;
|
|
413
|
+
const left = this.hsva.value.s * gradientRect.width;
|
|
392
414
|
this.setDragHandleElementPosition(top, left);
|
|
393
|
-
this.backgroundColor = getColorFromHue(this.hsva.h);
|
|
415
|
+
this.backgroundColor = getColorFromHue(this.hsva.value.h);
|
|
394
416
|
this.setAlphaSliderBackground(this.backgroundColor);
|
|
395
417
|
this.setHostElementAriaLabel();
|
|
396
418
|
}
|
|
@@ -416,7 +438,7 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
416
438
|
this.renderer.setStyle(sliderTrack, 'background', `linear-gradient(to top, transparent, ${backgroundColor})`);
|
|
417
439
|
}
|
|
418
440
|
setHostElementAriaLabel() {
|
|
419
|
-
const parsed = parseColor(this.value, this.format);
|
|
441
|
+
const parsed = parseColor(this.value, this.format, this.opacity);
|
|
420
442
|
this.renderer.setAttribute(this.host.nativeElement, 'aria-label', `${this.value ? parsed : this.localizationService.get('colorGradientNoColor')}`);
|
|
421
443
|
}
|
|
422
444
|
addEventListeners() {
|
|
@@ -432,7 +454,7 @@ let ColorGradientComponent = ColorGradientComponent_1 = class ColorGradientCompo
|
|
|
432
454
|
const keyupListener = this.renderer.listen(this.gradientDragHandle.nativeElement, 'keyup', () => {
|
|
433
455
|
this.renderer.removeClass(this.gradientWrapper.nativeElement, 'k-dragging');
|
|
434
456
|
if (!this.readonly && !this.disabled) {
|
|
435
|
-
this.ngZone.run(() => this.handleValueChange(getColorFromHSV(this.hsva)));
|
|
457
|
+
this.ngZone.run(() => this.handleValueChange(getColorFromHSV(this.hsva.value, this.format, this.opacity)));
|
|
436
458
|
}
|
|
437
459
|
});
|
|
438
460
|
const dragHandleFocusInListener = this.renderer.listen(this.gradientDragHandle.nativeElement, 'focusin', () => {
|
|
@@ -469,24 +491,24 @@ tslib_1.__decorate([
|
|
|
469
491
|
tslib_1.__metadata("design:type", Boolean),
|
|
470
492
|
tslib_1.__metadata("design:paramtypes", [])
|
|
471
493
|
], ColorGradientComponent.prototype, "disabledClass", null);
|
|
472
|
-
tslib_1.__decorate([
|
|
473
|
-
HostBinding('attr.tabindex'),
|
|
474
|
-
tslib_1.__metadata("design:type", Number),
|
|
475
|
-
tslib_1.__metadata("design:paramtypes", [])
|
|
476
|
-
], ColorGradientComponent.prototype, "hostTabindex", null);
|
|
477
494
|
tslib_1.__decorate([
|
|
478
495
|
HostBinding('attr.id'),
|
|
479
496
|
tslib_1.__metadata("design:type", String),
|
|
480
497
|
tslib_1.__metadata("design:paramtypes", [])
|
|
481
498
|
], ColorGradientComponent.prototype, "gradientId", null);
|
|
482
|
-
tslib_1.__decorate([
|
|
483
|
-
Input(),
|
|
484
|
-
tslib_1.__metadata("design:type", String)
|
|
485
|
-
], ColorGradientComponent.prototype, "id", void 0);
|
|
486
499
|
tslib_1.__decorate([
|
|
487
500
|
HostBinding('attr.dir'),
|
|
488
501
|
tslib_1.__metadata("design:type", String)
|
|
489
502
|
], ColorGradientComponent.prototype, "direction", void 0);
|
|
503
|
+
tslib_1.__decorate([
|
|
504
|
+
HostBinding('attr.tabindex'),
|
|
505
|
+
tslib_1.__metadata("design:type", Number),
|
|
506
|
+
tslib_1.__metadata("design:paramtypes", [])
|
|
507
|
+
], ColorGradientComponent.prototype, "hostTabindex", null);
|
|
508
|
+
tslib_1.__decorate([
|
|
509
|
+
Input(),
|
|
510
|
+
tslib_1.__metadata("design:type", String)
|
|
511
|
+
], ColorGradientComponent.prototype, "id", void 0);
|
|
490
512
|
tslib_1.__decorate([
|
|
491
513
|
Input(),
|
|
492
514
|
tslib_1.__metadata("design:type", Boolean)
|
|
@@ -514,21 +536,22 @@ tslib_1.__decorate([
|
|
|
514
536
|
], ColorGradientComponent.prototype, "value", null);
|
|
515
537
|
tslib_1.__decorate([
|
|
516
538
|
Input(),
|
|
517
|
-
tslib_1.__metadata("design:type", String)
|
|
518
|
-
|
|
539
|
+
tslib_1.__metadata("design:type", String),
|
|
540
|
+
tslib_1.__metadata("design:paramtypes", [String])
|
|
541
|
+
], ColorGradientComponent.prototype, "contrastTool", null);
|
|
519
542
|
tslib_1.__decorate([
|
|
520
543
|
Input(),
|
|
521
544
|
tslib_1.__metadata("design:type", Number),
|
|
522
545
|
tslib_1.__metadata("design:paramtypes", [Number])
|
|
523
546
|
], ColorGradientComponent.prototype, "tabindex", null);
|
|
524
|
-
tslib_1.__decorate([
|
|
525
|
-
Output(),
|
|
526
|
-
tslib_1.__metadata("design:type", EventEmitter)
|
|
527
|
-
], ColorGradientComponent.prototype, "valueChange", void 0);
|
|
528
547
|
tslib_1.__decorate([
|
|
529
548
|
Input(),
|
|
530
549
|
tslib_1.__metadata("design:type", String)
|
|
531
550
|
], ColorGradientComponent.prototype, "format", void 0);
|
|
551
|
+
tslib_1.__decorate([
|
|
552
|
+
Output(),
|
|
553
|
+
tslib_1.__metadata("design:type", EventEmitter)
|
|
554
|
+
], ColorGradientComponent.prototype, "valueChange", void 0);
|
|
532
555
|
tslib_1.__decorate([
|
|
533
556
|
ViewChild('gradientDragHandle', { read: ElementRef, static: false }),
|
|
534
557
|
tslib_1.__metadata("design:type", ElementRef)
|
|
@@ -547,6 +570,7 @@ tslib_1.__decorate([
|
|
|
547
570
|
], ColorGradientComponent.prototype, "gradientWrapper", void 0);
|
|
548
571
|
ColorGradientComponent = ColorGradientComponent_1 = tslib_1.__decorate([
|
|
549
572
|
Component({
|
|
573
|
+
exportAs: 'kendoColorGradient',
|
|
550
574
|
selector: 'kendo-colorgradient',
|
|
551
575
|
providers: [
|
|
552
576
|
{
|
|
@@ -580,22 +604,14 @@ ColorGradientComponent = ColorGradientComponent_1 = tslib_1.__decorate([
|
|
|
580
604
|
hueSliderHandle="Set hue"
|
|
581
605
|
i18n-opacitySliderHandle="kendo.colorgradient.opacitySliderHandle|The title for the opacity slider handle."
|
|
582
606
|
opacitySliderHandle="Set opacity"
|
|
583
|
-
i18n-hexInputPlaceholder="kendo.colorgradient.hexInputPlaceholder|The placeholder for the HEX color input."
|
|
584
|
-
hexInputPlaceholder="HEX Color"
|
|
585
|
-
i18n-redInputPlaceholder="kendo.colorgradient.redInputPlaceholder|The placeholder for the red color input."
|
|
586
|
-
redInputPlaceholder="Red"
|
|
587
|
-
i18n-greenInputPlaceholder="kendo.colorgradient.greenInputPlaceholder|The placeholder for the green color input."
|
|
588
|
-
greenInputPlaceholder="Green"
|
|
589
|
-
i18n-blueInputPlaceholder="kendo.colorgradient.blueInputPlaceholder|The placeholder for the blue color input."
|
|
590
|
-
blueInputPlaceholder="Blue"
|
|
591
|
-
i18n-alphaInputPlaceholder="kendo.colorgradient.alphaInputPlaceholder|The placeholder for the alpha input."
|
|
592
|
-
alphaInputPlaceholder="Alpha"
|
|
593
607
|
i18n-passContrast="kendo.colorgradient.passContrast|The pass message for the contrast tool."
|
|
594
608
|
passContrast="Pass"
|
|
595
609
|
i18n-failContrast="kendo.colorgradient.failContrast|The fail message for the contrast tool."
|
|
596
610
|
failContrast="Fail"
|
|
597
611
|
i18n-contrastRatio="kendo.colorgradient.contrastRatio|The contrast ratio message for the contrast tool."
|
|
598
|
-
contrastRatio="Contrast ratio"
|
|
612
|
+
contrastRatio="Contrast ratio"
|
|
613
|
+
i18n-formatButton="kendo.colorgradient.formatButton|The message for the input format toggle button."
|
|
614
|
+
formatButton="Change color format">
|
|
599
615
|
</ng-container>
|
|
600
616
|
<div class="k-colorgradient-canvas k-hstack">
|
|
601
617
|
<div class="k-hsv-rectangle" [style.background]="backgroundColor">
|
|
@@ -616,6 +632,14 @@ ColorGradientComponent = ColorGradientComponent_1 = tslib_1.__decorate([
|
|
|
616
632
|
>
|
|
617
633
|
</div>
|
|
618
634
|
</div>
|
|
635
|
+
<svg kendoColorContrastSvg
|
|
636
|
+
*ngIf="contrastToolVisible && gradientWrapper"
|
|
637
|
+
class="k-color-contrast-svg"
|
|
638
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
639
|
+
[wrapper]="gradientWrapper ? gradientWrapper : undefined"
|
|
640
|
+
[hsva]="hsva"
|
|
641
|
+
[backgroundColor]="contrastTool">
|
|
642
|
+
</svg>
|
|
619
643
|
</div>
|
|
620
644
|
<div class="k-hsv-controls k-hstack {{ clearButton ? 'k-sliders-wrap-clearable' : '' }}">
|
|
621
645
|
<span class="k-clear-color k-button k-flat k-button-icon"
|
|
@@ -641,12 +665,12 @@ ColorGradientComponent = ColorGradientComponent_1 = tslib_1.__decorate([
|
|
|
641
665
|
[max]="360"
|
|
642
666
|
[smallStep]="5"
|
|
643
667
|
[largeStep]="10"
|
|
644
|
-
[
|
|
668
|
+
[value]="hsva.value.h"
|
|
645
669
|
(valueChange)="handleHueSliderChange($event)"
|
|
646
670
|
>
|
|
647
671
|
</kendo-slider>
|
|
648
672
|
<kendo-slider
|
|
649
|
-
*ngIf="opacity
|
|
673
|
+
*ngIf="opacity"
|
|
650
674
|
#alphaSlider
|
|
651
675
|
[ngClass]="{'k-align-self-end': clearButton}"
|
|
652
676
|
class="k-alpha-slider k-colorgradient-slider"
|
|
@@ -684,12 +708,21 @@ ColorGradientComponent = ColorGradientComponent_1 = tslib_1.__decorate([
|
|
|
684
708
|
styles: [`
|
|
685
709
|
.k-clear-color {
|
|
686
710
|
position: absolute;
|
|
711
|
+
top: 0;
|
|
687
712
|
left: 50%;
|
|
688
713
|
transform: translateX(-50%);
|
|
689
714
|
}
|
|
690
|
-
.k-align-self-end {
|
|
715
|
+
.k-colorgradient-slider.k-align-self-end {
|
|
691
716
|
height: 140px;
|
|
692
717
|
}
|
|
718
|
+
|
|
719
|
+
.k-color-contrast-svg {
|
|
720
|
+
position: absolute;
|
|
721
|
+
overflow: visible;
|
|
722
|
+
pointer-events: none;
|
|
723
|
+
left: 0px;
|
|
724
|
+
top: 0px;
|
|
725
|
+
}
|
|
693
726
|
`]
|
|
694
727
|
}),
|
|
695
728
|
tslib_1.__metadata("design:paramtypes", [ElementRef,
|
|
@@ -5,13 +5,18 @@
|
|
|
5
5
|
import { OnChanges, SimpleChanges, EventEmitter, ElementRef, AfterViewInit, Renderer2 } from '@angular/core';
|
|
6
6
|
import { RGBA } from './models';
|
|
7
7
|
import { LocalizationService } from '@progress/kendo-angular-l10n';
|
|
8
|
+
import { NumericTextBoxComponent } from './../numerictextbox/numerictextbox.component';
|
|
8
9
|
/**
|
|
9
10
|
* @hidden
|
|
10
11
|
*/
|
|
11
12
|
export declare class ColorInputComponent implements AfterViewInit, OnChanges {
|
|
12
|
-
private localization;
|
|
13
13
|
private host;
|
|
14
14
|
private renderer;
|
|
15
|
+
private localizationService;
|
|
16
|
+
/**
|
|
17
|
+
* The id of the hex input.
|
|
18
|
+
*/
|
|
19
|
+
focusableId: string;
|
|
15
20
|
/**
|
|
16
21
|
* The color format view.
|
|
17
22
|
*/
|
|
@@ -38,7 +43,9 @@ export declare class ColorInputComponent implements AfterViewInit, OnChanges {
|
|
|
38
43
|
*/
|
|
39
44
|
valueChange: EventEmitter<string>;
|
|
40
45
|
colorInputClass: boolean;
|
|
41
|
-
opacityInput:
|
|
46
|
+
opacityInput: NumericTextBoxComponent;
|
|
47
|
+
hexInput: ElementRef;
|
|
48
|
+
blueInput: ElementRef;
|
|
42
49
|
toggleFormatButton: ElementRef;
|
|
43
50
|
/**
|
|
44
51
|
* The rgba inputs values.
|
|
@@ -54,15 +61,15 @@ export declare class ColorInputComponent implements AfterViewInit, OnChanges {
|
|
|
54
61
|
*/
|
|
55
62
|
private readonly rgbaInputValid;
|
|
56
63
|
private subscriptions;
|
|
57
|
-
constructor(
|
|
64
|
+
constructor(host: ElementRef, renderer: Renderer2, localizationService: LocalizationService);
|
|
58
65
|
ngAfterViewInit(): void;
|
|
59
66
|
ngOnDestroy(): void;
|
|
60
67
|
ngOnChanges(changes: SimpleChanges): void;
|
|
68
|
+
readonly formatButtonTitle: string;
|
|
61
69
|
handleRgbaValueChange(): void;
|
|
62
70
|
handleHexValueChange(hex: string): void;
|
|
63
71
|
handleRgbaInputBlur(): void;
|
|
64
72
|
handleHexInputBlur(): void;
|
|
65
|
-
textFor(key: string): string;
|
|
66
73
|
private toggleFormatView;
|
|
67
74
|
private initDomEvents;
|
|
68
75
|
}
|