UNPKG

@angular/material

Version:
1 lines 15.6 kB
{"version":3,"file":"progress-spinner.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/progress-spinner/progress-spinner.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/progress-spinner/progress-spinner.html","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/progress-spinner/progress-spinner-module.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n Component,\n ElementRef,\n InjectionToken,\n Input,\n ViewChild,\n ViewEncapsulation,\n numberAttribute,\n inject,\n} from '@angular/core';\nimport {_getAnimationsState, ThemePalette} from '../core';\nimport {NgTemplateOutlet} from '@angular/common';\n\n/** Possible mode for a progress spinner. */\nexport type ProgressSpinnerMode = 'determinate' | 'indeterminate';\n\n/** Default `mat-progress-spinner` options that can be overridden. */\nexport interface MatProgressSpinnerDefaultOptions {\n /**\n * Default theme color of the progress spinner. This API is supported in M2 themes only, it\n * has no effect in M3 themes. For color customization in M3, see https://material.angular.dev/components/progress-spinner/styling.\n *\n * For information on applying color variants in M3, see\n * https://material.angular.dev/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants\n */\n color?: ThemePalette;\n /** Diameter of the spinner. */\n diameter?: number;\n /** Width of the spinner's stroke. */\n strokeWidth?: number;\n /**\n * Whether the animations should be force to be enabled, ignoring if the current environment\n * disables them.\n */\n _forceAnimations?: boolean;\n}\n\n/** Injection token to be used to override the default options for `mat-progress-spinner`. */\nexport const MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS =\n new InjectionToken<MatProgressSpinnerDefaultOptions>('mat-progress-spinner-default-options', {\n providedIn: 'root',\n factory: () => ({diameter: BASE_SIZE}),\n });\n\n/**\n * Base reference size of the spinner.\n */\nconst BASE_SIZE = 100;\n\n/**\n * Base reference stroke width of the spinner.\n */\nconst BASE_STROKE_WIDTH = 10;\n\n@Component({\n selector: 'mat-progress-spinner, mat-spinner',\n exportAs: 'matProgressSpinner',\n host: {\n 'role': 'progressbar',\n 'class': 'mat-mdc-progress-spinner mdc-circular-progress',\n // set tab index to -1 so screen readers will read the aria-label\n // Note: there is a known issue with JAWS that does not read progressbar aria labels on FireFox\n 'tabindex': '-1',\n '[class]': '\"mat-\" + color',\n '[class._mat-animation-noopable]': `_noopAnimations`,\n '[class.mdc-circular-progress--indeterminate]': 'mode === \"indeterminate\"',\n '[style.width.px]': 'diameter',\n '[style.height.px]': 'diameter',\n '[style.--mat-progress-spinner-size]': 'diameter + \"px\"',\n '[style.--mat-progress-spinner-active-indicator-width]': 'diameter + \"px\"',\n '[attr.aria-valuemin]': '0',\n '[attr.aria-valuemax]': '100',\n '[attr.aria-valuenow]': 'mode === \"determinate\" ? value : null',\n '[attr.mode]': 'mode',\n },\n templateUrl: 'progress-spinner.html',\n styleUrl: 'progress-spinner.css',\n encapsulation: ViewEncapsulation.None,\n imports: [NgTemplateOutlet],\n})\nexport class MatProgressSpinner {\n readonly _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /** Whether the _mat-animation-noopable class should be applied, disabling animations. */\n _noopAnimations: boolean;\n\n // TODO: should be typed as `ThemePalette` but internal apps pass in arbitrary strings.\n /**\n * Theme color of the progress spinner. This API is supported in M2 themes only, it\n * has no effect in M3 themes. For color customization in M3, see https://material.angular.dev/components/progress-spinner/styling.\n *\n * For information on applying color variants in M3, see\n * https://material.angular.dev/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants\n */\n @Input()\n get color() {\n return this._color || this._defaultColor;\n }\n set color(value: string | null | undefined) {\n this._color = value;\n }\n private _color: string | null | undefined;\n private _defaultColor: ThemePalette = 'primary';\n\n /** The element of the determinate spinner. */\n @ViewChild('determinateSpinner') _determinateCircle!: ElementRef<HTMLElement>;\n\n constructor() {\n const defaults = inject<MatProgressSpinnerDefaultOptions>(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS);\n const animationsState = _getAnimationsState();\n const element = this._elementRef.nativeElement;\n\n this._noopAnimations =\n animationsState === 'di-disabled' && !!defaults && !defaults._forceAnimations;\n this.mode = element.nodeName.toLowerCase() === 'mat-spinner' ? 'indeterminate' : 'determinate';\n\n if (!this._noopAnimations && animationsState === 'reduced-motion') {\n element.classList.add('mat-progress-spinner-reduced-motion');\n }\n\n if (defaults) {\n if (defaults.color) {\n this.color = this._defaultColor = defaults.color;\n }\n\n if (defaults.diameter) {\n this.diameter = defaults.diameter;\n }\n\n if (defaults.strokeWidth) {\n this.strokeWidth = defaults.strokeWidth;\n }\n }\n }\n\n /**\n * Mode of the progress bar.\n *\n * Input must be one of these values: determinate, indeterminate, buffer, query, defaults to\n * 'determinate'.\n * Mirrored to mode attribute.\n */\n @Input() mode: ProgressSpinnerMode;\n\n /** Value of the progress bar. Defaults to zero. Mirrored to aria-valuenow. */\n @Input({transform: numberAttribute})\n get value(): number {\n return this.mode === 'determinate' ? this._value : 0;\n }\n set value(v: number) {\n this._value = Math.max(0, Math.min(100, v || 0));\n }\n private _value = 0;\n\n /** The diameter of the progress spinner (will set width and height of svg). */\n @Input({transform: numberAttribute})\n get diameter(): number {\n return this._diameter;\n }\n set diameter(size: number) {\n this._diameter = size || 0;\n }\n private _diameter = BASE_SIZE;\n\n /** Stroke width of the progress spinner. */\n @Input({transform: numberAttribute})\n get strokeWidth(): number {\n return this._strokeWidth ?? this.diameter / 10;\n }\n set strokeWidth(value: number) {\n this._strokeWidth = value || 0;\n }\n private _strokeWidth!: number;\n\n /** The radius of the spinner, adjusted for stroke width. */\n _circleRadius(): number {\n return (this.diameter - BASE_STROKE_WIDTH) / 2;\n }\n\n /** The view box of the spinner's svg element. */\n _viewBox() {\n const viewBox = this._circleRadius() * 2 + this.strokeWidth;\n return `0 0 ${viewBox} ${viewBox}`;\n }\n\n /** The stroke circumference of the svg circle. */\n _strokeCircumference(): number {\n return 2 * Math.PI * this._circleRadius();\n }\n\n /** The dash offset of the svg circle. */\n _strokeDashOffset() {\n if (this.mode === 'determinate') {\n return (this._strokeCircumference() * (100 - this._value)) / 100;\n }\n return null;\n }\n\n /** Stroke width of the circle in percent. */\n _circleStrokeWidth() {\n return (this.strokeWidth / this.diameter) * 100;\n }\n}\n\n/**\n * @deprecated Import Progress Spinner instead. Note that the\n * `mat-spinner` selector isn't deprecated.\n * @breaking-change 16.0.0\n */\n// tslint:disable-next-line:variable-name\nexport const MatSpinner = MatProgressSpinner;\n","<ng-template #circle>\n <svg [attr.viewBox]=\"_viewBox()\" class=\"mdc-circular-progress__indeterminate-circle-graphic\"\n xmlns=\"http://www.w3.org/2000/svg\" focusable=\"false\">\n <circle [attr.r]=\"_circleRadius()\"\n [style.stroke-dasharray.px]=\"_strokeCircumference()\"\n [style.stroke-dashoffset.px]=\"_strokeCircumference() / 2\"\n [style.stroke-width.%]=\"_circleStrokeWidth()\"\n cx=\"50%\" cy=\"50%\"/>\n </svg>\n</ng-template>\n\n<!--\n All children need to be hidden for screen readers in order to support ChromeVox.\n More context in the issue: https://github.com/angular/components/issues/22165.\n-->\n<div class=\"mdc-circular-progress__determinate-container\" aria-hidden=\"true\" #determinateSpinner>\n <svg [attr.viewBox]=\"_viewBox()\" class=\"mdc-circular-progress__determinate-circle-graphic\"\n xmlns=\"http://www.w3.org/2000/svg\" focusable=\"false\">\n <circle [attr.r]=\"_circleRadius()\"\n [style.stroke-dasharray.px]=\"_strokeCircumference()\"\n [style.stroke-dashoffset.px]=\"_strokeDashOffset()\"\n [style.stroke-width.%]=\"_circleStrokeWidth()\"\n class=\"mdc-circular-progress__determinate-circle\"\n cx=\"50%\" cy=\"50%\"/>\n </svg>\n</div>\n<!--TODO: figure out why there are 3 separate svgs-->\n<div class=\"mdc-circular-progress__indeterminate-container\" aria-hidden=\"true\">\n <div class=\"mdc-circular-progress__spinner-layer\">\n <div class=\"mdc-circular-progress__circle-clipper mdc-circular-progress__circle-left\">\n <ng-container [ngTemplateOutlet]=\"circle\"></ng-container>\n </div>\n <div class=\"mdc-circular-progress__gap-patch\">\n <ng-container [ngTemplateOutlet]=\"circle\"></ng-container>\n </div>\n <div class=\"mdc-circular-progress__circle-clipper mdc-circular-progress__circle-right\">\n <ng-container [ngTemplateOutlet]=\"circle\"></ng-container>\n </div>\n </div>\n</div>\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {BidiModule} from '@angular/cdk/bidi';\nimport {NgModule} from '@angular/core';\nimport {MatProgressSpinner, MatSpinner} from './progress-spinner';\n\n@NgModule({\n imports: [MatProgressSpinner, MatSpinner],\n exports: [MatProgressSpinner, MatSpinner, BidiModule],\n})\nexport class MatProgressSpinnerModule {}\n"],"names":[],"mappings":";;;;;;;MA8Ca,oCAAoC,GAC/C,IAAI,cAAc,CAAmC,sCAAsC,EAAE;AAC3F,EAAA,UAAU,EAAE,MAAM;AAClB,EAAA,OAAO,EAAE,OAAO;AAAC,IAAA,QAAQ,EAAE;GAAU;AACtC,CAAA;AAKH,MAAM,SAAS,GAAG,GAAG;AAKrB,MAAM,iBAAiB,GAAG,EAAE;MA4Bf,kBAAkB,CAAA;AACpB,EAAA,WAAW,GAAG,MAAM,CAA0B,UAAU,CAAC;EAGlE,eAAe;AAUf,EAAA,IACI,KAAK,GAAA;AACP,IAAA,OAAO,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,aAAa;AAC1C,EAAA;EACA,IAAI,KAAK,CAAC,KAAgC,EAAA;IACxC,IAAI,CAAC,MAAM,GAAG,KAAK;AACrB,EAAA;EACQ,MAAM;AACN,EAAA,aAAa,GAAiB,SAAS;EAGd,kBAAkB;AAEnD,EAAA,WAAA,GAAA;AACE,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAmC,oCAAoC,CAAC;AAC/F,IAAA,MAAM,eAAe,GAAG,mBAAmB,EAAE;AAC7C,IAAA,MAAM,O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