@progress/kendo-angular-progressbar 17.0.0-develop.9 → 17.0.1-develop.1

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