File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/node_modules/@material/tab/foundation.js
/**
* @license
* Copyright 2018 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import { __assign, __extends } from "tslib";
import { MDCFoundation } from '@material/base/foundation';
import { cssClasses, strings } from './constants';
/** MDC Tab Foundation */
var MDCTabFoundation = /** @class */ (function (_super) {
__extends(MDCTabFoundation, _super);
function MDCTabFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCTabFoundation.defaultAdapter), adapter)) || this;
_this.focusOnActivate = true;
return _this;
}
Object.defineProperty(MDCTabFoundation, "cssClasses", {
get: function () {
return cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTabFoundation, "strings", {
get: function () {
return strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTabFoundation, "defaultAdapter", {
get: function () {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function () { return undefined; },
removeClass: function () { return undefined; },
hasClass: function () { return false; },
setAttr: function () { return undefined; },
activateIndicator: function () { return undefined; },
deactivateIndicator: function () { return undefined; },
notifyInteracted: function () { return undefined; },
getOffsetLeft: function () { return 0; },
getOffsetWidth: function () { return 0; },
getContentOffsetLeft: function () { return 0; },
getContentOffsetWidth: function () { return 0; },
focus: function () { return undefined; },
isFocused: function () { return false; },
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCTabFoundation.prototype.handleClick = function () {
// It's up to the parent component to keep track of the active Tab and
// ensure we don't activate a Tab that's already active.
this.adapter.notifyInteracted();
};
MDCTabFoundation.prototype.isActive = function () {
return this.adapter.hasClass(cssClasses.ACTIVE);
};
/**
* Sets whether the tab should focus itself when activated
*/
MDCTabFoundation.prototype.setFocusOnActivate = function (focusOnActivate) {
this.focusOnActivate = focusOnActivate;
};
/**
* Activates the Tab
*/
MDCTabFoundation.prototype.activate = function (previousIndicatorClientRect) {
this.adapter.addClass(cssClasses.ACTIVE);
this.adapter.setAttr(strings.ARIA_SELECTED, 'true');
this.adapter.setAttr(strings.TABINDEX, '0');
this.adapter.activateIndicator(previousIndicatorClientRect);
if (this.focusOnActivate && !this.adapter.isFocused()) {
this.adapter.focus();
}
};
/**
* Deactivates the Tab
*/
MDCTabFoundation.prototype.deactivate = function () {
// Early exit
if (!this.isActive()) {
return;
}
this.adapter.removeClass(cssClasses.ACTIVE);
this.adapter.setAttr(strings.ARIA_SELECTED, 'false');
this.adapter.setAttr(strings.TABINDEX, '-1');
this.adapter.deactivateIndicator();
};
/**
* Returns the dimensions of the Tab
*/
MDCTabFoundation.prototype.computeDimensions = function () {
var rootWidth = this.adapter.getOffsetWidth();
var rootLeft = this.adapter.getOffsetLeft();
var contentWidth = this.adapter.getContentOffsetWidth();
var contentLeft = this.adapter.getContentOffsetLeft();
return {
contentLeft: rootLeft + contentLeft,
contentRight: rootLeft + contentLeft + contentWidth,
rootLeft: rootLeft,
rootRight: rootLeft + rootWidth,
};
};
return MDCTabFoundation;
}(MDCFoundation));
export { MDCTabFoundation };
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
export default MDCTabFoundation;
//# sourceMappingURL=foundation.js.map