@progress/kendo-angular-inputs 7.4.0-dev.202109021544 → 7.5.0-dev.202110261427

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 (60) hide show
  1. package/dist/cdn/js/kendo-angular-inputs.js +2 -2
  2. package/dist/cdn/main.js +1 -1
  3. package/dist/es/colorpicker/color-gradient.component.js +19 -7
  4. package/dist/es/colorpicker/color-input.component.js +36 -8
  5. package/dist/es/colorpicker/color-palette.component.js +13 -11
  6. package/dist/es/colorpicker/constants.js +24 -0
  7. package/dist/es/colorpicker/contrast-validation.component.js +57 -0
  8. package/dist/es/colorpicker/contrast.component.js +72 -0
  9. package/dist/es/colorpicker/localization/messages.js +12 -0
  10. package/dist/es/colorpicker/models/rgb.js +4 -0
  11. package/dist/es/colorpicker/utils/color-parser.js +52 -0
  12. package/dist/es/colorpicker.module.js +5 -1
  13. package/dist/es/index.js +2 -0
  14. package/dist/es/numerictextbox/numerictextbox.component.js +2 -2
  15. package/dist/es/numerictextbox/utils.js +8 -0
  16. package/dist/es/package-metadata.js +1 -1
  17. package/dist/es2015/colorpicker/color-gradient.component.d.ts +9 -0
  18. package/dist/es2015/colorpicker/color-gradient.component.js +46 -15
  19. package/dist/es2015/colorpicker/color-input.component.d.ts +14 -6
  20. package/dist/es2015/colorpicker/color-input.component.js +123 -87
  21. package/dist/es2015/colorpicker/color-palette.component.d.ts +14 -5
  22. package/dist/es2015/colorpicker/color-palette.component.js +19 -16
  23. package/dist/es2015/colorpicker/constants.d.ts +25 -0
  24. package/dist/es2015/colorpicker/constants.js +24 -0
  25. package/dist/es2015/colorpicker/contrast-validation.component.d.ts +18 -0
  26. package/dist/es2015/colorpicker/contrast-validation.component.js +54 -0
  27. package/dist/es2015/colorpicker/contrast.component.d.ts +21 -0
  28. package/dist/es2015/colorpicker/contrast.component.js +72 -0
  29. package/dist/es2015/colorpicker/localization/messages.d.ts +12 -0
  30. package/dist/es2015/colorpicker/localization/messages.js +12 -0
  31. package/dist/es2015/colorpicker/models/rgb.d.ts +12 -0
  32. package/dist/es2015/colorpicker/models/rgb.js +4 -0
  33. package/dist/es2015/colorpicker/utils/color-parser.d.ts +25 -0
  34. package/dist/es2015/colorpicker/utils/color-parser.js +52 -0
  35. package/dist/es2015/colorpicker.module.js +5 -1
  36. package/dist/es2015/index.d.ts +2 -0
  37. package/dist/es2015/index.js +2 -0
  38. package/dist/es2015/index.metadata.json +1 -1
  39. package/dist/es2015/numerictextbox/numerictextbox.component.js +2 -2
  40. package/dist/es2015/numerictextbox/utils.d.ts +4 -0
  41. package/dist/es2015/numerictextbox/utils.js +8 -0
  42. package/dist/es2015/package-metadata.js +1 -1
  43. package/dist/fesm2015/index.js +394 -121
  44. package/dist/fesm5/index.js +276 -28
  45. package/dist/npm/colorpicker/color-gradient.component.js +24 -12
  46. package/dist/npm/colorpicker/color-input.component.js +35 -7
  47. package/dist/npm/colorpicker/color-palette.component.js +13 -11
  48. package/dist/npm/colorpicker/constants.js +26 -0
  49. package/dist/npm/colorpicker/contrast-validation.component.js +59 -0
  50. package/dist/npm/colorpicker/contrast.component.js +74 -0
  51. package/dist/npm/colorpicker/localization/messages.js +12 -0
  52. package/dist/npm/colorpicker/models/rgb.js +6 -0
  53. package/dist/npm/colorpicker/utils/color-parser.js +52 -0
  54. package/dist/npm/colorpicker.module.js +5 -1
  55. package/dist/npm/index.js +4 -0
  56. package/dist/npm/numerictextbox/numerictextbox.component.js +1 -1
  57. package/dist/npm/numerictextbox/utils.js +8 -0
  58. package/dist/npm/package-metadata.js +1 -1
  59. package/dist/systemjs/kendo-angular-inputs.js +1 -1
  60. package/package.json +4 -4
@@ -0,0 +1,54 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as tslib_1 from "tslib";
6
+ import { LocalizationService } from '@progress/kendo-angular-l10n';
7
+ import { Component, Input } from '@angular/core';
8
+ /**
9
+ * @hidden
10
+ */
11
+ let ContrastValidationComponent = class ContrastValidationComponent {
12
+ constructor(localization) {
13
+ this.localization = localization;
14
+ }
15
+ get passMessage() {
16
+ return this.localization.get('passContrast');
17
+ }
18
+ get failMessage() {
19
+ return this.localization.get('failContrast');
20
+ }
21
+ get contrastText() {
22
+ return `${this.type}: ${this.ratio.toFixed(1)}`;
23
+ }
24
+ };
25
+ tslib_1.__decorate([
26
+ Input(),
27
+ tslib_1.__metadata("design:type", String)
28
+ ], ContrastValidationComponent.prototype, "type", void 0);
29
+ tslib_1.__decorate([
30
+ Input(),
31
+ tslib_1.__metadata("design:type", Number)
32
+ ], ContrastValidationComponent.prototype, "ratio", void 0);
33
+ tslib_1.__decorate([
34
+ Input(),
35
+ tslib_1.__metadata("design:type", Boolean)
36
+ ], ContrastValidationComponent.prototype, "pass", void 0);
37
+ ContrastValidationComponent = tslib_1.__decorate([
38
+ Component({
39
+ selector: '[kendoContrastValidation]',
40
+ template: `
41
+ <span>{{contrastText}}</span>
42
+ <span class="k-contrast-validation k-text-success" *ngIf="pass">
43
+ {{passMessage}}
44
+ <span class="k-icon k-i-check"></span>
45
+ </span>
46
+ <span class="k-contrast-validation k-text-error" *ngIf="!pass">
47
+ {{failMessage}}
48
+ <span class="k-icon k-i-close"></span>
49
+ </span>
50
+ `
51
+ }),
52
+ tslib_1.__metadata("design:paramtypes", [LocalizationService])
53
+ ], ContrastValidationComponent);
54
+ export { ContrastValidationComponent };
@@ -0,0 +1,21 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { LocalizationService } from '@progress/kendo-angular-l10n';
6
+ /**
7
+ * @hidden
8
+ */
9
+ export declare class ContrastComponent {
10
+ private localization;
11
+ value: string;
12
+ ratio: string;
13
+ aaRatio: number;
14
+ aaaRatio: number;
15
+ constructor(localization: LocalizationService);
16
+ readonly formatedRatio: string;
17
+ readonly contrastRatioMessage: string;
18
+ readonly satisfiesAACondition: boolean;
19
+ readonly satisfiesAAACondition: boolean;
20
+ readonly contrastRatio: number;
21
+ }
@@ -0,0 +1,72 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as tslib_1 from "tslib";
6
+ import { LocalizationService } from '@progress/kendo-angular-l10n';
7
+ import { Component, Input } from '@angular/core';
8
+ import { getContrastFromTwoRGBAs, getRGBA } from './utils';
9
+ import { AA_RATIO, AAA_RATIO } from './constants';
10
+ /**
11
+ * @hidden
12
+ */
13
+ let ContrastComponent = class ContrastComponent {
14
+ constructor(localization) {
15
+ this.localization = localization;
16
+ this.aaRatio = AA_RATIO;
17
+ this.aaaRatio = AAA_RATIO;
18
+ }
19
+ get formatedRatio() {
20
+ return this.contrastRatio.toFixed(2);
21
+ }
22
+ get contrastRatioMessage() {
23
+ return this.localization.get('contrastRatio');
24
+ }
25
+ get satisfiesAACondition() {
26
+ return this.contrastRatio >= this.aaRatio;
27
+ }
28
+ get satisfiesAAACondition() {
29
+ return this.contrastRatio >= this.aaaRatio;
30
+ }
31
+ get contrastRatio() {
32
+ let contrast = getContrastFromTwoRGBAs(getRGBA(this.value), getRGBA(this.ratio));
33
+ return contrast;
34
+ }
35
+ };
36
+ tslib_1.__decorate([
37
+ Input(),
38
+ tslib_1.__metadata("design:type", String)
39
+ ], ContrastComponent.prototype, "value", void 0);
40
+ tslib_1.__decorate([
41
+ Input(),
42
+ tslib_1.__metadata("design:type", String)
43
+ ], ContrastComponent.prototype, "ratio", void 0);
44
+ ContrastComponent = tslib_1.__decorate([
45
+ Component({
46
+ selector: '[kendoContrastTool]',
47
+ template: `
48
+ <div class="k-contrast-ratio">
49
+ <span class="k-contrast-ratio-text">{{contrastRatioMessage}}: {{formatedRatio}}</span>
50
+ <span class="k-contrast-validation k-text-success" *ngIf="satisfiesAACondition">
51
+ <span class="k-icon k-i-check"></span>
52
+ <span class="k-icon k-i-check" *ngIf="satisfiesAAACondition"></span>
53
+ </span>
54
+ <span class="k-contrast-validation k-text-error" *ngIf="!satisfiesAACondition">
55
+ <span class="k-icon k-i-close"></span>
56
+ </span>
57
+ </div>
58
+ <div kendoContrastValidation
59
+ type="AA"
60
+ [ratio]="aaaRatio"
61
+ [pass]="satisfiesAACondition">
62
+ </div>
63
+ <div kendoContrastValidation
64
+ type="AAA"
65
+ [ratio]="aaaRatio"
66
+ [pass]="satisfiesAAACondition">
67
+ </div>
68
+ `
69
+ }),
70
+ tslib_1.__metadata("design:paramtypes", [LocalizationService])
71
+ ], ContrastComponent);
72
+ export { ContrastComponent };
@@ -51,4 +51,16 @@ export declare class ColorPickerMessages extends ComponentMessages {
51
51
  * The placeholder for the alpha input.
52
52
  */
53
53
  alphaInputPlaceholder: string;
54
+ /**
55
+ * The "Pass" message for the contrast tool.
56
+ */
57
+ passContrast: string;
58
+ /**
59
+ * The "Fail" message for the contrast tool.
60
+ */
61
+ failContrast: string;
62
+ /**
63
+ * The "Contrast ratio" message for the contrast tool.
64
+ */
65
+ contrastRatio: string;
54
66
  }
@@ -54,3 +54,15 @@ tslib_1.__decorate([
54
54
  Input(),
55
55
  tslib_1.__metadata("design:type", String)
56
56
  ], ColorPickerMessages.prototype, "alphaInputPlaceholder", void 0);
57
+ tslib_1.__decorate([
58
+ Input(),
59
+ tslib_1.__metadata("design:type", String)
60
+ ], ColorPickerMessages.prototype, "passContrast", void 0);
61
+ tslib_1.__decorate([
62
+ Input(),
63
+ tslib_1.__metadata("design:type", String)
64
+ ], ColorPickerMessages.prototype, "failContrast", void 0);
65
+ tslib_1.__decorate([
66
+ Input(),
67
+ tslib_1.__metadata("design:type", String)
68
+ ], ColorPickerMessages.prototype, "contrastRatio", void 0);
@@ -0,0 +1,12 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * @hidden
7
+ */
8
+ export interface RGB {
9
+ r?: number;
10
+ g?: number;
11
+ b?: number;
12
+ }
@@ -0,0 +1,4 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
@@ -3,6 +3,7 @@
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { OutputFormat, HSVA, RGBA } from '../models';
6
+ import { RGB } from '../models/rgb';
6
7
  /**
7
8
  * @hidden
8
9
  *
@@ -44,3 +45,27 @@ export declare const getColorFromRGBA: (rgba: RGBA) => string;
44
45
  * @hidden
45
46
  */
46
47
  export declare function nameFormat(value: string, safe: boolean): string;
48
+ /**
49
+ * @hidden
50
+ *
51
+ * Returns the RGB object representation of the color based on the background color.
52
+ */
53
+ export declare const getRGBFromRGBA: (foregroundColor: RGBA, backgroundColor: RGBA) => RGB;
54
+ /**
55
+ * @hidden
56
+ *
57
+ * Returns the relative luminance.
58
+ */
59
+ export declare const getLuminance: (rgb: RGB) => number;
60
+ /**
61
+ * @hidden
62
+ *
63
+ * Returns the color contrast.
64
+ */
65
+ export declare const getContrast: (luminance1: number, luminance2: number) => number;
66
+ /**
67
+ * @hidden
68
+ *
69
+ * Returns the color contrast from two RGBA colors.
70
+ */
71
+ export declare const getContrastFromTwoRGBAs: (a: RGBA, b: RGBA) => number;
@@ -100,3 +100,55 @@ export function nameFormat(value, safe) {
100
100
  }
101
101
  return key;
102
102
  }
103
+ /**
104
+ * @hidden
105
+ *
106
+ * Returns the RGB object representation of the color based on the background color.
107
+ */
108
+ export const getRGBFromRGBA = (foregroundColor, backgroundColor) => {
109
+ const r1 = fitIntoBounds(foregroundColor.r, 0, 255);
110
+ const g1 = fitIntoBounds(foregroundColor.g, 0, 255);
111
+ const b1 = fitIntoBounds(foregroundColor.b, 0, 255);
112
+ const a1 = fitIntoBounds(foregroundColor.a, 0, 1);
113
+ const r2 = fitIntoBounds(backgroundColor.r, 0, 255);
114
+ const g2 = fitIntoBounds(backgroundColor.g, 0, 255);
115
+ const b2 = fitIntoBounds(backgroundColor.b, 0, 255);
116
+ return {
117
+ r: Math.round(((1 - a1) * r2) + (a1 * r1)),
118
+ g: Math.round(((1 - a1) * g2) + (a1 * g1)),
119
+ b: Math.round(((1 - a1) * b2) + (a1 * b1))
120
+ };
121
+ };
122
+ /**
123
+ * @hidden
124
+ *
125
+ * Returns the relative luminance.
126
+ */
127
+ export const getLuminance = (rgb) => {
128
+ let a = [rgb.r, rgb.g, rgb.b].map(function (v) {
129
+ v /= 255;
130
+ return v <= 0.03928
131
+ ? v / 12.92
132
+ : Math.pow((v + 0.055) / 1.055, 2.4);
133
+ });
134
+ return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
135
+ };
136
+ /**
137
+ * @hidden
138
+ *
139
+ * Returns the color contrast.
140
+ */
141
+ export const getContrast = (luminance1, luminance2) => {
142
+ const brightest = Math.max(luminance1, luminance2);
143
+ const darkest = Math.min(luminance1, luminance2);
144
+ return (brightest + 0.05)
145
+ / (darkest + 0.05);
146
+ };
147
+ /**
148
+ * @hidden
149
+ *
150
+ * Returns the color contrast from two RGBA colors.
151
+ */
152
+ export const getContrastFromTwoRGBAs = (a, b) => {
153
+ return getContrast(getLuminance(getRGBFromRGBA(a, b)), getLuminance(getRGBFromRGBA(b, { r: 0, g: 0, b: 0, a: 1 })));
154
+ };
@@ -16,6 +16,8 @@ import { ColorInputComponent } from './colorpicker/color-input.component';
16
16
  import { ColorPickerCustomMessagesComponent } from './colorpicker/localization/custom-messages.component';
17
17
  import { LocalizedColorPickerMessagesDirective } from './colorpicker/localization/localized-colorpicker-messages.directive';
18
18
  import { FocusOnDomReadyDirective } from './colorpicker/focus-on-dom-ready.directive';
19
+ import { ContrastValidationComponent } from './colorpicker/contrast-validation.component';
20
+ import { ContrastComponent } from './colorpicker/contrast.component';
19
21
  const PUBLIC_DIRECTIVES = [
20
22
  ColorPickerComponent,
21
23
  ColorPaletteComponent,
@@ -25,7 +27,9 @@ const PUBLIC_DIRECTIVES = [
25
27
  ];
26
28
  const INTERNAL_DIRECTIVES = [
27
29
  ColorInputComponent,
28
- FocusOnDomReadyDirective
30
+ FocusOnDomReadyDirective,
31
+ ContrastComponent,
32
+ ContrastValidationComponent
29
33
  ];
30
34
  /**
31
35
  * Represents the [NgModule]({{ site.data.urls.angular['ngmoduleapi'] }})
@@ -8,6 +8,8 @@
8
8
  export * from './main';
9
9
  export { CheckBoxModule } from './checkbox.module';
10
10
  export { ColorInputComponent } from './colorpicker/color-input.component';
11
+ export { ContrastValidationComponent } from './colorpicker/contrast-validation.component';
12
+ export { ContrastComponent } from './colorpicker/contrast.component';
11
13
  export { FocusOnDomReadyDirective } from './colorpicker/focus-on-dom-ready.directive';
12
14
  export { ColorGradientLocalizationService } from './colorpicker/localization/colorgradient-localization.service';
13
15
  export { ColorPaletteLocalizationService } from './colorpicker/localization/colorpalette-localization.service';
@@ -8,6 +8,8 @@
8
8
  export * from './main';
9
9
  export { CheckBoxModule } from './checkbox.module';
10
10
  export { ColorInputComponent } from './colorpicker/color-input.component';
11
+ export { ContrastValidationComponent } from './colorpicker/contrast-validation.component';
12
+ export { ContrastComponent } from './colorpicker/contrast.component';
11
13
  export { FocusOnDomReadyDirective } from './colorpicker/focus-on-dom-ready.directive';
12
14
  export { ColorGradientLocalizationService } from './colorpicker/localization/colorgradient-localization.service';
13
15
  export { ColorPaletteLocalizationService } from './colorpicker/localization/colorpalette-localization.service';