@angular-mdc/web
Version:
363 lines (349 loc) • 12.9 kB
JavaScript
/**
* @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
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/cdk/platform'), require('@angular/cdk/coercion'), require('@angular-mdc/web/base'), require('@material/linear-progress')) :
typeof define === 'function' && define.amd ? define('@angular-mdc/web/linear-progress', ['exports', '@angular/core', '@angular/cdk/platform', '@angular/cdk/coercion', '@angular-mdc/web/base', '@material/linear-progress'], factory) :
(global = global || self, factory((global.ng = global.ng || {}, global.ng.web = global.ng.web || {}, global.ng.web.linearProgress = {}), global.ng.core, global.ng.cdk.platform, global.ng.cdk.coercion, global.ng.web.base, global.mdc.linearProgress));
}(this, (function (exports, core, platform, coercion, base, linearProgress) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var _extendStatics = function extendStatics(d, b) {
_extendStatics = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) {
if (b.hasOwnProperty(p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
function __extends(d, b) {
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
/**
* @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 = coercion.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 = coercion.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 = coercion.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 = coercion.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(linearProgress.strings.PRIMARY_BAR_SELECTOR); }),
getBuffer: (/**
* @return {?}
*/
function () { return _this._root.querySelector(linearProgress.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 linearProgress.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: core.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: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush
},] },
];
/** @nocollapse */
MdcLinearProgress.ctorParameters = function () { return [
{ type: platform.Platform },
{ type: core.ChangeDetectorRef },
{ type: core.ElementRef }
]; };
MdcLinearProgress.propDecorators = {
label: [{ type: core.Input }],
progress: [{ type: core.Input }],
determinate: [{ type: core.Input }],
buffer: [{ type: core.Input }],
reversed: [{ type: core.Input }]
};
return MdcLinearProgress;
}(base.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: core.NgModule, args: [{
exports: [MdcLinearProgress],
declarations: [MdcLinearProgress]
},] },
];
return MdcLinearProgressModule;
}());
exports.MdcLinearProgress = MdcLinearProgress;
exports.MdcLinearProgressModule = MdcLinearProgressModule;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=web-linear-progress.umd.js.map