{"version":3,"file":"fundamental-ngx-core-progress-indicator.mjs","sources":["../../../../libs/core/progress-indicator/progress-indicator.component.ts","../../../../libs/core/progress-indicator/progress-indicator.component.html","../../../../libs/core/progress-indicator/progress-indicator.module.ts","../../../../libs/core/progress-indicator/fundamental-ngx-core-progress-indicator.ts"],"sourcesContent":["import { NgTemplateOutlet } from '@angular/common';\nimport {\n    AfterViewInit,\n    ChangeDetectionStrategy,\n    ChangeDetectorRef,\n    Component,\n    DestroyRef,\n    ElementRef,\n    Input,\n    OnChanges,\n    OnInit,\n    SimpleChanges,\n    ViewEncapsulation,\n    inject\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { resizeObservable } from '@fundamental-ngx/cdk/utils';\nimport { IconComponent } from '@fundamental-ngx/core/icon';\nimport { PopoverBodyComponent, PopoverComponent, PopoverControlComponent } from '@fundamental-ngx/core/popover';\nimport { debounceTime } from 'rxjs/operators';\n\nexport type ProgressIndicatorState = 'informative' | 'positive' | 'critical' | 'negative';\n\n@Component({\n    selector: 'fd-progress-indicator',\n    templateUrl: './progress-indicator.component.html',\n    styleUrl: './progress-indicator.component.scss',\n    encapsulation: ViewEncapsulation.None,\n    changeDetection: ChangeDetectionStrategy.OnPush,\n    imports: [NgTemplateOutlet, PopoverComponent, PopoverControlComponent, PopoverBodyComponent, IconComponent]\n})\nexport class ProgressIndicatorComponent implements OnInit, OnChanges, AfterViewInit {\n    /** The text to display if you would like to override the default percentage text. */\n    @Input()\n    valueText: string;\n\n    /** Custom unit if you would like to override the default percentage. */\n    @Input()\n    unit = '%';\n\n    /** The minimum value possible for the progress indicator. */\n    @Input()\n    valueMin = 0;\n\n    /** The maximum value possible for the progress indicator. */\n    @Input()\n    valueMax = 100;\n\n    /** The current value for the progress indicator. */\n    @Input()\n    valueNow = 0;\n\n    /** The state for the progress indicator. */\n    @Input()\n    state?: ProgressIndicatorState;\n\n    /** Whether or not to animate changes to the progress bar's valueNow. */\n    @Input()\n    animate = false;\n\n    /** @hidden */\n    hasPopover = false;\n\n    /** @hidden */\n    _progressBarWidth = 0;\n\n    /** @hidden An RxJS Subject that will kill the data stream upon component’s destruction (for unsubscribing)  */\n    private readonly _destroyRef = inject(DestroyRef);\n\n    /** @hidden */\n    constructor(\n        private _elementRef: ElementRef,\n        private _cdRef: ChangeDetectorRef\n    ) {}\n\n    /** @hidden */\n    ngOnChanges(changes: SimpleChanges): void {\n        if (changes.valueText) {\n            this._handleTruncation();\n        }\n\n        if ('valueNow' in changes || 'valueMin' in changes || 'valueMax' in changes) {\n            this._progressBarWidth = this.calculateProgressBarWidth();\n        }\n    }\n\n    /** @hidden */\n    ngOnInit(): void {\n        resizeObservable(this._elementRef.nativeElement)\n            .pipe(debounceTime(20), takeUntilDestroyed(this._destroyRef))\n            .subscribe(() => {\n                this._handleTruncation();\n            });\n    }\n\n    /** @hidden */\n    ngAfterViewInit(): void {\n        this._handleTruncation();\n    }\n\n    /** @hidden */\n    calculateProgressBarWidth(): number {\n        return ((this.valueNow - this.valueMin) / (this.valueMax - this.valueMin)) * 100;\n    }\n\n    /** @hidden */\n    private _handleTruncation(): void {\n        const labelSpan = this._elementRef.nativeElement.querySelector('.fd-progress-indicator__label');\n        this.hasPopover = labelSpan && labelSpan.offsetWidth < labelSpan.scrollWidth;\n        this._cdRef.detectChanges();\n    }\n}\n","<div\n    class=\"fd-progress-indicator\"\n    tabindex=\"-1\"\n    role=\"progressbar\"\n    [attr.aria-valuemin]=\"valueMin\"\n    [attr.aria-valuenow]=\"valueNow\"\n    [attr.aria-valuemax]=\"valueMax\"\n    [attr.aria-valuetext]=\"valueText\"\n    [attr.aria-label]=\"valueText\"\n    [class]=\"state ? 'fd-progress-indicator--' + state : ''\"\n>\n    @if (!hasPopover) {\n        @if (_progressBarWidth >= 0) {\n            <div class=\"fd-progress-indicator__container\">\n                <ng-template [ngTemplateOutlet]=\"indicatorContainer\"></ng-template>\n            </div>\n        }\n    } @else {\n        <fd-popover\n            [style.width.%]=\"100\"\n            [noArrow]=\"false\"\n            placement=\"bottom\"\n            fillControlMode=\"equal\"\n            #popover\n            class=\"fd-progress-indicator__container\"\n        >\n            @if (_progressBarWidth >= 0) {\n                <fd-popover-control>\n                    <ng-template [ngTemplateOutlet]=\"indicatorContainer\"></ng-template>\n                </fd-popover-control>\n            }\n            <fd-popover-body>\n                <div class=\"fd-popover__wrapper\">\n                    <div class=\"fd-progress-indicator__overflow\">\n                        <span>{{ valueText }}</span>\n                        <span class=\"fd-progress-indicator__overflow-close\" (click)=\"popover.close()\">\n                            <fd-icon glyph=\"decline\"></fd-icon>\n                        </span>\n                    </div>\n                </div>\n            </fd-popover-body>\n        </fd-popover>\n    }\n</div>\n<ng-template #indicatorContainer>\n    @if (_progressBarWidth > 0) {\n        <div\n            class=\"fd-progress-indicator__progress-bar\"\n            [class.fd-progress-indicator__progress-bar--animated]=\"animate\"\n            [style.min-width.%]=\"_progressBarWidth\"\n            [style.width.%]=\"_progressBarWidth\"\n        >\n            @if (_progressBarWidth > 50) {\n                <ng-template [ngTemplateOutlet]=\"progressBarLabel\"></ng-template>\n            }\n        </div>\n    }\n    <div class=\"fd-progress-indicator__remaining\" [style.min-width]=\"0\">\n        @if (_progressBarWidth <= 50) {\n            <ng-template [ngTemplateOutlet]=\"progressBarLabel\"></ng-template>\n        }\n    </div>\n</ng-template>\n<ng-template #progressBarLabel>\n    @if (state) {\n        <span class=\"fd-progress-indicator__icon\"></span>\n    }\n    @if (!valueText) {\n        <span class=\"fd-progress-indicator__label\"> {{ valueNow }}% </span>\n    } @else {\n        <span class=\"fd-progress-indicator__label\">\n            {{ valueText }}\n        </span>\n    }\n</ng-template>\n","import { NgModule } from '@angular/core';\nimport { ProgressIndicatorComponent } from './progress-indicator.component';\n\n/**\n * @deprecated\n * Use `ProgressIndicatorComponent` import instead.\n */\n@NgModule({\n    imports: [ProgressIndicatorComponent],\n    exports: [ProgressIndicatorComponent]\n})\nexport class ProgressIndicatorModule {}\n","/**\n * Generated bundle index. Do not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