UNPKG

@angular-mdc/web

Version:
319 lines (315 loc) 10.1 kB
/** * @license * Copyright (c) Dominic Carretto * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/trimox/angular-mdc-web/blob/master/LICENSE */ import { Component, ViewEncapsulation, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef, Input, NgModule } from '@angular/core'; import { __extends } from 'tslib'; import { Platform } from '@angular/cdk/platform'; import { coerceNumberProperty, coerceBooleanProperty } from '@angular/cdk/coercion'; import { MDCComponent } from '@angular-mdc/web/base'; import { MDCLinearProgressFoundation, strings } from '@material/linear-progress'; /** * @fileoverview added by tsickle * Generated from: linear-progress/linear-progress.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var MdcLinearProgress = /** @class */ (function (_super) { __extends(MdcLinearProgress, _super); function MdcLinearProgress(_platform, _changeDetectorRef, elementRef) { var _this = _super.call(this, elementRef) || this; _this._platform = _platform; _this._changeDetectorRef = _changeDetectorRef; _this.elementRef = elementRef; _this._initialized = false; /* Label indicating how the progress bar should be announced to the user. */ _this.label = undefined; _this._progress = 0; _this._determinate = false; _this._buffer = 0; _this._reversed = false; _this._root = _this.elementRef.nativeElement; return _this; } Object.defineProperty(MdcLinearProgress.prototype, "progress", { get: /** * @return {?} */ function () { return this._progress; }, set: /** * @param {?} value * @return {?} */ function (value) { this._progress = coerceNumberProperty(value); }, enumerable: true, configurable: true }); Object.defineProperty(MdcLinearProgress.prototype, "determinate", { get: /** * @return {?} */ function () { return this._determinate; }, set: /** * @param {?} value * @return {?} */ function (value) { this._determinate = coerceBooleanProperty(value); }, enumerable: true, configurable: true }); Object.defineProperty(MdcLinearProgress.prototype, "buffer", { get: /** * @return {?} */ function () { return this._buffer; }, set: /** * @param {?} value * @return {?} */ function (value) { this._buffer = coerceNumberProperty(value); }, enumerable: true, configurable: true }); Object.defineProperty(MdcLinearProgress.prototype, "reversed", { get: /** * @return {?} */ function () { return this._reversed; }, set: /** * @param {?} value * @return {?} */ function (value) { this._reversed = coerceBooleanProperty(value); this._syncReversedWithFoundation(); }, enumerable: true, configurable: true }); /** * @return {?} */ MdcLinearProgress.prototype.getDefaultFoundation = /** * @return {?} */ function () { var _this = this; /** @type {?} */ var adapter = { addClass: (/** * @param {?} className * @return {?} */ function (className) { return _this._root.classList.add(className); }), forceLayout: (/** * @return {?} */ function () { return ((/** @type {?} */ (_this._root))).offsetWidth; }), getPrimaryBar: (/** * @return {?} */ function () { return _this._root.querySelector(strings.PRIMARY_BAR_SELECTOR); }), getBuffer: (/** * @return {?} */ function () { return _this._root.querySelector(strings.BUFFER_SELECTOR); }), hasClass: (/** * @param {?} className * @return {?} */ function (className) { return _this._root.classList.contains(className); }), removeClass: (/** * @param {?} className * @return {?} */ function (className) { return _this._root.classList.remove(className); }), setStyle: (/** * @param {?} el * @param {?} styleProperty * @param {?} value * @return {?} */ function (el, styleProperty, value) { return el.style.setProperty(styleProperty, value); }), removeAttribute: (/** * @param {?} name * @return {?} */ function (name) { return _this._root.removeAttribute(name); }), setAttribute: (/** * @param {?} name * @param {?} value * @return {?} */ function (name, value) { return _this._root.setAttribute(name, value); }) }; return new MDCLinearProgressFoundation(adapter); }; /** * @return {?} */ MdcLinearProgress.prototype.ngOnInit = /** * @return {?} */ function () { if (this._platform.isBrowser) { this._initialized = true; this._foundation.init(); this._syncProgressWithFoundation(); this._syncBufferWithFoundation(); this._syncDeterminateWithFoundation(); this._syncReversedWithFoundation(); this._changeDetectorRef.markForCheck(); } }; /** * @param {?} changes * @return {?} */ MdcLinearProgress.prototype.ngOnChanges = /** * @param {?} changes * @return {?} */ function (changes) { if (!this._initialized) { return; } if (changes['progress']) { this._syncProgressWithFoundation(); } if (changes['buffer']) { this._syncBufferWithFoundation(); } if (changes['determinate']) { this._syncDeterminateWithFoundation(); } if (changes['reversed']) { this._syncReversedWithFoundation(); } }; /** * @return {?} */ MdcLinearProgress.prototype.open = /** * @return {?} */ function () { this._foundation.open(); }; /** * @return {?} */ MdcLinearProgress.prototype.close = /** * @return {?} */ function () { this._foundation.close(); }; /** * @private * @return {?} */ MdcLinearProgress.prototype._syncProgressWithFoundation = /** * @private * @return {?} */ function () { this._foundation.setProgress(this.progress); }; /** * @private * @return {?} */ MdcLinearProgress.prototype._syncBufferWithFoundation = /** * @private * @return {?} */ function () { this._foundation.setBuffer(this.buffer); }; /** * @private * @return {?} */ MdcLinearProgress.prototype._syncDeterminateWithFoundation = /** * @private * @return {?} */ function () { this._foundation.setDeterminate(this.determinate); }; /** * @private * @return {?} */ MdcLinearProgress.prototype._syncReversedWithFoundation = /** * @private * @return {?} */ function () { this._foundation.setReverse(this.reversed); }; MdcLinearProgress.decorators = [ { type: Component, args: [{selector: 'mdc-linear-progress', exportAs: 'mdcLinearProgress', host: { 'role': 'progressbar', 'class': 'mdc-linear-progress', '[class.mdc-linear-progress--indeterminate]': '!determinate', '[attr.aria-label]': 'label', 'aria-valuemin': '0', 'aria-valuemax': '100' }, template: "\n <div class=\"mdc-linear-progress__buffering-dots\"></div>\n <div class=\"mdc-linear-progress__buffer\"></div>\n <div class=\"mdc-linear-progress__bar mdc-linear-progress__primary-bar\">\n <span class=\"mdc-linear-progress__bar-inner\"></span>\n </div>\n <div class=\"mdc-linear-progress__bar mdc-linear-progress__secondary-bar\">\n <span class=\"mdc-linear-progress__bar-inner\"></span>\n </div>", encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush },] }, ]; /** @nocollapse */ MdcLinearProgress.ctorParameters = function () { return [ { type: Platform }, { type: ChangeDetectorRef }, { type: ElementRef } ]; }; MdcLinearProgress.propDecorators = { label: [{ type: Input }], progress: [{ type: Input }], determinate: [{ type: Input }], buffer: [{ type: Input }], reversed: [{ type: Input }] }; return MdcLinearProgress; }(MDCComponent)); /** * @fileoverview added by tsickle * Generated from: linear-progress/module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var MdcLinearProgressModule = /** @class */ (function () { function MdcLinearProgressModule() { } MdcLinearProgressModule.decorators = [ { type: NgModule, args: [{ exports: [MdcLinearProgress], declarations: [MdcLinearProgress] },] }, ]; return MdcLinearProgressModule; }()); export { MdcLinearProgress, MdcLinearProgressModule }; //# sourceMappingURL=linear-progress.es5.js.map