@progress/kendo-angular-progressbar 3.1.2-dev.202211170812 → 11.0.0-develop.79

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/NOTICE.txt +3 -3
  2. package/chunk/chunk-progressbar.component.d.ts +8 -4
  3. package/circularprogressbar/center-template.directive.d.ts +3 -3
  4. package/circularprogressbar/circular-progressbar.component.d.ts +2 -2
  5. package/circularprogressbar/models/center-template-context.interface.d.ts +1 -1
  6. package/circularprogressbar/models/circular-progressbar-progress-color-interface.d.ts +1 -1
  7. package/common/constants.d.ts +1 -1
  8. package/common/localization/custom-messages.component.d.ts +1 -1
  9. package/common/localization/localized-messages.directive.d.ts +1 -1
  10. package/common/localization/messages.d.ts +2 -2
  11. package/common/progressbar-base.d.ts +1 -1
  12. package/common/util.d.ts +16 -6
  13. package/{esm2015/chunk/chunk-progressbar.component.js → esm2020/chunk/chunk-progressbar.component.mjs} +18 -13
  14. package/{esm2015/circularprogressbar/center-template.directive.js → esm2020/circularprogressbar/center-template.directive.mjs} +5 -5
  15. package/{esm2015/circularprogressbar/circular-progressbar.component.js → esm2020/circularprogressbar/circular-progressbar.component.mjs} +29 -26
  16. package/{esm2015/circularprogressbar/models/center-template-context.interface.js → esm2020/circularprogressbar/models/center-template-context.interface.mjs} +1 -1
  17. package/{esm2015/circularprogressbar/models/circular-progressbar-progress-color-interface.js → esm2020/circularprogressbar/models/circular-progressbar-progress-color-interface.mjs} +1 -1
  18. package/{esm2015/common/constants.js → esm2020/common/constants.mjs} +1 -1
  19. package/{esm2015/common/localization/custom-messages.component.js → esm2020/common/localization/custom-messages.component.mjs} +5 -4
  20. package/{esm2015/common/localization/localized-messages.directive.js → esm2020/common/localization/localized-messages.directive.mjs} +5 -4
  21. package/{esm2015/common/localization/messages.js → esm2020/common/localization/messages.mjs} +5 -8
  22. package/{esm2015/common/progressbar-base.js → esm2020/common/progressbar-base.mjs} +9 -8
  23. package/{esm2015/common/util.js → esm2020/common/util.mjs} +5 -5
  24. package/{esm2015/main.js → esm2020/index.mjs} +1 -1
  25. package/{esm2015/package-metadata.js → esm2020/package-metadata.mjs} +3 -3
  26. package/{esm2015/kendo-angular-progressbar.js → esm2020/progress-kendo-angular-progressbar.mjs} +2 -2
  27. package/{esm2015/progressbar.component.js → esm2020/progressbar.component.mjs} +8 -8
  28. package/{esm2015/progressbar.module.js → esm2020/progressbar.module.mjs} +5 -5
  29. package/{esm2015/types/label-fn-type.js → esm2020/types/animation-end-event.mjs} +1 -1
  30. package/{esm2015/types/animation-end-event.js → esm2020/types/animation-options.interface.mjs} +1 -1
  31. package/{esm2015/types/animation-options.interface.js → esm2020/types/label-fn-type.mjs} +1 -1
  32. package/esm2020/types/label-position.mjs +5 -0
  33. package/esm2020/types/label-settings.interface.mjs +5 -0
  34. package/esm2020/types/label-type.mjs +5 -0
  35. package/esm2020/types/progressbar-animation.interface.mjs +5 -0
  36. package/esm2020/types/progressbar-orientation.mjs +5 -0
  37. package/fesm2015/{kendo-angular-progressbar.js → progress-kendo-angular-progressbar.mjs} +79 -74
  38. package/fesm2020/progress-kendo-angular-progressbar.mjs +1456 -0
  39. package/{main.d.ts → index.d.ts} +1 -1
  40. package/package-metadata.d.ts +1 -1
  41. package/package.json +28 -54
  42. package/{kendo-angular-progressbar.d.ts → progress-kendo-angular-progressbar.d.ts} +2 -2
  43. package/progressbar.component.d.ts +1 -1
  44. package/progressbar.module.d.ts +1 -1
  45. package/schematics/ngAdd/index.js +1 -5
  46. package/types/animation-end-event.d.ts +1 -1
  47. package/types/animation-options.interface.d.ts +1 -1
  48. package/types/label-fn-type.d.ts +1 -1
  49. package/types/label-position.d.ts +1 -1
  50. package/types/label-settings.interface.d.ts +1 -1
  51. package/types/label-type.d.ts +1 -1
  52. package/types/progressbar-animation.interface.d.ts +1 -1
  53. package/types/progressbar-orientation.d.ts +1 -1
  54. package/bundles/kendo-angular-progressbar.umd.js +0 -5
  55. package/esm2015/types/label-position.js +0 -5
  56. package/esm2015/types/label-settings.interface.js +0 -5
  57. package/esm2015/types/label-type.js +0 -5
  58. package/esm2015/types/progressbar-animation.interface.js +0 -5
  59. package/esm2015/types/progressbar-orientation.js +0 -5
  60. package/schematics/ngAdd/index.js.map +0 -1
@@ -0,0 +1,1456 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 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 i1 from '@progress/kendo-angular-l10n';
6
+ import { ComponentMessages, LocalizationService, L10N_PREFIX } from '@progress/kendo-angular-l10n';
7
+ import * as i0 from '@angular/core';
8
+ import { isDevMode, Component, HostBinding, Input, Directive, forwardRef, EventEmitter, Output, ViewChild, ContentChild, NgModule } from '@angular/core';
9
+ import { validatePackage } from '@progress/kendo-licensing';
10
+ import * as i2 from '@progress/kendo-angular-common';
11
+ import { hasObservers, isDocumentAvailable, isChanged, ResizeSensorModule } from '@progress/kendo-angular-common';
12
+ import * as i3 from '@angular/common';
13
+ import { CommonModule } from '@angular/common';
14
+ import { Subscription } from 'rxjs';
15
+ import { take } from 'rxjs/operators';
16
+
17
+ /**
18
+ * @hidden
19
+ */
20
+ const packageMetadata = {
21
+ name: '@progress/kendo-angular-progressbar',
22
+ productName: 'Kendo UI for Angular',
23
+ productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
24
+ publishDate: 1672320708,
25
+ version: '',
26
+ licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
27
+ };
28
+
29
+ /**
30
+ * @hidden
31
+ */
32
+ const MIN_MAX_ERROR_MESSAGE = `The max value should be greater than the min.`;
33
+ /**
34
+ * @hidden
35
+ */
36
+ const LABEL_DECIMALS = 3;
37
+ /**
38
+ * @hidden
39
+ */
40
+ const MIN_RATIO = 0.0001;
41
+
42
+ /**
43
+ * @hidden
44
+ */
45
+ const reverseChunks = (orientation, reverse) => (orientation === 'vertical' && !reverse || orientation === 'horizontal' && reverse);
46
+ /**
47
+ * @hidden
48
+ */
49
+ const formatValue = (value, min, max, label) => {
50
+ const defaultFormattedValue = truncateNumber(value);
51
+ if (typeof label !== 'boolean') {
52
+ if (typeof label.format === 'string') {
53
+ switch (label.format) {
54
+ case 'value':
55
+ return defaultFormattedValue;
56
+ case 'percent':
57
+ return `${Math.floor(calculatePercentage(value, min, max))}%`;
58
+ default:
59
+ return defaultFormattedValue;
60
+ }
61
+ }
62
+ else if (typeof label.format === 'function') {
63
+ return label.format(value);
64
+ }
65
+ else {
66
+ return defaultFormattedValue;
67
+ }
68
+ }
69
+ return defaultFormattedValue;
70
+ };
71
+ /**
72
+ * @hidden
73
+ */
74
+ const validateRange = (min, max) => {
75
+ if (isDevMode && min > max) {
76
+ throw new Error(MIN_MAX_ERROR_MESSAGE);
77
+ }
78
+ };
79
+ /**
80
+ * @hidden
81
+ */
82
+ const adjustValueToRange = (min, max, value) => Math.max(Math.min(value, max), min);
83
+ /**
84
+ * @hidden
85
+ */
86
+ const calculatePercentage = (value, min, max) => {
87
+ const onePercent = Math.abs((max - min) / 100);
88
+ return Math.abs((value - min) / onePercent);
89
+ };
90
+ /**
91
+ * @hidden
92
+ */
93
+ const truncateNumber = (value) => {
94
+ const numberParts = value.toString().split('.');
95
+ return numberParts.length === 1 ? `${numberParts[0]}` : `${numberParts[0]}.${numberParts[1].substr(0, LABEL_DECIMALS)}`;
96
+ };
97
+ /**
98
+ * @hidden
99
+ */
100
+ const calculateRatio = (min, max, value) => Math.max((value - min) / (max - min), MIN_RATIO);
101
+ /**
102
+ * @hidden
103
+ */
104
+ const extractValueFromChanges = (changes, type, value) => changes[type] && changes[type].currentValue !== undefined ? changes[type].currentValue : value;
105
+ /**
106
+ * @hidden
107
+ */
108
+ const runAnimation = (changes, animation, previousValue, displayValue) => animation && typeof requestAnimationFrame !== 'undefined' && changes['value'] && previousValue !== displayValue;
109
+ /**
110
+ * @hidden
111
+ */
112
+ const stopCurrentAnimation = (changes) => {
113
+ const isAnimationChanged = Boolean(changes['animation']);
114
+ const hasAnimation = isAnimationChanged && changes['animation'].currentValue;
115
+ return isAnimationChanged && !hasAnimation;
116
+ };
117
+ /**
118
+ * @hidden
119
+ */
120
+ const setProgressBarStyles = (props, renderer) => {
121
+ props.forEach(prop => {
122
+ renderer[prop.method](prop.el, prop.attr, `${prop.attrValue}`);
123
+ });
124
+ };
125
+ /**
126
+ * @hidden
127
+ */
128
+ const removeProgressBarStyles = (props, renderer) => {
129
+ props.forEach(prop => {
130
+ renderer[prop.method](prop.el, prop.attr);
131
+ });
132
+ };
133
+ /**
134
+ * @hidden
135
+ */
136
+ const hasElementSize = (element) => {
137
+ return !!(element.style.width && element.style.height);
138
+ };
139
+
140
+ /**
141
+ * @hidden
142
+ */
143
+ class ProgressBarBase {
144
+ /**
145
+ * @hidden
146
+ */
147
+ constructor(elem, renderer, localization) {
148
+ this.elem = elem;
149
+ this.renderer = renderer;
150
+ this.localization = localization;
151
+ this.hostClasses = true;
152
+ this.roleAttribute = 'progressbar';
153
+ /**
154
+ * The maximum value of the ProgressBar.
155
+ * Defaults to `100`.
156
+ */
157
+ this.max = 100;
158
+ /**
159
+ * The minimum value of the ProgressBar.
160
+ * Defaults to `0`.
161
+ */
162
+ this.min = 0;
163
+ /**
164
+ * The value of the ProgressBar.
165
+ * Has to be between `min` and `max`.
166
+ * By default, the value is equal to the `min` value.
167
+ */
168
+ /**
169
+ * The value of the ProgressBar.
170
+ * Has to be between `min` and `max`.
171
+ * Defaults to `0`.
172
+ */
173
+ this.value = 0;
174
+ /**
175
+ * Defines the orientation of the ProgressBar
176
+ * ([see example]({% slug progressbar_orientation %})).
177
+ * Defaults to `horizontal`.
178
+ */
179
+ this.orientation = 'horizontal';
180
+ /**
181
+ * If set to `true`, the ProgressBar will be disabled
182
+ * ([see example]({% slug progressbar_disabled %})).
183
+ * It will still allow you to change its value.
184
+ * Defaults to `false`.
185
+ */
186
+ this.disabled = false;
187
+ /**
188
+ * If set to `true`, the ProgressBar will be reversed
189
+ * ([see example]({% slug progressbar_direction %})).
190
+ * Defaults to `false`.
191
+ */
192
+ this.reverse = false;
193
+ /**
194
+ * Sets the `indeterminate` state of the ProgressBar.
195
+ * Defaults to `false`.
196
+ */
197
+ this.indeterminate = false;
198
+ this.displayValue = 0;
199
+ this.previousValue = 0;
200
+ validatePackage(packageMetadata);
201
+ this.localizationChangeSubscription = localization.changes.subscribe(({ rtl }) => {
202
+ this.direction = rtl ? 'rtl' : 'ltr';
203
+ });
204
+ }
205
+ get isHorizontal() {
206
+ return this.orientation === 'horizontal';
207
+ }
208
+ get isVertical() {
209
+ return this.orientation === 'vertical';
210
+ }
211
+ get disabledClass() {
212
+ return this.disabled;
213
+ }
214
+ get reverseClass() {
215
+ return this.reverse;
216
+ }
217
+ get indeterminateClass() {
218
+ return this.indeterminate;
219
+ }
220
+ get dirAttribute() {
221
+ return this.direction;
222
+ }
223
+ get ariaMinAttribute() {
224
+ return String(this.min);
225
+ }
226
+ get ariaMaxAttribute() {
227
+ return String(this.max);
228
+ }
229
+ get ariaValueAttribute() {
230
+ return this.indeterminate ? undefined : String(this.displayValue);
231
+ }
232
+ /**
233
+ * @hidden
234
+ */
235
+ get isCompleted() {
236
+ return this.value === this.max;
237
+ }
238
+ /**
239
+ * @hidden
240
+ */
241
+ get statusWidth() {
242
+ return this.orientation === 'horizontal' ? this._progressRatio * 100 : 100;
243
+ }
244
+ /**
245
+ * @hidden
246
+ */
247
+ get statusHeight() {
248
+ return this.orientation === 'vertical' ? this._progressRatio * 100 : 100;
249
+ }
250
+ /**
251
+ * @hidden
252
+ */
253
+ get statusWrapperWidth() {
254
+ return this.orientation === 'horizontal' ? 100 / this._progressRatio : 100;
255
+ }
256
+ /**
257
+ * @hidden
258
+ */
259
+ get statusWrapperHeight() {
260
+ return this.orientation === 'vertical' ? 100 / this._progressRatio : 100;
261
+ }
262
+ get _progressRatio() {
263
+ return calculateRatio(this.min, this.max, this.displayValue);
264
+ }
265
+ ngAfterViewInit() {
266
+ const elem = this.elem.nativeElement;
267
+ const label = this.localization.get('progressBarLabel');
268
+ this.renderer.setAttribute(elem, 'aria-label', label);
269
+ }
270
+ ngOnChanges(changes) {
271
+ const min = extractValueFromChanges(changes, 'min', this.min);
272
+ const max = extractValueFromChanges(changes, 'max', this.max);
273
+ const value = extractValueFromChanges(changes, 'value', this.value);
274
+ if (changes['min'] || changes['max'] || changes['value']) {
275
+ if (changes['min'] || changes['max']) {
276
+ validateRange(min, max);
277
+ }
278
+ if (changes['value']) {
279
+ if (value == null || Number.isNaN(value)) {
280
+ this.value = min;
281
+ }
282
+ const previousValue = this.displayValue;
283
+ this.displayValue = adjustValueToRange(this.min, this.max, value);
284
+ this.previousValue = previousValue;
285
+ }
286
+ this.min = min;
287
+ this.max = max;
288
+ this.displayValue = adjustValueToRange(this.min, this.max, value);
289
+ }
290
+ }
291
+ ngOnDestroy() {
292
+ if (this.localizationChangeSubscription) {
293
+ this.localizationChangeSubscription.unsubscribe();
294
+ }
295
+ }
296
+ }
297
+ ProgressBarBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarBase, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
298
+ ProgressBarBase.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ProgressBarBase, selector: "ng-component", inputs: { max: "max", min: "min", value: "value", orientation: "orientation", disabled: "disabled", reverse: "reverse", indeterminate: "indeterminate" }, host: { properties: { "class.k-progressbar": "this.hostClasses", "class.k-progressbar-horizontal": "this.isHorizontal", "class.k-progressbar-vertical": "this.isVertical", "class.k-disabled": "this.disabledClass", "class.k-progressbar-reverse": "this.reverseClass", "class.k-progressbar-indeterminate": "this.indeterminateClass", "attr.dir": "this.dirAttribute", "attr.role": "this.roleAttribute", "attr.aria-valuemin": "this.ariaMinAttribute", "attr.aria-valuemax": "this.ariaMaxAttribute", "attr.aria-valuenow": "this.ariaValueAttribute" } }, usesOnChanges: true, ngImport: i0, template: '', isInline: true });
299
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarBase, decorators: [{
300
+ type: Component,
301
+ args: [{
302
+ template: ''
303
+ }]
304
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1.LocalizationService }]; }, propDecorators: { hostClasses: [{
305
+ type: HostBinding,
306
+ args: ['class.k-progressbar']
307
+ }], isHorizontal: [{
308
+ type: HostBinding,
309
+ args: ['class.k-progressbar-horizontal']
310
+ }], isVertical: [{
311
+ type: HostBinding,
312
+ args: ['class.k-progressbar-vertical']
313
+ }], disabledClass: [{
314
+ type: HostBinding,
315
+ args: ['class.k-disabled']
316
+ }], reverseClass: [{
317
+ type: HostBinding,
318
+ args: ['class.k-progressbar-reverse']
319
+ }], indeterminateClass: [{
320
+ type: HostBinding,
321
+ args: ['class.k-progressbar-indeterminate']
322
+ }], dirAttribute: [{
323
+ type: HostBinding,
324
+ args: ['attr.dir']
325
+ }], roleAttribute: [{
326
+ type: HostBinding,
327
+ args: ['attr.role']
328
+ }], ariaMinAttribute: [{
329
+ type: HostBinding,
330
+ args: ['attr.aria-valuemin']
331
+ }], ariaMaxAttribute: [{
332
+ type: HostBinding,
333
+ args: ['attr.aria-valuemax']
334
+ }], ariaValueAttribute: [{
335
+ type: HostBinding,
336
+ args: ['attr.aria-valuenow']
337
+ }], max: [{
338
+ type: Input
339
+ }], min: [{
340
+ type: Input
341
+ }], value: [{
342
+ type: Input
343
+ }], orientation: [{
344
+ type: Input
345
+ }], disabled: [{
346
+ type: Input
347
+ }], reverse: [{
348
+ type: Input
349
+ }], indeterminate: [{
350
+ type: Input
351
+ }] } });
352
+
353
+ /**
354
+ * @hidden
355
+ */
356
+ class ProgressBarMessages extends ComponentMessages {
357
+ }
358
+ ProgressBarMessages.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarMessages, deps: null, target: i0.ɵɵFactoryTarget.Directive });
359
+ ProgressBarMessages.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", type: ProgressBarMessages, inputs: { progressBarLabel: "progressBarLabel" }, usesInheritance: true, ngImport: i0 });
360
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarMessages, decorators: [{
361
+ type: Directive,
362
+ args: [{}]
363
+ }], propDecorators: { progressBarLabel: [{
364
+ type: Input
365
+ }] } });
366
+
367
+ /**
368
+ * @hidden
369
+ */
370
+ class LocalizedProgressBarMessagesDirective extends ProgressBarMessages {
371
+ constructor(service) {
372
+ super();
373
+ this.service = service;
374
+ }
375
+ }
376
+ LocalizedProgressBarMessagesDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: LocalizedProgressBarMessagesDirective, deps: [{ token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Directive });
377
+ LocalizedProgressBarMessagesDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", type: LocalizedProgressBarMessagesDirective, selector: "[kendoProgressBarLocalizedMessages]", providers: [
378
+ {
379
+ provide: ProgressBarMessages,
380
+ useExisting: forwardRef(() => LocalizedProgressBarMessagesDirective)
381
+ }
382
+ ], usesInheritance: true, ngImport: i0 });
383
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: LocalizedProgressBarMessagesDirective, decorators: [{
384
+ type: Directive,
385
+ args: [{
386
+ providers: [
387
+ {
388
+ provide: ProgressBarMessages,
389
+ useExisting: forwardRef(() => LocalizedProgressBarMessagesDirective)
390
+ }
391
+ ],
392
+ selector: `[kendoProgressBarLocalizedMessages]`
393
+ }]
394
+ }], ctorParameters: function () { return [{ type: i1.LocalizationService }]; } });
395
+
396
+ /**
397
+ * Represents the [Kendo UI ProgressBar component for Angular]({% slug overview_progressbar %}).
398
+ *
399
+ * @example
400
+ * ```ts-preview
401
+ * _@Component({
402
+ * selector: 'my-app',
403
+ * template: `
404
+ * <kendo-progressbar [value]="value">
405
+ * </kendo-progressbar>
406
+ * `
407
+ * })
408
+ * class AppComponent {
409
+ * public value = 50;
410
+ * }
411
+ * ```
412
+ */
413
+ class ProgressBarComponent extends ProgressBarBase {
414
+ /**
415
+ * @hidden
416
+ */
417
+ constructor(localization, elem, renderer, zone) {
418
+ super(elem, renderer, localization);
419
+ this.localization = localization;
420
+ this.elem = elem;
421
+ this.renderer = renderer;
422
+ this.zone = zone;
423
+ /**
424
+ * Determines whether the status label will be visible.
425
+ * Defaults to `true`&mdash;the label will be visible and displayed with the default
426
+ * `LabelSettings` having its position set to `end` and its format set to `value`.
427
+ */
428
+ this.label = true;
429
+ /**
430
+ * The animation configuration of the ProgressBar.
431
+ * Defaults to `false`.
432
+ */
433
+ this.animation = false;
434
+ /**
435
+ * Fires when the animation which indicates the latest value change is completed.
436
+ */
437
+ this.animationEnd = new EventEmitter();
438
+ }
439
+ /**
440
+ * @hidden
441
+ */
442
+ get showLabel() {
443
+ if (typeof this.label === 'boolean') {
444
+ return this.label;
445
+ }
446
+ else {
447
+ if (this.label && !this.label.hasOwnProperty('visible')) {
448
+ this.label.visible = true;
449
+ }
450
+ return this.label.visible;
451
+ }
452
+ }
453
+ /**
454
+ * @hidden
455
+ */
456
+ get labelPosition() {
457
+ if (typeof this.label === 'boolean') {
458
+ return 'end';
459
+ }
460
+ else {
461
+ if (this.label && !this.label.hasOwnProperty('position')) {
462
+ this.label.position = 'end';
463
+ }
464
+ return this.label.position;
465
+ }
466
+ }
467
+ /**
468
+ * @hidden
469
+ */
470
+ get isPositionStart() {
471
+ return this.labelPosition === 'start';
472
+ }
473
+ /**
474
+ * @hidden
475
+ */
476
+ get isPositionCenter() {
477
+ return this.labelPosition === 'center';
478
+ }
479
+ /**
480
+ * @hidden
481
+ */
482
+ get isPositionEnd() {
483
+ return this.labelPosition === 'end';
484
+ }
485
+ /**
486
+ * @hidden
487
+ */
488
+ get formattedLabelValue() {
489
+ return formatValue(this.displayValue, this.min, this.max, this.label);
490
+ }
491
+ /**
492
+ * @hidden
493
+ */
494
+ ngOnChanges(changes) {
495
+ super.ngOnChanges(changes);
496
+ if (this.isAnimationInProgress && stopCurrentAnimation(changes)) {
497
+ this.cancelCurrentAnimation = true;
498
+ }
499
+ if (runAnimation(changes, this.animation, this.previousValue, this.displayValue) && !changes['value'].firstChange) {
500
+ this.startAnimation(this.previousValue);
501
+ }
502
+ }
503
+ /**
504
+ * @hidden
505
+ */
506
+ ngOnDestroy() {
507
+ if (this.animationFrame) {
508
+ cancelAnimationFrame(this.animationFrame);
509
+ }
510
+ }
511
+ /**
512
+ * @hidden
513
+ */
514
+ startAnimation(previousValue) {
515
+ this.isAnimationInProgress = true;
516
+ const element = this.progressStatusElement.nativeElement;
517
+ const wrapperElement = this.progressStatusWrapperElement.nativeElement;
518
+ const animationOptions = this.getAnimationOptions(previousValue);
519
+ this.zone.runOutsideAngular(() => {
520
+ if (this.animationFrame) {
521
+ cancelAnimationFrame(this.animationFrame);
522
+ }
523
+ const animate = () => {
524
+ const elapsed = new Date().getTime() - animationOptions.startTime;
525
+ const position = Math.min(elapsed / animationOptions.duration, 1);
526
+ const size = animationOptions.startSize + animationOptions.deltaSize * position;
527
+ const wrapperSize = (100 / size) * 100;
528
+ this.renderValueChange(element, wrapperElement, animationOptions.property, size, wrapperSize);
529
+ if (position < 1) {
530
+ if (this.cancelCurrentAnimation) {
531
+ this.resetProgress(element, wrapperElement, animationOptions.property);
532
+ return;
533
+ }
534
+ this.animationFrame = requestAnimationFrame(animate);
535
+ }
536
+ else {
537
+ this.stopAnimation(previousValue);
538
+ }
539
+ };
540
+ animate();
541
+ });
542
+ }
543
+ /**
544
+ * @hidden
545
+ */
546
+ get animationDuration() {
547
+ if (typeof this.animation === 'boolean') {
548
+ return 400;
549
+ }
550
+ else {
551
+ if (this.animation && !this.animation.hasOwnProperty('duration')) {
552
+ this.animation.duration = 400;
553
+ }
554
+ return this.animation.duration;
555
+ }
556
+ }
557
+ stopAnimation(value) {
558
+ if (hasObservers(this.animationEnd)) {
559
+ this.zone.run(() => {
560
+ this.animationEnd.emit({
561
+ from: value,
562
+ to: this.displayValue
563
+ });
564
+ });
565
+ }
566
+ this.zone.run(() => {
567
+ this.isAnimationInProgress = false;
568
+ });
569
+ }
570
+ getAnimationOptions(value) {
571
+ const isHorizontal = this.orientation === 'horizontal';
572
+ const previousRatio = calculateRatio(this.min, this.max, value);
573
+ const previousStatusWidth = isHorizontal ? previousRatio * 100 : 100;
574
+ const previousStatusHeight = !isHorizontal ? previousRatio * 100 : 100;
575
+ const property = isHorizontal ? 'width' : 'height';
576
+ const startTime = new Date().getTime();
577
+ const startSize = isHorizontal ? previousStatusWidth : previousStatusHeight;
578
+ const deltaSize = isHorizontal ? this.statusWidth - previousStatusWidth : this.statusHeight - previousStatusHeight;
579
+ const duration = this.animationDuration * Math.abs((deltaSize / 100));
580
+ return {
581
+ property,
582
+ startTime,
583
+ startSize,
584
+ deltaSize,
585
+ duration
586
+ };
587
+ }
588
+ renderValueChange(element, wrapperElement, property, size, wrapperSize) {
589
+ this.renderer.setStyle(element, property, size + '%');
590
+ this.renderer.setStyle(wrapperElement, property, wrapperSize + '%');
591
+ }
592
+ resetProgress(element, wrapperElement, property) {
593
+ const size = calculateRatio(this.min, this.max, this.value);
594
+ const newSize = size * 100;
595
+ const newWrapperSize = 100 / size;
596
+ this.renderValueChange(element, wrapperElement, property, newSize, newWrapperSize);
597
+ this.zone.run(() => {
598
+ this.cancelCurrentAnimation = false;
599
+ this.isAnimationInProgress = false;
600
+ });
601
+ }
602
+ }
603
+ ProgressBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarComponent, deps: [{ token: i1.LocalizationService }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
604
+ ProgressBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ProgressBarComponent, selector: "kendo-progressbar", inputs: { label: "label", progressCssStyle: "progressCssStyle", progressCssClass: "progressCssClass", emptyCssStyle: "emptyCssStyle", emptyCssClass: "emptyCssClass", animation: "animation" }, outputs: { animationEnd: "animationEnd" }, providers: [
605
+ LocalizationService,
606
+ {
607
+ provide: L10N_PREFIX,
608
+ useValue: 'kendo.progressbar'
609
+ }
610
+ ], viewQueries: [{ propertyName: "progressStatusElement", first: true, predicate: ["progressStatus"], descendants: true }, { propertyName: "progressStatusWrapperElement", first: true, predicate: ["progressStatusWrap"], descendants: true }], exportAs: ["kendoProgressBar"], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
611
+ <ng-container kendoProgressBarLocalizedMessages
612
+ i18n-progressBarLabel="kendo.progressbar.progressBarLabel|The aria-label attribute for the ProgressBar component."
613
+ progressBarLabel="Progressbar"
614
+ >
615
+ </ng-container>
616
+ <span class="k-progress-status-wrap"
617
+ [class.k-progress-start]="isPositionStart"
618
+ [class.k-progress-center]="isPositionCenter"
619
+ [class.k-progress-end]="isPositionEnd"
620
+ [ngStyle]="emptyCssStyle"
621
+ [ngClass]="emptyCssClass">
622
+ <span *ngIf="showLabel" class="k-progress-status">{{formattedLabelValue}}</span>
623
+ </span>
624
+ <div
625
+ #progressStatus
626
+ class="k-selected k-progressbar-value"
627
+ [class.k-complete]="isCompleted"
628
+ [ngStyle]="progressCssStyle"
629
+ [ngClass]="progressCssClass"
630
+ [style.width.%]="statusWidth"
631
+ [style.height.%]="statusHeight"
632
+ >
633
+ <span
634
+ #progressStatusWrap
635
+ class="k-progress-status-wrap"
636
+ [style.width.%]="statusWrapperWidth"
637
+ [style.height.%]="statusWrapperHeight"
638
+ [class.k-progress-start]="isPositionStart"
639
+ [class.k-progress-center]="isPositionCenter"
640
+ [class.k-progress-end]="isPositionEnd"
641
+ >
642
+ <span *ngIf="showLabel" class="k-progress-status">{{formattedLabelValue}}</span>
643
+ </span>
644
+ </div>
645
+ `, isInline: true, directives: [{ type: LocalizedProgressBarMessagesDirective, selector: "[kendoProgressBarLocalizedMessages]" }, { type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
646
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarComponent, decorators: [{
647
+ type: Component,
648
+ args: [{
649
+ exportAs: 'kendoProgressBar',
650
+ selector: 'kendo-progressbar',
651
+ template: `
652
+ <ng-container kendoProgressBarLocalizedMessages
653
+ i18n-progressBarLabel="kendo.progressbar.progressBarLabel|The aria-label attribute for the ProgressBar component."
654
+ progressBarLabel="Progressbar"
655
+ >
656
+ </ng-container>
657
+ <span class="k-progress-status-wrap"
658
+ [class.k-progress-start]="isPositionStart"
659
+ [class.k-progress-center]="isPositionCenter"
660
+ [class.k-progress-end]="isPositionEnd"
661
+ [ngStyle]="emptyCssStyle"
662
+ [ngClass]="emptyCssClass">
663
+ <span *ngIf="showLabel" class="k-progress-status">{{formattedLabelValue}}</span>
664
+ </span>
665
+ <div
666
+ #progressStatus
667
+ class="k-selected k-progressbar-value"
668
+ [class.k-complete]="isCompleted"
669
+ [ngStyle]="progressCssStyle"
670
+ [ngClass]="progressCssClass"
671
+ [style.width.%]="statusWidth"
672
+ [style.height.%]="statusHeight"
673
+ >
674
+ <span
675
+ #progressStatusWrap
676
+ class="k-progress-status-wrap"
677
+ [style.width.%]="statusWrapperWidth"
678
+ [style.height.%]="statusWrapperHeight"
679
+ [class.k-progress-start]="isPositionStart"
680
+ [class.k-progress-center]="isPositionCenter"
681
+ [class.k-progress-end]="isPositionEnd"
682
+ >
683
+ <span *ngIf="showLabel" class="k-progress-status">{{formattedLabelValue}}</span>
684
+ </span>
685
+ </div>
686
+ `,
687
+ providers: [
688
+ LocalizationService,
689
+ {
690
+ provide: L10N_PREFIX,
691
+ useValue: 'kendo.progressbar'
692
+ }
693
+ ]
694
+ }]
695
+ }], ctorParameters: function () { return [{ type: i1.LocalizationService }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }]; }, propDecorators: { label: [{
696
+ type: Input
697
+ }], progressCssStyle: [{
698
+ type: Input
699
+ }], progressCssClass: [{
700
+ type: Input
701
+ }], emptyCssStyle: [{
702
+ type: Input
703
+ }], emptyCssClass: [{
704
+ type: Input
705
+ }], animation: [{
706
+ type: Input
707
+ }], animationEnd: [{
708
+ type: Output
709
+ }], progressStatusElement: [{
710
+ type: ViewChild,
711
+ args: ['progressStatus', { static: false }]
712
+ }], progressStatusWrapperElement: [{
713
+ type: ViewChild,
714
+ args: ['progressStatusWrap', { static: false }]
715
+ }] } });
716
+
717
+ /**
718
+ * Represents the [Kendo UI ChunkProgressBar component for Angular]({% slug overview_chunkprogressbar %}).
719
+ *
720
+ * @example
721
+ * ```ts-preview
722
+ * _@Component({
723
+ * selector: 'my-app',
724
+ * template: `
725
+ * <kendo-chunkprogressbar [value]="value">
726
+ * </kendo-chunkprogressbar>
727
+ * `
728
+ * })
729
+ * class AppComponent {
730
+ * public value = 40;
731
+ * }
732
+ * ```
733
+ */
734
+ class ChunkProgressBarComponent extends ProgressBarBase {
735
+ /**
736
+ * @hidden
737
+ */
738
+ constructor(localization, elem, renderer) {
739
+ super(elem, renderer, localization);
740
+ this.localization = localization;
741
+ this.elem = elem;
742
+ this.renderer = renderer;
743
+ this.chunkClass = true;
744
+ /**
745
+ * Sets the number of chunks into which the ChunkProgressBar will be split.
746
+ * Defaults to `5`.
747
+ */
748
+ this.chunkCount = 5;
749
+ this._orientationStyles = {
750
+ width: `${this.chunkSizePercentage}%`,
751
+ height: null
752
+ };
753
+ }
754
+ /**
755
+ * @hidden
756
+ */
757
+ get chunks() {
758
+ const count = this.chunkCount;
759
+ const chunks = Array(count).fill(false);
760
+ const completedChunks = Math.floor(this._progressRatio * count);
761
+ for (let i = 0; i < completedChunks; i++) {
762
+ chunks[i] = true;
763
+ }
764
+ if (reverseChunks(this.orientation, this.reverse)) {
765
+ chunks.reverse();
766
+ }
767
+ return chunks;
768
+ }
769
+ /**
770
+ * @hidden
771
+ */
772
+ get chunkSizePercentage() {
773
+ return 100 / this.chunkCount;
774
+ }
775
+ /**
776
+ * @hidden
777
+ */
778
+ get orientationStyles() {
779
+ if (this.orientation === 'horizontal') {
780
+ this._orientationStyles.width = `${this.chunkSizePercentage}%`;
781
+ this._orientationStyles.height = null;
782
+ }
783
+ else {
784
+ this._orientationStyles.height = `${this.chunkSizePercentage}%`;
785
+ this._orientationStyles.width = null;
786
+ }
787
+ return this._orientationStyles;
788
+ }
789
+ }
790
+ ChunkProgressBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ChunkProgressBarComponent, deps: [{ token: i1.LocalizationService }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
791
+ ChunkProgressBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ChunkProgressBarComponent, selector: "kendo-chunkprogressbar", inputs: { chunkCount: "chunkCount", progressCssStyle: "progressCssStyle", progressCssClass: "progressCssClass", emptyCssStyle: "emptyCssStyle", emptyCssClass: "emptyCssClass" }, host: { properties: { "class.k-chunk-progressbar": "this.chunkClass" } }, providers: [
792
+ LocalizationService,
793
+ {
794
+ provide: L10N_PREFIX,
795
+ useValue: 'kendo.chunkprogressbar'
796
+ }
797
+ ], exportAs: ["kendoChunkProgressBar"], usesInheritance: true, ngImport: i0, template: `
798
+ <ng-container kendoProgressBarLocalizedMessages
799
+ i18n-progressBarLabel="kendo.chunkprogressbar.progressBarLabel|The aria-label attribute for the ChunkProgressBar component."
800
+ progressBarLabel="Chunk progressbar"
801
+ >
802
+ </ng-container>
803
+ <ul class="k-reset k-progressbar-chunks">
804
+ <li class="k-progressbar-chunk" *ngFor="let chunk of chunks; let i = index;"
805
+ [class.k-first]="i === 0"
806
+ [class.k-last]="i === chunkCount - 1"
807
+ [class.k-selected]="chunk"
808
+ [ngClass]="chunk ? progressCssClass : emptyCssClass"
809
+ [ngStyle]="chunk ? progressCssStyle : emptyCssStyle"
810
+ [style.width]="orientationStyles.width"
811
+ [style.height]="orientationStyles.height"
812
+ >
813
+ </li>
814
+ </ul>
815
+ `, isInline: true, directives: [{ type: LocalizedProgressBarMessagesDirective, selector: "[kendoProgressBarLocalizedMessages]" }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
816
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ChunkProgressBarComponent, decorators: [{
817
+ type: Component,
818
+ args: [{
819
+ exportAs: 'kendoChunkProgressBar',
820
+ selector: 'kendo-chunkprogressbar',
821
+ template: `
822
+ <ng-container kendoProgressBarLocalizedMessages
823
+ i18n-progressBarLabel="kendo.chunkprogressbar.progressBarLabel|The aria-label attribute for the ChunkProgressBar component."
824
+ progressBarLabel="Chunk progressbar"
825
+ >
826
+ </ng-container>
827
+ <ul class="k-reset k-progressbar-chunks">
828
+ <li class="k-progressbar-chunk" *ngFor="let chunk of chunks; let i = index;"
829
+ [class.k-first]="i === 0"
830
+ [class.k-last]="i === chunkCount - 1"
831
+ [class.k-selected]="chunk"
832
+ [ngClass]="chunk ? progressCssClass : emptyCssClass"
833
+ [ngStyle]="chunk ? progressCssStyle : emptyCssStyle"
834
+ [style.width]="orientationStyles.width"
835
+ [style.height]="orientationStyles.height"
836
+ >
837
+ </li>
838
+ </ul>
839
+ `,
840
+ providers: [
841
+ LocalizationService,
842
+ {
843
+ provide: L10N_PREFIX,
844
+ useValue: 'kendo.chunkprogressbar'
845
+ }
846
+ ]
847
+ }]
848
+ }], ctorParameters: function () { return [{ type: i1.LocalizationService }, { type: i0.ElementRef }, { type: i0.Renderer2 }]; }, propDecorators: { chunkClass: [{
849
+ type: HostBinding,
850
+ args: ['class.k-chunk-progressbar']
851
+ }], chunkCount: [{
852
+ type: Input
853
+ }], progressCssStyle: [{
854
+ type: Input
855
+ }], progressCssClass: [{
856
+ type: Input
857
+ }], emptyCssStyle: [{
858
+ type: Input
859
+ }], emptyCssClass: [{
860
+ type: Input
861
+ }] } });
862
+
863
+ /**
864
+ * A directive that selects a template within the <kendo-circularprogessbar> component which will be used for the center template.
865
+ * ([see example]({% slug center_template_circularprogressbar %})).
866
+ */
867
+ class CircularProgressbarCenterTemplateDirective {
868
+ constructor(templateRef) {
869
+ this.templateRef = templateRef;
870
+ }
871
+ }
872
+ CircularProgressbarCenterTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CircularProgressbarCenterTemplateDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
873
+ CircularProgressbarCenterTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", type: CircularProgressbarCenterTemplateDirective, selector: "[kendoCircularProgressbarCenterTemplate]", ngImport: i0 });
874
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CircularProgressbarCenterTemplateDirective, decorators: [{
875
+ type: Directive,
876
+ args: [{
877
+ selector: '[kendoCircularProgressbarCenterTemplate]'
878
+ }]
879
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
880
+
881
+ const DEFAULT_SURFACE_SIZE = 200;
882
+ /**
883
+ * Represents the [Kendo UI Circular ProgressBar component for Angular]({% slug overview_circularprogressbar %}).
884
+ *
885
+ * @example
886
+ * ```ts-preview
887
+ * _@Component({
888
+ * selector: 'my-app',
889
+ * template: `
890
+ * <kendo-circularprogressbar [value]="value"></kendo-circularprogressbar>
891
+ * `
892
+ * })
893
+ * class AppComponent {
894
+ * public value: number = 50;
895
+ * }
896
+ * ```
897
+ */
898
+ class CircularProgressBarComponent {
899
+ constructor(renderer, cdr, localization, element, zone) {
900
+ this.renderer = renderer;
901
+ this.cdr = cdr;
902
+ this.localization = localization;
903
+ this.element = element;
904
+ this.zone = zone;
905
+ this.hostClasses = true;
906
+ this.roleAttribute = 'progressbar';
907
+ /**
908
+ * Indicates whether an animation will be played on value changes.
909
+ *
910
+ * @default false
911
+ */
912
+ this.animation = false;
913
+ /**
914
+ * The opacity of the value arc.
915
+ * @default 1
916
+ */
917
+ this.opacity = 1;
918
+ /**
919
+ * Fires when the animation which indicates the latest value change is completed.
920
+ */
921
+ this.animationEnd = new EventEmitter();
922
+ this.centerTemplateContext = {};
923
+ this._indeterminate = false;
924
+ this._max = 100;
925
+ this._min = 0;
926
+ this._value = 0;
927
+ this.previousValue = 0;
928
+ this.internalValue = 0;
929
+ this.subscriptions = new Subscription();
930
+ validatePackage(packageMetadata);
931
+ this.subscriptions.add(this.localization.changes.subscribe(this.rtlChange.bind(this)));
932
+ }
933
+ get ariaMinAttribute() {
934
+ return String(this.min);
935
+ }
936
+ get ariaMaxAttribute() {
937
+ return String(this.max);
938
+ }
939
+ get ariaValueAttribute() {
940
+ return this.indeterminate ? undefined : String(this.value);
941
+ }
942
+ /**
943
+ * Sets the default value of the Circular Progressbar between `min` and `max`.
944
+ *
945
+ * @default 0
946
+ */
947
+ set value(value) {
948
+ if (value > this.max) {
949
+ this.handleErrors('value > max');
950
+ }
951
+ if (value < this.min) {
952
+ this.handleErrors('value < min');
953
+ }
954
+ this.previousValue = this.value;
955
+ this._value = value;
956
+ }
957
+ get value() {
958
+ return this._value;
959
+ }
960
+ /**
961
+ * The maximum value which the Circular Progressbar can accept.
962
+ *
963
+ * @default 100
964
+ */
965
+ set max(max) {
966
+ if (max < this.min) {
967
+ this.handleErrors('max < min');
968
+ }
969
+ this._max = max;
970
+ }
971
+ get max() {
972
+ return this._max;
973
+ }
974
+ /**
975
+ * The minimum value which the Circular Progressbar can accept.
976
+ *
977
+ * @default 0
978
+ */
979
+ set min(min) {
980
+ if (min > this.max) {
981
+ this.handleErrors('max < min');
982
+ }
983
+ this._min = min;
984
+ }
985
+ get min() {
986
+ return this._min;
987
+ }
988
+ /**
989
+ * Puts the Circular ProgressBar in indeterminate state.
990
+ * @default false
991
+ */
992
+ set indeterminate(indeterminate) {
993
+ this._indeterminate = indeterminate;
994
+ }
995
+ get indeterminate() {
996
+ return this._indeterminate;
997
+ }
998
+ ngAfterViewInit() {
999
+ if (!isDocumentAvailable()) {
1000
+ return;
1001
+ }
1002
+ const elem = this.element.nativeElement;
1003
+ const ariaLabel = this.localization.get('progressBarLabel');
1004
+ this.renderer.setAttribute(elem, 'aria-label', ariaLabel);
1005
+ this.initProgressArc();
1006
+ }
1007
+ ngOnChanges(changes) {
1008
+ const skipFirstChange = true;
1009
+ if (isChanged('value', changes, skipFirstChange) && this.progress) {
1010
+ if (this.animation) {
1011
+ this.progressbarAnimation();
1012
+ }
1013
+ else {
1014
+ const value = this.value - this.min;
1015
+ this.internalValue = changes['value'].currentValue;
1016
+ this.calculateProgress(value);
1017
+ }
1018
+ }
1019
+ if (changes['opacity'] && this.progress) {
1020
+ setProgressBarStyles([{ method: 'setAttribute', el: this.progress.nativeElement, attr: 'opacity', attrValue: this.opacity.toString() }], this.renderer);
1021
+ }
1022
+ if (changes['indeterminate'] && !changes['indeterminate'].firstChange) {
1023
+ this.indeterminateState();
1024
+ }
1025
+ }
1026
+ ngOnDestroy() {
1027
+ this.subscriptions.unsubscribe();
1028
+ }
1029
+ /**
1030
+ * @hidden
1031
+ */
1032
+ onResize() {
1033
+ this.setStyles();
1034
+ const value = this.animation ? this.internalValue : this.value;
1035
+ this.calculateProgress(value);
1036
+ this.updateCenterTemplate(value);
1037
+ }
1038
+ initProgressArc() {
1039
+ this.setStyles();
1040
+ if (this.indeterminate) {
1041
+ this.indeterminateState();
1042
+ }
1043
+ else {
1044
+ if (!this.animation) {
1045
+ const value = this.value - this.min;
1046
+ this.calculateProgress(value);
1047
+ }
1048
+ else {
1049
+ this.progressbarAnimation();
1050
+ }
1051
+ }
1052
+ }
1053
+ calculateProgress(value) {
1054
+ if (this.progressColor) {
1055
+ this.updateProgressColor(value);
1056
+ }
1057
+ // needed when we have *ngIf inside the template to render different content depending on some condition
1058
+ this.zone.onStable.pipe(take(1)).subscribe(() => {
1059
+ this.updateCenterTemplate(value + this.min);
1060
+ });
1061
+ const progressArc = this.progress.nativeElement;
1062
+ const radius = this.progress.nativeElement.r.baseVal.value;
1063
+ const circumference = Math.PI * (radius * 2);
1064
+ const dir = this.rtl ? circumference * -1 : circumference;
1065
+ const strokeDashOffest = circumference - dir * (value / (this.max - this.min));
1066
+ const progressCalculations = [
1067
+ { method: 'setStyle', el: progressArc, attr: 'strokeDasharray', attrValue: circumference.toString() },
1068
+ { method: 'setStyle', el: progressArc, attr: 'strokeDashoffset', attrValue: strokeDashOffest.toString() }
1069
+ ];
1070
+ setProgressBarStyles(progressCalculations, this.renderer);
1071
+ }
1072
+ progressbarAnimation() {
1073
+ const forwardProgress = {
1074
+ isOngoing: this.internalValue > this.value - this.min,
1075
+ isPositive: this.value >= this.previousValue
1076
+ };
1077
+ const backwardProgress = {
1078
+ isOngoing: this.internalValue < this.value - this.min,
1079
+ isNegative: this.value <= this.previousValue
1080
+ };
1081
+ if (forwardProgress.isOngoing && forwardProgress.isPositive ||
1082
+ backwardProgress.isOngoing && backwardProgress.isNegative) {
1083
+ return;
1084
+ }
1085
+ this.calculateProgress(this.internalValue);
1086
+ const from = this.internalValue;
1087
+ if (hasObservers(this.animationEnd)) {
1088
+ this.animationEnd.emit({
1089
+ from: from,
1090
+ to: this.internalValue
1091
+ });
1092
+ }
1093
+ // eslint-disable-next-line no-unused-expressions
1094
+ forwardProgress.isPositive ? this.internalValue += 1 : this.internalValue -= 1;
1095
+ requestAnimationFrame(this.progressbarAnimation.bind(this));
1096
+ }
1097
+ setStyles() {
1098
+ const progressArc = this.progress.nativeElement;
1099
+ const scale = this.scale.nativeElement;
1100
+ const surface = this.surface.nativeElement;
1101
+ const element = this.element.nativeElement;
1102
+ let elWidth = element.getBoundingClientRect().width;
1103
+ ;
1104
+ if (!hasElementSize(element)) {
1105
+ const surfaceSize = [
1106
+ { method: 'setStyle', el: surface, attr: 'width', attrValue: `${DEFAULT_SURFACE_SIZE}px` },
1107
+ { method: 'setStyle', el: surface, attr: 'height', attrValue: `${DEFAULT_SURFACE_SIZE}px` }
1108
+ ];
1109
+ elWidth = DEFAULT_SURFACE_SIZE;
1110
+ setProgressBarStyles(surfaceSize, this.renderer);
1111
+ }
1112
+ const attributesArray = [
1113
+ { method: 'setAttribute', el: progressArc, attr: 'r', attrValue: String((elWidth / 2) - 10) },
1114
+ { method: 'setAttribute', el: progressArc, attr: 'cx', attrValue: String((elWidth / 2)) },
1115
+ { method: 'setAttribute', el: progressArc, attr: 'cy', attrValue: String((elWidth / 2)) },
1116
+ { method: 'setAttribute', el: progressArc, attr: 'opacity', attrValue: String(this.opacity) },
1117
+ { method: 'setAttribute', el: scale, attr: 'r', attrValue: String((elWidth / 2) - 10) },
1118
+ { method: 'setAttribute', el: scale, attr: 'cx', attrValue: String(elWidth / 2) },
1119
+ { method: 'setAttribute', el: scale, attr: 'cy', attrValue: String(elWidth / 2) }
1120
+ ];
1121
+ setProgressBarStyles(attributesArray, this.renderer);
1122
+ }
1123
+ indeterminateState() {
1124
+ const progressArc = this.progress.nativeElement;
1125
+ if (this.indeterminate) {
1126
+ // the indeterminate state wont work as the `k-circular-progressbar-arc` has a transform: rotate(-90deg) which is
1127
+ // interfering with the svg animation as the animateTransform brings its own transform: rotate()
1128
+ // This will be like this until the themes release a new version, bringing a new class `k-circular-progressbar-indeterminate-arc`
1129
+ // containing only the necassery CSS styles and we will switch between them when the state of the progressbar is switched.
1130
+ this.calculateProgress(this.value - this.min);
1131
+ const rotate = this.rtl ? { from: 360, to: 0 } : { from: 0, to: 360 };
1132
+ let color;
1133
+ if (!this.progressColor) {
1134
+ color = getComputedStyle(progressArc).stroke;
1135
+ }
1136
+ const indeterminateStyles = [
1137
+ { method: 'setStyle', el: progressArc, attr: 'transform-origin', attrValue: 'center' },
1138
+ { method: 'setStyle', el: progressArc, attr: 'fill', attrValue: 'none' },
1139
+ { method: 'setStyle', el: progressArc, attr: 'stroke-linecap', attrValue: 'round' },
1140
+ { method: 'setStyle', el: progressArc, attr: 'stroke', attrValue: color ? color : this.currentColor }
1141
+ ];
1142
+ setProgressBarStyles(indeterminateStyles, this.renderer);
1143
+ this.renderer.removeClass(progressArc, 'k-circular-progressbar-arc');
1144
+ progressArc.innerHTML = `<animateTransform attributeName="transform" type="rotate" from="${rotate.from} 0 0" to="${rotate.to} 0 0" dur="1s" repeatCount="indefinite" />`;
1145
+ }
1146
+ else {
1147
+ this.renderer.addClass(progressArc, 'k-circular-progressbar-arc');
1148
+ const removeIndeterminateStyles = [
1149
+ { method: 'removeStyle', el: progressArc, attr: 'transform-origin' },
1150
+ { method: 'removeStyle', el: progressArc, attr: 'fill' },
1151
+ { method: 'removeStyle', el: progressArc, attr: 'stroke-linecap' }
1152
+ ];
1153
+ removeProgressBarStyles(removeIndeterminateStyles, this.renderer);
1154
+ progressArc.innerHTML = '';
1155
+ if (this.animation) {
1156
+ this.progressbarAnimation();
1157
+ }
1158
+ }
1159
+ }
1160
+ updateCenterTemplate(value) {
1161
+ if (!this.centerTemplate) {
1162
+ return;
1163
+ }
1164
+ this.centerTemplateContext.value = value;
1165
+ this.centerTemplateContext.color = this.currentColor;
1166
+ this.cdr.detectChanges();
1167
+ this.positionLabel();
1168
+ }
1169
+ positionLabel() {
1170
+ const labelEl = this.labelElement.nativeElement;
1171
+ const element = this.element.nativeElement;
1172
+ const surface = this.surface.nativeElement;
1173
+ let elWidth;
1174
+ let elHeight;
1175
+ if (!hasElementSize(element)) {
1176
+ const surfaceSize = surface.getBoundingClientRect();
1177
+ elWidth = surfaceSize.width;
1178
+ elHeight = surfaceSize.height;
1179
+ }
1180
+ else {
1181
+ const elementSize = element.getBoundingClientRect();
1182
+ elWidth = elementSize.width;
1183
+ elHeight = elementSize.height;
1184
+ }
1185
+ const left = (elWidth / 2) - (labelEl.offsetWidth / 2);
1186
+ const top = (elHeight / 2) - (labelEl.offsetHeight / 2);
1187
+ const labelCalculations = [
1188
+ { method: 'setStyle', el: labelEl, attr: 'left', attrValue: `${left}px` },
1189
+ { method: 'setStyle', el: labelEl, attr: 'top', attrValue: `${top}px` }
1190
+ ];
1191
+ setProgressBarStyles(labelCalculations, this.renderer);
1192
+ }
1193
+ get currentColor() {
1194
+ const currentColor = this.progress.nativeElement.style.stroke;
1195
+ return currentColor;
1196
+ }
1197
+ updateProgressColor(value) {
1198
+ const progressArc = this.progress.nativeElement;
1199
+ if (typeof this.progressColor === 'string') {
1200
+ this.renderer.setStyle(progressArc, 'stroke', this.progressColor);
1201
+ }
1202
+ else {
1203
+ for (let i = 0; i < this.progressColor.length; i++) {
1204
+ const from = this.progressColor[i].from;
1205
+ const to = this.progressColor[i].to;
1206
+ if (value >= from && value <= to || (!from && value <= to)) {
1207
+ this.renderer.setStyle(progressArc, 'stroke', this.progressColor[i].color);
1208
+ break;
1209
+ }
1210
+ if (!to && value >= from) {
1211
+ this.renderer.setStyle(progressArc, 'stroke', this.progressColor[i].color);
1212
+ }
1213
+ }
1214
+ }
1215
+ }
1216
+ handleErrors(type) {
1217
+ if (isDevMode()) {
1218
+ switch (type) {
1219
+ case 'value > max':
1220
+ throw new Error('The value of the CircularProgressbar cannot exceed the max value');
1221
+ case 'value < min':
1222
+ throw new Error('The value of the CircularProgressbar cannot be lower than the min value');
1223
+ case 'max < min':
1224
+ throw new Error('The min value cannot be higher than the max value');
1225
+ default:
1226
+ }
1227
+ }
1228
+ }
1229
+ setDirection() {
1230
+ this.rtl = this.localization.rtl;
1231
+ if (this.element) {
1232
+ this.renderer.setAttribute(this.element.nativeElement, 'dir', this.rtl ? 'rtl' : 'ltr');
1233
+ }
1234
+ if (this.labelElement) {
1235
+ this.renderer.setAttribute(this.labelElement.nativeElement, 'dir', this.rtl ? 'rtl' : 'ltr');
1236
+ }
1237
+ }
1238
+ rtlChange() {
1239
+ if (this.element && this.rtl !== this.localization.rtl) {
1240
+ this.setDirection();
1241
+ }
1242
+ }
1243
+ }
1244
+ CircularProgressBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CircularProgressBarComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i1.LocalizationService }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
1245
+ CircularProgressBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: CircularProgressBarComponent, selector: "kendo-circularprogressbar", inputs: { value: "value", max: "max", min: "min", animation: "animation", opacity: "opacity", indeterminate: "indeterminate", progressColor: "progressColor" }, outputs: { animationEnd: "animationEnd" }, host: { properties: { "class.k-circular-progressbar": "this.hostClasses", "attr.aria-valuemin": "this.ariaMinAttribute", "attr.aria-valuemax": "this.ariaMaxAttribute", "attr.aria-valuenow": "this.ariaValueAttribute", "attr.role": "this.roleAttribute" } }, providers: [
1246
+ LocalizationService,
1247
+ {
1248
+ provide: L10N_PREFIX,
1249
+ useValue: 'kendo.circularprogressbar'
1250
+ }
1251
+ ], queries: [{ propertyName: "centerTemplate", first: true, predicate: CircularProgressbarCenterTemplateDirective, descendants: true }], viewQueries: [{ propertyName: "progress", first: true, predicate: ["progress"], descendants: true }, { propertyName: "scale", first: true, predicate: ["scale"], descendants: true }, { propertyName: "labelElement", first: true, predicate: ["label"], descendants: true }, { propertyName: "surface", first: true, predicate: ["surface"], descendants: true }], exportAs: ["kendoCircularProgressBar"], usesOnChanges: true, ngImport: i0, template: `
1252
+ <ng-container kendoProgressBarLocalizedMessages
1253
+ i18n-progressBarLabel="kendo.circularprogressbar.progressBarLabel|The aria-label attribute for the Circular ProgressBar component."
1254
+ progressBarLabel="Circular progressbar"
1255
+ >
1256
+ </ng-container>
1257
+ <div #surface class="k-circular-progressbar-surface">
1258
+ <div>
1259
+ <svg #svg>
1260
+ <g>
1261
+ <circle class="k-circular-progressbar-scale" #scale stroke-width="9.5"></circle>
1262
+ <circle class="k-circular-progressbar-arc" #progress stroke-width="9.5"></circle>
1263
+ </g>
1264
+ </svg>
1265
+ <div class="k-circular-progressbar-label" *ngIf="centerTemplate" #label>
1266
+ <ng-template [ngTemplateOutlet]="centerTemplate.templateRef" [ngTemplateOutletContext]="centerTemplateContext"></ng-template>
1267
+ </div>
1268
+ </div>
1269
+ </div>
1270
+ <kendo-resize-sensor (resize)="onResize()"></kendo-resize-sensor>
1271
+ `, isInline: true, components: [{ type: i2.ResizeSensorComponent, selector: "kendo-resize-sensor", inputs: ["rateLimit"], outputs: ["resize"] }], directives: [{ type: LocalizedProgressBarMessagesDirective, selector: "[kendoProgressBarLocalizedMessages]" }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
1272
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CircularProgressBarComponent, decorators: [{
1273
+ type: Component,
1274
+ args: [{
1275
+ exportAs: 'kendoCircularProgressBar',
1276
+ selector: 'kendo-circularprogressbar',
1277
+ template: `
1278
+ <ng-container kendoProgressBarLocalizedMessages
1279
+ i18n-progressBarLabel="kendo.circularprogressbar.progressBarLabel|The aria-label attribute for the Circular ProgressBar component."
1280
+ progressBarLabel="Circular progressbar"
1281
+ >
1282
+ </ng-container>
1283
+ <div #surface class="k-circular-progressbar-surface">
1284
+ <div>
1285
+ <svg #svg>
1286
+ <g>
1287
+ <circle class="k-circular-progressbar-scale" #scale stroke-width="9.5"></circle>
1288
+ <circle class="k-circular-progressbar-arc" #progress stroke-width="9.5"></circle>
1289
+ </g>
1290
+ </svg>
1291
+ <div class="k-circular-progressbar-label" *ngIf="centerTemplate" #label>
1292
+ <ng-template [ngTemplateOutlet]="centerTemplate.templateRef" [ngTemplateOutletContext]="centerTemplateContext"></ng-template>
1293
+ </div>
1294
+ </div>
1295
+ </div>
1296
+ <kendo-resize-sensor (resize)="onResize()"></kendo-resize-sensor>
1297
+ `, providers: [
1298
+ LocalizationService,
1299
+ {
1300
+ provide: L10N_PREFIX,
1301
+ useValue: 'kendo.circularprogressbar'
1302
+ }
1303
+ ]
1304
+ }]
1305
+ }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i1.LocalizationService }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { hostClasses: [{
1306
+ type: HostBinding,
1307
+ args: ['class.k-circular-progressbar']
1308
+ }], ariaMinAttribute: [{
1309
+ type: HostBinding,
1310
+ args: ['attr.aria-valuemin']
1311
+ }], ariaMaxAttribute: [{
1312
+ type: HostBinding,
1313
+ args: ['attr.aria-valuemax']
1314
+ }], ariaValueAttribute: [{
1315
+ type: HostBinding,
1316
+ args: ['attr.aria-valuenow']
1317
+ }], roleAttribute: [{
1318
+ type: HostBinding,
1319
+ args: ['attr.role']
1320
+ }], value: [{
1321
+ type: Input
1322
+ }], max: [{
1323
+ type: Input
1324
+ }], min: [{
1325
+ type: Input
1326
+ }], animation: [{
1327
+ type: Input
1328
+ }], opacity: [{
1329
+ type: Input
1330
+ }], indeterminate: [{
1331
+ type: Input
1332
+ }], progressColor: [{
1333
+ type: Input
1334
+ }], animationEnd: [{
1335
+ type: Output
1336
+ }], progress: [{
1337
+ type: ViewChild,
1338
+ args: ['progress']
1339
+ }], scale: [{
1340
+ type: ViewChild,
1341
+ args: ['scale']
1342
+ }], labelElement: [{
1343
+ type: ViewChild,
1344
+ args: ["label"]
1345
+ }], surface: [{
1346
+ type: ViewChild,
1347
+ args: ["surface"]
1348
+ }], centerTemplate: [{
1349
+ type: ContentChild,
1350
+ args: [CircularProgressbarCenterTemplateDirective]
1351
+ }] } });
1352
+
1353
+ /**
1354
+ * Custom component messages override default component messages
1355
+ * ([see example]({% slug rtl_layout %})).
1356
+ */
1357
+ class ProgressBarCustomMessagesComponent extends ProgressBarMessages {
1358
+ constructor(service) {
1359
+ super();
1360
+ this.service = service;
1361
+ }
1362
+ get override() {
1363
+ return true;
1364
+ }
1365
+ }
1366
+ ProgressBarCustomMessagesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarCustomMessagesComponent, deps: [{ token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
1367
+ ProgressBarCustomMessagesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ProgressBarCustomMessagesComponent, selector: "kendo-progressbar-messages", providers: [
1368
+ {
1369
+ provide: ProgressBarMessages,
1370
+ useExisting: forwardRef(() => ProgressBarCustomMessagesComponent)
1371
+ }
1372
+ ], usesInheritance: true, ngImport: i0, template: ``, isInline: true });
1373
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarCustomMessagesComponent, decorators: [{
1374
+ type: Component,
1375
+ args: [{
1376
+ providers: [
1377
+ {
1378
+ provide: ProgressBarMessages,
1379
+ useExisting: forwardRef(() => ProgressBarCustomMessagesComponent)
1380
+ }
1381
+ ],
1382
+ selector: 'kendo-progressbar-messages',
1383
+ template: ``
1384
+ }]
1385
+ }], ctorParameters: function () { return [{ type: i1.LocalizationService }]; } });
1386
+
1387
+ const COMPONENT_DIRECTIVES = [
1388
+ ProgressBarComponent,
1389
+ ChunkProgressBarComponent,
1390
+ CircularProgressBarComponent,
1391
+ CircularProgressbarCenterTemplateDirective,
1392
+ LocalizedProgressBarMessagesDirective,
1393
+ ProgressBarCustomMessagesComponent
1394
+ ];
1395
+ const MODULES = [CommonModule, ResizeSensorModule];
1396
+ /**
1397
+ * Represents the [NgModule](link:site.data.urls.angular['ngmodules'])
1398
+ * definition for the ProgressBar components.
1399
+ *
1400
+ * @example
1401
+ *
1402
+ * ```ts-no-run
1403
+ * // Import the ProgressBar module
1404
+ * import { ProgressBarModule } from '@progress/kendo-angular-progressbar';
1405
+ *
1406
+ * // The browser platform with a compiler
1407
+ * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
1408
+ *
1409
+ * import { NgModule } from '@angular/core';
1410
+ *
1411
+ * // Import the app component
1412
+ * import { AppComponent } from './app.component';
1413
+ *
1414
+ * // Define the app module
1415
+ * _@NgModule({
1416
+ * declarations: [AppComponent], // declare app component
1417
+ * imports: [BrowserModule, ProgressBarModule], // import ProgressBar module
1418
+ * bootstrap: [AppComponent]
1419
+ * })
1420
+ * export class AppModule {}
1421
+ *
1422
+ * // Compile and launch the module
1423
+ * platformBrowserDynamic().bootstrapModule(AppModule);
1424
+ *
1425
+ * ```
1426
+ */
1427
+ class ProgressBarModule {
1428
+ }
1429
+ ProgressBarModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1430
+ ProgressBarModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarModule, declarations: [ProgressBarComponent,
1431
+ ChunkProgressBarComponent,
1432
+ CircularProgressBarComponent,
1433
+ CircularProgressbarCenterTemplateDirective,
1434
+ LocalizedProgressBarMessagesDirective,
1435
+ ProgressBarCustomMessagesComponent], imports: [CommonModule, ResizeSensorModule], exports: [ProgressBarComponent,
1436
+ ChunkProgressBarComponent,
1437
+ CircularProgressBarComponent,
1438
+ CircularProgressbarCenterTemplateDirective,
1439
+ LocalizedProgressBarMessagesDirective,
1440
+ ProgressBarCustomMessagesComponent] });
1441
+ ProgressBarModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarModule, imports: [MODULES] });
1442
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProgressBarModule, decorators: [{
1443
+ type: NgModule,
1444
+ args: [{
1445
+ declarations: COMPONENT_DIRECTIVES,
1446
+ exports: COMPONENT_DIRECTIVES,
1447
+ imports: MODULES
1448
+ }]
1449
+ }] });
1450
+
1451
+ /**
1452
+ * Generated bundle index. Do not edit.
1453
+ */
1454
+
1455
+ export { ChunkProgressBarComponent, CircularProgressBarComponent, CircularProgressbarCenterTemplateDirective, LocalizedProgressBarMessagesDirective, ProgressBarComponent, ProgressBarCustomMessagesComponent, ProgressBarModule };
1456
+