material-components-web
Version:
Modular and customizable Material Design UI components for the web
33,544 lines • 1.48 MB
JavaScript
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("material-components-web", [], factory);
else if(typeof exports === 'object')
exports["mdc"] = factory();
else
root["mdc"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./packages/material-components-web/index.ts");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./packages/material-components-web/index.ts":
/*!***************************************************!*\
!*** ./packages/material-components-web/index.ts ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.topAppBar = exports.tooltip = exports.textField = exports.tabScroller = exports.tabIndicator = exports.tabBar = exports.tab = exports.switchControl = exports.snackbar = exports.slider = exports.select = exports.segmentedButton = exports.ripple = exports.radio = exports.notchedOutline = exports.menuSurface = exports.menu = exports.list = exports.linearProgress = exports.lineRipple = exports.iconButton = exports.formField = exports.floatingLabel = exports.drawer = exports.dom = exports.dialog = exports.dataTable = exports.circularProgress = exports.chips = exports.checkbox = exports.base = exports.banner = exports.autoInit = void 0;
var index_1 = __importDefault(__webpack_require__(/*! @material/auto-init/index */ "./packages/mdc-auto-init/index.ts"));
exports.autoInit = index_1.default;
var banner = __importStar(__webpack_require__(/*! @material/banner/index */ "./packages/mdc-banner/index.ts"));
exports.banner = banner;
var base = __importStar(__webpack_require__(/*! @material/base/index */ "./packages/mdc-base/index.ts"));
exports.base = base;
var checkbox = __importStar(__webpack_require__(/*! @material/checkbox/index */ "./packages/mdc-checkbox/index.ts"));
exports.checkbox = checkbox;
var chips = __importStar(__webpack_require__(/*! @material/chips/deprecated/index */ "./packages/mdc-chips/deprecated/index.ts"));
exports.chips = chips;
var circularProgress = __importStar(__webpack_require__(/*! @material/circular-progress/index */ "./packages/mdc-circular-progress/index.ts"));
exports.circularProgress = circularProgress;
var dataTable = __importStar(__webpack_require__(/*! @material/data-table/index */ "./packages/mdc-data-table/index.ts"));
exports.dataTable = dataTable;
var dialog = __importStar(__webpack_require__(/*! @material/dialog/index */ "./packages/mdc-dialog/index.ts"));
exports.dialog = dialog;
var dom = __importStar(__webpack_require__(/*! @material/dom/index */ "./packages/mdc-dom/index.ts"));
exports.dom = dom;
var drawer = __importStar(__webpack_require__(/*! @material/drawer/index */ "./packages/mdc-drawer/index.ts"));
exports.drawer = drawer;
var floatingLabel = __importStar(__webpack_require__(/*! @material/floating-label/index */ "./packages/mdc-floating-label/index.ts"));
exports.floatingLabel = floatingLabel;
var formField = __importStar(__webpack_require__(/*! @material/form-field/index */ "./packages/mdc-form-field/index.ts"));
exports.formField = formField;
var iconButton = __importStar(__webpack_require__(/*! @material/icon-button/index */ "./packages/mdc-icon-button/index.ts"));
exports.iconButton = iconButton;
var lineRipple = __importStar(__webpack_require__(/*! @material/line-ripple/index */ "./packages/mdc-line-ripple/index.ts"));
exports.lineRipple = lineRipple;
var linearProgress = __importStar(__webpack_require__(/*! @material/linear-progress/index */ "./packages/mdc-linear-progress/index.ts"));
exports.linearProgress = linearProgress;
var list = __importStar(__webpack_require__(/*! @material/list/index */ "./packages/mdc-list/index.ts"));
exports.list = list;
var menuSurface = __importStar(__webpack_require__(/*! @material/menu-surface/index */ "./packages/mdc-menu-surface/index.ts"));
exports.menuSurface = menuSurface;
var menu = __importStar(__webpack_require__(/*! @material/menu/index */ "./packages/mdc-menu/index.ts"));
exports.menu = menu;
var notchedOutline = __importStar(__webpack_require__(/*! @material/notched-outline/index */ "./packages/mdc-notched-outline/index.ts"));
exports.notchedOutline = notchedOutline;
var radio = __importStar(__webpack_require__(/*! @material/radio/index */ "./packages/mdc-radio/index.ts"));
exports.radio = radio;
var ripple = __importStar(__webpack_require__(/*! @material/ripple/index */ "./packages/mdc-ripple/index.ts"));
exports.ripple = ripple;
var segmentedButton = __importStar(__webpack_require__(/*! @material/segmented-button/index */ "./packages/mdc-segmented-button/index.ts"));
exports.segmentedButton = segmentedButton;
var select = __importStar(__webpack_require__(/*! @material/select/index */ "./packages/mdc-select/index.ts"));
exports.select = select;
var slider = __importStar(__webpack_require__(/*! @material/slider/index */ "./packages/mdc-slider/index.ts"));
exports.slider = slider;
var snackbar = __importStar(__webpack_require__(/*! @material/snackbar/index */ "./packages/mdc-snackbar/index.ts"));
exports.snackbar = snackbar;
var switchControl = __importStar(__webpack_require__(/*! @material/switch/index */ "./packages/mdc-switch/index.ts"));
exports.switchControl = switchControl;
var tabBar = __importStar(__webpack_require__(/*! @material/tab-bar/index */ "./packages/mdc-tab-bar/index.ts"));
exports.tabBar = tabBar;
var tabIndicator = __importStar(__webpack_require__(/*! @material/tab-indicator/index */ "./packages/mdc-tab-indicator/index.ts"));
exports.tabIndicator = tabIndicator;
var tabScroller = __importStar(__webpack_require__(/*! @material/tab-scroller/index */ "./packages/mdc-tab-scroller/index.ts"));
exports.tabScroller = tabScroller;
var tab = __importStar(__webpack_require__(/*! @material/tab/index */ "./packages/mdc-tab/index.ts"));
exports.tab = tab;
var textField = __importStar(__webpack_require__(/*! @material/textfield/index */ "./packages/mdc-textfield/index.ts"));
exports.textField = textField;
var tooltip = __importStar(__webpack_require__(/*! @material/tooltip/index */ "./packages/mdc-tooltip/index.ts"));
exports.tooltip = tooltip;
var topAppBar = __importStar(__webpack_require__(/*! @material/top-app-bar/index */ "./packages/mdc-top-app-bar/index.ts"));
exports.topAppBar = topAppBar;
// Register all components
index_1.default.register('MDCBanner', banner.MDCBanner);
index_1.default.register('MDCCheckbox', checkbox.MDCCheckbox);
index_1.default.register('MDCChip', chips.MDCChip);
index_1.default.register('MDCChipSet', chips.MDCChipSet);
index_1.default.register('MDCCircularProgress', circularProgress.MDCCircularProgress);
index_1.default.register('MDCDataTable', dataTable.MDCDataTable);
index_1.default.register('MDCDialog', dialog.MDCDialog);
index_1.default.register('MDCDrawer', drawer.MDCDrawer);
index_1.default.register('MDCFloatingLabel', floatingLabel.MDCFloatingLabel);
index_1.default.register('MDCFormField', formField.MDCFormField);
index_1.default.register('MDCIconButtonToggle', iconButton.MDCIconButtonToggle);
index_1.default.register('MDCLineRipple', lineRipple.MDCLineRipple);
index_1.default.register('MDCLinearProgress', linearProgress.MDCLinearProgress);
index_1.default.register('MDCList', list.MDCList);
index_1.default.register('MDCMenu', menu.MDCMenu);
index_1.default.register('MDCMenuSurface', menuSurface.MDCMenuSurface);
index_1.default.register('MDCNotchedOutline', notchedOutline.MDCNotchedOutline);
index_1.default.register('MDCRadio', radio.MDCRadio);
index_1.default.register('MDCRipple', ripple.MDCRipple);
index_1.default.register('MDCSegmentedButton', segmentedButton.MDCSegmentedButton);
index_1.default.register('MDCSelect', select.MDCSelect);
index_1.default.register('MDCSlider', slider.MDCSlider);
index_1.default.register('MDCSnackbar', snackbar.MDCSnackbar);
index_1.default.register('MDCSwitch', switchControl.MDCSwitch);
index_1.default.register('MDCTabBar', tabBar.MDCTabBar);
index_1.default.register('MDCTextField', textField.MDCTextField);
index_1.default.register('MDCTooltip', tooltip.MDCTooltip);
index_1.default.register('MDCTopAppBar', topAppBar.MDCTopAppBar);
/***/ }),
/***/ "./packages/mdc-animation/animationframe.ts":
/*!**************************************************!*\
!*** ./packages/mdc-animation/animationframe.ts ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.AnimationFrame = void 0;
/**
* AnimationFrame provides a user-friendly abstraction around requesting
* and canceling animation frames.
*/
var AnimationFrame = /** @class */function () {
function AnimationFrame() {
this.rafIDs = new Map();
}
/**
* Requests an animation frame. Cancels any existing frame with the same key.
* @param {string} key The key for this callback.
* @param {FrameRequestCallback} callback The callback to be executed.
*/
AnimationFrame.prototype.request = function (key, callback) {
var _this = this;
this.cancel(key);
var frameID = requestAnimationFrame(function (frame) {
_this.rafIDs.delete(key);
// Callback must come *after* the key is deleted so that nested calls to
// request with the same key are not deleted.
callback(frame);
});
this.rafIDs.set(key, frameID);
};
/**
* Cancels a queued callback with the given key.
* @param {string} key The key for this callback.
*/
AnimationFrame.prototype.cancel = function (key) {
var rafID = this.rafIDs.get(key);
if (rafID) {
cancelAnimationFrame(rafID);
this.rafIDs.delete(key);
}
};
/**
* Cancels all queued callback.
*/
AnimationFrame.prototype.cancelAll = function () {
var _this = this;
// Need to use forEach because it's the only iteration method supported
// by IE11. Suppress the underscore because we don't need it.
// tslint:disable-next-line:enforce-name-casing
this.rafIDs.forEach(function (_, key) {
_this.cancel(key);
});
};
/**
* Returns the queue of unexecuted callback keys.
*/
AnimationFrame.prototype.getQueue = function () {
var queue = [];
// Need to use forEach because it's the only iteration method supported
// by IE11. Suppress the underscore because we don't need it.
// tslint:disable-next-line:enforce-name-casing
this.rafIDs.forEach(function (_, key) {
queue.push(key);
});
return queue;
};
return AnimationFrame;
}();
exports.AnimationFrame = AnimationFrame;
/***/ }),
/***/ "./packages/mdc-animation/util.ts":
/*!****************************************!*\
!*** ./packages/mdc-animation/util.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCorrectEventName = exports.getCorrectPropertyName = void 0;
var cssPropertyNameMap = {
animation: {
prefixed: '-webkit-animation',
standard: 'animation'
},
transform: {
prefixed: '-webkit-transform',
standard: 'transform'
},
transition: {
prefixed: '-webkit-transition',
standard: 'transition'
}
};
var jsEventTypeMap = {
animationend: {
cssProperty: 'animation',
prefixed: 'webkitAnimationEnd',
standard: 'animationend'
},
animationiteration: {
cssProperty: 'animation',
prefixed: 'webkitAnimationIteration',
standard: 'animationiteration'
},
animationstart: {
cssProperty: 'animation',
prefixed: 'webkitAnimationStart',
standard: 'animationstart'
},
transitionend: {
cssProperty: 'transition',
prefixed: 'webkitTransitionEnd',
standard: 'transitionend'
}
};
function isWindow(windowObj) {
return Boolean(windowObj.document) && typeof windowObj.document.createElement === 'function';
}
function getCorrectPropertyName(windowObj, cssProperty) {
if (isWindow(windowObj) && cssProperty in cssPropertyNameMap) {
var el = windowObj.document.createElement('div');
var _a = cssPropertyNameMap[cssProperty],
standard = _a.standard,
prefixed = _a.prefixed;
var isStandard = standard in el.style;
return isStandard ? standard : prefixed;
}
return cssProperty;
}
exports.getCorrectPropertyName = getCorrectPropertyName;
function getCorrectEventName(windowObj, eventType) {
if (isWindow(windowObj) && eventType in jsEventTypeMap) {
var el = windowObj.document.createElement('div');
var _a = jsEventTypeMap[eventType],
standard = _a.standard,
prefixed = _a.prefixed,
cssProperty = _a.cssProperty;
var isStandard = cssProperty in el.style;
return isStandard ? standard : prefixed;
}
return eventType;
}
exports.getCorrectEventName = getCorrectEventName;
/***/ }),
/***/ "./packages/mdc-auto-init/constants.ts":
/*!*********************************************!*\
!*** ./packages/mdc-auto-init/constants.ts ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = void 0;
exports.strings = {
AUTO_INIT_ATTR: 'data-mdc-auto-init',
AUTO_INIT_STATE_ATTR: 'data-mdc-auto-init-state',
INITIALIZED_STATE: 'initialized'
};
/***/ }),
/***/ "./packages/mdc-auto-init/index.ts":
/*!*****************************************!*\
!*** ./packages/mdc-auto-init/index.ts ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.mdcAutoInit = void 0;
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-auto-init/constants.ts");
var AUTO_INIT_ATTR = constants_1.strings.AUTO_INIT_ATTR,
AUTO_INIT_STATE_ATTR = constants_1.strings.AUTO_INIT_STATE_ATTR,
INITIALIZED_STATE = constants_1.strings.INITIALIZED_STATE;
var registry = {};
var CONSOLE_WARN = console.warn.bind(console); // tslint:disable-line:no-console
function emit(evtType, evtData, shouldBubble) {
if (shouldBubble === void 0) {
shouldBubble = false;
}
var evt;
if (typeof CustomEvent === 'function') {
evt = new CustomEvent(evtType, {
bubbles: shouldBubble,
detail: evtData
});
} else {
evt = document.createEvent('CustomEvent');
evt.initCustomEvent(evtType, shouldBubble, false, evtData);
}
document.dispatchEvent(evt);
}
/* istanbul ignore next: optional argument is not a branch statement */
/**
* Auto-initializes all MDC components on a page.
*/
function mdcAutoInit(root) {
var e_1, _a;
if (root === void 0) {
root = document;
}
var components = [];
var nodes = [].slice.call(root.querySelectorAll("[" + AUTO_INIT_ATTR + "]"));
nodes = nodes.filter(function (node) {
return node.getAttribute(AUTO_INIT_STATE_ATTR) !== INITIALIZED_STATE;
});
try {
for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
var node = nodes_1_1.value;
var ctorName = node.getAttribute(AUTO_INIT_ATTR);
if (!ctorName) {
throw new Error('(mdc-auto-init) Constructor name must be given.');
}
var Constructor = registry[ctorName]; // tslint:disable-line:variable-name
if (typeof Constructor !== 'function') {
throw new Error("(mdc-auto-init) Could not find constructor in registry for " + ctorName);
}
// TODO: Should we make an eslint rule for an attachTo() static method?
// See https://github.com/Microsoft/TypeScript/issues/14600 for discussion of static interface support in TS
var component = Constructor.attachTo(node);
Object.defineProperty(node, ctorName, {
configurable: true,
enumerable: false,
value: component,
writable: false
});
components.push(component);
node.setAttribute(AUTO_INIT_STATE_ATTR, INITIALIZED_STATE);
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
} finally {
if (e_1) throw e_1.error;
}
}
emit('MDCAutoInit:End', {});
return components;
}
exports.mdcAutoInit = mdcAutoInit;
// Constructor is PascalCased because it is a direct reference to a class, rather than an instance of a class.
// tslint:disable-next-line:variable-name
mdcAutoInit.register = function (componentName, Constructor, warn) {
if (warn === void 0) {
warn = CONSOLE_WARN;
}
if (typeof Constructor !== 'function') {
throw new Error("(mdc-auto-init) Invalid Constructor value: " + Constructor + ". Expected function.");
}
var registryValue = registry[componentName];
if (registryValue) {
warn("(mdc-auto-init) Overriding registration for " + componentName + " with " + Constructor + ". Was: " + registryValue);
}
registry[componentName] = Constructor;
};
mdcAutoInit.deregister = function (componentName) {
delete registry[componentName];
};
/** @nocollapse */
mdcAutoInit.deregisterAll = function () {
var e_2, _a;
try {
for (var _b = __values(Object.keys(registry)), _c = _b.next(); !_c.done; _c = _b.next()) {
var componentName = _c.value;
mdcAutoInit.deregister(componentName);
}
} catch (e_2_1) {
e_2 = { error: e_2_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_2) throw e_2.error;
}
}
};
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = mdcAutoInit;
/***/ }),
/***/ "./packages/mdc-banner/adapter.ts":
/*!****************************************!*\
!*** ./packages/mdc-banner/adapter.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-banner/component.ts":
/*!******************************************!*\
!*** ./packages/mdc-banner/component.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCBanner = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-banner/constants.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-banner/foundation.ts");
/** Vanilla JS implementation of banner component. */
var MDCBanner = /** @class */function (_super) {
__extends(MDCBanner, _super);
function MDCBanner() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCBanner.attachTo = function (root) {
return new MDCBanner(root);
};
MDCBanner.prototype.initialize = function (focusTrapFactory) {
var _this = this;
if (focusTrapFactory === void 0) {
focusTrapFactory = function focusTrapFactory(el, focusOptions) {
return new focus_trap_1.FocusTrap(el, focusOptions);
};
}
this.contentEl = this.root.querySelector(constants_1.selectors.CONTENT);
this.textEl = this.root.querySelector(constants_1.selectors.TEXT);
this.primaryActionEl = this.root.querySelector(constants_1.selectors.PRIMARY_ACTION);
this.secondaryActionEl = this.root.querySelector(constants_1.selectors.SECONDARY_ACTION);
this.focusTrapFactory = focusTrapFactory;
this.handleContentClick = function (evt) {
var target = evt.target;
if (ponyfill_1.closest(target, constants_1.selectors.PRIMARY_ACTION)) {
_this.foundation.handlePrimaryActionClick();
} else if (ponyfill_1.closest(target, constants_1.selectors.SECONDARY_ACTION)) {
_this.foundation.handleSecondaryActionClick();
}
};
};
MDCBanner.prototype.initialSyncWithDOM = function () {
this.registerContentClickHandler(this.handleContentClick);
this.focusTrap = this.focusTrapFactory(this.root, { initialFocusEl: this.primaryActionEl });
};
MDCBanner.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.deregisterContentClickHandler(this.handleContentClick);
};
MDCBanner.prototype.layout = function () {
this.foundation.layout();
};
/**
* Opens the banner and fires events.OPENING to indicate the beginning of its
* opening animation and then events.OPENED once the animation finishes.
*/
MDCBanner.prototype.open = function () {
this.foundation.open();
};
/**
* Closes the banner and fires events.CLOSING to indicate the beginning of its
* closing animation and then events.CLOSED once the animation finishes.
* @param reason Why the banner was closed. Value will be passed to
* events.CLOSING and events.CLOSED via the `event.detail.reason`
* property. Standard values are CloseReason.PRIMARY and
* CloseReason.SECONDARY, but CloseReason.UNSPECIFIED is provided for
* custom handling of programmatic closing of the banner.
*/
MDCBanner.prototype.close = function (reason) {
this.foundation.close(reason);
};
MDCBanner.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
// methods, we need a separate, strongly typed adapter variable.
var adapter = {
addClass: function addClass(className) {
_this.root.classList.add(className);
},
getContentHeight: function getContentHeight() {
return _this.contentEl.offsetHeight;
},
notifyClosed: function notifyClosed(reason) {
_this.emit(constants_1.events.CLOSED, { reason: reason });
},
notifyClosing: function notifyClosing(reason) {
_this.emit(constants_1.events.CLOSING, { reason: reason });
},
notifyOpened: function notifyOpened() {
_this.emit(constants_1.events.OPENED, {});
},
notifyOpening: function notifyOpening() {
_this.emit(constants_1.events.OPENING, {});
},
notifyActionClicked: function notifyActionClicked(action) {
_this.emit(constants_1.events.ACTION_CLICKED, { action: action });
},
releaseFocus: function releaseFocus() {
_this.focusTrap.releaseFocus();
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
setStyleProperty: function setStyleProperty(propertyName, value) {
_this.root.style.setProperty(propertyName, value);
},
trapFocus: function trapFocus() {
_this.focusTrap.trapFocus();
}
};
return new foundation_1.MDCBannerFoundation(adapter);
};
Object.defineProperty(MDCBanner.prototype, "isOpen", {
get: function get() {
return this.foundation.isOpen();
},
enumerable: false,
configurable: true
});
MDCBanner.prototype.getText = function () {
return this.textEl.textContent || '';
};
MDCBanner.prototype.setText = function (text) {
this.textEl.textContent = text;
};
MDCBanner.prototype.getPrimaryActionText = function () {
return this.primaryActionEl.textContent || '';
};
MDCBanner.prototype.setPrimaryActionText = function (actionButtonText) {
this.primaryActionEl.textContent = actionButtonText;
};
/** Returns null if the banner has no secondary action. */
MDCBanner.prototype.getSecondaryActionText = function () {
return this.secondaryActionEl ? this.secondaryActionEl.textContent || '' : null;
};
MDCBanner.prototype.setSecondaryActionText = function (actionButtonText) {
if (this.secondaryActionEl) {
this.secondaryActionEl.textContent = actionButtonText;
}
};
MDCBanner.prototype.registerContentClickHandler = function (handler) {
this.contentEl.addEventListener('click', handler);
};
MDCBanner.prototype.deregisterContentClickHandler = function (handler) {
this.contentEl.removeEventListener('click', handler);
};
return MDCBanner;
}(component_1.MDCComponent);
exports.MDCBanner = MDCBanner;
/***/ }),
/***/ "./packages/mdc-banner/constants.ts":
/*!******************************************!*\
!*** ./packages/mdc-banner/constants.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Action = exports.CloseReason = exports.selectors = exports.events = exports.numbers = exports.cssClasses = void 0;
/** Banner element classes. */
exports.cssClasses = {
CLOSING: 'mdc-banner--closing',
OPEN: 'mdc-banner--open',
OPENING: 'mdc-banner--opening'
};
/** Banner numbers. */
exports.numbers = {
BANNER_ANIMATION_CLOSE_TIME_MS: 250,
BANNER_ANIMATION_OPEN_TIME_MS: 300
};
/** Banner events. */
exports.events = {
CLOSED: 'MDCBanner:closed',
CLOSING: 'MDCBanner:closing',
OPENED: 'MDCBanner:opened',
OPENING: 'MDCBanner:opening',
ACTION_CLICKED: 'MDCBanner:actionClicked'
};
/** Banner selectors. */
exports.selectors = {
CONTENT: '.mdc-banner__content',
PRIMARY_ACTION: '.mdc-banner__primary-action',
SECONDARY_ACTION: '.mdc-banner__secondary-action',
TEXT: '.mdc-banner__text'
};
/** Reason as to why the banner was closed. */
var CloseReason;
(function (CloseReason) {
// Indicates the banner was closed via primary action button.
CloseReason[CloseReason["PRIMARY"] = 0] = "PRIMARY";
// Indicates the banner was closed via secondary action button.
CloseReason[CloseReason["SECONDARY"] = 1] = "SECONDARY";
// Will never be used by the component. Provided for custom handling of
// programmatic closing of the banner.
CloseReason[CloseReason["UNSPECIFIED"] = 2] = "UNSPECIFIED";
})(CloseReason = exports.CloseReason || (exports.CloseReason = {}));
/**
* Payload of actionClicked events to signify which action emitted the event.
*/
var Action;
(function (Action) {
Action[Action["PRIMARY"] = 0] = "PRIMARY";
Action[Action["SECONDARY"] = 1] = "SECONDARY";
Action[Action["UNKNOWN"] = 2] = "UNKNOWN";
})(Action = exports.Action || (exports.Action = {}));
/***/ }),
/***/ "./packages/mdc-banner/foundation.ts":
/*!*******************************************!*\
!*** ./packages/mdc-banner/foundation.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCBannerFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-banner/constants.ts");
var OPENING = constants_1.cssClasses.OPENING,
OPEN = constants_1.cssClasses.OPEN,
CLOSING = constants_1.cssClasses.CLOSING;
/**
* Foundation class for banner. Responsibilities include opening and closing the
* banner.
*/
var MDCBannerFoundation = /** @class */function (_super) {
__extends(MDCBannerFoundation, _super);
function MDCBannerFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCBannerFoundation.defaultAdapter), adapter)) || this;
_this.isOpened = false;
// Request id for open animation, used to cancel the refresh callback
// request on close() and destroy().
_this.animationFrame = 0;
// Timer id for close and open animation, used to cancel the timer on
// close() and destroy().
_this.animationTimer = 0;
return _this;
}
Object.defineProperty(MDCBannerFoundation, "defaultAdapter", {
get: function get() {
return {
addClass: function addClass() {
return undefined;
},
getContentHeight: function getContentHeight() {
return 0;
},
notifyClosed: function notifyClosed() {
return undefined;
},
notifyClosing: function notifyClosing() {
return undefined;
},
notifyOpened: function notifyOpened() {
return undefined;
},
notifyOpening: function notifyOpening() {
return undefined;
},
notifyActionClicked: function notifyActionClicked() {
return undefined;
},
releaseFocus: function releaseFocus() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
setStyleProperty: function setStyleProperty() {
return undefined;
},
trapFocus: function trapFocus() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCBannerFoundation.prototype.destroy = function () {
cancelAnimationFrame(this.animationFrame);
this.animationFrame = 0;
clearTimeout(this.animationTimer);
this.animationTimer = 0;
};
MDCBannerFoundation.prototype.open = function () {
var _this = this;
this.isOpened = true;
this.adapter.notifyOpening();
this.adapter.removeClass(CLOSING);
this.adapter.addClass(OPENING);
var contentHeight = this.adapter.getContentHeight();
this.animationFrame = requestAnimationFrame(function () {
_this.adapter.addClass(OPEN);
_this.adapter.setStyleProperty('height', contentHeight + "px");
_this.animationTimer = setTimeout(function () {
_this.handleAnimationTimerEnd();
_this.adapter.trapFocus();
_this.adapter.notifyOpened();
}, constants_1.numbers.BANNER_ANIMATION_OPEN_TIME_MS);
});
};
/**
* @param reason Why the banner was closed. Value will be passed to
* events.CLOSING and events.CLOSED via the `event.detail.reason`
* property. Standard values are CloseReason.PRIMARY and
* CloseReason.SECONDARY, but CloseReason.UNSPECIFIED is provided for
* custom handling of programmatic closing of the banner.
*/
MDCBannerFoundation.prototype.close = function (reason) {
var _this = this;
if (!this.isOpened) {
// Avoid redundant close calls (and events), e.g. repeated interactions as
// the banner is animating closed
return;
}
cancelAnimationFrame(this.animationFrame);
this.animationFrame = 0;
this.isOpened = false;
this.adapter.notifyClosing(reason);
this.adapter.addClass(CLOSING);
this.adapter.setStyleProperty('height', '0');
this.adapter.removeClass(OPEN);
this.adapter.removeClass(OPENING);
clearTimeout(this.animationTimer);
this.animationTimer = setTimeout(function () {
_this.adapter.releaseFocus();
_this.handleAnimationTimerEnd();
_this.adapter.notifyClosed(reason);
}, constants_1.numbers.BANNER_ANIMATION_CLOSE_TIME_MS);
};
MDCBannerFoundation.prototype.isOpen = function () {
return this.isOpened;
};
MDCBannerFoundation.prototype.handlePrimaryActionClick = function (disableAutoClose) {
if (disableAutoClose === void 0) {
disableAutoClose = false;
}
if (disableAutoClose) {
this.adapter.notifyActionClicked(0 /* PRIMARY */);
} else {
this.close(constants_1.CloseReason.PRIMARY);
}
};
MDCBannerFoundation.prototype.handleSecondaryActionClick = function (disableAutoClose) {
if (disableAutoClose === void 0) {
disableAutoClose = false;
}
if (disableAutoClose) {
this.adapter.notifyActionClicked(1 /* SECONDARY */);
} else {
this.close(constants_1.CloseReason.SECONDARY);
}
};
MDCBannerFoundation.prototype.layout = function () {
var contentHeight = this.adapter.getContentHeight();
this.adapter.setStyleProperty('height', contentHeight + "px");
};
MDCBannerFoundation.prototype.handleAnimationTimerEnd = function () {
this.animationTimer = 0;
this.adapter.removeClass(OPENING);
this.adapter.removeClass(CLOSING);
};
return MDCBannerFoundation;
}(foundation_1.MDCFoundation);
exports.MDCBannerFoundation = MDCBannerFoundation;
/***/ }),
/***/ "./packages/mdc-banner/index.ts":
/*!**************************************!*\
!*** ./packages/mdc-banner/index.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-banner/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-banner/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-banner/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-banner/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-base/component.ts":
/*!****************************************!*\
!*** ./packages/mdc-base/component.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
ar.push(r.value);
}
} catch (error) {
e = { error: error };
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};
var __spreadArray = this && this.__spreadArray || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
to[j] = from[i];
}return to;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCComponent = void 0;
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
var MDCComponent = /** @class */function () {
function MDCComponent(root, foundation) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
this.root = root;
this.initialize.apply(this, __spreadArray([], __read(args)));
// Note that we initialize foundation here and not within the constructor's
// default param so that this.root is defined and can be used within the
// foundation class.
this.foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
this.foundation.init();
this.initialSyncWithDOM();
}
MDCComponent.attachTo = function (root) {
// Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
// returns an instantiated component with its root set to that element. Also note that in the cases of
// subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
// from getDefaultFoundation().
return new MDCComponent(root, new foundation_1.MDCFoundation({}));
};
/* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */
MDCComponent.prototype.initialize = function () {
var _args = [];
for (var _i = 0; _i < arguments.length; _i++) {
_args[_i] = arguments[_i];
}
// Subclasses can override this to do any additional setup work that would be considered part of a
// "constructor". Essentially, it is a hook into the parent constructor before the foundation is
// initialized. Any additional arguments besides root and foundation will be passed in here.
};
MDCComponent.prototype.getDefaultFoundation = function () {
// Subclasses must override this method to return a properly configured foundation class for the
// component.
throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
};
MDCComponent.prototype.initialSyncWithDOM = function () {
// Subclasses should override this method if they need to perform work to synchronize with a host DOM
// object. An example of this would be a form control wrapper that needs to synchronize its internal state
// to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
// reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
};
MDCComponent.prototype.destroy = function () {
// Subclasses may implement this method to release any resources / deregister any listeners they have
// attached. An example of this might be deregistering a resize event from the window object.
this.foundation.destroy();
};
MDCComponent.prototype.listen = function (evtType, handler, options) {
this.root.addEventListener(evtType, handler, options);
};
MDCComponent.prototype.unlisten = function (evtType, handler, options) {
this.root.removeEventListener(evtType, handler, options);
};
/**
* Fires a cross-browser-compatible custom event from the component root of the given type, with the given data.
*/
MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
if (shouldBubble === void 0) {
shouldBubble = false;
}
var evt;
if (typeof CustomEvent === 'function') {
evt = new CustomEvent(evtType, {
bubbles: shouldBubble,
detail: evtData
});
} else {
evt = document.createEvent('CustomEvent');
evt.initCustomEvent(evtType, shouldBubble, false, evtData);
}
this.root.dispatchEvent(evt);
};
return MDCComponent;
}();
exports.MDCComponent = MDCComponent;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCComponent;
/***/ }),
/***/ "./packages/mdc-base/foundation.ts":
/*!*****************************************!*\
!*** ./packages/mdc-base/foundation.ts ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCFoundation = void 0;
var MDCFoundation = /** @class */function () {
function MDCFoundation(adapter) {
if (adapter === void 0) {
adapter = {};
}
this.adapter = adapter;
}
Object.defineProperty(MDCFoundation, "cssClasses", {
get: function get() {
// Classes extending MDCFoundation should implement this method to return an object which exports every
// CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
return {};
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCFoundation, "strings", {
get: function get() {
// Classes extending MDCFoundation should implement this method to return an object which exports all
// semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
return {};
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCFoundation, "numbers", {
get: function get() {
// Classes extending MDCFoundation should implement this method to return an object which exports all
// of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
return {};
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCFoundation, "defaultAdapter", {
get: function get() {
// Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
// way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
// validation.
return {};
},
enumerable: false,
configurable: true
});
MDCFoundation.prototype.init = function () {
// Subclasses should override this method to perform initialization routines (registering events, etc.)
};
MDCFoundation.prototype.destroy = function () {
// Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
};
return MDCFoundation;
}();
exports.MDCFoundation = MDCFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCFoundation;
/***/ }),
/***/ "./packages/mdc-base/index.ts":
/*!************************************!*\
!*** ./packages/mdc-base/index.ts ***!
\************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-base/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-base/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-base/observer-foundation.ts":
/*!**************************************************!*\
!*** ./packages/mdc-base/observer-foundation.ts ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2021 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
ar.push(r.value);
}
} catch (error) {
e = { error: error };
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};
var __spreadArray = this && this.__spreadArray || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
to[j] = from[i];
}return to;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCObserverFoundation = void 0;
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
var observer_1 = __webpack_require__(/*! ./observer */ "./packages/mdc-base/observer.ts");
var MDCObserverFoundation = /** @class */function (_super) {
__extends(MDCObserverFoundation, _super);
function MDCObserverFoundation(adapter) {
var _this = _super.call(this, adapter) || this;
/** A set of cleanup functions to unobserve changes. */
_this.unobserves = new Set();
return _this;
}
MDCObserverFoundation.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.unobserve();
};
/**
* Observe a target's properties for changes using the provided map of
* property names and observer functions.
*
* @template T The target type.
* @param target - The target to observe.
* @param observers - An object whose keys are target properties and values
* are observer functions that are called when the associated property
* changes.
* @return A cleanup function that can be called to unobserve the
* target.
*/
MDCObserverFoundation.prototype.observe = function (target, observers) {
var e_1, _a;
var _this = this;
var cleanup = [];
try {
for (var _b = __values(Object.keys(observers)), _c = _b.next(); !_c.done; _c = _b.next()) {
var property = _c.value;
var observer = observers[property].bind(this);
cleanup.push(this.observeProperty(target, property, observer));
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_1) throw e_1.error;
}
}
var unobserve = function unobserve() {
var e_2, _a;
try {
for (var cleanup_1 = __values(cleanup), cleanup_1_1 = cleanup_1.next(); !cleanup_1_1.done; cleanup_1_1 = cleanup_1.next()) {
var cleanupFn = cleanup_1_1.value;
cleanupFn();
}
} catch (e_2_1) {
e_2 = { error: e_2_1 };
} finally {
try {
if (cleanup_1_1 && !cleanup_1_1.done && (_a = cleanup_1.return)) _a.call(cleanup_1);
} finally {
if (e_2) throw e_2.error;
}
}
_this.unobserves.delete(unobserve);
};
this.unobserves.add(unobserve);
return unobserve;
};
/**
* Observe a target's property for changes. When a property changes, the
* provided `Observer` function will be invoked with the properties current
* and previous values.
*
* The returned cleanup function will stop listening to changes for the
* provided `Observer`.
*
* @template T The observed target type.
* @template K The observed property.
* @param target - The target to observe.
* @param property - The property of the target to observe.
* @param observer - An observer function to invoke each time the property
* changes.
* @return A cleanup function that will stop observing changes for the
* provided `Observer`.
*/
MDCObserverFoundation.prototype.observeProperty = function (target, property, observer) {
return observer_1.observeProperty(target, property, observer);
};
/**
* Enables or disables all observers for the provided target. Disabling
* observers will prevent them from being called until they are re-enabled.
*
* @param target - The target to enable or disable observers for.
* @param enabled - Whether or not observers should be called.
*/
MDCObserverFoundation.prototype.setObserversEnabled = function (target, enabled) {
observer_1.setObserversEnabled(target, enabled);
};
/**
* Clean up all observers and stop listening for property changes.
*/
MDCObserverFoundation.prototype.unobserve = function () {
var e_3, _a;
try {
// Iterate over a copy since unobserve() will remove themselves from the set
for (var _b = __values(__spreadArray([], __read(this.unobserves))), _c = _b.next(); !_c.done; _c = _b.next()) {
var unobserve = _c.value;
unobserve();
}
} catch (e_3_1) {
e_3 = { error: e_3_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_3) throw e_3.error;
}
}
};
return MDCObserverFoundation;
}(foundation_1.MDCFoundation);
exports.MDCObserverFoundation = MDCObserverFoundation;
/***/ }),
/***/ "./packages/mdc-base/observer.ts":
/*!***************************************!*\
!*** ./packages/mdc-base/observer.ts ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2021 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
ar.push(r.value);
}
} catch (error) {
e = { error: error };
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};
var __spreadArray = this && this.__spreadArray || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
to[j] = from[i];
}return to;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setObserversEnabled = exports.getDescriptor = exports.observeProperty = exports.mdcObserver = void 0;
/**
* Mixin to add `MDCObserver` functionality to an optional base class.
*
* @deprecated Prefer MDCObserverFoundation for stricter closure compliance.
* @template C Optional base class constructor type.
* @param baseClass - Optional base class.
* @return A class that extends the optional base class with `MDCObserver`
* functionality.
*/
function mdcObserver(baseClass) {
if (baseClass === void 0) {
baseClass = /** @class */function () {
function class_1() {}
return class_1;
}();
}
// Mixin classes cannot use private members and Symbol() cannot be used in 3P
// for IE11.
var unobserveMap = new WeakMap();
return (/** @class */function (_super) {
__extends(MDCObserver, _super);
function MDCObserver() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCObserver.prototype.observe = function (target, observers) {
var e_1, _a;
var _this = this;
var cleanup = [];
try {
for (var _b = __values(Object.keys(observers)), _c = _b.next(); !_c.done; _c = _b.next()) {
var property = _c.value;
var observer = observers[property].bind(this);
cleanup.push(observeProperty(target, property, observer));
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_1) throw e_1.error;
}
}
var unobserve = function unobserve() {
var e_2, _a;
try {
for (var cleanup_1 = __values(cleanup), cleanup_1_1 = cleanup_1.next(); !cleanup_1_1.done; cleanup_1_1 = cleanup_1.next()) {
var cleanupFn = cleanup_1_1.value;
cleanupFn();
}
} catch (e_2_1) {
e_2 = { error: e_2_1 };
} finally {
try {
if (cleanup_1_1 && !cleanup_1_1.done && (_a = cleanup_1.return)) _a.call(cleanup_1);
} finally {
if (e_2) throw e_2.error;
}
}
var unobserves = unobserveMap.get(_this) || [];
var index = unobserves.indexOf(unobserve);
if (index > -1) {
unobserves.splice(index, 1);
}
};
var unobserves = unobserveMap.get(this);
if (!unobserves) {
unobserves = [];
unobserveMap.set(this, unobserves);
}
unobserves.push(unobserve);
return unobserve;
};
MDCObserver.prototype.setObserversEnabled = function (target, enabled) {
setObserversEnabled(target, enabled);
};
MDCObserver.prototype.unobserve = function () {
var e_3, _a;
// Iterate over a copy since unobserve() will remove themselves from the
// array
var unobserves = unobserveMap.get(this) || [];
try {
for (var _b = __values(__spreadArray([], __read(unobserves))), _c = _b.next(); !_c.done; _c = _b.next()) {
var unobserve = _c.value;
unobserve();
}
} catch (e_3_1) {
e_3 = { error: e_3_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_3) throw e_3.error;
}
}
};
return MDCObserver;
}(baseClass)
);
}
exports.mdcObserver = mdcObserver;
/**
* Observe a target's property for changes. When a property changes, the
* provided `Observer` function will be invoked with the properties current and
* previous values.
*
* The returned cleanup function will stop listening to changes for the
* provided `Observer`.
*
* @template T The observed target type.
* @template K The observed property.
* @param target - The target to observe.
* @param property - The property of the target to observe.
* @param observer - An observer function to invoke each time the property
* changes.
* @return A cleanup function that will stop observing changes for the provided
* `Observer`.
*/
function observeProperty(target, property, observer) {
var targetObservers = installObserver(target, property);
var observers = targetObservers.getObservers(property);
observers.push(observer);
return function () {
observers.splice(observers.indexOf(observer), 1);
};
}
exports.observeProperty = observeProperty;
/**
* A Map of all `TargetObservers` that have been installed.
*/
var allTargetObservers = new WeakMap();
/**
* Installs a `TargetObservers` for the provided target (if not already
* installed), and replaces the given property with a getter and setter that
* will respond to changes and call `TargetObservers`.
*
* Subsequent calls to `installObserver()` with the same target and property
* will not override the property's previously installed getter/setter.
*
* @template T The observed target type.
* @template K The observed property to create a getter/setter for.
* @param target - The target to observe.
* @param property - The property to create a getter/setter for, if needed.
* @return The installed `TargetObservers` for the provided target.
*/
function installObserver(target, property) {
var observersMap = new Map();
if (!allTargetObservers.has(target)) {
allTargetObservers.set(target, {
isEnabled: true,
getObservers: function getObservers(key) {
var observers = observersMap.get(key) || [];
if (!observersMap.has(key)) {
observersMap.set(key, observers);
}
return observers;
},
installedProperties: new Set()
});
}
var targetObservers = allTargetObservers.get(target);
if (targetObservers.installedProperties.has(property)) {
// The getter/setter has already been replaced for this property
return targetObservers;
}
// Retrieve (or create if it's a plain property) the original descriptor from
// the target...
var descriptor = getDescriptor(target, property) || {
configurable: true,
enumerable: true,
value: target[property],
writable: true
};
// ...and create a copy that will be used for the observer.
var observedDescriptor = __assign({}, descriptor);
var descGet = descriptor.get,
descSet = descriptor.set;
if ('value' in descriptor) {
// The descriptor is a simple value (not a getter/setter).
// For our observer descriptor that we copied, delete the value/writable
// properties, since they are incompatible with the get/set properties
// for descriptors.
delete observedDescriptor.value;
delete observedDescriptor.writable;
// Set up a simple getter...
var value_1 = descriptor.value;
descGet = function descGet() {
return value_1;
};
// ...and setter (if the original property was writable).
if (descriptor.writable) {
descSet = function descSet(newValue) {
value_1 = newValue;
};
}
}
if (descGet) {
observedDescriptor.get = function () {
// `this as T` needed for closure conformance
return descGet.call(this);
};
}
if (descSet) {
observedDescriptor.set = function (newValue) {
var e_4, _a;
// `thus as T` needed for closure conformance
var previous = descGet ? descGet.call(this) : newValue;
descSet.call(this, newValue);
if (targetObservers.isEnabled && (!descGet || newValue !== previous)) {
try {
for (var _b = __values(targetObservers.getObservers(property)), _c = _b.next(); !_c.done; _c = _b.next()) {
var observer = _c.value;
observer(newValue, previous);
}
} catch (e_4_1) {
e_4 = { error: e_4_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_4) throw e_4.error;
}
}
}
};
}
targetObservers.installedProperties.add(property);
Object.defineProperty(target, property, observedDescriptor);
return targetObservers;
}
/**
* Retrieves the descriptor for a property from the provided target. This
* function will walk up the target's prototype chain to search for the
* descriptor.
*
* @template T The target type.
* @template K The property type.
* @param target - The target to retrieve a descriptor from.
* @param property - The name of the property to retrieve a descriptor for.
* @return the descriptor, or undefined if it does not exist. Keep in mind that
* plain properties may not have a descriptor defined.
*/
function getDescriptor(target, property) {
var descriptorTarget = target;
var descriptor;
while (descriptorTarget) {
descriptor = Object.getOwnPropertyDescriptor(descriptorTarget, property);
if (descriptor) {
break;
}
// Walk up the instance's prototype chain in case the property is declared
// on a superclass.
descriptorTarget = Object.getPrototypeOf(descriptorTarget);
}
return descriptor;
}
exports.getDescriptor = getDescriptor;
/**
* Enables or disables all observers for a provided target. Changes to observed
* properties will not call any observers when disabled.
*
* @template T The observed target type.
* @param target - The target to enable or disable observers for.
* @param enabled - True to enable or false to disable observers.
*/
function setObserversEnabled(target, enabled) {
var targetObservers = allTargetObservers.get(target);
if (targetObservers) {
targetObservers.isEnabled = enabled;
}
}
exports.setObserversEnabled = setObserversEnabled;
/***/ }),
/***/ "./packages/mdc-base/types.ts":
/*!************************************!*\
!*** ./packages/mdc-base/types.ts ***!
\************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
// tslint:enable:no-any
/***/ }),
/***/ "./packages/mdc-checkbox/adapter.ts":
/*!******************************************!*\
!*** ./packages/mdc-checkbox/adapter.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-checkbox/component.ts":
/*!********************************************!*\
!*** ./packages/mdc-checkbox/component.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCCheckbox = void 0;
var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-checkbox/foundation.ts");
var CB_PROTO_PROPS = ['checked', 'indeterminate'];
var MDCCheckbox = /** @class */function (_super) {
__extends(MDCCheckbox, _super);
function MDCCheckbox() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.rippleSurface = _this.createRipple();
return _this;
}
MDCCheckbox.attachTo = function (root) {
return new MDCCheckbox(root);
};
Object.defineProperty(MDCCheckbox.prototype, "ripple", {
get: function get() {
return this.rippleSurface;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCCheckbox.prototype, "checked", {
get: function get() {
return this.getNativeControl().checked;
},
set: function set(checked) {
this.getNativeControl().checked = checked;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCCheckbox.prototype, "indeterminate", {
get: function get() {
return this.getNativeControl().indeterminate;
},
set: function set(indeterminate) {
this.getNativeControl().indeterminate = indeterminate;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCCheckbox.prototype, "disabled", {
get: function get() {
return this.getNativeControl().disabled;
},
set: function set(disabled) {
this.foundation.setDisabled(disabled);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCCheckbox.prototype, "value", {
get: function get() {
return this.getNativeControl().value;
},
set: function set(value) {
this.getNativeControl().value = value;
},
enumerable: false,
configurable: true
});
MDCCheckbox.prototype.initialize = function () {
var DATA_INDETERMINATE_ATTR = constants_1.strings.DATA_INDETERMINATE_ATTR;
this.getNativeControl().indeterminate = this.getNativeControl().getAttribute(DATA_INDETERMINATE_ATTR) === 'true';
this.getNativeControl().removeAttribute(DATA_INDETERMINATE_ATTR);
};
MDCCheckbox.prototype.initialSyncWithDOM = function () {
var _this = this;
this.handleChange = function () {
_this.foundation.handleChange();
};
this.handleAnimationEnd = function () {
_this.foundation.handleAnimationEnd();
};
this.getNativeControl().addEventListener('change', this.handleChange);
this.listen(util_1.getCorrectEventName(window, 'animationend'), this.handleAnimationEnd);
this.installPropertyChangeHooks();
};
MDCCheckbox.prototype.destroy = function () {
this.rippleSurface.destroy();
this.getNativeControl().removeEventListener('change', this.handleChange);
this.unlisten(util_1.getCorrectEventName(window, 'animationend'), this.handleAnimationEnd);
this.uninstallPropertyChangeHooks();
_super.prototype.destroy.call(this);
};
MDCCheckbox.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
forceLayout: function forceLayout() {
return _this.root.offsetWidth;
},
hasNativeControl: function hasNativeControl() {
return !!_this.getNativeControl();
},
isAttachedToDOM: function isAttachedToDOM() {
return Boolean(_this.root.parentNode);
},
isChecked: function isChecked() {
return _this.checked;
},
isIndeterminate: function isIndeterminate() {
return _this.indeterminate;
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
removeNativeControlAttr: function removeNativeControlAttr(attr) {
_this.getNativeControl().removeAttribute(attr);
},
setNativeControlAttr: function setNativeControlAttr(attr, value) {
_this.getNativeControl().setAttribute(attr, value);
},
setNativeControlDisabled: function setNativeControlDisabled(disabled) {
_this.getNativeControl().disabled = disabled;
}
};
return new foundation_2.MDCCheckboxFoundation(adapter);
};
MDCCheckbox.prototype.createRipple = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
_this.getNativeControl().removeEventListener(evtType, handler, events_1.applyPassive());
}, isSurfaceActive: function isSurfaceActive() {
return ponyfill_1.matches(_this.getNativeControl(), ':active');
}, isUnbounded: function isUnbounded() {
return true;
}, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
_this.getNativeControl().addEventListener(evtType, handler, events_1.applyPassive());
} });
return new component_2.MDCRipple(this.root, new foundation_1.MDCRippleFoundation(adapter));
};
MDCCheckbox.prototype.installPropertyChangeHooks = function () {
var e_1, _a;
var _this = this;
var nativeCb = this.getNativeControl();
var cbProto = Object.getPrototypeOf(nativeCb);
var _loop_1 = function _loop_1(controlState) {
var desc = Object.getOwnPropertyDescriptor(cbProto, controlState);
// We have to check for this descriptor, since some browsers (Safari) don't support its return.
// See: https://bugs.webkit.org/show_bug.cgi?id=49739
if (!validDescriptor(desc)) {
return { value: void 0 };
}
// Type cast is needed for compatibility with Closure Compiler.
var nativeGetter = desc.get;
var nativeCbDesc = {
configurable: desc.configurable,
enumerable: desc.enumerable,
get: nativeGetter,
set: function set(state) {
desc.set.call(nativeCb, state);
_this.foundation.handleChange();
}
};
Object.defineProperty(nativeCb, controlState, nativeCbDesc);
};
try {
for (var CB_PROTO_PROPS_1 = __values(CB_PROTO_PROPS), CB_PROTO_PROPS_1_1 = CB_PROTO_PROPS_1.next(); !CB_PROTO_PROPS_1_1.done; CB_PROTO_PROPS_1_1 = CB_PROTO_PROPS_1.next()) {
var controlState = CB_PROTO_PROPS_1_1.value;
var state_1 = _loop_1(controlState);
if ((typeof state_1 === "undefined" ? "undefined" : _typeof(state_1)) === "object") return state_1.value;
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (CB_PROTO_PROPS_1_1 && !CB_PROTO_PROPS_1_1.done && (_a = CB_PROTO_PROPS_1.return)) _a.call(CB_PROTO_PROPS_1);
} finally {
if (e_1) throw e_1.error;
}
}
};
MDCCheckbox.prototype.uninstallPropertyChangeHooks = function () {
var e_2, _a;
var nativeCb = this.getNativeControl();
var cbProto = Object.getPrototypeOf(nativeCb);
try {
for (var CB_PROTO_PROPS_2 = __values(CB_PROTO_PROPS), CB_PROTO_PROPS_2_1 = CB_PROTO_PROPS_2.next(); !CB_PROTO_PROPS_2_1.done; CB_PROTO_PROPS_2_1 = CB_PROTO_PROPS_2.next()) {
var controlState = CB_PROTO_PROPS_2_1.value;
var desc = Object.getOwnPropertyDescriptor(cbProto, controlState);
if (!validDescriptor(desc)) {
return;
}
Object.defineProperty(nativeCb, controlState, desc);
}
} catch (e_2_1) {
e_2 = { error: e_2_1 };
} finally {
try {
if (CB_PROTO_PROPS_2_1 && !CB_PROTO_PROPS_2_1.done && (_a = CB_PROTO_PROPS_2.return)) _a.call(CB_PROTO_PROPS_2);
} finally {
if (e_2) throw e_2.error;
}
}
};
MDCCheckbox.prototype.getNativeControl = function () {
var NATIVE_CONTROL_SELECTOR = constants_1.strings.NATIVE_CONTROL_SELECTOR;
var el = this.root.querySelector(NATIVE_CONTROL_SELECTOR);
if (!el) {
throw new Error("Checkbox component requires a " + NATIVE_CONTROL_SELECTOR + " element");
}
return el;
};
return MDCCheckbox;
}(component_1.MDCComponent);
exports.MDCCheckbox = MDCCheckbox;
function validDescriptor(inputPropDesc) {
return !!inputPropDesc && typeof inputPropDesc.set === 'function';
}
/***/ }),
/***/ "./packages/mdc-checkbox/constants.ts":
/*!********************************************!*\
!*** ./packages/mdc-checkbox/constants.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.numbers = exports.strings = exports.cssClasses = void 0;
exports.cssClasses = {
ANIM_CHECKED_INDETERMINATE: 'mdc-checkbox--anim-checked-indeterminate',
ANIM_CHECKED_UNCHECKED: 'mdc-checkbox--anim-checked-unchecked',
ANIM_INDETERMINATE_CHECKED: 'mdc-checkbox--anim-indeterminate-checked',
ANIM_INDETERMINATE_UNCHECKED: 'mdc-checkbox--anim-indeterminate-unchecked',
ANIM_UNCHECKED_CHECKED: 'mdc-checkbox--anim-unchecked-checked',
ANIM_UNCHECKED_INDETERMINATE: 'mdc-checkbox--anim-unchecked-indeterminate',
BACKGROUND: 'mdc-checkbox__background',
CHECKED: 'mdc-checkbox--checked',
CHECKMARK: 'mdc-checkbox__checkmark',
CHECKMARK_PATH: 'mdc-checkbox__checkmark-path',
DISABLED: 'mdc-checkbox--disabled',
INDETERMINATE: 'mdc-checkbox--indeterminate',
MIXEDMARK: 'mdc-checkbox__mixedmark',
NATIVE_CONTROL: 'mdc-checkbox__native-control',
ROOT: 'mdc-checkbox',
SELECTED: 'mdc-checkbox--selected',
UPGRADED: 'mdc-checkbox--upgraded'
};
exports.strings = {
ARIA_CHECKED_ATTR: 'aria-checked',
ARIA_CHECKED_INDETERMINATE_VALUE: 'mixed',
DATA_INDETERMINATE_ATTR: 'data-indeterminate',
NATIVE_CONTROL_SELECTOR: '.mdc-checkbox__native-control',
TRANSITION_STATE_CHECKED: 'checked',
TRANSITION_STATE_INDETERMINATE: 'indeterminate',
TRANSITION_STATE_INIT: 'init',
TRANSITION_STATE_UNCHECKED: 'unchecked'
};
exports.numbers = {
ANIM_END_LATCH_MS: 250
};
/***/ }),
/***/ "./packages/mdc-checkbox/foundation.ts":
/*!*********************************************!*\
!*** ./packages/mdc-checkbox/foundation.ts ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCCheckboxFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.ts");
var MDCCheckboxFoundation = /** @class */function (_super) {
__extends(MDCCheckboxFoundation, _super);
function MDCCheckboxFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCCheckboxFoundation.defaultAdapter), adapter)) || this;
_this.currentCheckState = constants_1.strings.TRANSITION_STATE_INIT;
_this.currentAnimationClass = '';
_this.animEndLatchTimer = 0;
_this.enableAnimationEndHandler = false;
return _this;
}
Object.defineProperty(MDCCheckboxFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCCheckboxFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCCheckboxFoundation, "numbers", {
get: function get() {
return constants_1.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCCheckboxFoundation, "defaultAdapter", {
get: function get() {
return {
addClass: function addClass() {
return undefined;
},
forceLayout: function forceLayout() {
return undefined;
},
hasNativeControl: function hasNativeControl() {
return false;
},
isAttachedToDOM: function isAttachedToDOM() {
return false;
},
isChecked: function isChecked() {
return false;
},
isIndeterminate: function isIndeterminate() {
return false;
},
removeClass: function removeClass() {
return undefined;
},
removeNativeControlAttr: function removeNativeControlAttr() {
return undefined;
},
setNativeControlAttr: function setNativeControlAttr() {
return undefined;
},
setNativeControlDisabled: function setNativeControlDisabled() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCCheckboxFoundation.prototype.init = function () {
this.currentCheckState = this.determineCheckState();
this.updateAriaChecked();
this.adapter.addClass(constants_1.cssClasses.UPGRADED);
};
MDCCheckboxFoundation.prototype.destroy = function () {
clearTimeout(this.animEndLatchTimer);
};
MDCCheckboxFoundation.prototype.setDisabled = function (disabled) {
this.adapter.setNativeControlDisabled(disabled);
if (disabled) {
this.adapter.addClass(constants_1.cssClasses.DISABLED);
} else {
this.adapter.removeClass(constants_1.cssClasses.DISABLED);
}
};
/**
* Handles the animationend event for the checkbox
*/
MDCCheckboxFoundation.prototype.handleAnimationEnd = function () {
var _this = this;
if (!this.enableAnimationEndHandler) {
return;
}
clearTimeout(this.animEndLatchTimer);
this.animEndLatchTimer = setTimeout(function () {
_this.adapter.removeClass(_this.currentAnimationClass);
_this.enableAnimationEndHandler = false;
}, constants_1.numbers.ANIM_END_LATCH_MS);
};
/**
* Handles the change event for the checkbox
*/
MDCCheckboxFoundation.prototype.handleChange = function () {
this.transitionCheckState();
};
MDCCheckboxFoundation.prototype.transitionCheckState = function () {
if (!this.adapter.hasNativeControl()) {
return;
}
var oldState = this.currentCheckState;
var newState = this.determineCheckState();
if (oldState === newState) {
return;
}
this.updateAriaChecked();
var TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
var SELECTED = constants_1.cssClasses.SELECTED;
if (newState === TRANSITION_STATE_UNCHECKED) {
this.adapter.removeClass(SELECTED);
} else {
this.adapter.addClass(SELECTED);
}
// Check to ensure that there isn't a previously existing animation class, in case for example
// the user interacted with the checkbox before the animation was finished.
if (this.currentAnimationClass.length > 0) {
clearTimeout(this.animEndLatchTimer);
this.adapter.forceLayout();
this.adapter.removeClass(this.currentAnimationClass);
}
this.currentAnimationClass = this.getTransitionAnimationClass(oldState, newState);
this.currentCheckState = newState;
// Check for parentNode so that animations are only run when the element is attached
// to the DOM.
if (this.adapter.isAttachedToDOM() && this.currentAnimationClass.length > 0) {
this.adapter.addClass(this.currentAnimationClass);
this.enableAnimationEndHandler = true;
}
};
MDCCheckboxFoundation.prototype.determineCheckState = function () {
var TRANSITION_STATE_INDETERMINATE = constants_1.strings.TRANSITION_STATE_INDETERMINATE,
TRANSITION_STATE_CHECKED = constants_1.strings.TRANSITION_STATE_CHECKED,
TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
if (this.adapter.isIndeterminate()) {
return TRANSITION_STATE_INDETERMINATE;
}
return this.adapter.isChecked() ? TRANSITION_STATE_CHECKED : TRANSITION_STATE_UNCHECKED;
};
MDCCheckboxFoundation.prototype.getTransitionAnimationClass = function (oldState, newState) {
var TRANSITION_STATE_INIT = constants_1.strings.TRANSITION_STATE_INIT,
TRANSITION_STATE_CHECKED = constants_1.strings.TRANSITION_STATE_CHECKED,
TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
var _a = MDCCheckboxFoundation.cssClasses,
ANIM_UNCHECKED_CHECKED = _a.ANIM_UNCHECKED_CHECKED,
ANIM_UNCHECKED_INDETERMINATE = _a.ANIM_UNCHECKED_INDETERMINATE,
ANIM_CHECKED_UNCHECKED = _a.ANIM_CHECKED_UNCHECKED,
ANIM_CHECKED_INDETERMINATE = _a.ANIM_CHECKED_INDETERMINATE,
ANIM_INDETERMINATE_CHECKED = _a.ANIM_INDETERMINATE_CHECKED,
ANIM_INDETERMINATE_UNCHECKED = _a.ANIM_INDETERMINATE_UNCHECKED;
switch (oldState) {
case TRANSITION_STATE_INIT:
if (newState === TRANSITION_STATE_UNCHECKED) {
return '';
}
return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED;
case TRANSITION_STATE_UNCHECKED:
return newState === TRANSITION_STATE_CHECKED ? ANIM_UNCHECKED_CHECKED : ANIM_UNCHECKED_INDETERMINATE;
case TRANSITION_STATE_CHECKED:
return newState === TRANSITION_STATE_UNCHECKED ? ANIM_CHECKED_UNCHECKED : ANIM_CHECKED_INDETERMINATE;
default:
// TRANSITION_STATE_INDETERMINATE
return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED;
}
};
MDCCheckboxFoundation.prototype.updateAriaChecked = function () {
// Ensure aria-checked is set to mixed if checkbox is in indeterminate state.
if (this.adapter.isIndeterminate()) {
this.adapter.setNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR, constants_1.strings.ARIA_CHECKED_INDETERMINATE_VALUE);
} else {
// The on/off state does not need to keep track of aria-checked, since
// the screenreader uses the checked property on the checkbox element.
this.adapter.removeNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR);
}
};
return MDCCheckboxFoundation;
}(foundation_1.MDCFoundation);
exports.MDCCheckboxFoundation = MDCCheckboxFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCCheckboxFoundation;
/***/ }),
/***/ "./packages/mdc-checkbox/index.ts":
/*!****************************************!*\
!*** ./packages/mdc-checkbox/index.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-checkbox/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-checkbox/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-checkbox/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-chips/deprecated/chip-set/adapter.ts":
/*!***********************************************************!*\
!*** ./packages/mdc-chips/deprecated/chip-set/adapter.ts ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-chips/deprecated/chip-set/component.ts":
/*!*************************************************************!*\
!*** ./packages/mdc-chips/deprecated/chip-set/component.ts ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCChipSet = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var announce_1 = __webpack_require__(/*! @material/dom/announce */ "./packages/mdc-dom/announce.ts");
var component_2 = __webpack_require__(/*! ../chip/component */ "./packages/mdc-chips/deprecated/chip/component.ts");
var foundation_1 = __webpack_require__(/*! ../chip/foundation */ "./packages/mdc-chips/deprecated/chip/foundation.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-chips/deprecated/chip-set/foundation.ts");
var _a = foundation_1.MDCChipFoundation.strings,
INTERACTION_EVENT = _a.INTERACTION_EVENT,
SELECTION_EVENT = _a.SELECTION_EVENT,
REMOVAL_EVENT = _a.REMOVAL_EVENT,
NAVIGATION_EVENT = _a.NAVIGATION_EVENT;
var CHIP_SELECTOR = foundation_2.MDCChipSetFoundation.strings.CHIP_SELECTOR;
var idCounter = 0;
var MDCChipSet = /** @class */function (_super) {
__extends(MDCChipSet, _super);
function MDCChipSet() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCChipSet.attachTo = function (root) {
return new MDCChipSet(root);
};
Object.defineProperty(MDCChipSet.prototype, "chips", {
get: function get() {
return this.chipsList.slice();
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCChipSet.prototype, "selectedChipIds", {
/**
* @return An array of the IDs of all selected chips.
*/
get: function get() {
return this.foundation.getSelectedChipIds();
},
enumerable: false,
configurable: true
});
/**
* @param chipFactory A function which creates a new MDCChip.
*/
MDCChipSet.prototype.initialize = function (chipFactory) {
if (chipFactory === void 0) {
chipFactory = function chipFactory(el) {
return new component_2.MDCChip(el);
};
}
this.chipFactory = chipFactory;
this.chipsList = this.instantiateChips(this.chipFactory);
};
MDCChipSet.prototype.initialSyncWithDOM = function () {
var e_1, _a;
var _this = this;
try {
for (var _b = __values(this.chipsList), _c = _b.next(); !_c.done; _c = _b.next()) {
var chip = _c.value;
if (chip.id && chip.selected) {
this.foundation.select(chip.id);
}
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_1) throw e_1.error;
}
}
this.handleChipInteraction = function (evt) {
return _this.foundation.handleChipInteraction(evt.detail);
};
this.handleChipSelection = function (evt) {
return _this.foundation.handleChipSelection(evt.detail);
};
this.handleChipRemoval = function (evt) {
return _this.foundation.handleChipRemoval(evt.detail);
};
this.handleChipNavigation = function (evt) {
return _this.foundation.handleChipNavigation(evt.detail);
};
this.listen(INTERACTION_EVENT, this.handleChipInteraction);
this.listen(SELECTION_EVENT, this.handleChipSelection);
this.listen(REMOVAL_EVENT, this.handleChipRemoval);
this.listen(NAVIGATION_EVENT, this.handleChipNavigation);
};
MDCChipSet.prototype.destroy = function () {
var e_2, _a;
try {
for (var _b = __values(this.chipsList), _c = _b.next(); !_c.done; _c = _b.next()) {
var chip = _c.value;
chip.destroy();
}
} catch (e_2_1) {
e_2 = { error: e_2_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_2) throw e_2.error;
}
}
this.unlisten(INTERACTION_EVENT, this.handleChipInteraction);
this.unlisten(SELECTION_EVENT, this.handleChipSelection);
this.unlisten(REMOVAL_EVENT, this.handleChipRemoval);
this.unlisten(NAVIGATION_EVENT, this.handleChipNavigation);
_super.prototype.destroy.call(this);
};
/**
* Adds a new chip object to the chip set from the given chip element.
*/
MDCChipSet.prototype.addChip = function (chipEl) {
chipEl.id = chipEl.id || "mdc-chip-" + ++idCounter;
this.chipsList.push(this.chipFactory(chipEl));
};
MDCChipSet.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = {
announceMessage: function announceMessage(message) {
announce_1.announce(message);
},
focusChipPrimaryActionAtIndex: function focusChipPrimaryActionAtIndex(index) {
_this.chipsList[index].focusPrimaryAction();
},
focusChipTrailingActionAtIndex: function focusChipTrailingActionAtIndex(index) {
_this.chipsList[index].focusTrailingAction();
},
getChipListCount: function getChipListCount() {
return _this.chips.length;
},
getIndexOfChipById: function getIndexOfChipById(chipId) {
return _this.findChipIndex(chipId);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
isRTL: function isRTL() {
return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
},
removeChipAtIndex: function removeChipAtIndex(index) {
if (index >= 0 && index < _this.chips.length) {
_this.chipsList[index].destroy();
_this.chipsList[index].remove();
_this.chipsList.splice(index, 1);
}
},
removeFocusFromChipAtIndex: function removeFocusFromChipAtIndex(index) {
_this.chipsList[index].removeFocus();
},
selectChipAtIndex: function selectChipAtIndex(index, selected, shouldNotifyClients) {
if (index >= 0 && index < _this.chips.length) {
_this.chipsList[index].setSelectedFromChipSet(selected, shouldNotifyClients);
}
}
};
return new foundation_2.MDCChipSetFoundation(adapter);
};
/**
* Instantiates chip components on all of the chip set's child chip elements.
*/
MDCChipSet.prototype.instantiateChips = function (chipFactory) {
var chipElements = [].slice.call(this.root.querySelectorAll(CHIP_SELECTOR));
return chipElements.map(function (el) {
el.id = el.id || "mdc-chip-" + ++idCounter;
return chipFactory(el);
});
};
/**
* Returns the index of the chip with the given id, or -1 if the chip does not exist.
*/
MDCChipSet.prototype.findChipIndex = function (chipId) {
for (var i = 0; i < this.chips.length; i++) {
if (this.chipsList[i].id === chipId) {
return i;
}
}
return -1;
};
return MDCChipSet;
}(component_1.MDCComponent);
exports.MDCChipSet = MDCChipSet;
/***/ }),
/***/ "./packages/mdc-chips/deprecated/chip-set/constants.ts":
/*!*************************************************************!*\
!*** ./packages/mdc-chips/deprecated/chip-set/constants.ts ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssClasses = exports.strings = void 0;
exports.strings = {
CHIP_SELECTOR: '.mdc-chip'
};
exports.cssClasses = {
CHOICE: 'mdc-chip-set--choice',
FILTER: 'mdc-chip-set--filter'
};
/***/ }),
/***/ "./packages/mdc-chips/deprecated/chip-set/foundation.ts":
/*!**************************************************************!*\
!*** ./packages/mdc-chips/deprecated/chip-set/foundation.ts ***!
\**************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCChipSetFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ../chip/constants */ "./packages/mdc-chips/deprecated/chip/constants.ts");
var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/deprecated/chip-set/constants.ts");
var MDCChipSetFoundation = /** @class */function (_super) {
__extends(MDCChipSetFoundation, _super);
function MDCChipSetFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCChipSetFoundation.defaultAdapter), adapter)) || this;
/**
* The ids of the selected chips in the set. Only used for choice chip set or filter chip set.
*/
_this.selectedChipIds = [];
return _this;
}
Object.defineProperty(MDCChipSetFoundation, "strings", {
get: function get() {
return constants_2.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCChipSetFoundation, "cssClasses", {
get: function get() {
return constants_2.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCChipSetFoundation, "defaultAdapter", {
get: function get() {
return {
announceMessage: function announceMessage() {
return undefined;
},
focusChipPrimaryActionAtIndex: function focusChipPrimaryActionAtIndex() {
return undefined;
},
focusChipTrailingActionAtIndex: function focusChipTrailingActionAtIndex() {
return undefined;
},
getChipListCount: function getChipListCount() {
return -1;
},
getIndexOfChipById: function getIndexOfChipById() {
return -1;
},
hasClass: function hasClass() {
return false;
},
isRTL: function isRTL() {
return false;
},
removeChipAtIndex: function removeChipAtIndex() {
return undefined;
},
removeFocusFromChipAtIndex: function removeFocusFromChipAtIndex() {
return undefined;
},
selectChipAtIndex: function selectChipAtIndex() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
/**
* Returns an array of the IDs of all selected chips.
*/
MDCChipSetFoundation.prototype.getSelectedChipIds = function () {
return this.selectedChipIds.slice();
};
/**
* Selects the chip with the given id. Deselects all other chips if the chip set is of the choice variant.
* Does not notify clients of the updated selection state.
*/
MDCChipSetFoundation.prototype.select = function (chipId) {
this.selectImpl(chipId, false);
};
/**
* Handles a chip interaction event
*/
MDCChipSetFoundation.prototype.handleChipInteraction = function (_a) {
var chipId = _a.chipId;
var index = this.adapter.getIndexOfChipById(chipId);
this.removeFocusFromChipsExcept(index);
if (this.adapter.hasClass(constants_2.cssClasses.CHOICE) || this.adapter.hasClass(constants_2.cssClasses.FILTER)) {
this.toggleSelect(chipId);
}
};
/**
* Handles a chip selection event, used to handle discrepancy when selection state is set directly on the Chip.
*/
MDCChipSetFoundation.prototype.handleChipSelection = function (_a) {
var chipId = _a.chipId,
selected = _a.selected,
shouldIgnore = _a.shouldIgnore;
// Early exit if we should ignore the event
if (shouldIgnore) {
return;
}
var chipIsSelected = this.selectedChipIds.indexOf(chipId) >= 0;
if (selected && !chipIsSelected) {
this.select(chipId);
} else if (!selected && chipIsSelected) {
this.deselectImpl(chipId);
}
};
/**
* Handles the event when a chip is removed.
*/
MDCChipSetFoundation.prototype.handleChipRemoval = function (_a) {
var chipId = _a.chipId,
removedAnnouncement = _a.removedAnnouncement;
if (removedAnnouncement) {
this.adapter.announceMessage(removedAnnouncement);
}
var index = this.adapter.getIndexOfChipById(chipId);
this.deselectAndNotifyClients(chipId);
this.adapter.removeChipAtIndex(index);
var maxIndex = this.adapter.getChipListCount() - 1;
if (maxIndex < 0) {
return;
}
var nextIndex = Math.min(index, maxIndex);
this.removeFocusFromChipsExcept(nextIndex);
// After removing a chip, we should focus the trailing action for the next chip.
this.adapter.focusChipTrailingActionAtIndex(nextIndex);
};
/**
* Handles a chip navigation event.
*/
MDCChipSetFoundation.prototype.handleChipNavigation = function (_a) {
var chipId = _a.chipId,
key = _a.key,
source = _a.source;
var maxIndex = this.adapter.getChipListCount() - 1;
var index = this.adapter.getIndexOfChipById(chipId);
// Early exit if the index is out of range or the key is unusable
if (index === -1 || !constants_1.navigationKeys.has(key)) {
return;
}
var isRTL = this.adapter.isRTL();
var isLeftKey = key === constants_1.strings.ARROW_LEFT_KEY || key === constants_1.strings.IE_ARROW_LEFT_KEY;
var isRightKey = key === constants_1.strings.ARROW_RIGHT_KEY || key === constants_1.strings.IE_ARROW_RIGHT_KEY;
var isDownKey = key === constants_1.strings.ARROW_DOWN_KEY || key === constants_1.strings.IE_ARROW_DOWN_KEY;
var shouldIncrement = !isRTL && isRightKey || isRTL && isLeftKey || isDownKey;
var isHome = key === constants_1.strings.HOME_KEY;
var isEnd = key === constants_1.strings.END_KEY;
if (shouldIncrement) {
index++;
} else if (isHome) {
index = 0;
} else if (isEnd) {
index = maxIndex;
} else {
index--;
}
// Early exit if the index is out of bounds
if (index < 0 || index > maxIndex) {
return;
}
this.removeFocusFromChipsExcept(index);
this.focusChipAction(index, key, source);
};
MDCChipSetFoundation.prototype.focusChipAction = function (index, key, source) {
var shouldJumpChips = constants_1.jumpChipKeys.has(key);
if (shouldJumpChips && source === constants_1.EventSource.PRIMARY) {
return this.adapter.focusChipPrimaryActionAtIndex(index);
}
if (shouldJumpChips && source === constants_1.EventSource.TRAILING) {
return this.adapter.focusChipTrailingActionAtIndex(index);
}
var dir = this.getDirection(key);
if (dir === constants_1.Direction.LEFT) {
return this.adapter.focusChipTrailingActionAtIndex(index);
}
if (dir === constants_1.Direction.RIGHT) {
return this.adapter.focusChipPrimaryActionAtIndex(index);
}
};
MDCChipSetFoundation.prototype.getDirection = function (key) {
var isRTL = this.adapter.isRTL();
var isLeftKey = key === constants_1.strings.ARROW_LEFT_KEY || key === constants_1.strings.IE_ARROW_LEFT_KEY;
var isRightKey = key === constants_1.strings.ARROW_RIGHT_KEY || key === constants_1.strings.IE_ARROW_RIGHT_KEY;
if (!isRTL && isLeftKey || isRTL && isRightKey) {
return constants_1.Direction.LEFT;
}
return constants_1.Direction.RIGHT;
};
/**
* Deselects the chip with the given id and optionally notifies clients.
*/
MDCChipSetFoundation.prototype.deselectImpl = function (chipId, shouldNotifyClients) {
if (shouldNotifyClients === void 0) {
shouldNotifyClients = false;
}
var index = this.selectedChipIds.indexOf(chipId);
if (index >= 0) {
this.selectedChipIds.splice(index, 1);
var chipIndex = this.adapter.getIndexOfChipById(chipId);
this.adapter.selectChipAtIndex(chipIndex, /** isSelected */false, shouldNotifyClients);
}
};
/**
* Deselects the chip with the given id and notifies clients.
*/
MDCChipSetFoundation.prototype.deselectAndNotifyClients = function (chipId) {
this.deselectImpl(chipId, true);
};
/**
* Toggles selection of the chip with the given id.
*/
MDCChipSetFoundation.prototype.toggleSelect = function (chipId) {
if (this.selectedChipIds.indexOf(chipId) >= 0) {
this.deselectAndNotifyClients(chipId);
} else {
this.selectAndNotifyClients(chipId);
}
};
MDCChipSetFoundation.prototype.removeFocusFromChipsExcept = function (index) {
var chipCount = this.adapter.getChipListCount();
for (var i = 0; i < chipCount; i++) {
if (i !== index) {
this.adapter.removeFocusFromChipAtIndex(i);
}
}
};
MDCChipSetFoundation.prototype.selectAndNotifyClients = function (chipId) {
this.selectImpl(chipId, true);
};
MDCChipSetFoundation.prototype.selectImpl = function (chipId, shouldNotifyClients) {
if (this.selectedChipIds.indexOf(chipId) >= 0) {
return;
}
if (this.adapter.hasClass(constants_2.cssClasses.CHOICE) && this.selectedChipIds.length > 0) {
var previouslySelectedChip = this.selectedChipIds[0];
var previouslySelectedIndex = this.adapter.getIndexOfChipById(previouslySelectedChip);
this.selectedChipIds = [];
this.adapter.selectChipAtIndex(previouslySelectedIndex, /** isSelected */false, shouldNotifyClients);
}
this.selectedChipIds.push(chipId);
var index = this.adapter.getIndexOfChipById(chipId);
this.adapter.selectChipAtIndex(index, /** isSelected */true, shouldNotifyClients);
};
return MDCChipSetFoundation;
}(foundation_1.MDCFoundation);
exports.MDCChipSetFoundation = MDCChipSetFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCChipSetFoundation;
/***/ }),
/***/ "./packages/mdc-chips/deprecated/chip-set/index.ts":
/*!*********************************************************!*\
!*** ./packages/mdc-chips/deprecated/chip-set/index.ts ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.chipSetStrings = exports.chipSetCssClasses = void 0;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-chips/deprecated/chip-set/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-chips/deprecated/chip-set/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-chips/deprecated/chip-set/foundation.ts"), exports);
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/deprecated/chip-set/constants.ts");
Object.defineProperty(exports, "chipSetCssClasses", { enumerable: true, get: function get() {
return constants_1.cssClasses;
} });
Object.defineProperty(exports, "chipSetStrings", { enumerable: true, get: function get() {
return constants_1.strings;
} });
/***/ }),
/***/ "./packages/mdc-chips/deprecated/chip/adapter.ts":
/*!*******************************************************!*\
!*** ./packages/mdc-chips/deprecated/chip/adapter.ts ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-chips/deprecated/chip/component.ts":
/*!*********************************************************!*\
!*** ./packages/mdc-chips/deprecated/chip/component.ts ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCChip = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
var component_3 = __webpack_require__(/*! ../trailingaction/component */ "./packages/mdc-chips/deprecated/trailingaction/component.ts");
var constants_1 = __webpack_require__(/*! ../trailingaction/constants */ "./packages/mdc-chips/deprecated/trailingaction/constants.ts");
var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/deprecated/chip/constants.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-chips/deprecated/chip/foundation.ts");
var MDCChip = /** @class */function (_super) {
__extends(MDCChip, _super);
function MDCChip() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(MDCChip.prototype, "selected", {
/**
* @return Whether the chip is selected.
*/
get: function get() {
return this.foundation.isSelected();
},
/**
* Sets selected state on the chip.
*/
set: function set(selected) {
this.foundation.setSelected(selected);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCChip.prototype, "shouldRemoveOnTrailingIconClick", {
/**
* @return Whether a trailing icon click should trigger exit/removal of the chip.
*/
get: function get() {
return this.foundation.getShouldRemoveOnTrailingIconClick();
},
/**
* Sets whether a trailing icon click should trigger exit/removal of the chip.
*/
set: function set(shouldRemove) {
this.foundation.setShouldRemoveOnTrailingIconClick(shouldRemove);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCChip.prototype, "setShouldFocusPrimaryActionOnClick", {
/**
* Sets whether a clicking on the chip should focus the primary action.
*/
set: function set(shouldFocus) {
this.foundation.setShouldFocusPrimaryActionOnClick(shouldFocus);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCChip.prototype, "ripple", {
get: function get() {
return this.rippleSurface;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCChip.prototype, "id", {
get: function get() {
return this.root.id;
},
enumerable: false,
configurable: true
});
MDCChip.attachTo = function (root) {
return new MDCChip(root);
};
MDCChip.prototype.initialize = function (rippleFactory, trailingActionFactory) {
var _this = this;
if (rippleFactory === void 0) {
rippleFactory = function rippleFactory(el, foundation) {
return new component_2.MDCRipple(el, foundation);
};
}
if (trailingActionFactory === void 0) {
trailingActionFactory = function trailingActionFactory(el) {
return new component_3.MDCChipTrailingAction(el);
};
}
this.leadingIcon = this.root.querySelector(constants_2.strings.LEADING_ICON_SELECTOR);
this.checkmark = this.root.querySelector(constants_2.strings.CHECKMARK_SELECTOR);
this.primaryAction = this.root.querySelector(constants_2.strings.PRIMARY_ACTION_SELECTOR);
var trailingActionEl = this.root.querySelector(constants_2.strings.TRAILING_ACTION_SELECTOR);
if (trailingActionEl) {
this.trailingAction = trailingActionFactory(trailingActionEl);
}
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var rippleAdapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { computeBoundingRect: function computeBoundingRect() {
return _this.foundation.getDimensions();
} });
this.rippleSurface = rippleFactory(this.root, new foundation_1.MDCRippleFoundation(rippleAdapter));
};
MDCChip.prototype.initialSyncWithDOM = function () {
var _this = this;
// Custom events
this.handleTrailingActionInteraction = function () {
_this.foundation.handleTrailingActionInteraction();
};
this.handleTrailingActionNavigation = function (evt) {
_this.foundation.handleTrailingActionNavigation(evt);
};
// Native events
this.handleClick = function () {
_this.foundation.handleClick();
};
this.handleKeydown = function (evt) {
_this.foundation.handleKeydown(evt);
};
this.handleTransitionEnd = function (evt) {
_this.foundation.handleTransitionEnd(evt);
};
this.handleFocusIn = function (evt) {
_this.foundation.handleFocusIn(evt);
};
this.handleFocusOut = function (evt) {
_this.foundation.handleFocusOut(evt);
};
this.listen('transitionend', this.handleTransitionEnd);
this.listen('click', this.handleClick);
this.listen('keydown', this.handleKeydown);
this.listen('focusin', this.handleFocusIn);
this.listen('focusout', this.handleFocusOut);
if (this.trailingAction) {
this.listen(constants_1.strings.INTERACTION_EVENT, this.handleTrailingActionInteraction);
this.listen(constants_1.strings.NAVIGATION_EVENT, this.handleTrailingActionNavigation);
}
};
MDCChip.prototype.destroy = function () {
this.rippleSurface.destroy();
this.unlisten('transitionend', this.handleTransitionEnd);
this.unlisten('keydown', this.handleKeydown);
this.unlisten('click', this.handleClick);
this.unlisten('focusin', this.handleFocusIn);
this.unlisten('focusout', this.handleFocusOut);
if (this.trailingAction) {
this.unlisten(constants_1.strings.INTERACTION_EVENT, this.handleTrailingActionInteraction);
this.unlisten(constants_1.strings.NAVIGATION_EVENT, this.handleTrailingActionNavigation);
}
_super.prototype.destroy.call(this);
};
/**
* Begins the exit animation which leads to removal of the chip.
*/
MDCChip.prototype.beginExit = function () {
this.foundation.beginExit();
};
MDCChip.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
addClassToLeadingIcon: function addClassToLeadingIcon(className) {
if (_this.leadingIcon) {
_this.leadingIcon.classList.add(className);
}
},
eventTargetHasClass: function eventTargetHasClass(target, className) {
return target ? target.classList.contains(className) : false;
},
focusPrimaryAction: function focusPrimaryAction() {
if (_this.primaryAction) {
_this.primaryAction.focus();
}
},
focusTrailingAction: function focusTrailingAction() {
if (_this.trailingAction) {
_this.trailingAction.focus();
}
},
getAttribute: function getAttribute(attr) {
return _this.root.getAttribute(attr);
},
getCheckmarkBoundingClientRect: function getCheckmarkBoundingClientRect() {
return _this.checkmark ? _this.checkmark.getBoundingClientRect() : null;
},
getComputedStyleValue: function getComputedStyleValue(propertyName) {
return window.getComputedStyle(_this.root).getPropertyValue(propertyName);
},
getRootBoundingClientRect: function getRootBoundingClientRect() {
return _this.root.getBoundingClientRect();
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
hasLeadingIcon: function hasLeadingIcon() {
return !!_this.leadingIcon;
},
isRTL: function isRTL() {
return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
},
isTrailingActionNavigable: function isTrailingActionNavigable() {
if (_this.trailingAction) {
return _this.trailingAction.isNavigable();
}
return false;
},
notifyInteraction: function notifyInteraction() {
return _this.emit(constants_2.strings.INTERACTION_EVENT, { chipId: _this.id }, true /* shouldBubble */);
},
notifyNavigation: function notifyNavigation(key, source) {
return _this.emit(constants_2.strings.NAVIGATION_EVENT, { chipId: _this.id, key: key, source: source }, true /* shouldBubble */);
},
notifyRemoval: function notifyRemoval(removedAnnouncement) {
_this.emit(constants_2.strings.REMOVAL_EVENT, { chipId: _this.id, removedAnnouncement: removedAnnouncement }, true /* shouldBubble */);
},
notifySelection: function notifySelection(selected, shouldIgnore) {
return _this.emit(constants_2.strings.SELECTION_EVENT, { chipId: _this.id, selected: selected, shouldIgnore: shouldIgnore }, true /* shouldBubble */);
},
notifyTrailingIconInteraction: function notifyTrailingIconInteraction() {
return _this.emit(constants_2.strings.TRAILING_ICON_INTERACTION_EVENT, { chipId: _this.id }, true /* shouldBubble */);
},
notifyEditStart: function notifyEditStart() {},
notifyEditFinish: function notifyEditFinish() {},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
removeClassFromLeadingIcon: function removeClassFromLeadingIcon(className) {
if (_this.leadingIcon) {
_this.leadingIcon.classList.remove(className);
}
},
removeTrailingActionFocus: function removeTrailingActionFocus() {
if (_this.trailingAction) {
_this.trailingAction.removeFocus();
}
},
setPrimaryActionAttr: function setPrimaryActionAttr(attr, value) {
if (_this.primaryAction) {
_this.primaryAction.setAttribute(attr, value);
}
},
setStyleProperty: function setStyleProperty(propertyName, value) {
return _this.root.style.setProperty(propertyName, value);
}
};
return new foundation_2.MDCChipFoundation(adapter);
};
MDCChip.prototype.setSelectedFromChipSet = function (selected, shouldNotifyClients) {
this.foundation.setSelectedFromChipSet(selected, shouldNotifyClients);
};
MDCChip.prototype.focusPrimaryAction = function () {
this.foundation.focusPrimaryAction();
};
MDCChip.prototype.focusTrailingAction = function () {
this.foundation.focusTrailingAction();
};
MDCChip.prototype.removeFocus = function () {
this.foundation.removeFocus();
};
MDCChip.prototype.remove = function () {
var parent = this.root.parentNode;
if (parent !== null) {
parent.removeChild(this.root);
}
};
return MDCChip;
}(component_1.MDCComponent);
exports.MDCChip = MDCChip;
/***/ }),
/***/ "./packages/mdc-chips/deprecated/chip/constants.ts":
/*!*********************************************************!*\
!*** ./packages/mdc-chips/deprecated/chip/constants.ts ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.jumpChipKeys = exports.navigationKeys = exports.cssClasses = exports.strings = exports.EventSource = exports.Direction = void 0;
var Direction;
(function (Direction) {
Direction["LEFT"] = "left";
Direction["RIGHT"] = "right";
})(Direction = exports.Direction || (exports.Direction = {}));
var EventSource;
(function (EventSource) {
EventSource["PRIMARY"] = "primary";
EventSource["TRAILING"] = "trailing";
EventSource["NONE"] = "none";
})(EventSource = exports.EventSource || (exports.EventSource = {}));
exports.strings = {
ADDED_ANNOUNCEMENT_ATTRIBUTE: 'data-mdc-chip-added-announcement',
ARIA_CHECKED: 'aria-checked',
ARROW_DOWN_KEY: 'ArrowDown',
ARROW_LEFT_KEY: 'ArrowLeft',
ARROW_RIGHT_KEY: 'ArrowRight',
ARROW_UP_KEY: 'ArrowUp',
BACKSPACE_KEY: 'Backspace',
CHECKMARK_SELECTOR: '.mdc-chip__checkmark',
DELETE_KEY: 'Delete',
END_KEY: 'End',
ENTER_KEY: 'Enter',
ENTRY_ANIMATION_NAME: 'mdc-chip-entry',
HOME_KEY: 'Home',
IE_ARROW_DOWN_KEY: 'Down',
IE_ARROW_LEFT_KEY: 'Left',
IE_ARROW_RIGHT_KEY: 'Right',
IE_ARROW_UP_KEY: 'Up',
IE_DELETE_KEY: 'Del',
INTERACTION_EVENT: 'MDCChip:interaction',
LEADING_ICON_SELECTOR: '.mdc-chip__icon--leading',
NAVIGATION_EVENT: 'MDCChip:navigation',
PRIMARY_ACTION_SELECTOR: '.mdc-chip__primary-action',
REMOVED_ANNOUNCEMENT_ATTRIBUTE: 'data-mdc-chip-removed-announcement',
REMOVAL_EVENT: 'MDCChip:removal',
SELECTION_EVENT: 'MDCChip:selection',
SPACEBAR_KEY: ' ',
TAB_INDEX: 'tabindex',
TRAILING_ACTION_SELECTOR: '.mdc-chip-trailing-action',
TRAILING_ICON_INTERACTION_EVENT: 'MDCChip:trailingIconInteraction',
TRAILING_ICON_SELECTOR: '.mdc-chip__icon--trailing'
};
exports.cssClasses = {
CHECKMARK: 'mdc-chip__checkmark',
CHIP_EXIT: 'mdc-chip--exit',
DELETABLE: 'mdc-chip--deletable',
EDITABLE: 'mdc-chip--editable',
EDITING: 'mdc-chip--editing',
HIDDEN_LEADING_ICON: 'mdc-chip__icon--leading-hidden',
LEADING_ICON: 'mdc-chip__icon--leading',
PRIMARY_ACTION: 'mdc-chip__primary-action',
PRIMARY_ACTION_FOCUSED: 'mdc-chip--primary-action-focused',
SELECTED: 'mdc-chip--selected',
TEXT: 'mdc-chip__text',
TRAILING_ACTION: 'mdc-chip__trailing-action',
TRAILING_ICON: 'mdc-chip__icon--trailing'
};
exports.navigationKeys = new Set();
// IE11 has no support for new Set with iterable so we need to initialize this by hand
exports.navigationKeys.add(exports.strings.ARROW_LEFT_KEY);
exports.navigationKeys.add(exports.strings.ARROW_RIGHT_KEY);
exports.navigationKeys.add(exports.strings.ARROW_DOWN_KEY);
exports.navigationKeys.add(exports.strings.ARROW_UP_KEY);
exports.navigationKeys.add(exports.strings.END_KEY);
exports.navigationKeys.add(exports.strings.HOME_KEY);
exports.navigationKeys.add(exports.strings.IE_ARROW_LEFT_KEY);
exports.navigationKeys.add(exports.strings.IE_ARROW_RIGHT_KEY);
exports.navigationKeys.add(exports.strings.IE_ARROW_DOWN_KEY);
exports.navigationKeys.add(exports.strings.IE_ARROW_UP_KEY);
exports.jumpChipKeys = new Set();
// IE11 has no support for new Set with iterable so we need to initialize this by hand
exports.jumpChipKeys.add(exports.strings.ARROW_UP_KEY);
exports.jumpChipKeys.add(exports.strings.ARROW_DOWN_KEY);
exports.jumpChipKeys.add(exports.strings.HOME_KEY);
exports.jumpChipKeys.add(exports.strings.END_KEY);
exports.jumpChipKeys.add(exports.strings.IE_ARROW_UP_KEY);
exports.jumpChipKeys.add(exports.strings.IE_ARROW_DOWN_KEY);
/***/ }),
/***/ "./packages/mdc-chips/deprecated/chip/foundation.ts":
/*!**********************************************************!*\
!*** ./packages/mdc-chips/deprecated/chip/foundation.ts ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCChipFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/deprecated/chip/constants.ts");
var emptyClientRect = {
bottom: 0,
height: 0,
left: 0,
right: 0,
top: 0,
width: 0
};
var FocusBehavior;
(function (FocusBehavior) {
FocusBehavior[FocusBehavior["SHOULD_FOCUS"] = 0] = "SHOULD_FOCUS";
FocusBehavior[FocusBehavior["SHOULD_NOT_FOCUS"] = 1] = "SHOULD_NOT_FOCUS";
})(FocusBehavior || (FocusBehavior = {}));
var MDCChipFoundation = /** @class */function (_super) {
__extends(MDCChipFoundation, _super);
function MDCChipFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCChipFoundation.defaultAdapter), adapter)) || this;
/** Whether a trailing icon click should immediately trigger exit/removal of the chip. */
_this.shouldRemoveOnTrailingIconClick = true;
/**
* Whether the primary action should receive focus on click. Should only be
* set to true for clients who programmatically give focus to a different
* element on the page when a chip is clicked (like a menu).
*/
_this.shouldFocusPrimaryActionOnClick = true;
return _this;
}
Object.defineProperty(MDCChipFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCChipFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCChipFoundation, "defaultAdapter", {
get: function get() {
return {
addClass: function addClass() {
return undefined;
},
addClassToLeadingIcon: function addClassToLeadingIcon() {
return undefined;
},
eventTargetHasClass: function eventTargetHasClass() {
return false;
},
focusPrimaryAction: function focusPrimaryAction() {
return undefined;
},
focusTrailingAction: function focusTrailingAction() {
return undefined;
},
getAttribute: function getAttribute() {
return null;
},
getCheckmarkBoundingClientRect: function getCheckmarkBoundingClientRect() {
return emptyClientRect;
},
getComputedStyleValue: function getComputedStyleValue() {
return '';
},
getRootBoundingClientRect: function getRootBoundingClientRect() {
return emptyClientRect;
},
hasClass: function hasClass() {
return false;
},
hasLeadingIcon: function hasLeadingIcon() {
return false;
},
isRTL: function isRTL() {
return false;
},
isTrailingActionNavigable: function isTrailingActionNavigable() {
return false;
},
notifyEditFinish: function notifyEditFinish() {
return undefined;
},
notifyEditStart: function notifyEditStart() {
return undefined;
},
notifyInteraction: function notifyInteraction() {
return undefined;
},
notifyNavigation: function notifyNavigation() {
return undefined;
},
notifyRemoval: function notifyRemoval() {
return undefined;
},
notifySelection: function notifySelection() {
return undefined;
},
notifyTrailingIconInteraction: function notifyTrailingIconInteraction() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
removeClassFromLeadingIcon: function removeClassFromLeadingIcon() {
return undefined;
},
removeTrailingActionFocus: function removeTrailingActionFocus() {
return undefined;
},
setPrimaryActionAttr: function setPrimaryActionAttr() {
return undefined;
},
setStyleProperty: function setStyleProperty() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCChipFoundation.prototype.isSelected = function () {
return this.adapter.hasClass(constants_1.cssClasses.SELECTED);
};
MDCChipFoundation.prototype.isEditable = function () {
return this.adapter.hasClass(constants_1.cssClasses.EDITABLE);
};
MDCChipFoundation.prototype.isEditing = function () {
return this.adapter.hasClass(constants_1.cssClasses.EDITING);
};
MDCChipFoundation.prototype.setSelected = function (selected) {
this.setSelectedImpl(selected);
this.notifySelection(selected);
};
MDCChipFoundation.prototype.setSelectedFromChipSet = function (selected, shouldNotifyClients) {
this.setSelectedImpl(selected);
if (shouldNotifyClients) {
this.notifyIgnoredSelection(selected);
}
};
MDCChipFoundation.prototype.getShouldRemoveOnTrailingIconClick = function () {
return this.shouldRemoveOnTrailingIconClick;
};
MDCChipFoundation.prototype.setShouldRemoveOnTrailingIconClick = function (shouldRemove) {
this.shouldRemoveOnTrailingIconClick = shouldRemove;
};
MDCChipFoundation.prototype.setShouldFocusPrimaryActionOnClick = function (shouldFocus) {
this.shouldFocusPrimaryActionOnClick = shouldFocus;
};
MDCChipFoundation.prototype.getDimensions = function () {
var _this = this;
var getRootRect = function getRootRect() {
return _this.adapter.getRootBoundingClientRect();
};
var getCheckmarkRect = function getCheckmarkRect() {
return _this.adapter.getCheckmarkBoundingClientRect();
};
// When a chip has a checkmark and not a leading icon, the bounding rect changes in size depending on the current
// size of the checkmark.
if (!this.adapter.hasLeadingIcon()) {
var checkmarkRect = getCheckmarkRect();
if (checkmarkRect) {
var rootRect = getRootRect();
// Checkmark is a square, meaning the client rect's width and height are identical once the animation completes.
// However, the checkbox is initially hidden by setting the width to 0.
// To account for an initial width of 0, we use the checkbox's height instead (which equals the end-state width)
// when adding it to the root client rect's width.
return {
bottom: rootRect.bottom,
height: rootRect.height,
left: rootRect.left,
right: rootRect.right,
top: rootRect.top,
width: rootRect.width + checkmarkRect.height
};
}
}
return getRootRect();
};
/**
* Begins the exit animation which leads to removal of the chip.
*/
MDCChipFoundation.prototype.beginExit = function () {
this.adapter.addClass(constants_1.cssClasses.CHIP_EXIT);
};
MDCChipFoundation.prototype.handleClick = function () {
this.adapter.notifyInteraction();
this.setPrimaryActionFocusable(this.getFocusBehavior());
};
MDCChipFoundation.prototype.handleDoubleClick = function () {
if (this.isEditable()) {
this.startEditing();
}
};
/**
* Handles a transition end event on the root element.
*/
MDCChipFoundation.prototype.handleTransitionEnd = function (evt) {
var _this = this;
// Handle transition end event on the chip when it is about to be removed.
var shouldHandle = this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.CHIP_EXIT);
var widthIsAnimating = evt.propertyName === 'width';
var opacityIsAnimating = evt.propertyName === 'opacity';
if (shouldHandle && opacityIsAnimating) {
// See: https://css-tricks.com/using-css-transitions-auto-dimensions/#article-header-id-5
var chipWidth_1 = this.adapter.getComputedStyleValue('width');
// On the next frame (once we get the computed width), explicitly set the chip's width
// to its current pixel width, so we aren't transitioning out of 'auto'.
requestAnimationFrame(function () {
_this.adapter.setStyleProperty('width', chipWidth_1);
// To mitigate jitter, start transitioning padding and margin before width.
_this.adapter.setStyleProperty('padding', '0');
_this.adapter.setStyleProperty('margin', '0');
// On the next frame (once width is explicitly set), transition width to 0.
requestAnimationFrame(function () {
_this.adapter.setStyleProperty('width', '0');
});
});
return;
}
if (shouldHandle && widthIsAnimating) {
this.removeFocus();
var removedAnnouncement = this.adapter.getAttribute(constants_1.strings.REMOVED_ANNOUNCEMENT_ATTRIBUTE);
this.adapter.notifyRemoval(removedAnnouncement);
}
// Handle a transition end event on the leading icon or checkmark, since the transition end event bubbles.
if (!opacityIsAnimating) {
return;
}
var shouldHideLeadingIcon = this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.LEADING_ICON) && this.adapter.hasClass(constants_1.cssClasses.SELECTED);
var shouldShowLeadingIcon = this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.CHECKMARK) && !this.adapter.hasClass(constants_1.cssClasses.SELECTED);
if (shouldHideLeadingIcon) {
this.adapter.addClassToLeadingIcon(constants_1.cssClasses.HIDDEN_LEADING_ICON);
return;
}
if (shouldShowLeadingIcon) {
this.adapter.removeClassFromLeadingIcon(constants_1.cssClasses.HIDDEN_LEADING_ICON);
return;
}
};
MDCChipFoundation.prototype.handleFocusIn = function (evt) {
// Early exit if the event doesn't come from the primary action
if (!this.eventFromPrimaryAction(evt)) {
return;
}
this.adapter.addClass(constants_1.cssClasses.PRIMARY_ACTION_FOCUSED);
};
MDCChipFoundation.prototype.handleFocusOut = function (evt) {
// Early exit if the event doesn't come from the primary action
if (!this.eventFromPrimaryAction(evt)) {
return;
}
if (this.isEditing()) {
this.finishEditing();
}
this.adapter.removeClass(constants_1.cssClasses.PRIMARY_ACTION_FOCUSED);
};
/**
* Handles an interaction event on the trailing icon element. This is used to
* prevent the ripple from activating on interaction with the trailing icon.
*/
MDCChipFoundation.prototype.handleTrailingActionInteraction = function () {
this.adapter.notifyTrailingIconInteraction();
this.removeChip();
};
/**
* Handles a keydown event from the root element.
*/
MDCChipFoundation.prototype.handleKeydown = function (evt) {
if (this.isEditing()) {
if (this.shouldFinishEditing(evt)) {
evt.preventDefault();
this.finishEditing();
}
// When editing, the foundation should only handle key events that finish
// the editing process.
return;
}
if (this.isEditable()) {
if (this.shouldStartEditing(evt)) {
evt.preventDefault();
this.startEditing();
}
}
if (this.shouldNotifyInteraction(evt)) {
this.adapter.notifyInteraction();
this.setPrimaryActionFocusable(this.getFocusBehavior());
return;
}
if (this.isDeleteAction(evt)) {
evt.preventDefault();
this.removeChip();
return;
}
// Early exit if the key is not usable
if (!constants_1.navigationKeys.has(evt.key)) {
return;
}
// Prevent default behavior for movement keys which could include scrolling
evt.preventDefault();
this.focusNextAction(evt.key, constants_1.EventSource.PRIMARY);
};
MDCChipFoundation.prototype.handleTrailingActionNavigation = function (evt) {
this.focusNextAction(evt.detail.key, constants_1.EventSource.TRAILING);
};
/**
* Called by the chip set to remove focus from the chip actions.
*/
MDCChipFoundation.prototype.removeFocus = function () {
this.adapter.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '-1');
this.adapter.removeTrailingActionFocus();
};
/**
* Called by the chip set to focus the primary action.
*
*/
MDCChipFoundation.prototype.focusPrimaryAction = function () {
this.setPrimaryActionFocusable(FocusBehavior.SHOULD_FOCUS);
};
/**
* Called by the chip set to focus the trailing action (if present), otherwise
* gives focus to the trailing action.
*/
MDCChipFoundation.prototype.focusTrailingAction = function () {
var trailingActionIsNavigable = this.adapter.isTrailingActionNavigable();
if (trailingActionIsNavigable) {
this.adapter.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '-1');
this.adapter.focusTrailingAction();
return;
}
this.focusPrimaryAction();
};
MDCChipFoundation.prototype.setPrimaryActionFocusable = function (focusBehavior) {
this.adapter.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '0');
if (focusBehavior === FocusBehavior.SHOULD_FOCUS) {
this.adapter.focusPrimaryAction();
}
this.adapter.removeTrailingActionFocus();
};
MDCChipFoundation.prototype.getFocusBehavior = function () {
if (this.shouldFocusPrimaryActionOnClick) {
return FocusBehavior.SHOULD_FOCUS;
}
return FocusBehavior.SHOULD_NOT_FOCUS;
};
MDCChipFoundation.prototype.focusNextAction = function (key, source) {
var isTrailingActionNavigable = this.adapter.isTrailingActionNavigable();
var dir = this.getDirection(key);
// Early exit if the key should jump chips
if (constants_1.jumpChipKeys.has(key) || !isTrailingActionNavigable) {
this.adapter.notifyNavigation(key, source);
return;
}
if (source === constants_1.EventSource.PRIMARY && dir === constants_1.Direction.RIGHT) {
this.focusTrailingAction();
return;
}
if (source === constants_1.EventSource.TRAILING && dir === constants_1.Direction.LEFT) {
this.focusPrimaryAction();
return;
}
this.adapter.notifyNavigation(key, constants_1.EventSource.NONE);
};
MDCChipFoundation.prototype.getDirection = function (key) {
var isRTL = this.adapter.isRTL();
var isLeftKey = key === constants_1.strings.ARROW_LEFT_KEY || key === constants_1.strings.IE_ARROW_LEFT_KEY;
var isRightKey = key === constants_1.strings.ARROW_RIGHT_KEY || key === constants_1.strings.IE_ARROW_RIGHT_KEY;
if (!isRTL && isLeftKey || isRTL && isRightKey) {
return constants_1.Direction.LEFT;
}
return constants_1.Direction.RIGHT;
};
MDCChipFoundation.prototype.removeChip = function () {
if (this.shouldRemoveOnTrailingIconClick) {
this.beginExit();
}
};
MDCChipFoundation.prototype.shouldStartEditing = function (evt) {
return this.eventFromPrimaryAction(evt) && evt.key === constants_1.strings.ENTER_KEY;
};
MDCChipFoundation.prototype.shouldFinishEditing = function (evt) {
return evt.key === constants_1.strings.ENTER_KEY;
};
MDCChipFoundation.prototype.shouldNotifyInteraction = function (evt) {
return evt.key === constants_1.strings.ENTER_KEY || evt.key === constants_1.strings.SPACEBAR_KEY;
};
MDCChipFoundation.prototype.isDeleteAction = function (evt) {
var isDeletable = this.adapter.hasClass(constants_1.cssClasses.DELETABLE);
return isDeletable && (evt.key === constants_1.strings.BACKSPACE_KEY || evt.key === constants_1.strings.DELETE_KEY || evt.key === constants_1.strings.IE_DELETE_KEY);
};
MDCChipFoundation.prototype.setSelectedImpl = function (selected) {
if (selected) {
this.adapter.addClass(constants_1.cssClasses.SELECTED);
this.adapter.setPrimaryActionAttr(constants_1.strings.ARIA_CHECKED, 'true');
} else {
this.adapter.removeClass(constants_1.cssClasses.SELECTED);
this.adapter.setPrimaryActionAttr(constants_1.strings.ARIA_CHECKED, 'false');
}
};
MDCChipFoundation.prototype.notifySelection = function (selected) {
this.adapter.notifySelection(selected, false);
};
MDCChipFoundation.prototype.notifyIgnoredSelection = function (selected) {
this.adapter.notifySelection(selected, true);
};
MDCChipFoundation.prototype.eventFromPrimaryAction = function (evt) {
return this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.PRIMARY_ACTION);
};
MDCChipFoundation.prototype.startEditing = function () {
this.adapter.addClass(constants_1.cssClasses.EDITING);
this.adapter.notifyEditStart();
};
MDCChipFoundation.prototype.finishEditing = function () {
this.adapter.removeClass(constants_1.cssClasses.EDITING);
this.adapter.notifyEditFinish();
};
return MDCChipFoundation;
}(foundation_1.MDCFoundation);
exports.MDCChipFoundation = MDCChipFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCChipFoundation;
/***/ }),
/***/ "./packages/mdc-chips/deprecated/chip/index.ts":
/*!*****************************************************!*\
!*** ./packages/mdc-chips/deprecated/chip/index.ts ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.chipStrings = exports.chipCssClasses = void 0;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-chips/deprecated/chip/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-chips/deprecated/chip/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-chips/deprecated/chip/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-chips/deprecated/chip/types.ts"), exports);
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/deprecated/chip/constants.ts");
Object.defineProperty(exports, "chipCssClasses", { enumerable: true, get: function get() {
return constants_1.cssClasses;
} });
Object.defineProperty(exports, "chipStrings", { enumerable: true, get: function get() {
return constants_1.strings;
} });
/***/ }),
/***/ "./packages/mdc-chips/deprecated/chip/types.ts":
/*!*****************************************************!*\
!*** ./packages/mdc-chips/deprecated/chip/types.ts ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-chips/deprecated/index.ts":
/*!************************************************!*\
!*** ./packages/mdc-chips/deprecated/index.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./trailingaction/index */ "./packages/mdc-chips/deprecated/trailingaction/index.ts"), exports);
__exportStar(__webpack_require__(/*! ./chip/index */ "./packages/mdc-chips/deprecated/chip/index.ts"), exports);
__exportStar(__webpack_require__(/*! ./chip-set/index */ "./packages/mdc-chips/deprecated/chip-set/index.ts"), exports);
/***/ }),
/***/ "./packages/mdc-chips/deprecated/trailingaction/adapter.ts":
/*!*****************************************************************!*\
!*** ./packages/mdc-chips/deprecated/trailingaction/adapter.ts ***!
\*****************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-chips/deprecated/trailingaction/component.ts":
/*!*******************************************************************!*\
!*** ./packages/mdc-chips/deprecated/trailingaction/component.ts ***!
\*******************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCChipTrailingAction = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/deprecated/trailingaction/constants.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-chips/deprecated/trailingaction/foundation.ts");
var MDCChipTrailingAction = /** @class */function (_super) {
__extends(MDCChipTrailingAction, _super);
function MDCChipTrailingAction() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(MDCChipTrailingAction.prototype, "ripple", {
get: function get() {
return this.rippleSurface;
},
enumerable: false,
configurable: true
});
MDCChipTrailingAction.attachTo = function (root) {
return new MDCChipTrailingAction(root);
};
MDCChipTrailingAction.prototype.initialize = function (rippleFactory) {
if (rippleFactory === void 0) {
rippleFactory = function rippleFactory(el, foundation) {
return new component_2.MDCRipple(el, foundation);
};
}
// DO NOT INLINE this variable. For backward compatibility, foundations take
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
// methods, we need a separate, strongly typed adapter variable.
var rippleAdapter = component_2.MDCRipple.createAdapter(this);
this.rippleSurface = rippleFactory(this.root, new foundation_1.MDCRippleFoundation(rippleAdapter));
};
MDCChipTrailingAction.prototype.initialSyncWithDOM = function () {
var _this = this;
this.handleClick = function (evt) {
_this.foundation.handleClick(evt);
};
this.handleKeydown = function (evt) {
_this.foundation.handleKeydown(evt);
};
this.listen('click', this.handleClick);
this.listen('keydown', this.handleKeydown);
};
MDCChipTrailingAction.prototype.destroy = function () {
this.rippleSurface.destroy();
this.unlisten('click', this.handleClick);
this.unlisten('keydown', this.handleKeydown);
_super.prototype.destroy.call(this);
};
MDCChipTrailingAction.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
// methods, we need a separate, strongly typed adapter variable.
var adapter = {
focus: function focus() {
// TODO(b/157231863): Migate MDCComponent#root to HTMLElement
_this.root.focus();
},
getAttribute: function getAttribute(attr) {
return _this.root.getAttribute(attr);
},
notifyInteraction: function notifyInteraction(trigger) {
return _this.emit(constants_1.strings.INTERACTION_EVENT, { trigger: trigger }, true /* shouldBubble */);
},
notifyNavigation: function notifyNavigation(key) {
_this.emit(constants_1.strings.NAVIGATION_EVENT, { key: key }, true /* shouldBubble */);
},
setAttribute: function setAttribute(attr, value) {
_this.root.setAttribute(attr, value);
}
};
return new foundation_2.MDCChipTrailingActionFoundation(adapter);
};
MDCChipTrailingAction.prototype.isNavigable = function () {
return this.foundation.isNavigable();
};
MDCChipTrailingAction.prototype.focus = function () {
this.foundation.focus();
};
MDCChipTrailingAction.prototype.removeFocus = function () {
this.foundation.removeFocus();
};
return MDCChipTrailingAction;
}(component_1.MDCComponent);
exports.MDCChipTrailingAction = MDCChipTrailingAction;
/***/ }),
/***/ "./packages/mdc-chips/deprecated/trailingaction/constants.ts":
/*!*******************************************************************!*\
!*** ./packages/mdc-chips/deprecated/trailingaction/constants.ts ***!
\*******************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.InteractionTrigger = void 0;
var InteractionTrigger;
(function (InteractionTrigger) {
InteractionTrigger[InteractionTrigger["UNSPECIFIED"] = 0] = "UNSPECIFIED";
InteractionTrigger[InteractionTrigger["CLICK"] = 1] = "CLICK";
InteractionTrigger[InteractionTrigger["BACKSPACE_KEY"] = 2] = "BACKSPACE_KEY";
InteractionTrigger[InteractionTrigger["DELETE_KEY"] = 3] = "DELETE_KEY";
InteractionTrigger[InteractionTrigger["SPACEBAR_KEY"] = 4] = "SPACEBAR_KEY";
InteractionTrigger[InteractionTrigger["ENTER_KEY"] = 5] = "ENTER_KEY";
})(InteractionTrigger = exports.InteractionTrigger || (exports.InteractionTrigger = {}));
exports.strings = {
ARIA_HIDDEN: 'aria-hidden',
INTERACTION_EVENT: 'MDCChipTrailingAction:interaction',
NAVIGATION_EVENT: 'MDCChipTrailingAction:navigation',
TAB_INDEX: 'tabindex'
};
/***/ }),
/***/ "./packages/mdc-chips/deprecated/trailingaction/foundation.ts":
/*!********************************************************************!*\
!*** ./packages/mdc-chips/deprecated/trailingaction/foundation.ts ***!
\********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCChipTrailingActionFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/deprecated/trailingaction/constants.ts");
var MDCChipTrailingActionFoundation = /** @class */function (_super) {
__extends(MDCChipTrailingActionFoundation, _super);
function MDCChipTrailingActionFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCChipTrailingActionFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCChipTrailingActionFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCChipTrailingActionFoundation, "defaultAdapter", {
get: function get() {
return {
focus: function focus() {
return undefined;
},
getAttribute: function getAttribute() {
return null;
},
setAttribute: function setAttribute() {
return undefined;
},
notifyInteraction: function notifyInteraction() {
return undefined;
},
notifyNavigation: function notifyNavigation() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCChipTrailingActionFoundation.prototype.handleClick = function (evt) {
evt.stopPropagation();
this.adapter.notifyInteraction(constants_1.InteractionTrigger.CLICK);
};
MDCChipTrailingActionFoundation.prototype.handleKeydown = function (evt) {
evt.stopPropagation();
var key = keyboard_1.normalizeKey(evt);
if (this.shouldNotifyInteractionFromKey(key)) {
var trigger = this.getTriggerFromKey(key);
this.adapter.notifyInteraction(trigger);
return;
}
if (keyboard_1.isNavigationEvent(evt)) {
this.adapter.notifyNavigation(key);
return;
}
};
MDCChipTrailingActionFoundation.prototype.removeFocus = function () {
this.adapter.setAttribute(constants_1.strings.TAB_INDEX, '-1');
};
MDCChipTrailingActionFoundation.prototype.focus = function () {
this.adapter.setAttribute(constants_1.strings.TAB_INDEX, '0');
this.adapter.focus();
};
MDCChipTrailingActionFoundation.prototype.isNavigable = function () {
return this.adapter.getAttribute(constants_1.strings.ARIA_HIDDEN) !== 'true';
};
MDCChipTrailingActionFoundation.prototype.shouldNotifyInteractionFromKey = function (key) {
var isFromActionKey = key === keyboard_1.KEY.ENTER || key === keyboard_1.KEY.SPACEBAR;
var isFromDeleteKey = key === keyboard_1.KEY.BACKSPACE || key === keyboard_1.KEY.DELETE;
return isFromActionKey || isFromDeleteKey;
};
MDCChipTrailingActionFoundation.prototype.getTriggerFromKey = function (key) {
if (key === keyboard_1.KEY.SPACEBAR) {
return constants_1.InteractionTrigger.SPACEBAR_KEY;
}
if (key === keyboard_1.KEY.ENTER) {
return constants_1.InteractionTrigger.ENTER_KEY;
}
if (key === keyboard_1.KEY.DELETE) {
return constants_1.InteractionTrigger.DELETE_KEY;
}
if (key === keyboard_1.KEY.BACKSPACE) {
return constants_1.InteractionTrigger.BACKSPACE_KEY;
}
// Default case, should never be returned
return constants_1.InteractionTrigger.UNSPECIFIED;
};
return MDCChipTrailingActionFoundation;
}(foundation_1.MDCFoundation);
exports.MDCChipTrailingActionFoundation = MDCChipTrailingActionFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCChipTrailingActionFoundation;
/***/ }),
/***/ "./packages/mdc-chips/deprecated/trailingaction/index.ts":
/*!***************************************************************!*\
!*** ./packages/mdc-chips/deprecated/trailingaction/index.ts ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.trailingActionStrings = void 0;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-chips/deprecated/trailingaction/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-chips/deprecated/trailingaction/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-chips/deprecated/trailingaction/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-chips/deprecated/trailingaction/types.ts"), exports);
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/deprecated/trailingaction/constants.ts");
Object.defineProperty(exports, "trailingActionStrings", { enumerable: true, get: function get() {
return constants_1.strings;
} });
/***/ }),
/***/ "./packages/mdc-chips/deprecated/trailingaction/types.ts":
/*!***************************************************************!*\
!*** ./packages/mdc-chips/deprecated/trailingaction/types.ts ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-circular-progress/adapter.ts":
/*!***************************************************!*\
!*** ./packages/mdc-circular-progress/adapter.ts ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-circular-progress/component.ts":
/*!*****************************************************!*\
!*** ./packages/mdc-circular-progress/component.ts ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCCircularProgress = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-circular-progress/foundation.ts");
var MDCCircularProgress = /** @class */function (_super) {
__extends(MDCCircularProgress, _super);
function MDCCircularProgress() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCCircularProgress.prototype.initialize = function () {
this.determinateCircle = this.root.querySelector(foundation_1.MDCCircularProgressFoundation.strings.DETERMINATE_CIRCLE_SELECTOR);
};
MDCCircularProgress.attachTo = function (root) {
return new MDCCircularProgress(root);
};
Object.defineProperty(MDCCircularProgress.prototype, "determinate", {
/**
* Sets whether the progress indicator is in determinate mode.
* @param isDeterminate Whether the indicator should be determinate.
*/
set: function set(value) {
this.foundation.setDeterminate(value);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCCircularProgress.prototype, "progress", {
/**
* Sets the current progress value. In indeterminate mode, this has no
* visual effect but will be reflected if the indicator is switched to
* determinate mode.
* @param value The current progress value, which must be between 0 and 1.
*/
set: function set(value) {
this.foundation.setProgress(value);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCCircularProgress.prototype, "isClosed", {
/**
* Whether the progress indicator is hidden.
*/
get: function get() {
return this.foundation.isClosed();
},
enumerable: false,
configurable: true
});
/**
* Shows the progress indicator.
*/
MDCCircularProgress.prototype.open = function () {
this.foundation.open();
};
/**
* Hides the progress indicator.
*/
MDCCircularProgress.prototype.close = function () {
this.foundation.close();
};
MDCCircularProgress.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
// methods, we need a separate, strongly typed adapter variable.
var adapter = {
addClass: function addClass(className) {
_this.root.classList.add(className);
},
getDeterminateCircleAttribute: function getDeterminateCircleAttribute(attributeName) {
return _this.determinateCircle.getAttribute(attributeName);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
removeAttribute: function removeAttribute(attributeName) {
_this.root.removeAttribute(attributeName);
},
setAttribute: function setAttribute(attributeName, value) {
_this.root.setAttribute(attributeName, value);
},
setDeterminateCircleAttribute: function setDeterminateCircleAttribute(attributeName, value) {
_this.determinateCircle.setAttribute(attributeName, value);
}
};
return new foundation_1.MDCCircularProgressFoundation(adapter);
};
return MDCCircularProgress;
}(component_1.MDCComponent);
exports.MDCCircularProgress = MDCCircularProgress;
/***/ }),
/***/ "./packages/mdc-circular-progress/constants.ts":
/*!*****************************************************!*\
!*** ./packages/mdc-circular-progress/constants.ts ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.cssClasses = void 0;
/**
* CSS class names used in component.
*/
exports.cssClasses = {
INDETERMINATE_CLASS: 'mdc-circular-progress--indeterminate',
CLOSED_CLASS: 'mdc-circular-progress--closed'
};
/**
* Attributes and selectors used in component.
*/
exports.strings = {
ARIA_HIDDEN: 'aria-hidden',
ARIA_VALUENOW: 'aria-valuenow',
DETERMINATE_CIRCLE_SELECTOR: '.mdc-circular-progress__determinate-circle',
RADIUS: 'r',
STROKE_DASHOFFSET: 'stroke-dashoffset'
};
/***/ }),
/***/ "./packages/mdc-circular-progress/foundation.ts":
/*!******************************************************!*\
!*** ./packages/mdc-circular-progress/foundation.ts ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCCircularProgressFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-circular-progress/constants.ts");
var MDCCircularProgressFoundation = /** @class */function (_super) {
__extends(MDCCircularProgressFoundation, _super);
function MDCCircularProgressFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCCircularProgressFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCCircularProgressFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCCircularProgressFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCCircularProgressFoundation, "defaultAdapter", {
get: function get() {
return {
addClass: function addClass() {
return undefined;
},
getDeterminateCircleAttribute: function getDeterminateCircleAttribute() {
return null;
},
hasClass: function hasClass() {
return false;
},
removeClass: function removeClass() {
return undefined;
},
removeAttribute: function removeAttribute() {
return undefined;
},
setAttribute: function setAttribute() {
return undefined;
},
setDeterminateCircleAttribute: function setDeterminateCircleAttribute() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCCircularProgressFoundation.prototype.init = function () {
this.closed = this.adapter.hasClass(constants_1.cssClasses.CLOSED_CLASS);
this.determinate = !this.adapter.hasClass(constants_1.cssClasses.INDETERMINATE_CLASS);
this.progress = 0;
if (this.determinate) {
this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, this.progress.toString());
}
this.radius = Number(this.adapter.getDeterminateCircleAttribute(constants_1.strings.RADIUS));
};
/**
* Sets whether the progress indicator is in determinate mode.
* @param determinate Whether the indicator should be determinate.
*/
MDCCircularProgressFoundation.prototype.setDeterminate = function (determinate) {
this.determinate = determinate;
if (this.determinate) {
this.adapter.removeClass(constants_1.cssClasses.INDETERMINATE_CLASS);
this.setProgress(this.progress);
} else {
this.adapter.addClass(constants_1.cssClasses.INDETERMINATE_CLASS);
this.adapter.removeAttribute(constants_1.strings.ARIA_VALUENOW);
}
};
MDCCircularProgressFoundation.prototype.isDeterminate = function () {
return this.determinate;
};
/**
* Sets the current progress value. In indeterminate mode, this has no
* visual effect but will be reflected if the indicator is switched to
* determinate mode.
* @param value The current progress value, which must be between 0 and 1.
*/
MDCCircularProgressFoundation.prototype.setProgress = function (value) {
this.progress = value;
if (this.determinate) {
var unfilledArcLength = (1 - this.progress) * (2 * Math.PI * this.radius);
this.adapter.setDeterminateCircleAttribute(constants_1.strings.STROKE_DASHOFFSET, "" + unfilledArcLength);
this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, this.progress.toString());
}
};
MDCCircularProgressFoundation.prototype.getProgress = function () {
return this.progress;
};
/**
* Shows the progress indicator.
*/
MDCCircularProgressFoundation.prototype.open = function () {
this.closed = false;
this.adapter.removeClass(constants_1.cssClasses.CLOSED_CLASS);
this.adapter.removeAttribute(constants_1.strings.ARIA_HIDDEN);
};
/**
* Hides the progress indicator
*/
MDCCircularProgressFoundation.prototype.close = function () {
this.closed = true;
this.adapter.addClass(constants_1.cssClasses.CLOSED_CLASS);
this.adapter.setAttribute(constants_1.strings.ARIA_HIDDEN, 'true');
};
/**
* @return Returns whether the progress indicator is hidden.
*/
MDCCircularProgressFoundation.prototype.isClosed = function () {
return this.closed;
};
return MDCCircularProgressFoundation;
}(foundation_1.MDCFoundation);
exports.MDCCircularProgressFoundation = MDCCircularProgressFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCCircularProgressFoundation;
/***/ }),
/***/ "./packages/mdc-circular-progress/index.ts":
/*!*************************************************!*\
!*** ./packages/mdc-circular-progress/index.ts ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-circular-progress/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-circular-progress/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-circular-progress/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-circular-progress/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-data-table/adapter.ts":
/*!********************************************!*\
!*** ./packages/mdc-data-table/adapter.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-data-table/component.ts":
/*!**********************************************!*\
!*** ./packages/mdc-data-table/component.ts ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCDataTable = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var component_2 = __webpack_require__(/*! @material/checkbox/component */ "./packages/mdc-checkbox/component.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var component_3 = __webpack_require__(/*! @material/linear-progress/component */ "./packages/mdc-linear-progress/component.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-data-table/constants.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-data-table/foundation.ts");
/**
* Implementation of `MDCDataTableFoundation`
*/
var MDCDataTable = /** @class */function (_super) {
__extends(MDCDataTable, _super);
function MDCDataTable() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCDataTable.attachTo = function (root) {
return new MDCDataTable(root);
};
MDCDataTable.prototype.initialize = function (checkboxFactory) {
if (checkboxFactory === void 0) {
checkboxFactory = function checkboxFactory(el) {
return new component_2.MDCCheckbox(el);
};
}
this.checkboxFactory = checkboxFactory;
};
MDCDataTable.prototype.initialSyncWithDOM = function () {
var _this = this;
this.headerRow = this.root.querySelector("." + constants_1.cssClasses.HEADER_ROW);
this.handleHeaderRowCheckboxChange = function () {
_this.foundation.handleHeaderRowCheckboxChange();
};
this.headerRow.addEventListener('change', this.handleHeaderRowCheckboxChange);
this.headerRowClickListener = function (event) {
_this.handleHeaderRowClick(event);
};
this.headerRow.addEventListener('click', this.headerRowClickListener);
this.content = this.root.querySelector("." + constants_1.cssClasses.CONTENT);
this.handleContentClick = function (event) {
var dataRowEl = ponyfill_1.closest(event.target, constants_1.selectors.ROW);
if (!dataRowEl) return;
_this.foundation.handleRowClick({
rowId: _this.getRowIdByRowElement(dataRowEl),
row: dataRowEl
});
};
this.content.addEventListener('click', this.handleContentClick);
this.handleRowCheckboxChange = function (event) {
_this.foundation.handleRowCheckboxChange(event);
};
this.content.addEventListener('change', this.handleRowCheckboxChange);
this.layout();
};
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows
* are added or removed from table.
*/
MDCDataTable.prototype.layout = function () {
this.foundation.layout();
};
/**
* @return Returns array of header row cell elements.
*/
MDCDataTable.prototype.getHeaderCells = function () {
return [].slice.call(this.root.querySelectorAll(constants_1.selectors.HEADER_CELL));
};
/**
* @return Returns array of row elements.
*/
MDCDataTable.prototype.getRows = function () {
return this.foundation.getRows();
};
/**
* @return Returns array of selected row ids.
*/
MDCDataTable.prototype.getSelectedRowIds = function () {
return this.foundation.getSelectedRowIds();
};
/**
* Sets selected row ids. Overwrites previously selected rows.
* @param rowIds Array of row ids that needs to be selected.
*/
MDCDataTable.prototype.setSelectedRowIds = function (rowIds) {
this.foundation.setSelectedRowIds(rowIds);
};
/**
* Shows progress indicator when data table is in loading state.
*/
MDCDataTable.prototype.showProgress = function () {
this.getLinearProgress().open();
this.foundation.showProgress();
};
/**
* Hides progress indicator after data table is finished loading.
*/
MDCDataTable.prototype.hideProgress = function () {
this.foundation.hideProgress();
this.getLinearProgress().close();
};
MDCDataTable.prototype.destroy = function () {
var e_1, _a;
if (this.handleHeaderRowCheckboxChange) {
this.headerRow.removeEventListener('change', this.handleHeaderRowCheckboxChange);
}
if (this.headerRowClickListener) {
this.headerRow.removeEventListener('click', this.headerRowClickListener);
}
if (this.handleRowCheckboxChange) {
this.content.removeEventListener('change', this.handleRowCheckboxChange);
}
if (this.headerRowCheckbox) {
this.headerRowCheckbox.destroy();
}
if (this.rowCheckboxList) {
try {
for (var _b = __values(this.rowCheckboxList), _c = _b.next(); !_c.done; _c = _b.next()) {
var checkbox = _c.value;
checkbox.destroy();
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_1) throw e_1.error;
}
}
}
if (this.handleContentClick) {
this.content.removeEventListener('click', this.handleContentClick);
}
};
MDCDataTable.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
// methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
addClass: function addClass(className) {
_this.root.classList.add(className);
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
getHeaderCellElements: function getHeaderCellElements() {
return _this.getHeaderCells();
},
getHeaderCellCount: function getHeaderCellCount() {
return _this.getHeaderCells().length;
},
getAttributeByHeaderCellIndex: function getAttributeByHeaderCellIndex(index, attribute) {
return _this.getHeaderCells()[index].getAttribute(attribute);
},
setAttributeByHeaderCellIndex: function setAttributeByHeaderCellIndex(index, attribute, value) {
_this.getHeaderCells()[index].setAttribute(attribute, value);
},
setClassNameByHeaderCellIndex: function setClassNameByHeaderCellIndex(index, className) {
_this.getHeaderCells()[index].classList.add(className);
},
removeClassNameByHeaderCellIndex: function removeClassNameByHeaderCellIndex(index, className) {
_this.getHeaderCells()[index].classList.remove(className);
},
notifySortAction: function notifySortAction(data) {
_this.emit(constants_1.events.SORTED, data, /** shouldBubble */true);
},
getTableContainerHeight: function getTableContainerHeight() {
var tableContainer = _this.root.querySelector("." + constants_1.cssClasses.TABLE_CONTAINER);
if (!tableContainer) {
throw new Error('MDCDataTable: Table container element not found.');
}
return tableContainer.getBoundingClientRect().height;
},
getTableHeaderHeight: function getTableHeaderHeight() {
var tableHeader = _this.root.querySelector(constants_1.selectors.HEADER_ROW);
if (!tableHeader) {
throw new Error('MDCDataTable: Table header element not found.');
}
return tableHeader.getBoundingClientRect().height;
},
setProgressIndicatorStyles: function setProgressIndicatorStyles(styles) {
var progressIndicator = _this.root.querySelector(constants_1.selectors.PROGRESS_INDICATOR);
if (!progressIndicator) {
throw new Error('MDCDataTable: Progress indicator element not found.');
}
progressIndicator.style.setProperty('height', styles.height);
progressIndicator.style.setProperty('top', styles.top);
},
addClassAtRowIndex: function addClassAtRowIndex(rowIndex, className) {
_this.getRows()[rowIndex].classList.add(className);
},
getRowCount: function getRowCount() {
return _this.getRows().length;
},
getRowElements: function getRowElements() {
return [].slice.call(_this.root.querySelectorAll(constants_1.selectors.ROW));
},
getRowIdAtIndex: function getRowIdAtIndex(rowIndex) {
return _this.getRows()[rowIndex].getAttribute(constants_1.dataAttributes.ROW_ID);
},
getRowIndexByChildElement: function getRowIndexByChildElement(el) {
return _this.getRows().indexOf(ponyfill_1.closest(el, constants_1.selectors.ROW));
},
getSelectedRowCount: function getSelectedRowCount() {
return _this.root.querySelectorAll(constants_1.selectors.ROW_SELECTED).length;
},
isCheckboxAtRowIndexChecked: function isCheckboxAtRowIndexChecked(rowIndex) {
return _this.rowCheckboxList[rowIndex].checked;
},
isHeaderRowCheckboxChecked: function isHeaderRowCheckboxChecked() {
return _this.headerRowCheckbox.checked;
},
isRowsSelectable: function isRowsSelectable() {
return !!_this.root.querySelector(constants_1.selectors.ROW_CHECKBOX) || !!_this.root.querySelector(constants_1.selectors.HEADER_ROW_CHECKBOX);
},
notifyRowSelectionChanged: function notifyRowSelectionChanged(data) {
_this.emit(constants_1.events.ROW_SELECTION_CHANGED, {
row: _this.getRowByIndex(data.rowIndex),
rowId: _this.getRowIdByIndex(data.rowIndex),
rowIndex: data.rowIndex,
selected: data.selected
},
/** shouldBubble */true);
},
notifySelectedAll: function notifySelectedAll() {
_this.emit(constants_1.events.SELECTED_ALL, {}, /** shouldBubble */true);
},
notifyUnselectedAll: function notifyUnselectedAll() {
_this.emit(constants_1.events.UNSELECTED_ALL, {}, /** shouldBubble */true);
},
notifyRowClick: function notifyRowClick(data) {
_this.emit(constants_1.events.ROW_CLICK, data, /** shouldBubble */true);
},
registerHeaderRowCheckbox: function registerHeaderRowCheckbox() {
if (_this.headerRowCheckbox) {
_this.headerRowCheckbox.destroy();
}
var checkboxEl = _this.root.querySelector(constants_1.selectors.HEADER_ROW_CHECKBOX);
_this.headerRowCheckbox = _this.checkboxFactory(checkboxEl);
},
registerRowCheckboxes: function registerRowCheckboxes() {
if (_this.rowCheckboxList) {
_this.rowCheckboxList.forEach(function (checkbox) {
checkbox.destroy();
});
}
_this.rowCheckboxList = [];
_this.getRows().forEach(function (rowEl) {
var checkbox = _this.checkboxFactory(rowEl.querySelector(constants_1.selectors.ROW_CHECKBOX));
_this.rowCheckboxList.push(checkbox);
});
},
removeClassAtRowIndex: function removeClassAtRowIndex(rowIndex, className) {
_this.getRows()[rowIndex].classList.remove(className);
},
setAttributeAtRowIndex: function setAttributeAtRowIndex(rowIndex, attr, value) {
_this.getRows()[rowIndex].setAttribute(attr, value);
},
setHeaderRowCheckboxChecked: function setHeaderRowCheckboxChecked(checked) {
_this.headerRowCheckbox.checked = checked;
},
setHeaderRowCheckboxIndeterminate: function setHeaderRowCheckboxIndeterminate(indeterminate) {
_this.headerRowCheckbox.indeterminate = indeterminate;
},
setRowCheckboxCheckedAtIndex: function setRowCheckboxCheckedAtIndex(rowIndex, checked) {
_this.rowCheckboxList[rowIndex].checked = checked;
},
setSortStatusLabelByHeaderCellIndex: function setSortStatusLabelByHeaderCellIndex(columnIndex, sortValue) {
var headerCell = _this.getHeaderCells()[columnIndex];
var sortStatusLabel = headerCell.querySelector(constants_1.selectors.SORT_STATUS_LABEL);
if (!sortStatusLabel) return;
sortStatusLabel.textContent = _this.getSortStatusMessageBySortValue(sortValue);
}
};
return new foundation_1.MDCDataTableFoundation(adapter);
};
MDCDataTable.prototype.getRowByIndex = function (index) {
return this.getRows()[index];
};
MDCDataTable.prototype.getRowIdByIndex = function (index) {
return this.getRowByIndex(index).getAttribute(constants_1.dataAttributes.ROW_ID);
};
MDCDataTable.prototype.handleHeaderRowClick = function (event) {
var headerCell = ponyfill_1.closest(event.target, constants_1.selectors.HEADER_CELL_WITH_SORT);
if (!headerCell) {
return;
}
var columnId = headerCell.getAttribute(constants_1.dataAttributes.COLUMN_ID);
var columnIndex = this.getHeaderCells().indexOf(headerCell);
if (columnIndex === -1) {
return;
}
this.foundation.handleSortAction({ columnId: columnId, columnIndex: columnIndex, headerCell: headerCell });
};
MDCDataTable.prototype.getSortStatusMessageBySortValue = function (sortValue) {
switch (sortValue) {
case constants_1.SortValue.ASCENDING:
return constants_1.messages.SORTED_IN_ASCENDING;
case constants_1.SortValue.DESCENDING:
return constants_1.messages.SORTED_IN_DESCENDING;
default:
return '';
}
};
MDCDataTable.prototype.getLinearProgressElement = function () {
var el = this.root.querySelector("." + constants_1.cssClasses.LINEAR_PROGRESS);
if (!el) {
throw new Error('MDCDataTable: linear progress element is not found.');
}
return el;
};
MDCDataTable.prototype.getLinearProgress = function () {
if (!this.linearProgress) {
var el = this.getLinearProgressElement();
this.linearProgress = new component_3.MDCLinearProgress(el);
}
return this.linearProgress;
};
MDCDataTable.prototype.getRowIdByRowElement = function (rowElement) {
return rowElement.getAttribute(constants_1.dataAttributes.ROW_ID);
};
return MDCDataTable;
}(component_1.MDCComponent);
exports.MDCDataTable = MDCDataTable;
/***/ }),
/***/ "./packages/mdc-data-table/constants.ts":
/*!**********************************************!*\
!*** ./packages/mdc-data-table/constants.ts ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.events = exports.SortValue = exports.strings = exports.messages = exports.selectors = exports.dataAttributes = exports.attributes = exports.cssClasses = void 0;
/**
* CSS class names used in component.
*/
exports.cssClasses = {
CELL: 'mdc-data-table__cell',
CELL_NUMERIC: 'mdc-data-table__cell--numeric',
CONTENT: 'mdc-data-table__content',
HEADER_CELL: 'mdc-data-table__header-cell',
HEADER_CELL_LABEL: 'mdc-data-table__header-cell-label',
HEADER_CELL_SORTED: 'mdc-data-table__header-cell--sorted',
HEADER_CELL_SORTED_DESCENDING: 'mdc-data-table__header-cell--sorted-descending',
HEADER_CELL_WITH_SORT: 'mdc-data-table__header-cell--with-sort',
HEADER_CELL_WRAPPER: 'mdc-data-table__header-cell-wrapper',
HEADER_ROW: 'mdc-data-table__header-row',
HEADER_ROW_CHECKBOX: 'mdc-data-table__header-row-checkbox',
IN_PROGRESS: 'mdc-data-table--in-progress',
LINEAR_PROGRESS: 'mdc-data-table__linear-progress',
PAGINATION_ROWS_PER_PAGE_LABEL: 'mdc-data-table__pagination-rows-per-page-label',
PAGINATION_ROWS_PER_PAGE_SELECT: 'mdc-data-table__pagination-rows-per-page-select',
PROGRESS_INDICATOR: 'mdc-data-table__progress-indicator',
ROOT: 'mdc-data-table',
ROW: 'mdc-data-table__row',
ROW_CHECKBOX: 'mdc-data-table__row-checkbox',
ROW_SELECTED: 'mdc-data-table__row--selected',
SORT_ICON_BUTTON: 'mdc-data-table__sort-icon-button',
SORT_STATUS_LABEL: 'mdc-data-table__sort-status-label',
TABLE_CONTAINER: 'mdc-data-table__table-container'
};
/**
* DOM attributes used in component.
*/
exports.attributes = {
ARIA_SELECTED: 'aria-selected',
ARIA_SORT: 'aria-sort'
};
/**
* List of data attributes used in component.
*/
exports.dataAttributes = {
COLUMN_ID: 'data-column-id',
ROW_ID: 'data-row-id'
};
/**
* CSS selectors used in component.
*/
exports.selectors = {
CONTENT: "." + exports.cssClasses.CONTENT,
HEADER_CELL: "." + exports.cssClasses.HEADER_CELL,
HEADER_CELL_WITH_SORT: "." + exports.cssClasses.HEADER_CELL_WITH_SORT,
HEADER_ROW: "." + exports.cssClasses.HEADER_ROW,
HEADER_ROW_CHECKBOX: "." + exports.cssClasses.HEADER_ROW_CHECKBOX,
PROGRESS_INDICATOR: "." + exports.cssClasses.PROGRESS_INDICATOR,
ROW: "." + exports.cssClasses.ROW,
ROW_CHECKBOX: "." + exports.cssClasses.ROW_CHECKBOX,
ROW_SELECTED: "." + exports.cssClasses.ROW_SELECTED,
SORT_ICON_BUTTON: "." + exports.cssClasses.SORT_ICON_BUTTON,
SORT_STATUS_LABEL: "." + exports.cssClasses.SORT_STATUS_LABEL
};
/**
* Messages used in component.
*/
exports.messages = {
SORTED_IN_DESCENDING: 'Sorted in descending order',
SORTED_IN_ASCENDING: 'Sorted in ascending order'
};
/**
* Attributes and selectors used in component.
* @deprecated Use `attributes`, `dataAttributes` and `selectors` instead.
*/
exports.strings = {
ARIA_SELECTED: exports.attributes.ARIA_SELECTED,
ARIA_SORT: exports.attributes.ARIA_SORT,
DATA_ROW_ID_ATTR: exports.dataAttributes.ROW_ID,
HEADER_ROW_CHECKBOX_SELECTOR: exports.selectors.HEADER_ROW_CHECKBOX,
ROW_CHECKBOX_SELECTOR: exports.selectors.ROW_CHECKBOX,
ROW_SELECTED_SELECTOR: exports.selectors.ROW_SELECTED,
ROW_SELECTOR: exports.selectors.ROW
};
/**
* Sort values defined by ARIA.
* See https://www.w3.org/WAI/PF/aria/states_and_properties#aria-sort
*/
var SortValue;
(function (SortValue) {
// Items are sorted in ascending order by this column.
SortValue["ASCENDING"] = "ascending";
// Items are sorted in descending order by this column.
SortValue["DESCENDING"] = "descending";
// There is no defined sort applied to the column.
SortValue["NONE"] = "none";
// A sort algorithm other than ascending or descending has been applied.
SortValue["OTHER"] = "other";
})(SortValue = exports.SortValue || (exports.SortValue = {}));
/**
* Event names used in component.
*/
exports.events = {
ROW_CLICK: 'MDCDataTable:rowClick',
ROW_SELECTION_CHANGED: 'MDCDataTable:rowSelectionChanged',
SELECTED_ALL: 'MDCDataTable:selectedAll',
SORTED: 'MDCDataTable:sorted',
UNSELECTED_ALL: 'MDCDataTable:unselectedAll'
};
/***/ }),
/***/ "./packages/mdc-data-table/foundation.ts":
/*!***********************************************!*\
!*** ./packages/mdc-data-table/foundation.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function (resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = this && this.__generator || function (thisArg, body) {
var _ = { label: 0, sent: function sent() {
if (t[0] & 1) throw t[1];return t[1];
}, trys: [], ops: [] },
f,
y,
t,
g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
return this;
}), g;
function verb(n) {
return function (v) {
return step([n, v]);
};
}
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) {
try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:case 1:
t = op;break;
case 4:
_.label++;return { value: op[1], done: false };
case 5:
_.label++;y = op[1];op = [0];continue;
case 7:
op = _.ops.pop();_.trys.pop();continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;continue;
}
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
_.label = op[1];break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];t = op;break;
}
if (t && _.label < t[2]) {
_.label = t[2];_.ops.push(op);break;
}
if (t[2]) _.ops.pop();
_.trys.pop();continue;
}
op = body.call(thisArg, _);
} catch (e) {
op = [6, e];y = 0;
} finally {
f = t = 0;
}
}if (op[0] & 5) throw op[1];return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCDataTableFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-data-table/constants.ts");
/**
* The Foundation of data table component containing pure business logic, any
* logic requiring DOM manipulation are delegated to adapter methods.
*/
var MDCDataTableFoundation = /** @class */function (_super) {
__extends(MDCDataTableFoundation, _super);
function MDCDataTableFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCDataTableFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCDataTableFoundation, "defaultAdapter", {
get: function get() {
return {
addClass: function addClass() {
return undefined;
},
addClassAtRowIndex: function addClassAtRowIndex() {
return undefined;
},
getAttributeByHeaderCellIndex: function getAttributeByHeaderCellIndex() {
return '';
},
getHeaderCellCount: function getHeaderCellCount() {
return 0;
},
getHeaderCellElements: function getHeaderCellElements() {
return [];
},
getRowCount: function getRowCount() {
return 0;
},
getRowElements: function getRowElements() {
return [];
},
getRowIdAtIndex: function getRowIdAtIndex() {
return '';
},
getRowIndexByChildElement: function getRowIndexByChildElement() {
return 0;
},
getSelectedRowCount: function getSelectedRowCount() {
return 0;
},
getTableContainerHeight: function getTableContainerHeight() {
return 0;
},
getTableHeaderHeight: function getTableHeaderHeight() {
return 0;
},
isCheckboxAtRowIndexChecked: function isCheckboxAtRowIndexChecked() {
return false;
},
isHeaderRowCheckboxChecked: function isHeaderRowCheckboxChecked() {
return false;
},
isRowsSelectable: function isRowsSelectable() {
return false;
},
notifyRowSelectionChanged: function notifyRowSelectionChanged() {
return undefined;
},
notifySelectedAll: function notifySelectedAll() {
return undefined;
},
notifySortAction: function notifySortAction() {
return undefined;
},
notifyUnselectedAll: function notifyUnselectedAll() {
return undefined;
},
notifyRowClick: function notifyRowClick() {
return undefined;
},
registerHeaderRowCheckbox: function registerHeaderRowCheckbox() {
return undefined;
},
registerRowCheckboxes: function registerRowCheckboxes() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
removeClassAtRowIndex: function removeClassAtRowIndex() {
return undefined;
},
removeClassNameByHeaderCellIndex: function removeClassNameByHeaderCellIndex() {
return undefined;
},
setAttributeAtRowIndex: function setAttributeAtRowIndex() {
return undefined;
},
setAttributeByHeaderCellIndex: function setAttributeByHeaderCellIndex() {
return undefined;
},
setClassNameByHeaderCellIndex: function setClassNameByHeaderCellIndex() {
return undefined;
},
setHeaderRowCheckboxChecked: function setHeaderRowCheckboxChecked() {
return undefined;
},
setHeaderRowCheckboxIndeterminate: function setHeaderRowCheckboxIndeterminate() {
return undefined;
},
setProgressIndicatorStyles: function setProgressIndicatorStyles() {
return undefined;
},
setRowCheckboxCheckedAtIndex: function setRowCheckboxCheckedAtIndex() {
return undefined;
},
setSortStatusLabelByHeaderCellIndex: function setSortStatusLabelByHeaderCellIndex() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows
* are added or removed from table. Use this if registering checkbox is
* synchronous.
*/
MDCDataTableFoundation.prototype.layout = function () {
if (this.adapter.isRowsSelectable()) {
this.adapter.registerHeaderRowCheckbox();
this.adapter.registerRowCheckboxes();
this.setHeaderRowCheckboxState();
}
};
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows
* are added or removed from table. Use this if registering checkbox is
* asynchronous.
*/
MDCDataTableFoundation.prototype.layoutAsync = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!this.adapter.isRowsSelectable()) return [3 /*break*/, 3];
return [4 /*yield*/, this.adapter.registerHeaderRowCheckbox()];
case 1:
_a.sent();
return [4 /*yield*/, this.adapter.registerRowCheckboxes()];
case 2:
_a.sent();
this.setHeaderRowCheckboxState();
_a.label = 3;
case 3:
return [2 /*return*/];
}
});
});
};
/**
* @return Returns array of row elements.
*/
MDCDataTableFoundation.prototype.getRows = function () {
return this.adapter.getRowElements();
};
/**
* @return Array of header cell elements.
*/
MDCDataTableFoundation.prototype.getHeaderCells = function () {
return this.adapter.getHeaderCellElements();
};
/**
* Sets selected row ids. Overwrites previously selected rows.
* @param rowIds Array of row ids that needs to be selected.
*/
MDCDataTableFoundation.prototype.setSelectedRowIds = function (rowIds) {
for (var rowIndex = 0; rowIndex < this.adapter.getRowCount(); rowIndex++) {
var rowId = this.adapter.getRowIdAtIndex(rowIndex);
var isSelected = false;
if (rowId && rowIds.indexOf(rowId) >= 0) {
isSelected = true;
}
this.adapter.setRowCheckboxCheckedAtIndex(rowIndex, isSelected);
this.selectRowAtIndex(rowIndex, isSelected);
}
this.setHeaderRowCheckboxState();
};
/**
* @return Returns array of all row ids.
*/
MDCDataTableFoundation.prototype.getRowIds = function () {
var rowIds = [];
for (var rowIndex = 0; rowIndex < this.adapter.getRowCount(); rowIndex++) {
rowIds.push(this.adapter.getRowIdAtIndex(rowIndex));
}
return rowIds;
};
/**
* @return Returns array of selected row ids.
*/
MDCDataTableFoundation.prototype.getSelectedRowIds = function () {
var selectedRowIds = [];
for (var rowIndex = 0; rowIndex < this.adapter.getRowCount(); rowIndex++) {
if (this.adapter.isCheckboxAtRowIndexChecked(rowIndex)) {
selectedRowIds.push(this.adapter.getRowIdAtIndex(rowIndex));
}
}
return selectedRowIds;
};
/**
* Handles header row checkbox change event.
*/
MDCDataTableFoundation.prototype.handleHeaderRowCheckboxChange = function () {
var isHeaderChecked = this.adapter.isHeaderRowCheckboxChecked();
for (var rowIndex = 0; rowIndex < this.adapter.getRowCount(); rowIndex++) {
this.adapter.setRowCheckboxCheckedAtIndex(rowIndex, isHeaderChecked);
this.selectRowAtIndex(rowIndex, isHeaderChecked);
}
if (isHeaderChecked) {
this.adapter.notifySelectedAll();
} else {
this.adapter.notifyUnselectedAll();
}
};
/**
* Handles change event originated from row checkboxes.
*/
MDCDataTableFoundation.prototype.handleRowCheckboxChange = function (event) {
var rowIndex = this.adapter.getRowIndexByChildElement(event.target);
if (rowIndex === -1) {
return;
}
var selected = this.adapter.isCheckboxAtRowIndexChecked(rowIndex);
this.selectRowAtIndex(rowIndex, selected);
this.setHeaderRowCheckboxState();
var rowId = this.adapter.getRowIdAtIndex(rowIndex);
this.adapter.notifyRowSelectionChanged({ rowId: rowId, rowIndex: rowIndex, selected: selected });
};
/**
* Handles sort action on sortable header cell.
*/
MDCDataTableFoundation.prototype.handleSortAction = function (eventData) {
var columnId = eventData.columnId,
columnIndex = eventData.columnIndex,
headerCell = eventData.headerCell;
// Reset sort attributes / classes on other header cells.
for (var index = 0; index < this.adapter.getHeaderCellCount(); index++) {
if (index === columnIndex) {
continue;
}
this.adapter.removeClassNameByHeaderCellIndex(index, constants_1.cssClasses.HEADER_CELL_SORTED);
this.adapter.removeClassNameByHeaderCellIndex(index, constants_1.cssClasses.HEADER_CELL_SORTED_DESCENDING);
this.adapter.setAttributeByHeaderCellIndex(index, constants_1.strings.ARIA_SORT, constants_1.SortValue.NONE);
this.adapter.setSortStatusLabelByHeaderCellIndex(index, constants_1.SortValue.NONE);
}
// Set appropriate sort attributes / classes on target header cell.
this.adapter.setClassNameByHeaderCellIndex(columnIndex, constants_1.cssClasses.HEADER_CELL_SORTED);
var currentSortValue = this.adapter.getAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT);
var sortValue = constants_1.SortValue.NONE;
// Set to descending if sorted on ascending order.
if (currentSortValue === constants_1.SortValue.ASCENDING) {
this.adapter.setClassNameByHeaderCellIndex(columnIndex, constants_1.cssClasses.HEADER_CELL_SORTED_DESCENDING);
this.adapter.setAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT, constants_1.SortValue.DESCENDING);
sortValue = constants_1.SortValue.DESCENDING;
// Set to ascending if sorted on descending order.
} else if (currentSortValue === constants_1.SortValue.DESCENDING) {
this.adapter.removeClassNameByHeaderCellIndex(columnIndex, constants_1.cssClasses.HEADER_CELL_SORTED_DESCENDING);
this.adapter.setAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT, constants_1.SortValue.ASCENDING);
sortValue = constants_1.SortValue.ASCENDING;
} else {
// Set to ascending by default when not sorted.
this.adapter.setAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT, constants_1.SortValue.ASCENDING);
sortValue = constants_1.SortValue.ASCENDING;
}
this.adapter.setSortStatusLabelByHeaderCellIndex(columnIndex, sortValue);
this.adapter.notifySortAction({
columnId: columnId,
columnIndex: columnIndex,
headerCell: headerCell,
sortValue: sortValue
});
};
/**
* Handles data table row click event.
*/
MDCDataTableFoundation.prototype.handleRowClick = function (_a) {
var rowId = _a.rowId,
row = _a.row;
this.adapter.notifyRowClick({
rowId: rowId,
row: row
});
};
/**
* Shows progress indicator blocking only the table body content when in
* loading state.
*/
MDCDataTableFoundation.prototype.showProgress = function () {
var tableHeaderHeight = this.adapter.getTableHeaderHeight();
// Calculate the height of table content (Not scroll content) excluding
// header row height.
var height = this.adapter.getTableContainerHeight() - tableHeaderHeight;
var top = tableHeaderHeight;
this.adapter.setProgressIndicatorStyles({
height: height + "px",
top: top + "px"
});
this.adapter.addClass(constants_1.cssClasses.IN_PROGRESS);
};
/**
* Hides progress indicator when data table is finished loading.
*/
MDCDataTableFoundation.prototype.hideProgress = function () {
this.adapter.removeClass(constants_1.cssClasses.IN_PROGRESS);
};
/**
* Updates header row checkbox state based on number of rows selected.
*/
MDCDataTableFoundation.prototype.setHeaderRowCheckboxState = function () {
if (this.adapter.getSelectedRowCount() === 0) {
this.adapter.setHeaderRowCheckboxChecked(false);
this.adapter.setHeaderRowCheckboxIndeterminate(false);
} else if (this.adapter.getSelectedRowCount() === this.adapter.getRowCount()) {
this.adapter.setHeaderRowCheckboxChecked(true);
this.adapter.setHeaderRowCheckboxIndeterminate(false);
} else {
this.adapter.setHeaderRowCheckboxIndeterminate(true);
this.adapter.setHeaderRowCheckboxChecked(false);
}
};
/**
* Sets the attributes of row element based on selection state.
*/
MDCDataTableFoundation.prototype.selectRowAtIndex = function (rowIndex, selected) {
if (selected) {
this.adapter.addClassAtRowIndex(rowIndex, constants_1.cssClasses.ROW_SELECTED);
this.adapter.setAttributeAtRowIndex(rowIndex, constants_1.strings.ARIA_SELECTED, 'true');
} else {
this.adapter.removeClassAtRowIndex(rowIndex, constants_1.cssClasses.ROW_SELECTED);
this.adapter.setAttributeAtRowIndex(rowIndex, constants_1.strings.ARIA_SELECTED, 'false');
}
};
return MDCDataTableFoundation;
}(foundation_1.MDCFoundation);
exports.MDCDataTableFoundation = MDCDataTableFoundation;
/***/ }),
/***/ "./packages/mdc-data-table/index.ts":
/*!******************************************!*\
!*** ./packages/mdc-data-table/index.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-data-table/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-data-table/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-data-table/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-data-table/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-data-table/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-data-table/types.ts":
/*!******************************************!*\
!*** ./packages/mdc-data-table/types.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
;
/***/ }),
/***/ "./packages/mdc-dialog/adapter.ts":
/*!****************************************!*\
!*** ./packages/mdc-dialog/adapter.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-dialog/component.ts":
/*!******************************************!*\
!*** ./packages/mdc-dialog/component.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCDialog = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-dialog/foundation.ts");
var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-dialog/util.ts"));
var strings = foundation_1.MDCDialogFoundation.strings;
var MDCDialog = /** @class */function (_super) {
__extends(MDCDialog, _super);
function MDCDialog() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(MDCDialog.prototype, "isOpen", {
get: function get() {
return this.foundation.isOpen();
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCDialog.prototype, "escapeKeyAction", {
get: function get() {
return this.foundation.getEscapeKeyAction();
},
set: function set(action) {
this.foundation.setEscapeKeyAction(action);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCDialog.prototype, "scrimClickAction", {
get: function get() {
return this.foundation.getScrimClickAction();
},
set: function set(action) {
this.foundation.setScrimClickAction(action);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCDialog.prototype, "autoStackButtons", {
get: function get() {
return this.foundation.getAutoStackButtons();
},
set: function set(autoStack) {
this.foundation.setAutoStackButtons(autoStack);
},
enumerable: false,
configurable: true
});
MDCDialog.attachTo = function (root) {
return new MDCDialog(root);
};
MDCDialog.prototype.initialize = function (focusTrapFactory) {
var e_1, _a;
if (focusTrapFactory === void 0) {
focusTrapFactory = function focusTrapFactory(el, focusOptions) {
return new focus_trap_1.FocusTrap(el, focusOptions);
};
}
var container = this.root.querySelector(strings.CONTAINER_SELECTOR);
if (!container) {
throw new Error("Dialog component requires a " + strings.CONTAINER_SELECTOR + " container element");
}
this.container = container;
this.content = this.root.querySelector(strings.CONTENT_SELECTOR);
this.buttons = [].slice.call(this.root.querySelectorAll(strings.BUTTON_SELECTOR));
this.defaultButton = this.root.querySelector("[" + strings.BUTTON_DEFAULT_ATTRIBUTE + "]");
this.focusTrapFactory = focusTrapFactory;
this.buttonRipples = [];
try {
for (var _b = __values(this.buttons), _c = _b.next(); !_c.done; _c = _b.next()) {
var buttonEl = _c.value;
this.buttonRipples.push(new component_2.MDCRipple(buttonEl));
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_1) throw e_1.error;
}
}
};
MDCDialog.prototype.initialSyncWithDOM = function () {
var _this = this;
this.focusTrap = util.createFocusTrapInstance(this.container, this.focusTrapFactory, this.getInitialFocusEl() || undefined);
this.handleClick = this.foundation.handleClick.bind(this.foundation);
this.handleKeydown = this.foundation.handleKeydown.bind(this.foundation);
this.handleDocumentKeydown = this.foundation.handleDocumentKeydown.bind(this.foundation);
// this.handleLayout = this.layout.bind(this);
this.handleOpening = function () {
document.addEventListener('keydown', _this.handleDocumentKeydown);
};
this.handleClosing = function () {
document.removeEventListener('keydown', _this.handleDocumentKeydown);
};
this.listen('click', this.handleClick);
this.listen('keydown', this.handleKeydown);
this.listen(strings.OPENING_EVENT, this.handleOpening);
this.listen(strings.CLOSING_EVENT, this.handleClosing);
};
MDCDialog.prototype.destroy = function () {
this.unlisten('click', this.handleClick);
this.unlisten('keydown', this.handleKeydown);
this.unlisten(strings.OPENING_EVENT, this.handleOpening);
this.unlisten(strings.CLOSING_EVENT, this.handleClosing);
this.handleClosing();
this.buttonRipples.forEach(function (ripple) {
ripple.destroy();
});
_super.prototype.destroy.call(this);
};
MDCDialog.prototype.layout = function () {
this.foundation.layout();
};
MDCDialog.prototype.open = function () {
this.foundation.open();
};
MDCDialog.prototype.close = function (action) {
if (action === void 0) {
action = '';
}
this.foundation.close(action);
};
MDCDialog.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = {
addBodyClass: function addBodyClass(className) {
return document.body.classList.add(className);
},
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
areButtonsStacked: function areButtonsStacked() {
return util.areTopsMisaligned(_this.buttons);
},
clickDefaultButton: function clickDefaultButton() {
if (_this.defaultButton && !_this.defaultButton.disabled) {
_this.defaultButton.click();
}
},
eventTargetMatches: function eventTargetMatches(target, selector) {
return target ? ponyfill_1.matches(target, selector) : false;
},
getActionFromEvent: function getActionFromEvent(evt) {
if (!evt.target) {
return '';
}
var element = ponyfill_1.closest(evt.target, "[" + strings.ACTION_ATTRIBUTE + "]");
return element && element.getAttribute(strings.ACTION_ATTRIBUTE);
},
getInitialFocusEl: function getInitialFocusEl() {
return _this.getInitialFocusEl();
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
isContentScrollable: function isContentScrollable() {
return util.isScrollable(_this.content);
},
notifyClosed: function notifyClosed(action) {
return _this.emit(strings.CLOSED_EVENT, action ? { action: action } : {});
},
notifyClosing: function notifyClosing(action) {
return _this.emit(strings.CLOSING_EVENT, action ? { action: action } : {});
},
notifyOpened: function notifyOpened() {
return _this.emit(strings.OPENED_EVENT, {});
},
notifyOpening: function notifyOpening() {
return _this.emit(strings.OPENING_EVENT, {});
},
releaseFocus: function releaseFocus() {
_this.focusTrap.releaseFocus();
},
removeBodyClass: function removeBodyClass(className) {
return document.body.classList.remove(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
reverseButtons: function reverseButtons() {
_this.buttons.reverse();
_this.buttons.forEach(function (button) {
button.parentElement.appendChild(button);
});
},
trapFocus: function trapFocus() {
_this.focusTrap.trapFocus();
},
registerContentEventHandler: function registerContentEventHandler(evt, handler) {
if (_this.content instanceof HTMLElement) {
_this.content.addEventListener(evt, handler);
}
},
deregisterContentEventHandler: function deregisterContentEventHandler(evt, handler) {
if (_this.content instanceof HTMLElement) {
_this.content.removeEventListener(evt, handler);
}
},
isScrollableContentAtTop: function isScrollableContentAtTop() {
return util.isScrollAtTop(_this.content);
},
isScrollableContentAtBottom: function isScrollableContentAtBottom() {
return util.isScrollAtBottom(_this.content);
},
registerWindowEventHandler: function registerWindowEventHandler(evt, handler) {
window.addEventListener(evt, handler);
},
deregisterWindowEventHandler: function deregisterWindowEventHandler(evt, handler) {
window.removeEventListener(evt, handler);
}
};
return new foundation_1.MDCDialogFoundation(adapter);
};
MDCDialog.prototype.getInitialFocusEl = function () {
return this.root.querySelector("[" + strings.INITIAL_FOCUS_ATTRIBUTE + "]");
};
return MDCDialog;
}(component_1.MDCComponent);
exports.MDCDialog = MDCDialog;
/***/ }),
/***/ "./packages/mdc-dialog/constants.ts":
/*!******************************************!*\
!*** ./packages/mdc-dialog/constants.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.numbers = exports.strings = exports.cssClasses = void 0;
exports.cssClasses = {
CLOSING: 'mdc-dialog--closing',
OPEN: 'mdc-dialog--open',
OPENING: 'mdc-dialog--opening',
SCROLLABLE: 'mdc-dialog--scrollable',
SCROLL_LOCK: 'mdc-dialog-scroll-lock',
STACKED: 'mdc-dialog--stacked',
FULLSCREEN: 'mdc-dialog--fullscreen',
// Class for showing a scroll divider on full-screen dialog header element.
// Should only be displayed on scrollable content, when the dialog content is
// scrolled "underneath" the header.
SCROLL_DIVIDER_HEADER: 'mdc-dialog-scroll-divider-header',
// Class for showing a scroll divider on a full-screen dialog footer element.
// Should only be displayed on scrolalble content, when the dialog content is
// obscured "underneath" the footer.
SCROLL_DIVIDER_FOOTER: 'mdc-dialog-scroll-divider-footer',
// The "surface scrim" is a scrim covering only the surface of a dialog. This
// is used in situations where a confirmation dialog is shown over an already
// opened full-screen dialog. On larger screen-sizes, the full-screen dialog
// is sized as a modal and so in these situations we display a "surface scrim"
// to prevent a "double scrim" (where the scrim from the secondary
// confirmation dialog would overlap with the scrim from the full-screen
// dialog).
SURFACE_SCRIM_SHOWN: 'mdc-dialog__surface-scrim--shown',
// "Showing" animating class for the surface-scrim.
SURFACE_SCRIM_SHOWING: 'mdc-dialog__surface-scrim--showing',
// "Hiding" animating class for the surface-scrim.
SURFACE_SCRIM_HIDING: 'mdc-dialog__surface-scrim--hiding',
// Class to hide a dialog's scrim (used in conjunction with a surface-scrim).
// Note that we only hide the original scrim rather than removing it entirely
// to prevent interactions with the content behind this scrim, and to capture
// scrim clicks.
SCRIM_HIDDEN: 'mdc-dialog__scrim--hidden'
};
exports.strings = {
ACTION_ATTRIBUTE: 'data-mdc-dialog-action',
BUTTON_DEFAULT_ATTRIBUTE: 'data-mdc-dialog-button-default',
BUTTON_SELECTOR: '.mdc-dialog__button',
CLOSED_EVENT: 'MDCDialog:closed',
CLOSE_ACTION: 'close',
CLOSING_EVENT: 'MDCDialog:closing',
CONTAINER_SELECTOR: '.mdc-dialog__container',
CONTENT_SELECTOR: '.mdc-dialog__content',
DESTROY_ACTION: 'destroy',
INITIAL_FOCUS_ATTRIBUTE: 'data-mdc-dialog-initial-focus',
OPENED_EVENT: 'MDCDialog:opened',
OPENING_EVENT: 'MDCDialog:opening',
SCRIM_SELECTOR: '.mdc-dialog__scrim',
SUPPRESS_DEFAULT_PRESS_SELECTOR: ['textarea', '.mdc-menu .mdc-list-item', '.mdc-menu .mdc-deprecated-list-item'].join(', '),
SURFACE_SELECTOR: '.mdc-dialog__surface'
};
exports.numbers = {
DIALOG_ANIMATION_CLOSE_TIME_MS: 75,
DIALOG_ANIMATION_OPEN_TIME_MS: 150
};
/***/ }),
/***/ "./packages/mdc-dialog/foundation.ts":
/*!*******************************************!*\
!*** ./packages/mdc-dialog/foundation.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCDialogFoundation = void 0;
var animationframe_1 = __webpack_require__(/*! @material/animation/animationframe */ "./packages/mdc-animation/animationframe.ts");
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-dialog/constants.ts");
var AnimationKeys;
(function (AnimationKeys) {
AnimationKeys["POLL_SCROLL_POS"] = "poll_scroll_position";
AnimationKeys["POLL_LAYOUT_CHANGE"] = "poll_layout_change";
})(AnimationKeys || (AnimationKeys = {}));
var MDCDialogFoundation = /** @class */function (_super) {
__extends(MDCDialogFoundation, _super);
function MDCDialogFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCDialogFoundation.defaultAdapter), adapter)) || this;
_this.dialogOpen = false;
_this.isFullscreen = false;
_this.animationFrame = 0;
_this.animationTimer = 0;
_this.escapeKeyAction = constants_1.strings.CLOSE_ACTION;
_this.scrimClickAction = constants_1.strings.CLOSE_ACTION;
_this.autoStackButtons = true;
_this.areButtonsStacked = false;
_this.suppressDefaultPressSelector = constants_1.strings.SUPPRESS_DEFAULT_PRESS_SELECTOR;
_this.animFrame = new animationframe_1.AnimationFrame();
_this.contentScrollHandler = function () {
_this.handleScrollEvent();
};
_this.windowResizeHandler = function () {
_this.layout();
};
_this.windowOrientationChangeHandler = function () {
_this.layout();
};
return _this;
}
Object.defineProperty(MDCDialogFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCDialogFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCDialogFoundation, "numbers", {
get: function get() {
return constants_1.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCDialogFoundation, "defaultAdapter", {
get: function get() {
return {
addBodyClass: function addBodyClass() {
return undefined;
},
addClass: function addClass() {
return undefined;
},
areButtonsStacked: function areButtonsStacked() {
return false;
},
clickDefaultButton: function clickDefaultButton() {
return undefined;
},
eventTargetMatches: function eventTargetMatches() {
return false;
},
getActionFromEvent: function getActionFromEvent() {
return '';
},
getInitialFocusEl: function getInitialFocusEl() {
return null;
},
hasClass: function hasClass() {
return false;
},
isContentScrollable: function isContentScrollable() {
return false;
},
notifyClosed: function notifyClosed() {
return undefined;
},
notifyClosing: function notifyClosing() {
return undefined;
},
notifyOpened: function notifyOpened() {
return undefined;
},
notifyOpening: function notifyOpening() {
return undefined;
},
releaseFocus: function releaseFocus() {
return undefined;
},
removeBodyClass: function removeBodyClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
reverseButtons: function reverseButtons() {
return undefined;
},
trapFocus: function trapFocus() {
return undefined;
},
registerContentEventHandler: function registerContentEventHandler() {
return undefined;
},
deregisterContentEventHandler: function deregisterContentEventHandler() {
return undefined;
},
isScrollableContentAtTop: function isScrollableContentAtTop() {
return false;
},
isScrollableContentAtBottom: function isScrollableContentAtBottom() {
return false;
},
registerWindowEventHandler: function registerWindowEventHandler() {
return undefined;
},
deregisterWindowEventHandler: function deregisterWindowEventHandler() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCDialogFoundation.prototype.init = function () {
if (this.adapter.hasClass(constants_1.cssClasses.STACKED)) {
this.setAutoStackButtons(false);
}
this.isFullscreen = this.adapter.hasClass(constants_1.cssClasses.FULLSCREEN);
};
MDCDialogFoundation.prototype.destroy = function () {
if (this.animationTimer) {
clearTimeout(this.animationTimer);
this.handleAnimationTimerEnd();
}
if (this.isFullscreen) {
this.adapter.deregisterContentEventHandler('scroll', this.contentScrollHandler);
}
this.animFrame.cancelAll();
this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
this.adapter.deregisterWindowEventHandler('orientationchange', this.windowOrientationChangeHandler);
};
MDCDialogFoundation.prototype.open = function (dialogOptions) {
var _this = this;
this.dialogOpen = true;
this.adapter.notifyOpening();
this.adapter.addClass(constants_1.cssClasses.OPENING);
if (this.isFullscreen) {
// A scroll event listener is registered even if the dialog is not
// scrollable on open, since the window resize event, or orientation
// change may make the dialog scrollable after it is opened.
this.adapter.registerContentEventHandler('scroll', this.contentScrollHandler);
}
if (dialogOptions && dialogOptions.isAboveFullscreenDialog) {
this.adapter.addClass(constants_1.cssClasses.SCRIM_HIDDEN);
}
this.adapter.registerWindowEventHandler('resize', this.windowResizeHandler);
this.adapter.registerWindowEventHandler('orientationchange', this.windowOrientationChangeHandler);
// Wait a frame once display is no longer "none", to establish basis for
// animation
this.runNextAnimationFrame(function () {
_this.adapter.addClass(constants_1.cssClasses.OPEN);
_this.adapter.addBodyClass(constants_1.cssClasses.SCROLL_LOCK);
_this.layout();
_this.animationTimer = setTimeout(function () {
_this.handleAnimationTimerEnd();
_this.adapter.trapFocus(_this.adapter.getInitialFocusEl());
_this.adapter.notifyOpened();
}, constants_1.numbers.DIALOG_ANIMATION_OPEN_TIME_MS);
});
};
MDCDialogFoundation.prototype.close = function (action) {
var _this = this;
if (action === void 0) {
action = '';
}
if (!this.dialogOpen) {
// Avoid redundant close calls (and events), e.g. from keydown on elements
// that inherently emit click
return;
}
this.dialogOpen = false;
this.adapter.notifyClosing(action);
this.adapter.addClass(constants_1.cssClasses.CLOSING);
this.adapter.removeClass(constants_1.cssClasses.OPEN);
this.adapter.removeBodyClass(constants_1.cssClasses.SCROLL_LOCK);
if (this.isFullscreen) {
this.adapter.deregisterContentEventHandler('scroll', this.contentScrollHandler);
}
this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
this.adapter.deregisterWindowEventHandler('orientationchange', this.windowOrientationChangeHandler);
cancelAnimationFrame(this.animationFrame);
this.animationFrame = 0;
clearTimeout(this.animationTimer);
this.animationTimer = setTimeout(function () {
_this.adapter.releaseFocus();
_this.handleAnimationTimerEnd();
_this.adapter.notifyClosed(action);
}, constants_1.numbers.DIALOG_ANIMATION_CLOSE_TIME_MS);
};
/**
* Used only in instances of showing a secondary dialog over a full-screen
* dialog. Shows the "surface scrim" displayed over the full-screen dialog.
*/
MDCDialogFoundation.prototype.showSurfaceScrim = function () {
var _this = this;
this.adapter.addClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWING);
this.runNextAnimationFrame(function () {
_this.adapter.addClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWN);
});
};
/**
* Used only in instances of showing a secondary dialog over a full-screen
* dialog. Hides the "surface scrim" displayed over the full-screen dialog.
*/
MDCDialogFoundation.prototype.hideSurfaceScrim = function () {
this.adapter.removeClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWN);
this.adapter.addClass(constants_1.cssClasses.SURFACE_SCRIM_HIDING);
};
/**
* Handles `transitionend` event triggered when surface scrim animation is
* finished.
*/
MDCDialogFoundation.prototype.handleSurfaceScrimTransitionEnd = function () {
this.adapter.removeClass(constants_1.cssClasses.SURFACE_SCRIM_HIDING);
this.adapter.removeClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWING);
};
MDCDialogFoundation.prototype.isOpen = function () {
return this.dialogOpen;
};
MDCDialogFoundation.prototype.getEscapeKeyAction = function () {
return this.escapeKeyAction;
};
MDCDialogFoundation.prototype.setEscapeKeyAction = function (action) {
this.escapeKeyAction = action;
};
MDCDialogFoundation.prototype.getScrimClickAction = function () {
return this.scrimClickAction;
};
MDCDialogFoundation.prototype.setScrimClickAction = function (action) {
this.scrimClickAction = action;
};
MDCDialogFoundation.prototype.getAutoStackButtons = function () {
return this.autoStackButtons;
};
MDCDialogFoundation.prototype.setAutoStackButtons = function (autoStack) {
this.autoStackButtons = autoStack;
};
MDCDialogFoundation.prototype.getSuppressDefaultPressSelector = function () {
return this.suppressDefaultPressSelector;
};
MDCDialogFoundation.prototype.setSuppressDefaultPressSelector = function (selector) {
this.suppressDefaultPressSelector = selector;
};
MDCDialogFoundation.prototype.layout = function () {
var _this = this;
this.animFrame.request(AnimationKeys.POLL_LAYOUT_CHANGE, function () {
_this.layoutInternal();
});
};
/** Handles click on the dialog root element. */
MDCDialogFoundation.prototype.handleClick = function (evt) {
var isScrim = this.adapter.eventTargetMatches(evt.target, constants_1.strings.SCRIM_SELECTOR);
// Check for scrim click first since it doesn't require querying ancestors.
if (isScrim && this.scrimClickAction !== '') {
this.close(this.scrimClickAction);
} else {
var action = this.adapter.getActionFromEvent(evt);
if (action) {
this.close(action);
}
}
};
/** Handles keydown on the dialog root element. */
MDCDialogFoundation.prototype.handleKeydown = function (evt) {
var isEnter = evt.key === 'Enter' || evt.keyCode === 13;
if (!isEnter) {
return;
}
var action = this.adapter.getActionFromEvent(evt);
if (action) {
// Action button callback is handled in `handleClick`,
// since space/enter keydowns on buttons trigger click events.
return;
}
// `composedPath` is used here, when available, to account for use cases
// where a target meant to suppress the default press behaviour
// may exist in a shadow root.
// For example, a textarea inside a web component:
// <mwc-dialog>
// <horizontal-layout>
// #shadow-root (open)
// <mwc-textarea>
// #shadow-root (open)
// <textarea></textarea>
// </mwc-textarea>
// </horizontal-layout>
// </mwc-dialog>
var target = evt.composedPath ? evt.composedPath()[0] : evt.target;
var isDefault = this.suppressDefaultPressSelector ? !this.adapter.eventTargetMatches(target, this.suppressDefaultPressSelector) : true;
if (isEnter && isDefault) {
this.adapter.clickDefaultButton();
}
};
/** Handles keydown on the document. */
MDCDialogFoundation.prototype.handleDocumentKeydown = function (evt) {
var isEscape = evt.key === 'Escape' || evt.keyCode === 27;
if (isEscape && this.escapeKeyAction !== '') {
this.close(this.escapeKeyAction);
}
};
/**
* Handles scroll event on the dialog's content element -- showing a scroll
* divider on the header or footer based on the scroll position. This handler
* should only be registered on full-screen dialogs with scrollable content.
*/
MDCDialogFoundation.prototype.handleScrollEvent = function () {
var _this = this;
// Since scroll events can fire at a high rate, we throttle these events by
// using requestAnimationFrame.
this.animFrame.request(AnimationKeys.POLL_SCROLL_POS, function () {
_this.toggleScrollDividerHeader();
_this.toggleScrollDividerFooter();
});
};
MDCDialogFoundation.prototype.layoutInternal = function () {
if (this.autoStackButtons) {
this.detectStackedButtons();
}
this.toggleScrollableClasses();
};
MDCDialogFoundation.prototype.handleAnimationTimerEnd = function () {
this.animationTimer = 0;
this.adapter.removeClass(constants_1.cssClasses.OPENING);
this.adapter.removeClass(constants_1.cssClasses.CLOSING);
};
/**
* Runs the given logic on the next animation frame, using setTimeout to
* factor in Firefox reflow behavior.
*/
MDCDialogFoundation.prototype.runNextAnimationFrame = function (callback) {
var _this = this;
cancelAnimationFrame(this.animationFrame);
this.animationFrame = requestAnimationFrame(function () {
_this.animationFrame = 0;
clearTimeout(_this.animationTimer);
_this.animationTimer = setTimeout(callback, 0);
});
};
MDCDialogFoundation.prototype.detectStackedButtons = function () {
// Remove the class first to let us measure the buttons' natural positions.
this.adapter.removeClass(constants_1.cssClasses.STACKED);
var areButtonsStacked = this.adapter.areButtonsStacked();
if (areButtonsStacked) {
this.adapter.addClass(constants_1.cssClasses.STACKED);
}
if (areButtonsStacked !== this.areButtonsStacked) {
this.adapter.reverseButtons();
this.areButtonsStacked = areButtonsStacked;
}
};
MDCDialogFoundation.prototype.toggleScrollableClasses = function () {
// Remove the class first to let us measure the natural height of the
// content.
this.adapter.removeClass(constants_1.cssClasses.SCROLLABLE);
if (this.adapter.isContentScrollable()) {
this.adapter.addClass(constants_1.cssClasses.SCROLLABLE);
if (this.isFullscreen) {
// If dialog is full-screen and scrollable, check if a scroll divider
// should be shown.
this.toggleScrollDividerHeader();
this.toggleScrollDividerFooter();
}
}
};
MDCDialogFoundation.prototype.toggleScrollDividerHeader = function () {
if (!this.adapter.isScrollableContentAtTop()) {
this.adapter.addClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER);
} else if (this.adapter.hasClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER)) {
this.adapter.removeClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER);
}
};
MDCDialogFoundation.prototype.toggleScrollDividerFooter = function () {
if (!this.adapter.isScrollableContentAtBottom()) {
this.adapter.addClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER);
} else if (this.adapter.hasClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER)) {
this.adapter.removeClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER);
}
};
return MDCDialogFoundation;
}(foundation_1.MDCFoundation);
exports.MDCDialogFoundation = MDCDialogFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCDialogFoundation;
/***/ }),
/***/ "./packages/mdc-dialog/index.ts":
/*!**************************************!*\
!*** ./packages/mdc-dialog/index.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.util = void 0;
var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-dialog/util.ts"));
exports.util = util;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-dialog/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-dialog/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-dialog/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-dialog/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-dialog/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-dialog/types.ts":
/*!**************************************!*\
!*** ./packages/mdc-dialog/types.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-dialog/util.ts":
/*!*************************************!*\
!*** ./packages/mdc-dialog/util.ts ***!
\*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.areTopsMisaligned = exports.isScrollAtBottom = exports.isScrollAtTop = exports.isScrollable = exports.createFocusTrapInstance = void 0;
function createFocusTrapInstance(surfaceEl, focusTrapFactory, initialFocusEl) {
return focusTrapFactory(surfaceEl, { initialFocusEl: initialFocusEl });
}
exports.createFocusTrapInstance = createFocusTrapInstance;
function isScrollable(el) {
return el ? el.scrollHeight > el.offsetHeight : false;
}
exports.isScrollable = isScrollable;
/**
* For scrollable content, returns true if the content has not been scrolled
* (that is, the scroll content is as the "top"). This is used in full-screen
* dialogs, where the scroll divider is expected only to appear once the
* content has been scrolled "underneath" the header bar.
*/
function isScrollAtTop(el) {
return el ? el.scrollTop === 0 : false;
}
exports.isScrollAtTop = isScrollAtTop;
/**
* For scrollable content, returns true if the content has been scrolled all the
* way to the bottom. This is used in full-screen dialogs, where the footer
* scroll divider is expected only to appear when the content is "cut-off" by
* the footer bar.
*/
function isScrollAtBottom(el) {
return el ? Math.ceil(el.scrollHeight - el.scrollTop) === el.clientHeight : false;
}
exports.isScrollAtBottom = isScrollAtBottom;
function areTopsMisaligned(els) {
var tops = new Set();
[].forEach.call(els, function (el) {
return tops.add(el.offsetTop);
});
return tops.size > 1;
}
exports.areTopsMisaligned = areTopsMisaligned;
/***/ }),
/***/ "./packages/mdc-dom/announce.ts":
/*!**************************************!*\
!*** ./packages/mdc-dom/announce.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.announce = exports.DATA_MDC_DOM_ANNOUNCE = exports.AnnouncerPriority = void 0;
/**
* Priorities for the announce function.
*/
var AnnouncerPriority;
(function (AnnouncerPriority) {
AnnouncerPriority["POLITE"] = "polite";
AnnouncerPriority["ASSERTIVE"] = "assertive";
})(AnnouncerPriority = exports.AnnouncerPriority || (exports.AnnouncerPriority = {}));
/**
* Data attribute added to live region element.
*/
exports.DATA_MDC_DOM_ANNOUNCE = 'data-mdc-dom-announce';
/**
* Announces the given message with optional priority, defaulting to "polite"
*/
function announce(message, options) {
Announcer.getInstance().say(message, options);
}
exports.announce = announce;
var Announcer = /** @class */function () {
// Constructor made private to ensure only the singleton is used
function Announcer() {
this.liveRegions = new Map();
}
Announcer.getInstance = function () {
if (!Announcer.instance) {
Announcer.instance = new Announcer();
}
return Announcer.instance;
};
Announcer.prototype.say = function (message, options) {
var _a, _b;
var priority = (_a = options === null || options === void 0 ? void 0 : options.priority) !== null && _a !== void 0 ? _a : AnnouncerPriority.POLITE;
var ownerDocument = (_b = options === null || options === void 0 ? void 0 : options.ownerDocument) !== null && _b !== void 0 ? _b : document;
var liveRegion = this.getLiveRegion(priority, ownerDocument);
// Reset the region to pick up the message, even if the message is the
// exact same as before.
liveRegion.textContent = '';
// Timeout is necessary for screen readers like NVDA and VoiceOver.
setTimeout(function () {
liveRegion.textContent = message;
ownerDocument.addEventListener('click', clearLiveRegion);
}, 1);
function clearLiveRegion() {
liveRegion.textContent = '';
ownerDocument.removeEventListener('click', clearLiveRegion);
}
};
Announcer.prototype.getLiveRegion = function (priority, ownerDocument) {
var documentLiveRegions = this.liveRegions.get(ownerDocument);
if (!documentLiveRegions) {
documentLiveRegions = new Map();
this.liveRegions.set(ownerDocument, documentLiveRegions);
}
var existingLiveRegion = documentLiveRegions.get(priority);
if (existingLiveRegion && ownerDocument.body.contains(existingLiveRegion)) {
return existingLiveRegion;
}
var liveRegion = this.createLiveRegion(priority, ownerDocument);
documentLiveRegions.set(priority, liveRegion);
return liveRegion;
};
Announcer.prototype.createLiveRegion = function (priority, ownerDocument) {
var el = ownerDocument.createElement('div');
el.style.position = 'absolute';
el.style.top = '-9999px';
el.style.left = '-9999px';
el.style.height = '1px';
el.style.overflow = 'hidden';
el.setAttribute('aria-atomic', 'true');
el.setAttribute('aria-live', priority);
el.setAttribute(exports.DATA_MDC_DOM_ANNOUNCE, 'true');
ownerDocument.body.appendChild(el);
return el;
};
return Announcer;
}();
/***/ }),
/***/ "./packages/mdc-dom/events.ts":
/*!************************************!*\
!*** ./packages/mdc-dom/events.ts ***!
\************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyPassive = void 0;
/**
* Determine whether the current browser supports passive event listeners, and
* if so, use them.
*/
function applyPassive(globalObj) {
if (globalObj === void 0) {
globalObj = window;
}
return supportsPassiveOption(globalObj) ? { passive: true } : false;
}
exports.applyPassive = applyPassive;
function supportsPassiveOption(globalObj) {
if (globalObj === void 0) {
globalObj = window;
}
// See
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
var passiveSupported = false;
try {
var options = {
// This function will be called when the browser
// attempts to access the passive property.
get passive() {
passiveSupported = true;
return false;
}
};
var handler = function handler() {};
globalObj.document.addEventListener('test', handler, options);
globalObj.document.removeEventListener('test', handler, options);
} catch (err) {
passiveSupported = false;
}
return passiveSupported;
}
/***/ }),
/***/ "./packages/mdc-dom/focus-trap.ts":
/*!****************************************!*\
!*** ./packages/mdc-dom/focus-trap.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FocusTrap = void 0;
var FOCUS_SENTINEL_CLASS = 'mdc-dom-focus-sentinel';
/**
* Utility to trap focus in a given root element, e.g. for modal components such
* as dialogs. The root should have at least one focusable child element,
* for setting initial focus when trapping focus.
* Also tracks the previously focused element, and restores focus to that
* element when releasing focus.
*/
var FocusTrap = /** @class */function () {
function FocusTrap(root, options) {
if (options === void 0) {
options = {};
}
this.root = root;
this.options = options;
// Previously focused element before trapping focus.
this.elFocusedBeforeTrapFocus = null;
}
/**
* Traps focus in `root`. Also focuses on either `initialFocusEl` if set;
* otherwises sets initial focus to the first focusable child element.
*/
FocusTrap.prototype.trapFocus = function () {
var focusableEls = this.getFocusableElements(this.root);
if (focusableEls.length === 0) {
throw new Error('FocusTrap: Element must have at least one focusable child.');
}
this.elFocusedBeforeTrapFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
this.wrapTabFocus(this.root);
if (!this.options.skipInitialFocus) {
this.focusInitialElement(focusableEls, this.options.initialFocusEl);
}
};
/**
* Releases focus from `root`. Also restores focus to the previously focused
* element.
*/
FocusTrap.prototype.releaseFocus = function () {
[].slice.call(this.root.querySelectorAll("." + FOCUS_SENTINEL_CLASS)).forEach(function (sentinelEl) {
sentinelEl.parentElement.removeChild(sentinelEl);
});
if (!this.options.skipRestoreFocus && this.elFocusedBeforeTrapFocus) {
this.elFocusedBeforeTrapFocus.focus();
}
};
/**
* Wraps tab focus within `el` by adding two hidden sentinel divs which are
* used to mark the beginning and the end of the tabbable region. When
* focused, these sentinel elements redirect focus to the first/last
* children elements of the tabbable region, ensuring that focus is trapped
* within that region.
*/
FocusTrap.prototype.wrapTabFocus = function (el) {
var _this = this;
var sentinelStart = this.createSentinel();
var sentinelEnd = this.createSentinel();
sentinelStart.addEventListener('focus', function () {
var focusableEls = _this.getFocusableElements(el);
if (focusableEls.length > 0) {
focusableEls[focusableEls.length - 1].focus();
}
});
sentinelEnd.addEventListener('focus', function () {
var focusableEls = _this.getFocusableElements(el);
if (focusableEls.length > 0) {
focusableEls[0].focus();
}
});
el.insertBefore(sentinelStart, el.children[0]);
el.appendChild(sentinelEnd);
};
/**
* Focuses on `initialFocusEl` if defined and a child of the root element.
* Otherwise, focuses on the first focusable child element of the root.
*/
FocusTrap.prototype.focusInitialElement = function (focusableEls, initialFocusEl) {
var focusIndex = 0;
if (initialFocusEl) {
focusIndex = Math.max(focusableEls.indexOf(initialFocusEl), 0);
}
focusableEls[focusIndex].focus();
};
FocusTrap.prototype.getFocusableElements = function (root) {
var focusableEls = [].slice.call(root.querySelectorAll('[autofocus], [tabindex], a, input, textarea, select, button'));
return focusableEls.filter(function (el) {
var isDisabledOrHidden = el.getAttribute('aria-disabled') === 'true' || el.getAttribute('disabled') != null || el.getAttribute('hidden') != null || el.getAttribute('aria-hidden') === 'true';
var isTabbableAndVisible = el.tabIndex >= 0 && el.getBoundingClientRect().width > 0 && !el.classList.contains(FOCUS_SENTINEL_CLASS) && !isDisabledOrHidden;
var isProgrammaticallyHidden = false;
if (isTabbableAndVisible) {
var style = getComputedStyle(el);
isProgrammaticallyHidden = style.display === 'none' || style.visibility === 'hidden';
}
return isTabbableAndVisible && !isProgrammaticallyHidden;
});
};
FocusTrap.prototype.createSentinel = function () {
var sentinel = document.createElement('div');
sentinel.setAttribute('tabindex', '0');
// Don't announce in screen readers.
sentinel.setAttribute('aria-hidden', 'true');
sentinel.classList.add(FOCUS_SENTINEL_CLASS);
return sentinel;
};
return FocusTrap;
}();
exports.FocusTrap = FocusTrap;
/***/ }),
/***/ "./packages/mdc-dom/index.ts":
/*!***********************************!*\
!*** ./packages/mdc-dom/index.ts ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ponyfill = exports.keyboard = exports.focusTrap = exports.events = void 0;
var events = __importStar(__webpack_require__(/*! ./events */ "./packages/mdc-dom/events.ts"));
exports.events = events;
var focusTrap = __importStar(__webpack_require__(/*! ./focus-trap */ "./packages/mdc-dom/focus-trap.ts"));
exports.focusTrap = focusTrap;
var keyboard = __importStar(__webpack_require__(/*! ./keyboard */ "./packages/mdc-dom/keyboard.ts"));
exports.keyboard = keyboard;
var ponyfill = __importStar(__webpack_require__(/*! ./ponyfill */ "./packages/mdc-dom/ponyfill.ts"));
exports.ponyfill = ponyfill;
/***/ }),
/***/ "./packages/mdc-dom/keyboard.ts":
/*!**************************************!*\
!*** ./packages/mdc-dom/keyboard.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNavigationEvent = exports.normalizeKey = exports.KEY = void 0;
/**
* KEY provides normalized string values for keys.
*/
exports.KEY = {
UNKNOWN: 'Unknown',
BACKSPACE: 'Backspace',
ENTER: 'Enter',
SPACEBAR: 'Spacebar',
PAGE_UP: 'PageUp',
PAGE_DOWN: 'PageDown',
END: 'End',
HOME: 'Home',
ARROW_LEFT: 'ArrowLeft',
ARROW_UP: 'ArrowUp',
ARROW_RIGHT: 'ArrowRight',
ARROW_DOWN: 'ArrowDown',
DELETE: 'Delete',
ESCAPE: 'Escape',
TAB: 'Tab'
};
var normalizedKeys = new Set();
// IE11 has no support for new Map with iterable so we need to initialize this
// by hand.
normalizedKeys.add(exports.KEY.BACKSPACE);
normalizedKeys.add(exports.KEY.ENTER);
normalizedKeys.add(exports.KEY.SPACEBAR);
normalizedKeys.add(exports.KEY.PAGE_UP);
normalizedKeys.add(exports.KEY.PAGE_DOWN);
normalizedKeys.add(exports.KEY.END);
normalizedKeys.add(exports.KEY.HOME);
normalizedKeys.add(exports.KEY.ARROW_LEFT);
normalizedKeys.add(exports.KEY.ARROW_UP);
normalizedKeys.add(exports.KEY.ARROW_RIGHT);
normalizedKeys.add(exports.KEY.ARROW_DOWN);
normalizedKeys.add(exports.KEY.DELETE);
normalizedKeys.add(exports.KEY.ESCAPE);
normalizedKeys.add(exports.KEY.TAB);
var KEY_CODE = {
BACKSPACE: 8,
ENTER: 13,
SPACEBAR: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
ARROW_LEFT: 37,
ARROW_UP: 38,
ARROW_RIGHT: 39,
ARROW_DOWN: 40,
DELETE: 46,
ESCAPE: 27,
TAB: 9
};
var mappedKeyCodes = new Map();
// IE11 has no support for new Map with iterable so we need to initialize this
// by hand.
mappedKeyCodes.set(KEY_CODE.BACKSPACE, exports.KEY.BACKSPACE);
mappedKeyCodes.set(KEY_CODE.ENTER, exports.KEY.ENTER);
mappedKeyCodes.set(KEY_CODE.SPACEBAR, exports.KEY.SPACEBAR);
mappedKeyCodes.set(KEY_CODE.PAGE_UP, exports.KEY.PAGE_UP);
mappedKeyCodes.set(KEY_CODE.PAGE_DOWN, exports.KEY.PAGE_DOWN);
mappedKeyCodes.set(KEY_CODE.END, exports.KEY.END);
mappedKeyCodes.set(KEY_CODE.HOME, exports.KEY.HOME);
mappedKeyCodes.set(KEY_CODE.ARROW_LEFT, exports.KEY.ARROW_LEFT);
mappedKeyCodes.set(KEY_CODE.ARROW_UP, exports.KEY.ARROW_UP);
mappedKeyCodes.set(KEY_CODE.ARROW_RIGHT, exports.KEY.ARROW_RIGHT);
mappedKeyCodes.set(KEY_CODE.ARROW_DOWN, exports.KEY.ARROW_DOWN);
mappedKeyCodes.set(KEY_CODE.DELETE, exports.KEY.DELETE);
mappedKeyCodes.set(KEY_CODE.ESCAPE, exports.KEY.ESCAPE);
mappedKeyCodes.set(KEY_CODE.TAB, exports.KEY.TAB);
var navigationKeys = new Set();
// IE11 has no support for new Set with iterable so we need to initialize this
// by hand.
navigationKeys.add(exports.KEY.PAGE_UP);
navigationKeys.add(exports.KEY.PAGE_DOWN);
navigationKeys.add(exports.KEY.END);
navigationKeys.add(exports.KEY.HOME);
navigationKeys.add(exports.KEY.ARROW_LEFT);
navigationKeys.add(exports.KEY.ARROW_UP);
navigationKeys.add(exports.KEY.ARROW_RIGHT);
navigationKeys.add(exports.KEY.ARROW_DOWN);
/**
* normalizeKey returns the normalized string for a navigational action.
*/
function normalizeKey(evt) {
var key = evt.key;
// If the event already has a normalized key, return it
if (normalizedKeys.has(key)) {
return key;
}
// tslint:disable-next-line:deprecation
var mappedKey = mappedKeyCodes.get(evt.keyCode);
if (mappedKey) {
return mappedKey;
}
return exports.KEY.UNKNOWN;
}
exports.normalizeKey = normalizeKey;
/**
* isNavigationEvent returns whether the event is a navigation event
*/
function isNavigationEvent(evt) {
return navigationKeys.has(normalizeKey(evt));
}
exports.isNavigationEvent = isNavigationEvent;
/***/ }),
/***/ "./packages/mdc-dom/ponyfill.ts":
/*!**************************************!*\
!*** ./packages/mdc-dom/ponyfill.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.estimateScrollWidth = exports.matches = exports.closest = void 0;
/**
* @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain.
* This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
*/
function closest(element, selector) {
if (element.closest) {
return element.closest(selector);
}
var el = element;
while (el) {
if (matches(el, selector)) {
return el;
}
el = el.parentElement;
}
return null;
}
exports.closest = closest;
function matches(element, selector) {
var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
return nativeMatches.call(element, selector);
}
exports.matches = matches;
/**
* Used to compute the estimated scroll width of elements. When an element is
* hidden due to display: none; being applied to a parent element, the width is
* returned as 0. However, the element will have a true width once no longer
* inside a display: none context. This method computes an estimated width when
* the element is hidden or returns the true width when the element is visble.
* @param {Element} element the element whose width to estimate
*/
function estimateScrollWidth(element) {
// Check the offsetParent. If the element inherits display: none from any
// parent, the offsetParent property will be null (see
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
// This check ensures we only clone the node when necessary.
var htmlEl = element;
if (htmlEl.offsetParent !== null) {
return htmlEl.scrollWidth;
}
var clone = htmlEl.cloneNode(true);
clone.style.setProperty('position', 'absolute');
clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
document.documentElement.appendChild(clone);
var scrollWidth = clone.scrollWidth;
document.documentElement.removeChild(clone);
return scrollWidth;
}
exports.estimateScrollWidth = estimateScrollWidth;
/***/ }),
/***/ "./packages/mdc-drawer/adapter.ts":
/*!****************************************!*\
!*** ./packages/mdc-drawer/adapter.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-drawer/component.ts":
/*!******************************************!*\
!*** ./packages/mdc-drawer/component.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCDrawer = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
var foundation_1 = __webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
var foundation_2 = __webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts");
var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
var cssClasses = foundation_1.MDCDismissibleDrawerFoundation.cssClasses,
strings = foundation_1.MDCDismissibleDrawerFoundation.strings;
/**
* @events `MDCDrawer:closed {}` Emits when the navigation drawer has closed.
* @events `MDCDrawer:opened {}` Emits when the navigation drawer has opened.
*/
var MDCDrawer = /** @class */function (_super) {
__extends(MDCDrawer, _super);
function MDCDrawer() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCDrawer.attachTo = function (root) {
return new MDCDrawer(root);
};
Object.defineProperty(MDCDrawer.prototype, "open", {
/**
* @return boolean Proxies to the foundation's `open`/`close` methods.
* Also returns true if drawer is in the open position.
*/
get: function get() {
return this.foundation.isOpen();
},
/**
* Toggles the drawer open and closed.
*/
set: function set(isOpen) {
if (isOpen) {
this.foundation.open();
} else {
this.foundation.close();
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCDrawer.prototype, "list", {
// initialSyncWithDOM()
get: function get() {
return this.innerList;
},
enumerable: false,
configurable: true
});
MDCDrawer.prototype.initialize = function (focusTrapFactory, listFactory) {
if (focusTrapFactory === void 0) {
focusTrapFactory = function focusTrapFactory(el) {
return new focus_trap_1.FocusTrap(el);
};
}
if (listFactory === void 0) {
listFactory = function listFactory(el) {
return new component_2.MDCList(el);
};
}
var listEl = this.root.querySelector(strings.LIST_SELECTOR);
if (listEl) {
this.innerList = listFactory(listEl);
this.innerList.wrapFocus = true;
}
this.focusTrapFactory = focusTrapFactory;
};
MDCDrawer.prototype.initialSyncWithDOM = function () {
var _this = this;
var MODAL = cssClasses.MODAL;
var SCRIM_SELECTOR = strings.SCRIM_SELECTOR;
this.scrim = this.root.parentNode.querySelector(SCRIM_SELECTOR);
if (this.scrim && this.root.classList.contains(MODAL)) {
this.handleScrimClick = function () {
return _this.foundation.handleScrimClick();
};
this.scrim.addEventListener('click', this.handleScrimClick);
this.focusTrap = util.createFocusTrapInstance(this.root, this.focusTrapFactory);
}
this.handleKeydown = function (evt) {
_this.foundation.handleKeydown(evt);
};
this.handleTransitionEnd = function (evt) {
_this.foundation.handleTransitionEnd(evt);
};
this.listen('keydown', this.handleKeydown);
this.listen('transitionend', this.handleTransitionEnd);
};
MDCDrawer.prototype.destroy = function () {
this.unlisten('keydown', this.handleKeydown);
this.unlisten('transitionend', this.handleTransitionEnd);
if (this.innerList) {
this.innerList.destroy();
}
var MODAL = cssClasses.MODAL;
if (this.scrim && this.handleScrimClick && this.root.classList.contains(MODAL)) {
this.scrim.removeEventListener('click', this.handleScrimClick);
// Ensure drawer is closed to hide scrim and release focus
this.open = false;
}
};
MDCDrawer.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
// methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
addClass: function addClass(className) {
_this.root.classList.add(className);
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
elementHasClass: function elementHasClass(element, className) {
return element.classList.contains(className);
},
saveFocus: function saveFocus() {
_this.previousFocus = document.activeElement;
},
restoreFocus: function restoreFocus() {
var previousFocus = _this.previousFocus;
if (previousFocus && previousFocus.focus && _this.root.contains(document.activeElement)) {
previousFocus.focus();
}
},
focusActiveNavigationItem: function focusActiveNavigationItem() {
var activeNavItemEl = _this.root.querySelector(strings.LIST_ITEM_ACTIVATED_SELECTOR);
if (activeNavItemEl) {
activeNavItemEl.focus();
}
},
notifyClose: function notifyClose() {
_this.emit(strings.CLOSE_EVENT, {}, true /* shouldBubble */);
},
notifyOpen: function notifyOpen() {
_this.emit(strings.OPEN_EVENT, {}, true /* shouldBubble */);
},
trapFocus: function trapFocus() {
_this.focusTrap.trapFocus();
},
releaseFocus: function releaseFocus() {
_this.focusTrap.releaseFocus();
}
};
// tslint:enable:object-literal-sort-keys
var DISMISSIBLE = cssClasses.DISMISSIBLE,
MODAL = cssClasses.MODAL;
if (this.root.classList.contains(DISMISSIBLE)) {
return new foundation_1.MDCDismissibleDrawerFoundation(adapter);
} else if (this.root.classList.contains(MODAL)) {
return new foundation_2.MDCModalDrawerFoundation(adapter);
} else {
throw new Error("MDCDrawer: Failed to instantiate component. Supported variants are " + DISMISSIBLE + " and " + MODAL + ".");
}
};
return MDCDrawer;
}(component_1.MDCComponent);
exports.MDCDrawer = MDCDrawer;
/***/ }),
/***/ "./packages/mdc-drawer/constants.ts":
/*!******************************************!*\
!*** ./packages/mdc-drawer/constants.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.cssClasses = void 0;
var cssClasses = {
ANIMATE: 'mdc-drawer--animate',
CLOSING: 'mdc-drawer--closing',
DISMISSIBLE: 'mdc-drawer--dismissible',
MODAL: 'mdc-drawer--modal',
OPEN: 'mdc-drawer--open',
OPENING: 'mdc-drawer--opening',
ROOT: 'mdc-drawer'
};
exports.cssClasses = cssClasses;
var strings = {
APP_CONTENT_SELECTOR: '.mdc-drawer-app-content',
CLOSE_EVENT: 'MDCDrawer:closed',
OPEN_EVENT: 'MDCDrawer:opened',
SCRIM_SELECTOR: '.mdc-drawer-scrim',
LIST_SELECTOR: '.mdc-list,.mdc-deprecated-list',
LIST_ITEM_ACTIVATED_SELECTOR: '.mdc-list-item--activated,.mdc-deprecated-list-item--activated'
};
exports.strings = strings;
/***/ }),
/***/ "./packages/mdc-drawer/dismissible/foundation.ts":
/*!*******************************************************!*\
!*** ./packages/mdc-drawer/dismissible/foundation.ts ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCDismissibleDrawerFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-drawer/constants.ts");
var MDCDismissibleDrawerFoundation = /** @class */function (_super) {
__extends(MDCDismissibleDrawerFoundation, _super);
function MDCDismissibleDrawerFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCDismissibleDrawerFoundation.defaultAdapter), adapter)) || this;
_this.animationFrame = 0;
_this.animationTimer = 0;
return _this;
}
Object.defineProperty(MDCDismissibleDrawerFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCDismissibleDrawerFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCDismissibleDrawerFoundation, "defaultAdapter", {
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
hasClass: function hasClass() {
return false;
},
elementHasClass: function elementHasClass() {
return false;
},
notifyClose: function notifyClose() {
return undefined;
},
notifyOpen: function notifyOpen() {
return undefined;
},
saveFocus: function saveFocus() {
return undefined;
},
restoreFocus: function restoreFocus() {
return undefined;
},
focusActiveNavigationItem: function focusActiveNavigationItem() {
return undefined;
},
trapFocus: function trapFocus() {
return undefined;
},
releaseFocus: function releaseFocus() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCDismissibleDrawerFoundation.prototype.destroy = function () {
if (this.animationFrame) {
cancelAnimationFrame(this.animationFrame);
}
if (this.animationTimer) {
clearTimeout(this.animationTimer);
}
};
/**
* Opens the drawer from the closed state.
*/
MDCDismissibleDrawerFoundation.prototype.open = function () {
var _this = this;
if (this.isOpen() || this.isOpening() || this.isClosing()) {
return;
}
this.adapter.addClass(constants_1.cssClasses.OPEN);
this.adapter.addClass(constants_1.cssClasses.ANIMATE);
// Wait a frame once display is no longer "none", to establish basis for animation
this.runNextAnimationFrame(function () {
_this.adapter.addClass(constants_1.cssClasses.OPENING);
});
this.adapter.saveFocus();
};
/**
* Closes the drawer from the open state.
*/
MDCDismissibleDrawerFoundation.prototype.close = function () {
if (!this.isOpen() || this.isOpening() || this.isClosing()) {
return;
}
this.adapter.addClass(constants_1.cssClasses.CLOSING);
};
/**
* Returns true if the drawer is in the open position.
* @return true if drawer is in open state.
*/
MDCDismissibleDrawerFoundation.prototype.isOpen = function () {
return this.adapter.hasClass(constants_1.cssClasses.OPEN);
};
/**
* Returns true if the drawer is animating open.
* @return true if drawer is animating open.
*/
MDCDismissibleDrawerFoundation.prototype.isOpening = function () {
return this.adapter.hasClass(constants_1.cssClasses.OPENING) || this.adapter.hasClass(constants_1.cssClasses.ANIMATE);
};
/**
* Returns true if the drawer is animating closed.
* @return true if drawer is animating closed.
*/
MDCDismissibleDrawerFoundation.prototype.isClosing = function () {
return this.adapter.hasClass(constants_1.cssClasses.CLOSING);
};
/**
* Keydown handler to close drawer when key is escape.
*/
MDCDismissibleDrawerFoundation.prototype.handleKeydown = function (evt) {
var keyCode = evt.keyCode,
key = evt.key;
var isEscape = key === 'Escape' || keyCode === 27;
if (isEscape) {
this.close();
}
};
/**
* Handles the `transitionend` event when the drawer finishes opening/closing.
*/
MDCDismissibleDrawerFoundation.prototype.handleTransitionEnd = function (evt) {
var OPENING = constants_1.cssClasses.OPENING,
CLOSING = constants_1.cssClasses.CLOSING,
OPEN = constants_1.cssClasses.OPEN,
ANIMATE = constants_1.cssClasses.ANIMATE,
ROOT = constants_1.cssClasses.ROOT;
// In Edge, transitionend on ripple pseudo-elements yields a target without classList, so check for Element first.
var isRootElement = this.isElement(evt.target) && this.adapter.elementHasClass(evt.target, ROOT);
if (!isRootElement) {
return;
}
if (this.isClosing()) {
this.adapter.removeClass(OPEN);
this.closed();
this.adapter.restoreFocus();
this.adapter.notifyClose();
} else {
this.adapter.focusActiveNavigationItem();
this.opened();
this.adapter.notifyOpen();
}
this.adapter.removeClass(ANIMATE);
this.adapter.removeClass(OPENING);
this.adapter.removeClass(CLOSING);
};
/**
* Extension point for when drawer finishes open animation.
*/
MDCDismissibleDrawerFoundation.prototype.opened = function () {}; // tslint:disable-line:no-empty
/**
* Extension point for when drawer finishes close animation.
*/
MDCDismissibleDrawerFoundation.prototype.closed = function () {}; // tslint:disable-line:no-empty
/**
* Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
*/
MDCDismissibleDrawerFoundation.prototype.runNextAnimationFrame = function (callback) {
var _this = this;
cancelAnimationFrame(this.animationFrame);
this.animationFrame = requestAnimationFrame(function () {
_this.animationFrame = 0;
clearTimeout(_this.animationTimer);
_this.animationTimer = setTimeout(callback, 0);
});
};
MDCDismissibleDrawerFoundation.prototype.isElement = function (element) {
// In Edge, transitionend on ripple pseudo-elements yields a target without classList.
return Boolean(element.classList);
};
return MDCDismissibleDrawerFoundation;
}(foundation_1.MDCFoundation);
exports.MDCDismissibleDrawerFoundation = MDCDismissibleDrawerFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCDismissibleDrawerFoundation;
/***/ }),
/***/ "./packages/mdc-drawer/index.ts":
/*!**************************************!*\
!*** ./packages/mdc-drawer/index.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.util = void 0;
var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
exports.util = util;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-drawer/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-drawer/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-drawer/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-drawer/modal/foundation.ts":
/*!*************************************************!*\
!*** ./packages/mdc-drawer/modal/foundation.ts ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCModalDrawerFoundation = void 0;
var foundation_1 = __webpack_require__(/*! ../dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
/* istanbul ignore next: subclass is not a branch statement */
var MDCModalDrawerFoundation = /** @class */function (_super) {
__extends(MDCModalDrawerFoundation, _super);
function MDCModalDrawerFoundation() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Handles click event on scrim.
*/
MDCModalDrawerFoundation.prototype.handleScrimClick = function () {
this.close();
};
/**
* Called when drawer finishes open animation.
*/
MDCModalDrawerFoundation.prototype.opened = function () {
this.adapter.trapFocus();
};
/**
* Called when drawer finishes close animation.
*/
MDCModalDrawerFoundation.prototype.closed = function () {
this.adapter.releaseFocus();
};
return MDCModalDrawerFoundation;
}(foundation_1.MDCDismissibleDrawerFoundation);
exports.MDCModalDrawerFoundation = MDCModalDrawerFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCModalDrawerFoundation;
/***/ }),
/***/ "./packages/mdc-drawer/util.ts":
/*!*************************************!*\
!*** ./packages/mdc-drawer/util.ts ***!
\*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.createFocusTrapInstance = void 0;
function createFocusTrapInstance(surfaceEl, focusTrapFactory) {
return focusTrapFactory(surfaceEl, {
// Component handles focusing on active nav item.
skipInitialFocus: true
});
}
exports.createFocusTrapInstance = createFocusTrapInstance;
/***/ }),
/***/ "./packages/mdc-floating-label/adapter.ts":
/*!************************************************!*\
!*** ./packages/mdc-floating-label/adapter.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-floating-label/component.ts":
/*!**************************************************!*\
!*** ./packages/mdc-floating-label/component.ts ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCFloatingLabel = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts");
var MDCFloatingLabel = /** @class */function (_super) {
__extends(MDCFloatingLabel, _super);
function MDCFloatingLabel() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCFloatingLabel.attachTo = function (root) {
return new MDCFloatingLabel(root);
};
/**
* Styles the label to produce the label shake for errors.
* @param shouldShake If true, shakes the label by adding a CSS class; otherwise, stops shaking by removing the class.
*/
MDCFloatingLabel.prototype.shake = function (shouldShake) {
this.foundation.shake(shouldShake);
};
/**
* Styles the label to float/dock.
* @param shouldFloat If true, floats the label by adding a CSS class; otherwise, docks it by removing the class.
*/
MDCFloatingLabel.prototype.float = function (shouldFloat) {
this.foundation.float(shouldFloat);
};
/**
* Styles the label as required.
* @param isRequired If true, adds an asterisk to the label, indicating that it is required.
*/
MDCFloatingLabel.prototype.setRequired = function (isRequired) {
this.foundation.setRequired(isRequired);
};
MDCFloatingLabel.prototype.getWidth = function () {
return this.foundation.getWidth();
};
MDCFloatingLabel.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
getWidth: function getWidth() {
return ponyfill_1.estimateScrollWidth(_this.root);
},
registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
return _this.listen(evtType, handler);
},
deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
return _this.unlisten(evtType, handler);
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_1.MDCFloatingLabelFoundation(adapter);
};
return MDCFloatingLabel;
}(component_1.MDCComponent);
exports.MDCFloatingLabel = MDCFloatingLabel;
/***/ }),
/***/ "./packages/mdc-floating-label/constants.ts":
/*!**************************************************!*\
!*** ./packages/mdc-floating-label/constants.ts ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssClasses = void 0;
exports.cssClasses = {
LABEL_FLOAT_ABOVE: 'mdc-floating-label--float-above',
LABEL_REQUIRED: 'mdc-floating-label--required',
LABEL_SHAKE: 'mdc-floating-label--shake',
ROOT: 'mdc-floating-label'
};
/***/ }),
/***/ "./packages/mdc-floating-label/foundation.ts":
/*!***************************************************!*\
!*** ./packages/mdc-floating-label/foundation.ts ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCFloatingLabelFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-floating-label/constants.ts");
var MDCFloatingLabelFoundation = /** @class */function (_super) {
__extends(MDCFloatingLabelFoundation, _super);
function MDCFloatingLabelFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCFloatingLabelFoundation.defaultAdapter), adapter)) || this;
_this.shakeAnimationEndHandler = function () {
_this.handleShakeAnimationEnd();
};
return _this;
}
Object.defineProperty(MDCFloatingLabelFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCFloatingLabelFoundation, "defaultAdapter", {
/**
* See {@link MDCFloatingLabelAdapter} for typing information on parameters and return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
getWidth: function getWidth() {
return 0;
},
registerInteractionHandler: function registerInteractionHandler() {
return undefined;
},
deregisterInteractionHandler: function deregisterInteractionHandler() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCFloatingLabelFoundation.prototype.init = function () {
this.adapter.registerInteractionHandler('animationend', this.shakeAnimationEndHandler);
};
MDCFloatingLabelFoundation.prototype.destroy = function () {
this.adapter.deregisterInteractionHandler('animationend', this.shakeAnimationEndHandler);
};
/**
* Returns the width of the label element.
*/
MDCFloatingLabelFoundation.prototype.getWidth = function () {
return this.adapter.getWidth();
};
/**
* Styles the label to produce a shake animation to indicate an error.
* @param shouldShake If true, adds the shake CSS class; otherwise, removes shake class.
*/
MDCFloatingLabelFoundation.prototype.shake = function (shouldShake) {
var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
if (shouldShake) {
this.adapter.addClass(LABEL_SHAKE);
} else {
this.adapter.removeClass(LABEL_SHAKE);
}
};
/**
* Styles the label to float or dock.
* @param shouldFloat If true, adds the float CSS class; otherwise, removes float and shake classes to dock the label.
*/
MDCFloatingLabelFoundation.prototype.float = function (shouldFloat) {
var _a = MDCFloatingLabelFoundation.cssClasses,
LABEL_FLOAT_ABOVE = _a.LABEL_FLOAT_ABOVE,
LABEL_SHAKE = _a.LABEL_SHAKE;
if (shouldFloat) {
this.adapter.addClass(LABEL_FLOAT_ABOVE);
} else {
this.adapter.removeClass(LABEL_FLOAT_ABOVE);
this.adapter.removeClass(LABEL_SHAKE);
}
};
/**
* Styles the label as required.
* @param isRequired If true, adds an asterisk to the label, indicating that it is required.
*/
MDCFloatingLabelFoundation.prototype.setRequired = function (isRequired) {
var LABEL_REQUIRED = MDCFloatingLabelFoundation.cssClasses.LABEL_REQUIRED;
if (isRequired) {
this.adapter.addClass(LABEL_REQUIRED);
} else {
this.adapter.removeClass(LABEL_REQUIRED);
}
};
MDCFloatingLabelFoundation.prototype.handleShakeAnimationEnd = function () {
var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
this.adapter.removeClass(LABEL_SHAKE);
};
return MDCFloatingLabelFoundation;
}(foundation_1.MDCFoundation);
exports.MDCFloatingLabelFoundation = MDCFloatingLabelFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCFloatingLabelFoundation;
/***/ }),
/***/ "./packages/mdc-floating-label/index.ts":
/*!**********************************************!*\
!*** ./packages/mdc-floating-label/index.ts ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-floating-label/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-floating-label/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-floating-label/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-form-field/adapter.ts":
/*!********************************************!*\
!*** ./packages/mdc-form-field/adapter.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-form-field/component.ts":
/*!**********************************************!*\
!*** ./packages/mdc-form-field/component.ts ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCFormField = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-form-field/foundation.ts");
var MDCFormField = /** @class */function (_super) {
__extends(MDCFormField, _super);
function MDCFormField() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCFormField.attachTo = function (root) {
return new MDCFormField(root);
};
MDCFormField.prototype.labelEl = function () {
var LABEL_SELECTOR = foundation_1.MDCFormFieldFoundation.strings.LABEL_SELECTOR;
return this.root.querySelector(LABEL_SELECTOR);
};
MDCFormField.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = {
activateInputRipple: function activateInputRipple() {
if (_this.input && _this.input.ripple) {
_this.input.ripple.activate();
}
},
deactivateInputRipple: function deactivateInputRipple() {
if (_this.input && _this.input.ripple) {
_this.input.ripple.deactivate();
}
},
deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
var labelEl = _this.labelEl();
if (labelEl) {
labelEl.removeEventListener(evtType, handler);
}
},
registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
var labelEl = _this.labelEl();
if (labelEl) {
labelEl.addEventListener(evtType, handler);
}
}
};
return new foundation_1.MDCFormFieldFoundation(adapter);
};
return MDCFormField;
}(component_1.MDCComponent);
exports.MDCFormField = MDCFormField;
/***/ }),
/***/ "./packages/mdc-form-field/constants.ts":
/*!**********************************************!*\
!*** ./packages/mdc-form-field/constants.ts ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.cssClasses = void 0;
exports.cssClasses = {
ROOT: 'mdc-form-field'
};
exports.strings = {
LABEL_SELECTOR: '.mdc-form-field > label'
};
/***/ }),
/***/ "./packages/mdc-form-field/foundation.ts":
/*!***********************************************!*\
!*** ./packages/mdc-form-field/foundation.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCFormFieldFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-form-field/constants.ts");
var MDCFormFieldFoundation = /** @class */function (_super) {
__extends(MDCFormFieldFoundation, _super);
function MDCFormFieldFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCFormFieldFoundation.defaultAdapter), adapter)) || this;
_this.click = function () {
_this.handleClick();
};
return _this;
}
Object.defineProperty(MDCFormFieldFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCFormFieldFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCFormFieldFoundation, "defaultAdapter", {
get: function get() {
return {
activateInputRipple: function activateInputRipple() {
return undefined;
},
deactivateInputRipple: function deactivateInputRipple() {
return undefined;
},
deregisterInteractionHandler: function deregisterInteractionHandler() {
return undefined;
},
registerInteractionHandler: function registerInteractionHandler() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCFormFieldFoundation.prototype.init = function () {
this.adapter.registerInteractionHandler('click', this.click);
};
MDCFormFieldFoundation.prototype.destroy = function () {
this.adapter.deregisterInteractionHandler('click', this.click);
};
MDCFormFieldFoundation.prototype.handleClick = function () {
var _this = this;
this.adapter.activateInputRipple();
requestAnimationFrame(function () {
_this.adapter.deactivateInputRipple();
});
};
return MDCFormFieldFoundation;
}(foundation_1.MDCFoundation);
exports.MDCFormFieldFoundation = MDCFormFieldFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCFormFieldFoundation;
/***/ }),
/***/ "./packages/mdc-form-field/index.ts":
/*!******************************************!*\
!*** ./packages/mdc-form-field/index.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-form-field/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-form-field/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-form-field/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-form-field/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-icon-button/adapter.ts":
/*!*********************************************!*\
!*** ./packages/mdc-icon-button/adapter.ts ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-icon-button/component.ts":
/*!***********************************************!*\
!*** ./packages/mdc-icon-button/component.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCIconButtonToggle = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-icon-button/foundation.ts");
var strings = foundation_1.MDCIconButtonToggleFoundation.strings;
var MDCIconButtonToggle = /** @class */function (_super) {
__extends(MDCIconButtonToggle, _super);
function MDCIconButtonToggle() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.rippleComponent = _this.createRipple();
return _this;
}
MDCIconButtonToggle.attachTo = function (root) {
return new MDCIconButtonToggle(root);
};
MDCIconButtonToggle.prototype.initialSyncWithDOM = function () {
var _this = this;
this.handleClick = function () {
_this.foundation.handleClick();
};
this.listen('click', this.handleClick);
};
MDCIconButtonToggle.prototype.destroy = function () {
this.unlisten('click', this.handleClick);
this.ripple.destroy();
_super.prototype.destroy.call(this);
};
MDCIconButtonToggle.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
notifyChange: function notifyChange(evtData) {
_this.emit(strings.CHANGE_EVENT, evtData);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
getAttr: function getAttr(attrName) {
return _this.root.getAttribute(attrName);
},
setAttr: function setAttr(attrName, attrValue) {
return _this.root.setAttribute(attrName, attrValue);
}
};
return new foundation_1.MDCIconButtonToggleFoundation(adapter);
};
Object.defineProperty(MDCIconButtonToggle.prototype, "ripple", {
get: function get() {
return this.rippleComponent;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCIconButtonToggle.prototype, "on", {
get: function get() {
return this.foundation.isOn();
},
set: function set(isOn) {
this.foundation.toggle(isOn);
},
enumerable: false,
configurable: true
});
MDCIconButtonToggle.prototype.createRipple = function () {
var ripple = new component_2.MDCRipple(this.root);
ripple.unbounded = true;
return ripple;
};
return MDCIconButtonToggle;
}(component_1.MDCComponent);
exports.MDCIconButtonToggle = MDCIconButtonToggle;
/***/ }),
/***/ "./packages/mdc-icon-button/constants.ts":
/*!***********************************************!*\
!*** ./packages/mdc-icon-button/constants.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.cssClasses = void 0;
exports.cssClasses = {
ICON_BUTTON_ON: 'mdc-icon-button--on',
ROOT: 'mdc-icon-button'
};
exports.strings = {
ARIA_LABEL: 'aria-label',
ARIA_PRESSED: 'aria-pressed',
DATA_ARIA_LABEL_OFF: 'data-aria-label-off',
DATA_ARIA_LABEL_ON: 'data-aria-label-on',
CHANGE_EVENT: 'MDCIconButtonToggle:change'
};
/***/ }),
/***/ "./packages/mdc-icon-button/foundation.ts":
/*!************************************************!*\
!*** ./packages/mdc-icon-button/foundation.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCIconButtonToggleFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-icon-button/constants.ts");
var MDCIconButtonToggleFoundation = /** @class */function (_super) {
__extends(MDCIconButtonToggleFoundation, _super);
function MDCIconButtonToggleFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCIconButtonToggleFoundation.defaultAdapter), adapter)) || this;
/**
* Whether the icon button has an aria label that changes depending on
* toggled state.
*/
_this.hasToggledAriaLabel = false;
return _this;
}
Object.defineProperty(MDCIconButtonToggleFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCIconButtonToggleFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCIconButtonToggleFoundation, "defaultAdapter", {
get: function get() {
return {
addClass: function addClass() {
return undefined;
},
hasClass: function hasClass() {
return false;
},
notifyChange: function notifyChange() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
getAttr: function getAttr() {
return null;
},
setAttr: function setAttr() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCIconButtonToggleFoundation.prototype.init = function () {
var ariaLabelOn = this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_ON);
var ariaLabelOff = this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_OFF);
if (ariaLabelOn && ariaLabelOff) {
if (this.adapter.getAttr(constants_1.strings.ARIA_PRESSED) !== null) {
throw new Error('MDCIconButtonToggleFoundation: Button should not set ' + '`aria-pressed` if it has a toggled aria label.');
}
this.hasToggledAriaLabel = true;
} else {
this.adapter.setAttr(constants_1.strings.ARIA_PRESSED, String(this.isOn()));
}
};
MDCIconButtonToggleFoundation.prototype.handleClick = function () {
this.toggle();
this.adapter.notifyChange({ isOn: this.isOn() });
};
MDCIconButtonToggleFoundation.prototype.isOn = function () {
return this.adapter.hasClass(constants_1.cssClasses.ICON_BUTTON_ON);
};
MDCIconButtonToggleFoundation.prototype.toggle = function (isOn) {
if (isOn === void 0) {
isOn = !this.isOn();
}
// Toggle UI based on state.
if (isOn) {
this.adapter.addClass(constants_1.cssClasses.ICON_BUTTON_ON);
} else {
this.adapter.removeClass(constants_1.cssClasses.ICON_BUTTON_ON);
}
// Toggle aria attributes based on state.
if (this.hasToggledAriaLabel) {
var ariaLabel = isOn ? this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_ON) : this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_OFF);
this.adapter.setAttr(constants_1.strings.ARIA_LABEL, ariaLabel || '');
} else {
this.adapter.setAttr(constants_1.strings.ARIA_PRESSED, "" + isOn);
}
};
return MDCIconButtonToggleFoundation;
}(foundation_1.MDCFoundation);
exports.MDCIconButtonToggleFoundation = MDCIconButtonToggleFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCIconButtonToggleFoundation;
/***/ }),
/***/ "./packages/mdc-icon-button/index.ts":
/*!*******************************************!*\
!*** ./packages/mdc-icon-button/index.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-icon-button/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-icon-button/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-icon-button/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-icon-button/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-icon-button/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-icon-button/types.ts":
/*!*******************************************!*\
!*** ./packages/mdc-icon-button/types.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-line-ripple/adapter.ts":
/*!*********************************************!*\
!*** ./packages/mdc-line-ripple/adapter.ts ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-line-ripple/component.ts":
/*!***********************************************!*\
!*** ./packages/mdc-line-ripple/component.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCLineRipple = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-line-ripple/foundation.ts");
var MDCLineRipple = /** @class */function (_super) {
__extends(MDCLineRipple, _super);
function MDCLineRipple() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCLineRipple.attachTo = function (root) {
return new MDCLineRipple(root);
};
/**
* Activates the line ripple
*/
MDCLineRipple.prototype.activate = function () {
this.foundation.activate();
};
/**
* Deactivates the line ripple
*/
MDCLineRipple.prototype.deactivate = function () {
this.foundation.deactivate();
};
/**
* Sets the transform origin given a user's click location.
* The `rippleCenter` is the x-coordinate of the middle of the ripple.
*/
MDCLineRipple.prototype.setRippleCenter = function (xCoordinate) {
this.foundation.setRippleCenter(xCoordinate);
};
MDCLineRipple.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
setStyle: function setStyle(propertyName, value) {
return _this.root.style.setProperty(propertyName, value);
},
registerEventHandler: function registerEventHandler(evtType, handler) {
return _this.listen(evtType, handler);
},
deregisterEventHandler: function deregisterEventHandler(evtType, handler) {
return _this.unlisten(evtType, handler);
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_1.MDCLineRippleFoundation(adapter);
};
return MDCLineRipple;
}(component_1.MDCComponent);
exports.MDCLineRipple = MDCLineRipple;
/***/ }),
/***/ "./packages/mdc-line-ripple/constants.ts":
/*!***********************************************!*\
!*** ./packages/mdc-line-ripple/constants.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssClasses = void 0;
var cssClasses = {
LINE_RIPPLE_ACTIVE: 'mdc-line-ripple--active',
LINE_RIPPLE_DEACTIVATING: 'mdc-line-ripple--deactivating'
};
exports.cssClasses = cssClasses;
/***/ }),
/***/ "./packages/mdc-line-ripple/foundation.ts":
/*!************************************************!*\
!*** ./packages/mdc-line-ripple/foundation.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCLineRippleFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-line-ripple/constants.ts");
var MDCLineRippleFoundation = /** @class */function (_super) {
__extends(MDCLineRippleFoundation, _super);
function MDCLineRippleFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCLineRippleFoundation.defaultAdapter), adapter)) || this;
_this.transitionEndHandler = function (evt) {
_this.handleTransitionEnd(evt);
};
return _this;
}
Object.defineProperty(MDCLineRippleFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCLineRippleFoundation, "defaultAdapter", {
/**
* See {@link MDCLineRippleAdapter} for typing information on parameters and return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
hasClass: function hasClass() {
return false;
},
setStyle: function setStyle() {
return undefined;
},
registerEventHandler: function registerEventHandler() {
return undefined;
},
deregisterEventHandler: function deregisterEventHandler() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCLineRippleFoundation.prototype.init = function () {
this.adapter.registerEventHandler('transitionend', this.transitionEndHandler);
};
MDCLineRippleFoundation.prototype.destroy = function () {
this.adapter.deregisterEventHandler('transitionend', this.transitionEndHandler);
};
MDCLineRippleFoundation.prototype.activate = function () {
this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
this.adapter.addClass(constants_1.cssClasses.LINE_RIPPLE_ACTIVE);
};
MDCLineRippleFoundation.prototype.setRippleCenter = function (xCoordinate) {
this.adapter.setStyle('transform-origin', xCoordinate + "px center");
};
MDCLineRippleFoundation.prototype.deactivate = function () {
this.adapter.addClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
};
MDCLineRippleFoundation.prototype.handleTransitionEnd = function (evt) {
// Wait for the line ripple to be either transparent or opaque
// before emitting the animation end event
var isDeactivating = this.adapter.hasClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
if (evt.propertyName === 'opacity') {
if (isDeactivating) {
this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_ACTIVE);
this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
}
}
};
return MDCLineRippleFoundation;
}(foundation_1.MDCFoundation);
exports.MDCLineRippleFoundation = MDCLineRippleFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCLineRippleFoundation;
/***/ }),
/***/ "./packages/mdc-line-ripple/index.ts":
/*!*******************************************!*\
!*** ./packages/mdc-line-ripple/index.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-line-ripple/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-line-ripple/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-line-ripple/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-line-ripple/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-linear-progress/adapter.ts":
/*!*************************************************!*\
!*** ./packages/mdc-linear-progress/adapter.ts ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-linear-progress/component.ts":
/*!***************************************************!*\
!*** ./packages/mdc-linear-progress/component.ts ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCLinearProgress = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-linear-progress/foundation.ts");
var MDCLinearProgress = /** @class */function (_super) {
__extends(MDCLinearProgress, _super);
function MDCLinearProgress() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCLinearProgress.attachTo = function (root) {
return new MDCLinearProgress(root);
};
Object.defineProperty(MDCLinearProgress.prototype, "determinate", {
set: function set(value) {
this.foundation.setDeterminate(value);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCLinearProgress.prototype, "progress", {
set: function set(value) {
this.foundation.setProgress(value);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCLinearProgress.prototype, "buffer", {
set: function set(value) {
this.foundation.setBuffer(value);
},
enumerable: false,
configurable: true
});
MDCLinearProgress.prototype.open = function () {
this.foundation.open();
};
MDCLinearProgress.prototype.close = function () {
this.foundation.close();
};
MDCLinearProgress.prototype.initialSyncWithDOM = function () {
var _this = this;
this.root.addEventListener('transitionend', function () {
_this.foundation.handleTransitionEnd();
});
};
MDCLinearProgress.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
// methods, we need a separate, strongly typed adapter variable.
var adapter = {
addClass: function addClass(className) {
_this.root.classList.add(className);
},
forceLayout: function forceLayout() {
_this.root.getBoundingClientRect();
},
setBufferBarStyle: function setBufferBarStyle(styleProperty, value) {
var bufferBar = _this.root.querySelector(foundation_1.MDCLinearProgressFoundation.strings.BUFFER_BAR_SELECTOR);
if (bufferBar) {
bufferBar.style.setProperty(styleProperty, value);
}
},
setPrimaryBarStyle: function setPrimaryBarStyle(styleProperty, value) {
var primaryBar = _this.root.querySelector(foundation_1.MDCLinearProgressFoundation.strings.PRIMARY_BAR_SELECTOR);
if (primaryBar) {
primaryBar.style.setProperty(styleProperty, value);
}
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
removeAttribute: function removeAttribute(attributeName) {
_this.root.removeAttribute(attributeName);
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
setAttribute: function setAttribute(attributeName, value) {
_this.root.setAttribute(attributeName, value);
},
setStyle: function setStyle(name, value) {
_this.root.style.setProperty(name, value);
},
attachResizeObserver: function attachResizeObserver(callback) {
var RO = window.ResizeObserver;
if (RO) {
var ro = new RO(callback);
ro.observe(_this.root);
return ro;
}
return null;
},
getWidth: function getWidth() {
return _this.root.offsetWidth;
}
};
return new foundation_1.MDCLinearProgressFoundation(adapter);
};
return MDCLinearProgress;
}(component_1.MDCComponent);
exports.MDCLinearProgress = MDCLinearProgress;
/***/ }),
/***/ "./packages/mdc-linear-progress/constants.ts":
/*!***************************************************!*\
!*** ./packages/mdc-linear-progress/constants.ts ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.animationDimensionPercentages = exports.strings = exports.cssClasses = void 0;
exports.cssClasses = {
CLOSED_CLASS: 'mdc-linear-progress--closed',
CLOSED_ANIMATION_OFF_CLASS: 'mdc-linear-progress--closed-animation-off',
INDETERMINATE_CLASS: 'mdc-linear-progress--indeterminate',
REVERSED_CLASS: 'mdc-linear-progress--reversed',
ANIMATION_READY_CLASS: 'mdc-linear-progress--animation-ready'
};
exports.strings = {
ARIA_HIDDEN: 'aria-hidden',
ARIA_VALUEMAX: 'aria-valuemax',
ARIA_VALUEMIN: 'aria-valuemin',
ARIA_VALUENOW: 'aria-valuenow',
BUFFER_BAR_SELECTOR: '.mdc-linear-progress__buffer-bar',
FLEX_BASIS: 'flex-basis',
PRIMARY_BAR_SELECTOR: '.mdc-linear-progress__primary-bar'
};
// these are percentages pulled from keyframes.scss
exports.animationDimensionPercentages = {
PRIMARY_HALF: .8367142,
PRIMARY_FULL: 2.00611057,
SECONDARY_QUARTER: .37651913,
SECONDARY_HALF: .84386165,
SECONDARY_FULL: 1.60277782
};
/***/ }),
/***/ "./packages/mdc-linear-progress/foundation.ts":
/*!****************************************************!*\
!*** ./packages/mdc-linear-progress/foundation.ts ***!
\****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCLinearProgressFoundation = void 0;
var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-linear-progress/constants.ts");
var MDCLinearProgressFoundation = /** @class */function (_super) {
__extends(MDCLinearProgressFoundation, _super);
function MDCLinearProgressFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCLinearProgressFoundation.defaultAdapter), adapter)) || this;
_this.observer = null;
return _this;
}
Object.defineProperty(MDCLinearProgressFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCLinearProgressFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCLinearProgressFoundation, "defaultAdapter", {
get: function get() {
return {
addClass: function addClass() {
return undefined;
},
attachResizeObserver: function attachResizeObserver() {
return null;
},
forceLayout: function forceLayout() {
return undefined;
},
getWidth: function getWidth() {
return 0;
},
hasClass: function hasClass() {
return false;
},
setBufferBarStyle: function setBufferBarStyle() {
return null;
},
setPrimaryBarStyle: function setPrimaryBarStyle() {
return null;
},
setStyle: function setStyle() {
return undefined;
},
removeAttribute: function removeAttribute() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
setAttribute: function setAttribute() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCLinearProgressFoundation.prototype.init = function () {
var _this = this;
this.determinate = !this.adapter.hasClass(constants_1.cssClasses.INDETERMINATE_CLASS);
this.adapter.addClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
this.progress = 0;
this.buffer = 1;
this.observer = this.adapter.attachResizeObserver(function (entries) {
var e_1, _a;
if (_this.determinate) {
return;
}
try {
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
var entry = entries_1_1.value;
if (entry.contentRect) {
_this.calculateAndSetDimensions(entry.contentRect.width);
}
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
} finally {
if (e_1) throw e_1.error;
}
}
});
if (!this.determinate && this.observer) {
this.calculateAndSetDimensions(this.adapter.getWidth());
}
};
MDCLinearProgressFoundation.prototype.setDeterminate = function (isDeterminate) {
this.determinate = isDeterminate;
if (this.determinate) {
this.adapter.removeClass(constants_1.cssClasses.INDETERMINATE_CLASS);
this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, this.progress.toString());
this.adapter.setAttribute(constants_1.strings.ARIA_VALUEMAX, '1');
this.adapter.setAttribute(constants_1.strings.ARIA_VALUEMIN, '0');
this.setPrimaryBarProgress(this.progress);
this.setBufferBarProgress(this.buffer);
return;
}
if (this.observer) {
this.calculateAndSetDimensions(this.adapter.getWidth());
}
this.adapter.addClass(constants_1.cssClasses.INDETERMINATE_CLASS);
this.adapter.removeAttribute(constants_1.strings.ARIA_VALUENOW);
this.adapter.removeAttribute(constants_1.strings.ARIA_VALUEMAX);
this.adapter.removeAttribute(constants_1.strings.ARIA_VALUEMIN);
this.setPrimaryBarProgress(1);
this.setBufferBarProgress(1);
};
MDCLinearProgressFoundation.prototype.isDeterminate = function () {
return this.determinate;
};
MDCLinearProgressFoundation.prototype.setProgress = function (value) {
this.progress = value;
if (this.determinate) {
this.setPrimaryBarProgress(value);
this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, value.toString());
}
};
MDCLinearProgressFoundation.prototype.getProgress = function () {
return this.progress;
};
MDCLinearProgressFoundation.prototype.setBuffer = function (value) {
this.buffer = value;
if (this.determinate) {
this.setBufferBarProgress(value);
}
};
MDCLinearProgressFoundation.prototype.getBuffer = function () {
return this.buffer;
};
MDCLinearProgressFoundation.prototype.open = function () {
this.adapter.removeClass(constants_1.cssClasses.CLOSED_CLASS);
this.adapter.removeClass(constants_1.cssClasses.CLOSED_ANIMATION_OFF_CLASS);
this.adapter.removeAttribute(constants_1.strings.ARIA_HIDDEN);
};
MDCLinearProgressFoundation.prototype.close = function () {
this.adapter.addClass(constants_1.cssClasses.CLOSED_CLASS);
this.adapter.setAttribute(constants_1.strings.ARIA_HIDDEN, 'true');
};
MDCLinearProgressFoundation.prototype.isClosed = function () {
return this.adapter.hasClass(constants_1.cssClasses.CLOSED_CLASS);
};
/**
* Handles the transitionend event emitted after `close()` is called and the
* opacity fades out. This is so that animations are removed only after the
* progress indicator is completely hidden.
*/
MDCLinearProgressFoundation.prototype.handleTransitionEnd = function () {
if (this.adapter.hasClass(constants_1.cssClasses.CLOSED_CLASS)) {
this.adapter.addClass(constants_1.cssClasses.CLOSED_ANIMATION_OFF_CLASS);
}
};
MDCLinearProgressFoundation.prototype.destroy = function () {
_super.prototype.destroy.call(this);
if (this.observer) {
this.observer.disconnect();
}
};
MDCLinearProgressFoundation.prototype.restartAnimation = function () {
this.adapter.removeClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
this.adapter.forceLayout();
this.adapter.addClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
};
MDCLinearProgressFoundation.prototype.setPrimaryBarProgress = function (progressValue) {
var value = "scaleX(" + progressValue + ")";
// Accessing `window` without a `typeof` check will throw on Node
// environments.
var transformProp = typeof window !== 'undefined' ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
this.adapter.setPrimaryBarStyle(transformProp, value);
};
MDCLinearProgressFoundation.prototype.setBufferBarProgress = function (progressValue) {
var value = progressValue * 100 + "%";
this.adapter.setBufferBarStyle(constants_1.strings.FLEX_BASIS, value);
};
MDCLinearProgressFoundation.prototype.calculateAndSetDimensions = function (width) {
var primaryHalf = width * constants_1.animationDimensionPercentages.PRIMARY_HALF;
var primaryFull = width * constants_1.animationDimensionPercentages.PRIMARY_FULL;
var secondaryQuarter = width * constants_1.animationDimensionPercentages.SECONDARY_QUARTER;
var secondaryHalf = width * constants_1.animationDimensionPercentages.SECONDARY_HALF;
var secondaryFull = width * constants_1.animationDimensionPercentages.SECONDARY_FULL;
this.adapter.setStyle('--mdc-linear-progress-primary-half', primaryHalf + "px");
this.adapter.setStyle('--mdc-linear-progress-primary-half-neg', -primaryHalf + "px");
this.adapter.setStyle('--mdc-linear-progress-primary-full', primaryFull + "px");
this.adapter.setStyle('--mdc-linear-progress-primary-full-neg', -primaryFull + "px");
this.adapter.setStyle('--mdc-linear-progress-secondary-quarter', secondaryQuarter + "px");
this.adapter.setStyle('--mdc-linear-progress-secondary-quarter-neg', -secondaryQuarter + "px");
this.adapter.setStyle('--mdc-linear-progress-secondary-half', secondaryHalf + "px");
this.adapter.setStyle('--mdc-linear-progress-secondary-half-neg', -secondaryHalf + "px");
this.adapter.setStyle('--mdc-linear-progress-secondary-full', secondaryFull + "px");
this.adapter.setStyle('--mdc-linear-progress-secondary-full-neg', -secondaryFull + "px");
// need to restart animation for custom props to apply to keyframes
this.restartAnimation();
};
return MDCLinearProgressFoundation;
}(foundation_1.MDCFoundation);
exports.MDCLinearProgressFoundation = MDCLinearProgressFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCLinearProgressFoundation;
/***/ }),
/***/ "./packages/mdc-linear-progress/index.ts":
/*!***********************************************!*\
!*** ./packages/mdc-linear-progress/index.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-linear-progress/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-linear-progress/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-linear-progress/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-linear-progress/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-linear-progress/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-linear-progress/types.ts":
/*!***********************************************!*\
!*** ./packages/mdc-linear-progress/types.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2021 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-list/adapter.ts":
/*!**************************************!*\
!*** ./packages/mdc-list/adapter.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-list/component.ts":
/*!****************************************!*\
!*** ./packages/mdc-list/component.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCList = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-list/foundation.ts");
var MDCList = /** @class */function (_super) {
__extends(MDCList, _super);
function MDCList() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(MDCList.prototype, "vertical", {
set: function set(value) {
this.foundation.setVerticalOrientation(value);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCList.prototype, "listElements", {
get: function get() {
return Array.from(this.root.querySelectorAll("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]));
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCList.prototype, "wrapFocus", {
set: function set(value) {
this.foundation.setWrapFocus(value);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCList.prototype, "typeaheadInProgress", {
/**
* @return Whether typeahead is currently matching a user-specified prefix.
*/
get: function get() {
return this.foundation.isTypeaheadInProgress();
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCList.prototype, "hasTypeahead", {
/**
* Sets whether typeahead functionality is enabled on the list.
* @param hasTypeahead Whether typeahead is enabled.
*/
set: function set(hasTypeahead) {
this.foundation.setHasTypeahead(hasTypeahead);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCList.prototype, "singleSelection", {
set: function set(isSingleSelectionList) {
this.foundation.setSingleSelection(isSingleSelectionList);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCList.prototype, "disabledItemsFocusable", {
set: function set(areDisabledItemsFocusable) {
this.foundation.setDisabledItemsFocusable(areDisabledItemsFocusable);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCList.prototype, "selectedIndex", {
get: function get() {
return this.foundation.getSelectedIndex();
},
set: function set(index) {
this.foundation.setSelectedIndex(index);
},
enumerable: false,
configurable: true
});
MDCList.attachTo = function (root) {
return new MDCList(root);
};
MDCList.prototype.initialSyncWithDOM = function () {
this.isEvolutionEnabled = constants_1.evolutionAttribute in this.root.dataset;
if (this.isEvolutionEnabled) {
this.classNameMap = constants_1.evolutionClassNameMap;
} else if (ponyfill_1.matches(this.root, constants_1.strings.DEPRECATED_SELECTOR)) {
this.classNameMap = constants_1.deprecatedClassNameMap;
} else {
this.classNameMap = Object.values(constants_1.cssClasses).reduce(function (obj, className) {
obj[className] = className;
return obj;
}, {});
}
this.handleClick = this.handleClickEvent.bind(this);
this.handleKeydown = this.handleKeydownEvent.bind(this);
this.focusInEventListener = this.handleFocusInEvent.bind(this);
this.focusOutEventListener = this.handleFocusOutEvent.bind(this);
this.listen('keydown', this.handleKeydown);
this.listen('click', this.handleClick);
this.listen('focusin', this.focusInEventListener);
this.listen('focusout', this.focusOutEventListener);
this.layout();
this.initializeListType();
this.ensureFocusable();
};
MDCList.prototype.destroy = function () {
this.unlisten('keydown', this.handleKeydown);
this.unlisten('click', this.handleClick);
this.unlisten('focusin', this.focusInEventListener);
this.unlisten('focusout', this.focusOutEventListener);
};
MDCList.prototype.layout = function () {
var direction = this.root.getAttribute(constants_1.strings.ARIA_ORIENTATION);
this.vertical = direction !== constants_1.strings.ARIA_ORIENTATION_HORIZONTAL;
var itemSelector = "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not([tabindex])";
var childSelector = constants_1.strings.FOCUSABLE_CHILD_ELEMENTS;
// List items need to have at least tabindex=-1 to be focusable.
var itemEls = this.root.querySelectorAll(itemSelector);
if (itemEls.length) {
Array.prototype.forEach.call(itemEls, function (el) {
el.setAttribute('tabindex', '-1');
});
}
// Child button/a elements are not tabbable until the list item is focused.
var focusableChildEls = this.root.querySelectorAll(childSelector);
if (focusableChildEls.length) {
Array.prototype.forEach.call(focusableChildEls, function (el) {
el.setAttribute('tabindex', '-1');
});
}
if (this.isEvolutionEnabled) {
this.foundation.setUseSelectedAttribute(true);
}
this.foundation.layout();
};
/**
* Extracts the primary text from a list item.
* @param item The list item element.
* @return The primary text in the element.
*/
MDCList.prototype.getPrimaryText = function (item) {
var _a;
var primaryText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS]);
if (this.isEvolutionEnabled || primaryText) {
return (_a = primaryText === null || primaryText === void 0 ? void 0 : primaryText.textContent) !== null && _a !== void 0 ? _a : '';
}
var singleLineText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_TEXT_CLASS]);
return singleLineText && singleLineText.textContent || '';
};
/**
* Initialize selectedIndex value based on pre-selected list items.
*/
MDCList.prototype.initializeListType = function () {
var _this = this;
this.isInteractive = ponyfill_1.matches(this.root, constants_1.strings.ARIA_INTERACTIVE_ROLES_SELECTOR);
if (this.isEvolutionEnabled && this.isInteractive) {
var selection = Array.from(this.root.querySelectorAll(constants_1.strings.SELECTED_ITEM_SELECTOR), function (listItem) {
return _this.listElements.indexOf(listItem);
});
if (ponyfill_1.matches(this.root, constants_1.strings.ARIA_MULTI_SELECTABLE_SELECTOR)) {
this.selectedIndex = selection;
} else if (selection.length > 0) {
this.selectedIndex = selection[0];
}
return;
}
var checkboxListItems = this.root.querySelectorAll(constants_1.strings.ARIA_ROLE_CHECKBOX_SELECTOR);
var radioSelectedListItem = this.root.querySelector(constants_1.strings.ARIA_CHECKED_RADIO_SELECTOR);
if (checkboxListItems.length) {
var preselectedItems = this.root.querySelectorAll(constants_1.strings.ARIA_CHECKED_CHECKBOX_SELECTOR);
this.selectedIndex = Array.from(preselectedItems, function (listItem) {
return _this.listElements.indexOf(listItem);
});
} else if (radioSelectedListItem) {
this.selectedIndex = this.listElements.indexOf(radioSelectedListItem);
}
};
/**
* Updates the list item at itemIndex to the desired isEnabled state.
* @param itemIndex Index of the list item
* @param isEnabled Sets the list item to enabled or disabled.
*/
MDCList.prototype.setEnabled = function (itemIndex, isEnabled) {
this.foundation.setEnabled(itemIndex, isEnabled);
};
/**
* Given the next desired character from the user, adds it to the typeahead
* buffer. Then, attempts to find the next option matching the buffer. Wraps
* around if at the end of options.
*
* @param nextChar The next character to add to the prefix buffer.
* @param startingIndex The index from which to start matching. Defaults to
* the currently focused index.
* @return The index of the matched item.
*/
MDCList.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
return this.foundation.typeaheadMatchItem(nextChar, startingIndex, /** skipFocus */true);
};
MDCList.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
// methods, we need a separate, strongly typed adapter variable.
var adapter = {
addClassForElementIndex: function addClassForElementIndex(index, className) {
var element = _this.listElements[index];
if (element) {
element.classList.add(_this.classNameMap[className]);
}
},
focusItemAtIndex: function focusItemAtIndex(index) {
var element = _this.listElements[index];
if (element) {
element.focus();
}
},
getAttributeForElementIndex: function getAttributeForElementIndex(index, attr) {
return _this.listElements[index].getAttribute(attr);
},
getFocusedElementIndex: function getFocusedElementIndex() {
return _this.listElements.indexOf(document.activeElement);
},
getListItemCount: function getListItemCount() {
return _this.listElements.length;
},
getPrimaryTextAtIndex: function getPrimaryTextAtIndex(index) {
return _this.getPrimaryText(_this.listElements[index]);
},
hasCheckboxAtIndex: function hasCheckboxAtIndex(index) {
var listItem = _this.listElements[index];
return !!listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
},
hasRadioAtIndex: function hasRadioAtIndex(index) {
var listItem = _this.listElements[index];
return !!listItem.querySelector(constants_1.strings.RADIO_SELECTOR);
},
isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex(index) {
var listItem = _this.listElements[index];
var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
return toggleEl.checked;
},
isFocusInsideList: function isFocusInsideList() {
return _this.root !== document.activeElement && _this.root.contains(document.activeElement);
},
isRootFocused: function isRootFocused() {
return document.activeElement === _this.root;
},
listItemAtIndexHasClass: function listItemAtIndexHasClass(index, className) {
return _this.listElements[index].classList.contains(_this.classNameMap[className]);
},
notifyAction: function notifyAction(index) {
_this.emit(constants_1.strings.ACTION_EVENT, { index: index }, /** shouldBubble */true);
},
notifySelectionChange: function notifySelectionChange(changedIndices) {
_this.emit(constants_1.strings.SELECTION_CHANGE_EVENT, { changedIndices: changedIndices }, /** shouldBubble */true);
},
removeClassForElementIndex: function removeClassForElementIndex(index, className) {
var element = _this.listElements[index];
if (element) {
element.classList.remove(_this.classNameMap[className]);
}
},
setAttributeForElementIndex: function setAttributeForElementIndex(index, attr, value) {
var element = _this.listElements[index];
if (element) {
element.setAttribute(attr, value);
}
},
setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex(index, isChecked) {
var listItem = _this.listElements[index];
var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_RADIO_SELECTOR);
toggleEl.checked = isChecked;
var event = document.createEvent('Event');
event.initEvent('change', true, true);
toggleEl.dispatchEvent(event);
},
setTabIndexForListItemChildren: function setTabIndexForListItemChildren(listItemIndex, tabIndexValue) {
var element = _this.listElements[listItemIndex];
var selector = constants_1.strings.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX;
Array.prototype.forEach.call(element.querySelectorAll(selector), function (el) {
el.setAttribute('tabindex', tabIndexValue);
});
}
};
return new foundation_1.MDCListFoundation(adapter);
};
/**
* Ensures that at least one item is focusable if the list is interactive and
* doesn't specify a suitable tabindex.
*/
MDCList.prototype.ensureFocusable = function () {
if (this.isEvolutionEnabled && this.isInteractive) {
if (!this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + "[tabindex=\"0\"]")) {
var index = this.initialFocusIndex();
if (index !== -1) {
this.listElements[index].tabIndex = 0;
}
}
}
};
MDCList.prototype.initialFocusIndex = function () {
if (this.selectedIndex instanceof Array && this.selectedIndex.length > 0) {
return this.selectedIndex[0];
}
if (typeof this.selectedIndex === 'number' && this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
return this.selectedIndex;
}
var el = this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not(." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS] + ")");
if (el === null) {
return -1;
}
return this.getListItemIndex(el);
};
/**
* Used to figure out which list item this event is targetting. Or returns -1
* if there is no list item
*/
MDCList.prototype.getListItemIndex = function (el) {
var nearestParent = ponyfill_1.closest(el, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ", ." + this.classNameMap[constants_1.cssClasses.ROOT]);
// Get the index of the element if it is a list item.
if (nearestParent && ponyfill_1.matches(nearestParent, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS])) {
return this.listElements.indexOf(nearestParent);
}
return -1;
};
/**
* Used to figure out which element was clicked before sending the event to
* the foundation.
*/
MDCList.prototype.handleFocusInEvent = function (evt) {
var index = this.getListItemIndex(evt.target);
this.foundation.handleFocusIn(index);
};
/**
* Used to figure out which element was clicked before sending the event to
* the foundation.
*/
MDCList.prototype.handleFocusOutEvent = function (evt) {
var index = this.getListItemIndex(evt.target);
this.foundation.handleFocusOut(index);
};
/**
* Used to figure out which element was focused when keydown event occurred
* before sending the event to the foundation.
*/
MDCList.prototype.handleKeydownEvent = function (evt) {
var index = this.getListItemIndex(evt.target);
var target = evt.target;
this.foundation.handleKeydown(evt, target.classList.contains(this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]), index);
};
/**
* Used to figure out which element was clicked before sending the event to
* the foundation.
*/
MDCList.prototype.handleClickEvent = function (evt) {
var index = this.getListItemIndex(evt.target);
var target = evt.target;
// Toggle the checkbox only if it's not the target of the event, or the
// checkbox will have 2 change events.
var toggleCheckbox = !ponyfill_1.matches(target, constants_1.strings.CHECKBOX_RADIO_SELECTOR);
this.foundation.handleClick(index, toggleCheckbox, evt);
};
return MDCList;
}(component_1.MDCComponent);
exports.MDCList = MDCList;
/***/ }),
/***/ "./packages/mdc-list/constants.ts":
/*!****************************************!*\
!*** ./packages/mdc-list/constants.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true });
exports.evolutionClassNameMap = exports.evolutionAttribute = exports.deprecatedClassNameMap = exports.numbers = exports.cssClasses = exports.strings = void 0;
var cssClasses = {
LIST_ITEM_ACTIVATED_CLASS: 'mdc-list-item--activated',
LIST_ITEM_CLASS: 'mdc-list-item',
LIST_ITEM_DISABLED_CLASS: 'mdc-list-item--disabled',
LIST_ITEM_SELECTED_CLASS: 'mdc-list-item--selected',
LIST_ITEM_TEXT_CLASS: 'mdc-list-item__text',
LIST_ITEM_PRIMARY_TEXT_CLASS: 'mdc-list-item__primary-text',
ROOT: 'mdc-list'
};
exports.cssClasses = cssClasses;
var evolutionClassNameMap = (_a = {}, _a["" + cssClasses.LIST_ITEM_ACTIVATED_CLASS] = 'mdc-list-item--activated', _a["" + cssClasses.LIST_ITEM_CLASS] = 'mdc-list-item', _a["" + cssClasses.LIST_ITEM_DISABLED_CLASS] = 'mdc-list-item--disabled', _a["" + cssClasses.LIST_ITEM_SELECTED_CLASS] = 'mdc-list-item--selected', _a["" + cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS] = 'mdc-list-item__primary-text', _a["" + cssClasses.ROOT] = 'mdc-list', _a);
exports.evolutionClassNameMap = evolutionClassNameMap;
var deprecatedClassNameMap = (_b = {}, _b["" + cssClasses.LIST_ITEM_ACTIVATED_CLASS] = 'mdc-deprecated-list-item--activated', _b["" + cssClasses.LIST_ITEM_CLASS] = 'mdc-deprecated-list-item', _b["" + cssClasses.LIST_ITEM_DISABLED_CLASS] = 'mdc-deprecated-list-item--disabled', _b["" + cssClasses.LIST_ITEM_SELECTED_CLASS] = 'mdc-deprecated-list-item--selected', _b["" + cssClasses.LIST_ITEM_TEXT_CLASS] = 'mdc-deprecated-list-item__text', _b["" + cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS] = 'mdc-deprecated-list-item__primary-text', _b["" + cssClasses.ROOT] = 'mdc-deprecated-list', _b);
exports.deprecatedClassNameMap = deprecatedClassNameMap;
var strings = {
ACTION_EVENT: 'MDCList:action',
SELECTION_CHANGE_EVENT: 'MDCList:selectionChange',
ARIA_CHECKED: 'aria-checked',
ARIA_CHECKED_CHECKBOX_SELECTOR: '[role="checkbox"][aria-checked="true"]',
ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]',
ARIA_CURRENT: 'aria-current',
ARIA_DISABLED: 'aria-disabled',
ARIA_ORIENTATION: 'aria-orientation',
ARIA_ORIENTATION_HORIZONTAL: 'horizontal',
ARIA_ROLE_CHECKBOX_SELECTOR: '[role="checkbox"]',
ARIA_SELECTED: 'aria-selected',
ARIA_INTERACTIVE_ROLES_SELECTOR: '[role="listbox"], [role="menu"]',
ARIA_MULTI_SELECTABLE_SELECTOR: '[aria-multiselectable="true"]',
CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"], input[type="radio"]',
CHECKBOX_SELECTOR: 'input[type="checkbox"]',
CHILD_ELEMENTS_TO_TOGGLE_TABINDEX: "\n ." + cssClasses.LIST_ITEM_CLASS + " button:not(:disabled),\n ." + cssClasses.LIST_ITEM_CLASS + " a,\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " button:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " a\n ",
DEPRECATED_SELECTOR: '.mdc-deprecated-list',
FOCUSABLE_CHILD_ELEMENTS: "\n ." + cssClasses.LIST_ITEM_CLASS + " button:not(:disabled),\n ." + cssClasses.LIST_ITEM_CLASS + " a,\n ." + cssClasses.LIST_ITEM_CLASS + " input[type=\"radio\"]:not(:disabled),\n ." + cssClasses.LIST_ITEM_CLASS + " input[type=\"checkbox\"]:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " button:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " a,\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " input[type=\"radio\"]:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " input[type=\"checkbox\"]:not(:disabled)\n ",
RADIO_SELECTOR: 'input[type="radio"]',
SELECTED_ITEM_SELECTOR: '[aria-selected="true"], [aria-current="true"]'
};
exports.strings = strings;
var numbers = {
UNSET_INDEX: -1,
TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS: 300
};
exports.numbers = numbers;
var evolutionAttribute = 'evolution';
exports.evolutionAttribute = evolutionAttribute;
/***/ }),
/***/ "./packages/mdc-list/events.ts":
/*!*************************************!*\
!*** ./packages/mdc-list/events.ts ***!
\*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.preventDefaultEvent = void 0;
var ELEMENTS_KEY_ALLOWED_IN = ['input', 'button', 'textarea', 'select'];
/**
* Ensures that preventDefault is only called if the containing element
* doesn't consume the event, and it will cause an unintended scroll.
*
* @param evt keyboard event to be prevented.
*/
var preventDefaultEvent = function preventDefaultEvent(evt) {
var target = evt.target;
if (!target) {
return;
}
var tagName = ("" + target.tagName).toLowerCase();
if (ELEMENTS_KEY_ALLOWED_IN.indexOf(tagName) === -1) {
evt.preventDefault();
}
};
exports.preventDefaultEvent = preventDefaultEvent;
/***/ }),
/***/ "./packages/mdc-list/foundation.ts":
/*!*****************************************!*\
!*** ./packages/mdc-list/foundation.ts ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
ar.push(r.value);
}
} catch (error) {
e = { error: error };
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};
var __spreadArray = this && this.__spreadArray || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
to[j] = from[i];
}return to;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCListFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
var typeahead = __importStar(__webpack_require__(/*! ./typeahead */ "./packages/mdc-list/typeahead.ts"));
function isNumberArray(selectedIndex) {
return selectedIndex instanceof Array;
}
/** List of modifier keys to consider while handling keyboard events. */
var handledModifierKeys = ['Alt', 'Control', 'Meta', 'Shift'];
/** Checks if the event has the given modifier keys. */
function createModifierChecker(event) {
var eventModifiers = new Set(event ? handledModifierKeys.filter(function (m) {
return event.getModifierState(m);
}) : []);
return function (modifiers) {
return modifiers.every(function (m) {
return eventModifiers.has(m);
}) && modifiers.length === eventModifiers.size;
};
}
var MDCListFoundation = /** @class */function (_super) {
__extends(MDCListFoundation, _super);
function MDCListFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCListFoundation.defaultAdapter), adapter)) || this;
_this.wrapFocus = false;
_this.isVertical = true;
_this.isSingleSelectionList = false;
_this.areDisabledItemsFocusable = true;
_this.selectedIndex = constants_1.numbers.UNSET_INDEX;
_this.focusedItemIndex = constants_1.numbers.UNSET_INDEX;
_this.useActivatedClass = false;
_this.useSelectedAttr = false;
_this.ariaCurrentAttrValue = null;
_this.isCheckboxList = false;
_this.isRadioList = false;
_this.lastSelectedIndex = null;
_this.hasTypeahead = false;
// Transiently holds current typeahead prefix from user.
_this.typeaheadState = typeahead.initState();
_this.sortedIndexByFirstChar = new Map();
return _this;
}
Object.defineProperty(MDCListFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCListFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCListFoundation, "numbers", {
get: function get() {
return constants_1.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCListFoundation, "defaultAdapter", {
get: function get() {
return {
addClassForElementIndex: function addClassForElementIndex() {
return undefined;
},
focusItemAtIndex: function focusItemAtIndex() {
return undefined;
},
getAttributeForElementIndex: function getAttributeForElementIndex() {
return null;
},
getFocusedElementIndex: function getFocusedElementIndex() {
return 0;
},
getListItemCount: function getListItemCount() {
return 0;
},
hasCheckboxAtIndex: function hasCheckboxAtIndex() {
return false;
},
hasRadioAtIndex: function hasRadioAtIndex() {
return false;
},
isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex() {
return false;
},
isFocusInsideList: function isFocusInsideList() {
return false;
},
isRootFocused: function isRootFocused() {
return false;
},
listItemAtIndexHasClass: function listItemAtIndexHasClass() {
return false;
},
notifyAction: function notifyAction() {
return undefined;
},
notifySelectionChange: function notifySelectionChange() {},
removeClassForElementIndex: function removeClassForElementIndex() {
return undefined;
},
setAttributeForElementIndex: function setAttributeForElementIndex() {
return undefined;
},
setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex() {
return undefined;
},
setTabIndexForListItemChildren: function setTabIndexForListItemChildren() {
return undefined;
},
getPrimaryTextAtIndex: function getPrimaryTextAtIndex() {
return '';
}
};
},
enumerable: false,
configurable: true
});
MDCListFoundation.prototype.layout = function () {
if (this.adapter.getListItemCount() === 0) {
return;
}
// TODO(b/172274142): consider all items when determining the list's type.
if (this.adapter.hasCheckboxAtIndex(0)) {
this.isCheckboxList = true;
} else if (this.adapter.hasRadioAtIndex(0)) {
this.isRadioList = true;
} else {
this.maybeInitializeSingleSelection();
}
if (this.hasTypeahead) {
this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
}
};
/** Returns the index of the item that was last focused. */
MDCListFoundation.prototype.getFocusedItemIndex = function () {
return this.focusedItemIndex;
};
/** Toggles focus wrapping with keyboard navigation. */
MDCListFoundation.prototype.setWrapFocus = function (value) {
this.wrapFocus = value;
};
/**
* Toggles orientation direction for keyboard navigation (true for vertical,
* false for horizontal).
*/
MDCListFoundation.prototype.setVerticalOrientation = function (value) {
this.isVertical = value;
};
/** Toggles single-selection behavior. */
MDCListFoundation.prototype.setSingleSelection = function (value) {
this.isSingleSelectionList = value;
if (value) {
this.maybeInitializeSingleSelection();
this.selectedIndex = this.getSelectedIndexFromDOM();
}
};
MDCListFoundation.prototype.setDisabledItemsFocusable = function (value) {
this.areDisabledItemsFocusable = value;
};
/**
* Automatically determines whether the list is single selection list. If so,
* initializes the internal state to match the selected item.
*/
MDCListFoundation.prototype.maybeInitializeSingleSelection = function () {
var selectedItemIndex = this.getSelectedIndexFromDOM();
if (selectedItemIndex === constants_1.numbers.UNSET_INDEX) return;
var hasActivatedClass = this.adapter.listItemAtIndexHasClass(selectedItemIndex, constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
if (hasActivatedClass) {
this.setUseActivatedClass(true);
}
this.isSingleSelectionList = true;
this.selectedIndex = selectedItemIndex;
};
/** @return Index of the first selected item based on the DOM state. */
MDCListFoundation.prototype.getSelectedIndexFromDOM = function () {
var selectedIndex = constants_1.numbers.UNSET_INDEX;
var listItemsCount = this.adapter.getListItemCount();
for (var i = 0; i < listItemsCount; i++) {
var hasSelectedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS);
var hasActivatedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
if (!(hasSelectedClass || hasActivatedClass)) {
continue;
}
selectedIndex = i;
break;
}
return selectedIndex;
};
/**
* Sets whether typeahead is enabled on the list.
* @param hasTypeahead Whether typeahead is enabled.
*/
MDCListFoundation.prototype.setHasTypeahead = function (hasTypeahead) {
this.hasTypeahead = hasTypeahead;
if (hasTypeahead) {
this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
}
};
/**
* @return Whether typeahead is currently matching a user-specified prefix.
*/
MDCListFoundation.prototype.isTypeaheadInProgress = function () {
return this.hasTypeahead && typeahead.isTypingInProgress(this.typeaheadState);
};
/** Toggle use of the "activated" CSS class. */
MDCListFoundation.prototype.setUseActivatedClass = function (useActivated) {
this.useActivatedClass = useActivated;
};
/**
* Toggles use of the selected attribute (true for aria-selected, false for
* aria-checked).
*/
MDCListFoundation.prototype.setUseSelectedAttribute = function (useSelected) {
this.useSelectedAttr = useSelected;
};
MDCListFoundation.prototype.getSelectedIndex = function () {
return this.selectedIndex;
};
MDCListFoundation.prototype.setSelectedIndex = function (index, options) {
if (options === void 0) {
options = {};
}
if (!this.isIndexValid(index)) {
return;
}
if (this.isCheckboxList) {
this.setCheckboxAtIndex(index, options);
} else if (this.isRadioList) {
this.setRadioAtIndex(index, options);
} else {
this.setSingleSelectionAtIndex(index, options);
}
};
/**
* Focus in handler for the list items.
*/
MDCListFoundation.prototype.handleFocusIn = function (listItemIndex) {
if (listItemIndex >= 0) {
this.focusedItemIndex = listItemIndex;
this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '0');
this.adapter.setTabIndexForListItemChildren(listItemIndex, '0');
}
};
/**
* Focus out handler for the list items.
*/
MDCListFoundation.prototype.handleFocusOut = function (listItemIndex) {
var _this = this;
if (listItemIndex >= 0) {
this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '-1');
this.adapter.setTabIndexForListItemChildren(listItemIndex, '-1');
}
/**
* Between Focusout & Focusin some browsers do not have focus on any
* element. Setting a delay to wait till the focus is moved to next element.
*/
setTimeout(function () {
if (!_this.adapter.isFocusInsideList()) {
_this.setTabindexToFirstSelectedOrFocusedItem();
}
}, 0);
};
MDCListFoundation.prototype.isIndexDisabled = function (index) {
return this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
};
/**
* Key handler for the list.
*/
MDCListFoundation.prototype.handleKeydown = function (event, isRootListItem, listItemIndex) {
var _this = this;
var _a;
var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
var isHome = keyboard_1.normalizeKey(event) === 'Home';
var isEnd = keyboard_1.normalizeKey(event) === 'End';
var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
// The keys for forward and back differ based on list orientation.
var isForward = this.isVertical && isArrowDown || !this.isVertical && isArrowRight;
var isBack = this.isVertical && isArrowUp || !this.isVertical && isArrowLeft;
// Have to check both upper and lower case, because having caps lock on
// affects the value.
var isLetterA = event.key === 'A' || event.key === 'a';
var eventHasModifiers = createModifierChecker(event);
if (this.adapter.isRootFocused()) {
if ((isBack || isEnd) && eventHasModifiers([])) {
event.preventDefault();
this.focusLastElement();
} else if ((isForward || isHome) && eventHasModifiers([])) {
event.preventDefault();
this.focusFirstElement();
} else if (isBack && eventHasModifiers(['Shift']) && this.isCheckboxList) {
event.preventDefault();
var focusedIndex = this.focusLastElement();
if (focusedIndex !== -1) {
this.setSelectedIndexOnAction(focusedIndex, false);
}
} else if (isForward && eventHasModifiers(['Shift']) && this.isCheckboxList) {
event.preventDefault();
var focusedIndex = this.focusFirstElement();
if (focusedIndex !== -1) {
this.setSelectedIndexOnAction(focusedIndex, false);
}
}
if (this.hasTypeahead) {
var handleKeydownOpts = {
event: event,
focusItemAtIndex: function focusItemAtIndex(index) {
_this.focusItemAtIndex(index);
},
focusedItemIndex: -1,
isTargetListItem: isRootListItem,
sortedIndexByFirstChar: this.sortedIndexByFirstChar,
isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
return _this.isIndexDisabled(index);
}
};
typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
}
return;
}
var currentIndex = this.adapter.getFocusedElementIndex();
if (currentIndex === -1) {
currentIndex = listItemIndex;
if (currentIndex < 0) {
// If this event doesn't have a mdc-list-item ancestor from the
// current list (not from a sublist), return early.
return;
}
}
if (isForward && eventHasModifiers([])) {
events_1.preventDefaultEvent(event);
this.focusNextElement(currentIndex);
} else if (isBack && eventHasModifiers([])) {
events_1.preventDefaultEvent(event);
this.focusPrevElement(currentIndex);
} else if (isForward && eventHasModifiers(['Shift']) && this.isCheckboxList) {
events_1.preventDefaultEvent(event);
var focusedIndex = this.focusNextElement(currentIndex);
if (focusedIndex !== -1) {
this.setSelectedIndexOnAction(focusedIndex, false);
}
} else if (isBack && eventHasModifiers(['Shift']) && this.isCheckboxList) {
events_1.preventDefaultEvent(event);
var focusedIndex = this.focusPrevElement(currentIndex);
if (focusedIndex !== -1) {
this.setSelectedIndexOnAction(focusedIndex, false);
}
} else if (isHome && eventHasModifiers([])) {
events_1.preventDefaultEvent(event);
this.focusFirstElement();
} else if (isEnd && eventHasModifiers([])) {
events_1.preventDefaultEvent(event);
this.focusLastElement();
} else if (isHome && eventHasModifiers(['Control', 'Shift']) && this.isCheckboxList) {
events_1.preventDefaultEvent(event);
if (this.isIndexDisabled(currentIndex)) {
return;
}
this.focusFirstElement();
this.toggleCheckboxRange(0, currentIndex, currentIndex);
} else if (isEnd && eventHasModifiers(['Control', 'Shift']) && this.isCheckboxList) {
events_1.preventDefaultEvent(event);
if (this.isIndexDisabled(currentIndex)) {
return;
}
this.focusLastElement();
this.toggleCheckboxRange(currentIndex, this.adapter.getListItemCount() - 1, currentIndex);
} else if (isLetterA && eventHasModifiers(['Control']) && this.isCheckboxList) {
event.preventDefault();
this.checkboxListToggleAll(this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex, true);
} else if ((isEnter || isSpace) && eventHasModifiers([])) {
if (isRootListItem) {
// Return early if enter key is pressed on anchor element which triggers
// synthetic MouseEvent event.
var target = event.target;
if (target && target.tagName === 'A' && isEnter) {
return;
}
events_1.preventDefaultEvent(event);
if (this.isIndexDisabled(currentIndex)) {
return;
}
if (!this.isTypeaheadInProgress()) {
if (this.isSelectableList()) {
this.setSelectedIndexOnAction(currentIndex, false);
}
this.adapter.notifyAction(currentIndex);
}
}
} else if ((isEnter || isSpace) && eventHasModifiers(['Shift']) && this.isCheckboxList) {
// Return early if enter key is pressed on anchor element which triggers
// synthetic MouseEvent event.
var target = event.target;
if (target && target.tagName === 'A' && isEnter) {
return;
}
events_1.preventDefaultEvent(event);
if (this.isIndexDisabled(currentIndex)) {
return;
}
if (!this.isTypeaheadInProgress()) {
this.toggleCheckboxRange((_a = this.lastSelectedIndex) !== null && _a !== void 0 ? _a : currentIndex, currentIndex, currentIndex);
this.adapter.notifyAction(currentIndex);
}
}
if (this.hasTypeahead) {
var handleKeydownOpts = {
event: event,
focusItemAtIndex: function focusItemAtIndex(index) {
_this.focusItemAtIndex(index);
},
focusedItemIndex: this.focusedItemIndex,
isTargetListItem: isRootListItem,
sortedIndexByFirstChar: this.sortedIndexByFirstChar,
isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
return _this.isIndexDisabled(index);
}
};
typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
}
};
/**
* Click handler for the list.
*
* @param index Index for the item that has been clicked.
* @param isCheckboxAlreadyUpdatedInAdapter Whether the checkbox for
* the list item has already been updated in the adapter. This attribute
* should be set to `true` when e.g. the click event directly landed on
* the underlying native checkbox element which would cause the checked
* state to be already toggled within `adapter.isCheckboxCheckedAtIndex`.
*/
MDCListFoundation.prototype.handleClick = function (index, isCheckboxAlreadyUpdatedInAdapter, event) {
var _a;
var eventHasModifiers = createModifierChecker(event);
if (index === constants_1.numbers.UNSET_INDEX) {
return;
}
if (this.isIndexDisabled(index)) {
return;
}
if (eventHasModifiers([])) {
if (this.isSelectableList()) {
this.setSelectedIndexOnAction(index, isCheckboxAlreadyUpdatedInAdapter);
}
this.adapter.notifyAction(index);
} else if (this.isCheckboxList && eventHasModifiers(['Shift'])) {
this.toggleCheckboxRange((_a = this.lastSelectedIndex) !== null && _a !== void 0 ? _a : index, index, index);
this.adapter.notifyAction(index);
}
};
/**
* Focuses the next element on the list.
*/
MDCListFoundation.prototype.focusNextElement = function (index) {
var count = this.adapter.getListItemCount();
var nextIndex = index;
var firstChecked = null;
do {
nextIndex++;
if (nextIndex >= count) {
if (this.wrapFocus) {
nextIndex = 0;
} else {
// Return early because last item is already focused.
return index;
}
}
if (nextIndex === firstChecked) {
return -1;
}
firstChecked = firstChecked !== null && firstChecked !== void 0 ? firstChecked : nextIndex;
} while (!this.areDisabledItemsFocusable && this.isIndexDisabled(nextIndex));
this.focusItemAtIndex(nextIndex);
return nextIndex;
};
/**
* Focuses the previous element on the list.
*/
MDCListFoundation.prototype.focusPrevElement = function (index) {
var count = this.adapter.getListItemCount();
var prevIndex = index;
var firstChecked = null;
do {
prevIndex--;
if (prevIndex < 0) {
if (this.wrapFocus) {
prevIndex = count - 1;
} else {
// Return early because first item is already focused.
return index;
}
}
if (prevIndex === firstChecked) {
return -1;
}
firstChecked = firstChecked !== null && firstChecked !== void 0 ? firstChecked : prevIndex;
} while (!this.areDisabledItemsFocusable && this.isIndexDisabled(prevIndex));
this.focusItemAtIndex(prevIndex);
return prevIndex;
};
MDCListFoundation.prototype.focusFirstElement = function () {
// Pass -1 to `focusNextElement`, since it will incremement to 0 and focus
// the first element.
return this.focusNextElement(-1);
};
MDCListFoundation.prototype.focusLastElement = function () {
// Pass the length of the list to `focusNextElement` since it will decrement
// to length - 1 and focus the last element.
return this.focusPrevElement(this.adapter.getListItemCount());
};
MDCListFoundation.prototype.focusInitialElement = function () {
var initialIndex = this.getFirstSelectedOrFocusedItemIndex();
this.focusItemAtIndex(initialIndex);
return initialIndex;
};
/**
* @param itemIndex Index of the list item
* @param isEnabled Sets the list item to enabled or disabled.
*/
MDCListFoundation.prototype.setEnabled = function (itemIndex, isEnabled) {
if (!this.isIndexValid(itemIndex, false)) {
return;
}
if (isEnabled) {
this.adapter.removeClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'false');
} else {
this.adapter.addClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'true');
}
};
MDCListFoundation.prototype.setSingleSelectionAtIndex = function (index, options) {
if (options === void 0) {
options = {};
}
if (this.selectedIndex === index && !options.forceUpdate) {
return;
}
var selectedClassName = constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS;
if (this.useActivatedClass) {
selectedClassName = constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS;
}
if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
this.adapter.removeClassForElementIndex(this.selectedIndex, selectedClassName);
}
this.setAriaForSingleSelectionAtIndex(index);
this.setTabindexAtIndex(index);
if (index !== constants_1.numbers.UNSET_INDEX) {
this.adapter.addClassForElementIndex(index, selectedClassName);
}
this.selectedIndex = index;
// If the selected value has changed through user interaction,
// we want to notify the selection change to the adapter.
if (options.isUserInteraction && !options.forceUpdate) {
this.adapter.notifySelectionChange([index]);
}
};
/**
* Sets aria attribute for single selection at given index.
*/
MDCListFoundation.prototype.setAriaForSingleSelectionAtIndex = function (index) {
// Detect the presence of aria-current and get the value only during list
// initialization when it is in unset state.
if (this.selectedIndex === constants_1.numbers.UNSET_INDEX) {
this.ariaCurrentAttrValue = this.adapter.getAttributeForElementIndex(index, constants_1.strings.ARIA_CURRENT);
}
var isAriaCurrent = this.ariaCurrentAttrValue !== null;
var ariaAttribute = isAriaCurrent ? constants_1.strings.ARIA_CURRENT : constants_1.strings.ARIA_SELECTED;
if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
this.adapter.setAttributeForElementIndex(this.selectedIndex, ariaAttribute, 'false');
}
if (index !== constants_1.numbers.UNSET_INDEX) {
var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue : 'true';
this.adapter.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
}
};
/**
* Returns the attribute to use for indicating selection status.
*/
MDCListFoundation.prototype.getSelectionAttribute = function () {
return this.useSelectedAttr ? constants_1.strings.ARIA_SELECTED : constants_1.strings.ARIA_CHECKED;
};
/**
* Toggles radio at give index. Radio doesn't change the checked state if it
* is already checked.
*/
MDCListFoundation.prototype.setRadioAtIndex = function (index, options) {
if (options === void 0) {
options = {};
}
var selectionAttribute = this.getSelectionAttribute();
this.adapter.setCheckedCheckboxOrRadioAtIndex(index, true);
if (this.selectedIndex === index && !options.forceUpdate) {
return;
}
if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
this.adapter.setAttributeForElementIndex(this.selectedIndex, selectionAttribute, 'false');
}
this.adapter.setAttributeForElementIndex(index, selectionAttribute, 'true');
this.selectedIndex = index;
// If the selected value has changed through user interaction,
// we want to notify the selection change to the adapter.
if (options.isUserInteraction && !options.forceUpdate) {
this.adapter.notifySelectionChange([index]);
}
};
MDCListFoundation.prototype.setCheckboxAtIndex = function (index, options) {
if (options === void 0) {
options = {};
}
var currentIndex = this.selectedIndex;
// If this update is not triggered by a user interaction, we do not
// need to know about the currently selected indices and can avoid
// constructing the `Set` for performance reasons.
var currentlySelected = options.isUserInteraction ? new Set(currentIndex === constants_1.numbers.UNSET_INDEX ? [] : currentIndex) : null;
var selectionAttribute = this.getSelectionAttribute();
var changedIndices = [];
for (var i = 0; i < this.adapter.getListItemCount(); i++) {
var previousIsChecked = currentlySelected === null || currentlySelected === void 0 ? void 0 : currentlySelected.has(i);
var newIsChecked = index.indexOf(i) >= 0;
// If the selection has changed for this item, we keep track of it
// so that we can notify the adapter.
if (newIsChecked !== previousIsChecked) {
changedIndices.push(i);
}
this.adapter.setCheckedCheckboxOrRadioAtIndex(i, newIsChecked);
this.adapter.setAttributeForElementIndex(i, selectionAttribute, newIsChecked ? 'true' : 'false');
}
this.selectedIndex = index;
// If the selected value has changed through user interaction,
// we want to notify the selection change to the adapter.
if (options.isUserInteraction && changedIndices.length) {
this.adapter.notifySelectionChange(changedIndices);
}
};
/**
* Toggles the state of all checkboxes in the given range (inclusive) based on
* the state of the checkbox at the `toggleIndex`. To determine whether to set
* the given range to checked or unchecked, read the value of the checkbox at
* the `toggleIndex` and negate it. Then apply that new checked state to all
* checkboxes in the range.
* @param fromIndex The start of the range of checkboxes to toggle
* @param toIndex The end of the range of checkboxes to toggle
* @param toggleIndex The index that will be used to determine the new state
* of the given checkbox range.
*/
MDCListFoundation.prototype.toggleCheckboxRange = function (fromIndex, toIndex, toggleIndex) {
this.lastSelectedIndex = toggleIndex;
var currentlySelected = new Set(this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex);
var newIsChecked = !(currentlySelected === null || currentlySelected === void 0 ? void 0 : currentlySelected.has(toggleIndex));
var _a = __read([fromIndex, toIndex].sort(), 2),
startIndex = _a[0],
endIndex = _a[1];
var selectionAttribute = this.getSelectionAttribute();
var changedIndices = [];
for (var i = startIndex; i <= endIndex; i++) {
if (this.isIndexDisabled(i)) {
continue;
}
var previousIsChecked = currentlySelected.has(i);
// If the selection has changed for this item, we keep track of it
// so that we can notify the adapter.
if (newIsChecked !== previousIsChecked) {
changedIndices.push(i);
this.adapter.setCheckedCheckboxOrRadioAtIndex(i, newIsChecked);
this.adapter.setAttributeForElementIndex(i, selectionAttribute, "" + newIsChecked);
if (newIsChecked) {
currentlySelected.add(i);
} else {
currentlySelected.delete(i);
}
}
}
// If the selected value has changed, update and notify the selection change
// to the adapter.
if (changedIndices.length) {
this.selectedIndex = __spreadArray([], __read(currentlySelected));
this.adapter.notifySelectionChange(changedIndices);
}
};
MDCListFoundation.prototype.setTabindexAtIndex = function (index) {
if (this.focusedItemIndex === constants_1.numbers.UNSET_INDEX && index !== 0) {
// If some list item was selected set first list item's tabindex to -1.
// Generally, tabindex is set to 0 on first list item of list that has no
// preselected items.
this.adapter.setAttributeForElementIndex(0, 'tabindex', '-1');
} else if (this.focusedItemIndex >= 0 && this.focusedItemIndex !== index) {
this.adapter.setAttributeForElementIndex(this.focusedItemIndex, 'tabindex', '-1');
}
// Set the previous selection's tabindex to -1. We need this because
// in selection menus that are not visible, programmatically setting an
// option will not change focus but will change where tabindex should be 0.
if (!(this.selectedIndex instanceof Array) && this.selectedIndex !== index) {
this.adapter.setAttributeForElementIndex(this.selectedIndex, 'tabindex', '-1');
}
if (index !== constants_1.numbers.UNSET_INDEX) {
this.adapter.setAttributeForElementIndex(index, 'tabindex', '0');
}
};
/**
* @return Return true if it is single selectin list, checkbox list or radio
* list.
*/
MDCListFoundation.prototype.isSelectableList = function () {
return this.isSingleSelectionList || this.isCheckboxList || this.isRadioList;
};
MDCListFoundation.prototype.setTabindexToFirstSelectedOrFocusedItem = function () {
var targetIndex = this.getFirstSelectedOrFocusedItemIndex();
this.setTabindexAtIndex(targetIndex);
};
MDCListFoundation.prototype.getFirstSelectedOrFocusedItemIndex = function () {
// Action lists retain focus on the most recently focused item.
if (!this.isSelectableList()) {
return Math.max(this.focusedItemIndex, 0);
}
// Single-selection lists focus the selected item.
if (typeof this.selectedIndex === 'number' && this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
return this.selectedIndex;
}
// Multiple-selection lists focus the first selected item.
if (isNumberArray(this.selectedIndex) && this.selectedIndex.length > 0) {
return this.selectedIndex.reduce(function (minIndex, currentIndex) {
return Math.min(minIndex, currentIndex);
});
}
// Selection lists without a selection focus the first item.
return 0;
};
MDCListFoundation.prototype.isIndexValid = function (index, validateListType) {
var _this = this;
if (validateListType === void 0) {
validateListType = true;
}
if (index instanceof Array) {
if (!this.isCheckboxList && validateListType) {
throw new Error('MDCListFoundation: Array of index is only supported for checkbox based list');
}
if (index.length === 0) {
return true;
} else {
return index.some(function (i) {
return _this.isIndexInRange(i);
});
}
} else if (typeof index === 'number') {
if (this.isCheckboxList && validateListType) {
throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: " + index);
}
return this.isIndexInRange(index) || this.isSingleSelectionList && index === constants_1.numbers.UNSET_INDEX;
} else {
return false;
}
};
MDCListFoundation.prototype.isIndexInRange = function (index) {
var listSize = this.adapter.getListItemCount();
return index >= 0 && index < listSize;
};
/**
* Sets selected index on user action, toggles checkboxes in checkbox lists
* by default, unless `isCheckboxAlreadyUpdatedInAdapter` is set to `true`.
*
* In cases where `isCheckboxAlreadyUpdatedInAdapter` is set to `true`, the
* UI is just updated to reflect the value returned by the adapter.
*
* When calling this, make sure user interaction does not toggle disabled
* list items.
*/
MDCListFoundation.prototype.setSelectedIndexOnAction = function (index, isCheckboxAlreadyUpdatedInAdapter) {
this.lastSelectedIndex = index;
if (this.isCheckboxList) {
this.toggleCheckboxAtIndex(index, isCheckboxAlreadyUpdatedInAdapter);
this.adapter.notifySelectionChange([index]);
} else {
this.setSelectedIndex(index, { isUserInteraction: true });
}
};
MDCListFoundation.prototype.toggleCheckboxAtIndex = function (index, isCheckboxAlreadyUpdatedInAdapter) {
var selectionAttribute = this.getSelectionAttribute();
var adapterIsChecked = this.adapter.isCheckboxCheckedAtIndex(index);
// By default the checked value from the adapter is toggled unless the
// checked state in the adapter has already been updated beforehand.
// This can be happen when the underlying native checkbox has already
// been updated through the native click event.
var newCheckedValue;
if (isCheckboxAlreadyUpdatedInAdapter) {
newCheckedValue = adapterIsChecked;
} else {
newCheckedValue = !adapterIsChecked;
this.adapter.setCheckedCheckboxOrRadioAtIndex(index, newCheckedValue);
}
this.adapter.setAttributeForElementIndex(index, selectionAttribute, newCheckedValue ? 'true' : 'false');
// If none of the checkbox items are selected and selectedIndex is not
// initialized then provide a default value.
var selectedIndexes = this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex.slice();
if (newCheckedValue) {
selectedIndexes.push(index);
} else {
selectedIndexes = selectedIndexes.filter(function (i) {
return i !== index;
});
}
this.selectedIndex = selectedIndexes;
};
MDCListFoundation.prototype.focusItemAtIndex = function (index) {
this.adapter.focusItemAtIndex(index);
this.focusedItemIndex = index;
};
MDCListFoundation.prototype.checkboxListToggleAll = function (currentlySelectedIndexes, isUserInteraction) {
var count = this.adapter.getListItemCount();
// If all items are selected, deselect everything.
if (currentlySelectedIndexes.length === count) {
this.setCheckboxAtIndex([], { isUserInteraction: isUserInteraction });
} else {
// Otherwise select all enabled options.
var allIndexes = [];
for (var i = 0; i < count; i++) {
if (!this.isIndexDisabled(i) || currentlySelectedIndexes.indexOf(i) > -1) {
allIndexes.push(i);
}
}
this.setCheckboxAtIndex(allIndexes, { isUserInteraction: isUserInteraction });
}
};
/**
* Given the next desired character from the user, adds it to the typeahead
* buffer. Then, attempts to find the next option matching the buffer. Wraps
* around if at the end of options.
*
* @param nextChar The next character to add to the prefix buffer.
* @param startingIndex The index from which to start matching. Only relevant
* when starting a new match sequence. To start a new match sequence,
* clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
* to clear after a set interval defined in list foundation. Defaults to
* the currently focused index.
* @return The index of the matched item, or -1 if no match.
*/
MDCListFoundation.prototype.typeaheadMatchItem = function (nextChar, startingIndex, skipFocus) {
var _this = this;
if (skipFocus === void 0) {
skipFocus = false;
}
var opts = {
focusItemAtIndex: function focusItemAtIndex(index) {
_this.focusItemAtIndex(index);
},
focusedItemIndex: startingIndex ? startingIndex : this.focusedItemIndex,
nextChar: nextChar,
sortedIndexByFirstChar: this.sortedIndexByFirstChar,
skipFocus: skipFocus,
isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
return _this.isIndexDisabled(index);
}
};
return typeahead.matchItem(opts, this.typeaheadState);
};
/**
* Initializes the MDCListTextAndIndex data structure by indexing the current
* list items by primary text.
*
* @return The primary texts of all the list items sorted by first character.
*/
MDCListFoundation.prototype.typeaheadInitSortedIndex = function () {
return typeahead.initSortedIndex(this.adapter.getListItemCount(), this.adapter.getPrimaryTextAtIndex);
};
/**
* Clears the typeahead buffer.
*/
MDCListFoundation.prototype.clearTypeaheadBuffer = function () {
typeahead.clearBuffer(this.typeaheadState);
};
return MDCListFoundation;
}(foundation_1.MDCFoundation);
exports.MDCListFoundation = MDCListFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCListFoundation;
/***/ }),
/***/ "./packages/mdc-list/index.ts":
/*!************************************!*\
!*** ./packages/mdc-list/index.ts ***!
\************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-list/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-list/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-list/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-list/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-list/typeahead.ts":
/*!****************************************!*\
!*** ./packages/mdc-list/typeahead.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleKeydown = exports.clearBuffer = exports.isTypingInProgress = exports.matchItem = exports.initSortedIndex = exports.initState = void 0;
var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
/**
* Initializes a state object for typeahead. Use the same reference for calls to
* typeahead functions.
*
* @return The current state of the typeahead process. Each state reference
* represents a typeahead instance as the reference is typically mutated
* in-place.
*/
function initState() {
var state = {
bufferClearTimeout: 0,
currentFirstChar: '',
sortedIndexCursor: 0,
typeaheadBuffer: ''
};
return state;
}
exports.initState = initState;
/**
* Initializes typeahead state by indexing the current list items by primary
* text into the sortedIndexByFirstChar data structure.
*
* @param listItemCount numer of items in the list
* @param getPrimaryTextByItemIndex function that returns the primary text at a
* given index
*
* @return Map that maps the first character of the primary text to the full
* list text and it's index
*/
function initSortedIndex(listItemCount, getPrimaryTextByItemIndex) {
var sortedIndexByFirstChar = new Map();
// Aggregate item text to index mapping
for (var i = 0; i < listItemCount; i++) {
var primaryText = getPrimaryTextByItemIndex(i).trim();
if (!primaryText) {
continue;
}
var firstChar = primaryText[0].toLowerCase();
if (!sortedIndexByFirstChar.has(firstChar)) {
sortedIndexByFirstChar.set(firstChar, []);
}
sortedIndexByFirstChar.get(firstChar).push({ text: primaryText.toLowerCase(), index: i });
}
// Sort the mapping
// TODO(b/157162694): Investigate replacing forEach with Map.values()
sortedIndexByFirstChar.forEach(function (values) {
values.sort(function (first, second) {
return first.index - second.index;
});
});
return sortedIndexByFirstChar;
}
exports.initSortedIndex = initSortedIndex;
/**
* Given the next desired character from the user, it attempts to find the next
* list option matching the buffer. Wraps around if at the end of options.
*
* @param opts Options and accessors
* - nextChar - the next character to match against items
* - sortedIndexByFirstChar - output of `initSortedIndex(...)`
* - focusedItemIndex - the index of the currently focused item
* - focusItemAtIndex - function that focuses a list item at given index
* - skipFocus - whether or not to focus the matched item
* - isItemAtIndexDisabled - function that determines whether an item at a
* given index is disabled
* @param state The typeahead state instance. See `initState`.
*
* @return The index of the matched item, or -1 if no match.
*/
function matchItem(opts, state) {
var nextChar = opts.nextChar,
focusItemAtIndex = opts.focusItemAtIndex,
sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
focusedItemIndex = opts.focusedItemIndex,
skipFocus = opts.skipFocus,
isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
clearTimeout(state.bufferClearTimeout);
state.bufferClearTimeout = setTimeout(function () {
clearBuffer(state);
}, constants_1.numbers.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS);
state.typeaheadBuffer = state.typeaheadBuffer + nextChar;
var index;
if (state.typeaheadBuffer.length === 1) {
index = matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state);
} else {
index = matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state);
}
if (index !== -1 && !skipFocus) {
focusItemAtIndex(index);
}
return index;
}
exports.matchItem = matchItem;
/**
* Matches the user's single input character in the buffer to the
* next option that begins with such character. Wraps around if at
* end of options. Returns -1 if no match is found.
*/
function matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state) {
var firstChar = state.typeaheadBuffer[0];
var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
if (!itemsMatchingFirstChar) {
return -1;
}
// Has the same firstChar been recently matched?
// Also, did starting index remain the same between key presses?
// If both hold true, simply increment index.
if (firstChar === state.currentFirstChar && itemsMatchingFirstChar[state.sortedIndexCursor].index === focusedItemIndex) {
state.sortedIndexCursor = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
var newIndex = itemsMatchingFirstChar[state.sortedIndexCursor].index;
if (!isItemAtIndexDisabled(newIndex)) {
return newIndex;
}
}
// If we're here, it means one of the following happened:
// - either firstChar or startingIndex has changed, invalidating the
// cursor.
// - The next item of typeahead is disabled, so we have to look further.
state.currentFirstChar = firstChar;
var newCursorPosition = -1;
var cursorPosition;
// Find the first non-disabled item as a fallback.
for (cursorPosition = 0; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
if (!isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
newCursorPosition = cursorPosition;
break;
}
}
// Advance cursor to first item matching the firstChar that is positioned
// after starting item. Cursor is unchanged from fallback if there's no
// such item.
for (; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
if (itemsMatchingFirstChar[cursorPosition].index > focusedItemIndex && !isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
newCursorPosition = cursorPosition;
break;
}
}
if (newCursorPosition !== -1) {
state.sortedIndexCursor = newCursorPosition;
return itemsMatchingFirstChar[state.sortedIndexCursor].index;
}
return -1;
}
/**
* Attempts to find the next item that matches all of the typeahead buffer.
* Wraps around if at end of options. Returns -1 if no match is found.
*/
function matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state) {
var firstChar = state.typeaheadBuffer[0];
var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
if (!itemsMatchingFirstChar) {
return -1;
}
// Do nothing if text already matches
var startingItem = itemsMatchingFirstChar[state.sortedIndexCursor];
if (startingItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0 && !isItemAtIndexDisabled(startingItem.index)) {
return startingItem.index;
}
// Find next item that matches completely; if no match, we'll eventually
// loop around to same position
var cursorPosition = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
var nextCursorPosition = -1;
while (cursorPosition !== state.sortedIndexCursor) {
var currentItem = itemsMatchingFirstChar[cursorPosition];
var matches = currentItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0;
var isEnabled = !isItemAtIndexDisabled(currentItem.index);
if (matches && isEnabled) {
nextCursorPosition = cursorPosition;
break;
}
cursorPosition = (cursorPosition + 1) % itemsMatchingFirstChar.length;
}
if (nextCursorPosition !== -1) {
state.sortedIndexCursor = nextCursorPosition;
return itemsMatchingFirstChar[state.sortedIndexCursor].index;
}
return -1;
}
/**
* Whether or not the given typeahead instaance state is currently typing.
*
* @param state The typeahead state instance. See `initState`.
*/
function isTypingInProgress(state) {
return state.typeaheadBuffer.length > 0;
}
exports.isTypingInProgress = isTypingInProgress;
/**
* Clears the typeahaed buffer so that it resets item matching to the first
* character.
*
* @param state The typeahead state instance. See `initState`.
*/
function clearBuffer(state) {
state.typeaheadBuffer = '';
}
exports.clearBuffer = clearBuffer;
/**
* Given a keydown event, it calculates whether or not to automatically focus a
* list item depending on what was typed mimicing the typeahead functionality of
* a standard <select> element that is open.
*
* @param opts Options and accessors
* - event - the KeyboardEvent to handle and parse
* - sortedIndexByFirstChar - output of `initSortedIndex(...)`
* - focusedItemIndex - the index of the currently focused item
* - focusItemAtIndex - function that focuses a list item at given index
* - isItemAtFocusedIndexDisabled - whether or not the currently focused item
* is disabled
* - isTargetListItem - whether or not the event target is a list item
* @param state The typeahead state instance. See `initState`.
*
* @returns index of the item matched by the keydown. -1 if not matched.
*/
function handleKeydown(opts, state) {
var event = opts.event,
isTargetListItem = opts.isTargetListItem,
focusedItemIndex = opts.focusedItemIndex,
focusItemAtIndex = opts.focusItemAtIndex,
sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
var isHome = keyboard_1.normalizeKey(event) === 'Home';
var isEnd = keyboard_1.normalizeKey(event) === 'End';
var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
if (event.altKey || event.ctrlKey || event.metaKey || isArrowLeft || isArrowUp || isArrowRight || isArrowDown || isHome || isEnd || isEnter) {
return -1;
}
var isCharacterKey = !isSpace && event.key.length === 1;
if (isCharacterKey) {
events_1.preventDefaultEvent(event);
var matchItemOpts = {
focusItemAtIndex: focusItemAtIndex,
focusedItemIndex: focusedItemIndex,
nextChar: event.key.toLowerCase(),
sortedIndexByFirstChar: sortedIndexByFirstChar,
skipFocus: false,
isItemAtIndexDisabled: isItemAtIndexDisabled
};
return matchItem(matchItemOpts, state);
}
if (!isSpace) {
return -1;
}
if (isTargetListItem) {
events_1.preventDefaultEvent(event);
}
var typeaheadOnListItem = isTargetListItem && isTypingInProgress(state);
if (typeaheadOnListItem) {
var matchItemOpts = {
focusItemAtIndex: focusItemAtIndex,
focusedItemIndex: focusedItemIndex,
nextChar: ' ',
sortedIndexByFirstChar: sortedIndexByFirstChar,
skipFocus: false,
isItemAtIndexDisabled: isItemAtIndexDisabled
};
// space participates in typeahead matching if in rapid typing mode
return matchItem(matchItemOpts, state);
}
return -1;
}
exports.handleKeydown = handleKeydown;
/***/ }),
/***/ "./packages/mdc-list/types.ts":
/*!************************************!*\
!*** ./packages/mdc-list/types.ts ***!
\************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-menu-surface/adapter.ts":
/*!**********************************************!*\
!*** ./packages/mdc-menu-surface/adapter.ts ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-menu-surface/component.ts":
/*!************************************************!*\
!*** ./packages/mdc-menu-surface/component.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCMenuSurface = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu-surface/foundation.ts");
var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
var MDCMenuSurface = /** @class */function (_super) {
__extends(MDCMenuSurface, _super);
function MDCMenuSurface() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCMenuSurface.attachTo = function (root) {
return new MDCMenuSurface(root);
};
MDCMenuSurface.prototype.initialSyncWithDOM = function () {
var _this = this;
var parentEl = this.root.parentElement;
this.anchorElement = parentEl && parentEl.classList.contains(constants_1.cssClasses.ANCHOR) ? parentEl : null;
if (this.root.classList.contains(constants_1.cssClasses.FIXED)) {
this.setFixedPosition(true);
}
this.handleKeydown = function (event) {
_this.foundation.handleKeydown(event);
};
this.handleBodyClick = function (event) {
_this.foundation.handleBodyClick(event);
};
// capture so that no race between handleBodyClick and quickOpen when
// menusurface opened on button click which registers this listener
this.registerBodyClickListener = function () {
document.body.addEventListener('click', _this.handleBodyClick, { capture: true });
};
this.deregisterBodyClickListener = function () {
document.body.removeEventListener('click', _this.handleBodyClick, { capture: true });
};
this.listen('keydown', this.handleKeydown);
this.listen(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
this.listen(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
};
MDCMenuSurface.prototype.destroy = function () {
this.unlisten('keydown', this.handleKeydown);
this.unlisten(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
this.unlisten(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
_super.prototype.destroy.call(this);
};
MDCMenuSurface.prototype.isOpen = function () {
return this.foundation.isOpen();
};
MDCMenuSurface.prototype.open = function () {
this.foundation.open();
};
MDCMenuSurface.prototype.close = function (skipRestoreFocus) {
if (skipRestoreFocus === void 0) {
skipRestoreFocus = false;
}
this.foundation.close(skipRestoreFocus);
};
Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", {
set: function set(quickOpen) {
this.foundation.setQuickOpen(quickOpen);
},
enumerable: false,
configurable: true
});
/** Sets the foundation to use page offsets for an positioning when the menu is hoisted to the body. */
MDCMenuSurface.prototype.setIsHoisted = function (isHoisted) {
this.foundation.setIsHoisted(isHoisted);
};
/** Sets the element that the menu-surface is anchored to. */
MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function (element) {
this.anchorElement = element;
};
/** Sets the menu-surface to position: fixed. */
MDCMenuSurface.prototype.setFixedPosition = function (isFixed) {
if (isFixed) {
this.root.classList.add(constants_1.cssClasses.FIXED);
} else {
this.root.classList.remove(constants_1.cssClasses.FIXED);
}
this.foundation.setFixedPosition(isFixed);
};
/** Sets the absolute x/y position to position based on. Requires the menu to be hoisted. */
MDCMenuSurface.prototype.setAbsolutePosition = function (x, y) {
this.foundation.setAbsolutePosition(x, y);
this.setIsHoisted(true);
};
/**
* @param corner Default anchor corner alignment of top-left surface corner.
*/
MDCMenuSurface.prototype.setAnchorCorner = function (corner) {
this.foundation.setAnchorCorner(corner);
};
MDCMenuSurface.prototype.setAnchorMargin = function (margin) {
this.foundation.setAnchorMargin(margin);
};
MDCMenuSurface.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
hasAnchor: function hasAnchor() {
return !!_this.anchorElement;
},
notifyClose: function notifyClose() {
return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {});
},
notifyClosing: function notifyClosing() {
_this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSING_EVENT, {});
},
notifyOpen: function notifyOpen() {
return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {});
},
notifyOpening: function notifyOpening() {
return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENING_EVENT, {});
},
isElementInContainer: function isElementInContainer(el) {
return _this.root.contains(el);
},
isRtl: function isRtl() {
return getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
},
setTransformOrigin: function setTransformOrigin(origin) {
var propertyName = util_1.getCorrectPropertyName(window, 'transform') + "-origin";
_this.root.style.setProperty(propertyName, origin);
},
isFocused: function isFocused() {
return document.activeElement === _this.root;
},
saveFocus: function saveFocus() {
_this.previousFocus = document.activeElement;
},
restoreFocus: function restoreFocus() {
if (_this.root.contains(document.activeElement)) {
if (_this.previousFocus && _this.previousFocus.focus) {
_this.previousFocus.focus();
}
}
},
getInnerDimensions: function getInnerDimensions() {
return {
width: _this.root.offsetWidth,
height: _this.root.offsetHeight
};
},
getAnchorDimensions: function getAnchorDimensions() {
return _this.anchorElement ? _this.anchorElement.getBoundingClientRect() : null;
},
getWindowDimensions: function getWindowDimensions() {
return { width: window.innerWidth, height: window.innerHeight };
},
getBodyDimensions: function getBodyDimensions() {
return { width: document.body.clientWidth, height: document.body.clientHeight };
},
getWindowScroll: function getWindowScroll() {
return { x: window.pageXOffset, y: window.pageYOffset };
},
setPosition: function setPosition(position) {
var rootHTML = _this.root;
rootHTML.style.left = 'left' in position ? position.left + "px" : '';
rootHTML.style.right = 'right' in position ? position.right + "px" : '';
rootHTML.style.top = 'top' in position ? position.top + "px" : '';
rootHTML.style.bottom = 'bottom' in position ? position.bottom + "px" : '';
},
setMaxHeight: function setMaxHeight(height) {
_this.root.style.maxHeight = height;
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_1.MDCMenuSurfaceFoundation(adapter);
};
return MDCMenuSurface;
}(component_1.MDCComponent);
exports.MDCMenuSurface = MDCMenuSurface;
/***/ }),
/***/ "./packages/mdc-menu-surface/constants.ts":
/*!************************************************!*\
!*** ./packages/mdc-menu-surface/constants.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Corner = exports.CornerBit = exports.numbers = exports.strings = exports.cssClasses = void 0;
var cssClasses = {
ANCHOR: 'mdc-menu-surface--anchor',
ANIMATING_CLOSED: 'mdc-menu-surface--animating-closed',
ANIMATING_OPEN: 'mdc-menu-surface--animating-open',
FIXED: 'mdc-menu-surface--fixed',
IS_OPEN_BELOW: 'mdc-menu-surface--is-open-below',
OPEN: 'mdc-menu-surface--open',
ROOT: 'mdc-menu-surface'
};
exports.cssClasses = cssClasses;
// tslint:disable:object-literal-sort-keys
var strings = {
CLOSED_EVENT: 'MDCMenuSurface:closed',
CLOSING_EVENT: 'MDCMenuSurface:closing',
OPENED_EVENT: 'MDCMenuSurface:opened',
OPENING_EVENT: 'MDCMenuSurface:opening',
FOCUSABLE_ELEMENTS: ['button:not(:disabled)', '[href]:not([aria-disabled="true"])', 'input:not(:disabled)', 'select:not(:disabled)', 'textarea:not(:disabled)', '[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])'].join(', ')
};
exports.strings = strings;
// tslint:enable:object-literal-sort-keys
var numbers = {
/** Total duration of menu-surface open animation. */
TRANSITION_OPEN_DURATION: 120,
/** Total duration of menu-surface close animation. */
TRANSITION_CLOSE_DURATION: 75,
/**
* Margin left to the edge of the viewport when menu-surface is at maximum
* possible height. Also used as a viewport margin.
*/
MARGIN_TO_EDGE: 32,
/**
* Ratio of anchor width to menu-surface width for switching from corner
* positioning to center positioning.
*/
ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67,
/**
* Amount of time to wait before restoring focus when closing the menu
* surface. This is important because if a touch event triggered the menu
* close, and the subsequent mouse event occurs after focus is restored, then
* the restored focus would be lost.
*/
TOUCH_EVENT_WAIT_MS: 30
};
exports.numbers = numbers;
/**
* Enum for bits in the {@see Corner) bitmap.
*/
var CornerBit;
(function (CornerBit) {
CornerBit[CornerBit["BOTTOM"] = 1] = "BOTTOM";
CornerBit[CornerBit["CENTER"] = 2] = "CENTER";
CornerBit[CornerBit["RIGHT"] = 4] = "RIGHT";
CornerBit[CornerBit["FLIP_RTL"] = 8] = "FLIP_RTL";
})(CornerBit || (CornerBit = {}));
exports.CornerBit = CornerBit;
/**
* Enum for representing an element corner for positioning the menu-surface.
*
* The START constants map to LEFT if element directionality is left
* to right and RIGHT if the directionality is right to left.
* Likewise END maps to RIGHT or LEFT depending on the directionality.
*/
var Corner;
(function (Corner) {
Corner[Corner["TOP_LEFT"] = 0] = "TOP_LEFT";
Corner[Corner["TOP_RIGHT"] = 4] = "TOP_RIGHT";
Corner[Corner["BOTTOM_LEFT"] = 1] = "BOTTOM_LEFT";
Corner[Corner["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT";
Corner[Corner["TOP_START"] = 8] = "TOP_START";
Corner[Corner["TOP_END"] = 12] = "TOP_END";
Corner[Corner["BOTTOM_START"] = 9] = "BOTTOM_START";
Corner[Corner["BOTTOM_END"] = 13] = "BOTTOM_END";
})(Corner || (Corner = {}));
exports.Corner = Corner;
/***/ }),
/***/ "./packages/mdc-menu-surface/foundation.ts":
/*!*************************************************!*\
!*** ./packages/mdc-menu-surface/foundation.ts ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCMenuSurfaceFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts");
var MDCMenuSurfaceFoundation = /** @class */function (_super) {
__extends(MDCMenuSurfaceFoundation, _super);
function MDCMenuSurfaceFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCMenuSurfaceFoundation.defaultAdapter), adapter)) || this;
_this.isSurfaceOpen = false;
_this.isQuickOpen = false;
_this.isHoistedElement = false;
_this.isFixedPosition = false;
_this.isHorizontallyCenteredOnViewport = false;
_this.maxHeight = 0;
_this.openBottomBias = 0;
_this.openAnimationEndTimerId = 0;
_this.closeAnimationEndTimerId = 0;
_this.animationRequestId = 0;
_this.anchorCorner = constants_1.Corner.TOP_START;
/**
* Corner of the menu surface to which menu surface is attached to anchor.
*
* Anchor corner --->+----------+
* | ANCHOR |
* +----------+
* Origin corner --->+--------------+
* | |
* | |
* | MENU SURFACE |
* | |
* | |
* +--------------+
*/
_this.originCorner = constants_1.Corner.TOP_START;
_this.anchorMargin = { top: 0, right: 0, bottom: 0, left: 0 };
_this.position = { x: 0, y: 0 };
return _this;
}
Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenuSurfaceFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", {
get: function get() {
return constants_1.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", {
get: function get() {
return constants_1.Corner;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenuSurfaceFoundation, "defaultAdapter", {
/**
* @see {@link MDCMenuSurfaceAdapter} for typing information on parameters and return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
hasClass: function hasClass() {
return false;
},
hasAnchor: function hasAnchor() {
return false;
},
isElementInContainer: function isElementInContainer() {
return false;
},
isFocused: function isFocused() {
return false;
},
isRtl: function isRtl() {
return false;
},
getInnerDimensions: function getInnerDimensions() {
return { height: 0, width: 0 };
},
getAnchorDimensions: function getAnchorDimensions() {
return null;
},
getWindowDimensions: function getWindowDimensions() {
return { height: 0, width: 0 };
},
getBodyDimensions: function getBodyDimensions() {
return { height: 0, width: 0 };
},
getWindowScroll: function getWindowScroll() {
return { x: 0, y: 0 };
},
setPosition: function setPosition() {
return undefined;
},
setMaxHeight: function setMaxHeight() {
return undefined;
},
setTransformOrigin: function setTransformOrigin() {
return undefined;
},
saveFocus: function saveFocus() {
return undefined;
},
restoreFocus: function restoreFocus() {
return undefined;
},
notifyClose: function notifyClose() {
return undefined;
},
notifyClosing: function notifyClosing() {
return undefined;
},
notifyOpen: function notifyOpen() {
return undefined;
},
notifyOpening: function notifyOpening() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCMenuSurfaceFoundation.prototype.init = function () {
var _a = MDCMenuSurfaceFoundation.cssClasses,
ROOT = _a.ROOT,
OPEN = _a.OPEN;
if (!this.adapter.hasClass(ROOT)) {
throw new Error(ROOT + " class required in root element.");
}
if (this.adapter.hasClass(OPEN)) {
this.isSurfaceOpen = true;
}
};
MDCMenuSurfaceFoundation.prototype.destroy = function () {
clearTimeout(this.openAnimationEndTimerId);
clearTimeout(this.closeAnimationEndTimerId);
// Cancel any currently running animations.
cancelAnimationFrame(this.animationRequestId);
};
/**
* @param corner Default anchor corner alignment of top-left menu surface
* corner.
*/
MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) {
this.anchorCorner = corner;
};
/**
* Flip menu corner horizontally.
*/
MDCMenuSurfaceFoundation.prototype.flipCornerHorizontally = function () {
this.originCorner = this.originCorner ^ constants_1.CornerBit.RIGHT;
};
/**
* @param margin Set of margin values from anchor.
*/
MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function (margin) {
this.anchorMargin.top = margin.top || 0;
this.anchorMargin.right = margin.right || 0;
this.anchorMargin.bottom = margin.bottom || 0;
this.anchorMargin.left = margin.left || 0;
};
/** Used to indicate if the menu-surface is hoisted to the body. */
MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) {
this.isHoistedElement = isHoisted;
};
/**
* Used to set the menu-surface calculations based on a fixed position menu.
*/
MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) {
this.isFixedPosition = isFixedPosition;
};
/**
* @return Returns true if menu is in fixed (`position: fixed`) position.
*/
MDCMenuSurfaceFoundation.prototype.isFixed = function () {
return this.isFixedPosition;
};
/** Sets the menu-surface position on the page. */
MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function (x, y) {
this.position.x = this.isFinite(x) ? x : 0;
this.position.y = this.isFinite(y) ? y : 0;
};
/** Sets whether menu-surface should be horizontally centered to viewport. */
MDCMenuSurfaceFoundation.prototype.setIsHorizontallyCenteredOnViewport = function (isCentered) {
this.isHorizontallyCenteredOnViewport = isCentered;
};
MDCMenuSurfaceFoundation.prototype.setQuickOpen = function (quickOpen) {
this.isQuickOpen = quickOpen;
};
/**
* Sets maximum menu-surface height on open.
* @param maxHeight The desired max-height. Set to 0 (default) to
* automatically calculate max height based on available viewport space.
*/
MDCMenuSurfaceFoundation.prototype.setMaxHeight = function (maxHeight) {
this.maxHeight = maxHeight;
};
/**
* Set to a positive integer to influence the menu to preferentially open
* below the anchor instead of above.
* @param bias A value of `x` simulates an extra `x` pixels of available space
* below the menu during positioning calculations.
*/
MDCMenuSurfaceFoundation.prototype.setOpenBottomBias = function (bias) {
this.openBottomBias = bias;
};
MDCMenuSurfaceFoundation.prototype.isOpen = function () {
return this.isSurfaceOpen;
};
/**
* Open the menu surface.
*/
MDCMenuSurfaceFoundation.prototype.open = function () {
var _this = this;
if (this.isSurfaceOpen) {
return;
}
this.adapter.notifyOpening();
this.adapter.saveFocus();
if (this.isQuickOpen) {
this.isSurfaceOpen = true;
this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
this.dimensions = this.adapter.getInnerDimensions();
this.autoposition();
this.adapter.notifyOpen();
} else {
this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
this.animationRequestId = requestAnimationFrame(function () {
_this.dimensions = _this.adapter.getInnerDimensions();
_this.autoposition();
_this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
_this.openAnimationEndTimerId = setTimeout(function () {
_this.openAnimationEndTimerId = 0;
_this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
_this.adapter.notifyOpen();
}, constants_1.numbers.TRANSITION_OPEN_DURATION);
});
this.isSurfaceOpen = true;
}
};
/**
* Closes the menu surface.
*/
MDCMenuSurfaceFoundation.prototype.close = function (skipRestoreFocus) {
var _this = this;
if (skipRestoreFocus === void 0) {
skipRestoreFocus = false;
}
if (!this.isSurfaceOpen) {
return;
}
this.adapter.notifyClosing();
if (this.isQuickOpen) {
this.isSurfaceOpen = false;
if (!skipRestoreFocus) {
this.maybeRestoreFocus();
}
this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
this.adapter.notifyClose();
return;
}
this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
requestAnimationFrame(function () {
_this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
_this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
_this.closeAnimationEndTimerId = setTimeout(function () {
_this.closeAnimationEndTimerId = 0;
_this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
_this.adapter.notifyClose();
}, constants_1.numbers.TRANSITION_CLOSE_DURATION);
});
this.isSurfaceOpen = false;
if (!skipRestoreFocus) {
this.maybeRestoreFocus();
}
};
/** Handle clicks and close if not within menu-surface element. */
MDCMenuSurfaceFoundation.prototype.handleBodyClick = function (evt) {
var el = evt.target;
if (this.adapter.isElementInContainer(el)) {
return;
}
this.close();
};
/** Handle keys that close the surface. */
MDCMenuSurfaceFoundation.prototype.handleKeydown = function (evt) {
var keyCode = evt.keyCode,
key = evt.key;
var isEscape = key === 'Escape' || keyCode === 27;
if (isEscape) {
this.close();
}
};
MDCMenuSurfaceFoundation.prototype.autoposition = function () {
var _a;
// Compute measurements for autoposition methods reuse.
this.measurements = this.getAutoLayoutmeasurements();
var corner = this.getoriginCorner();
var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight(corner);
var verticalAlignment = this.hasBit(corner, constants_1.CornerBit.BOTTOM) ? 'bottom' : 'top';
var horizontalAlignment = this.hasBit(corner, constants_1.CornerBit.RIGHT) ? 'right' : 'left';
var horizontalOffset = this.getHorizontalOriginOffset(corner);
var verticalOffset = this.getVerticalOriginOffset(corner);
var _b = this.measurements,
anchorSize = _b.anchorSize,
surfaceSize = _b.surfaceSize;
var position = (_a = {}, _a[horizontalAlignment] = horizontalOffset, _a[verticalAlignment] = verticalOffset, _a);
// Center align when anchor width is comparable or greater than menu
// surface, otherwise keep corner.
if (anchorSize.width / surfaceSize.width > constants_1.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) {
horizontalAlignment = 'center';
}
// If the menu-surface has been hoisted to the body, it's no longer relative
// to the anchor element
if (this.isHoistedElement || this.isFixedPosition) {
this.adjustPositionForHoistedElement(position);
}
this.adapter.setTransformOrigin(horizontalAlignment + " " + verticalAlignment);
this.adapter.setPosition(position);
this.adapter.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + 'px' : '');
// If it is opened from the top then add is-open-below class
if (!this.hasBit(corner, constants_1.CornerBit.BOTTOM)) {
this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
}
};
/**
* @return Measurements used to position menu surface popup.
*/
MDCMenuSurfaceFoundation.prototype.getAutoLayoutmeasurements = function () {
var anchorRect = this.adapter.getAnchorDimensions();
var bodySize = this.adapter.getBodyDimensions();
var viewportSize = this.adapter.getWindowDimensions();
var windowScroll = this.adapter.getWindowScroll();
if (!anchorRect) {
// tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
anchorRect = {
top: this.position.y,
right: this.position.x,
bottom: this.position.y,
left: this.position.x,
width: 0,
height: 0
};
// tslint:enable:object-literal-sort-keys
}
return {
anchorSize: anchorRect,
bodySize: bodySize,
surfaceSize: this.dimensions,
viewportDistance: {
// tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
top: anchorRect.top,
right: viewportSize.width - anchorRect.right,
bottom: viewportSize.height - anchorRect.bottom,
left: anchorRect.left
},
viewportSize: viewportSize,
windowScroll: windowScroll
};
};
/**
* Computes the corner of the anchor from which to animate and position the
* menu surface.
*
* Only LEFT or RIGHT bit is used to position the menu surface ignoring RTL
* context. E.g., menu surface will be positioned from right side on TOP_END.
*/
MDCMenuSurfaceFoundation.prototype.getoriginCorner = function () {
var corner = this.originCorner;
var _a = this.measurements,
viewportDistance = _a.viewportDistance,
anchorSize = _a.anchorSize,
surfaceSize = _a.surfaceSize;
var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
var isAnchoredToBottom = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
var availableTop;
var availableBottom;
if (isAnchoredToBottom) {
availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.bottom;
availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE - this.anchorMargin.bottom;
} else {
availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.top;
availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE + anchorSize.height - this.anchorMargin.top;
}
var isAvailableBottom = availableBottom - surfaceSize.height > 0;
if (!isAvailableBottom && availableTop > availableBottom + this.openBottomBias) {
// Attach bottom side of surface to the anchor.
corner = this.setBit(corner, constants_1.CornerBit.BOTTOM);
}
var isRtl = this.adapter.isRtl();
var isFlipRtl = this.hasBit(this.anchorCorner, constants_1.CornerBit.FLIP_RTL);
var hasRightBit = this.hasBit(this.anchorCorner, constants_1.CornerBit.RIGHT) || this.hasBit(corner, constants_1.CornerBit.RIGHT);
// Whether surface attached to right side of anchor element.
var isAnchoredToRight = false;
// Anchored to start
if (isRtl && isFlipRtl) {
isAnchoredToRight = !hasRightBit;
} else {
// Anchored to right
isAnchoredToRight = hasRightBit;
}
var availableLeft;
var availableRight;
if (isAnchoredToRight) {
availableLeft = viewportDistance.left + anchorSize.width + this.anchorMargin.right;
availableRight = viewportDistance.right - this.anchorMargin.right;
} else {
availableLeft = viewportDistance.left + this.anchorMargin.left;
availableRight = viewportDistance.right + anchorSize.width - this.anchorMargin.left;
}
var isAvailableLeft = availableLeft - surfaceSize.width > 0;
var isAvailableRight = availableRight - surfaceSize.width > 0;
var isOriginCornerAlignedToEnd = this.hasBit(corner, constants_1.CornerBit.FLIP_RTL) && this.hasBit(corner, constants_1.CornerBit.RIGHT);
if (isAvailableRight && isOriginCornerAlignedToEnd && isRtl || !isAvailableLeft && isOriginCornerAlignedToEnd) {
// Attach left side of surface to the anchor.
corner = this.unsetBit(corner, constants_1.CornerBit.RIGHT);
} else if (isAvailableLeft && isAnchoredToRight && isRtl || isAvailableLeft && !isAnchoredToRight && hasRightBit || !isAvailableRight && availableLeft >= availableRight) {
// Attach right side of surface to the anchor.
corner = this.setBit(corner, constants_1.CornerBit.RIGHT);
}
return corner;
};
/**
* @param corner Origin corner of the menu surface.
* @return Maximum height of the menu surface, based on available space. 0
* indicates should not be set.
*/
MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight = function (corner) {
if (this.maxHeight > 0) {
return this.maxHeight;
}
var viewportDistance = this.measurements.viewportDistance;
var maxHeight = 0;
var isBottomAligned = this.hasBit(corner, constants_1.CornerBit.BOTTOM);
var isBottomAnchored = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
// When maximum height is not specified, it is handled from CSS.
if (isBottomAligned) {
maxHeight = viewportDistance.top + this.anchorMargin.top - MARGIN_TO_EDGE;
if (!isBottomAnchored) {
maxHeight += this.measurements.anchorSize.height;
}
} else {
maxHeight = viewportDistance.bottom - this.anchorMargin.bottom + this.measurements.anchorSize.height - MARGIN_TO_EDGE;
if (isBottomAnchored) {
maxHeight -= this.measurements.anchorSize.height;
}
}
return maxHeight;
};
/**
* @param corner Origin corner of the menu surface.
* @return Horizontal offset of menu surface origin corner from corresponding
* anchor corner.
*/
MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset = function (corner) {
var anchorSize = this.measurements.anchorSize;
// isRightAligned corresponds to using the 'right' property on the surface.
var isRightAligned = this.hasBit(corner, constants_1.CornerBit.RIGHT);
var avoidHorizontalOverlap = this.hasBit(this.anchorCorner, constants_1.CornerBit.RIGHT);
if (isRightAligned) {
var rightOffset = avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.left : this.anchorMargin.right;
// For hoisted or fixed elements, adjust the offset by the difference
// between viewport width and body width so when we calculate the right
// value (`adjustPositionForHoistedElement`) based on the element
// position, the right property is correct.
if (this.isHoistedElement || this.isFixedPosition) {
return rightOffset - (this.measurements.viewportSize.width - this.measurements.bodySize.width);
}
return rightOffset;
}
return avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.right : this.anchorMargin.left;
};
/**
* @param corner Origin corner of the menu surface.
* @return Vertical offset of menu surface origin corner from corresponding
* anchor corner.
*/
MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset = function (corner) {
var anchorSize = this.measurements.anchorSize;
var isBottomAligned = this.hasBit(corner, constants_1.CornerBit.BOTTOM);
var avoidVerticalOverlap = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
var y = 0;
if (isBottomAligned) {
y = avoidVerticalOverlap ? anchorSize.height - this.anchorMargin.top : -this.anchorMargin.bottom;
} else {
y = avoidVerticalOverlap ? anchorSize.height + this.anchorMargin.bottom : this.anchorMargin.top;
}
return y;
};
/**
* Calculates the offsets for positioning the menu-surface when the
* menu-surface has been hoisted to the body.
*/
MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement = function (position) {
var e_1, _a;
var _b = this.measurements,
windowScroll = _b.windowScroll,
viewportDistance = _b.viewportDistance,
surfaceSize = _b.surfaceSize,
viewportSize = _b.viewportSize;
var props = Object.keys(position);
try {
for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
var prop = props_1_1.value;
var value = position[prop] || 0;
if (this.isHorizontallyCenteredOnViewport && (prop === 'left' || prop === 'right')) {
position[prop] = (viewportSize.width - surfaceSize.width) / 2;
continue;
}
// Hoisted surfaces need to have the anchor elements location on the page
// added to the position properties for proper alignment on the body.
value += viewportDistance[prop];
// Surfaces that are absolutely positioned need to have additional
// calculations for scroll and bottom positioning.
if (!this.isFixedPosition) {
if (prop === 'top') {
value += windowScroll.y;
} else if (prop === 'bottom') {
value -= windowScroll.y;
} else if (prop === 'left') {
value += windowScroll.x;
} else {
// prop === 'right'
value -= windowScroll.x;
}
}
position[prop] = value;
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
} finally {
if (e_1) throw e_1.error;
}
}
};
/**
* The last focused element when the menu surface was opened should regain
* focus, if the user is focused on or within the menu surface when it is
* closed.
*/
MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus = function () {
var _this = this;
var isRootFocused = this.adapter.isFocused();
var ownerDocument = this.adapter.getOwnerDocument ? this.adapter.getOwnerDocument() : document;
var childHasFocus = ownerDocument.activeElement && this.adapter.isElementInContainer(ownerDocument.activeElement);
if (isRootFocused || childHasFocus) {
// Wait before restoring focus when closing the menu surface. This is
// important because if a touch event triggered the menu close, and the
// subsequent mouse event occurs after focus is restored, then the
// restored focus would be lost.
setTimeout(function () {
_this.adapter.restoreFocus();
}, constants_1.numbers.TOUCH_EVENT_WAIT_MS);
}
};
MDCMenuSurfaceFoundation.prototype.hasBit = function (corner, bit) {
return Boolean(corner & bit); // tslint:disable-line:no-bitwise
};
MDCMenuSurfaceFoundation.prototype.setBit = function (corner, bit) {
return corner | bit; // tslint:disable-line:no-bitwise
};
MDCMenuSurfaceFoundation.prototype.unsetBit = function (corner, bit) {
return corner ^ bit;
};
/**
* isFinite that doesn't force conversion to number type.
* Equivalent to Number.isFinite in ES2015, which is not supported in IE.
*/
MDCMenuSurfaceFoundation.prototype.isFinite = function (num) {
return typeof num === 'number' && isFinite(num);
};
return MDCMenuSurfaceFoundation;
}(foundation_1.MDCFoundation);
exports.MDCMenuSurfaceFoundation = MDCMenuSurfaceFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCMenuSurfaceFoundation;
/***/ }),
/***/ "./packages/mdc-menu-surface/index.ts":
/*!********************************************!*\
!*** ./packages/mdc-menu-surface/index.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-menu-surface/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-menu-surface/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-menu-surface/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-menu-surface/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-menu-surface/types.ts":
/*!********************************************!*\
!*** ./packages/mdc-menu-surface/types.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-menu/adapter.ts":
/*!**************************************!*\
!*** ./packages/mdc-menu/adapter.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-menu/component.ts":
/*!****************************************!*\
!*** ./packages/mdc-menu/component.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCMenu = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
var constants_1 = __webpack_require__(/*! @material/list/constants */ "./packages/mdc-list/constants.ts");
var foundation_1 = __webpack_require__(/*! @material/list/foundation */ "./packages/mdc-list/foundation.ts");
var component_3 = __webpack_require__(/*! @material/menu-surface/component */ "./packages/mdc-menu-surface/component.ts");
var foundation_2 = __webpack_require__(/*! @material/menu-surface/foundation */ "./packages/mdc-menu-surface/foundation.ts");
var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu/foundation.ts");
var MDCMenu = /** @class */function (_super) {
__extends(MDCMenu, _super);
function MDCMenu() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCMenu.attachTo = function (root) {
return new MDCMenu(root);
};
MDCMenu.prototype.initialize = function (menuSurfaceFactory, listFactory) {
if (menuSurfaceFactory === void 0) {
menuSurfaceFactory = function menuSurfaceFactory(el) {
return new component_3.MDCMenuSurface(el);
};
}
if (listFactory === void 0) {
listFactory = function listFactory(el) {
return new component_2.MDCList(el);
};
}
this.menuSurfaceFactory = menuSurfaceFactory;
this.listFactory = listFactory;
};
MDCMenu.prototype.initialSyncWithDOM = function () {
var _this = this;
this.menuSurface = this.menuSurfaceFactory(this.root);
var list = this.root.querySelector(constants_2.strings.LIST_SELECTOR);
if (list) {
this.list = this.listFactory(list);
this.list.wrapFocus = true;
} else {
this.list = null;
}
this.handleKeydown = function (evt) {
_this.foundation.handleKeydown(evt);
};
this.handleItemAction = function (evt) {
_this.foundation.handleItemAction(_this.items[evt.detail.index]);
};
this.handleMenuSurfaceOpened = function () {
_this.foundation.handleMenuSurfaceOpened();
};
this.menuSurface.listen(foundation_2.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened);
this.listen('keydown', this.handleKeydown);
this.listen(foundation_1.MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction);
};
MDCMenu.prototype.destroy = function () {
if (this.list) {
this.list.destroy();
}
this.menuSurface.destroy();
this.menuSurface.unlisten(foundation_2.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened);
this.unlisten('keydown', this.handleKeydown);
this.unlisten(foundation_1.MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction);
_super.prototype.destroy.call(this);
};
Object.defineProperty(MDCMenu.prototype, "open", {
get: function get() {
return this.menuSurface.isOpen();
},
set: function set(value) {
if (value) {
this.menuSurface.open();
} else {
this.menuSurface.close();
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenu.prototype, "wrapFocus", {
get: function get() {
return this.list ? this.list.wrapFocus : false;
},
set: function set(value) {
if (this.list) {
this.list.wrapFocus = value;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenu.prototype, "hasTypeahead", {
/**
* Sets whether the menu has typeahead functionality.
* @param value Whether typeahead is enabled.
*/
set: function set(value) {
if (this.list) {
this.list.hasTypeahead = value;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenu.prototype, "typeaheadInProgress", {
/**
* @return Whether typeahead logic is currently matching some user prefix.
*/
get: function get() {
return this.list ? this.list.typeaheadInProgress : false;
},
enumerable: false,
configurable: true
});
/**
* Given the next desired character from the user, adds it to the typeahead
* buffer. Then, attempts to find the next option matching the buffer. Wraps
* around if at the end of options.
*
* @param nextChar The next character to add to the prefix buffer.
* @param startingIndex The index from which to start matching. Only relevant
* when starting a new match sequence. To start a new match sequence,
* clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
* to clear after a set interval defined in list foundation. Defaults to
* the currently focused index.
* @return The index of the matched item, or -1 if no match.
*/
MDCMenu.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
if (this.list) {
return this.list.typeaheadMatchItem(nextChar, startingIndex);
}
return -1;
};
/**
* Layout the underlying list element in the case of any dynamic updates
* to its structure.
*/
MDCMenu.prototype.layout = function () {
if (this.list) {
this.list.layout();
}
};
Object.defineProperty(MDCMenu.prototype, "items", {
/**
* Return the items within the menu. Note that this only contains the set of elements within
* the items container that are proper list items, and not supplemental / presentational DOM
* elements.
*/
get: function get() {
return this.list ? this.list.listElements : [];
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenu.prototype, "singleSelection", {
/**
* Turns on/off the underlying list's single selection mode. Used mainly
* by select menu.
*
* @param singleSelection Whether to enable single selection mode.
*/
set: function set(singleSelection) {
if (this.list) {
this.list.singleSelection = singleSelection;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenu.prototype, "selectedIndex", {
/**
* Retrieves the selected index. Only applicable to select menus.
* @return The selected index, which is a number for single selection and
* radio lists, and an array of numbers for checkbox lists.
*/
get: function get() {
return this.list ? this.list.selectedIndex : constants_1.numbers.UNSET_INDEX;
},
/**
* Sets the selected index of the list. Only applicable to select menus.
* @param index The selected index, which is a number for single selection and
* radio lists, and an array of numbers for checkbox lists.
*/
set: function set(index) {
if (this.list) {
this.list.selectedIndex = index;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenu.prototype, "quickOpen", {
set: function set(quickOpen) {
this.menuSurface.quickOpen = quickOpen;
},
enumerable: false,
configurable: true
});
/**
* Sets default focus state where the menu should focus every time when menu
* is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
* default.
* @param focusState Default focus state.
*/
MDCMenu.prototype.setDefaultFocusState = function (focusState) {
this.foundation.setDefaultFocusState(focusState);
};
/**
* @param corner Default anchor corner alignment of top-left menu corner.
*/
MDCMenu.prototype.setAnchorCorner = function (corner) {
this.menuSurface.setAnchorCorner(corner);
};
MDCMenu.prototype.setAnchorMargin = function (margin) {
this.menuSurface.setAnchorMargin(margin);
};
/**
* Sets the list item as the selected row at the specified index.
* @param index Index of list item within menu.
*/
MDCMenu.prototype.setSelectedIndex = function (index) {
this.foundation.setSelectedIndex(index);
};
/**
* Sets the enabled state to isEnabled for the menu item at the given index.
* @param index Index of the menu item
* @param isEnabled The desired enabled state of the menu item.
*/
MDCMenu.prototype.setEnabled = function (index, isEnabled) {
this.foundation.setEnabled(index, isEnabled);
};
/**
* @return The item within the menu at the index specified.
*/
MDCMenu.prototype.getOptionByIndex = function (index) {
var items = this.items;
if (index < items.length) {
return this.items[index];
} else {
return null;
}
};
/**
* @param index A menu item's index.
* @return The primary text within the menu at the index specified.
*/
MDCMenu.prototype.getPrimaryTextAtIndex = function (index) {
var item = this.getOptionByIndex(index);
if (item && this.list) {
return this.list.getPrimaryText(item) || '';
}
return '';
};
MDCMenu.prototype.setFixedPosition = function (isFixed) {
this.menuSurface.setFixedPosition(isFixed);
};
MDCMenu.prototype.setIsHoisted = function (isHoisted) {
this.menuSurface.setIsHoisted(isHoisted);
};
MDCMenu.prototype.setAbsolutePosition = function (x, y) {
this.menuSurface.setAbsolutePosition(x, y);
};
/**
* Sets the element that the menu-surface is anchored to.
*/
MDCMenu.prototype.setAnchorElement = function (element) {
this.menuSurface.anchorElement = element;
};
MDCMenu.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
addClassToElementAtIndex: function addClassToElementAtIndex(index, className) {
var list = _this.items;
list[index].classList.add(className);
},
removeClassFromElementAtIndex: function removeClassFromElementAtIndex(index, className) {
var list = _this.items;
list[index].classList.remove(className);
},
addAttributeToElementAtIndex: function addAttributeToElementAtIndex(index, attr, value) {
var list = _this.items;
list[index].setAttribute(attr, value);
},
removeAttributeFromElementAtIndex: function removeAttributeFromElementAtIndex(index, attr) {
var list = _this.items;
list[index].removeAttribute(attr);
},
getAttributeFromElementAtIndex: function getAttributeFromElementAtIndex(index, attr) {
var list = _this.items;
return list[index].getAttribute(attr);
},
elementContainsClass: function elementContainsClass(element, className) {
return element.classList.contains(className);
},
closeSurface: function closeSurface(skipRestoreFocus) {
_this.menuSurface.close(skipRestoreFocus);
},
getElementIndex: function getElementIndex(element) {
return _this.items.indexOf(element);
},
notifySelected: function notifySelected(evtData) {
_this.emit(constants_2.strings.SELECTED_EVENT, {
index: evtData.index,
item: _this.items[evtData.index]
});
},
getMenuItemCount: function getMenuItemCount() {
return _this.items.length;
},
focusItemAtIndex: function focusItemAtIndex(index) {
_this.items[index].focus();
},
focusListRoot: function focusListRoot() {
_this.root.querySelector(constants_2.strings.LIST_SELECTOR).focus();
},
isSelectableItemAtIndex: function isSelectableItemAtIndex(index) {
return !!ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
},
getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex(index) {
var selectionGroupEl = ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
var selectedItemEl = selectionGroupEl.querySelector("." + constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
return selectedItemEl ? _this.items.indexOf(selectedItemEl) : -1;
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_3.MDCMenuFoundation(adapter);
};
return MDCMenu;
}(component_1.MDCComponent);
exports.MDCMenu = MDCMenu;
/***/ }),
/***/ "./packages/mdc-menu/constants.ts":
/*!****************************************!*\
!*** ./packages/mdc-menu/constants.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultFocusState = exports.numbers = exports.strings = exports.cssClasses = void 0;
var cssClasses = {
MENU_SELECTED_LIST_ITEM: 'mdc-menu-item--selected',
MENU_SELECTION_GROUP: 'mdc-menu__selection-group',
ROOT: 'mdc-menu'
};
exports.cssClasses = cssClasses;
var strings = {
ARIA_CHECKED_ATTR: 'aria-checked',
ARIA_DISABLED_ATTR: 'aria-disabled',
CHECKBOX_SELECTOR: 'input[type="checkbox"]',
LIST_SELECTOR: '.mdc-list,.mdc-deprecated-list',
SELECTED_EVENT: 'MDCMenu:selected',
SKIP_RESTORE_FOCUS: 'data-menu-item-skip-restore-focus'
};
exports.strings = strings;
var numbers = {
FOCUS_ROOT_INDEX: -1
};
exports.numbers = numbers;
var DefaultFocusState;
(function (DefaultFocusState) {
DefaultFocusState[DefaultFocusState["NONE"] = 0] = "NONE";
DefaultFocusState[DefaultFocusState["LIST_ROOT"] = 1] = "LIST_ROOT";
DefaultFocusState[DefaultFocusState["FIRST_ITEM"] = 2] = "FIRST_ITEM";
DefaultFocusState[DefaultFocusState["LAST_ITEM"] = 3] = "LAST_ITEM";
})(DefaultFocusState || (DefaultFocusState = {}));
exports.DefaultFocusState = DefaultFocusState;
/***/ }),
/***/ "./packages/mdc-menu/foundation.ts":
/*!*****************************************!*\
!*** ./packages/mdc-menu/foundation.ts ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCMenuFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! @material/list/constants */ "./packages/mdc-list/constants.ts");
var foundation_2 = __webpack_require__(/*! @material/menu-surface/foundation */ "./packages/mdc-menu-surface/foundation.ts");
var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
var MDCMenuFoundation = /** @class */function (_super) {
__extends(MDCMenuFoundation, _super);
function MDCMenuFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCMenuFoundation.defaultAdapter), adapter)) || this;
_this.closeAnimationEndTimerId = 0;
_this.defaultFocusState = constants_2.DefaultFocusState.LIST_ROOT;
_this.selectedIndex = -1;
return _this;
}
Object.defineProperty(MDCMenuFoundation, "cssClasses", {
get: function get() {
return constants_2.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenuFoundation, "strings", {
get: function get() {
return constants_2.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenuFoundation, "numbers", {
get: function get() {
return constants_2.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCMenuFoundation, "defaultAdapter", {
/**
* @see {@link MDCMenuAdapter} for typing information on parameters and return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClassToElementAtIndex: function addClassToElementAtIndex() {
return undefined;
},
removeClassFromElementAtIndex: function removeClassFromElementAtIndex() {
return undefined;
},
addAttributeToElementAtIndex: function addAttributeToElementAtIndex() {
return undefined;
},
removeAttributeFromElementAtIndex: function removeAttributeFromElementAtIndex() {
return undefined;
},
getAttributeFromElementAtIndex: function getAttributeFromElementAtIndex() {
return null;
},
elementContainsClass: function elementContainsClass() {
return false;
},
closeSurface: function closeSurface() {
return undefined;
},
getElementIndex: function getElementIndex() {
return -1;
},
notifySelected: function notifySelected() {
return undefined;
},
getMenuItemCount: function getMenuItemCount() {
return 0;
},
focusItemAtIndex: function focusItemAtIndex() {
return undefined;
},
focusListRoot: function focusListRoot() {
return undefined;
},
getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex() {
return -1;
},
isSelectableItemAtIndex: function isSelectableItemAtIndex() {
return false;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCMenuFoundation.prototype.destroy = function () {
if (this.closeAnimationEndTimerId) {
clearTimeout(this.closeAnimationEndTimerId);
}
this.adapter.closeSurface();
};
MDCMenuFoundation.prototype.handleKeydown = function (evt) {
var key = evt.key,
keyCode = evt.keyCode;
var isTab = key === 'Tab' || keyCode === 9;
if (isTab) {
this.adapter.closeSurface( /** skipRestoreFocus */true);
}
};
MDCMenuFoundation.prototype.handleItemAction = function (listItem) {
var _this = this;
var index = this.adapter.getElementIndex(listItem);
if (index < 0) {
return;
}
this.adapter.notifySelected({ index: index });
var skipRestoreFocus = this.adapter.getAttributeFromElementAtIndex(index, constants_2.strings.SKIP_RESTORE_FOCUS) === 'true';
this.adapter.closeSurface(skipRestoreFocus);
// Wait for the menu to close before adding/removing classes that affect styles.
this.closeAnimationEndTimerId = setTimeout(function () {
// Recompute the index in case the menu contents have changed.
var recomputedIndex = _this.adapter.getElementIndex(listItem);
if (recomputedIndex >= 0 && _this.adapter.isSelectableItemAtIndex(recomputedIndex)) {
_this.setSelectedIndex(recomputedIndex);
}
}, foundation_2.MDCMenuSurfaceFoundation.numbers.TRANSITION_CLOSE_DURATION);
};
MDCMenuFoundation.prototype.handleMenuSurfaceOpened = function () {
switch (this.defaultFocusState) {
case constants_2.DefaultFocusState.FIRST_ITEM:
this.adapter.focusItemAtIndex(0);
break;
case constants_2.DefaultFocusState.LAST_ITEM:
this.adapter.focusItemAtIndex(this.adapter.getMenuItemCount() - 1);
break;
case constants_2.DefaultFocusState.NONE:
// Do nothing.
break;
default:
this.adapter.focusListRoot();
break;
}
};
/**
* Sets default focus state where the menu should focus every time when menu
* is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
* default.
*/
MDCMenuFoundation.prototype.setDefaultFocusState = function (focusState) {
this.defaultFocusState = focusState;
};
/** @return Index of the currently selected list item within the menu. */
MDCMenuFoundation.prototype.getSelectedIndex = function () {
return this.selectedIndex;
};
/**
* Selects the list item at `index` within the menu.
* @param index Index of list item within the menu.
*/
MDCMenuFoundation.prototype.setSelectedIndex = function (index) {
this.validatedIndex(index);
if (!this.adapter.isSelectableItemAtIndex(index)) {
throw new Error('MDCMenuFoundation: No selection group at specified index.');
}
var prevSelectedIndex = this.adapter.getSelectedSiblingOfItemAtIndex(index);
if (prevSelectedIndex >= 0) {
this.adapter.removeAttributeFromElementAtIndex(prevSelectedIndex, constants_2.strings.ARIA_CHECKED_ATTR);
this.adapter.removeClassFromElementAtIndex(prevSelectedIndex, constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
}
this.adapter.addClassToElementAtIndex(index, constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_CHECKED_ATTR, 'true');
this.selectedIndex = index;
};
/**
* Sets the enabled state to isEnabled for the menu item at the given index.
* @param index Index of the menu item
* @param isEnabled The desired enabled state of the menu item.
*/
MDCMenuFoundation.prototype.setEnabled = function (index, isEnabled) {
this.validatedIndex(index);
if (isEnabled) {
this.adapter.removeClassFromElementAtIndex(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_DISABLED_ATTR, 'false');
} else {
this.adapter.addClassToElementAtIndex(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_DISABLED_ATTR, 'true');
}
};
MDCMenuFoundation.prototype.validatedIndex = function (index) {
var menuSize = this.adapter.getMenuItemCount();
var isIndexInRange = index >= 0 && index < menuSize;
if (!isIndexInRange) {
throw new Error('MDCMenuFoundation: No list item at specified index.');
}
};
return MDCMenuFoundation;
}(foundation_1.MDCFoundation);
exports.MDCMenuFoundation = MDCMenuFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCMenuFoundation;
/***/ }),
/***/ "./packages/mdc-menu/index.ts":
/*!************************************!*\
!*** ./packages/mdc-menu/index.ts ***!
\************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Corner = void 0;
var constants_1 = __webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts"); // for backward compatibility
Object.defineProperty(exports, "Corner", { enumerable: true, get: function get() {
return constants_1.Corner;
} });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-menu/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-menu/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-menu/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-menu/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-menu/types.ts":
/*!************************************!*\
!*** ./packages/mdc-menu/types.ts ***!
\************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-notched-outline/adapter.ts":
/*!*************************************************!*\
!*** ./packages/mdc-notched-outline/adapter.ts ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-notched-outline/component.ts":
/*!***************************************************!*\
!*** ./packages/mdc-notched-outline/component.ts ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCNotchedOutline = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var foundation_1 = __webpack_require__(/*! @material/floating-label/foundation */ "./packages/mdc-floating-label/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-notched-outline/foundation.ts");
var MDCNotchedOutline = /** @class */function (_super) {
__extends(MDCNotchedOutline, _super);
function MDCNotchedOutline() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCNotchedOutline.attachTo = function (root) {
return new MDCNotchedOutline(root);
};
MDCNotchedOutline.prototype.initialSyncWithDOM = function () {
this.notchElement = this.root.querySelector(constants_1.strings.NOTCH_ELEMENT_SELECTOR);
var label = this.root.querySelector('.' + foundation_1.MDCFloatingLabelFoundation.cssClasses.ROOT);
if (label) {
label.style.transitionDuration = '0s';
this.root.classList.add(constants_1.cssClasses.OUTLINE_UPGRADED);
requestAnimationFrame(function () {
label.style.transitionDuration = '';
});
} else {
this.root.classList.add(constants_1.cssClasses.NO_LABEL);
}
};
/**
* Updates classes and styles to open the notch to the specified width.
* @param notchWidth The notch width in the outline.
*/
MDCNotchedOutline.prototype.notch = function (notchWidth) {
this.foundation.notch(notchWidth);
};
/**
* Updates classes and styles to close the notch.
*/
MDCNotchedOutline.prototype.closeNotch = function () {
this.foundation.closeNotch();
};
MDCNotchedOutline.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
setNotchWidthProperty: function setNotchWidthProperty(width) {
_this.notchElement.style.setProperty('width', width + 'px');
},
removeNotchWidthProperty: function removeNotchWidthProperty() {
_this.notchElement.style.removeProperty('width');
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_2.MDCNotchedOutlineFoundation(adapter);
};
return MDCNotchedOutline;
}(component_1.MDCComponent);
exports.MDCNotchedOutline = MDCNotchedOutline;
/***/ }),
/***/ "./packages/mdc-notched-outline/constants.ts":
/*!***************************************************!*\
!*** ./packages/mdc-notched-outline/constants.ts ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.numbers = exports.cssClasses = void 0;
var strings = {
NOTCH_ELEMENT_SELECTOR: '.mdc-notched-outline__notch'
};
exports.strings = strings;
var numbers = {
// This should stay in sync with $mdc-notched-outline-padding * 2.
NOTCH_ELEMENT_PADDING: 8
};
exports.numbers = numbers;
var cssClasses = {
NO_LABEL: 'mdc-notched-outline--no-label',
OUTLINE_NOTCHED: 'mdc-notched-outline--notched',
OUTLINE_UPGRADED: 'mdc-notched-outline--upgraded'
};
exports.cssClasses = cssClasses;
/***/ }),
/***/ "./packages/mdc-notched-outline/foundation.ts":
/*!****************************************************!*\
!*** ./packages/mdc-notched-outline/foundation.ts ***!
\****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCNotchedOutlineFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts");
var MDCNotchedOutlineFoundation = /** @class */function (_super) {
__extends(MDCNotchedOutlineFoundation, _super);
function MDCNotchedOutlineFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCNotchedOutlineFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCNotchedOutlineFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCNotchedOutlineFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCNotchedOutlineFoundation, "numbers", {
get: function get() {
return constants_1.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCNotchedOutlineFoundation, "defaultAdapter", {
/**
* See {@link MDCNotchedOutlineAdapter} for typing information on parameters and return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
setNotchWidthProperty: function setNotchWidthProperty() {
return undefined;
},
removeNotchWidthProperty: function removeNotchWidthProperty() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
/**
* Adds the outline notched selector and updates the notch width calculated based off of notchWidth.
*/
MDCNotchedOutlineFoundation.prototype.notch = function (notchWidth) {
var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED;
if (notchWidth > 0) {
notchWidth += constants_1.numbers.NOTCH_ELEMENT_PADDING; // Add padding from left/right.
}
this.adapter.setNotchWidthProperty(notchWidth);
this.adapter.addClass(OUTLINE_NOTCHED);
};
/**
* Removes notched outline selector to close the notch in the outline.
*/
MDCNotchedOutlineFoundation.prototype.closeNotch = function () {
var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED;
this.adapter.removeClass(OUTLINE_NOTCHED);
this.adapter.removeNotchWidthProperty();
};
return MDCNotchedOutlineFoundation;
}(foundation_1.MDCFoundation);
exports.MDCNotchedOutlineFoundation = MDCNotchedOutlineFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCNotchedOutlineFoundation;
/***/ }),
/***/ "./packages/mdc-notched-outline/index.ts":
/*!***********************************************!*\
!*** ./packages/mdc-notched-outline/index.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-notched-outline/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-notched-outline/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-notched-outline/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-radio/adapter.ts":
/*!***************************************!*\
!*** ./packages/mdc-radio/adapter.ts ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-radio/component.ts":
/*!*****************************************!*\
!*** ./packages/mdc-radio/component.ts ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCRadio = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-radio/foundation.ts");
var MDCRadio = /** @class */function (_super) {
__extends(MDCRadio, _super);
function MDCRadio() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.rippleSurface = _this.createRipple();
return _this;
}
MDCRadio.attachTo = function (root) {
return new MDCRadio(root);
};
Object.defineProperty(MDCRadio.prototype, "checked", {
get: function get() {
return this.nativeControl.checked;
},
set: function set(checked) {
this.nativeControl.checked = checked;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCRadio.prototype, "disabled", {
get: function get() {
return this.nativeControl.disabled;
},
set: function set(disabled) {
this.foundation.setDisabled(disabled);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCRadio.prototype, "value", {
get: function get() {
return this.nativeControl.value;
},
set: function set(value) {
this.nativeControl.value = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCRadio.prototype, "ripple", {
get: function get() {
return this.rippleSurface;
},
enumerable: false,
configurable: true
});
MDCRadio.prototype.destroy = function () {
this.rippleSurface.destroy();
_super.prototype.destroy.call(this);
};
MDCRadio.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
setNativeControlDisabled: function setNativeControlDisabled(disabled) {
return _this.nativeControl.disabled = disabled;
}
};
return new foundation_2.MDCRadioFoundation(adapter);
};
MDCRadio.prototype.createRipple = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
_this.nativeControl.addEventListener(evtType, handler, events_1.applyPassive());
}, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
_this.nativeControl.removeEventListener(evtType, handler, events_1.applyPassive());
},
// Radio buttons technically go "active" whenever there is *any* keyboard
// interaction. This is not the UI we desire.
isSurfaceActive: function isSurfaceActive() {
return false;
}, isUnbounded: function isUnbounded() {
return true;
} });
// tslint:enable:object-literal-sort-keys
return new component_2.MDCRipple(this.root, new foundation_1.MDCRippleFoundation(adapter));
};
Object.defineProperty(MDCRadio.prototype, "nativeControl", {
get: function get() {
var NATIVE_CONTROL_SELECTOR = foundation_2.MDCRadioFoundation.strings.NATIVE_CONTROL_SELECTOR;
var el = this.root.querySelector(NATIVE_CONTROL_SELECTOR);
if (!el) {
throw new Error("Radio component requires a " + NATIVE_CONTROL_SELECTOR + " element");
}
return el;
},
enumerable: false,
configurable: true
});
return MDCRadio;
}(component_1.MDCComponent);
exports.MDCRadio = MDCRadio;
/***/ }),
/***/ "./packages/mdc-radio/constants.ts":
/*!*****************************************!*\
!*** ./packages/mdc-radio/constants.ts ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssClasses = exports.strings = void 0;
var strings = {
NATIVE_CONTROL_SELECTOR: '.mdc-radio__native-control'
};
exports.strings = strings;
var cssClasses = {
DISABLED: 'mdc-radio--disabled',
ROOT: 'mdc-radio'
};
exports.cssClasses = cssClasses;
/***/ }),
/***/ "./packages/mdc-radio/foundation.ts":
/*!******************************************!*\
!*** ./packages/mdc-radio/foundation.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCRadioFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-radio/constants.ts");
var MDCRadioFoundation = /** @class */function (_super) {
__extends(MDCRadioFoundation, _super);
function MDCRadioFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCRadioFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCRadioFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCRadioFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCRadioFoundation, "defaultAdapter", {
get: function get() {
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
setNativeControlDisabled: function setNativeControlDisabled() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCRadioFoundation.prototype.setDisabled = function (disabled) {
var DISABLED = MDCRadioFoundation.cssClasses.DISABLED;
this.adapter.setNativeControlDisabled(disabled);
if (disabled) {
this.adapter.addClass(DISABLED);
} else {
this.adapter.removeClass(DISABLED);
}
};
return MDCRadioFoundation;
}(foundation_1.MDCFoundation);
exports.MDCRadioFoundation = MDCRadioFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCRadioFoundation;
/***/ }),
/***/ "./packages/mdc-radio/index.ts":
/*!*************************************!*\
!*** ./packages/mdc-radio/index.ts ***!
\*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-radio/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-radio/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-radio/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-radio/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-ripple/adapter.ts":
/*!****************************************!*\
!*** ./packages/mdc-ripple/adapter.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-ripple/component.ts":
/*!******************************************!*\
!*** ./packages/mdc-ripple/component.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCRipple = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts");
var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
var MDCRipple = /** @class */function (_super) {
__extends(MDCRipple, _super);
function MDCRipple() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.disabled = false;
return _this;
}
MDCRipple.attachTo = function (root, opts) {
if (opts === void 0) {
opts = {
isUnbounded: undefined
};
}
var ripple = new MDCRipple(root);
// Only override unbounded behavior if option is explicitly specified
if (opts.isUnbounded !== undefined) {
ripple.unbounded = opts.isUnbounded;
}
return ripple;
};
MDCRipple.createAdapter = function (instance) {
return {
addClass: function addClass(className) {
return instance.root.classList.add(className);
},
browserSupportsCssVars: function browserSupportsCssVars() {
return util.supportsCssVariables(window);
},
computeBoundingRect: function computeBoundingRect() {
return instance.root.getBoundingClientRect();
},
containsEventTarget: function containsEventTarget(target) {
return instance.root.contains(target);
},
deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
return document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
},
deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
return instance.root.removeEventListener(evtType, handler, events_1.applyPassive());
},
deregisterResizeHandler: function deregisterResizeHandler(handler) {
return window.removeEventListener('resize', handler);
},
getWindowPageOffset: function getWindowPageOffset() {
return { x: window.pageXOffset, y: window.pageYOffset };
},
isSurfaceActive: function isSurfaceActive() {
return ponyfill_1.matches(instance.root, ':active');
},
isSurfaceDisabled: function isSurfaceDisabled() {
return Boolean(instance.disabled);
},
isUnbounded: function isUnbounded() {
return Boolean(instance.unbounded);
},
registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
return document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
},
registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
return instance.root.addEventListener(evtType, handler, events_1.applyPassive());
},
registerResizeHandler: function registerResizeHandler(handler) {
return window.addEventListener('resize', handler);
},
removeClass: function removeClass(className) {
return instance.root.classList.remove(className);
},
updateCssVariable: function updateCssVariable(varName, value) {
return instance.root.style.setProperty(varName, value);
}
};
};
Object.defineProperty(MDCRipple.prototype, "unbounded", {
get: function get() {
return Boolean(this.isUnbounded);
},
set: function set(unbounded) {
this.isUnbounded = Boolean(unbounded);
this.setUnbounded();
},
enumerable: false,
configurable: true
});
MDCRipple.prototype.activate = function () {
this.foundation.activate();
};
MDCRipple.prototype.deactivate = function () {
this.foundation.deactivate();
};
MDCRipple.prototype.layout = function () {
this.foundation.layout();
};
MDCRipple.prototype.getDefaultFoundation = function () {
return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
};
MDCRipple.prototype.initialSyncWithDOM = function () {
var root = this.root;
this.isUnbounded = 'mdcRippleIsUnbounded' in root.dataset;
};
/**
* Closure Compiler throws an access control error when directly accessing a
* protected or private property inside a getter/setter, like unbounded above.
* By accessing the protected property inside a method, we solve that problem.
* That's why this function exists.
*/
MDCRipple.prototype.setUnbounded = function () {
this.foundation.setUnbounded(Boolean(this.isUnbounded));
};
return MDCRipple;
}(component_1.MDCComponent);
exports.MDCRipple = MDCRipple;
/***/ }),
/***/ "./packages/mdc-ripple/constants.ts":
/*!******************************************!*\
!*** ./packages/mdc-ripple/constants.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.numbers = exports.strings = exports.cssClasses = void 0;
exports.cssClasses = {
// Ripple is a special case where the "root" component is really a "mixin" of sorts,
// given that it's an 'upgrade' to an existing component. That being said it is the root
// CSS class that all other CSS classes derive from.
BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
ROOT: 'mdc-ripple-upgraded',
UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
};
exports.strings = {
VAR_FG_SCALE: '--mdc-ripple-fg-scale',
VAR_FG_SIZE: '--mdc-ripple-fg-size',
VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
VAR_LEFT: '--mdc-ripple-left',
VAR_TOP: '--mdc-ripple-top'
};
exports.numbers = {
DEACTIVATION_TIMEOUT_MS: 225,
FG_DEACTIVATION_MS: 150,
INITIAL_ORIGIN_SCALE: 0.6,
PADDING: 10,
TAP_DELAY_MS: 300 };
/***/ }),
/***/ "./packages/mdc-ripple/foundation.ts":
/*!*******************************************!*\
!*** ./packages/mdc-ripple/foundation.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCRippleFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts");
var util_1 = __webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts");
// Activation events registered on the root element of each instance for activation
var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
// Deactivation events registered on documentElement when a pointer-related down event occurs
var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
// simultaneous nested activations
var activatedTargets = [];
var MDCRippleFoundation = /** @class */function (_super) {
__extends(MDCRippleFoundation, _super);
function MDCRippleFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this;
_this.activationAnimationHasEnded = false;
_this.activationTimer = 0;
_this.fgDeactivationRemovalTimer = 0;
_this.fgScale = '0';
_this.frame = { width: 0, height: 0 };
_this.initialSize = 0;
_this.layoutFrame = 0;
_this.maxRadius = 0;
_this.unboundedCoords = { left: 0, top: 0 };
_this.activationState = _this.defaultActivationState();
_this.activationTimerCallback = function () {
_this.activationAnimationHasEnded = true;
_this.runDeactivationUXLogicIfReady();
};
_this.activateHandler = function (e) {
_this.activateImpl(e);
};
_this.deactivateHandler = function () {
_this.deactivateImpl();
};
_this.focusHandler = function () {
_this.handleFocus();
};
_this.blurHandler = function () {
_this.handleBlur();
};
_this.resizeHandler = function () {
_this.layout();
};
return _this;
}
Object.defineProperty(MDCRippleFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCRippleFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCRippleFoundation, "numbers", {
get: function get() {
return constants_1.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
get: function get() {
return {
addClass: function addClass() {
return undefined;
},
browserSupportsCssVars: function browserSupportsCssVars() {
return true;
},
computeBoundingRect: function computeBoundingRect() {
return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
},
containsEventTarget: function containsEventTarget() {
return true;
},
deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
return undefined;
},
deregisterInteractionHandler: function deregisterInteractionHandler() {
return undefined;
},
deregisterResizeHandler: function deregisterResizeHandler() {
return undefined;
},
getWindowPageOffset: function getWindowPageOffset() {
return { x: 0, y: 0 };
},
isSurfaceActive: function isSurfaceActive() {
return true;
},
isSurfaceDisabled: function isSurfaceDisabled() {
return true;
},
isUnbounded: function isUnbounded() {
return true;
},
registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
return undefined;
},
registerInteractionHandler: function registerInteractionHandler() {
return undefined;
},
registerResizeHandler: function registerResizeHandler() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
updateCssVariable: function updateCssVariable() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCRippleFoundation.prototype.init = function () {
var _this = this;
var supportsPressRipple = this.supportsPressRipple();
this.registerRootHandlers(supportsPressRipple);
if (supportsPressRipple) {
var _a = MDCRippleFoundation.cssClasses,
ROOT_1 = _a.ROOT,
UNBOUNDED_1 = _a.UNBOUNDED;
requestAnimationFrame(function () {
_this.adapter.addClass(ROOT_1);
if (_this.adapter.isUnbounded()) {
_this.adapter.addClass(UNBOUNDED_1);
// Unbounded ripples need layout logic applied immediately to set coordinates for both shade and ripple
_this.layoutInternal();
}
});
}
};
MDCRippleFoundation.prototype.destroy = function () {
var _this = this;
if (this.supportsPressRipple()) {
if (this.activationTimer) {
clearTimeout(this.activationTimer);
this.activationTimer = 0;
this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
}
if (this.fgDeactivationRemovalTimer) {
clearTimeout(this.fgDeactivationRemovalTimer);
this.fgDeactivationRemovalTimer = 0;
this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
}
var _a = MDCRippleFoundation.cssClasses,
ROOT_2 = _a.ROOT,
UNBOUNDED_2 = _a.UNBOUNDED;
requestAnimationFrame(function () {
_this.adapter.removeClass(ROOT_2);
_this.adapter.removeClass(UNBOUNDED_2);
_this.removeCssVars();
});
}
this.deregisterRootHandlers();
this.deregisterDeactivationHandlers();
};
/**
* @param evt Optional event containing position information.
*/
MDCRippleFoundation.prototype.activate = function (evt) {
this.activateImpl(evt);
};
MDCRippleFoundation.prototype.deactivate = function () {
this.deactivateImpl();
};
MDCRippleFoundation.prototype.layout = function () {
var _this = this;
if (this.layoutFrame) {
cancelAnimationFrame(this.layoutFrame);
}
this.layoutFrame = requestAnimationFrame(function () {
_this.layoutInternal();
_this.layoutFrame = 0;
});
};
MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
if (unbounded) {
this.adapter.addClass(UNBOUNDED);
} else {
this.adapter.removeClass(UNBOUNDED);
}
};
MDCRippleFoundation.prototype.handleFocus = function () {
var _this = this;
requestAnimationFrame(function () {
return _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
});
};
MDCRippleFoundation.prototype.handleBlur = function () {
var _this = this;
requestAnimationFrame(function () {
return _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
});
};
/**
* We compute this property so that we are not querying information about the client
* until the point in time where the foundation requests it. This prevents scenarios where
* client-side feature-detection may happen too early, such as when components are rendered on the server
* and then initialized at mount time on the client.
*/
MDCRippleFoundation.prototype.supportsPressRipple = function () {
return this.adapter.browserSupportsCssVars();
};
MDCRippleFoundation.prototype.defaultActivationState = function () {
return {
activationEvent: undefined,
hasDeactivationUXRun: false,
isActivated: false,
isProgrammatic: false,
wasActivatedByPointer: false,
wasElementMadeActive: false
};
};
/**
* supportsPressRipple Passed from init to save a redundant function call
*/
MDCRippleFoundation.prototype.registerRootHandlers = function (supportsPressRipple) {
var e_1, _a;
if (supportsPressRipple) {
try {
for (var ACTIVATION_EVENT_TYPES_1 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next(); !ACTIVATION_EVENT_TYPES_1_1.done; ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next()) {
var evtType = ACTIVATION_EVENT_TYPES_1_1.value;
this.adapter.registerInteractionHandler(evtType, this.activateHandler);
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (ACTIVATION_EVENT_TYPES_1_1 && !ACTIVATION_EVENT_TYPES_1_1.done && (_a = ACTIVATION_EVENT_TYPES_1.return)) _a.call(ACTIVATION_EVENT_TYPES_1);
} finally {
if (e_1) throw e_1.error;
}
}
if (this.adapter.isUnbounded()) {
this.adapter.registerResizeHandler(this.resizeHandler);
}
}
this.adapter.registerInteractionHandler('focus', this.focusHandler);
this.adapter.registerInteractionHandler('blur', this.blurHandler);
};
MDCRippleFoundation.prototype.registerDeactivationHandlers = function (evt) {
var e_2, _a;
if (evt.type === 'keydown') {
this.adapter.registerInteractionHandler('keyup', this.deactivateHandler);
} else {
try {
for (var POINTER_DEACTIVATION_EVENT_TYPES_1 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next(); !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done; POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next()) {
var evtType = POINTER_DEACTIVATION_EVENT_TYPES_1_1.value;
this.adapter.registerDocumentInteractionHandler(evtType, this.deactivateHandler);
}
} catch (e_2_1) {
e_2 = { error: e_2_1 };
} finally {
try {
if (POINTER_DEACTIVATION_EVENT_TYPES_1_1 && !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done && (_a = POINTER_DEACTIVATION_EVENT_TYPES_1.return)) _a.call(POINTER_DEACTIVATION_EVENT_TYPES_1);
} finally {
if (e_2) throw e_2.error;
}
}
}
};
MDCRippleFoundation.prototype.deregisterRootHandlers = function () {
var e_3, _a;
try {
for (var ACTIVATION_EVENT_TYPES_2 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next(); !ACTIVATION_EVENT_TYPES_2_1.done; ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next()) {
var evtType = ACTIVATION_EVENT_TYPES_2_1.value;
this.adapter.deregisterInteractionHandler(evtType, this.activateHandler);
}
} catch (e_3_1) {
e_3 = { error: e_3_1 };
} finally {
try {
if (ACTIVATION_EVENT_TYPES_2_1 && !ACTIVATION_EVENT_TYPES_2_1.done && (_a = ACTIVATION_EVENT_TYPES_2.return)) _a.call(ACTIVATION_EVENT_TYPES_2);
} finally {
if (e_3) throw e_3.error;
}
}
this.adapter.deregisterInteractionHandler('focus', this.focusHandler);
this.adapter.deregisterInteractionHandler('blur', this.blurHandler);
if (this.adapter.isUnbounded()) {
this.adapter.deregisterResizeHandler(this.resizeHandler);
}
};
MDCRippleFoundation.prototype.deregisterDeactivationHandlers = function () {
var e_4, _a;
this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler);
try {
for (var POINTER_DEACTIVATION_EVENT_TYPES_2 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next(); !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done; POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next()) {
var evtType = POINTER_DEACTIVATION_EVENT_TYPES_2_1.value;
this.adapter.deregisterDocumentInteractionHandler(evtType, this.deactivateHandler);
}
} catch (e_4_1) {
e_4 = { error: e_4_1 };
} finally {
try {
if (POINTER_DEACTIVATION_EVENT_TYPES_2_1 && !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done && (_a = POINTER_DEACTIVATION_EVENT_TYPES_2.return)) _a.call(POINTER_DEACTIVATION_EVENT_TYPES_2);
} finally {
if (e_4) throw e_4.error;
}
}
};
MDCRippleFoundation.prototype.removeCssVars = function () {
var _this = this;
var rippleStrings = MDCRippleFoundation.strings;
var keys = Object.keys(rippleStrings);
keys.forEach(function (key) {
if (key.indexOf('VAR_') === 0) {
_this.adapter.updateCssVariable(rippleStrings[key], null);
}
});
};
MDCRippleFoundation.prototype.activateImpl = function (evt) {
var _this = this;
if (this.adapter.isSurfaceDisabled()) {
return;
}
var activationState = this.activationState;
if (activationState.isActivated) {
return;
}
// Avoid reacting to follow-on events fired by touch device after an already-processed user interaction
var previousActivationEvent = this.previousActivationEvent;
var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
if (isSameInteraction) {
return;
}
activationState.isActivated = true;
activationState.isProgrammatic = evt === undefined;
activationState.activationEvent = evt;
activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
return _this.adapter.containsEventTarget(target);
});
if (hasActivatedChild) {
// Immediately reset activation state, while preserving logic that prevents touch follow-on events
this.resetActivationState();
return;
}
if (evt !== undefined) {
activatedTargets.push(evt.target);
this.registerDeactivationHandlers(evt);
}
activationState.wasElementMadeActive = this.checkElementMadeActive(evt);
if (activationState.wasElementMadeActive) {
this.animateActivation();
}
requestAnimationFrame(function () {
// Reset array on next frame after the current event has had a chance to bubble to prevent ancestor ripples
activatedTargets = [];
if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
// If space was pressed, try again within an rAF call to detect :active, because different UAs report
// active states inconsistently when they're called within event handling code:
// - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
// - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
// We try first outside rAF to support Edge, which does not exhibit this problem, but will crash if a CSS
// variable is set within a rAF callback for a submit button interaction (#2241).
activationState.wasElementMadeActive = _this.checkElementMadeActive(evt);
if (activationState.wasElementMadeActive) {
_this.animateActivation();
}
}
if (!activationState.wasElementMadeActive) {
// Reset activation state immediately if element was not made active.
_this.activationState = _this.defaultActivationState();
}
});
};
MDCRippleFoundation.prototype.checkElementMadeActive = function (evt) {
return evt !== undefined && evt.type === 'keydown' ? this.adapter.isSurfaceActive() : true;
};
MDCRippleFoundation.prototype.animateActivation = function () {
var _this = this;
var _a = MDCRippleFoundation.strings,
VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
var _b = MDCRippleFoundation.cssClasses,
FG_DEACTIVATION = _b.FG_DEACTIVATION,
FG_ACTIVATION = _b.FG_ACTIVATION;
var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
this.layoutInternal();
var translateStart = '';
var translateEnd = '';
if (!this.adapter.isUnbounded()) {
var _c = this.getFgTranslationCoordinates(),
startPoint = _c.startPoint,
endPoint = _c.endPoint;
translateStart = startPoint.x + "px, " + startPoint.y + "px";
translateEnd = endPoint.x + "px, " + endPoint.y + "px";
}
this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
// Cancel any ongoing activation/deactivation animations
clearTimeout(this.activationTimer);
clearTimeout(this.fgDeactivationRemovalTimer);
this.rmBoundedActivationClasses();
this.adapter.removeClass(FG_DEACTIVATION);
// Force layout in order to re-trigger the animation.
this.adapter.computeBoundingRect();
this.adapter.addClass(FG_ACTIVATION);
this.activationTimer = setTimeout(function () {
_this.activationTimerCallback();
}, DEACTIVATION_TIMEOUT_MS);
};
MDCRippleFoundation.prototype.getFgTranslationCoordinates = function () {
var _a = this.activationState,
activationEvent = _a.activationEvent,
wasActivatedByPointer = _a.wasActivatedByPointer;
var startPoint;
if (wasActivatedByPointer) {
startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
} else {
startPoint = {
x: this.frame.width / 2,
y: this.frame.height / 2
};
}
// Center the element around the start point.
startPoint = {
x: startPoint.x - this.initialSize / 2,
y: startPoint.y - this.initialSize / 2
};
var endPoint = {
x: this.frame.width / 2 - this.initialSize / 2,
y: this.frame.height / 2 - this.initialSize / 2
};
return { startPoint: startPoint, endPoint: endPoint };
};
MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady = function () {
var _this = this;
// This method is called both when a pointing device is released, and when the activation animation ends.
// The deactivation animation should only run after both of those occur.
var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
var _a = this.activationState,
hasDeactivationUXRun = _a.hasDeactivationUXRun,
isActivated = _a.isActivated;
var activationHasEnded = hasDeactivationUXRun || !isActivated;
if (activationHasEnded && this.activationAnimationHasEnded) {
this.rmBoundedActivationClasses();
this.adapter.addClass(FG_DEACTIVATION);
this.fgDeactivationRemovalTimer = setTimeout(function () {
_this.adapter.removeClass(FG_DEACTIVATION);
}, constants_1.numbers.FG_DEACTIVATION_MS);
}
};
MDCRippleFoundation.prototype.rmBoundedActivationClasses = function () {
var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
this.adapter.removeClass(FG_ACTIVATION);
this.activationAnimationHasEnded = false;
this.adapter.computeBoundingRect();
};
MDCRippleFoundation.prototype.resetActivationState = function () {
var _this = this;
this.previousActivationEvent = this.activationState.activationEvent;
this.activationState = this.defaultActivationState();
// Touch devices may fire additional events for the same interaction within a short time.
// Store the previous event until it's safe to assume that subsequent events are for new interactions.
setTimeout(function () {
return _this.previousActivationEvent = undefined;
}, MDCRippleFoundation.numbers.TAP_DELAY_MS);
};
MDCRippleFoundation.prototype.deactivateImpl = function () {
var _this = this;
var activationState = this.activationState;
// This can happen in scenarios such as when you have a keyup event that blurs the element.
if (!activationState.isActivated) {
return;
}
var state = __assign({}, activationState);
if (activationState.isProgrammatic) {
requestAnimationFrame(function () {
_this.animateDeactivation(state);
});
this.resetActivationState();
} else {
this.deregisterDeactivationHandlers();
requestAnimationFrame(function () {
_this.activationState.hasDeactivationUXRun = true;
_this.animateDeactivation(state);
_this.resetActivationState();
});
}
};
MDCRippleFoundation.prototype.animateDeactivation = function (_a) {
var wasActivatedByPointer = _a.wasActivatedByPointer,
wasElementMadeActive = _a.wasElementMadeActive;
if (wasActivatedByPointer || wasElementMadeActive) {
this.runDeactivationUXLogicIfReady();
}
};
MDCRippleFoundation.prototype.layoutInternal = function () {
var _this = this;
this.frame = this.adapter.computeBoundingRect();
var maxDim = Math.max(this.frame.height, this.frame.width);
// Surface diameter is treated differently for unbounded vs. bounded ripples.
// Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately
// to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically
// square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter
// (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via
// `overflow: hidden`.
var getBoundedRadius = function getBoundedRadius() {
var hypotenuse = Math.sqrt(Math.pow(_this.frame.width, 2) + Math.pow(_this.frame.height, 2));
return hypotenuse + MDCRippleFoundation.numbers.PADDING;
};
this.maxRadius = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
// Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform
var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
// Unbounded ripple size should always be even number to equally center align.
if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
this.initialSize = initialSize - 1;
} else {
this.initialSize = initialSize;
}
this.fgScale = "" + this.maxRadius / this.initialSize;
this.updateLayoutCssVars();
};
MDCRippleFoundation.prototype.updateLayoutCssVars = function () {
var _a = MDCRippleFoundation.strings,
VAR_FG_SIZE = _a.VAR_FG_SIZE,
VAR_LEFT = _a.VAR_LEFT,
VAR_TOP = _a.VAR_TOP,
VAR_FG_SCALE = _a.VAR_FG_SCALE;
this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize + "px");
this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale);
if (this.adapter.isUnbounded()) {
this.unboundedCoords = {
left: Math.round(this.frame.width / 2 - this.initialSize / 2),
top: Math.round(this.frame.height / 2 - this.initialSize / 2)
};
this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords.left + "px");
this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords.top + "px");
}
};
return MDCRippleFoundation;
}(foundation_1.MDCFoundation);
exports.MDCRippleFoundation = MDCRippleFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCRippleFoundation;
/***/ }),
/***/ "./packages/mdc-ripple/index.ts":
/*!**************************************!*\
!*** ./packages/mdc-ripple/index.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.util = void 0;
var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
exports.util = util;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-ripple/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-ripple/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-ripple/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-ripple/types.ts":
/*!**************************************!*\
!*** ./packages/mdc-ripple/types.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-ripple/util.ts":
/*!*************************************!*\
!*** ./packages/mdc-ripple/util.ts ***!
\*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNormalizedEventCoords = exports.supportsCssVariables = void 0;
/**
* Stores result from supportsCssVariables to avoid redundant processing to
* detect CSS custom variable support.
*/
var supportsCssVariables_;
function supportsCssVariables(windowObj, forceRefresh) {
if (forceRefresh === void 0) {
forceRefresh = false;
}
var CSS = windowObj.CSS;
var supportsCssVars = supportsCssVariables_;
if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
return supportsCssVariables_;
}
var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
if (!supportsFunctionPresent) {
return false;
}
var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
// See: https://bugs.webkit.org/show_bug.cgi?id=154669
// See: README section on Safari
var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
if (!forceRefresh) {
supportsCssVariables_ = supportsCssVars;
}
return supportsCssVars;
}
exports.supportsCssVariables = supportsCssVariables;
function getNormalizedEventCoords(evt, pageOffset, clientRect) {
if (!evt) {
return { x: 0, y: 0 };
}
var x = pageOffset.x,
y = pageOffset.y;
var documentX = x + clientRect.left;
var documentY = y + clientRect.top;
var normalizedX;
var normalizedY;
// Determine touch point relative to the ripple container.
if (evt.type === 'touchstart') {
var touchEvent = evt;
normalizedX = touchEvent.changedTouches[0].pageX - documentX;
normalizedY = touchEvent.changedTouches[0].pageY - documentY;
} else {
var mouseEvent = evt;
normalizedX = mouseEvent.pageX - documentX;
normalizedY = mouseEvent.pageY - documentY;
}
return { x: normalizedX, y: normalizedY };
}
exports.getNormalizedEventCoords = getNormalizedEventCoords;
/***/ }),
/***/ "./packages/mdc-segmented-button/index.ts":
/*!************************************************!*\
!*** ./packages/mdc-segmented-button/index.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./segmented-button/index */ "./packages/mdc-segmented-button/segmented-button/index.ts"), exports);
__exportStar(__webpack_require__(/*! ./segment/index */ "./packages/mdc-segmented-button/segment/index.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-segmented-button/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-segmented-button/segment/adapter.ts":
/*!**********************************************************!*\
!*** ./packages/mdc-segmented-button/segment/adapter.ts ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-segmented-button/segment/component.ts":
/*!************************************************************!*\
!*** ./packages/mdc-segmented-button/segment/component.ts ***!
\************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSegmentedButtonSegment = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segment/constants.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segment/foundation.ts");
/**
* Implementation of MDCSegmentedButtonSegmentFoundation
*/
var MDCSegmentedButtonSegment = /** @class */function (_super) {
__extends(MDCSegmentedButtonSegment, _super);
function MDCSegmentedButtonSegment() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(MDCSegmentedButtonSegment.prototype, "ripple", {
get: function get() {
return this.rippleComponent;
},
enumerable: false,
configurable: true
});
MDCSegmentedButtonSegment.attachTo = function (root) {
return new MDCSegmentedButtonSegment(root);
};
MDCSegmentedButtonSegment.prototype.initialize = function (rippleFactory) {
var _this = this;
if (rippleFactory === void 0) {
rippleFactory = function rippleFactory(el, foundation) {
return new component_2.MDCRipple(el, foundation);
};
}
var rippleAdapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { computeBoundingRect: function computeBoundingRect() {
return _this.foundation.getDimensions();
} });
this.rippleComponent = rippleFactory(this.root, new foundation_1.MDCRippleFoundation(rippleAdapter));
};
MDCSegmentedButtonSegment.prototype.initialSyncWithDOM = function () {
var _this = this;
this.handleClick = function () {
_this.foundation.handleClick();
};
this.listen(constants_1.events.CLICK, this.handleClick);
};
MDCSegmentedButtonSegment.prototype.destroy = function () {
this.ripple.destroy();
this.unlisten(constants_1.events.CLICK, this.handleClick);
_super.prototype.destroy.call(this);
};
MDCSegmentedButtonSegment.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
// methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
isSingleSelect: function isSingleSelect() {
return _this.isSingleSelect;
},
getAttr: function getAttr(attrName) {
return _this.root.getAttribute(attrName);
},
setAttr: function setAttr(attrName, value) {
_this.root.setAttribute(attrName, value);
},
addClass: function addClass(className) {
_this.root.classList.add(className);
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
notifySelectedChange: function notifySelectedChange(selected) {
_this.emit(constants_1.events.SELECTED, {
index: _this.index,
selected: selected,
segmentId: _this.getSegmentId()
}, true /* shouldBubble */);
},
getRootBoundingClientRect: function getRootBoundingClientRect() {
return _this.root.getBoundingClientRect();
}
};
return new foundation_2.MDCSegmentedButtonSegmentFoundation(adapter);
};
/**
* Sets segment's index value
*
* @param index Segment's index within wrapping segmented button
*/
MDCSegmentedButtonSegment.prototype.setIndex = function (index) {
this.index = index;
};
/**
* Sets segment's isSingleSelect value
*
* @param isSingleSelect True if wrapping segmented button is single select
*/
MDCSegmentedButtonSegment.prototype.setIsSingleSelect = function (isSingleSelect) {
this.isSingleSelect = isSingleSelect;
};
/**
* @return Returns true if segment is currently selected, otherwise returns
* false
*/
MDCSegmentedButtonSegment.prototype.isSelected = function () {
return this.foundation.isSelected();
};
/**
* Sets segment to be selected
*/
MDCSegmentedButtonSegment.prototype.setSelected = function () {
this.foundation.setSelected();
};
/**
* Sets segment to be not selected
*/
MDCSegmentedButtonSegment.prototype.setUnselected = function () {
this.foundation.setUnselected();
};
/**
* @return Returns segment's segmentId if it was set by client
*/
MDCSegmentedButtonSegment.prototype.getSegmentId = function () {
return this.foundation.getSegmentId();
};
return MDCSegmentedButtonSegment;
}(component_1.MDCComponent);
exports.MDCSegmentedButtonSegment = MDCSegmentedButtonSegment;
/***/ }),
/***/ "./packages/mdc-segmented-button/segment/constants.ts":
/*!************************************************************!*\
!*** ./packages/mdc-segmented-button/segment/constants.ts ***!
\************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssClasses = exports.events = exports.attributes = exports.booleans = void 0;
/**
* Boolean strings for segment
*/
exports.booleans = {
TRUE: 'true',
FALSE: 'false'
};
/**
* Attributes referenced by segment
*/
exports.attributes = {
ARIA_CHECKED: 'aria-checked',
ARIA_PRESSED: 'aria-pressed',
DATA_SEGMENT_ID: 'data-segment-id'
};
/**
* Events received or emitted by segment
*/
exports.events = {
CLICK: 'click',
SELECTED: 'selected'
};
/**
* Style classes for segment
*/
exports.cssClasses = {
SELECTED: 'mdc-segmented-button__segment--selected'
};
/***/ }),
/***/ "./packages/mdc-segmented-button/segment/foundation.ts":
/*!*************************************************************!*\
!*** ./packages/mdc-segmented-button/segment/foundation.ts ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSegmentedButtonSegmentFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segment/constants.ts");
var emptyClientRect = {
bottom: 0,
height: 0,
left: 0,
right: 0,
top: 0,
width: 0
};
var MDCSegmentedButtonSegmentFoundation = /** @class */function (_super) {
__extends(MDCSegmentedButtonSegmentFoundation, _super);
function MDCSegmentedButtonSegmentFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCSegmentedButtonSegmentFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCSegmentedButtonSegmentFoundation, "defaultAdapter", {
get: function get() {
return {
isSingleSelect: function isSingleSelect() {
return false;
}, getAttr: function getAttr() {
return '';
}, setAttr: function setAttr() {
return undefined;
},
addClass: function addClass() {
return undefined;
}, removeClass: function removeClass() {
return undefined;
},
hasClass: function hasClass() {
return false;
},
notifySelectedChange: function notifySelectedChange() {
return undefined;
},
getRootBoundingClientRect: function getRootBoundingClientRect() {
return emptyClientRect;
}
};
},
enumerable: false,
configurable: true
});
/**
* @return Returns true if segment is currently selected, otherwise returns
* false
*/
MDCSegmentedButtonSegmentFoundation.prototype.isSelected = function () {
return this.adapter.hasClass(constants_1.cssClasses.SELECTED);
};
/**
* Sets segment to be selected
*/
MDCSegmentedButtonSegmentFoundation.prototype.setSelected = function () {
this.adapter.addClass(constants_1.cssClasses.SELECTED);
this.setAriaAttr(constants_1.booleans.TRUE);
};
/**
* Sets segment to be not selected
*/
MDCSegmentedButtonSegmentFoundation.prototype.setUnselected = function () {
this.adapter.removeClass(constants_1.cssClasses.SELECTED);
this.setAriaAttr(constants_1.booleans.FALSE);
};
/**
* @return Returns segment's segmentId if it was set by client
*/
MDCSegmentedButtonSegmentFoundation.prototype.getSegmentId = function () {
var _a;
return (_a = this.adapter.getAttr(constants_1.attributes.DATA_SEGMENT_ID)) !== null && _a !== void 0 ? _a : undefined;
};
/**
* Called when segment is clicked. If the wrapping segmented button is single
* select, doesn't allow segment to be set to not selected. Otherwise, toggles
* segment's selected status. Finally, emits event to wrapping segmented
* button.
*
* @event selected With detail - SegmentDetail
*/
MDCSegmentedButtonSegmentFoundation.prototype.handleClick = function () {
if (this.adapter.isSingleSelect()) {
this.setSelected();
} else {
this.toggleSelection();
}
this.adapter.notifySelectedChange(this.isSelected());
};
/**
* @return Returns bounding rectangle for ripple effect
*/
MDCSegmentedButtonSegmentFoundation.prototype.getDimensions = function () {
return this.adapter.getRootBoundingClientRect();
};
/**
* Sets segment from not selected to selected, or selected to not selected
*/
MDCSegmentedButtonSegmentFoundation.prototype.toggleSelection = function () {
if (this.isSelected()) {
this.setUnselected();
} else {
this.setSelected();
}
};
/**
* Sets appropriate aria attribute, based on wrapping segmented button's
* single selected value, to new value
*
* @param value Value that represents selected status
*/
MDCSegmentedButtonSegmentFoundation.prototype.setAriaAttr = function (value) {
if (this.adapter.isSingleSelect()) {
this.adapter.setAttr(constants_1.attributes.ARIA_CHECKED, value);
} else {
this.adapter.setAttr(constants_1.attributes.ARIA_PRESSED, value);
}
};
return MDCSegmentedButtonSegmentFoundation;
}(foundation_1.MDCFoundation);
exports.MDCSegmentedButtonSegmentFoundation = MDCSegmentedButtonSegmentFoundation;
/***/ }),
/***/ "./packages/mdc-segmented-button/segment/index.ts":
/*!********************************************************!*\
!*** ./packages/mdc-segmented-button/segment/index.ts ***!
\********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-segmented-button/segment/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segment/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-segmented-button/segment/component.ts"), exports);
/***/ }),
/***/ "./packages/mdc-segmented-button/segmented-button/adapter.ts":
/*!*******************************************************************!*\
!*** ./packages/mdc-segmented-button/segmented-button/adapter.ts ***!
\*******************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-segmented-button/segmented-button/component.ts":
/*!*********************************************************************!*\
!*** ./packages/mdc-segmented-button/segmented-button/component.ts ***!
\*********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSegmentedButton = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var component_2 = __webpack_require__(/*! ../segment/component */ "./packages/mdc-segmented-button/segment/component.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segmented-button/constants.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segmented-button/foundation.ts");
var MDCSegmentedButton = /** @class */function (_super) {
__extends(MDCSegmentedButton, _super);
function MDCSegmentedButton() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCSegmentedButton.attachTo = function (root) {
return new MDCSegmentedButton(root);
};
Object.defineProperty(MDCSegmentedButton.prototype, "segments", {
get: function get() {
return this.segmentsList.slice();
},
enumerable: false,
configurable: true
});
// initialSyncWithDOM
MDCSegmentedButton.prototype.initialize = function (segmentFactory) {
if (segmentFactory === void 0) {
segmentFactory = function segmentFactory(el) {
return new component_2.MDCSegmentedButtonSegment(el);
};
}
this.segmentFactory = segmentFactory;
this.segmentsList = this.instantiateSegments(this.segmentFactory);
};
/**
* @param segmentFactory Factory to create new child segments
* @return Returns list of child segments found in DOM
*/
MDCSegmentedButton.prototype.instantiateSegments = function (segmentFactory) {
var segmentElements = [].slice.call(this.root.querySelectorAll(constants_1.selectors.SEGMENT));
return segmentElements.map(function (el) {
return segmentFactory(el);
});
};
MDCSegmentedButton.prototype.initialSyncWithDOM = function () {
var _this = this;
this.handleSelected = function (event) {
_this.foundation.handleSelected(event.detail);
};
this.listen(constants_1.events.SELECTED, this.handleSelected);
var isSingleSelect = this.foundation.isSingleSelect();
for (var i = 0; i < this.segmentsList.length; i++) {
var segment = this.segmentsList[i];
segment.setIndex(i);
segment.setIsSingleSelect(isSingleSelect);
}
var selectedSegments = this.segmentsList.filter(function (segment) {
return segment.isSelected();
});
if (isSingleSelect && selectedSegments.length === 0 && this.segmentsList.length > 0) {
throw new Error('No segment selected in singleSelect mdc-segmented-button');
} else if (isSingleSelect && selectedSegments.length > 1) {
throw new Error('Multiple segments selected in singleSelect mdc-segmented-button');
}
};
MDCSegmentedButton.prototype.destroy = function () {
var e_1, _a;
try {
for (var _b = __values(this.segmentsList), _c = _b.next(); !_c.done; _c = _b.next()) {
var segment = _c.value;
segment.destroy();
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_1) throw e_1.error;
}
}
this.unlisten(constants_1.events.SELECTED, this.handleSelected);
_super.prototype.destroy.call(this);
};
MDCSegmentedButton.prototype.getDefaultFoundation = function () {
var _this = this;
var adapter = {
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
getSegments: function getSegments() {
return _this.mappedSegments();
},
selectSegment: function selectSegment(indexOrSegmentId) {
var segmentDetail = _this.mappedSegments().find(function (detail) {
return detail.index === indexOrSegmentId || detail.segmentId === indexOrSegmentId;
});
if (segmentDetail) {
_this.segmentsList[segmentDetail.index].setSelected();
}
},
unselectSegment: function unselectSegment(indexOrSegmentId) {
var segmentDetail = _this.mappedSegments().find(function (detail) {
return detail.index === indexOrSegmentId || detail.segmentId === indexOrSegmentId;
});
if (segmentDetail) {
_this.segmentsList[segmentDetail.index].setUnselected();
}
},
notifySelectedChange: function notifySelectedChange(detail) {
_this.emit(constants_1.events.CHANGE, detail, true /* shouldBubble */);
}
};
return new foundation_1.MDCSegmentedButtonFoundation(adapter);
};
/**
* @return Returns readonly list of selected child segments as SegmentDetails
*/
MDCSegmentedButton.prototype.getSelectedSegments = function () {
return this.foundation.getSelectedSegments();
};
/**
* Sets identified segment to be selected
*
* @param indexOrSegmentId Number index or string segmentId that identifies
* child segment
*/
MDCSegmentedButton.prototype.selectSegment = function (indexOrSegmentId) {
this.foundation.selectSegment(indexOrSegmentId);
};
/**
* Sets identified segment to be not selected
*
* @param indexOrSegmentId Number index or string segmentId that identifies
* child segment
*/
MDCSegmentedButton.prototype.unselectSegment = function (indexOrSegmentId) {
this.foundation.unselectSegment(indexOrSegmentId);
};
/**
* @param indexOrSegmentId Number index or string segmentId that identifies
* child segment
* @return Returns true if identified child segment is currently selected,
* otherwise returns false
*/
MDCSegmentedButton.prototype.isSegmentSelected = function (indexOrSegmentId) {
return this.foundation.isSegmentSelected(indexOrSegmentId);
};
/**
* @return Returns child segments mapped to readonly SegmentDetail list
*/
MDCSegmentedButton.prototype.mappedSegments = function () {
return this.segmentsList.map(function (segment, index) {
return {
index: index,
selected: segment.isSelected(),
segmentId: segment.getSegmentId()
};
});
};
return MDCSegmentedButton;
}(component_1.MDCComponent);
exports.MDCSegmentedButton = MDCSegmentedButton;
/***/ }),
/***/ "./packages/mdc-segmented-button/segmented-button/constants.ts":
/*!*********************************************************************!*\
!*** ./packages/mdc-segmented-button/segmented-button/constants.ts ***!
\*********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssClasses = exports.events = exports.selectors = void 0;
/**
* Selectors used by segmented-button
*/
exports.selectors = {
SEGMENT: '.mdc-segmented-button__segment'
};
/**
* Events received or emitted by segmented-button
*/
exports.events = {
SELECTED: 'selected',
CHANGE: 'change'
};
/**
* Style classes for segmented-button
*/
exports.cssClasses = {
SINGLE_SELECT: 'mdc-segmented-button--single-select'
};
/***/ }),
/***/ "./packages/mdc-segmented-button/segmented-button/foundation.ts":
/*!**********************************************************************!*\
!*** ./packages/mdc-segmented-button/segmented-button/foundation.ts ***!
\**********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSegmentedButtonFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segmented-button/constants.ts");
var MDCSegmentedButtonFoundation = /** @class */function (_super) {
__extends(MDCSegmentedButtonFoundation, _super);
function MDCSegmentedButtonFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCSegmentedButtonFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCSegmentedButtonFoundation, "defaultAdapter", {
get: function get() {
return {
hasClass: function hasClass() {
return false;
}, getSegments: function getSegments() {
return [];
},
selectSegment: function selectSegment() {
return undefined;
},
unselectSegment: function unselectSegment() {
return undefined;
},
notifySelectedChange: function notifySelectedChange() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
/**
* Sets identified child segment to be selected
*
* @param indexOrSegmentId Number index or string segmentId that identifies
* child segment
*/
MDCSegmentedButtonFoundation.prototype.selectSegment = function (indexOrSegmentId) {
this.adapter.selectSegment(indexOrSegmentId);
};
/**
* Sets identified child segment to be not selected
*
* @param indexOrSegmentId Number index or string segmentId that identifies
* child segment
*/
MDCSegmentedButtonFoundation.prototype.unselectSegment = function (indexOrSegmentId) {
this.adapter.unselectSegment(indexOrSegmentId);
};
/**
* @return Returns currently selected child segments as readonly list of
* SegmentDetails
*/
MDCSegmentedButtonFoundation.prototype.getSelectedSegments = function () {
return this.adapter.getSegments().filter(function (segmentDetail) {
return segmentDetail.selected;
});
};
/**
* @param indexOrSegmentId Number index or string segmentId that identifies
* child segment
* @return Returns true if identified child segment is currently selected,
* otherwise returns false
*/
MDCSegmentedButtonFoundation.prototype.isSegmentSelected = function (indexOrSegmentId) {
return this.adapter.getSegments().some(function (segmentDetail) {
return (segmentDetail.index === indexOrSegmentId || segmentDetail.segmentId === indexOrSegmentId) && segmentDetail.selected;
});
};
/**
* @return Returns true if segmented button is single select, otherwise
* returns false
*/
MDCSegmentedButtonFoundation.prototype.isSingleSelect = function () {
return this.adapter.hasClass(constants_1.cssClasses.SINGLE_SELECT);
};
/**
* Called when child segment's selected status may have changed. If segmented
* button is single select, unselects all child segments other than identified
* child segment. Finally, emits event to client.
*
* @param detail Child segment affected represented as SegmentDetail
* @event change With detail - SegmentDetail
*/
MDCSegmentedButtonFoundation.prototype.handleSelected = function (detail) {
if (this.isSingleSelect()) {
this.unselectPrevSelected(detail.index);
}
this.adapter.notifySelectedChange(detail);
};
/**
* Sets all child segments to be not selected except for child segment
* identified by index
*
* @param index Index of child segment to not unselect
*/
MDCSegmentedButtonFoundation.prototype.unselectPrevSelected = function (index) {
var e_1, _a;
try {
for (var _b = __values(this.getSelectedSegments()), _c = _b.next(); !_c.done; _c = _b.next()) {
var selectedSegment = _c.value;
if (selectedSegment.index !== index) {
this.unselectSegment(selectedSegment.index);
}
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_1) throw e_1.error;
}
}
};
return MDCSegmentedButtonFoundation;
}(foundation_1.MDCFoundation);
exports.MDCSegmentedButtonFoundation = MDCSegmentedButtonFoundation;
/***/ }),
/***/ "./packages/mdc-segmented-button/segmented-button/index.ts":
/*!*****************************************************************!*\
!*** ./packages/mdc-segmented-button/segmented-button/index.ts ***!
\*****************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-segmented-button/segmented-button/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segmented-button/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-segmented-button/segmented-button/component.ts"), exports);
/***/ }),
/***/ "./packages/mdc-segmented-button/types.ts":
/*!************************************************!*\
!*** ./packages/mdc-segmented-button/types.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-select/adapter.ts":
/*!****************************************!*\
!*** ./packages/mdc-select/adapter.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-select/component.ts":
/*!******************************************!*\
!*** ./packages/mdc-select/component.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSelect = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var component_2 = __webpack_require__(/*! @material/floating-label/component */ "./packages/mdc-floating-label/component.ts");
var component_3 = __webpack_require__(/*! @material/line-ripple/component */ "./packages/mdc-line-ripple/component.ts");
var menuSurfaceConstants = __importStar(__webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts"));
var component_4 = __webpack_require__(/*! @material/menu/component */ "./packages/mdc-menu/component.ts");
var menuConstants = __importStar(__webpack_require__(/*! @material/menu/constants */ "./packages/mdc-menu/constants.ts"));
var component_5 = __webpack_require__(/*! @material/notched-outline/component */ "./packages/mdc-notched-outline/component.ts");
var component_6 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts");
var component_7 = __webpack_require__(/*! ./helper-text/component */ "./packages/mdc-select/helper-text/component.ts");
var component_8 = __webpack_require__(/*! ./icon/component */ "./packages/mdc-select/icon/component.ts");
var MDCSelect = /** @class */function (_super) {
__extends(MDCSelect, _super);
function MDCSelect() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCSelect.attachTo = function (root) {
return new MDCSelect(root);
};
MDCSelect.prototype.initialize = function (labelFactory, lineRippleFactory, outlineFactory, menuFactory, iconFactory, helperTextFactory) {
if (labelFactory === void 0) {
labelFactory = function labelFactory(el) {
return new component_2.MDCFloatingLabel(el);
};
}
if (lineRippleFactory === void 0) {
lineRippleFactory = function lineRippleFactory(el) {
return new component_3.MDCLineRipple(el);
};
}
if (outlineFactory === void 0) {
outlineFactory = function outlineFactory(el) {
return new component_5.MDCNotchedOutline(el);
};
}
if (menuFactory === void 0) {
menuFactory = function menuFactory(el) {
return new component_4.MDCMenu(el);
};
}
if (iconFactory === void 0) {
iconFactory = function iconFactory(el) {
return new component_8.MDCSelectIcon(el);
};
}
if (helperTextFactory === void 0) {
helperTextFactory = function helperTextFactory(el) {
return new component_7.MDCSelectHelperText(el);
};
}
this.selectAnchor = this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
this.selectedText = this.root.querySelector(constants_1.strings.SELECTED_TEXT_SELECTOR);
this.hiddenInput = this.root.querySelector(constants_1.strings.HIDDEN_INPUT_SELECTOR);
if (!this.selectedText) {
throw new Error('MDCSelect: Missing required element: The following selector must be present: ' + ("'" + constants_1.strings.SELECTED_TEXT_SELECTOR + "'"));
}
if (this.selectAnchor.hasAttribute(constants_1.strings.ARIA_CONTROLS)) {
var helperTextElement = document.getElementById(this.selectAnchor.getAttribute(constants_1.strings.ARIA_CONTROLS));
if (helperTextElement) {
this.helperText = helperTextFactory(helperTextElement);
}
}
this.menuSetup(menuFactory);
var labelElement = this.root.querySelector(constants_1.strings.LABEL_SELECTOR);
this.label = labelElement ? labelFactory(labelElement) : null;
var lineRippleElement = this.root.querySelector(constants_1.strings.LINE_RIPPLE_SELECTOR);
this.lineRipple = lineRippleElement ? lineRippleFactory(lineRippleElement) : null;
var outlineElement = this.root.querySelector(constants_1.strings.OUTLINE_SELECTOR);
this.outline = outlineElement ? outlineFactory(outlineElement) : null;
var leadingIcon = this.root.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
if (leadingIcon) {
this.leadingIcon = iconFactory(leadingIcon);
}
if (!this.root.classList.contains(constants_1.cssClasses.OUTLINED)) {
this.ripple = this.createRipple();
}
};
/**
* Initializes the select's event listeners and internal state based
* on the environment's state.
*/
MDCSelect.prototype.initialSyncWithDOM = function () {
var _this = this;
this.handleFocus = function () {
_this.foundation.handleFocus();
};
this.handleBlur = function () {
_this.foundation.handleBlur();
};
this.handleClick = function (evt) {
_this.selectAnchor.focus();
_this.foundation.handleClick(_this.getNormalizedXCoordinate(evt));
};
this.handleKeydown = function (evt) {
_this.foundation.handleKeydown(evt);
};
this.handleMenuItemAction = function (evt) {
_this.foundation.handleMenuItemAction(evt.detail.index);
};
this.handleMenuOpened = function () {
_this.foundation.handleMenuOpened();
};
this.handleMenuClosed = function () {
_this.foundation.handleMenuClosed();
};
this.handleMenuClosing = function () {
_this.foundation.handleMenuClosing();
};
this.selectAnchor.addEventListener('focus', this.handleFocus);
this.selectAnchor.addEventListener('blur', this.handleBlur);
this.selectAnchor.addEventListener('click', this.handleClick);
this.selectAnchor.addEventListener('keydown', this.handleKeydown);
this.menu.listen(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
this.menu.listen(menuSurfaceConstants.strings.CLOSING_EVENT, this.handleMenuClosing);
this.menu.listen(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
this.menu.listen(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
if (this.hiddenInput) {
if (this.hiddenInput.value) {
// If the hidden input already has a value, use it to restore the
// select's value. This can happen e.g. if the user goes back or (in
// some browsers) refreshes the page.
this.foundation.setValue(this.hiddenInput.value, /** skipNotify */true);
this.foundation.layout();
return;
}
this.hiddenInput.value = this.value;
}
};
MDCSelect.prototype.destroy = function () {
this.selectAnchor.removeEventListener('focus', this.handleFocus);
this.selectAnchor.removeEventListener('blur', this.handleBlur);
this.selectAnchor.removeEventListener('keydown', this.handleKeydown);
this.selectAnchor.removeEventListener('click', this.handleClick);
this.menu.unlisten(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
this.menu.unlisten(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
this.menu.unlisten(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
this.menu.destroy();
if (this.ripple) {
this.ripple.destroy();
}
if (this.outline) {
this.outline.destroy();
}
if (this.leadingIcon) {
this.leadingIcon.destroy();
}
if (this.helperText) {
this.helperText.destroy();
}
_super.prototype.destroy.call(this);
};
Object.defineProperty(MDCSelect.prototype, "value", {
get: function get() {
return this.foundation.getValue();
},
set: function set(value) {
this.foundation.setValue(value);
},
enumerable: false,
configurable: true
});
MDCSelect.prototype.setValue = function (value, skipNotify) {
if (skipNotify === void 0) {
skipNotify = false;
}
this.foundation.setValue(value, skipNotify);
};
Object.defineProperty(MDCSelect.prototype, "selectedIndex", {
get: function get() {
return this.foundation.getSelectedIndex();
},
set: function set(selectedIndex) {
this.foundation.setSelectedIndex(selectedIndex, /* closeMenu */true);
},
enumerable: false,
configurable: true
});
MDCSelect.prototype.setSelectedIndex = function (selectedIndex, skipNotify) {
if (skipNotify === void 0) {
skipNotify = false;
}
this.foundation.setSelectedIndex(selectedIndex, /* closeMenu */true, skipNotify);
};
Object.defineProperty(MDCSelect.prototype, "disabled", {
get: function get() {
return this.foundation.getDisabled();
},
set: function set(disabled) {
this.foundation.setDisabled(disabled);
if (this.hiddenInput) {
this.hiddenInput.disabled = disabled;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelect.prototype, "leadingIconAriaLabel", {
set: function set(label) {
this.foundation.setLeadingIconAriaLabel(label);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelect.prototype, "leadingIconContent", {
/**
* Sets the text content of the leading icon.
*/
set: function set(content) {
this.foundation.setLeadingIconContent(content);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelect.prototype, "helperTextContent", {
/**
* Sets the text content of the helper text.
*/
set: function set(content) {
this.foundation.setHelperTextContent(content);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelect.prototype, "useDefaultValidation", {
/**
* Enables or disables the default validation scheme where a required select
* must be non-empty. Set to false for custom validation.
* @param useDefaultValidation Set this to false to ignore default
* validation scheme.
*/
set: function set(useDefaultValidation) {
this.foundation.setUseDefaultValidation(useDefaultValidation);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelect.prototype, "valid", {
/**
* Checks if the select is in a valid state.
*/
get: function get() {
return this.foundation.isValid();
},
/**
* Sets the current invalid state of the select.
*/
set: function set(isValid) {
this.foundation.setValid(isValid);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelect.prototype, "required", {
/**
* Returns whether the select is required.
*/
get: function get() {
return this.foundation.getRequired();
},
/**
* Sets the control to the required state.
*/
set: function set(isRequired) {
this.foundation.setRequired(isRequired);
},
enumerable: false,
configurable: true
});
/**
* Re-calculates if the notched outline should be notched and if the label
* should float.
*/
MDCSelect.prototype.layout = function () {
this.foundation.layout();
};
/**
* Synchronizes the list of options with the state of the foundation. Call
* this whenever menu options are dynamically updated.
*/
MDCSelect.prototype.layoutOptions = function () {
this.foundation.layoutOptions();
this.menu.layout();
// Update cached menuItemValues for adapter.
this.menuItemValues = this.menu.items.map(function (el) {
return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
});
if (this.hiddenInput) {
this.hiddenInput.value = this.value;
}
};
MDCSelect.prototype.getDefaultFoundation = function () {
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = __assign(__assign(__assign(__assign({}, this.getSelectAdapterMethods()), this.getCommonAdapterMethods()), this.getOutlineAdapterMethods()), this.getLabelAdapterMethods());
return new foundation_2.MDCSelectFoundation(adapter, this.getFoundationMap());
};
/**
* Handles setup for the menu.
*/
MDCSelect.prototype.menuSetup = function (menuFactory) {
this.menuElement = this.root.querySelector(constants_1.strings.MENU_SELECTOR);
this.menu = menuFactory(this.menuElement);
this.menu.hasTypeahead = true;
this.menu.singleSelection = true;
this.menuItemValues = this.menu.items.map(function (el) {
return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
});
};
MDCSelect.prototype.createRipple = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = __assign(__assign({}, component_6.MDCRipple.createAdapter({ root: this.selectAnchor })), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
_this.selectAnchor.addEventListener(evtType, handler);
}, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
_this.selectAnchor.removeEventListener(evtType, handler);
} });
// tslint:enable:object-literal-sort-keys
return new component_6.MDCRipple(this.selectAnchor, new foundation_1.MDCRippleFoundation(adapter));
};
MDCSelect.prototype.getSelectAdapterMethods = function () {
var _this = this;
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
getMenuItemAttr: function getMenuItemAttr(menuItem, attr) {
return menuItem.getAttribute(attr);
},
setSelectedText: function setSelectedText(text) {
_this.selectedText.textContent = text;
},
isSelectAnchorFocused: function isSelectAnchorFocused() {
return document.activeElement === _this.selectAnchor;
},
getSelectAnchorAttr: function getSelectAnchorAttr(attr) {
return _this.selectAnchor.getAttribute(attr);
},
setSelectAnchorAttr: function setSelectAnchorAttr(attr, value) {
_this.selectAnchor.setAttribute(attr, value);
},
removeSelectAnchorAttr: function removeSelectAnchorAttr(attr) {
_this.selectAnchor.removeAttribute(attr);
},
addMenuClass: function addMenuClass(className) {
_this.menuElement.classList.add(className);
},
removeMenuClass: function removeMenuClass(className) {
_this.menuElement.classList.remove(className);
},
openMenu: function openMenu() {
_this.menu.open = true;
},
closeMenu: function closeMenu() {
_this.menu.open = false;
},
getAnchorElement: function getAnchorElement() {
return _this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
},
setMenuAnchorElement: function setMenuAnchorElement(anchorEl) {
_this.menu.setAnchorElement(anchorEl);
},
setMenuAnchorCorner: function setMenuAnchorCorner(anchorCorner) {
_this.menu.setAnchorCorner(anchorCorner);
},
setMenuWrapFocus: function setMenuWrapFocus(wrapFocus) {
_this.menu.wrapFocus = wrapFocus;
},
getSelectedIndex: function getSelectedIndex() {
var index = _this.menu.selectedIndex;
return index instanceof Array ? index[0] : index;
},
setSelectedIndex: function setSelectedIndex(index) {
_this.menu.selectedIndex = index;
},
focusMenuItemAtIndex: function focusMenuItemAtIndex(index) {
_this.menu.items[index].focus();
},
getMenuItemCount: function getMenuItemCount() {
return _this.menu.items.length;
},
// Cache menu item values. layoutOptions() updates this cache.
getMenuItemValues: function getMenuItemValues() {
return _this.menuItemValues;
},
getMenuItemTextAtIndex: function getMenuItemTextAtIndex(index) {
return _this.menu.getPrimaryTextAtIndex(index);
},
isTypeaheadInProgress: function isTypeaheadInProgress() {
return _this.menu.typeaheadInProgress;
},
typeaheadMatchItem: function typeaheadMatchItem(nextChar, startingIndex) {
return _this.menu.typeaheadMatchItem(nextChar, startingIndex);
}
};
// tslint:enable:object-literal-sort-keys
};
MDCSelect.prototype.getCommonAdapterMethods = function () {
var _this = this;
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass(className) {
_this.root.classList.add(className);
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
setRippleCenter: function setRippleCenter(normalizedX) {
_this.lineRipple && _this.lineRipple.setRippleCenter(normalizedX);
},
activateBottomLine: function activateBottomLine() {
_this.lineRipple && _this.lineRipple.activate();
},
deactivateBottomLine: function deactivateBottomLine() {
_this.lineRipple && _this.lineRipple.deactivate();
},
notifyChange: function notifyChange(value) {
if (_this.hiddenInput) {
_this.hiddenInput.value = value;
}
var index = _this.selectedIndex;
_this.emit(constants_1.strings.CHANGE_EVENT, { value: value, index: index }, true /* shouldBubble */);
}
};
// tslint:enable:object-literal-sort-keys
};
MDCSelect.prototype.getOutlineAdapterMethods = function () {
var _this = this;
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
hasOutline: function hasOutline() {
return Boolean(_this.outline);
},
notchOutline: function notchOutline(labelWidth) {
_this.outline && _this.outline.notch(labelWidth);
},
closeOutline: function closeOutline() {
_this.outline && _this.outline.closeNotch();
}
};
// tslint:enable:object-literal-sort-keys
};
MDCSelect.prototype.getLabelAdapterMethods = function () {
var _this = this;
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
hasLabel: function hasLabel() {
return !!_this.label;
},
floatLabel: function floatLabel(shouldFloat) {
_this.label && _this.label.float(shouldFloat);
},
getLabelWidth: function getLabelWidth() {
return _this.label ? _this.label.getWidth() : 0;
},
setLabelRequired: function setLabelRequired(isRequired) {
_this.label && _this.label.setRequired(isRequired);
}
};
// tslint:enable:object-literal-sort-keys
};
/**
* Calculates where the line ripple should start based on the x coordinate within the component.
*/
MDCSelect.prototype.getNormalizedXCoordinate = function (evt) {
var targetClientRect = evt.target.getBoundingClientRect();
var xCoordinate = this.isTouchEvent(evt) ? evt.touches[0].clientX : evt.clientX;
return xCoordinate - targetClientRect.left;
};
MDCSelect.prototype.isTouchEvent = function (evt) {
return Boolean(evt.touches);
};
/**
* Returns a map of all subcomponents to subfoundations.
*/
MDCSelect.prototype.getFoundationMap = function () {
return {
helperText: this.helperText ? this.helperText.foundationForSelect : undefined,
leadingIcon: this.leadingIcon ? this.leadingIcon.foundationForSelect : undefined
};
};
return MDCSelect;
}(component_1.MDCComponent);
exports.MDCSelect = MDCSelect;
/***/ }),
/***/ "./packages/mdc-select/constants.ts":
/*!******************************************!*\
!*** ./packages/mdc-select/constants.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.numbers = exports.strings = exports.cssClasses = void 0;
var cssClasses = {
ACTIVATED: 'mdc-select--activated',
DISABLED: 'mdc-select--disabled',
FOCUSED: 'mdc-select--focused',
INVALID: 'mdc-select--invalid',
MENU_INVALID: 'mdc-select__menu--invalid',
OUTLINED: 'mdc-select--outlined',
REQUIRED: 'mdc-select--required',
ROOT: 'mdc-select',
WITH_LEADING_ICON: 'mdc-select--with-leading-icon'
};
exports.cssClasses = cssClasses;
var strings = {
ARIA_CONTROLS: 'aria-controls',
ARIA_DESCRIBEDBY: 'aria-describedby',
ARIA_SELECTED_ATTR: 'aria-selected',
CHANGE_EVENT: 'MDCSelect:change',
HIDDEN_INPUT_SELECTOR: 'input[type="hidden"]',
LABEL_SELECTOR: '.mdc-floating-label',
LEADING_ICON_SELECTOR: '.mdc-select__icon',
LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
MENU_SELECTOR: '.mdc-select__menu',
OUTLINE_SELECTOR: '.mdc-notched-outline',
SELECTED_TEXT_SELECTOR: '.mdc-select__selected-text',
SELECT_ANCHOR_SELECTOR: '.mdc-select__anchor',
VALUE_ATTR: 'data-value'
};
exports.strings = strings;
var numbers = {
LABEL_SCALE: 0.75,
UNSET_INDEX: -1,
CLICK_DEBOUNCE_TIMEOUT_MS: 330
};
exports.numbers = numbers;
/***/ }),
/***/ "./packages/mdc-select/foundation.ts":
/*!*******************************************!*\
!*** ./packages/mdc-select/foundation.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSelectFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
var constants_1 = __webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts");
var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
var MDCSelectFoundation = /** @class */function (_super) {
__extends(MDCSelectFoundation, _super);
/* istanbul ignore next: optional argument is not a branch statement */
/**
* @param adapter
* @param foundationMap Map from subcomponent names to their subfoundations.
*/
function MDCSelectFoundation(adapter, foundationMap) {
if (foundationMap === void 0) {
foundationMap = {};
}
var _this = _super.call(this, __assign(__assign({}, MDCSelectFoundation.defaultAdapter), adapter)) || this;
// Disabled state
_this.disabled = false;
// isMenuOpen is used to track the state of the menu by listening to the
// MDCMenuSurface:closed event For reference, menu.open will return false if
// the menu is still closing, but isMenuOpen returns false only after the menu
// has closed
_this.isMenuOpen = false;
// By default, select is invalid if it is required but no value is selected.
_this.useDefaultValidation = true;
_this.customValidity = true;
_this.lastSelectedIndex = constants_2.numbers.UNSET_INDEX;
_this.clickDebounceTimeout = 0;
_this.recentlyClicked = false;
_this.leadingIcon = foundationMap.leadingIcon;
_this.helperText = foundationMap.helperText;
return _this;
}
Object.defineProperty(MDCSelectFoundation, "cssClasses", {
get: function get() {
return constants_2.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelectFoundation, "numbers", {
get: function get() {
return constants_2.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelectFoundation, "strings", {
get: function get() {
return constants_2.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelectFoundation, "defaultAdapter", {
/**
* See {@link MDCSelectAdapter} for typing information on parameters and return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
hasClass: function hasClass() {
return false;
},
activateBottomLine: function activateBottomLine() {
return undefined;
},
deactivateBottomLine: function deactivateBottomLine() {
return undefined;
},
getSelectedIndex: function getSelectedIndex() {
return -1;
},
setSelectedIndex: function setSelectedIndex() {
return undefined;
},
hasLabel: function hasLabel() {
return false;
},
floatLabel: function floatLabel() {
return undefined;
},
getLabelWidth: function getLabelWidth() {
return 0;
},
setLabelRequired: function setLabelRequired() {
return undefined;
},
hasOutline: function hasOutline() {
return false;
},
notchOutline: function notchOutline() {
return undefined;
},
closeOutline: function closeOutline() {
return undefined;
},
setRippleCenter: function setRippleCenter() {
return undefined;
},
notifyChange: function notifyChange() {
return undefined;
},
setSelectedText: function setSelectedText() {
return undefined;
},
isSelectAnchorFocused: function isSelectAnchorFocused() {
return false;
},
getSelectAnchorAttr: function getSelectAnchorAttr() {
return '';
},
setSelectAnchorAttr: function setSelectAnchorAttr() {
return undefined;
},
removeSelectAnchorAttr: function removeSelectAnchorAttr() {
return undefined;
},
addMenuClass: function addMenuClass() {
return undefined;
},
removeMenuClass: function removeMenuClass() {
return undefined;
},
openMenu: function openMenu() {
return undefined;
},
closeMenu: function closeMenu() {
return undefined;
},
getAnchorElement: function getAnchorElement() {
return null;
},
setMenuAnchorElement: function setMenuAnchorElement() {
return undefined;
},
setMenuAnchorCorner: function setMenuAnchorCorner() {
return undefined;
},
setMenuWrapFocus: function setMenuWrapFocus() {
return undefined;
},
focusMenuItemAtIndex: function focusMenuItemAtIndex() {
return undefined;
},
getMenuItemCount: function getMenuItemCount() {
return 0;
},
getMenuItemValues: function getMenuItemValues() {
return [];
},
getMenuItemTextAtIndex: function getMenuItemTextAtIndex() {
return '';
},
isTypeaheadInProgress: function isTypeaheadInProgress() {
return false;
},
typeaheadMatchItem: function typeaheadMatchItem() {
return -1;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
/** Returns the index of the currently selected menu item, or -1 if none. */
MDCSelectFoundation.prototype.getSelectedIndex = function () {
return this.adapter.getSelectedIndex();
};
MDCSelectFoundation.prototype.setSelectedIndex = function (index, closeMenu, skipNotify) {
if (closeMenu === void 0) {
closeMenu = false;
}
if (skipNotify === void 0) {
skipNotify = false;
}
if (index >= this.adapter.getMenuItemCount()) {
return;
}
if (index === constants_2.numbers.UNSET_INDEX) {
this.adapter.setSelectedText('');
} else {
this.adapter.setSelectedText(this.adapter.getMenuItemTextAtIndex(index).trim());
}
this.adapter.setSelectedIndex(index);
if (closeMenu) {
this.adapter.closeMenu();
}
if (!skipNotify && this.lastSelectedIndex !== index) {
this.handleChange();
}
this.lastSelectedIndex = index;
};
MDCSelectFoundation.prototype.setValue = function (value, skipNotify) {
if (skipNotify === void 0) {
skipNotify = false;
}
var index = this.adapter.getMenuItemValues().indexOf(value);
this.setSelectedIndex(index, /** closeMenu */false, skipNotify);
};
MDCSelectFoundation.prototype.getValue = function () {
var index = this.adapter.getSelectedIndex();
var menuItemValues = this.adapter.getMenuItemValues();
return index !== constants_2.numbers.UNSET_INDEX ? menuItemValues[index] : '';
};
MDCSelectFoundation.prototype.getDisabled = function () {
return this.disabled;
};
MDCSelectFoundation.prototype.setDisabled = function (isDisabled) {
this.disabled = isDisabled;
if (this.disabled) {
this.adapter.addClass(constants_2.cssClasses.DISABLED);
this.adapter.closeMenu();
} else {
this.adapter.removeClass(constants_2.cssClasses.DISABLED);
}
if (this.leadingIcon) {
this.leadingIcon.setDisabled(this.disabled);
}
if (this.disabled) {
// Prevent click events from focusing select. Simply pointer-events: none
// is not enough since screenreader clicks may bypass this.
this.adapter.removeSelectAnchorAttr('tabindex');
} else {
this.adapter.setSelectAnchorAttr('tabindex', '0');
}
this.adapter.setSelectAnchorAttr('aria-disabled', this.disabled.toString());
};
/** Opens the menu. */
MDCSelectFoundation.prototype.openMenu = function () {
this.adapter.addClass(constants_2.cssClasses.ACTIVATED);
this.adapter.openMenu();
this.isMenuOpen = true;
this.adapter.setSelectAnchorAttr('aria-expanded', 'true');
};
/**
* @param content Sets the content of the helper text.
*/
MDCSelectFoundation.prototype.setHelperTextContent = function (content) {
if (this.helperText) {
this.helperText.setContent(content);
}
};
/**
* Re-calculates if the notched outline should be notched and if the label
* should float.
*/
MDCSelectFoundation.prototype.layout = function () {
if (this.adapter.hasLabel()) {
var optionHasValue = this.getValue().length > 0;
var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
var shouldFloatAndNotch = optionHasValue || isFocused;
var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
this.notchOutline(shouldFloatAndNotch);
this.adapter.floatLabel(shouldFloatAndNotch);
this.adapter.setLabelRequired(isRequired);
}
};
/**
* Synchronizes the list of options with the state of the foundation. Call
* this whenever menu options are dynamically updated.
*/
MDCSelectFoundation.prototype.layoutOptions = function () {
var menuItemValues = this.adapter.getMenuItemValues();
var selectedIndex = menuItemValues.indexOf(this.getValue());
this.setSelectedIndex(selectedIndex, /** closeMenu */false, /** skipNotify */true);
};
MDCSelectFoundation.prototype.handleMenuOpened = function () {
if (this.adapter.getMenuItemValues().length === 0) {
return;
}
// Menu should open to the last selected element, should open to first menu item otherwise.
var selectedIndex = this.getSelectedIndex();
var focusItemIndex = selectedIndex >= 0 ? selectedIndex : 0;
this.adapter.focusMenuItemAtIndex(focusItemIndex);
};
MDCSelectFoundation.prototype.handleMenuClosing = function () {
this.adapter.setSelectAnchorAttr('aria-expanded', 'false');
};
MDCSelectFoundation.prototype.handleMenuClosed = function () {
this.adapter.removeClass(constants_2.cssClasses.ACTIVATED);
this.isMenuOpen = false;
// Unfocus the select if menu is closed without a selection
if (!this.adapter.isSelectAnchorFocused()) {
this.blur();
}
};
/**
* Handles value changes, via change event or programmatic updates.
*/
MDCSelectFoundation.prototype.handleChange = function () {
this.layout();
this.adapter.notifyChange(this.getValue());
var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
if (isRequired && this.useDefaultValidation) {
this.setValid(this.isValid());
}
};
MDCSelectFoundation.prototype.handleMenuItemAction = function (index) {
this.setSelectedIndex(index, /** closeMenu */true);
};
/**
* Handles focus events from select element.
*/
MDCSelectFoundation.prototype.handleFocus = function () {
this.adapter.addClass(constants_2.cssClasses.FOCUSED);
this.layout();
this.adapter.activateBottomLine();
};
/**
* Handles blur events from select element.
*/
MDCSelectFoundation.prototype.handleBlur = function () {
if (this.isMenuOpen) {
return;
}
this.blur();
};
MDCSelectFoundation.prototype.handleClick = function (normalizedX) {
if (this.disabled || this.recentlyClicked) {
return;
}
this.setClickDebounceTimeout();
if (this.isMenuOpen) {
this.adapter.closeMenu();
return;
}
this.adapter.setRippleCenter(normalizedX);
this.openMenu();
};
/**
* Handles keydown events on select element. Depending on the type of
* character typed, does typeahead matching or opens menu.
*/
MDCSelectFoundation.prototype.handleKeydown = function (event) {
if (this.isMenuOpen || !this.adapter.hasClass(constants_2.cssClasses.FOCUSED)) {
return;
}
var isEnter = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ENTER;
var isSpace = keyboard_1.normalizeKey(event) === keyboard_1.KEY.SPACEBAR;
var arrowUp = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_UP;
var arrowDown = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_DOWN;
var isModifier = event.ctrlKey || event.metaKey;
// Typeahead
if (!isModifier && (!isSpace && event.key && event.key.length === 1 || isSpace && this.adapter.isTypeaheadInProgress())) {
var key = isSpace ? ' ' : event.key;
var typeaheadNextIndex = this.adapter.typeaheadMatchItem(key, this.getSelectedIndex());
if (typeaheadNextIndex >= 0) {
this.setSelectedIndex(typeaheadNextIndex);
}
event.preventDefault();
return;
}
if (!isEnter && !isSpace && !arrowUp && !arrowDown) {
return;
}
this.openMenu();
event.preventDefault();
};
/**
* Opens/closes the notched outline.
*/
MDCSelectFoundation.prototype.notchOutline = function (openNotch) {
if (!this.adapter.hasOutline()) {
return;
}
var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
if (openNotch) {
var labelScale = constants_2.numbers.LABEL_SCALE;
var labelWidth = this.adapter.getLabelWidth() * labelScale;
this.adapter.notchOutline(labelWidth);
} else if (!isFocused) {
this.adapter.closeOutline();
}
};
/**
* Sets the aria label of the leading icon.
*/
MDCSelectFoundation.prototype.setLeadingIconAriaLabel = function (label) {
if (this.leadingIcon) {
this.leadingIcon.setAriaLabel(label);
}
};
/**
* Sets the text content of the leading icon.
*/
MDCSelectFoundation.prototype.setLeadingIconContent = function (content) {
if (this.leadingIcon) {
this.leadingIcon.setContent(content);
}
};
MDCSelectFoundation.prototype.getUseDefaultValidation = function () {
return this.useDefaultValidation;
};
MDCSelectFoundation.prototype.setUseDefaultValidation = function (useDefaultValidation) {
this.useDefaultValidation = useDefaultValidation;
};
MDCSelectFoundation.prototype.setValid = function (isValid) {
if (!this.useDefaultValidation) {
this.customValidity = isValid;
}
this.adapter.setSelectAnchorAttr('aria-invalid', (!isValid).toString());
if (isValid) {
this.adapter.removeClass(constants_2.cssClasses.INVALID);
this.adapter.removeMenuClass(constants_2.cssClasses.MENU_INVALID);
} else {
this.adapter.addClass(constants_2.cssClasses.INVALID);
this.adapter.addMenuClass(constants_2.cssClasses.MENU_INVALID);
}
this.syncHelperTextValidity(isValid);
};
MDCSelectFoundation.prototype.isValid = function () {
if (this.useDefaultValidation && this.adapter.hasClass(constants_2.cssClasses.REQUIRED) && !this.adapter.hasClass(constants_2.cssClasses.DISABLED)) {
// See notes for required attribute under https://www.w3.org/TR/html52/sec-forms.html#the-select-element
// TL;DR: Invalid if no index is selected, or if the first index is selected and has an empty value.
return this.getSelectedIndex() !== constants_2.numbers.UNSET_INDEX && (this.getSelectedIndex() !== 0 || Boolean(this.getValue()));
}
return this.customValidity;
};
MDCSelectFoundation.prototype.setRequired = function (isRequired) {
if (isRequired) {
this.adapter.addClass(constants_2.cssClasses.REQUIRED);
} else {
this.adapter.removeClass(constants_2.cssClasses.REQUIRED);
}
this.adapter.setSelectAnchorAttr('aria-required', isRequired.toString());
this.adapter.setLabelRequired(isRequired);
};
MDCSelectFoundation.prototype.getRequired = function () {
return this.adapter.getSelectAnchorAttr('aria-required') === 'true';
};
MDCSelectFoundation.prototype.init = function () {
var anchorEl = this.adapter.getAnchorElement();
if (anchorEl) {
this.adapter.setMenuAnchorElement(anchorEl);
this.adapter.setMenuAnchorCorner(constants_1.Corner.BOTTOM_START);
}
this.adapter.setMenuWrapFocus(false);
this.setDisabled(this.adapter.hasClass(constants_2.cssClasses.DISABLED));
this.syncHelperTextValidity(!this.adapter.hasClass(constants_2.cssClasses.INVALID));
this.layout();
this.layoutOptions();
};
/**
* Unfocuses the select component.
*/
MDCSelectFoundation.prototype.blur = function () {
this.adapter.removeClass(constants_2.cssClasses.FOCUSED);
this.layout();
this.adapter.deactivateBottomLine();
var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
if (isRequired && this.useDefaultValidation) {
this.setValid(this.isValid());
}
};
MDCSelectFoundation.prototype.syncHelperTextValidity = function (isValid) {
if (!this.helperText) {
return;
}
this.helperText.setValidity(isValid);
var helperTextVisible = this.helperText.isVisible();
var helperTextId = this.helperText.getId();
if (helperTextVisible && helperTextId) {
this.adapter.setSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY, helperTextId);
} else {
// Needed because screenreaders will read labels pointed to by
// `aria-describedby` even if they are `aria-hidden`.
this.adapter.removeSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY);
}
};
MDCSelectFoundation.prototype.setClickDebounceTimeout = function () {
var _this = this;
clearTimeout(this.clickDebounceTimeout);
this.clickDebounceTimeout = setTimeout(function () {
_this.recentlyClicked = false;
}, constants_2.numbers.CLICK_DEBOUNCE_TIMEOUT_MS);
this.recentlyClicked = true;
};
return MDCSelectFoundation;
}(foundation_1.MDCFoundation);
exports.MDCSelectFoundation = MDCSelectFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCSelectFoundation;
/***/ }),
/***/ "./packages/mdc-select/helper-text/adapter.ts":
/*!****************************************************!*\
!*** ./packages/mdc-select/helper-text/adapter.ts ***!
\****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-select/helper-text/component.ts":
/*!******************************************************!*\
!*** ./packages/mdc-select/helper-text/component.ts ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSelectHelperText = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/helper-text/foundation.ts");
var MDCSelectHelperText = /** @class */function (_super) {
__extends(MDCSelectHelperText, _super);
function MDCSelectHelperText() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCSelectHelperText.attachTo = function (root) {
return new MDCSelectHelperText(root);
};
Object.defineProperty(MDCSelectHelperText.prototype, "foundationForSelect", {
// Provided for access by MDCSelect component
get: function get() {
return this.foundation;
},
enumerable: false,
configurable: true
});
MDCSelectHelperText.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
getAttr: function getAttr(attr) {
return _this.root.getAttribute(attr);
},
setAttr: function setAttr(attr, value) {
return _this.root.setAttribute(attr, value);
},
removeAttr: function removeAttr(attr) {
return _this.root.removeAttribute(attr);
},
setContent: function setContent(content) {
_this.root.textContent = content;
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_1.MDCSelectHelperTextFoundation(adapter);
};
return MDCSelectHelperText;
}(component_1.MDCComponent);
exports.MDCSelectHelperText = MDCSelectHelperText;
/***/ }),
/***/ "./packages/mdc-select/helper-text/constants.ts":
/*!******************************************************!*\
!*** ./packages/mdc-select/helper-text/constants.ts ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssClasses = exports.strings = void 0;
var strings = {
ARIA_HIDDEN: 'aria-hidden',
ROLE: 'role'
};
exports.strings = strings;
var cssClasses = {
HELPER_TEXT_VALIDATION_MSG: 'mdc-select-helper-text--validation-msg',
HELPER_TEXT_VALIDATION_MSG_PERSISTENT: 'mdc-select-helper-text--validation-msg-persistent'
};
exports.cssClasses = cssClasses;
/***/ }),
/***/ "./packages/mdc-select/helper-text/foundation.ts":
/*!*******************************************************!*\
!*** ./packages/mdc-select/helper-text/foundation.ts ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSelectHelperTextFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/helper-text/constants.ts");
var MDCSelectHelperTextFoundation = /** @class */function (_super) {
__extends(MDCSelectHelperTextFoundation, _super);
function MDCSelectHelperTextFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCSelectHelperTextFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCSelectHelperTextFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelectHelperTextFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelectHelperTextFoundation, "defaultAdapter", {
/**
* See {@link MDCSelectHelperTextAdapter} for typing information on parameters and return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
hasClass: function hasClass() {
return false;
},
setAttr: function setAttr() {
return undefined;
},
getAttr: function getAttr() {
return null;
},
removeAttr: function removeAttr() {
return undefined;
},
setContent: function setContent() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
/**
* @return The ID of the helper text, or null if none is set.
*/
MDCSelectHelperTextFoundation.prototype.getId = function () {
return this.adapter.getAttr('id');
};
/**
* @return Whether the helper text is currently visible.
*/
MDCSelectHelperTextFoundation.prototype.isVisible = function () {
return this.adapter.getAttr(constants_1.strings.ARIA_HIDDEN) !== 'true';
};
/**
* Sets the content of the helper text field.
*/
MDCSelectHelperTextFoundation.prototype.setContent = function (content) {
this.adapter.setContent(content);
};
/**
* Sets the helper text to act as a validation message.
* By default, validation messages are hidden when the select is valid and
* visible when the select is invalid.
*
* @param isValidation True to make the helper text act as an error validation
* message.
*/
MDCSelectHelperTextFoundation.prototype.setValidation = function (isValidation) {
if (isValidation) {
this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
} else {
this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
}
};
/**
* Sets the persistency of the validation helper text.
* This keeps the validation message visible even if the select is valid,
* though it will be displayed in the normal (grey) color.
*/
MDCSelectHelperTextFoundation.prototype.setValidationMsgPersistent = function (isPersistent) {
if (isPersistent) {
this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
} else {
this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
}
};
/**
* @return Whether the helper text acts as a validation message.
* By default, validation messages are hidden when the select is valid and
* visible when the select is invalid.
*/
MDCSelectHelperTextFoundation.prototype.getIsValidation = function () {
return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
};
/**
* @return Whether the validation helper text persists even if the input is
* valid. If it is, it will be displayed in the normal (grey) color.
*/
MDCSelectHelperTextFoundation.prototype.getIsValidationMsgPersistent = function () {
return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
};
/**
* When acting as a validation message, shows/hides the helper text and
* triggers alerts as necessary based on the select's validity.
*/
MDCSelectHelperTextFoundation.prototype.setValidity = function (selectIsValid) {
var isValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
if (!isValidationMsg) {
// Non-validating helper-text is always displayed and does not participate
// in validation logic.
return;
}
var isPersistentValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
// Validating helper text is displayed if select is invalid, unless it is
// set as persistent, in which case it always displays.
var msgShouldDisplay = !selectIsValid || isPersistentValidationMsg;
if (msgShouldDisplay) {
this.showToScreenReader();
// In addition to displaying, also trigger an alert if the select
// has become invalid.
if (!selectIsValid) {
this.adapter.setAttr(constants_1.strings.ROLE, 'alert');
} else {
this.adapter.removeAttr(constants_1.strings.ROLE);
}
return;
}
// Hide everything.
this.adapter.removeAttr(constants_1.strings.ROLE);
this.hide();
};
/**
* Makes the helper text visible to screen readers.
*/
MDCSelectHelperTextFoundation.prototype.showToScreenReader = function () {
this.adapter.removeAttr(constants_1.strings.ARIA_HIDDEN);
};
/**
* Hides the help text from screen readers.
*/
MDCSelectHelperTextFoundation.prototype.hide = function () {
this.adapter.setAttr(constants_1.strings.ARIA_HIDDEN, 'true');
};
return MDCSelectHelperTextFoundation;
}(foundation_1.MDCFoundation);
exports.MDCSelectHelperTextFoundation = MDCSelectHelperTextFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCSelectHelperTextFoundation;
/***/ }),
/***/ "./packages/mdc-select/helper-text/index.ts":
/*!**************************************************!*\
!*** ./packages/mdc-select/helper-text/index.ts ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.helperTextStrings = exports.helperTextCssClasses = void 0;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-select/helper-text/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-select/helper-text/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/helper-text/foundation.ts"), exports);
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/helper-text/constants.ts");
Object.defineProperty(exports, "helperTextCssClasses", { enumerable: true, get: function get() {
return constants_1.cssClasses;
} });
Object.defineProperty(exports, "helperTextStrings", { enumerable: true, get: function get() {
return constants_1.strings;
} });
/***/ }),
/***/ "./packages/mdc-select/icon/adapter.ts":
/*!*********************************************!*\
!*** ./packages/mdc-select/icon/adapter.ts ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-select/icon/component.ts":
/*!***********************************************!*\
!*** ./packages/mdc-select/icon/component.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSelectIcon = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/icon/foundation.ts");
var MDCSelectIcon = /** @class */function (_super) {
__extends(MDCSelectIcon, _super);
function MDCSelectIcon() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCSelectIcon.attachTo = function (root) {
return new MDCSelectIcon(root);
};
Object.defineProperty(MDCSelectIcon.prototype, "foundationForSelect", {
// Provided for access by MDCSelect component
get: function get() {
return this.foundation;
},
enumerable: false,
configurable: true
});
MDCSelectIcon.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
getAttr: function getAttr(attr) {
return _this.root.getAttribute(attr);
},
setAttr: function setAttr(attr, value) {
return _this.root.setAttribute(attr, value);
},
removeAttr: function removeAttr(attr) {
return _this.root.removeAttribute(attr);
},
setContent: function setContent(content) {
_this.root.textContent = content;
},
registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
return _this.listen(evtType, handler);
},
deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
return _this.unlisten(evtType, handler);
},
notifyIconAction: function notifyIconAction() {
return _this.emit(foundation_1.MDCSelectIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */);
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_1.MDCSelectIconFoundation(adapter);
};
return MDCSelectIcon;
}(component_1.MDCComponent);
exports.MDCSelectIcon = MDCSelectIcon;
/***/ }),
/***/ "./packages/mdc-select/icon/constants.ts":
/*!***********************************************!*\
!*** ./packages/mdc-select/icon/constants.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = void 0;
var strings = {
ICON_EVENT: 'MDCSelect:icon',
ICON_ROLE: 'button'
};
exports.strings = strings;
/***/ }),
/***/ "./packages/mdc-select/icon/foundation.ts":
/*!************************************************!*\
!*** ./packages/mdc-select/icon/foundation.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSelectIconFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/icon/constants.ts");
var INTERACTION_EVENTS = ['click', 'keydown'];
var MDCSelectIconFoundation = /** @class */function (_super) {
__extends(MDCSelectIconFoundation, _super);
function MDCSelectIconFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCSelectIconFoundation.defaultAdapter), adapter)) || this;
_this.savedTabIndex = null;
_this.interactionHandler = function (evt) {
_this.handleInteraction(evt);
};
return _this;
}
Object.defineProperty(MDCSelectIconFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSelectIconFoundation, "defaultAdapter", {
/**
* See {@link MDCSelectIconAdapter} for typing information on parameters and return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
getAttr: function getAttr() {
return null;
},
setAttr: function setAttr() {
return undefined;
},
removeAttr: function removeAttr() {
return undefined;
},
setContent: function setContent() {
return undefined;
},
registerInteractionHandler: function registerInteractionHandler() {
return undefined;
},
deregisterInteractionHandler: function deregisterInteractionHandler() {
return undefined;
},
notifyIconAction: function notifyIconAction() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCSelectIconFoundation.prototype.init = function () {
var e_1, _a;
this.savedTabIndex = this.adapter.getAttr('tabindex');
try {
for (var INTERACTION_EVENTS_1 = __values(INTERACTION_EVENTS), INTERACTION_EVENTS_1_1 = INTERACTION_EVENTS_1.next(); !INTERACTION_EVENTS_1_1.done; INTERACTION_EVENTS_1_1 = INTERACTION_EVENTS_1.next()) {
var evtType = INTERACTION_EVENTS_1_1.value;
this.adapter.registerInteractionHandler(evtType, this.interactionHandler);
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (INTERACTION_EVENTS_1_1 && !INTERACTION_EVENTS_1_1.done && (_a = INTERACTION_EVENTS_1.return)) _a.call(INTERACTION_EVENTS_1);
} finally {
if (e_1) throw e_1.error;
}
}
};
MDCSelectIconFoundation.prototype.destroy = function () {
var e_2, _a;
try {
for (var INTERACTION_EVENTS_2 = __values(INTERACTION_EVENTS), INTERACTION_EVENTS_2_1 = INTERACTION_EVENTS_2.next(); !INTERACTION_EVENTS_2_1.done; INTERACTION_EVENTS_2_1 = INTERACTION_EVENTS_2.next()) {
var evtType = INTERACTION_EVENTS_2_1.value;
this.adapter.deregisterInteractionHandler(evtType, this.interactionHandler);
}
} catch (e_2_1) {
e_2 = { error: e_2_1 };
} finally {
try {
if (INTERACTION_EVENTS_2_1 && !INTERACTION_EVENTS_2_1.done && (_a = INTERACTION_EVENTS_2.return)) _a.call(INTERACTION_EVENTS_2);
} finally {
if (e_2) throw e_2.error;
}
}
};
MDCSelectIconFoundation.prototype.setDisabled = function (disabled) {
if (!this.savedTabIndex) {
return;
}
if (disabled) {
this.adapter.setAttr('tabindex', '-1');
this.adapter.removeAttr('role');
} else {
this.adapter.setAttr('tabindex', this.savedTabIndex);
this.adapter.setAttr('role', constants_1.strings.ICON_ROLE);
}
};
MDCSelectIconFoundation.prototype.setAriaLabel = function (label) {
this.adapter.setAttr('aria-label', label);
};
MDCSelectIconFoundation.prototype.setContent = function (content) {
this.adapter.setContent(content);
};
MDCSelectIconFoundation.prototype.handleInteraction = function (evt) {
var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13;
if (evt.type === 'click' || isEnterKey) {
this.adapter.notifyIconAction();
}
};
return MDCSelectIconFoundation;
}(foundation_1.MDCFoundation);
exports.MDCSelectIconFoundation = MDCSelectIconFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCSelectIconFoundation;
/***/ }),
/***/ "./packages/mdc-select/icon/index.ts":
/*!*******************************************!*\
!*** ./packages/mdc-select/icon/index.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.iconStrings = void 0;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-select/icon/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-select/icon/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/icon/foundation.ts"), exports);
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/icon/constants.ts");
Object.defineProperty(exports, "iconStrings", { enumerable: true, get: function get() {
return constants_1.strings;
} });
/***/ }),
/***/ "./packages/mdc-select/index.ts":
/*!**************************************!*\
!*** ./packages/mdc-select/index.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-select/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-select/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-select/types.ts"), exports);
__exportStar(__webpack_require__(/*! ./helper-text/index */ "./packages/mdc-select/helper-text/index.ts"), exports);
__exportStar(__webpack_require__(/*! ./icon/index */ "./packages/mdc-select/icon/index.ts"), exports);
/***/ }),
/***/ "./packages/mdc-select/types.ts":
/*!**************************************!*\
!*** ./packages/mdc-select/types.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-slider/adapter.ts":
/*!****************************************!*\
!*** ./packages/mdc-slider/adapter.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-slider/component.ts":
/*!******************************************!*\
!*** ./packages/mdc-slider/component.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSlider = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-slider/foundation.ts");
var types_1 = __webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts");
/** Vanilla JS implementation of slider component. */
var MDCSlider = /** @class */function (_super) {
__extends(MDCSlider, _super);
function MDCSlider() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.skipInitialUIUpdate = false;
// Function that maps a slider value to the value of the `aria-valuetext`
// attribute on the thumb element.
_this.valueToAriaValueTextFn = null;
return _this;
}
MDCSlider.attachTo = function (root, options) {
if (options === void 0) {
options = {};
}
return new MDCSlider(root, undefined, options);
};
MDCSlider.prototype.getDefaultFoundation = function () {
var _this = this;
// tslint:disable:object-literal-sort-keys Methods should be in the same
// order as the adapter interface.
var adapter = {
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
addClass: function addClass(className) {
_this.root.classList.add(className);
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
addThumbClass: function addThumbClass(className, thumb) {
_this.getThumbEl(thumb).classList.add(className);
},
removeThumbClass: function removeThumbClass(className, thumb) {
_this.getThumbEl(thumb).classList.remove(className);
},
getAttribute: function getAttribute(attribute) {
return _this.root.getAttribute(attribute);
},
getInputValue: function getInputValue(thumb) {
return _this.getInput(thumb).value;
},
setInputValue: function setInputValue(value, thumb) {
_this.getInput(thumb).value = value;
},
getInputAttribute: function getInputAttribute(attribute, thumb) {
return _this.getInput(thumb).getAttribute(attribute);
},
setInputAttribute: function setInputAttribute(attribute, value, thumb) {
_this.getInput(thumb).setAttribute(attribute, value);
},
removeInputAttribute: function removeInputAttribute(attribute, thumb) {
_this.getInput(thumb).removeAttribute(attribute);
},
focusInput: function focusInput(thumb) {
_this.getInput(thumb).focus();
},
isInputFocused: function isInputFocused(thumb) {
return _this.getInput(thumb) === document.activeElement;
},
shouldHideFocusStylesForPointerEvents: function shouldHideFocusStylesForPointerEvents() {
return false;
},
getThumbKnobWidth: function getThumbKnobWidth(thumb) {
return _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.THUMB_KNOB).getBoundingClientRect().width;
},
getThumbBoundingClientRect: function getThumbBoundingClientRect(thumb) {
return _this.getThumbEl(thumb).getBoundingClientRect();
},
getBoundingClientRect: function getBoundingClientRect() {
return _this.root.getBoundingClientRect();
},
getValueIndicatorContainerWidth: function getValueIndicatorContainerWidth(thumb) {
return _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.VALUE_INDICATOR_CONTAINER).getBoundingClientRect().width;
},
isRTL: function isRTL() {
return getComputedStyle(_this.root).direction === 'rtl';
},
setThumbStyleProperty: function setThumbStyleProperty(propertyName, value, thumb) {
_this.getThumbEl(thumb).style.setProperty(propertyName, value);
},
removeThumbStyleProperty: function removeThumbStyleProperty(propertyName, thumb) {
_this.getThumbEl(thumb).style.removeProperty(propertyName);
},
setTrackActiveStyleProperty: function setTrackActiveStyleProperty(propertyName, value) {
_this.trackActive.style.setProperty(propertyName, value);
},
removeTrackActiveStyleProperty: function removeTrackActiveStyleProperty(propertyName) {
_this.trackActive.style.removeProperty(propertyName);
},
setValueIndicatorText: function setValueIndicatorText(value, thumb) {
var valueIndicatorEl = _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.VALUE_INDICATOR_TEXT);
valueIndicatorEl.textContent = String(value);
},
getValueToAriaValueTextFn: function getValueToAriaValueTextFn() {
return _this.valueToAriaValueTextFn;
},
updateTickMarks: function updateTickMarks(tickMarks) {
var tickMarksContainer = _this.root.querySelector("." + constants_1.cssClasses.TICK_MARKS_CONTAINER);
if (!tickMarksContainer) {
tickMarksContainer = document.createElement('div');
tickMarksContainer.classList.add(constants_1.cssClasses.TICK_MARKS_CONTAINER);
var track = _this.root.querySelector("." + constants_1.cssClasses.TRACK);
track.appendChild(tickMarksContainer);
}
if (tickMarks.length !== tickMarksContainer.children.length) {
while (tickMarksContainer.firstChild) {
tickMarksContainer.removeChild(tickMarksContainer.firstChild);
}
_this.addTickMarks(tickMarksContainer, tickMarks);
} else {
_this.updateTickMarks(tickMarksContainer, tickMarks);
}
},
setPointerCapture: function setPointerCapture(pointerId) {
_this.root.setPointerCapture(pointerId);
},
emitChangeEvent: function emitChangeEvent(value, thumb) {
_this.emit(constants_1.events.CHANGE, { value: value, thumb: thumb });
},
emitInputEvent: function emitInputEvent(value, thumb) {
_this.emit(constants_1.events.INPUT, { value: value, thumb: thumb });
},
emitDragStartEvent: function emitDragStartEvent(_, thumb) {
// Emitting event is not yet implemented. See issue:
// https://github.com/material-components/material-components-web/issues/6448
_this.getRipple(thumb).activate();
},
emitDragEndEvent: function emitDragEndEvent(_, thumb) {
// Emitting event is not yet implemented. See issue:
// https://github.com/material-components/material-components-web/issues/6448
_this.getRipple(thumb).deactivate();
},
registerEventHandler: function registerEventHandler(evtType, handler) {
_this.listen(evtType, handler);
},
deregisterEventHandler: function deregisterEventHandler(evtType, handler) {
_this.unlisten(evtType, handler);
},
registerThumbEventHandler: function registerThumbEventHandler(thumb, evtType, handler) {
_this.getThumbEl(thumb).addEventListener(evtType, handler);
},
deregisterThumbEventHandler: function deregisterThumbEventHandler(thumb, evtType, handler) {
_this.getThumbEl(thumb).removeEventListener(evtType, handler);
},
registerInputEventHandler: function registerInputEventHandler(thumb, evtType, handler) {
_this.getInput(thumb).addEventListener(evtType, handler);
},
deregisterInputEventHandler: function deregisterInputEventHandler(thumb, evtType, handler) {
_this.getInput(thumb).removeEventListener(evtType, handler);
},
registerBodyEventHandler: function registerBodyEventHandler(evtType, handler) {
document.body.addEventListener(evtType, handler);
},
deregisterBodyEventHandler: function deregisterBodyEventHandler(evtType, handler) {
document.body.removeEventListener(evtType, handler);
},
registerWindowEventHandler: function registerWindowEventHandler(evtType, handler) {
window.addEventListener(evtType, handler);
},
deregisterWindowEventHandler: function deregisterWindowEventHandler(evtType, handler) {
window.removeEventListener(evtType, handler);
}
};
return new foundation_2.MDCSliderFoundation(adapter);
};
/**
* Initializes component, with the following options:
* - `skipInitialUIUpdate`: Whether to skip updating the UI when initially
* syncing with the DOM. This should be enabled when the slider position
* is set before component initialization.
*/
MDCSlider.prototype.initialize = function (_a) {
var _b = _a === void 0 ? {} : _a,
skipInitialUIUpdate = _b.skipInitialUIUpdate;
this.inputs = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.INPUT));
this.thumbs = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.THUMB));
this.trackActive = this.root.querySelector("." + constants_1.cssClasses.TRACK_ACTIVE);
this.ripples = this.createRipples();
if (skipInitialUIUpdate) {
this.skipInitialUIUpdate = true;
}
};
MDCSlider.prototype.initialSyncWithDOM = function () {
this.foundation.layout({ skipUpdateUI: this.skipInitialUIUpdate });
};
/** Redraws UI based on DOM (e.g. element dimensions, RTL). */
MDCSlider.prototype.layout = function () {
this.foundation.layout();
};
MDCSlider.prototype.getValueStart = function () {
return this.foundation.getValueStart();
};
MDCSlider.prototype.setValueStart = function (valueStart) {
this.foundation.setValueStart(valueStart);
};
MDCSlider.prototype.getValue = function () {
return this.foundation.getValue();
};
MDCSlider.prototype.setValue = function (value) {
this.foundation.setValue(value);
};
/** @return Slider disabled state. */
MDCSlider.prototype.getDisabled = function () {
return this.foundation.getDisabled();
};
/** Sets slider disabled state. */
MDCSlider.prototype.setDisabled = function (disabled) {
this.foundation.setDisabled(disabled);
};
/**
* Sets a function that maps the slider value to the value of the
* `aria-valuetext` attribute on the thumb element.
*/
MDCSlider.prototype.setValueToAriaValueTextFn = function (mapFn) {
this.valueToAriaValueTextFn = mapFn;
};
MDCSlider.prototype.getThumbEl = function (thumb) {
return thumb === types_1.Thumb.END ? this.thumbs[this.thumbs.length - 1] : this.thumbs[0];
};
MDCSlider.prototype.getInput = function (thumb) {
return thumb === types_1.Thumb.END ? this.inputs[this.inputs.length - 1] : this.inputs[0];
};
MDCSlider.prototype.getRipple = function (thumb) {
return thumb === types_1.Thumb.END ? this.ripples[this.ripples.length - 1] : this.ripples[0];
};
/** Adds tick mark elements to the given container. */
MDCSlider.prototype.addTickMarks = function (tickMarkContainer, tickMarks) {
var fragment = document.createDocumentFragment();
for (var i = 0; i < tickMarks.length; i++) {
var div = document.createElement('div');
var tickMarkClass = tickMarks[i] === types_1.TickMark.ACTIVE ? constants_1.cssClasses.TICK_MARK_ACTIVE : constants_1.cssClasses.TICK_MARK_INACTIVE;
div.classList.add(tickMarkClass);
fragment.appendChild(div);
}
tickMarkContainer.appendChild(fragment);
};
/** Updates tick mark elements' classes in the given container. */
MDCSlider.prototype.updateTickMarks = function (tickMarkContainer, tickMarks) {
var tickMarkEls = Array.from(tickMarkContainer.children);
for (var i = 0; i < tickMarkEls.length; i++) {
if (tickMarks[i] === types_1.TickMark.ACTIVE) {
tickMarkEls[i].classList.add(constants_1.cssClasses.TICK_MARK_ACTIVE);
tickMarkEls[i].classList.remove(constants_1.cssClasses.TICK_MARK_INACTIVE);
} else {
tickMarkEls[i].classList.add(constants_1.cssClasses.TICK_MARK_INACTIVE);
tickMarkEls[i].classList.remove(constants_1.cssClasses.TICK_MARK_ACTIVE);
}
}
};
/** Initializes thumb ripples. */
MDCSlider.prototype.createRipples = function () {
var ripples = [];
var rippleSurfaces = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.THUMB));
var _loop_1 = function _loop_1(i) {
var rippleSurface = rippleSurfaces[i];
// Use the corresponding input as the focus source for the ripple (i.e.
// when the input is focused, the ripple is in the focused state).
var input = this_1.inputs[i];
var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this_1)), { addClass: function addClass(className) {
rippleSurface.classList.add(className);
}, computeBoundingRect: function computeBoundingRect() {
return rippleSurface.getBoundingClientRect();
}, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
input.removeEventListener(evtType, handler);
}, isSurfaceActive: function isSurfaceActive() {
return ponyfill_1.matches(input, ':active');
}, isUnbounded: function isUnbounded() {
return true;
}, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
input.addEventListener(evtType, handler, events_1.applyPassive());
}, removeClass: function removeClass(className) {
rippleSurface.classList.remove(className);
}, updateCssVariable: function updateCssVariable(varName, value) {
rippleSurface.style.setProperty(varName, value);
} });
var ripple = new component_2.MDCRipple(rippleSurface, new foundation_1.MDCRippleFoundation(adapter));
ripple.unbounded = true;
ripples.push(ripple);
};
var this_1 = this;
for (var i = 0; i < rippleSurfaces.length; i++) {
_loop_1(i);
}
return ripples;
};
return MDCSlider;
}(component_1.MDCComponent);
exports.MDCSlider = MDCSlider;
/***/ }),
/***/ "./packages/mdc-slider/constants.ts":
/*!******************************************!*\
!*** ./packages/mdc-slider/constants.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.events = exports.attributes = exports.numbers = exports.cssClasses = void 0;
/** Slider element classes. */
exports.cssClasses = {
DISABLED: 'mdc-slider--disabled',
DISCRETE: 'mdc-slider--discrete',
INPUT: 'mdc-slider__input',
RANGE: 'mdc-slider--range',
THUMB: 'mdc-slider__thumb',
// Applied when thumb is in the focused state.
THUMB_FOCUSED: 'mdc-slider__thumb--focused',
THUMB_KNOB: 'mdc-slider__thumb-knob',
// Class added to the top thumb (for overlapping thumbs in range slider).
THUMB_TOP: 'mdc-slider__thumb--top',
THUMB_WITH_INDICATOR: 'mdc-slider__thumb--with-indicator',
TICK_MARKS: 'mdc-slider--tick-marks',
TICK_MARKS_CONTAINER: 'mdc-slider__tick-marks',
TICK_MARK_ACTIVE: 'mdc-slider__tick-mark--active',
TICK_MARK_INACTIVE: 'mdc-slider__tick-mark--inactive',
TRACK: 'mdc-slider__track',
// The active track fill element that will be scaled as the value changes.
TRACK_ACTIVE: 'mdc-slider__track--active_fill',
VALUE_INDICATOR_CONTAINER: 'mdc-slider__value-indicator-container',
VALUE_INDICATOR_TEXT: 'mdc-slider__value-indicator-text'
};
/** Slider numbers. */
exports.numbers = {
// Default step size.
STEP_SIZE: 1,
// Default minimum difference between the start and end values.
MIN_RANGE: 0,
// Minimum absolute difference between clientX of move event / down event
// for which to update thumb, in the case of overlapping thumbs.
// This is needed to reduce chances of choosing the thumb based on
// pointer jitter.
THUMB_UPDATE_MIN_PX: 5
};
/** Slider attributes. */
exports.attributes = {
ARIA_VALUETEXT: 'aria-valuetext',
INPUT_DISABLED: 'disabled',
INPUT_MIN: 'min',
INPUT_MAX: 'max',
INPUT_VALUE: 'value',
INPUT_STEP: 'step',
DATA_MIN_RANGE: 'data-min-range'
};
/** Slider events. */
exports.events = {
CHANGE: 'MDCSlider:change',
INPUT: 'MDCSlider:input'
};
/** Slider strings. */
exports.strings = {
VAR_VALUE_INDICATOR_CARET_LEFT: '--slider-value-indicator-caret-left',
VAR_VALUE_INDICATOR_CARET_RIGHT: '--slider-value-indicator-caret-right',
VAR_VALUE_INDICATOR_CARET_TRANSFORM: '--slider-value-indicator-caret-transform',
VAR_VALUE_INDICATOR_CONTAINER_LEFT: '--slider-value-indicator-container-left',
VAR_VALUE_INDICATOR_CONTAINER_RIGHT: '--slider-value-indicator-container-right',
VAR_VALUE_INDICATOR_CONTAINER_TRANSFORM: '--slider-value-indicator-container-transform'
};
/***/ }),
/***/ "./packages/mdc-slider/foundation.ts":
/*!*******************************************!*\
!*** ./packages/mdc-slider/foundation.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSliderFoundation = void 0;
var animationframe_1 = __webpack_require__(/*! @material/animation/animationframe */ "./packages/mdc-animation/animationframe.ts");
var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts");
var types_1 = __webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts");
var AnimationKeys;
(function (AnimationKeys) {
AnimationKeys["SLIDER_UPDATE"] = "slider_update";
})(AnimationKeys || (AnimationKeys = {}));
// Accessing `window` without a `typeof` check will throw on Node environments.
var HAS_WINDOW = typeof window !== 'undefined';
/**
* Foundation class for slider. Responsibilities include:
* - Updating slider values (internal state and DOM updates) based on client
* 'x' position.
* - Updating DOM after slider property updates (e.g. min, max).
*/
var MDCSliderFoundation = /** @class */function (_super) {
__extends(MDCSliderFoundation, _super);
function MDCSliderFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCSliderFoundation.defaultAdapter), adapter)) || this;
// Whether the initial styles (to position the thumb, before component
// initialization) have been removed.
_this.initialStylesRemoved = false;
_this.isDisabled = false;
_this.isDiscrete = false;
_this.step = constants_1.numbers.STEP_SIZE;
_this.minRange = constants_1.numbers.MIN_RANGE;
_this.hasTickMarks = false;
// The following properties are only set for range sliders.
_this.isRange = false;
// Tracks the thumb being moved across a slider pointer interaction (down,
// move event).
_this.thumb = null;
// `clientX` from the most recent down event. Used in subsequent move
// events to determine which thumb to move (in the case of
// overlapping thumbs).
_this.downEventClientX = null;
// Width of the start thumb knob.
_this.startThumbKnobWidth = 0;
// Width of the end thumb knob.
_this.endThumbKnobWidth = 0;
_this.animFrame = new animationframe_1.AnimationFrame();
return _this;
}
Object.defineProperty(MDCSliderFoundation, "defaultAdapter", {
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same
// order as the adapter interface.
return {
hasClass: function hasClass() {
return false;
},
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
addThumbClass: function addThumbClass() {
return undefined;
},
removeThumbClass: function removeThumbClass() {
return undefined;
},
getAttribute: function getAttribute() {
return null;
},
getInputValue: function getInputValue() {
return '';
},
setInputValue: function setInputValue() {
return undefined;
},
getInputAttribute: function getInputAttribute() {
return null;
},
setInputAttribute: function setInputAttribute() {
return null;
},
removeInputAttribute: function removeInputAttribute() {
return null;
},
focusInput: function focusInput() {
return undefined;
},
isInputFocused: function isInputFocused() {
return false;
},
shouldHideFocusStylesForPointerEvents: function shouldHideFocusStylesForPointerEvents() {
return false;
},
getThumbKnobWidth: function getThumbKnobWidth() {
return 0;
},
getValueIndicatorContainerWidth: function getValueIndicatorContainerWidth() {
return 0;
},
getThumbBoundingClientRect: function getThumbBoundingClientRect() {
return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
},
getBoundingClientRect: function getBoundingClientRect() {
return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
},
isRTL: function isRTL() {
return false;
},
setThumbStyleProperty: function setThumbStyleProperty() {
return undefined;
},
removeThumbStyleProperty: function removeThumbStyleProperty() {
return undefined;
},
setTrackActiveStyleProperty: function setTrackActiveStyleProperty() {
return undefined;
},
removeTrackActiveStyleProperty: function removeTrackActiveStyleProperty() {
return undefined;
},
setValueIndicatorText: function setValueIndicatorText() {
return undefined;
},
getValueToAriaValueTextFn: function getValueToAriaValueTextFn() {
return null;
},
updateTickMarks: function updateTickMarks() {
return undefined;
},
setPointerCapture: function setPointerCapture() {
return undefined;
},
emitChangeEvent: function emitChangeEvent() {
return undefined;
},
emitInputEvent: function emitInputEvent() {
return undefined;
},
emitDragStartEvent: function emitDragStartEvent() {
return undefined;
},
emitDragEndEvent: function emitDragEndEvent() {
return undefined;
},
registerEventHandler: function registerEventHandler() {
return undefined;
},
deregisterEventHandler: function deregisterEventHandler() {
return undefined;
},
registerThumbEventHandler: function registerThumbEventHandler() {
return undefined;
},
deregisterThumbEventHandler: function deregisterThumbEventHandler() {
return undefined;
},
registerInputEventHandler: function registerInputEventHandler() {
return undefined;
},
deregisterInputEventHandler: function deregisterInputEventHandler() {
return undefined;
},
registerBodyEventHandler: function registerBodyEventHandler() {
return undefined;
},
deregisterBodyEventHandler: function deregisterBodyEventHandler() {
return undefined;
},
registerWindowEventHandler: function registerWindowEventHandler() {
return undefined;
},
deregisterWindowEventHandler: function deregisterWindowEventHandler() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCSliderFoundation.prototype.init = function () {
var _this = this;
this.isDisabled = this.adapter.hasClass(constants_1.cssClasses.DISABLED);
this.isDiscrete = this.adapter.hasClass(constants_1.cssClasses.DISCRETE);
this.hasTickMarks = this.adapter.hasClass(constants_1.cssClasses.TICK_MARKS);
this.isRange = this.adapter.hasClass(constants_1.cssClasses.RANGE);
var min = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_MIN, this.isRange ? types_1.Thumb.START : types_1.Thumb.END), constants_1.attributes.INPUT_MIN);
var max = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_MAX, types_1.Thumb.END), constants_1.attributes.INPUT_MAX);
var value = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_VALUE, types_1.Thumb.END), constants_1.attributes.INPUT_VALUE);
var valueStart = this.isRange ? this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_VALUE, types_1.Thumb.START), constants_1.attributes.INPUT_VALUE) : min;
var stepAttr = this.adapter.getInputAttribute(constants_1.attributes.INPUT_STEP, types_1.Thumb.END);
var step = stepAttr ? this.convertAttributeValueToNumber(stepAttr, constants_1.attributes.INPUT_STEP) : this.step;
var minRangeAttr = this.adapter.getAttribute(constants_1.attributes.DATA_MIN_RANGE);
var minRange = minRangeAttr ? this.convertAttributeValueToNumber(minRangeAttr, constants_1.attributes.DATA_MIN_RANGE) : this.minRange;
this.validateProperties({ min: min, max: max, value: value, valueStart: valueStart, step: step, minRange: minRange });
this.min = min;
this.max = max;
this.value = value;
this.valueStart = valueStart;
this.step = step;
this.minRange = minRange;
this.numDecimalPlaces = getNumDecimalPlaces(this.step);
this.valueBeforeDownEvent = value;
this.valueStartBeforeDownEvent = valueStart;
this.mousedownOrTouchstartListener = this.handleMousedownOrTouchstart.bind(this);
this.moveListener = this.handleMove.bind(this);
this.pointerdownListener = this.handlePointerdown.bind(this);
this.pointerupListener = this.handlePointerup.bind(this);
this.thumbMouseenterListener = this.handleThumbMouseenter.bind(this);
this.thumbMouseleaveListener = this.handleThumbMouseleave.bind(this);
this.inputStartChangeListener = function () {
_this.handleInputChange(types_1.Thumb.START);
};
this.inputEndChangeListener = function () {
_this.handleInputChange(types_1.Thumb.END);
};
this.inputStartFocusListener = function () {
_this.handleInputFocus(types_1.Thumb.START);
};
this.inputEndFocusListener = function () {
_this.handleInputFocus(types_1.Thumb.END);
};
this.inputStartBlurListener = function () {
_this.handleInputBlur(types_1.Thumb.START);
};
this.inputEndBlurListener = function () {
_this.handleInputBlur(types_1.Thumb.END);
};
this.resizeListener = this.handleResize.bind(this);
this.registerEventHandlers();
};
MDCSliderFoundation.prototype.destroy = function () {
this.deregisterEventHandlers();
};
MDCSliderFoundation.prototype.setMin = function (value) {
this.min = value;
if (!this.isRange) {
this.valueStart = value;
}
this.updateUI();
};
MDCSliderFoundation.prototype.setMax = function (value) {
this.max = value;
this.updateUI();
};
MDCSliderFoundation.prototype.getMin = function () {
return this.min;
};
MDCSliderFoundation.prototype.getMax = function () {
return this.max;
};
/**
* - For single point sliders, returns the thumb value.
* - For range (two-thumb) sliders, returns the end thumb's value.
*/
MDCSliderFoundation.prototype.getValue = function () {
return this.value;
};
/**
* - For single point sliders, sets the thumb value.
* - For range (two-thumb) sliders, sets the end thumb's value.
*/
MDCSliderFoundation.prototype.setValue = function (value) {
if (this.isRange && value < this.valueStart + this.minRange) {
throw new Error("end thumb value (" + value + ") must be >= start thumb " + ("value (" + this.valueStart + ") + min range (" + this.minRange + ")"));
}
this.updateValue(value, types_1.Thumb.END);
};
/**
* Only applicable for range sliders.
* @return The start thumb's value.
*/
MDCSliderFoundation.prototype.getValueStart = function () {
if (!this.isRange) {
throw new Error('`valueStart` is only applicable for range sliders.');
}
return this.valueStart;
};
/**
* Only applicable for range sliders. Sets the start thumb's value.
*/
MDCSliderFoundation.prototype.setValueStart = function (valueStart) {
if (!this.isRange) {
throw new Error('`valueStart` is only applicable for range sliders.');
}
if (this.isRange && valueStart > this.value - this.minRange) {
throw new Error("start thumb value (" + valueStart + ") must be <= end thumb " + ("value (" + this.value + ") - min range (" + this.minRange + ")"));
}
this.updateValue(valueStart, types_1.Thumb.START);
};
MDCSliderFoundation.prototype.setStep = function (value) {
this.step = value;
this.numDecimalPlaces = getNumDecimalPlaces(value);
this.updateUI();
};
/**
* Only applicable for range sliders. Sets the minimum difference between the
* start and end values.
*/
MDCSliderFoundation.prototype.setMinRange = function (value) {
if (!this.isRange) {
throw new Error('`minRange` is only applicable for range sliders.');
}
if (value < 0) {
throw new Error('`minRange` must be non-negative. ' + ("Current value: " + value));
}
if (this.value - this.valueStart < value) {
throw new Error("start thumb value (" + this.valueStart + ") and end thumb value " + ("(" + this.value + ") must differ by at least " + value + "."));
}
this.minRange = value;
};
MDCSliderFoundation.prototype.setIsDiscrete = function (value) {
this.isDiscrete = value;
this.updateValueIndicatorUI();
this.updateTickMarksUI();
};
MDCSliderFoundation.prototype.getStep = function () {
return this.step;
};
MDCSliderFoundation.prototype.getMinRange = function () {
if (!this.isRange) {
throw new Error('`minRange` is only applicable for range sliders.');
}
return this.minRange;
};
MDCSliderFoundation.prototype.setHasTickMarks = function (value) {
this.hasTickMarks = value;
this.updateTickMarksUI();
};
MDCSliderFoundation.prototype.getDisabled = function () {
return this.isDisabled;
};
/**
* Sets disabled state, including updating styles and thumb tabindex.
*/
MDCSliderFoundation.prototype.setDisabled = function (disabled) {
this.isDisabled = disabled;
if (disabled) {
this.adapter.addClass(constants_1.cssClasses.DISABLED);
if (this.isRange) {
this.adapter.setInputAttribute(constants_1.attributes.INPUT_DISABLED, '', types_1.Thumb.START);
}
this.adapter.setInputAttribute(constants_1.attributes.INPUT_DISABLED, '', types_1.Thumb.END);
} else {
this.adapter.removeClass(constants_1.cssClasses.DISABLED);
if (this.isRange) {
this.adapter.removeInputAttribute(constants_1.attributes.INPUT_DISABLED, types_1.Thumb.START);
}
this.adapter.removeInputAttribute(constants_1.attributes.INPUT_DISABLED, types_1.Thumb.END);
}
};
/** @return Whether the slider is a range slider. */
MDCSliderFoundation.prototype.getIsRange = function () {
return this.isRange;
};
/**
* - Syncs slider boundingClientRect with the current DOM.
* - Updates UI based on internal state.
*/
MDCSliderFoundation.prototype.layout = function (_a) {
var _b = _a === void 0 ? {} : _a,
skipUpdateUI = _b.skipUpdateUI;
this.rect = this.adapter.getBoundingClientRect();
if (this.isRange) {
this.startThumbKnobWidth = this.adapter.getThumbKnobWidth(types_1.Thumb.START);
this.endThumbKnobWidth = this.adapter.getThumbKnobWidth(types_1.Thumb.END);
}
if (!skipUpdateUI) {
this.updateUI();
}
};
/** Handles resize events on the window. */
MDCSliderFoundation.prototype.handleResize = function () {
this.layout();
};
/**
* Handles pointer down events on the slider root element.
*/
MDCSliderFoundation.prototype.handleDown = function (event) {
if (this.isDisabled) return;
this.valueStartBeforeDownEvent = this.valueStart;
this.valueBeforeDownEvent = this.value;
var clientX = event.clientX != null ? event.clientX : event.targetTouches[0].clientX;
this.downEventClientX = clientX;
var value = this.mapClientXOnSliderScale(clientX);
this.thumb = this.getThumbFromDownEvent(clientX, value);
if (this.thumb === null) return;
this.handleDragStart(event, value, this.thumb);
this.updateValue(value, this.thumb, { emitInputEvent: true });
};
/**
* Handles pointer move events on the slider root element.
*/
MDCSliderFoundation.prototype.handleMove = function (event) {
if (this.isDisabled) return;
// Prevent scrolling.
event.preventDefault();
var clientX = event.clientX != null ? event.clientX : event.targetTouches[0].clientX;
var dragAlreadyStarted = this.thumb != null;
this.thumb = this.getThumbFromMoveEvent(clientX);
if (this.thumb === null) return;
var value = this.mapClientXOnSliderScale(clientX);
if (!dragAlreadyStarted) {
this.handleDragStart(event, value, this.thumb);
this.adapter.emitDragStartEvent(value, this.thumb);
}
this.updateValue(value, this.thumb, { emitInputEvent: true });
};
/**
* Handles pointer up events on the slider root element.
*/
MDCSliderFoundation.prototype.handleUp = function () {
var _a, _b;
if (this.isDisabled || this.thumb === null) return;
// Remove the focused state and hide the value indicator(s) (if present)
// if focus state is meant to be hidden.
if ((_b = (_a = this.adapter).shouldHideFocusStylesForPointerEvents) === null || _b === void 0 ? void 0 : _b.call(_a)) {
this.handleInputBlur(this.thumb);
}
var oldValue = this.thumb === types_1.Thumb.START ? this.valueStartBeforeDownEvent : this.valueBeforeDownEvent;
var newValue = this.thumb === types_1.Thumb.START ? this.valueStart : this.value;
if (oldValue !== newValue) {
this.adapter.emitChangeEvent(newValue, this.thumb);
}
this.adapter.emitDragEndEvent(newValue, this.thumb);
this.thumb = null;
};
/**
* For range, discrete slider, shows the value indicator on both thumbs.
*/
MDCSliderFoundation.prototype.handleThumbMouseenter = function () {
if (!this.isDiscrete || !this.isRange) return;
this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.START);
this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.END);
};
/**
* For range, discrete slider, hides the value indicator on both thumbs.
*/
MDCSliderFoundation.prototype.handleThumbMouseleave = function () {
var _a, _b;
if (!this.isDiscrete || !this.isRange) return;
if (!((_b = (_a = this.adapter).shouldHideFocusStylesForPointerEvents) === null || _b === void 0 ? void 0 : _b.call(_a)) && (this.adapter.isInputFocused(types_1.Thumb.START) || this.adapter.isInputFocused(types_1.Thumb.END)) || this.thumb) {
// Leave value indicator shown if either input is focused or the thumb is
// being dragged.
return;
}
this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.START);
this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.END);
};
MDCSliderFoundation.prototype.handleMousedownOrTouchstart = function (event) {
var _this = this;
var moveEventType = event.type === 'mousedown' ? 'mousemove' : 'touchmove';
// After a down event on the slider root, listen for move events on
// body (so the slider value is updated for events outside of the
// slider root).
this.adapter.registerBodyEventHandler(moveEventType, this.moveListener);
var upHandler = function upHandler() {
_this.handleUp();
// Once the drag is finished (up event on body), remove the move
// handler.
_this.adapter.deregisterBodyEventHandler(moveEventType, _this.moveListener);
// Also stop listening for subsequent up events.
_this.adapter.deregisterEventHandler('mouseup', upHandler);
_this.adapter.deregisterEventHandler('touchend', upHandler);
};
this.adapter.registerBodyEventHandler('mouseup', upHandler);
this.adapter.registerBodyEventHandler('touchend', upHandler);
this.handleDown(event);
};
MDCSliderFoundation.prototype.handlePointerdown = function (event) {
var isPrimaryButton = event.button === 0;
if (!isPrimaryButton) return;
if (event.pointerId != null) {
this.adapter.setPointerCapture(event.pointerId);
}
this.adapter.registerEventHandler('pointermove', this.moveListener);
this.handleDown(event);
};
/**
* Handles input `change` event by setting internal slider value to match
* input's new value.
*/
MDCSliderFoundation.prototype.handleInputChange = function (thumb) {
var value = Number(this.adapter.getInputValue(thumb));
if (thumb === types_1.Thumb.START) {
this.setValueStart(value);
} else {
this.setValue(value);
}
this.adapter.emitChangeEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
this.adapter.emitInputEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
};
/** Shows activated state and value indicator on thumb(s). */
MDCSliderFoundation.prototype.handleInputFocus = function (thumb) {
this.adapter.addThumbClass(constants_1.cssClasses.THUMB_FOCUSED, thumb);
if (!this.isDiscrete) return;
this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, thumb);
if (this.isRange) {
var otherThumb = thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START;
this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, otherThumb);
}
};
/** Removes activated state and value indicator from thumb(s). */
MDCSliderFoundation.prototype.handleInputBlur = function (thumb) {
this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_FOCUSED, thumb);
if (!this.isDiscrete) return;
this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, thumb);
if (this.isRange) {
var otherThumb = thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START;
this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, otherThumb);
}
};
/**
* Emits custom dragStart event, along with focusing the underlying input.
*/
MDCSliderFoundation.prototype.handleDragStart = function (event, value, thumb) {
var _a, _b;
this.adapter.emitDragStartEvent(value, thumb);
this.adapter.focusInput(thumb);
// Restore focused state and show the value indicator(s) (if present)
// in case they were previously hidden on dragEnd.
// This is needed if the input is already focused, in which case
// #focusInput above wouldn't actually trigger #handleInputFocus,
// which is why we need to invoke it manually here.
if ((_b = (_a = this.adapter).shouldHideFocusStylesForPointerEvents) === null || _b === void 0 ? void 0 : _b.call(_a)) {
this.handleInputFocus(thumb);
}
// Prevent the input (that we just focused) from losing focus.
event.preventDefault();
};
/**
* @return The thumb to be moved based on initial down event.
*/
MDCSliderFoundation.prototype.getThumbFromDownEvent = function (clientX, value) {
// For single point slider, thumb to be moved is always the END (only)
// thumb.
if (!this.isRange) return types_1.Thumb.END;
// Check if event press point is in the bounds of any thumb.
var thumbStartRect = this.adapter.getThumbBoundingClientRect(types_1.Thumb.START);
var thumbEndRect = this.adapter.getThumbBoundingClientRect(types_1.Thumb.END);
var inThumbStartBounds = clientX >= thumbStartRect.left && clientX <= thumbStartRect.right;
var inThumbEndBounds = clientX >= thumbEndRect.left && clientX <= thumbEndRect.right;
if (inThumbStartBounds && inThumbEndBounds) {
// Thumbs overlapping. Thumb to be moved cannot be determined yet.
return null;
}
// If press is in bounds for either thumb on down event, that's the thumb
// to be moved.
if (inThumbStartBounds) {
return types_1.Thumb.START;
}
if (inThumbEndBounds) {
return types_1.Thumb.END;
}
// For presses outside the range, return whichever thumb is closer.
if (value < this.valueStart) {
return types_1.Thumb.START;
}
if (value > this.value) {
return types_1.Thumb.END;
}
// For presses inside the range, return whichever thumb is closer.
return value - this.valueStart <= this.value - value ? types_1.Thumb.START : types_1.Thumb.END;
};
/**
* @return The thumb to be moved based on move event (based on drag
* direction from original down event). Only applicable if thumbs
* were overlapping in the down event.
*/
MDCSliderFoundation.prototype.getThumbFromMoveEvent = function (clientX) {
// Thumb has already been chosen.
if (this.thumb !== null) return this.thumb;
if (this.downEventClientX === null) {
throw new Error('`downEventClientX` is null after move event.');
}
var moveDistanceUnderThreshold = Math.abs(this.downEventClientX - clientX) < constants_1.numbers.THUMB_UPDATE_MIN_PX;
if (moveDistanceUnderThreshold) return this.thumb;
var draggedThumbToLeft = clientX < this.downEventClientX;
if (draggedThumbToLeft) {
return this.adapter.isRTL() ? types_1.Thumb.END : types_1.Thumb.START;
} else {
return this.adapter.isRTL() ? types_1.Thumb.START : types_1.Thumb.END;
}
};
/**
* Updates UI based on internal state.
* @param thumb Thumb whose value is being updated. If undefined, UI is
* updated for both thumbs based on current internal state.
*/
MDCSliderFoundation.prototype.updateUI = function (thumb) {
if (thumb) {
this.updateThumbAndInputAttributes(thumb);
} else {
this.updateThumbAndInputAttributes(types_1.Thumb.START);
this.updateThumbAndInputAttributes(types_1.Thumb.END);
}
this.updateThumbAndTrackUI(thumb);
this.updateValueIndicatorUI(thumb);
this.updateTickMarksUI();
};
/**
* Updates thumb and input attributes based on current value.
* @param thumb Thumb whose aria attributes to update.
*/
MDCSliderFoundation.prototype.updateThumbAndInputAttributes = function (thumb) {
if (!thumb) return;
var value = this.isRange && thumb === types_1.Thumb.START ? this.valueStart : this.value;
var valueStr = String(value);
this.adapter.setInputAttribute(constants_1.attributes.INPUT_VALUE, valueStr, thumb);
if (this.isRange && thumb === types_1.Thumb.START) {
this.adapter.setInputAttribute(constants_1.attributes.INPUT_MIN, String(value + this.minRange), types_1.Thumb.END);
} else if (this.isRange && thumb === types_1.Thumb.END) {
this.adapter.setInputAttribute(constants_1.attributes.INPUT_MAX, String(value - this.minRange), types_1.Thumb.START);
}
// Sync attribute with property.
if (this.adapter.getInputValue(thumb) !== valueStr) {
this.adapter.setInputValue(valueStr, thumb);
}
var valueToAriaValueTextFn = this.adapter.getValueToAriaValueTextFn();
if (valueToAriaValueTextFn) {
this.adapter.setInputAttribute(constants_1.attributes.ARIA_VALUETEXT, valueToAriaValueTextFn(value, thumb), thumb);
}
};
/**
* Updates value indicator UI based on current value.
* @param thumb Thumb whose value indicator to update. If undefined, all
* thumbs' value indicators are updated.
*/
MDCSliderFoundation.prototype.updateValueIndicatorUI = function (thumb) {
if (!this.isDiscrete) return;
var value = this.isRange && thumb === types_1.Thumb.START ? this.valueStart : this.value;
this.adapter.setValueIndicatorText(value, thumb === types_1.Thumb.START ? types_1.Thumb.START : types_1.Thumb.END);
if (!thumb && this.isRange) {
this.adapter.setValueIndicatorText(this.valueStart, types_1.Thumb.START);
}
};
/**
* Updates tick marks UI within slider, based on current min, max, and step.
*/
MDCSliderFoundation.prototype.updateTickMarksUI = function () {
if (!this.isDiscrete || !this.hasTickMarks) return;
var numTickMarksInactiveStart = (this.valueStart - this.min) / this.step;
var numTickMarksActive = (this.value - this.valueStart) / this.step + 1;
var numTickMarksInactiveEnd = (this.max - this.value) / this.step;
var tickMarksInactiveStart = Array.from({ length: numTickMarksInactiveStart }).fill(types_1.TickMark.INACTIVE);
var tickMarksActive = Array.from({ length: numTickMarksActive }).fill(types_1.TickMark.ACTIVE);
var tickMarksInactiveEnd = Array.from({ length: numTickMarksInactiveEnd }).fill(types_1.TickMark.INACTIVE);
this.adapter.updateTickMarks(tickMarksInactiveStart.concat(tickMarksActive).concat(tickMarksInactiveEnd));
};
/** Maps clientX to a value on the slider scale. */
MDCSliderFoundation.prototype.mapClientXOnSliderScale = function (clientX) {
var xPos = clientX - this.rect.left;
var pctComplete = xPos / this.rect.width;
if (this.adapter.isRTL()) {
pctComplete = 1 - pctComplete;
}
// Fit the percentage complete between the range [min,max]
// by remapping from [0, 1] to [min, min+(max-min)].
var value = this.min + pctComplete * (this.max - this.min);
if (value === this.max || value === this.min) {
return value;
}
return Number(this.quantize(value).toFixed(this.numDecimalPlaces));
};
/** Calculates the quantized value based on step value. */
MDCSliderFoundation.prototype.quantize = function (value) {
var numSteps = Math.round((value - this.min) / this.step);
return this.min + numSteps * this.step;
};
/**
* Updates slider value (internal state and UI) based on the given value.
*/
MDCSliderFoundation.prototype.updateValue = function (value, thumb, _a) {
var _b = _a === void 0 ? {} : _a,
emitInputEvent = _b.emitInputEvent;
value = this.clampValue(value, thumb);
if (this.isRange && thumb === types_1.Thumb.START) {
// Exit early if current value is the same as the new value.
if (this.valueStart === value) return;
this.valueStart = value;
} else {
// Exit early if current value is the same as the new value.
if (this.value === value) return;
this.value = value;
}
this.updateUI(thumb);
if (emitInputEvent) {
this.adapter.emitInputEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
}
};
/**
* Clamps the given value for the given thumb based on slider properties:
* - Restricts value within [min, max].
* - If range slider, clamp start value <= end value - min range, and
* end value >= start value + min range.
*/
MDCSliderFoundation.prototype.clampValue = function (value, thumb) {
// Clamp value to [min, max] range.
value = Math.min(Math.max(value, this.min), this.max);
var thumbStartMovedPastThumbEnd = this.isRange && thumb === types_1.Thumb.START && value > this.value - this.minRange;
if (thumbStartMovedPastThumbEnd) {
return this.value - this.minRange;
}
var thumbEndMovedPastThumbStart = this.isRange && thumb === types_1.Thumb.END && value < this.valueStart + this.minRange;
if (thumbEndMovedPastThumbStart) {
return this.valueStart + this.minRange;
}
return value;
};
/**
* Updates the active track and thumb style properties to reflect current
* value.
*/
MDCSliderFoundation.prototype.updateThumbAndTrackUI = function (thumb) {
var _this = this;
var _a = this,
max = _a.max,
min = _a.min;
var pctComplete = (this.value - this.valueStart) / (max - min);
var rangePx = pctComplete * this.rect.width;
var isRtl = this.adapter.isRTL();
var transformProp = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
if (this.isRange) {
var thumbLeftPos_1 = this.adapter.isRTL() ? (max - this.value) / (max - min) * this.rect.width : (this.valueStart - min) / (max - min) * this.rect.width;
var thumbRightPos_1 = thumbLeftPos_1 + rangePx;
this.animFrame.request(AnimationKeys.SLIDER_UPDATE, function () {
// Set active track styles, accounting for animation direction by
// setting `transform-origin`.
var trackAnimatesFromRight = !isRtl && thumb === types_1.Thumb.START || isRtl && thumb !== types_1.Thumb.START;
if (trackAnimatesFromRight) {
_this.adapter.setTrackActiveStyleProperty('transform-origin', 'right');
_this.adapter.setTrackActiveStyleProperty('left', 'auto');
_this.adapter.setTrackActiveStyleProperty('right', _this.rect.width - thumbRightPos_1 + "px");
} else {
_this.adapter.setTrackActiveStyleProperty('transform-origin', 'left');
_this.adapter.setTrackActiveStyleProperty('right', 'auto');
_this.adapter.setTrackActiveStyleProperty('left', thumbLeftPos_1 + "px");
}
_this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
// Set thumb styles.
var thumbStartPos = isRtl ? thumbRightPos_1 : thumbLeftPos_1;
var thumbEndPos = _this.adapter.isRTL() ? thumbLeftPos_1 : thumbRightPos_1;
if (thumb === types_1.Thumb.START || !thumb || !_this.initialStylesRemoved) {
_this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", types_1.Thumb.START);
_this.alignValueIndicator(types_1.Thumb.START, thumbStartPos);
}
if (thumb === types_1.Thumb.END || !thumb || !_this.initialStylesRemoved) {
_this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbEndPos + "px)", types_1.Thumb.END);
_this.alignValueIndicator(types_1.Thumb.END, thumbEndPos);
}
_this.removeInitialStyles(isRtl);
_this.updateOverlappingThumbsUI(thumbStartPos, thumbEndPos, thumb);
});
} else {
this.animFrame.request(AnimationKeys.SLIDER_UPDATE, function () {
var thumbStartPos = isRtl ? _this.rect.width - rangePx : rangePx;
_this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", types_1.Thumb.END);
_this.alignValueIndicator(types_1.Thumb.END, thumbStartPos);
_this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
_this.removeInitialStyles(isRtl);
});
}
};
/**
* Shifts the value indicator to either side if it would otherwise stick
* beyond the slider's length while keeping the caret above the knob.
*/
MDCSliderFoundation.prototype.alignValueIndicator = function (thumb, thumbPos) {
if (!this.isDiscrete) return;
var thumbHalfWidth = this.adapter.getThumbBoundingClientRect(thumb).width / 2;
var containerWidth = this.adapter.getValueIndicatorContainerWidth(thumb);
var sliderWidth = this.adapter.getBoundingClientRect().width;
if (containerWidth / 2 > thumbPos + thumbHalfWidth) {
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_LEFT, thumbHalfWidth + "px", thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_RIGHT, 'auto', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_TRANSFORM, 'translateX(-50%)', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_LEFT, '0', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_RIGHT, 'auto', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_TRANSFORM, 'none', thumb);
} else if (containerWidth / 2 > sliderWidth - thumbPos + thumbHalfWidth) {
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_LEFT, 'auto', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_RIGHT, thumbHalfWidth + "px", thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_TRANSFORM, 'translateX(50%)', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_LEFT, 'auto', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_RIGHT, '0', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_TRANSFORM, 'none', thumb);
} else {
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_LEFT, '50%', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_RIGHT, 'auto', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_TRANSFORM, 'translateX(-50%)', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_LEFT, '50%', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_RIGHT, 'auto', thumb);
this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_TRANSFORM, 'translateX(-50%)', thumb);
}
};
/**
* Removes initial inline styles if not already removed. `left:<...>%`
* inline styles can be added to position the thumb correctly before JS
* initialization. However, they need to be removed before the JS starts
* positioning the thumb. This is because the JS uses
* `transform:translateX(<...>)px` (for performance reasons) to position
* the thumb (which is not possible for initial styles since we need the
* bounding rect measurements).
*/
MDCSliderFoundation.prototype.removeInitialStyles = function (isRtl) {
if (this.initialStylesRemoved) return;
// Remove thumb position properties that were added for initial render.
var position = isRtl ? 'right' : 'left';
this.adapter.removeThumbStyleProperty(position, types_1.Thumb.END);
if (this.isRange) {
this.adapter.removeThumbStyleProperty(position, types_1.Thumb.START);
}
this.initialStylesRemoved = true;
this.resetTrackAndThumbAnimation();
};
/**
* Resets track/thumb animation to prevent animation when adding
* `transform` styles to thumb initially.
*/
MDCSliderFoundation.prototype.resetTrackAndThumbAnimation = function () {
var _this = this;
if (!this.isDiscrete) return;
// Set transition properties to default (no animation), so that the
// newly added `transform` styles do not animate thumb/track from
// their default positions.
var transitionProp = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transition') : 'transition';
var transitionDefault = 'none 0s ease 0s';
this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, types_1.Thumb.END);
if (this.isRange) {
this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, types_1.Thumb.START);
}
this.adapter.setTrackActiveStyleProperty(transitionProp, transitionDefault);
// In the next frame, remove the transition inline styles we just
// added, such that any animations added in the CSS can now take effect.
requestAnimationFrame(function () {
_this.adapter.removeThumbStyleProperty(transitionProp, types_1.Thumb.END);
_this.adapter.removeTrackActiveStyleProperty(transitionProp);
if (_this.isRange) {
_this.adapter.removeThumbStyleProperty(transitionProp, types_1.Thumb.START);
}
});
};
/**
* Adds THUMB_TOP class to active thumb if thumb knobs overlap; otherwise
* removes THUMB_TOP class from both thumbs.
* @param thumb Thumb that is active (being moved).
*/
MDCSliderFoundation.prototype.updateOverlappingThumbsUI = function (thumbStartPos, thumbEndPos, thumb) {
var thumbsOverlap = false;
if (this.adapter.isRTL()) {
var startThumbLeftEdge = thumbStartPos - this.startThumbKnobWidth / 2;
var endThumbRightEdge = thumbEndPos + this.endThumbKnobWidth / 2;
thumbsOverlap = endThumbRightEdge >= startThumbLeftEdge;
} else {
var startThumbRightEdge = thumbStartPos + this.startThumbKnobWidth / 2;
var endThumbLeftEdge = thumbEndPos - this.endThumbKnobWidth / 2;
thumbsOverlap = startThumbRightEdge >= endThumbLeftEdge;
}
if (thumbsOverlap) {
this.adapter.addThumbClass(constants_1.cssClasses.THUMB_TOP,
// If no thumb was dragged (in the case of initial layout), end
// thumb is on top by default.
thumb || types_1.Thumb.END);
this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START);
} else {
this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, types_1.Thumb.START);
this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, types_1.Thumb.END);
}
};
/**
* Converts attribute value to a number, e.g. '100' => 100. Throws errors
* for invalid values.
* @param attributeValue Attribute value, e.g. 100.
* @param attributeName Attribute name, e.g. `aria-valuemax`.
*/
MDCSliderFoundation.prototype.convertAttributeValueToNumber = function (attributeValue, attributeName) {
if (attributeValue === null) {
throw new Error('MDCSliderFoundation: `' + attributeName + '` must be non-null.');
}
var value = Number(attributeValue);
if (isNaN(value)) {
throw new Error('MDCSliderFoundation: `' + attributeName + '` value is `' + attributeValue + '`, but must be a number.');
}
return value;
};
/** Checks that the given properties are valid slider values. */
MDCSliderFoundation.prototype.validateProperties = function (_a) {
var min = _a.min,
max = _a.max,
value = _a.value,
valueStart = _a.valueStart,
step = _a.step,
minRange = _a.minRange;
if (min >= max) {
throw new Error("MDCSliderFoundation: min must be strictly less than max. " + ("Current: [min: " + min + ", max: " + max + "]"));
}
if (step <= 0) {
throw new Error("MDCSliderFoundation: step must be a positive number. " + ("Current step: " + step));
}
if (this.isRange) {
if (value < min || value > max || valueStart < min || valueStart > max) {
throw new Error("MDCSliderFoundation: values must be in [min, max] range. " + ("Current values: [start value: " + valueStart + ", end value: ") + (value + ", min: " + min + ", max: " + max + "]"));
}
if (valueStart > value) {
throw new Error("MDCSliderFoundation: start value must be <= end value. " + ("Current values: [start value: " + valueStart + ", end value: " + value + "]"));
}
if (minRange < 0) {
throw new Error("MDCSliderFoundation: minimum range must be non-negative. " + ("Current min range: " + minRange));
}
if (value - valueStart < minRange) {
throw new Error("MDCSliderFoundation: start value and end value must differ by at least " + (minRange + ". Current values: [start value: " + valueStart + ", ") + ("end value: " + value + "]"));
}
var numStepsValueStartFromMin = (valueStart - min) / step;
var numStepsValueFromMin = (value - min) / step;
if (!Number.isInteger(parseFloat(numStepsValueStartFromMin.toFixed(6))) || !Number.isInteger(parseFloat(numStepsValueFromMin.toFixed(6)))) {
throw new Error("MDCSliderFoundation: Slider values must be valid based on the " + ("step value (" + step + "). Current values: [start value: ") + (valueStart + ", end value: " + value + ", min: " + min + "]"));
}
} else {
// Single point slider.
if (value < min || value > max) {
throw new Error("MDCSliderFoundation: value must be in [min, max] range. " + ("Current values: [value: " + value + ", min: " + min + ", max: " + max + "]"));
}
var numStepsValueFromMin = (value - min) / step;
if (!Number.isInteger(parseFloat(numStepsValueFromMin.toFixed(6)))) {
throw new Error("MDCSliderFoundation: Slider value must be valid based on the " + ("step value (" + step + "). Current value: " + value));
}
}
};
MDCSliderFoundation.prototype.registerEventHandlers = function () {
this.adapter.registerWindowEventHandler('resize', this.resizeListener);
if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
// If supported, use pointer events API with #setPointerCapture.
this.adapter.registerEventHandler('pointerdown', this.pointerdownListener);
this.adapter.registerEventHandler('pointerup', this.pointerupListener);
} else {
// Otherwise, fall back to mousedown/touchstart events.
this.adapter.registerEventHandler('mousedown', this.mousedownOrTouchstartListener);
this.adapter.registerEventHandler('touchstart', this.mousedownOrTouchstartListener);
}
if (this.isRange) {
this.adapter.registerThumbEventHandler(types_1.Thumb.START, 'mouseenter', this.thumbMouseenterListener);
this.adapter.registerThumbEventHandler(types_1.Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
this.adapter.registerInputEventHandler(types_1.Thumb.START, 'change', this.inputStartChangeListener);
this.adapter.registerInputEventHandler(types_1.Thumb.START, 'focus', this.inputStartFocusListener);
this.adapter.registerInputEventHandler(types_1.Thumb.START, 'blur', this.inputStartBlurListener);
}
this.adapter.registerThumbEventHandler(types_1.Thumb.END, 'mouseenter', this.thumbMouseenterListener);
this.adapter.registerThumbEventHandler(types_1.Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
this.adapter.registerInputEventHandler(types_1.Thumb.END, 'change', this.inputEndChangeListener);
this.adapter.registerInputEventHandler(types_1.Thumb.END, 'focus', this.inputEndFocusListener);
this.adapter.registerInputEventHandler(types_1.Thumb.END, 'blur', this.inputEndBlurListener);
};
MDCSliderFoundation.prototype.deregisterEventHandlers = function () {
this.adapter.deregisterWindowEventHandler('resize', this.resizeListener);
if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
this.adapter.deregisterEventHandler('pointerdown', this.pointerdownListener);
this.adapter.deregisterEventHandler('pointerup', this.pointerupListener);
} else {
this.adapter.deregisterEventHandler('mousedown', this.mousedownOrTouchstartListener);
this.adapter.deregisterEventHandler('touchstart', this.mousedownOrTouchstartListener);
}
if (this.isRange) {
this.adapter.deregisterThumbEventHandler(types_1.Thumb.START, 'mouseenter', this.thumbMouseenterListener);
this.adapter.deregisterThumbEventHandler(types_1.Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'change', this.inputStartChangeListener);
this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'focus', this.inputStartFocusListener);
this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'blur', this.inputStartBlurListener);
}
this.adapter.deregisterThumbEventHandler(types_1.Thumb.END, 'mouseenter', this.thumbMouseenterListener);
this.adapter.deregisterThumbEventHandler(types_1.Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'change', this.inputEndChangeListener);
this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'focus', this.inputEndFocusListener);
this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'blur', this.inputEndBlurListener);
};
MDCSliderFoundation.prototype.handlePointerup = function () {
this.handleUp();
this.adapter.deregisterEventHandler('pointermove', this.moveListener);
};
MDCSliderFoundation.SUPPORTS_POINTER_EVENTS = HAS_WINDOW && Boolean(window.PointerEvent) &&
// #setPointerCapture is buggy on iOS, so we can't use pointer events
// until the following bug is fixed:
// https://bugs.webkit.org/show_bug.cgi?id=220196
!isIOS();
return MDCSliderFoundation;
}(foundation_1.MDCFoundation);
exports.MDCSliderFoundation = MDCSliderFoundation;
function isIOS() {
// Source:
// https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
return ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform)
// iPad on iOS 13 detection
|| navigator.userAgent.includes('Mac') && 'ontouchend' in document;
}
/**
* Given a number, returns the number of digits that appear after the
* decimal point.
* See
* https://stackoverflow.com/questions/9539513/is-there-a-reliable-way-in-javascript-to-obtain-the-number-of-decimal-places-of
*/
function getNumDecimalPlaces(n) {
// Pull out the fraction and the exponent.
var match = /(?:\.(\d+))?(?:[eE]([+\-]?\d+))?$/.exec(String(n));
// NaN or Infinity or integer.
// We arbitrarily decide that Infinity is integral.
if (!match) return 0;
var fraction = match[1] || ''; // E.g. 1.234e-2 => 234
var exponent = match[2] || 0; // E.g. 1.234e-2 => -2
// Count the number of digits in the fraction and subtract the
// exponent to simulate moving the decimal point left by exponent places.
// 1.234e+2 has 1 fraction digit and '234'.length - 2 == 1
// 1.234e-2 has 5 fraction digit and '234'.length - -2 == 5
return Math.max(0, // lower limit
(fraction === '0' ? 0 : fraction.length) - Number(exponent));
}
/***/ }),
/***/ "./packages/mdc-slider/index.ts":
/*!**************************************!*\
!*** ./packages/mdc-slider/index.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-slider/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-slider/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-slider/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-slider/types.ts":
/*!**************************************!*\
!*** ./packages/mdc-slider/types.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Thumb = exports.TickMark = void 0;
/** Tick mark enum, for discrete sliders. */
var TickMark;
(function (TickMark) {
TickMark[TickMark["ACTIVE"] = 0] = "ACTIVE";
TickMark[TickMark["INACTIVE"] = 1] = "INACTIVE";
})(TickMark = exports.TickMark || (exports.TickMark = {}));
/**
* Thumb types: range slider has two thumbs (START, END) whereas single point
* slider only has one thumb (END).
*/
var Thumb;
(function (Thumb) {
// Thumb at start of slider (e.g. in LTR mode, left thumb on range slider).
Thumb[Thumb["START"] = 1] = "START";
// Thumb at end of slider (e.g. in LTR mode, right thumb on range slider,
// or only thumb on single point slider).
Thumb[Thumb["END"] = 2] = "END";
})(Thumb = exports.Thumb || (exports.Thumb = {}));
/***/ }),
/***/ "./packages/mdc-snackbar/adapter.ts":
/*!******************************************!*\
!*** ./packages/mdc-snackbar/adapter.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-snackbar/component.ts":
/*!********************************************!*\
!*** ./packages/mdc-snackbar/component.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSnackbar = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts");
var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
var SURFACE_SELECTOR = constants_1.strings.SURFACE_SELECTOR,
LABEL_SELECTOR = constants_1.strings.LABEL_SELECTOR,
ACTION_SELECTOR = constants_1.strings.ACTION_SELECTOR,
DISMISS_SELECTOR = constants_1.strings.DISMISS_SELECTOR,
OPENING_EVENT = constants_1.strings.OPENING_EVENT,
OPENED_EVENT = constants_1.strings.OPENED_EVENT,
CLOSING_EVENT = constants_1.strings.CLOSING_EVENT,
CLOSED_EVENT = constants_1.strings.CLOSED_EVENT;
var MDCSnackbar = /** @class */function (_super) {
__extends(MDCSnackbar, _super);
function MDCSnackbar() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCSnackbar.attachTo = function (root) {
return new MDCSnackbar(root);
};
MDCSnackbar.prototype.initialize = function (announcerFactory) {
if (announcerFactory === void 0) {
announcerFactory = function announcerFactory() {
return util.announce;
};
}
this.announce = announcerFactory();
};
MDCSnackbar.prototype.initialSyncWithDOM = function () {
var _this = this;
this.surfaceEl = this.root.querySelector(SURFACE_SELECTOR);
this.labelEl = this.root.querySelector(LABEL_SELECTOR);
this.actionEl = this.root.querySelector(ACTION_SELECTOR);
this.handleKeyDown = function (evt) {
_this.foundation.handleKeyDown(evt);
};
this.handleSurfaceClick = function (evt) {
var target = evt.target;
if (_this.isActionButton(target)) {
_this.foundation.handleActionButtonClick(evt);
} else if (_this.isActionIcon(target)) {
_this.foundation.handleActionIconClick(evt);
}
};
this.registerKeyDownHandler(this.handleKeyDown);
this.registerSurfaceClickHandler(this.handleSurfaceClick);
};
MDCSnackbar.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.deregisterKeyDownHandler(this.handleKeyDown);
this.deregisterSurfaceClickHandler(this.handleSurfaceClick);
};
MDCSnackbar.prototype.open = function () {
this.foundation.open();
};
/**
* @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
* `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
* client-specific values may also be used if desired.
*/
MDCSnackbar.prototype.close = function (reason) {
if (reason === void 0) {
reason = '';
}
this.foundation.close(reason);
};
MDCSnackbar.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = {
addClass: function addClass(className) {
_this.root.classList.add(className);
},
announce: function announce() {
_this.announce(_this.labelEl);
},
notifyClosed: function notifyClosed(reason) {
return _this.emit(CLOSED_EVENT, reason ? { reason: reason } : {});
},
notifyClosing: function notifyClosing(reason) {
return _this.emit(CLOSING_EVENT, reason ? { reason: reason } : {});
},
notifyOpened: function notifyOpened() {
return _this.emit(OPENED_EVENT, {});
},
notifyOpening: function notifyOpening() {
return _this.emit(OPENING_EVENT, {});
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
}
};
return new foundation_1.MDCSnackbarFoundation(adapter);
};
Object.defineProperty(MDCSnackbar.prototype, "timeoutMs", {
get: function get() {
return this.foundation.getTimeoutMs();
},
set: function set(timeoutMs) {
this.foundation.setTimeoutMs(timeoutMs);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSnackbar.prototype, "closeOnEscape", {
get: function get() {
return this.foundation.getCloseOnEscape();
},
set: function set(closeOnEscape) {
this.foundation.setCloseOnEscape(closeOnEscape);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSnackbar.prototype, "isOpen", {
get: function get() {
return this.foundation.isOpen();
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSnackbar.prototype, "labelText", {
get: function get() {
// This property only returns null if the node is a document, DOCTYPE,
// or notation. On Element nodes, it always returns a string.
return this.labelEl.textContent;
},
set: function set(labelText) {
this.labelEl.textContent = labelText;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSnackbar.prototype, "actionButtonText", {
get: function get() {
return this.actionEl.textContent;
},
set: function set(actionButtonText) {
this.actionEl.textContent = actionButtonText;
},
enumerable: false,
configurable: true
});
MDCSnackbar.prototype.registerKeyDownHandler = function (handler) {
this.listen('keydown', handler);
};
MDCSnackbar.prototype.deregisterKeyDownHandler = function (handler) {
this.unlisten('keydown', handler);
};
MDCSnackbar.prototype.registerSurfaceClickHandler = function (handler) {
this.surfaceEl.addEventListener('click', handler);
};
MDCSnackbar.prototype.deregisterSurfaceClickHandler = function (handler) {
this.surfaceEl.removeEventListener('click', handler);
};
MDCSnackbar.prototype.isActionButton = function (target) {
return Boolean(ponyfill_1.closest(target, ACTION_SELECTOR));
};
MDCSnackbar.prototype.isActionIcon = function (target) {
return Boolean(ponyfill_1.closest(target, DISMISS_SELECTOR));
};
return MDCSnackbar;
}(component_1.MDCComponent);
exports.MDCSnackbar = MDCSnackbar;
/***/ }),
/***/ "./packages/mdc-snackbar/constants.ts":
/*!********************************************!*\
!*** ./packages/mdc-snackbar/constants.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.numbers = exports.strings = exports.cssClasses = void 0;
var cssClasses = {
CLOSING: 'mdc-snackbar--closing',
OPEN: 'mdc-snackbar--open',
OPENING: 'mdc-snackbar--opening'
};
exports.cssClasses = cssClasses;
var strings = {
ACTION_SELECTOR: '.mdc-snackbar__action',
ARIA_LIVE_LABEL_TEXT_ATTR: 'data-mdc-snackbar-label-text',
CLOSED_EVENT: 'MDCSnackbar:closed',
CLOSING_EVENT: 'MDCSnackbar:closing',
DISMISS_SELECTOR: '.mdc-snackbar__dismiss',
LABEL_SELECTOR: '.mdc-snackbar__label',
OPENED_EVENT: 'MDCSnackbar:opened',
OPENING_EVENT: 'MDCSnackbar:opening',
REASON_ACTION: 'action',
REASON_DISMISS: 'dismiss',
SURFACE_SELECTOR: '.mdc-snackbar__surface'
};
exports.strings = strings;
var numbers = {
DEFAULT_AUTO_DISMISS_TIMEOUT_MS: 5000,
INDETERMINATE: -1,
MAX_AUTO_DISMISS_TIMEOUT_MS: 10000,
MIN_AUTO_DISMISS_TIMEOUT_MS: 4000,
// These variables need to be kept in sync with the values in _variables.scss.
SNACKBAR_ANIMATION_CLOSE_TIME_MS: 75,
SNACKBAR_ANIMATION_OPEN_TIME_MS: 150,
/**
* Number of milliseconds to wait between temporarily clearing the label text
* in the DOM and subsequently restoring it. This is necessary to force IE 11
* to pick up the `aria-live` content change and announce it to the user.
*/
ARIA_LIVE_DELAY_MS: 1000
};
exports.numbers = numbers;
/***/ }),
/***/ "./packages/mdc-snackbar/foundation.ts":
/*!*********************************************!*\
!*** ./packages/mdc-snackbar/foundation.ts ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSnackbarFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
var OPENING = constants_1.cssClasses.OPENING,
OPEN = constants_1.cssClasses.OPEN,
CLOSING = constants_1.cssClasses.CLOSING;
var REASON_ACTION = constants_1.strings.REASON_ACTION,
REASON_DISMISS = constants_1.strings.REASON_DISMISS;
var MDCSnackbarFoundation = /** @class */function (_super) {
__extends(MDCSnackbarFoundation, _super);
function MDCSnackbarFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCSnackbarFoundation.defaultAdapter), adapter)) || this;
_this.opened = false;
_this.animationFrame = 0;
_this.animationTimer = 0;
_this.autoDismissTimer = 0;
_this.autoDismissTimeoutMs = constants_1.numbers.DEFAULT_AUTO_DISMISS_TIMEOUT_MS;
_this.closeOnEscape = true;
return _this;
}
Object.defineProperty(MDCSnackbarFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSnackbarFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSnackbarFoundation, "numbers", {
get: function get() {
return constants_1.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSnackbarFoundation, "defaultAdapter", {
get: function get() {
return {
addClass: function addClass() {
return undefined;
},
announce: function announce() {
return undefined;
},
notifyClosed: function notifyClosed() {
return undefined;
},
notifyClosing: function notifyClosing() {
return undefined;
},
notifyOpened: function notifyOpened() {
return undefined;
},
notifyOpening: function notifyOpening() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCSnackbarFoundation.prototype.destroy = function () {
this.clearAutoDismissTimer();
cancelAnimationFrame(this.animationFrame);
this.animationFrame = 0;
clearTimeout(this.animationTimer);
this.animationTimer = 0;
this.adapter.removeClass(OPENING);
this.adapter.removeClass(OPEN);
this.adapter.removeClass(CLOSING);
};
MDCSnackbarFoundation.prototype.open = function () {
var _this = this;
this.clearAutoDismissTimer();
this.opened = true;
this.adapter.notifyOpening();
this.adapter.removeClass(CLOSING);
this.adapter.addClass(OPENING);
this.adapter.announce();
// Wait a frame once display is no longer "none", to establish basis for animation
this.runNextAnimationFrame(function () {
_this.adapter.addClass(OPEN);
_this.animationTimer = setTimeout(function () {
var timeoutMs = _this.getTimeoutMs();
_this.handleAnimationTimerEnd();
_this.adapter.notifyOpened();
if (timeoutMs !== constants_1.numbers.INDETERMINATE) {
_this.autoDismissTimer = setTimeout(function () {
_this.close(REASON_DISMISS);
}, timeoutMs);
}
}, constants_1.numbers.SNACKBAR_ANIMATION_OPEN_TIME_MS);
});
};
/**
* @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
* `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
* client-specific values may also be used if desired.
*/
MDCSnackbarFoundation.prototype.close = function (reason) {
var _this = this;
if (reason === void 0) {
reason = '';
}
if (!this.opened) {
// Avoid redundant close calls (and events), e.g. repeated interactions as the snackbar is animating closed
return;
}
cancelAnimationFrame(this.animationFrame);
this.animationFrame = 0;
this.clearAutoDismissTimer();
this.opened = false;
this.adapter.notifyClosing(reason);
this.adapter.addClass(constants_1.cssClasses.CLOSING);
this.adapter.removeClass(constants_1.cssClasses.OPEN);
this.adapter.removeClass(constants_1.cssClasses.OPENING);
clearTimeout(this.animationTimer);
this.animationTimer = setTimeout(function () {
_this.handleAnimationTimerEnd();
_this.adapter.notifyClosed(reason);
}, constants_1.numbers.SNACKBAR_ANIMATION_CLOSE_TIME_MS);
};
MDCSnackbarFoundation.prototype.isOpen = function () {
return this.opened;
};
MDCSnackbarFoundation.prototype.getTimeoutMs = function () {
return this.autoDismissTimeoutMs;
};
MDCSnackbarFoundation.prototype.setTimeoutMs = function (timeoutMs) {
// Use shorter variable names to make the code more readable
var minValue = constants_1.numbers.MIN_AUTO_DISMISS_TIMEOUT_MS;
var maxValue = constants_1.numbers.MAX_AUTO_DISMISS_TIMEOUT_MS;
var indeterminateValue = constants_1.numbers.INDETERMINATE;
if (timeoutMs === constants_1.numbers.INDETERMINATE || timeoutMs <= maxValue && timeoutMs >= minValue) {
this.autoDismissTimeoutMs = timeoutMs;
} else {
throw new Error("\n timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + "\n (or " + indeterminateValue + " to disable), but got '" + timeoutMs + "'");
}
};
MDCSnackbarFoundation.prototype.getCloseOnEscape = function () {
return this.closeOnEscape;
};
MDCSnackbarFoundation.prototype.setCloseOnEscape = function (closeOnEscape) {
this.closeOnEscape = closeOnEscape;
};
MDCSnackbarFoundation.prototype.handleKeyDown = function (evt) {
var isEscapeKey = evt.key === 'Escape' || evt.keyCode === 27;
if (isEscapeKey && this.getCloseOnEscape()) {
this.close(REASON_DISMISS);
}
};
MDCSnackbarFoundation.prototype.handleActionButtonClick = function (_evt) {
this.close(REASON_ACTION);
};
MDCSnackbarFoundation.prototype.handleActionIconClick = function (_evt) {
this.close(REASON_DISMISS);
};
MDCSnackbarFoundation.prototype.clearAutoDismissTimer = function () {
clearTimeout(this.autoDismissTimer);
this.autoDismissTimer = 0;
};
MDCSnackbarFoundation.prototype.handleAnimationTimerEnd = function () {
this.animationTimer = 0;
this.adapter.removeClass(constants_1.cssClasses.OPENING);
this.adapter.removeClass(constants_1.cssClasses.CLOSING);
};
/**
* Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
*/
MDCSnackbarFoundation.prototype.runNextAnimationFrame = function (callback) {
var _this = this;
cancelAnimationFrame(this.animationFrame);
this.animationFrame = requestAnimationFrame(function () {
_this.animationFrame = 0;
clearTimeout(_this.animationTimer);
_this.animationTimer = setTimeout(callback, 0);
});
};
return MDCSnackbarFoundation;
}(foundation_1.MDCFoundation);
exports.MDCSnackbarFoundation = MDCSnackbarFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCSnackbarFoundation;
/***/ }),
/***/ "./packages/mdc-snackbar/index.ts":
/*!****************************************!*\
!*** ./packages/mdc-snackbar/index.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.util = void 0;
var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
exports.util = util;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-snackbar/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-snackbar/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-snackbar/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-snackbar/types.ts":
/*!****************************************!*\
!*** ./packages/mdc-snackbar/types.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-snackbar/util.ts":
/*!***************************************!*\
!*** ./packages/mdc-snackbar/util.ts ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.announce = void 0;
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
var ARIA_LIVE_DELAY_MS = constants_1.numbers.ARIA_LIVE_DELAY_MS;
var ARIA_LIVE_LABEL_TEXT_ATTR = constants_1.strings.ARIA_LIVE_LABEL_TEXT_ATTR;
function announce(ariaEl, labelEl) {
if (labelEl === void 0) {
labelEl = ariaEl;
}
var priority = ariaEl.getAttribute('aria-live');
// Trim text to ignore ` ` (see below).
// textContent is only null if the node is a document, DOCTYPE, or notation.
var labelText = labelEl.textContent.trim();
if (!labelText || !priority) {
return;
}
// Temporarily disable `aria-live` to prevent JAWS+Firefox from announcing the message twice.
ariaEl.setAttribute('aria-live', 'off');
// Temporarily clear `textContent` to force a DOM mutation event that will be detected by screen readers.
// `aria-live` elements are only announced when the element's `textContent` *changes*, so snackbars
// sent to the browser in the initial HTML response won't be read unless we clear the element's `textContent` first.
// Similarly, displaying the same snackbar message twice in a row doesn't trigger a DOM mutation event,
// so screen readers won't announce the second message unless we first clear `textContent`.
//
// We have to clear the label text two different ways to make it work in all browsers and screen readers:
//
// 1. `textContent = ''` is required for IE11 + JAWS
// 2. `innerHTML = ' '` is required for Chrome + JAWS and NVDA
//
// All other browser/screen reader combinations support both methods.
//
// The wrapper `<span>` visually hides the space character so that it doesn't cause jank when added/removed.
// N.B.: Setting `position: absolute`, `opacity: 0`, or `height: 0` prevents Chrome from detecting the DOM change.
//
// This technique has been tested in:
//
// * JAWS 2019:
// - Chrome 70
// - Firefox 60 (ESR)
// - IE 11
// * NVDA 2018:
// - Chrome 70
// - Firefox 60 (ESR)
// - IE 11
// * ChromeVox 53
labelEl.textContent = '';
// For the second case, assigning a string directly to innerHTML results in a
// Trusted Types violation. Work around that by using document.createElement.
var span = document.createElement('span');
span.setAttribute('style', 'display: inline-block; width: 0; height: 1px;');
span.textContent = "\xA0"; // Equivalent to
labelEl.appendChild(span);
// Prevent visual jank by temporarily displaying the label text in the ::before pseudo-element.
// CSS generated content is normally announced by screen readers
// (except in IE 11; see https://tink.uk/accessibility-support-for-css-generated-content/);
// however, `aria-live` is turned off, so this DOM update will be ignored by screen readers.
labelEl.setAttribute(ARIA_LIVE_LABEL_TEXT_ATTR, labelText);
setTimeout(function () {
// Allow screen readers to announce changes to the DOM again.
ariaEl.setAttribute('aria-live', priority);
// Remove the message from the ::before pseudo-element.
labelEl.removeAttribute(ARIA_LIVE_LABEL_TEXT_ATTR);
// Restore the original label text, which will be announced by screen readers.
labelEl.textContent = labelText;
}, ARIA_LIVE_DELAY_MS);
}
exports.announce = announce;
/***/ }),
/***/ "./packages/mdc-switch/adapter.ts":
/*!****************************************!*\
!*** ./packages/mdc-switch/adapter.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2021 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-switch/component.ts":
/*!******************************************!*\
!*** ./packages/mdc-switch/component.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2021 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSwitch = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-switch/constants.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-switch/foundation.ts");
/**
* `MDCSwitch` provides a component implementation of a Material Design switch.
*/
var MDCSwitch = /** @class */function (_super) {
__extends(MDCSwitch, _super);
function MDCSwitch(root, foundation) {
var _this = _super.call(this, root, foundation) || this;
_this.root = root;
return _this;
}
/**
* Creates a new `MDCSwitch` and attaches it to the given root element.
* @param root The root to attach to.
* @return the new component instance.
*/
MDCSwitch.attachTo = function (root) {
return new MDCSwitch(root);
};
MDCSwitch.prototype.initialize = function () {
this.ripple = new component_2.MDCRipple(this.root, this.createRippleFoundation());
};
MDCSwitch.prototype.initialSyncWithDOM = function () {
var rippleElement = this.root.querySelector(constants_1.Selectors.RIPPLE);
if (!rippleElement) {
throw new Error("Switch " + constants_1.Selectors.RIPPLE + " element is required.");
}
this.rippleElement = rippleElement;
this.root.addEventListener('click', this.foundation.handleClick);
this.foundation.initFromDOM();
};
MDCSwitch.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.ripple.destroy();
this.root.removeEventListener('click', this.foundation.handleClick);
};
MDCSwitch.prototype.getDefaultFoundation = function () {
return new foundation_2.MDCSwitchRenderFoundation(this.createAdapter());
};
MDCSwitch.prototype.createAdapter = function () {
var _this = this;
return {
addClass: function addClass(className) {
_this.root.classList.add(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
isDisabled: function isDisabled() {
return _this.root.disabled;
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
setAriaChecked: function setAriaChecked(ariaChecked) {
return _this.root.setAttribute('aria-checked', ariaChecked);
},
setDisabled: function setDisabled(disabled) {
_this.root.disabled = disabled;
},
state: this
};
};
MDCSwitch.prototype.createRippleFoundation = function () {
return new foundation_1.MDCRippleFoundation(this.createRippleAdapter());
};
MDCSwitch.prototype.createRippleAdapter = function () {
var _this = this;
return __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { computeBoundingRect: function computeBoundingRect() {
return _this.rippleElement.getBoundingClientRect();
}, isUnbounded: function isUnbounded() {
return true;
} });
};
return MDCSwitch;
}(component_1.MDCComponent);
exports.MDCSwitch = MDCSwitch;
/***/ }),
/***/ "./packages/mdc-switch/constants.ts":
/*!******************************************!*\
!*** ./packages/mdc-switch/constants.ts ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2021 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Selectors = exports.CssClasses = void 0;
/**
* CSS classes used for switch.
*/
var CssClasses;
(function (CssClasses) {
CssClasses["PROCESSING"] = "mdc-switch--processing";
CssClasses["SELECTED"] = "mdc-switch--selected";
CssClasses["UNSELECTED"] = "mdc-switch--unselected";
})(CssClasses = exports.CssClasses || (exports.CssClasses = {}));
/**
* Query selectors used for switch.
*/
var Selectors;
(function (Selectors) {
Selectors["RIPPLE"] = ".mdc-switch__ripple";
})(Selectors = exports.Selectors || (exports.Selectors = {}));
/***/ }),
/***/ "./packages/mdc-switch/deprecated/adapter.ts":
/*!***************************************************!*\
!*** ./packages/mdc-switch/deprecated/adapter.ts ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-switch/deprecated/component.ts":
/*!*****************************************************!*\
!*** ./packages/mdc-switch/deprecated/component.ts ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
ar.push(r.value);
}
} catch (error) {
e = { error: error };
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};
var __spreadArray = this && this.__spreadArray || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
to[j] = from[i];
}return to;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSwitch = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-switch/deprecated/foundation.ts");
var MDCSwitch = /** @class */function (_super) {
__extends(MDCSwitch, _super);
function MDCSwitch() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.rippleSurface = _this.createRipple();
return _this;
}
MDCSwitch.attachTo = function (root) {
return new MDCSwitch(root);
};
MDCSwitch.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.rippleSurface.destroy();
this.nativeControl.removeEventListener('change', this.changeHandler);
};
MDCSwitch.prototype.initialSyncWithDOM = function () {
var _this = this;
this.changeHandler = function () {
var _a;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
(_a = _this.foundation).handleChange.apply(_a, __spreadArray([], __read(args)));
};
this.nativeControl.addEventListener('change', this.changeHandler);
// Sometimes the checked state of the input element is saved in the history.
// The switch styling should match the checked state of the input element.
// Do an initial sync between the native control and the foundation.
this.checked = this.checked;
};
MDCSwitch.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
setNativeControlChecked: function setNativeControlChecked(checked) {
return _this.nativeControl.checked = checked;
},
setNativeControlDisabled: function setNativeControlDisabled(disabled) {
return _this.nativeControl.disabled = disabled;
},
setNativeControlAttr: function setNativeControlAttr(attr, value) {
_this.nativeControl.setAttribute(attr, value);
}
};
return new foundation_2.MDCSwitchFoundation(adapter);
};
Object.defineProperty(MDCSwitch.prototype, "ripple", {
get: function get() {
return this.rippleSurface;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSwitch.prototype, "checked", {
get: function get() {
return this.nativeControl.checked;
},
set: function set(checked) {
this.foundation.setChecked(checked);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSwitch.prototype, "disabled", {
get: function get() {
return this.nativeControl.disabled;
},
set: function set(disabled) {
this.foundation.setDisabled(disabled);
},
enumerable: false,
configurable: true
});
MDCSwitch.prototype.createRipple = function () {
var _this = this;
var RIPPLE_SURFACE_SELECTOR = foundation_2.MDCSwitchFoundation.strings.RIPPLE_SURFACE_SELECTOR;
var rippleSurface = this.root.querySelector(RIPPLE_SURFACE_SELECTOR);
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { addClass: function addClass(className) {
return rippleSurface.classList.add(className);
}, computeBoundingRect: function computeBoundingRect() {
return rippleSurface.getBoundingClientRect();
}, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
_this.nativeControl.removeEventListener(evtType, handler, events_1.applyPassive());
}, isSurfaceActive: function isSurfaceActive() {
return ponyfill_1.matches(_this.nativeControl, ':active');
}, isUnbounded: function isUnbounded() {
return true;
}, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
_this.nativeControl.addEventListener(evtType, handler, events_1.applyPassive());
}, removeClass: function removeClass(className) {
rippleSurface.classList.remove(className);
}, updateCssVariable: function updateCssVariable(varName, value) {
rippleSurface.style.setProperty(varName, value);
} });
return new component_2.MDCRipple(this.root, new foundation_1.MDCRippleFoundation(adapter));
};
Object.defineProperty(MDCSwitch.prototype, "nativeControl", {
get: function get() {
var NATIVE_CONTROL_SELECTOR = foundation_2.MDCSwitchFoundation.strings.NATIVE_CONTROL_SELECTOR;
return this.root.querySelector(NATIVE_CONTROL_SELECTOR);
},
enumerable: false,
configurable: true
});
return MDCSwitch;
}(component_1.MDCComponent);
exports.MDCSwitch = MDCSwitch;
/***/ }),
/***/ "./packages/mdc-switch/deprecated/constants.ts":
/*!*****************************************************!*\
!*** ./packages/mdc-switch/deprecated/constants.ts ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.cssClasses = void 0;
/** CSS classes used by the switch. */
var cssClasses = {
/** Class used for a switch that is in the "checked" (on) position. */
CHECKED: 'mdc-switch--checked',
/** Class used for a switch that is disabled. */
DISABLED: 'mdc-switch--disabled'
};
exports.cssClasses = cssClasses;
/** String constants used by the switch. */
var strings = {
/** Aria attribute for checked or unchecked state of switch */
ARIA_CHECKED_ATTR: 'aria-checked',
/** A CSS selector used to locate the native HTML control for the switch. */
NATIVE_CONTROL_SELECTOR: '.mdc-switch__native-control',
/** A CSS selector used to locate the ripple surface element for the switch. */
RIPPLE_SURFACE_SELECTOR: '.mdc-switch__thumb-underlay'
};
exports.strings = strings;
/***/ }),
/***/ "./packages/mdc-switch/deprecated/foundation.ts":
/*!******************************************************!*\
!*** ./packages/mdc-switch/deprecated/foundation.ts ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSwitchFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-switch/deprecated/constants.ts");
var MDCSwitchFoundation = /** @class */function (_super) {
__extends(MDCSwitchFoundation, _super);
function MDCSwitchFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCSwitchFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCSwitchFoundation, "strings", {
/** The string constants used by the switch. */
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSwitchFoundation, "cssClasses", {
/** The CSS classes used by the switch. */
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCSwitchFoundation, "defaultAdapter", {
/** The default Adapter for the switch. */
get: function get() {
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
setNativeControlChecked: function setNativeControlChecked() {
return undefined;
},
setNativeControlDisabled: function setNativeControlDisabled() {
return undefined;
},
setNativeControlAttr: function setNativeControlAttr() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
/** Sets the checked state of the switch. */
MDCSwitchFoundation.prototype.setChecked = function (checked) {
this.adapter.setNativeControlChecked(checked);
this.updateAriaChecked(checked);
this.updateCheckedStyling(checked);
};
/** Sets the disabled state of the switch. */
MDCSwitchFoundation.prototype.setDisabled = function (disabled) {
this.adapter.setNativeControlDisabled(disabled);
if (disabled) {
this.adapter.addClass(constants_1.cssClasses.DISABLED);
} else {
this.adapter.removeClass(constants_1.cssClasses.DISABLED);
}
};
/** Handles the change event for the switch native control. */
MDCSwitchFoundation.prototype.handleChange = function (evt) {
var nativeControl = evt.target;
this.updateAriaChecked(nativeControl.checked);
this.updateCheckedStyling(nativeControl.checked);
};
/** Updates the styling of the switch based on its checked state. */
MDCSwitchFoundation.prototype.updateCheckedStyling = function (checked) {
if (checked) {
this.adapter.addClass(constants_1.cssClasses.CHECKED);
} else {
this.adapter.removeClass(constants_1.cssClasses.CHECKED);
}
};
MDCSwitchFoundation.prototype.updateAriaChecked = function (checked) {
this.adapter.setNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR, "" + !!checked);
};
return MDCSwitchFoundation;
}(foundation_1.MDCFoundation);
exports.MDCSwitchFoundation = MDCSwitchFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCSwitchFoundation;
/***/ }),
/***/ "./packages/mdc-switch/deprecated/index.ts":
/*!*************************************************!*\
!*** ./packages/mdc-switch/deprecated/index.ts ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-switch/deprecated/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-switch/deprecated/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-switch/deprecated/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-switch/deprecated/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-switch/foundation.ts":
/*!*******************************************!*\
!*** ./packages/mdc-switch/foundation.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2021 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSwitchRenderFoundation = exports.MDCSwitchFoundation = void 0;
var observer_foundation_1 = __webpack_require__(/*! @material/base/observer-foundation */ "./packages/mdc-base/observer-foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-switch/constants.ts");
/**
* `MDCSwitchFoundation` provides a state-only foundation for a switch
* component.
*
* State observers and event handler entrypoints update a component's adapter's
* state with the logic needed for switch to function.
*/
var MDCSwitchFoundation = /** @class */function (_super) {
__extends(MDCSwitchFoundation, _super);
function MDCSwitchFoundation(adapter) {
var _this = _super.call(this, adapter) || this;
_this.handleClick = _this.handleClick.bind(_this);
return _this;
}
/**
* Initializes the foundation and starts observing state changes.
*/
MDCSwitchFoundation.prototype.init = function () {
this.observe(this.adapter.state, {
disabled: this.stopProcessingIfDisabled,
processing: this.stopProcessingIfDisabled
});
};
/**
* Event handler for switch click events. Clicking on a switch will toggle its
* selected state.
*/
MDCSwitchFoundation.prototype.handleClick = function () {
if (this.adapter.state.disabled) {
return;
}
this.adapter.state.selected = !this.adapter.state.selected;
};
MDCSwitchFoundation.prototype.stopProcessingIfDisabled = function () {
if (this.adapter.state.disabled) {
this.adapter.state.processing = false;
}
};
return MDCSwitchFoundation;
}(observer_foundation_1.MDCObserverFoundation);
exports.MDCSwitchFoundation = MDCSwitchFoundation;
/**
* `MDCSwitchRenderFoundation` provides a state and rendering foundation for a
* switch component.
*
* State observers and event handler entrypoints update a component's
* adapter's state with the logic needed for switch to function.
*
* In response to state changes, the rendering foundation uses the component's
* render adapter to keep the component's DOM updated with the state.
*/
var MDCSwitchRenderFoundation = /** @class */function (_super) {
__extends(MDCSwitchRenderFoundation, _super);
function MDCSwitchRenderFoundation() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Initializes the foundation and starts observing state changes.
*/
MDCSwitchRenderFoundation.prototype.init = function () {
_super.prototype.init.call(this);
this.observe(this.adapter.state, {
disabled: this.onDisabledChange,
processing: this.onProcessingChange,
selected: this.onSelectedChange
});
};
/**
* Initializes the foundation from a server side rendered (SSR) component.
* This will sync the adapter's state with the current state of the DOM.
*
* This method should be called after `init()`.
*/
MDCSwitchRenderFoundation.prototype.initFromDOM = function () {
// Turn off observers while setting state
this.setObserversEnabled(this.adapter.state, false);
this.adapter.state.selected = this.adapter.hasClass(constants_1.CssClasses.SELECTED);
// Ensure aria-checked is set if attribute is not present
this.onSelectedChange();
this.adapter.state.disabled = this.adapter.isDisabled();
this.adapter.state.processing = this.adapter.hasClass(constants_1.CssClasses.PROCESSING);
// Re-observe state
this.setObserversEnabled(this.adapter.state, true);
this.stopProcessingIfDisabled();
};
MDCSwitchRenderFoundation.prototype.onDisabledChange = function () {
this.adapter.setDisabled(this.adapter.state.disabled);
};
MDCSwitchRenderFoundation.prototype.onProcessingChange = function () {
this.toggleClass(this.adapter.state.processing, constants_1.CssClasses.PROCESSING);
};
MDCSwitchRenderFoundation.prototype.onSelectedChange = function () {
this.adapter.setAriaChecked(String(this.adapter.state.selected));
this.toggleClass(this.adapter.state.selected, constants_1.CssClasses.SELECTED);
this.toggleClass(!this.adapter.state.selected, constants_1.CssClasses.UNSELECTED);
};
MDCSwitchRenderFoundation.prototype.toggleClass = function (addClass, className) {
if (addClass) {
this.adapter.addClass(className);
} else {
this.adapter.removeClass(className);
}
};
return MDCSwitchRenderFoundation;
}(MDCSwitchFoundation);
exports.MDCSwitchRenderFoundation = MDCSwitchRenderFoundation;
/***/ }),
/***/ "./packages/mdc-switch/index.ts":
/*!**************************************!*\
!*** ./packages/mdc-switch/index.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2021 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.deprecated = void 0;
// TODO(b/185410690): remove deprecated export
var deprecated = __importStar(__webpack_require__(/*! ./deprecated */ "./packages/mdc-switch/deprecated/index.ts"));
exports.deprecated = deprecated;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-switch/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-switch/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-switch/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-switch/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-tab-bar/adapter.ts":
/*!*****************************************!*\
!*** ./packages/mdc-tab-bar/adapter.ts ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-tab-bar/component.ts":
/*!*******************************************!*\
!*** ./packages/mdc-tab-bar/component.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTabBar = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var component_2 = __webpack_require__(/*! @material/tab-scroller/component */ "./packages/mdc-tab-scroller/component.ts");
var component_3 = __webpack_require__(/*! @material/tab/component */ "./packages/mdc-tab/component.ts");
var foundation_1 = __webpack_require__(/*! @material/tab/foundation */ "./packages/mdc-tab/foundation.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-bar/foundation.ts");
var strings = foundation_2.MDCTabBarFoundation.strings;
var tabIdCounter = 0;
var MDCTabBar = /** @class */function (_super) {
__extends(MDCTabBar, _super);
function MDCTabBar() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTabBar.attachTo = function (root) {
return new MDCTabBar(root);
};
Object.defineProperty(MDCTabBar.prototype, "focusOnActivate", {
set: function set(focusOnActivate) {
var e_1, _a;
try {
for (var _b = __values(this.tabList), _c = _b.next(); !_c.done; _c = _b.next()) {
var tab = _c.value;
tab.focusOnActivate = focusOnActivate;
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_1) throw e_1.error;
}
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTabBar.prototype, "useAutomaticActivation", {
set: function set(useAutomaticActivation) {
this.foundation.setUseAutomaticActivation(useAutomaticActivation);
},
enumerable: false,
configurable: true
});
MDCTabBar.prototype.initialize = function (tabFactory, tabScrollerFactory) {
if (tabFactory === void 0) {
tabFactory = function tabFactory(el) {
return new component_3.MDCTab(el);
};
}
if (tabScrollerFactory === void 0) {
tabScrollerFactory = function tabScrollerFactory(el) {
return new component_2.MDCTabScroller(el);
};
}
this.tabList = this.instantiateTabs(tabFactory);
this.tabScroller = this.instantiatetabScroller(tabScrollerFactory);
};
MDCTabBar.prototype.initialSyncWithDOM = function () {
var _this = this;
this.handleTabInteraction = function (evt) {
_this.foundation.handleTabInteraction(evt);
};
this.handleKeyDown = function (evt) {
_this.foundation.handleKeyDown(evt);
};
this.listen(foundation_1.MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction);
this.listen('keydown', this.handleKeyDown);
for (var i = 0; i < this.tabList.length; i++) {
if (this.tabList[i].active) {
this.scrollIntoView(i);
break;
}
}
};
MDCTabBar.prototype.destroy = function () {
var e_2, _a;
_super.prototype.destroy.call(this);
this.unlisten(foundation_1.MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction);
this.unlisten('keydown', this.handleKeyDown);
try {
for (var _b = __values(this.tabList), _c = _b.next(); !_c.done; _c = _b.next()) {
var tab = _c.value;
tab.destroy();
}
} catch (e_2_1) {
e_2 = { error: e_2_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_2) throw e_2.error;
}
}
if (this.tabScroller) {
this.tabScroller.destroy();
}
};
MDCTabBar.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
scrollTo: function scrollTo(scrollX) {
_this.tabScroller.scrollTo(scrollX);
},
incrementScroll: function incrementScroll(scrollXIncrement) {
_this.tabScroller.incrementScroll(scrollXIncrement);
},
getScrollPosition: function getScrollPosition() {
return _this.tabScroller.getScrollPosition();
},
getScrollContentWidth: function getScrollContentWidth() {
return _this.tabScroller.getScrollContentWidth();
},
getOffsetWidth: function getOffsetWidth() {
return _this.root.offsetWidth;
},
isRTL: function isRTL() {
return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
},
setActiveTab: function setActiveTab(index) {
_this.foundation.activateTab(index);
},
activateTabAtIndex: function activateTabAtIndex(index, clientRect) {
_this.tabList[index].activate(clientRect);
},
deactivateTabAtIndex: function deactivateTabAtIndex(index) {
_this.tabList[index].deactivate();
},
focusTabAtIndex: function focusTabAtIndex(index) {
_this.tabList[index].focus();
},
getTabIndicatorClientRectAtIndex: function getTabIndicatorClientRectAtIndex(index) {
return _this.tabList[index].computeIndicatorClientRect();
},
getTabDimensionsAtIndex: function getTabDimensionsAtIndex(index) {
return _this.tabList[index].computeDimensions();
},
getPreviousActiveTabIndex: function getPreviousActiveTabIndex() {
for (var i = 0; i < _this.tabList.length; i++) {
if (_this.tabList[i].active) {
return i;
}
}
return -1;
},
getFocusedTabIndex: function getFocusedTabIndex() {
var tabElements = _this.getTabElements();
var activeElement = document.activeElement;
return tabElements.indexOf(activeElement);
},
getIndexOfTabById: function getIndexOfTabById(id) {
for (var i = 0; i < _this.tabList.length; i++) {
if (_this.tabList[i].id === id) {
return i;
}
}
return -1;
},
getTabListLength: function getTabListLength() {
return _this.tabList.length;
},
notifyTabActivated: function notifyTabActivated(index) {
return _this.emit(strings.TAB_ACTIVATED_EVENT, { index: index }, true);
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_2.MDCTabBarFoundation(adapter);
};
/**
* Activates the tab at the given index
* @param index The index of the tab
*/
MDCTabBar.prototype.activateTab = function (index) {
this.foundation.activateTab(index);
};
/**
* Scrolls the tab at the given index into view
* @param index THe index of the tab
*/
MDCTabBar.prototype.scrollIntoView = function (index) {
this.foundation.scrollIntoView(index);
};
/**
* Returns all the tab elements in a nice clean array
*/
MDCTabBar.prototype.getTabElements = function () {
return [].slice.call(this.root.querySelectorAll(strings.TAB_SELECTOR));
};
/**
* Instantiates tab components on all child tab elements
*/
MDCTabBar.prototype.instantiateTabs = function (tabFactory) {
return this.getTabElements().map(function (el) {
el.id = el.id || "mdc-tab-" + ++tabIdCounter;
return tabFactory(el);
});
};
/**
* Instantiates tab scroller component on the child tab scroller element
*/
MDCTabBar.prototype.instantiatetabScroller = function (tabScrollerFactory) {
var tabScrollerElement = this.root.querySelector(strings.TAB_SCROLLER_SELECTOR);
if (tabScrollerElement) {
return tabScrollerFactory(tabScrollerElement);
}
return null;
};
return MDCTabBar;
}(component_1.MDCComponent);
exports.MDCTabBar = MDCTabBar;
/***/ }),
/***/ "./packages/mdc-tab-bar/constants.ts":
/*!*******************************************!*\
!*** ./packages/mdc-tab-bar/constants.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.numbers = void 0;
var strings = {
ARROW_LEFT_KEY: 'ArrowLeft',
ARROW_RIGHT_KEY: 'ArrowRight',
END_KEY: 'End',
ENTER_KEY: 'Enter',
HOME_KEY: 'Home',
SPACE_KEY: 'Space',
TAB_ACTIVATED_EVENT: 'MDCTabBar:activated',
TAB_SCROLLER_SELECTOR: '.mdc-tab-scroller',
TAB_SELECTOR: '.mdc-tab'
};
exports.strings = strings;
var numbers = {
ARROW_LEFT_KEYCODE: 37,
ARROW_RIGHT_KEYCODE: 39,
END_KEYCODE: 35,
ENTER_KEYCODE: 13,
EXTRA_SCROLL_AMOUNT: 20,
HOME_KEYCODE: 36,
SPACE_KEYCODE: 32
};
exports.numbers = numbers;
/***/ }),
/***/ "./packages/mdc-tab-bar/foundation.ts":
/*!********************************************!*\
!*** ./packages/mdc-tab-bar/foundation.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTabBarFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-bar/constants.ts");
var ACCEPTABLE_KEYS = new Set();
// IE11 has no support for new Set with iterable so we need to initialize this by hand
ACCEPTABLE_KEYS.add(constants_1.strings.ARROW_LEFT_KEY);
ACCEPTABLE_KEYS.add(constants_1.strings.ARROW_RIGHT_KEY);
ACCEPTABLE_KEYS.add(constants_1.strings.END_KEY);
ACCEPTABLE_KEYS.add(constants_1.strings.HOME_KEY);
ACCEPTABLE_KEYS.add(constants_1.strings.ENTER_KEY);
ACCEPTABLE_KEYS.add(constants_1.strings.SPACE_KEY);
var KEYCODE_MAP = new Map();
// IE11 has no support for new Map with iterable so we need to initialize this by hand
KEYCODE_MAP.set(constants_1.numbers.ARROW_LEFT_KEYCODE, constants_1.strings.ARROW_LEFT_KEY);
KEYCODE_MAP.set(constants_1.numbers.ARROW_RIGHT_KEYCODE, constants_1.strings.ARROW_RIGHT_KEY);
KEYCODE_MAP.set(constants_1.numbers.END_KEYCODE, constants_1.strings.END_KEY);
KEYCODE_MAP.set(constants_1.numbers.HOME_KEYCODE, constants_1.strings.HOME_KEY);
KEYCODE_MAP.set(constants_1.numbers.ENTER_KEYCODE, constants_1.strings.ENTER_KEY);
KEYCODE_MAP.set(constants_1.numbers.SPACE_KEYCODE, constants_1.strings.SPACE_KEY);
var MDCTabBarFoundation = /** @class */function (_super) {
__extends(MDCTabBarFoundation, _super);
function MDCTabBarFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCTabBarFoundation.defaultAdapter), adapter)) || this;
_this.useAutomaticActivation = false;
return _this;
}
Object.defineProperty(MDCTabBarFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTabBarFoundation, "numbers", {
get: function get() {
return constants_1.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTabBarFoundation, "defaultAdapter", {
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
scrollTo: function scrollTo() {
return undefined;
},
incrementScroll: function incrementScroll() {
return undefined;
},
getScrollPosition: function getScrollPosition() {
return 0;
},
getScrollContentWidth: function getScrollContentWidth() {
return 0;
},
getOffsetWidth: function getOffsetWidth() {
return 0;
},
isRTL: function isRTL() {
return false;
},
setActiveTab: function setActiveTab() {
return undefined;
},
activateTabAtIndex: function activateTabAtIndex() {
return undefined;
},
deactivateTabAtIndex: function deactivateTabAtIndex() {
return undefined;
},
focusTabAtIndex: function focusTabAtIndex() {
return undefined;
},
getTabIndicatorClientRectAtIndex: function getTabIndicatorClientRectAtIndex() {
return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
},
getTabDimensionsAtIndex: function getTabDimensionsAtIndex() {
return { rootLeft: 0, rootRight: 0, contentLeft: 0, contentRight: 0 };
},
getPreviousActiveTabIndex: function getPreviousActiveTabIndex() {
return -1;
},
getFocusedTabIndex: function getFocusedTabIndex() {
return -1;
},
getIndexOfTabById: function getIndexOfTabById() {
return -1;
},
getTabListLength: function getTabListLength() {
return 0;
},
notifyTabActivated: function notifyTabActivated() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
/**
* Switches between automatic and manual activation modes.
* See https://www.w3.org/TR/wai-aria-practices/#tabpanel for examples.
*/
MDCTabBarFoundation.prototype.setUseAutomaticActivation = function (useAutomaticActivation) {
this.useAutomaticActivation = useAutomaticActivation;
};
MDCTabBarFoundation.prototype.activateTab = function (index) {
var previousActiveIndex = this.adapter.getPreviousActiveTabIndex();
if (!this.indexIsInRange(index) || index === previousActiveIndex) {
return;
}
var previousClientRect;
if (previousActiveIndex !== -1) {
this.adapter.deactivateTabAtIndex(previousActiveIndex);
previousClientRect = this.adapter.getTabIndicatorClientRectAtIndex(previousActiveIndex);
}
this.adapter.activateTabAtIndex(index, previousClientRect);
this.scrollIntoView(index);
this.adapter.notifyTabActivated(index);
};
MDCTabBarFoundation.prototype.handleKeyDown = function (evt) {
// Get the key from the event
var key = this.getKeyFromEvent(evt);
// Early exit if the event key isn't one of the keyboard navigation keys
if (key === undefined) {
return;
}
// Prevent default behavior for movement keys, but not for activation keys, since :active is used to apply ripple
if (!this.isActivationKey(key)) {
evt.preventDefault();
}
if (this.useAutomaticActivation) {
if (this.isActivationKey(key)) {
return;
}
var index = this.determineTargetFromKey(this.adapter.getPreviousActiveTabIndex(), key);
this.adapter.setActiveTab(index);
this.scrollIntoView(index);
} else {
var focusedTabIndex = this.adapter.getFocusedTabIndex();
if (this.isActivationKey(key)) {
this.adapter.setActiveTab(focusedTabIndex);
} else {
var index = this.determineTargetFromKey(focusedTabIndex, key);
this.adapter.focusTabAtIndex(index);
this.scrollIntoView(index);
}
}
};
/**
* Handles the MDCTab:interacted event
*/
MDCTabBarFoundation.prototype.handleTabInteraction = function (evt) {
this.adapter.setActiveTab(this.adapter.getIndexOfTabById(evt.detail.tabId));
};
/**
* Scrolls the tab at the given index into view
* @param index The tab index to make visible
*/
MDCTabBarFoundation.prototype.scrollIntoView = function (index) {
// Early exit if the index is out of range
if (!this.indexIsInRange(index)) {
return;
}
// Always scroll to 0 if scrolling to the 0th index
if (index === 0) {
this.adapter.scrollTo(0);
return;
}
// Always scroll to the max value if scrolling to the Nth index
// MDCTabScroller.scrollTo() will never scroll past the max possible value
if (index === this.adapter.getTabListLength() - 1) {
this.adapter.scrollTo(this.adapter.getScrollContentWidth());
return;
}
if (this.isRTL()) {
this.scrollIntoViewImplRTL(index);
return;
}
this.scrollIntoViewImpl(index);
};
/**
* Private method for determining the index of the destination tab based on what key was pressed
* @param origin The original index from which to determine the destination
* @param key The name of the key
*/
MDCTabBarFoundation.prototype.determineTargetFromKey = function (origin, key) {
var isRTL = this.isRTL();
var maxIndex = this.adapter.getTabListLength() - 1;
var shouldGoToEnd = key === constants_1.strings.END_KEY;
var shouldDecrement = key === constants_1.strings.ARROW_LEFT_KEY && !isRTL || key === constants_1.strings.ARROW_RIGHT_KEY && isRTL;
var shouldIncrement = key === constants_1.strings.ARROW_RIGHT_KEY && !isRTL || key === constants_1.strings.ARROW_LEFT_KEY && isRTL;
var index = origin;
if (shouldGoToEnd) {
index = maxIndex;
} else if (shouldDecrement) {
index -= 1;
} else if (shouldIncrement) {
index += 1;
} else {
index = 0;
}
if (index < 0) {
index = maxIndex;
} else if (index > maxIndex) {
index = 0;
}
return index;
};
/**
* Calculates the scroll increment that will make the tab at the given index visible
* @param index The index of the tab
* @param nextIndex The index of the next tab
* @param scrollPosition The current scroll position
* @param barWidth The width of the Tab Bar
*/
MDCTabBarFoundation.prototype.calculateScrollIncrement = function (index, nextIndex, scrollPosition, barWidth) {
var nextTabDimensions = this.adapter.getTabDimensionsAtIndex(nextIndex);
var relativeContentLeft = nextTabDimensions.contentLeft - scrollPosition - barWidth;
var relativeContentRight = nextTabDimensions.contentRight - scrollPosition;
var leftIncrement = relativeContentRight - constants_1.numbers.EXTRA_SCROLL_AMOUNT;
var rightIncrement = relativeContentLeft + constants_1.numbers.EXTRA_SCROLL_AMOUNT;
if (nextIndex < index) {
return Math.min(leftIncrement, 0);
}
return Math.max(rightIncrement, 0);
};
/**
* Calculates the scroll increment that will make the tab at the given index visible in RTL
* @param index The index of the tab
* @param nextIndex The index of the next tab
* @param scrollPosition The current scroll position
* @param barWidth The width of the Tab Bar
* @param scrollContentWidth The width of the scroll content
*/
MDCTabBarFoundation.prototype.calculateScrollIncrementRTL = function (index, nextIndex, scrollPosition, barWidth, scrollContentWidth) {
var nextTabDimensions = this.adapter.getTabDimensionsAtIndex(nextIndex);
var relativeContentLeft = scrollContentWidth - nextTabDimensions.contentLeft - scrollPosition;
var relativeContentRight = scrollContentWidth - nextTabDimensions.contentRight - scrollPosition - barWidth;
var leftIncrement = relativeContentRight + constants_1.numbers.EXTRA_SCROLL_AMOUNT;
var rightIncrement = relativeContentLeft - constants_1.numbers.EXTRA_SCROLL_AMOUNT;
if (nextIndex > index) {
return Math.max(leftIncrement, 0);
}
return Math.min(rightIncrement, 0);
};
/**
* Determines the index of the adjacent tab closest to either edge of the Tab Bar
* @param index The index of the tab
* @param tabDimensions The dimensions of the tab
* @param scrollPosition The current scroll position
* @param barWidth The width of the tab bar
*/
MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdge = function (index, tabDimensions, scrollPosition, barWidth) {
/**
* Tabs are laid out in the Tab Scroller like this:
*
* Scroll Position
* +---+
* | | Bar Width
* | +-----------------------------------+
* | | |
* | V V
* | +-----------------------------------+
* V | Tab Scroller |
* +------------+--------------+-------------------+
* | Tab | Tab | Tab |
* +------------+--------------+-------------------+
* | |
* +-----------------------------------+
*
* To determine the next adjacent index, we look at the Tab root left and
* Tab root right, both relative to the scroll position. If the Tab root
* left is less than 0, then we know it's out of view to the left. If the
* Tab root right minus the bar width is greater than 0, we know the Tab is
* out of view to the right. From there, we either increment or decrement
* the index.
*/
var relativeRootLeft = tabDimensions.rootLeft - scrollPosition;
var relativeRootRight = tabDimensions.rootRight - scrollPosition - barWidth;
var relativeRootDelta = relativeRootLeft + relativeRootRight;
var leftEdgeIsCloser = relativeRootLeft < 0 || relativeRootDelta < 0;
var rightEdgeIsCloser = relativeRootRight > 0 || relativeRootDelta > 0;
if (leftEdgeIsCloser) {
return index - 1;
}
if (rightEdgeIsCloser) {
return index + 1;
}
return -1;
};
/**
* Determines the index of the adjacent tab closest to either edge of the Tab Bar in RTL
* @param index The index of the tab
* @param tabDimensions The dimensions of the tab
* @param scrollPosition The current scroll position
* @param barWidth The width of the tab bar
* @param scrollContentWidth The width of the scroller content
*/
MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdgeRTL = function (index, tabDimensions, scrollPosition, barWidth, scrollContentWidth) {
var rootLeft = scrollContentWidth - tabDimensions.rootLeft - barWidth - scrollPosition;
var rootRight = scrollContentWidth - tabDimensions.rootRight - scrollPosition;
var rootDelta = rootLeft + rootRight;
var leftEdgeIsCloser = rootLeft > 0 || rootDelta > 0;
var rightEdgeIsCloser = rootRight < 0 || rootDelta < 0;
if (leftEdgeIsCloser) {
return index + 1;
}
if (rightEdgeIsCloser) {
return index - 1;
}
return -1;
};
/**
* Returns the key associated with a keydown event
* @param evt The keydown event
*/
MDCTabBarFoundation.prototype.getKeyFromEvent = function (evt) {
if (ACCEPTABLE_KEYS.has(evt.key)) {
return evt.key;
}
return KEYCODE_MAP.get(evt.keyCode);
};
MDCTabBarFoundation.prototype.isActivationKey = function (key) {
return key === constants_1.strings.SPACE_KEY || key === constants_1.strings.ENTER_KEY;
};
/**
* Returns whether a given index is inclusively between the ends
* @param index The index to test
*/
MDCTabBarFoundation.prototype.indexIsInRange = function (index) {
return index >= 0 && index < this.adapter.getTabListLength();
};
/**
* Returns the view's RTL property
*/
MDCTabBarFoundation.prototype.isRTL = function () {
return this.adapter.isRTL();
};
/**
* Scrolls the tab at the given index into view for left-to-right user agents.
* @param index The index of the tab to scroll into view
*/
MDCTabBarFoundation.prototype.scrollIntoViewImpl = function (index) {
var scrollPosition = this.adapter.getScrollPosition();
var barWidth = this.adapter.getOffsetWidth();
var tabDimensions = this.adapter.getTabDimensionsAtIndex(index);
var nextIndex = this.findAdjacentTabIndexClosestToEdge(index, tabDimensions, scrollPosition, barWidth);
if (!this.indexIsInRange(nextIndex)) {
return;
}
var scrollIncrement = this.calculateScrollIncrement(index, nextIndex, scrollPosition, barWidth);
this.adapter.incrementScroll(scrollIncrement);
};
/**
* Scrolls the tab at the given index into view in RTL
* @param index The tab index to make visible
*/
MDCTabBarFoundation.prototype.scrollIntoViewImplRTL = function (index) {
var scrollPosition = this.adapter.getScrollPosition();
var barWidth = this.adapter.getOffsetWidth();
var tabDimensions = this.adapter.getTabDimensionsAtIndex(index);
var scrollWidth = this.adapter.getScrollContentWidth();
var nextIndex = this.findAdjacentTabIndexClosestToEdgeRTL(index, tabDimensions, scrollPosition, barWidth, scrollWidth);
if (!this.indexIsInRange(nextIndex)) {
return;
}
var scrollIncrement = this.calculateScrollIncrementRTL(index, nextIndex, scrollPosition, barWidth, scrollWidth);
this.adapter.incrementScroll(scrollIncrement);
};
return MDCTabBarFoundation;
}(foundation_1.MDCFoundation);
exports.MDCTabBarFoundation = MDCTabBarFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTabBarFoundation;
/***/ }),
/***/ "./packages/mdc-tab-bar/index.ts":
/*!***************************************!*\
!*** ./packages/mdc-tab-bar/index.ts ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-tab-bar/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-tab-bar/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-bar/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-bar/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-tab-bar/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-tab-bar/types.ts":
/*!***************************************!*\
!*** ./packages/mdc-tab-bar/types.ts ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-tab-indicator/adapter.ts":
/*!***********************************************!*\
!*** ./packages/mdc-tab-indicator/adapter.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-tab-indicator/component.ts":
/*!*************************************************!*\
!*** ./packages/mdc-tab-indicator/component.ts ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTabIndicator = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var fading_foundation_1 = __webpack_require__(/*! ./fading-foundation */ "./packages/mdc-tab-indicator/fading-foundation.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
var sliding_foundation_1 = __webpack_require__(/*! ./sliding-foundation */ "./packages/mdc-tab-indicator/sliding-foundation.ts");
var MDCTabIndicator = /** @class */function (_super) {
__extends(MDCTabIndicator, _super);
function MDCTabIndicator() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTabIndicator.attachTo = function (root) {
return new MDCTabIndicator(root);
};
MDCTabIndicator.prototype.initialize = function () {
this.content = this.root.querySelector(foundation_1.MDCTabIndicatorFoundation.strings.CONTENT_SELECTOR);
};
MDCTabIndicator.prototype.computeContentClientRect = function () {
return this.foundation.computeContentClientRect();
};
MDCTabIndicator.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
computeContentClientRect: function computeContentClientRect() {
return _this.content.getBoundingClientRect();
},
setContentStyleProperty: function setContentStyleProperty(prop, value) {
_this.content.style.setProperty(prop, value);
}
};
// tslint:enable:object-literal-sort-keys
if (this.root.classList.contains(foundation_1.MDCTabIndicatorFoundation.cssClasses.FADE)) {
return new fading_foundation_1.MDCFadingTabIndicatorFoundation(adapter);
}
// Default to the sliding indicator
return new sliding_foundation_1.MDCSlidingTabIndicatorFoundation(adapter);
};
MDCTabIndicator.prototype.activate = function (previousIndicatorClientRect) {
this.foundation.activate(previousIndicatorClientRect);
};
MDCTabIndicator.prototype.deactivate = function () {
this.foundation.deactivate();
};
return MDCTabIndicator;
}(component_1.MDCComponent);
exports.MDCTabIndicator = MDCTabIndicator;
/***/ }),
/***/ "./packages/mdc-tab-indicator/constants.ts":
/*!*************************************************!*\
!*** ./packages/mdc-tab-indicator/constants.ts ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.cssClasses = void 0;
var cssClasses = {
ACTIVE: 'mdc-tab-indicator--active',
FADE: 'mdc-tab-indicator--fade',
NO_TRANSITION: 'mdc-tab-indicator--no-transition'
};
exports.cssClasses = cssClasses;
var strings = {
CONTENT_SELECTOR: '.mdc-tab-indicator__content'
};
exports.strings = strings;
/***/ }),
/***/ "./packages/mdc-tab-indicator/fading-foundation.ts":
/*!*********************************************************!*\
!*** ./packages/mdc-tab-indicator/fading-foundation.ts ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCFadingTabIndicatorFoundation = void 0;
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
/* istanbul ignore next: subclass is not a branch statement */
var MDCFadingTabIndicatorFoundation = /** @class */function (_super) {
__extends(MDCFadingTabIndicatorFoundation, _super);
function MDCFadingTabIndicatorFoundation() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCFadingTabIndicatorFoundation.prototype.activate = function () {
this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
};
MDCFadingTabIndicatorFoundation.prototype.deactivate = function () {
this.adapter.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
};
return MDCFadingTabIndicatorFoundation;
}(foundation_1.MDCTabIndicatorFoundation);
exports.MDCFadingTabIndicatorFoundation = MDCFadingTabIndicatorFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCFadingTabIndicatorFoundation;
/***/ }),
/***/ "./packages/mdc-tab-indicator/foundation.ts":
/*!**************************************************!*\
!*** ./packages/mdc-tab-indicator/foundation.ts ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTabIndicatorFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-indicator/constants.ts");
var MDCTabIndicatorFoundation = /** @class */function (_super) {
__extends(MDCTabIndicatorFoundation, _super);
function MDCTabIndicatorFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCTabIndicatorFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCTabIndicatorFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTabIndicatorFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTabIndicatorFoundation, "defaultAdapter", {
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
computeContentClientRect: function computeContentClientRect() {
return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
},
setContentStyleProperty: function setContentStyleProperty() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCTabIndicatorFoundation.prototype.computeContentClientRect = function () {
return this.adapter.computeContentClientRect();
};
return MDCTabIndicatorFoundation;
}(foundation_1.MDCFoundation);
exports.MDCTabIndicatorFoundation = MDCTabIndicatorFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTabIndicatorFoundation;
/***/ }),
/***/ "./packages/mdc-tab-indicator/index.ts":
/*!*********************************************!*\
!*** ./packages/mdc-tab-indicator/index.ts ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-tab-indicator/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-tab-indicator/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-indicator/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./fading-foundation */ "./packages/mdc-tab-indicator/fading-foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./sliding-foundation */ "./packages/mdc-tab-indicator/sliding-foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-tab-indicator/sliding-foundation.ts":
/*!**********************************************************!*\
!*** ./packages/mdc-tab-indicator/sliding-foundation.ts ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCSlidingTabIndicatorFoundation = void 0;
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
/* istanbul ignore next: subclass is not a branch statement */
var MDCSlidingTabIndicatorFoundation = /** @class */function (_super) {
__extends(MDCSlidingTabIndicatorFoundation, _super);
function MDCSlidingTabIndicatorFoundation() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCSlidingTabIndicatorFoundation.prototype.activate = function (previousIndicatorClientRect) {
// Early exit if no indicator is present to handle cases where an indicator
// may be activated without a prior indicator state
if (!previousIndicatorClientRect) {
this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
return;
}
// This animation uses the FLIP approach. You can read more about it at the link below:
// https://aerotwist.com/blog/flip-your-animations/
// Calculate the dimensions based on the dimensions of the previous indicator
var currentClientRect = this.computeContentClientRect();
var widthDelta = previousIndicatorClientRect.width / currentClientRect.width;
var xPosition = previousIndicatorClientRect.left - currentClientRect.left;
this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION);
this.adapter.setContentStyleProperty('transform', "translateX(" + xPosition + "px) scaleX(" + widthDelta + ")");
// Force repaint before updating classes and transform to ensure the transform properly takes effect
this.computeContentClientRect();
this.adapter.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION);
this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
this.adapter.setContentStyleProperty('transform', '');
};
MDCSlidingTabIndicatorFoundation.prototype.deactivate = function () {
this.adapter.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
};
return MDCSlidingTabIndicatorFoundation;
}(foundation_1.MDCTabIndicatorFoundation);
exports.MDCSlidingTabIndicatorFoundation = MDCSlidingTabIndicatorFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCSlidingTabIndicatorFoundation;
/***/ }),
/***/ "./packages/mdc-tab-scroller/adapter.ts":
/*!**********************************************!*\
!*** ./packages/mdc-tab-scroller/adapter.ts ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-tab-scroller/component.ts":
/*!************************************************!*\
!*** ./packages/mdc-tab-scroller/component.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTabScroller = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-scroller/foundation.ts");
var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-tab-scroller/util.ts"));
var MDCTabScroller = /** @class */function (_super) {
__extends(MDCTabScroller, _super);
function MDCTabScroller() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTabScroller.attachTo = function (root) {
return new MDCTabScroller(root);
};
// initialSyncWithDOM()
MDCTabScroller.prototype.initialize = function () {
this.area = this.root.querySelector(foundation_1.MDCTabScrollerFoundation.strings.AREA_SELECTOR);
this.content = this.root.querySelector(foundation_1.MDCTabScrollerFoundation.strings.CONTENT_SELECTOR);
};
MDCTabScroller.prototype.initialSyncWithDOM = function () {
var _this = this;
this.handleInteraction = function () {
_this.foundation.handleInteraction();
};
this.handleTransitionEnd = function (evt) {
_this.foundation.handleTransitionEnd(evt);
};
this.area.addEventListener('wheel', this.handleInteraction, events_1.applyPassive());
this.area.addEventListener('touchstart', this.handleInteraction, events_1.applyPassive());
this.area.addEventListener('pointerdown', this.handleInteraction, events_1.applyPassive());
this.area.addEventListener('mousedown', this.handleInteraction, events_1.applyPassive());
this.area.addEventListener('keydown', this.handleInteraction, events_1.applyPassive());
this.content.addEventListener('transitionend', this.handleTransitionEnd);
};
MDCTabScroller.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.area.removeEventListener('wheel', this.handleInteraction, events_1.applyPassive());
this.area.removeEventListener('touchstart', this.handleInteraction, events_1.applyPassive());
this.area.removeEventListener('pointerdown', this.handleInteraction, events_1.applyPassive());
this.area.removeEventListener('mousedown', this.handleInteraction, events_1.applyPassive());
this.area.removeEventListener('keydown', this.handleInteraction, events_1.applyPassive());
this.content.removeEventListener('transitionend', this.handleTransitionEnd);
};
MDCTabScroller.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
eventTargetMatchesSelector: function eventTargetMatchesSelector(evtTarget, selector) {
return ponyfill_1.matches(evtTarget, selector);
},
addClass: function addClass(className) {
_this.root.classList.add(className);
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
addScrollAreaClass: function addScrollAreaClass(className) {
_this.area.classList.add(className);
},
setScrollAreaStyleProperty: function setScrollAreaStyleProperty(prop, value) {
_this.area.style.setProperty(prop, value);
},
setScrollContentStyleProperty: function setScrollContentStyleProperty(prop, value) {
_this.content.style.setProperty(prop, value);
},
getScrollContentStyleValue: function getScrollContentStyleValue(propName) {
return window.getComputedStyle(_this.content).getPropertyValue(propName);
},
setScrollAreaScrollLeft: function setScrollAreaScrollLeft(scrollX) {
return _this.area.scrollLeft = scrollX;
},
getScrollAreaScrollLeft: function getScrollAreaScrollLeft() {
return _this.area.scrollLeft;
},
getScrollContentOffsetWidth: function getScrollContentOffsetWidth() {
return _this.content.offsetWidth;
},
getScrollAreaOffsetWidth: function getScrollAreaOffsetWidth() {
return _this.area.offsetWidth;
},
computeScrollAreaClientRect: function computeScrollAreaClientRect() {
return _this.area.getBoundingClientRect();
},
computeScrollContentClientRect: function computeScrollContentClientRect() {
return _this.content.getBoundingClientRect();
},
computeHorizontalScrollbarHeight: function computeHorizontalScrollbarHeight() {
return util.computeHorizontalScrollbarHeight(document);
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_1.MDCTabScrollerFoundation(adapter);
};
/**
* Returns the current visual scroll position
*/
MDCTabScroller.prototype.getScrollPosition = function () {
return this.foundation.getScrollPosition();
};
/**
* Returns the width of the scroll content
*/
MDCTabScroller.prototype.getScrollContentWidth = function () {
return this.content.offsetWidth;
};
/**
* Increments the scroll value by the given amount
* @param scrollXIncrement The pixel value by which to increment the scroll value
*/
MDCTabScroller.prototype.incrementScroll = function (scrollXIncrement) {
this.foundation.incrementScroll(scrollXIncrement);
};
/**
* Scrolls to the given pixel position
* @param scrollX The pixel value to scroll to
*/
MDCTabScroller.prototype.scrollTo = function (scrollX) {
this.foundation.scrollTo(scrollX);
};
return MDCTabScroller;
}(component_1.MDCComponent);
exports.MDCTabScroller = MDCTabScroller;
/***/ }),
/***/ "./packages/mdc-tab-scroller/constants.ts":
/*!************************************************!*\
!*** ./packages/mdc-tab-scroller/constants.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.cssClasses = void 0;
var cssClasses = {
ANIMATING: 'mdc-tab-scroller--animating',
SCROLL_AREA_SCROLL: 'mdc-tab-scroller__scroll-area--scroll',
SCROLL_TEST: 'mdc-tab-scroller__test'
};
exports.cssClasses = cssClasses;
var strings = {
AREA_SELECTOR: '.mdc-tab-scroller__scroll-area',
CONTENT_SELECTOR: '.mdc-tab-scroller__scroll-content'
};
exports.strings = strings;
/***/ }),
/***/ "./packages/mdc-tab-scroller/foundation.ts":
/*!*************************************************!*\
!*** ./packages/mdc-tab-scroller/foundation.ts ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
ar.push(r.value);
}
} catch (error) {
e = { error: error };
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTabScrollerFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts");
var rtl_default_scroller_1 = __webpack_require__(/*! ./rtl-default-scroller */ "./packages/mdc-tab-scroller/rtl-default-scroller.ts");
var rtl_negative_scroller_1 = __webpack_require__(/*! ./rtl-negative-scroller */ "./packages/mdc-tab-scroller/rtl-negative-scroller.ts");
var rtl_reverse_scroller_1 = __webpack_require__(/*! ./rtl-reverse-scroller */ "./packages/mdc-tab-scroller/rtl-reverse-scroller.ts");
var MDCTabScrollerFoundation = /** @class */function (_super) {
__extends(MDCTabScrollerFoundation, _super);
function MDCTabScrollerFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCTabScrollerFoundation.defaultAdapter), adapter)) || this;
/**
* Controls whether we should handle the transitionend and interaction events during the animation.
*/
_this.isAnimating = false;
return _this;
}
Object.defineProperty(MDCTabScrollerFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTabScrollerFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTabScrollerFoundation, "defaultAdapter", {
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
eventTargetMatchesSelector: function eventTargetMatchesSelector() {
return false;
},
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
addScrollAreaClass: function addScrollAreaClass() {
return undefined;
},
setScrollAreaStyleProperty: function setScrollAreaStyleProperty() {
return undefined;
},
setScrollContentStyleProperty: function setScrollContentStyleProperty() {
return undefined;
},
getScrollContentStyleValue: function getScrollContentStyleValue() {
return '';
},
setScrollAreaScrollLeft: function setScrollAreaScrollLeft() {
return undefined;
},
getScrollAreaScrollLeft: function getScrollAreaScrollLeft() {
return 0;
},
getScrollContentOffsetWidth: function getScrollContentOffsetWidth() {
return 0;
},
getScrollAreaOffsetWidth: function getScrollAreaOffsetWidth() {
return 0;
},
computeScrollAreaClientRect: function computeScrollAreaClientRect() {
return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
},
computeScrollContentClientRect: function computeScrollContentClientRect() {
return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
},
computeHorizontalScrollbarHeight: function computeHorizontalScrollbarHeight() {
return 0;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCTabScrollerFoundation.prototype.init = function () {
// Compute horizontal scrollbar height on scroller with overflow initially hidden, then update overflow to scroll
// and immediately adjust bottom margin to avoid the scrollbar initially appearing before JS runs.
var horizontalScrollbarHeight = this.adapter.computeHorizontalScrollbarHeight();
this.adapter.setScrollAreaStyleProperty('margin-bottom', -horizontalScrollbarHeight + 'px');
this.adapter.addScrollAreaClass(MDCTabScrollerFoundation.cssClasses.SCROLL_AREA_SCROLL);
};
/**
* Computes the current visual scroll position
*/
MDCTabScrollerFoundation.prototype.getScrollPosition = function () {
if (this.isRTL()) {
return this.computeCurrentScrollPositionRTL();
}
var currentTranslateX = this.calculateCurrentTranslateX();
var scrollLeft = this.adapter.getScrollAreaScrollLeft();
return scrollLeft - currentTranslateX;
};
/**
* Handles interaction events that occur during transition
*/
MDCTabScrollerFoundation.prototype.handleInteraction = function () {
// Early exit if we aren't animating
if (!this.isAnimating) {
return;
}
// Prevent other event listeners from handling this event
this.stopScrollAnimation();
};
/**
* Handles the transitionend event
*/
MDCTabScrollerFoundation.prototype.handleTransitionEnd = function (evt) {
// Early exit if we aren't animating or the event was triggered by a different element.
var evtTarget = evt.target;
if (!this.isAnimating || !this.adapter.eventTargetMatchesSelector(evtTarget, MDCTabScrollerFoundation.strings.CONTENT_SELECTOR)) {
return;
}
this.isAnimating = false;
this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
};
/**
* Increment the scroll value by the scrollXIncrement using animation.
* @param scrollXIncrement The value by which to increment the scroll position
*/
MDCTabScrollerFoundation.prototype.incrementScroll = function (scrollXIncrement) {
// Early exit for non-operational increment values
if (scrollXIncrement === 0) {
return;
}
this.animate(this.getIncrementScrollOperation(scrollXIncrement));
};
/**
* Increment the scroll value by the scrollXIncrement without animation.
* @param scrollXIncrement The value by which to increment the scroll position
*/
MDCTabScrollerFoundation.prototype.incrementScrollImmediate = function (scrollXIncrement) {
// Early exit for non-operational increment values
if (scrollXIncrement === 0) {
return;
}
var operation = this.getIncrementScrollOperation(scrollXIncrement);
if (operation.scrollDelta === 0) {
return;
}
this.stopScrollAnimation();
this.adapter.setScrollAreaScrollLeft(operation.finalScrollPosition);
};
/**
* Scrolls to the given scrollX value
*/
MDCTabScrollerFoundation.prototype.scrollTo = function (scrollX) {
if (this.isRTL()) {
this.scrollToImplRTL(scrollX);
return;
}
this.scrollToImpl(scrollX);
};
/**
* @return Browser-specific {@link MDCTabScrollerRTL} instance.
*/
MDCTabScrollerFoundation.prototype.getRTLScroller = function () {
if (!this.rtlScrollerInstance) {
this.rtlScrollerInstance = this.rtlScrollerFactory();
}
return this.rtlScrollerInstance;
};
/**
* @return translateX value from a CSS matrix transform function string.
*/
MDCTabScrollerFoundation.prototype.calculateCurrentTranslateX = function () {
var transformValue = this.adapter.getScrollContentStyleValue('transform');
// Early exit if no transform is present
if (transformValue === 'none') {
return 0;
}
// The transform value comes back as a matrix transformation in the form
// of `matrix(a, b, c, d, tx, ty)`. We only care about tx (translateX) so
// we're going to grab all the parenthesized values, strip out tx, and
// parse it.
var match = /\((.+?)\)/.exec(transformValue);
if (!match) {
return 0;
}
var matrixParams = match[1];
// tslint:disable-next-line:ban-ts-ignore "Unused vars" should be a linter warning, not a compiler error.
// @ts-ignore These unused variables should retain their semantic names for clarity.
var _a = __read(matrixParams.split(','), 6),
a = _a[0],
b = _a[1],
c = _a[2],
d = _a[3],
tx = _a[4],
ty = _a[5];
return parseFloat(tx); // tslint:disable-line:ban
};
/**
* Calculates a safe scroll value that is > 0 and < the max scroll value
* @param scrollX The distance to scroll
*/
MDCTabScrollerFoundation.prototype.clampScrollValue = function (scrollX) {
var edges = this.calculateScrollEdges();
return Math.min(Math.max(edges.left, scrollX), edges.right);
};
MDCTabScrollerFoundation.prototype.computeCurrentScrollPositionRTL = function () {
var translateX = this.calculateCurrentTranslateX();
return this.getRTLScroller().getScrollPositionRTL(translateX);
};
MDCTabScrollerFoundation.prototype.calculateScrollEdges = function () {
var contentWidth = this.adapter.getScrollContentOffsetWidth();
var rootWidth = this.adapter.getScrollAreaOffsetWidth();
return {
left: 0,
right: contentWidth - rootWidth
};
};
/**
* Internal scroll method
* @param scrollX The new scroll position
*/
MDCTabScrollerFoundation.prototype.scrollToImpl = function (scrollX) {
var currentScrollX = this.getScrollPosition();
var safeScrollX = this.clampScrollValue(scrollX);
var scrollDelta = safeScrollX - currentScrollX;
this.animate({
finalScrollPosition: safeScrollX,
scrollDelta: scrollDelta
});
};
/**
* Internal RTL scroll method
* @param scrollX The new scroll position
*/
MDCTabScrollerFoundation.prototype.scrollToImplRTL = function (scrollX) {
var animation = this.getRTLScroller().scrollToRTL(scrollX);
this.animate(animation);
};
/**
* Internal method to compute the increment scroll operation values.
* @param scrollX The desired scroll position increment
* @return MDCTabScrollerAnimation with the sanitized values for performing the scroll operation.
*/
MDCTabScrollerFoundation.prototype.getIncrementScrollOperation = function (scrollX) {
if (this.isRTL()) {
return this.getRTLScroller().incrementScrollRTL(scrollX);
}
var currentScrollX = this.getScrollPosition();
var targetScrollX = scrollX + currentScrollX;
var safeScrollX = this.clampScrollValue(targetScrollX);
var scrollDelta = safeScrollX - currentScrollX;
return {
finalScrollPosition: safeScrollX,
scrollDelta: scrollDelta
};
};
/**
* Animates the tab scrolling
* @param animation The animation to apply
*/
MDCTabScrollerFoundation.prototype.animate = function (animation) {
var _this = this;
// Early exit if translateX is 0, which means there's no animation to perform
if (animation.scrollDelta === 0) {
return;
}
this.stopScrollAnimation();
// This animation uses the FLIP approach.
// Read more here: https://aerotwist.com/blog/flip-your-animations/
this.adapter.setScrollAreaScrollLeft(animation.finalScrollPosition);
this.adapter.setScrollContentStyleProperty('transform', "translateX(" + animation.scrollDelta + "px)");
// Force repaint
this.adapter.computeScrollAreaClientRect();
requestAnimationFrame(function () {
_this.adapter.addClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
_this.adapter.setScrollContentStyleProperty('transform', 'none');
});
this.isAnimating = true;
};
/**
* Stops scroll animation
*/
MDCTabScrollerFoundation.prototype.stopScrollAnimation = function () {
this.isAnimating = false;
var currentScrollPosition = this.getAnimatingScrollPosition();
this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
this.adapter.setScrollContentStyleProperty('transform', 'translateX(0px)');
this.adapter.setScrollAreaScrollLeft(currentScrollPosition);
};
/**
* Gets the current scroll position during animation
*/
MDCTabScrollerFoundation.prototype.getAnimatingScrollPosition = function () {
var currentTranslateX = this.calculateCurrentTranslateX();
var scrollLeft = this.adapter.getScrollAreaScrollLeft();
if (this.isRTL()) {
return this.getRTLScroller().getAnimatingScrollPosition(scrollLeft, currentTranslateX);
}
return scrollLeft - currentTranslateX;
};
/**
* Determines the RTL Scroller to use
*/
MDCTabScrollerFoundation.prototype.rtlScrollerFactory = function () {
// Browsers have three different implementations of scrollLeft in RTL mode,
// dependent on the browser. The behavior is based off the max LTR
// scrollLeft value and 0.
//
// * Default scrolling in RTL *
// - Left-most value: 0
// - Right-most value: Max LTR scrollLeft value
//
// * Negative scrolling in RTL *
// - Left-most value: Negated max LTR scrollLeft value
// - Right-most value: 0
//
// * Reverse scrolling in RTL *
// - Left-most value: Max LTR scrollLeft value
// - Right-most value: 0
//
// We use those principles below to determine which RTL scrollLeft
// behavior is implemented in the current browser.
var initialScrollLeft = this.adapter.getScrollAreaScrollLeft();
this.adapter.setScrollAreaScrollLeft(initialScrollLeft - 1);
var newScrollLeft = this.adapter.getScrollAreaScrollLeft();
// If the newScrollLeft value is negative,then we know that the browser has
// implemented negative RTL scrolling, since all other implementations have
// only positive values.
if (newScrollLeft < 0) {
// Undo the scrollLeft test check
this.adapter.setScrollAreaScrollLeft(initialScrollLeft);
return new rtl_negative_scroller_1.MDCTabScrollerRTLNegative(this.adapter);
}
var rootClientRect = this.adapter.computeScrollAreaClientRect();
var contentClientRect = this.adapter.computeScrollContentClientRect();
var rightEdgeDelta = Math.round(contentClientRect.right - rootClientRect.right);
// Undo the scrollLeft test check
this.adapter.setScrollAreaScrollLeft(initialScrollLeft);
// By calculating the clientRect of the root element and the clientRect of
// the content element, we can determine how much the scroll value changed
// when we performed the scrollLeft subtraction above.
if (rightEdgeDelta === newScrollLeft) {
return new rtl_reverse_scroller_1.MDCTabScrollerRTLReverse(this.adapter);
}
return new rtl_default_scroller_1.MDCTabScrollerRTLDefault(this.adapter);
};
MDCTabScrollerFoundation.prototype.isRTL = function () {
return this.adapter.getScrollContentStyleValue('direction') === 'rtl';
};
return MDCTabScrollerFoundation;
}(foundation_1.MDCFoundation);
exports.MDCTabScrollerFoundation = MDCTabScrollerFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTabScrollerFoundation;
/***/ }),
/***/ "./packages/mdc-tab-scroller/index.ts":
/*!********************************************!*\
!*** ./packages/mdc-tab-scroller/index.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.util = void 0;
var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-tab-scroller/util.ts"));
exports.util = util;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-tab-scroller/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-tab-scroller/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-scroller/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-tab-scroller/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-tab-scroller/rtl-default-scroller.ts":
/*!***********************************************************!*\
!*** ./packages/mdc-tab-scroller/rtl-default-scroller.ts ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTabScrollerRTLDefault = void 0;
var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
var MDCTabScrollerRTLDefault = /** @class */function (_super) {
__extends(MDCTabScrollerRTLDefault, _super);
function MDCTabScrollerRTLDefault() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTabScrollerRTLDefault.prototype.getScrollPositionRTL = function () {
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
var right = this.calculateScrollEdges().right;
// Scroll values on most browsers are ints instead of floats so we round
return Math.round(right - currentScrollLeft);
};
MDCTabScrollerRTLDefault.prototype.scrollToRTL = function (scrollX) {
var edges = this.calculateScrollEdges();
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
var clampedScrollLeft = this.clampScrollValue(edges.right - scrollX);
return {
finalScrollPosition: clampedScrollLeft,
scrollDelta: clampedScrollLeft - currentScrollLeft
};
};
MDCTabScrollerRTLDefault.prototype.incrementScrollRTL = function (scrollX) {
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
var clampedScrollLeft = this.clampScrollValue(currentScrollLeft - scrollX);
return {
finalScrollPosition: clampedScrollLeft,
scrollDelta: clampedScrollLeft - currentScrollLeft
};
};
MDCTabScrollerRTLDefault.prototype.getAnimatingScrollPosition = function (scrollX) {
return scrollX;
};
MDCTabScrollerRTLDefault.prototype.calculateScrollEdges = function () {
var contentWidth = this.adapter.getScrollContentOffsetWidth();
var rootWidth = this.adapter.getScrollAreaOffsetWidth();
return {
left: 0,
right: contentWidth - rootWidth
};
};
MDCTabScrollerRTLDefault.prototype.clampScrollValue = function (scrollX) {
var edges = this.calculateScrollEdges();
return Math.min(Math.max(edges.left, scrollX), edges.right);
};
return MDCTabScrollerRTLDefault;
}(rtl_scroller_1.MDCTabScrollerRTL);
exports.MDCTabScrollerRTLDefault = MDCTabScrollerRTLDefault;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTabScrollerRTLDefault;
/***/ }),
/***/ "./packages/mdc-tab-scroller/rtl-negative-scroller.ts":
/*!************************************************************!*\
!*** ./packages/mdc-tab-scroller/rtl-negative-scroller.ts ***!
\************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTabScrollerRTLNegative = void 0;
var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
var MDCTabScrollerRTLNegative = /** @class */function (_super) {
__extends(MDCTabScrollerRTLNegative, _super);
function MDCTabScrollerRTLNegative() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTabScrollerRTLNegative.prototype.getScrollPositionRTL = function (translateX) {
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
return Math.round(translateX - currentScrollLeft);
};
MDCTabScrollerRTLNegative.prototype.scrollToRTL = function (scrollX) {
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
var clampedScrollLeft = this.clampScrollValue(-scrollX);
return {
finalScrollPosition: clampedScrollLeft,
scrollDelta: clampedScrollLeft - currentScrollLeft
};
};
MDCTabScrollerRTLNegative.prototype.incrementScrollRTL = function (scrollX) {
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
var clampedScrollLeft = this.clampScrollValue(currentScrollLeft - scrollX);
return {
finalScrollPosition: clampedScrollLeft,
scrollDelta: clampedScrollLeft - currentScrollLeft
};
};
MDCTabScrollerRTLNegative.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
return scrollX - translateX;
};
MDCTabScrollerRTLNegative.prototype.calculateScrollEdges = function () {
var contentWidth = this.adapter.getScrollContentOffsetWidth();
var rootWidth = this.adapter.getScrollAreaOffsetWidth();
return {
left: rootWidth - contentWidth,
right: 0
};
};
MDCTabScrollerRTLNegative.prototype.clampScrollValue = function (scrollX) {
var edges = this.calculateScrollEdges();
return Math.max(Math.min(edges.right, scrollX), edges.left);
};
return MDCTabScrollerRTLNegative;
}(rtl_scroller_1.MDCTabScrollerRTL);
exports.MDCTabScrollerRTLNegative = MDCTabScrollerRTLNegative;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTabScrollerRTLNegative;
/***/ }),
/***/ "./packages/mdc-tab-scroller/rtl-reverse-scroller.ts":
/*!***********************************************************!*\
!*** ./packages/mdc-tab-scroller/rtl-reverse-scroller.ts ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTabScrollerRTLReverse = void 0;
var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
var MDCTabScrollerRTLReverse = /** @class */function (_super) {
__extends(MDCTabScrollerRTLReverse, _super);
function MDCTabScrollerRTLReverse() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTabScrollerRTLReverse.prototype.getScrollPositionRTL = function (translateX) {
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
// Scroll values on most browsers are ints instead of floats so we round
return Math.round(currentScrollLeft - translateX);
};
MDCTabScrollerRTLReverse.prototype.scrollToRTL = function (scrollX) {
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
var clampedScrollLeft = this.clampScrollValue(scrollX);
return {
finalScrollPosition: clampedScrollLeft,
scrollDelta: currentScrollLeft - clampedScrollLeft
};
};
MDCTabScrollerRTLReverse.prototype.incrementScrollRTL = function (scrollX) {
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
var clampedScrollLeft = this.clampScrollValue(currentScrollLeft + scrollX);
return {
finalScrollPosition: clampedScrollLeft,
scrollDelta: currentScrollLeft - clampedScrollLeft
};
};
MDCTabScrollerRTLReverse.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
return scrollX + translateX;
};
MDCTabScrollerRTLReverse.prototype.calculateScrollEdges = function () {
var contentWidth = this.adapter.getScrollContentOffsetWidth();
var rootWidth = this.adapter.getScrollAreaOffsetWidth();
return {
left: contentWidth - rootWidth,
right: 0
};
};
MDCTabScrollerRTLReverse.prototype.clampScrollValue = function (scrollX) {
var edges = this.calculateScrollEdges();
return Math.min(Math.max(edges.right, scrollX), edges.left);
};
return MDCTabScrollerRTLReverse;
}(rtl_scroller_1.MDCTabScrollerRTL);
exports.MDCTabScrollerRTLReverse = MDCTabScrollerRTLReverse;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTabScrollerRTLReverse;
/***/ }),
/***/ "./packages/mdc-tab-scroller/rtl-scroller.ts":
/*!***************************************************!*\
!*** ./packages/mdc-tab-scroller/rtl-scroller.ts ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTabScrollerRTL = void 0;
var MDCTabScrollerRTL = /** @class */function () {
function MDCTabScrollerRTL(adapter) {
this.adapter = adapter;
}
return MDCTabScrollerRTL;
}();
exports.MDCTabScrollerRTL = MDCTabScrollerRTL;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTabScrollerRTL;
/***/ }),
/***/ "./packages/mdc-tab-scroller/types.ts":
/*!********************************************!*\
!*** ./packages/mdc-tab-scroller/types.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-tab-scroller/util.ts":
/*!*******************************************!*\
!*** ./packages/mdc-tab-scroller/util.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.computeHorizontalScrollbarHeight = void 0;
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts");
/**
* Stores result from computeHorizontalScrollbarHeight to avoid redundant processing.
*/
var horizontalScrollbarHeight_;
/**
* Computes the height of browser-rendered horizontal scrollbars using a self-created test element.
* May return 0 (e.g. on OS X browsers under default configuration).
*/
function computeHorizontalScrollbarHeight(documentObj, shouldCacheResult) {
if (shouldCacheResult === void 0) {
shouldCacheResult = true;
}
if (shouldCacheResult && typeof horizontalScrollbarHeight_ !== 'undefined') {
return horizontalScrollbarHeight_;
}
var el = documentObj.createElement('div');
el.classList.add(constants_1.cssClasses.SCROLL_TEST);
documentObj.body.appendChild(el);
var horizontalScrollbarHeight = el.offsetHeight - el.clientHeight;
documentObj.body.removeChild(el);
if (shouldCacheResult) {
horizontalScrollbarHeight_ = horizontalScrollbarHeight;
}
return horizontalScrollbarHeight;
}
exports.computeHorizontalScrollbarHeight = computeHorizontalScrollbarHeight;
/***/ }),
/***/ "./packages/mdc-tab/adapter.ts":
/*!*************************************!*\
!*** ./packages/mdc-tab/adapter.ts ***!
\*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-tab/component.ts":
/*!***************************************!*\
!*** ./packages/mdc-tab/component.ts ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTab = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
var component_3 = __webpack_require__(/*! @material/tab-indicator/component */ "./packages/mdc-tab-indicator/component.ts");
var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab/foundation.ts");
var MDCTab = /** @class */function (_super) {
__extends(MDCTab, _super);
function MDCTab() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTab.attachTo = function (root) {
return new MDCTab(root);
};
MDCTab.prototype.initialize = function (rippleFactory, tabIndicatorFactory) {
if (rippleFactory === void 0) {
rippleFactory = function rippleFactory(el, foundation) {
return new component_2.MDCRipple(el, foundation);
};
}
if (tabIndicatorFactory === void 0) {
tabIndicatorFactory = function tabIndicatorFactory(el) {
return new component_3.MDCTabIndicator(el);
};
}
this.id = this.root.id;
var rippleFoundation = new foundation_1.MDCRippleFoundation(component_2.MDCRipple.createAdapter(this));
this.ripple = rippleFactory(this.root, rippleFoundation);
var tabIndicatorElement = this.root.querySelector(foundation_2.MDCTabFoundation.strings.TAB_INDICATOR_SELECTOR);
this.tabIndicator = tabIndicatorFactory(tabIndicatorElement);
this.content = this.root.querySelector(foundation_2.MDCTabFoundation.strings.CONTENT_SELECTOR);
};
MDCTab.prototype.initialSyncWithDOM = function () {
var _this = this;
this.handleClick = function () {
_this.foundation.handleClick();
};
this.listen('click', this.handleClick);
};
MDCTab.prototype.destroy = function () {
this.unlisten('click', this.handleClick);
this.ripple.destroy();
_super.prototype.destroy.call(this);
};
MDCTab.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
setAttr: function setAttr(attr, value) {
return _this.root.setAttribute(attr, value);
},
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
activateIndicator: function activateIndicator(previousIndicatorClientRect) {
_this.tabIndicator.activate(previousIndicatorClientRect);
},
deactivateIndicator: function deactivateIndicator() {
_this.tabIndicator.deactivate();
},
notifyInteracted: function notifyInteracted() {
return _this.emit(foundation_2.MDCTabFoundation.strings.INTERACTED_EVENT, { tabId: _this.id }, true /* bubble */);
},
getOffsetLeft: function getOffsetLeft() {
return _this.root.offsetLeft;
},
getOffsetWidth: function getOffsetWidth() {
return _this.root.offsetWidth;
},
getContentOffsetLeft: function getContentOffsetLeft() {
return _this.content.offsetLeft;
},
getContentOffsetWidth: function getContentOffsetWidth() {
return _this.content.offsetWidth;
},
focus: function focus() {
return _this.root.focus();
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_2.MDCTabFoundation(adapter);
};
Object.defineProperty(MDCTab.prototype, "active", {
/**
* Getter for the active state of the tab
*/
get: function get() {
return this.foundation.isActive();
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTab.prototype, "focusOnActivate", {
set: function set(focusOnActivate) {
this.foundation.setFocusOnActivate(focusOnActivate);
},
enumerable: false,
configurable: true
});
/**
* Activates the tab
*/
MDCTab.prototype.activate = function (computeIndicatorClientRect) {
this.foundation.activate(computeIndicatorClientRect);
};
/**
* Deactivates the tab
*/
MDCTab.prototype.deactivate = function () {
this.foundation.deactivate();
};
/**
* Returns the indicator's client rect
*/
MDCTab.prototype.computeIndicatorClientRect = function () {
return this.tabIndicator.computeContentClientRect();
};
MDCTab.prototype.computeDimensions = function () {
return this.foundation.computeDimensions();
};
/**
* Focuses the tab
*/
MDCTab.prototype.focus = function () {
this.root.focus();
};
return MDCTab;
}(component_1.MDCComponent);
exports.MDCTab = MDCTab;
/***/ }),
/***/ "./packages/mdc-tab/constants.ts":
/*!***************************************!*\
!*** ./packages/mdc-tab/constants.ts ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.cssClasses = void 0;
var cssClasses = {
ACTIVE: 'mdc-tab--active'
};
exports.cssClasses = cssClasses;
var strings = {
ARIA_SELECTED: 'aria-selected',
CONTENT_SELECTOR: '.mdc-tab__content',
INTERACTED_EVENT: 'MDCTab:interacted',
RIPPLE_SELECTOR: '.mdc-tab__ripple',
TABINDEX: 'tabIndex',
TAB_INDICATOR_SELECTOR: '.mdc-tab-indicator'
};
exports.strings = strings;
/***/ }),
/***/ "./packages/mdc-tab/foundation.ts":
/*!****************************************!*\
!*** ./packages/mdc-tab/foundation.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTabFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab/constants.ts");
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 get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTabFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTabFoundation, "defaultAdapter", {
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
hasClass: function hasClass() {
return false;
},
setAttr: function setAttr() {
return undefined;
},
activateIndicator: function activateIndicator() {
return undefined;
},
deactivateIndicator: function deactivateIndicator() {
return undefined;
},
notifyInteracted: function notifyInteracted() {
return undefined;
},
getOffsetLeft: function getOffsetLeft() {
return 0;
},
getOffsetWidth: function getOffsetWidth() {
return 0;
},
getContentOffsetLeft: function getContentOffsetLeft() {
return 0;
},
getContentOffsetWidth: function getContentOffsetWidth() {
return 0;
},
focus: function focus() {
return undefined;
}
};
// 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(constants_1.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(constants_1.cssClasses.ACTIVE);
this.adapter.setAttr(constants_1.strings.ARIA_SELECTED, 'true');
this.adapter.setAttr(constants_1.strings.TABINDEX, '0');
this.adapter.activateIndicator(previousIndicatorClientRect);
if (this.focusOnActivate) {
this.adapter.focus();
}
};
/**
* Deactivates the Tab
*/
MDCTabFoundation.prototype.deactivate = function () {
// Early exit
if (!this.isActive()) {
return;
}
this.adapter.removeClass(constants_1.cssClasses.ACTIVE);
this.adapter.setAttr(constants_1.strings.ARIA_SELECTED, 'false');
this.adapter.setAttr(constants_1.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;
}(foundation_1.MDCFoundation);
exports.MDCTabFoundation = MDCTabFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTabFoundation;
/***/ }),
/***/ "./packages/mdc-tab/index.ts":
/*!***********************************!*\
!*** ./packages/mdc-tab/index.ts ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-tab/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-tab/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-tab/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-tab/types.ts"), exports);
/***/ }),
/***/ "./packages/mdc-tab/types.ts":
/*!***********************************!*\
!*** ./packages/mdc-tab/types.ts ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-textfield/adapter.ts":
/*!*******************************************!*\
!*** ./packages/mdc-textfield/adapter.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-textfield/character-counter/adapter.ts":
/*!*************************************************************!*\
!*** ./packages/mdc-textfield/character-counter/adapter.ts ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-textfield/character-counter/component.ts":
/*!***************************************************************!*\
!*** ./packages/mdc-textfield/character-counter/component.ts ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTextFieldCharacterCounter = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/character-counter/foundation.ts");
var MDCTextFieldCharacterCounter = /** @class */function (_super) {
__extends(MDCTextFieldCharacterCounter, _super);
function MDCTextFieldCharacterCounter() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTextFieldCharacterCounter.attachTo = function (root) {
return new MDCTextFieldCharacterCounter(root);
};
Object.defineProperty(MDCTextFieldCharacterCounter.prototype, "foundationForTextField", {
// Provided for access by MDCTextField component
get: function get() {
return this.foundation;
},
enumerable: false,
configurable: true
});
MDCTextFieldCharacterCounter.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = {
setContent: function setContent(content) {
_this.root.textContent = content;
}
};
return new foundation_1.MDCTextFieldCharacterCounterFoundation(adapter);
};
return MDCTextFieldCharacterCounter;
}(component_1.MDCComponent);
exports.MDCTextFieldCharacterCounter = MDCTextFieldCharacterCounter;
/***/ }),
/***/ "./packages/mdc-textfield/character-counter/constants.ts":
/*!***************************************************************!*\
!*** ./packages/mdc-textfield/character-counter/constants.ts ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssClasses = exports.strings = void 0;
var cssClasses = {
ROOT: 'mdc-text-field-character-counter'
};
exports.cssClasses = cssClasses;
var strings = {
ROOT_SELECTOR: "." + cssClasses.ROOT
};
exports.strings = strings;
/***/ }),
/***/ "./packages/mdc-textfield/character-counter/foundation.ts":
/*!****************************************************************!*\
!*** ./packages/mdc-textfield/character-counter/foundation.ts ***!
\****************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTextFieldCharacterCounterFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/character-counter/constants.ts");
var MDCTextFieldCharacterCounterFoundation = /** @class */function (_super) {
__extends(MDCTextFieldCharacterCounterFoundation, _super);
function MDCTextFieldCharacterCounterFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCTextFieldCharacterCounterFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "defaultAdapter", {
/**
* See {@link MDCTextFieldCharacterCounterAdapter} for typing information on parameters and return types.
*/
get: function get() {
return {
setContent: function setContent() {
return undefined;
}
};
},
enumerable: false,
configurable: true
});
MDCTextFieldCharacterCounterFoundation.prototype.setCounterValue = function (currentLength, maxLength) {
currentLength = Math.min(currentLength, maxLength);
this.adapter.setContent(currentLength + " / " + maxLength);
};
return MDCTextFieldCharacterCounterFoundation;
}(foundation_1.MDCFoundation);
exports.MDCTextFieldCharacterCounterFoundation = MDCTextFieldCharacterCounterFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTextFieldCharacterCounterFoundation;
/***/ }),
/***/ "./packages/mdc-textfield/character-counter/index.ts":
/*!***********************************************************!*\
!*** ./packages/mdc-textfield/character-counter/index.ts ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.characterCountStrings = exports.characterCountCssClasses = void 0;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-textfield/character-counter/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/character-counter/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/character-counter/foundation.ts"), exports);
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/character-counter/constants.ts");
Object.defineProperty(exports, "characterCountCssClasses", { enumerable: true, get: function get() {
return constants_1.cssClasses;
} });
Object.defineProperty(exports, "characterCountStrings", { enumerable: true, get: function get() {
return constants_1.strings;
} });
/***/ }),
/***/ "./packages/mdc-textfield/component.ts":
/*!*********************************************!*\
!*** ./packages/mdc-textfield/component.ts ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTextField = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
var ponyfill = __importStar(__webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts"));
var component_2 = __webpack_require__(/*! @material/floating-label/component */ "./packages/mdc-floating-label/component.ts");
var component_3 = __webpack_require__(/*! @material/line-ripple/component */ "./packages/mdc-line-ripple/component.ts");
var component_4 = __webpack_require__(/*! @material/notched-outline/component */ "./packages/mdc-notched-outline/component.ts");
var component_5 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
var component_6 = __webpack_require__(/*! ./character-counter/component */ "./packages/mdc-textfield/character-counter/component.ts");
var foundation_2 = __webpack_require__(/*! ./character-counter/foundation */ "./packages/mdc-textfield/character-counter/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts");
var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/foundation.ts");
var component_7 = __webpack_require__(/*! ./helper-text/component */ "./packages/mdc-textfield/helper-text/component.ts");
var foundation_4 = __webpack_require__(/*! ./helper-text/foundation */ "./packages/mdc-textfield/helper-text/foundation.ts");
var component_8 = __webpack_require__(/*! ./icon/component */ "./packages/mdc-textfield/icon/component.ts");
var MDCTextField = /** @class */function (_super) {
__extends(MDCTextField, _super);
function MDCTextField() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTextField.attachTo = function (root) {
return new MDCTextField(root);
};
MDCTextField.prototype.initialize = function (rippleFactory, lineRippleFactory, helperTextFactory, characterCounterFactory, iconFactory, labelFactory, outlineFactory) {
if (rippleFactory === void 0) {
rippleFactory = function rippleFactory(el, foundation) {
return new component_5.MDCRipple(el, foundation);
};
}
if (lineRippleFactory === void 0) {
lineRippleFactory = function lineRippleFactory(el) {
return new component_3.MDCLineRipple(el);
};
}
if (helperTextFactory === void 0) {
helperTextFactory = function helperTextFactory(el) {
return new component_7.MDCTextFieldHelperText(el);
};
}
if (characterCounterFactory === void 0) {
characterCounterFactory = function characterCounterFactory(el) {
return new component_6.MDCTextFieldCharacterCounter(el);
};
}
if (iconFactory === void 0) {
iconFactory = function iconFactory(el) {
return new component_8.MDCTextFieldIcon(el);
};
}
if (labelFactory === void 0) {
labelFactory = function labelFactory(el) {
return new component_2.MDCFloatingLabel(el);
};
}
if (outlineFactory === void 0) {
outlineFactory = function outlineFactory(el) {
return new component_4.MDCNotchedOutline(el);
};
}
this.input = this.root.querySelector(constants_1.strings.INPUT_SELECTOR);
var labelElement = this.root.querySelector(constants_1.strings.LABEL_SELECTOR);
this.label = labelElement ? labelFactory(labelElement) : null;
var lineRippleElement = this.root.querySelector(constants_1.strings.LINE_RIPPLE_SELECTOR);
this.lineRipple = lineRippleElement ? lineRippleFactory(lineRippleElement) : null;
var outlineElement = this.root.querySelector(constants_1.strings.OUTLINE_SELECTOR);
this.outline = outlineElement ? outlineFactory(outlineElement) : null;
// Helper text
var helperTextStrings = foundation_4.MDCTextFieldHelperTextFoundation.strings;
var nextElementSibling = this.root.nextElementSibling;
var hasHelperLine = nextElementSibling && nextElementSibling.classList.contains(constants_1.cssClasses.HELPER_LINE);
var helperTextEl = hasHelperLine && nextElementSibling && nextElementSibling.querySelector(helperTextStrings.ROOT_SELECTOR);
this.helperText = helperTextEl ? helperTextFactory(helperTextEl) : null;
// Character counter
var characterCounterStrings = foundation_2.MDCTextFieldCharacterCounterFoundation.strings;
var characterCounterEl = this.root.querySelector(characterCounterStrings.ROOT_SELECTOR);
// If character counter is not found in root element search in sibling element.
if (!characterCounterEl && hasHelperLine && nextElementSibling) {
characterCounterEl = nextElementSibling.querySelector(characterCounterStrings.ROOT_SELECTOR);
}
this.characterCounter = characterCounterEl ? characterCounterFactory(characterCounterEl) : null;
// Leading icon
var leadingIconEl = this.root.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
this.leadingIcon = leadingIconEl ? iconFactory(leadingIconEl) : null;
// Trailing icon
var trailingIconEl = this.root.querySelector(constants_1.strings.TRAILING_ICON_SELECTOR);
this.trailingIcon = trailingIconEl ? iconFactory(trailingIconEl) : null;
// Prefix and Suffix
this.prefix = this.root.querySelector(constants_1.strings.PREFIX_SELECTOR);
this.suffix = this.root.querySelector(constants_1.strings.SUFFIX_SELECTOR);
this.ripple = this.createRipple(rippleFactory);
};
MDCTextField.prototype.destroy = function () {
if (this.ripple) {
this.ripple.destroy();
}
if (this.lineRipple) {
this.lineRipple.destroy();
}
if (this.helperText) {
this.helperText.destroy();
}
if (this.characterCounter) {
this.characterCounter.destroy();
}
if (this.leadingIcon) {
this.leadingIcon.destroy();
}
if (this.trailingIcon) {
this.trailingIcon.destroy();
}
if (this.label) {
this.label.destroy();
}
if (this.outline) {
this.outline.destroy();
}
_super.prototype.destroy.call(this);
};
/**
* Initializes the Text Field's internal state based on the environment's
* state.
*/
MDCTextField.prototype.initialSyncWithDOM = function () {
this.disabled = this.input.disabled;
};
Object.defineProperty(MDCTextField.prototype, "value", {
get: function get() {
return this.foundation.getValue();
},
/**
* @param value The value to set on the input.
*/
set: function set(value) {
this.foundation.setValue(value);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "disabled", {
get: function get() {
return this.foundation.isDisabled();
},
/**
* @param disabled Sets the Text Field disabled or enabled.
*/
set: function set(disabled) {
this.foundation.setDisabled(disabled);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "valid", {
get: function get() {
return this.foundation.isValid();
},
/**
* @param valid Sets the Text Field valid or invalid.
*/
set: function set(valid) {
this.foundation.setValid(valid);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "required", {
get: function get() {
return this.input.required;
},
/**
* @param required Sets the Text Field to required.
*/
set: function set(required) {
this.input.required = required;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "pattern", {
get: function get() {
return this.input.pattern;
},
/**
* @param pattern Sets the input element's validation pattern.
*/
set: function set(pattern) {
this.input.pattern = pattern;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "minLength", {
get: function get() {
return this.input.minLength;
},
/**
* @param minLength Sets the input element's minLength.
*/
set: function set(minLength) {
this.input.minLength = minLength;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "maxLength", {
get: function get() {
return this.input.maxLength;
},
/**
* @param maxLength Sets the input element's maxLength.
*/
set: function set(maxLength) {
// Chrome throws exception if maxLength is set to a value less than zero
if (maxLength < 0) {
this.input.removeAttribute('maxLength');
} else {
this.input.maxLength = maxLength;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "min", {
get: function get() {
return this.input.min;
},
/**
* @param min Sets the input element's min.
*/
set: function set(min) {
this.input.min = min;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "max", {
get: function get() {
return this.input.max;
},
/**
* @param max Sets the input element's max.
*/
set: function set(max) {
this.input.max = max;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "step", {
get: function get() {
return this.input.step;
},
/**
* @param step Sets the input element's step.
*/
set: function set(step) {
this.input.step = step;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "helperTextContent", {
/**
* Sets the helper text element content.
*/
set: function set(content) {
this.foundation.setHelperTextContent(content);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "leadingIconAriaLabel", {
/**
* Sets the aria label of the leading icon.
*/
set: function set(label) {
this.foundation.setLeadingIconAriaLabel(label);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "leadingIconContent", {
/**
* Sets the text content of the leading icon.
*/
set: function set(content) {
this.foundation.setLeadingIconContent(content);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "trailingIconAriaLabel", {
/**
* Sets the aria label of the trailing icon.
*/
set: function set(label) {
this.foundation.setTrailingIconAriaLabel(label);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "trailingIconContent", {
/**
* Sets the text content of the trailing icon.
*/
set: function set(content) {
this.foundation.setTrailingIconContent(content);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "useNativeValidation", {
/**
* Enables or disables the use of native validation. Use this for custom validation.
* @param useNativeValidation Set this to false to ignore native input validation.
*/
set: function set(useNativeValidation) {
this.foundation.setUseNativeValidation(useNativeValidation);
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "prefixText", {
/**
* Gets the text content of the prefix, or null if it does not exist.
*/
get: function get() {
return this.prefix ? this.prefix.textContent : null;
},
/**
* Sets the text content of the prefix, if it exists.
*/
set: function set(prefixText) {
if (this.prefix) {
this.prefix.textContent = prefixText;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextField.prototype, "suffixText", {
/**
* Gets the text content of the suffix, or null if it does not exist.
*/
get: function get() {
return this.suffix ? this.suffix.textContent : null;
},
/**
* Sets the text content of the suffix, if it exists.
*/
set: function set(suffixText) {
if (this.suffix) {
this.suffix.textContent = suffixText;
}
},
enumerable: false,
configurable: true
});
/**
* Focuses the input element.
*/
MDCTextField.prototype.focus = function () {
this.input.focus();
};
/**
* Recomputes the outline SVG path for the outline element.
*/
MDCTextField.prototype.layout = function () {
var openNotch = this.foundation.shouldFloat;
this.foundation.notchOutline(openNotch);
};
MDCTextField.prototype.getDefaultFoundation = function () {
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = __assign(__assign(__assign(__assign(__assign({}, this.getRootAdapterMethods()), this.getInputAdapterMethods()), this.getLabelAdapterMethods()), this.getLineRippleAdapterMethods()), this.getOutlineAdapterMethods());
// tslint:enable:object-literal-sort-keys
return new foundation_3.MDCTextFieldFoundation(adapter, this.getFoundationMap());
};
MDCTextField.prototype.getRootAdapterMethods = function () {
var _this = this;
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
registerTextFieldInteractionHandler: function registerTextFieldInteractionHandler(evtType, handler) {
_this.listen(evtType, handler);
},
deregisterTextFieldInteractionHandler: function deregisterTextFieldInteractionHandler(evtType, handler) {
_this.unlisten(evtType, handler);
},
registerValidationAttributeChangeHandler: function registerValidationAttributeChangeHandler(handler) {
var getAttributesList = function getAttributesList(mutationsList) {
return mutationsList.map(function (mutation) {
return mutation.attributeName;
}).filter(function (attributeName) {
return attributeName;
});
};
var observer = new MutationObserver(function (mutationsList) {
return handler(getAttributesList(mutationsList));
});
var config = { attributes: true };
observer.observe(_this.input, config);
return observer;
},
deregisterValidationAttributeChangeHandler: function deregisterValidationAttributeChangeHandler(observer) {
observer.disconnect();
}
};
// tslint:enable:object-literal-sort-keys
};
MDCTextField.prototype.getInputAdapterMethods = function () {
var _this = this;
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
getNativeInput: function getNativeInput() {
return _this.input;
},
setInputAttr: function setInputAttr(attr, value) {
_this.input.setAttribute(attr, value);
},
removeInputAttr: function removeInputAttr(attr) {
_this.input.removeAttribute(attr);
},
isFocused: function isFocused() {
return document.activeElement === _this.input;
},
registerInputInteractionHandler: function registerInputInteractionHandler(evtType, handler) {
_this.input.addEventListener(evtType, handler, events_1.applyPassive());
},
deregisterInputInteractionHandler: function deregisterInputInteractionHandler(evtType, handler) {
_this.input.removeEventListener(evtType, handler, events_1.applyPassive());
}
};
// tslint:enable:object-literal-sort-keys
};
MDCTextField.prototype.getLabelAdapterMethods = function () {
var _this = this;
return {
floatLabel: function floatLabel(shouldFloat) {
_this.label && _this.label.float(shouldFloat);
},
getLabelWidth: function getLabelWidth() {
return _this.label ? _this.label.getWidth() : 0;
},
hasLabel: function hasLabel() {
return Boolean(_this.label);
},
shakeLabel: function shakeLabel(shouldShake) {
_this.label && _this.label.shake(shouldShake);
},
setLabelRequired: function setLabelRequired(isRequired) {
_this.label && _this.label.setRequired(isRequired);
}
};
};
MDCTextField.prototype.getLineRippleAdapterMethods = function () {
var _this = this;
return {
activateLineRipple: function activateLineRipple() {
if (_this.lineRipple) {
_this.lineRipple.activate();
}
},
deactivateLineRipple: function deactivateLineRipple() {
if (_this.lineRipple) {
_this.lineRipple.deactivate();
}
},
setLineRippleTransformOrigin: function setLineRippleTransformOrigin(normalizedX) {
if (_this.lineRipple) {
_this.lineRipple.setRippleCenter(normalizedX);
}
}
};
};
MDCTextField.prototype.getOutlineAdapterMethods = function () {
var _this = this;
return {
closeOutline: function closeOutline() {
_this.outline && _this.outline.closeNotch();
},
hasOutline: function hasOutline() {
return Boolean(_this.outline);
},
notchOutline: function notchOutline(labelWidth) {
_this.outline && _this.outline.notch(labelWidth);
}
};
};
/**
* @return A map of all subcomponents to subfoundations.
*/
MDCTextField.prototype.getFoundationMap = function () {
return {
characterCounter: this.characterCounter ? this.characterCounter.foundationForTextField : undefined,
helperText: this.helperText ? this.helperText.foundationForTextField : undefined,
leadingIcon: this.leadingIcon ? this.leadingIcon.foundationForTextField : undefined,
trailingIcon: this.trailingIcon ? this.trailingIcon.foundationForTextField : undefined
};
};
MDCTextField.prototype.createRipple = function (rippleFactory) {
var _this = this;
var isTextArea = this.root.classList.contains(constants_1.cssClasses.TEXTAREA);
var isOutlined = this.root.classList.contains(constants_1.cssClasses.OUTLINED);
if (isTextArea || isOutlined) {
return null;
}
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = __assign(__assign({}, component_5.MDCRipple.createAdapter(this)), { isSurfaceActive: function isSurfaceActive() {
return ponyfill.matches(_this.input, ':active');
}, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
_this.input.addEventListener(evtType, handler, events_1.applyPassive());
}, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
_this.input.removeEventListener(evtType, handler, events_1.applyPassive());
} });
// tslint:enable:object-literal-sort-keys
return rippleFactory(this.root, new foundation_1.MDCRippleFoundation(adapter));
};
return MDCTextField;
}(component_1.MDCComponent);
exports.MDCTextField = MDCTextField;
/***/ }),
/***/ "./packages/mdc-textfield/constants.ts":
/*!*********************************************!*\
!*** ./packages/mdc-textfield/constants.ts ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ALWAYS_FLOAT_TYPES = exports.VALIDATION_ATTR_WHITELIST = exports.numbers = exports.strings = exports.cssClasses = void 0;
var strings = {
ARIA_CONTROLS: 'aria-controls',
ARIA_DESCRIBEDBY: 'aria-describedby',
INPUT_SELECTOR: '.mdc-text-field__input',
LABEL_SELECTOR: '.mdc-floating-label',
LEADING_ICON_SELECTOR: '.mdc-text-field__icon--leading',
LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
OUTLINE_SELECTOR: '.mdc-notched-outline',
PREFIX_SELECTOR: '.mdc-text-field__affix--prefix',
SUFFIX_SELECTOR: '.mdc-text-field__affix--suffix',
TRAILING_ICON_SELECTOR: '.mdc-text-field__icon--trailing'
};
exports.strings = strings;
var cssClasses = {
DISABLED: 'mdc-text-field--disabled',
FOCUSED: 'mdc-text-field--focused',
HELPER_LINE: 'mdc-text-field-helper-line',
INVALID: 'mdc-text-field--invalid',
LABEL_FLOATING: 'mdc-text-field--label-floating',
NO_LABEL: 'mdc-text-field--no-label',
OUTLINED: 'mdc-text-field--outlined',
ROOT: 'mdc-text-field',
TEXTAREA: 'mdc-text-field--textarea',
WITH_LEADING_ICON: 'mdc-text-field--with-leading-icon',
WITH_TRAILING_ICON: 'mdc-text-field--with-trailing-icon',
WITH_INTERNAL_COUNTER: 'mdc-text-field--with-internal-counter'
};
exports.cssClasses = cssClasses;
var numbers = {
LABEL_SCALE: 0.75
};
exports.numbers = numbers;
/**
* Whitelist based off of
* https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation
* under the "Validation-related attributes" section.
*/
var VALIDATION_ATTR_WHITELIST = ['pattern', 'min', 'max', 'required', 'step', 'minlength', 'maxlength'];
exports.VALIDATION_ATTR_WHITELIST = VALIDATION_ATTR_WHITELIST;
/**
* Label should always float for these types as they show some UI even if value
* is empty.
*/
var ALWAYS_FLOAT_TYPES = ['color', 'date', 'datetime-local', 'month', 'range', 'time', 'week'];
exports.ALWAYS_FLOAT_TYPES = ALWAYS_FLOAT_TYPES;
/***/ }),
/***/ "./packages/mdc-textfield/foundation.ts":
/*!**********************************************!*\
!*** ./packages/mdc-textfield/foundation.ts ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTextFieldFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts");
var POINTERDOWN_EVENTS = ['mousedown', 'touchstart'];
var INTERACTION_EVENTS = ['click', 'keydown'];
var MDCTextFieldFoundation = /** @class */function (_super) {
__extends(MDCTextFieldFoundation, _super);
/**
* @param adapter
* @param foundationMap Map from subcomponent names to their subfoundations.
*/
function MDCTextFieldFoundation(adapter, foundationMap) {
if (foundationMap === void 0) {
foundationMap = {};
}
var _this = _super.call(this, __assign(__assign({}, MDCTextFieldFoundation.defaultAdapter), adapter)) || this;
_this.isFocused = false;
_this.receivedUserInput = false;
_this.valid = true;
_this.useNativeValidation = true;
_this.validateOnValueChange = true;
_this.helperText = foundationMap.helperText;
_this.characterCounter = foundationMap.characterCounter;
_this.leadingIcon = foundationMap.leadingIcon;
_this.trailingIcon = foundationMap.trailingIcon;
_this.inputFocusHandler = function () {
_this.activateFocus();
};
_this.inputBlurHandler = function () {
_this.deactivateFocus();
};
_this.inputInputHandler = function () {
_this.handleInput();
};
_this.setPointerXOffset = function (evt) {
_this.setTransformOrigin(evt);
};
_this.textFieldInteractionHandler = function () {
_this.handleTextFieldInteraction();
};
_this.validationAttributeChangeHandler = function (attributesList) {
_this.handleValidationAttributeChange(attributesList);
};
return _this;
}
Object.defineProperty(MDCTextFieldFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldFoundation, "numbers", {
get: function get() {
return constants_1.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldAlwaysFloat", {
get: function get() {
var type = this.getNativeInput().type;
return constants_1.ALWAYS_FLOAT_TYPES.indexOf(type) >= 0;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldFloat", {
get: function get() {
return this.shouldAlwaysFloat || this.isFocused || !!this.getValue() || this.isBadInput();
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldShake", {
get: function get() {
return !this.isFocused && !this.isValid() && !!this.getValue();
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldFoundation, "defaultAdapter", {
/**
* See {@link MDCTextFieldAdapter} for typing information on parameters and
* return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
hasClass: function hasClass() {
return true;
},
setInputAttr: function setInputAttr() {
return undefined;
},
removeInputAttr: function removeInputAttr() {
return undefined;
},
registerTextFieldInteractionHandler: function registerTextFieldInteractionHandler() {
return undefined;
},
deregisterTextFieldInteractionHandler: function deregisterTextFieldInteractionHandler() {
return undefined;
},
registerInputInteractionHandler: function registerInputInteractionHandler() {
return undefined;
},
deregisterInputInteractionHandler: function deregisterInputInteractionHandler() {
return undefined;
},
registerValidationAttributeChangeHandler: function registerValidationAttributeChangeHandler() {
return new MutationObserver(function () {
return undefined;
});
},
deregisterValidationAttributeChangeHandler: function deregisterValidationAttributeChangeHandler() {
return undefined;
},
getNativeInput: function getNativeInput() {
return null;
},
isFocused: function isFocused() {
return false;
},
activateLineRipple: function activateLineRipple() {
return undefined;
},
deactivateLineRipple: function deactivateLineRipple() {
return undefined;
},
setLineRippleTransformOrigin: function setLineRippleTransformOrigin() {
return undefined;
},
shakeLabel: function shakeLabel() {
return undefined;
},
floatLabel: function floatLabel() {
return undefined;
},
setLabelRequired: function setLabelRequired() {
return undefined;
},
hasLabel: function hasLabel() {
return false;
},
getLabelWidth: function getLabelWidth() {
return 0;
},
hasOutline: function hasOutline() {
return false;
},
notchOutline: function notchOutline() {
return undefined;
},
closeOutline: function closeOutline() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCTextFieldFoundation.prototype.init = function () {
var e_1, _a, e_2, _b;
if (this.adapter.hasLabel() && this.getNativeInput().required) {
this.adapter.setLabelRequired(true);
}
if (this.adapter.isFocused()) {
this.inputFocusHandler();
} else if (this.adapter.hasLabel() && this.shouldFloat) {
this.notchOutline(true);
this.adapter.floatLabel(true);
this.styleFloating(true);
}
this.adapter.registerInputInteractionHandler('focus', this.inputFocusHandler);
this.adapter.registerInputInteractionHandler('blur', this.inputBlurHandler);
this.adapter.registerInputInteractionHandler('input', this.inputInputHandler);
try {
for (var POINTERDOWN_EVENTS_1 = __values(POINTERDOWN_EVENTS), POINTERDOWN_EVENTS_1_1 = POINTERDOWN_EVENTS_1.next(); !POINTERDOWN_EVENTS_1_1.done; POINTERDOWN_EVENTS_1_1 = POINTERDOWN_EVENTS_1.next()) {
var evtType = POINTERDOWN_EVENTS_1_1.value;
this.adapter.registerInputInteractionHandler(evtType, this.setPointerXOffset);
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (POINTERDOWN_EVENTS_1_1 && !POINTERDOWN_EVENTS_1_1.done && (_a = POINTERDOWN_EVENTS_1.return)) _a.call(POINTERDOWN_EVENTS_1);
} finally {
if (e_1) throw e_1.error;
}
}
try {
for (var INTERACTION_EVENTS_1 = __values(INTERACTION_EVENTS), INTERACTION_EVENTS_1_1 = INTERACTION_EVENTS_1.next(); !INTERACTION_EVENTS_1_1.done; INTERACTION_EVENTS_1_1 = INTERACTION_EVENTS_1.next()) {
var evtType = INTERACTION_EVENTS_1_1.value;
this.adapter.registerTextFieldInteractionHandler(evtType, this.textFieldInteractionHandler);
}
} catch (e_2_1) {
e_2 = { error: e_2_1 };
} finally {
try {
if (INTERACTION_EVENTS_1_1 && !INTERACTION_EVENTS_1_1.done && (_b = INTERACTION_EVENTS_1.return)) _b.call(INTERACTION_EVENTS_1);
} finally {
if (e_2) throw e_2.error;
}
}
this.validationObserver = this.adapter.registerValidationAttributeChangeHandler(this.validationAttributeChangeHandler);
this.setcharacterCounter(this.getValue().length);
};
MDCTextFieldFoundation.prototype.destroy = function () {
var e_3, _a, e_4, _b;
this.adapter.deregisterInputInteractionHandler('focus', this.inputFocusHandler);
this.adapter.deregisterInputInteractionHandler('blur', this.inputBlurHandler);
this.adapter.deregisterInputInteractionHandler('input', this.inputInputHandler);
try {
for (var POINTERDOWN_EVENTS_2 = __values(POINTERDOWN_EVENTS), POINTERDOWN_EVENTS_2_1 = POINTERDOWN_EVENTS_2.next(); !POINTERDOWN_EVENTS_2_1.done; POINTERDOWN_EVENTS_2_1 = POINTERDOWN_EVENTS_2.next()) {
var evtType = POINTERDOWN_EVENTS_2_1.value;
this.adapter.deregisterInputInteractionHandler(evtType, this.setPointerXOffset);
}
} catch (e_3_1) {
e_3 = { error: e_3_1 };
} finally {
try {
if (POINTERDOWN_EVENTS_2_1 && !POINTERDOWN_EVENTS_2_1.done && (_a = POINTERDOWN_EVENTS_2.return)) _a.call(POINTERDOWN_EVENTS_2);
} finally {
if (e_3) throw e_3.error;
}
}
try {
for (var INTERACTION_EVENTS_2 = __values(INTERACTION_EVENTS), INTERACTION_EVENTS_2_1 = INTERACTION_EVENTS_2.next(); !INTERACTION_EVENTS_2_1.done; INTERACTION_EVENTS_2_1 = INTERACTION_EVENTS_2.next()) {
var evtType = INTERACTION_EVENTS_2_1.value;
this.adapter.deregisterTextFieldInteractionHandler(evtType, this.textFieldInteractionHandler);
}
} catch (e_4_1) {
e_4 = { error: e_4_1 };
} finally {
try {
if (INTERACTION_EVENTS_2_1 && !INTERACTION_EVENTS_2_1.done && (_b = INTERACTION_EVENTS_2.return)) _b.call(INTERACTION_EVENTS_2);
} finally {
if (e_4) throw e_4.error;
}
}
this.adapter.deregisterValidationAttributeChangeHandler(this.validationObserver);
};
/**
* Handles user interactions with the Text Field.
*/
MDCTextFieldFoundation.prototype.handleTextFieldInteraction = function () {
var nativeInput = this.adapter.getNativeInput();
if (nativeInput && nativeInput.disabled) {
return;
}
this.receivedUserInput = true;
};
/**
* Handles validation attribute changes
*/
MDCTextFieldFoundation.prototype.handleValidationAttributeChange = function (attributesList) {
var _this = this;
attributesList.some(function (attributeName) {
if (constants_1.VALIDATION_ATTR_WHITELIST.indexOf(attributeName) > -1) {
_this.styleValidity(true);
_this.adapter.setLabelRequired(_this.getNativeInput().required);
return true;
}
return false;
});
if (attributesList.indexOf('maxlength') > -1) {
this.setcharacterCounter(this.getValue().length);
}
};
/**
* Opens/closes the notched outline.
*/
MDCTextFieldFoundation.prototype.notchOutline = function (openNotch) {
if (!this.adapter.hasOutline() || !this.adapter.hasLabel()) {
return;
}
if (openNotch) {
var labelWidth = this.adapter.getLabelWidth() * constants_1.numbers.LABEL_SCALE;
this.adapter.notchOutline(labelWidth);
} else {
this.adapter.closeOutline();
}
};
/**
* Activates the text field focus state.
*/
MDCTextFieldFoundation.prototype.activateFocus = function () {
this.isFocused = true;
this.styleFocused(this.isFocused);
this.adapter.activateLineRipple();
if (this.adapter.hasLabel()) {
this.notchOutline(this.shouldFloat);
this.adapter.floatLabel(this.shouldFloat);
this.styleFloating(this.shouldFloat);
this.adapter.shakeLabel(this.shouldShake);
}
if (this.helperText && (this.helperText.isPersistent() || !this.helperText.isValidation() || !this.valid)) {
this.helperText.showToScreenReader();
}
};
/**
* Sets the line ripple's transform origin, so that the line ripple activate
* animation will animate out from the user's click location.
*/
MDCTextFieldFoundation.prototype.setTransformOrigin = function (evt) {
if (this.isDisabled() || this.adapter.hasOutline()) {
return;
}
var touches = evt.touches;
var targetEvent = touches ? touches[0] : evt;
var targetClientRect = targetEvent.target.getBoundingClientRect();
var normalizedX = targetEvent.clientX - targetClientRect.left;
this.adapter.setLineRippleTransformOrigin(normalizedX);
};
/**
* Handles input change of text input and text area.
*/
MDCTextFieldFoundation.prototype.handleInput = function () {
this.autoCompleteFocus();
this.setcharacterCounter(this.getValue().length);
};
/**
* Activates the Text Field's focus state in cases when the input value
* changes without user input (e.g. programmatically).
*/
MDCTextFieldFoundation.prototype.autoCompleteFocus = function () {
if (!this.receivedUserInput) {
this.activateFocus();
}
};
/**
* Deactivates the Text Field's focus state.
*/
MDCTextFieldFoundation.prototype.deactivateFocus = function () {
this.isFocused = false;
this.adapter.deactivateLineRipple();
var isValid = this.isValid();
this.styleValidity(isValid);
this.styleFocused(this.isFocused);
if (this.adapter.hasLabel()) {
this.notchOutline(this.shouldFloat);
this.adapter.floatLabel(this.shouldFloat);
this.styleFloating(this.shouldFloat);
this.adapter.shakeLabel(this.shouldShake);
}
if (!this.shouldFloat) {
this.receivedUserInput = false;
}
};
MDCTextFieldFoundation.prototype.getValue = function () {
return this.getNativeInput().value;
};
/**
* @param value The value to set on the input Element.
*/
MDCTextFieldFoundation.prototype.setValue = function (value) {
// Prevent Safari from moving the caret to the end of the input when the
// value has not changed.
if (this.getValue() !== value) {
this.getNativeInput().value = value;
}
this.setcharacterCounter(value.length);
if (this.validateOnValueChange) {
var isValid = this.isValid();
this.styleValidity(isValid);
}
if (this.adapter.hasLabel()) {
this.notchOutline(this.shouldFloat);
this.adapter.floatLabel(this.shouldFloat);
this.styleFloating(this.shouldFloat);
if (this.validateOnValueChange) {
this.adapter.shakeLabel(this.shouldShake);
}
}
};
/**
* @return The custom validity state, if set; otherwise, the result of a
* native validity check.
*/
MDCTextFieldFoundation.prototype.isValid = function () {
return this.useNativeValidation ? this.isNativeInputValid() : this.valid;
};
/**
* @param isValid Sets the custom validity state of the Text Field.
*/
MDCTextFieldFoundation.prototype.setValid = function (isValid) {
this.valid = isValid;
this.styleValidity(isValid);
var shouldShake = !isValid && !this.isFocused && !!this.getValue();
if (this.adapter.hasLabel()) {
this.adapter.shakeLabel(shouldShake);
}
};
/**
* @param shouldValidate Whether or not validity should be updated on
* value change.
*/
MDCTextFieldFoundation.prototype.setValidateOnValueChange = function (shouldValidate) {
this.validateOnValueChange = shouldValidate;
};
/**
* @return Whether or not validity should be updated on value change. `true`
* by default.
*/
MDCTextFieldFoundation.prototype.getValidateOnValueChange = function () {
return this.validateOnValueChange;
};
/**
* Enables or disables the use of native validation. Use this for custom
* validation.
* @param useNativeValidation Set this to false to ignore native input
* validation.
*/
MDCTextFieldFoundation.prototype.setUseNativeValidation = function (useNativeValidation) {
this.useNativeValidation = useNativeValidation;
};
MDCTextFieldFoundation.prototype.isDisabled = function () {
return this.getNativeInput().disabled;
};
/**
* @param disabled Sets the text-field disabled or enabled.
*/
MDCTextFieldFoundation.prototype.setDisabled = function (disabled) {
this.getNativeInput().disabled = disabled;
this.styleDisabled(disabled);
};
/**
* @param content Sets the content of the helper text.
*/
MDCTextFieldFoundation.prototype.setHelperTextContent = function (content) {
if (this.helperText) {
this.helperText.setContent(content);
}
};
/**
* Sets the aria label of the leading icon.
*/
MDCTextFieldFoundation.prototype.setLeadingIconAriaLabel = function (label) {
if (this.leadingIcon) {
this.leadingIcon.setAriaLabel(label);
}
};
/**
* Sets the text content of the leading icon.
*/
MDCTextFieldFoundation.prototype.setLeadingIconContent = function (content) {
if (this.leadingIcon) {
this.leadingIcon.setContent(content);
}
};
/**
* Sets the aria label of the trailing icon.
*/
MDCTextFieldFoundation.prototype.setTrailingIconAriaLabel = function (label) {
if (this.trailingIcon) {
this.trailingIcon.setAriaLabel(label);
}
};
/**
* Sets the text content of the trailing icon.
*/
MDCTextFieldFoundation.prototype.setTrailingIconContent = function (content) {
if (this.trailingIcon) {
this.trailingIcon.setContent(content);
}
};
/**
* Sets character counter values that shows characters used and the total
* character limit.
*/
MDCTextFieldFoundation.prototype.setcharacterCounter = function (currentLength) {
if (!this.characterCounter) {
return;
}
var maxLength = this.getNativeInput().maxLength;
if (maxLength === -1) {
throw new Error('MDCTextFieldFoundation: Expected maxlength html property on text input or textarea.');
}
this.characterCounter.setCounterValue(currentLength, maxLength);
};
/**
* @return True if the Text Field input fails in converting the user-supplied
* value.
*/
MDCTextFieldFoundation.prototype.isBadInput = function () {
// The badInput property is not supported in IE 11 💩.
return this.getNativeInput().validity.badInput || false;
};
/**
* @return The result of native validity checking (ValidityState.valid).
*/
MDCTextFieldFoundation.prototype.isNativeInputValid = function () {
return this.getNativeInput().validity.valid;
};
/**
* Styles the component based on the validity state.
*/
MDCTextFieldFoundation.prototype.styleValidity = function (isValid) {
var INVALID = MDCTextFieldFoundation.cssClasses.INVALID;
if (isValid) {
this.adapter.removeClass(INVALID);
} else {
this.adapter.addClass(INVALID);
}
if (this.helperText) {
this.helperText.setValidity(isValid);
// We dynamically set or unset aria-describedby for validation helper text
// only, based on whether the field is valid
var helperTextValidation = this.helperText.isValidation();
if (!helperTextValidation) {
return;
}
var helperTextVisible = this.helperText.isVisible();
var helperTextId = this.helperText.getId();
if (helperTextVisible && helperTextId) {
this.adapter.setInputAttr(constants_1.strings.ARIA_DESCRIBEDBY, helperTextId);
} else {
this.adapter.removeInputAttr(constants_1.strings.ARIA_DESCRIBEDBY);
}
}
};
/**
* Styles the component based on the focused state.
*/
MDCTextFieldFoundation.prototype.styleFocused = function (isFocused) {
var FOCUSED = MDCTextFieldFoundation.cssClasses.FOCUSED;
if (isFocused) {
this.adapter.addClass(FOCUSED);
} else {
this.adapter.removeClass(FOCUSED);
}
};
/**
* Styles the component based on the disabled state.
*/
MDCTextFieldFoundation.prototype.styleDisabled = function (isDisabled) {
var _a = MDCTextFieldFoundation.cssClasses,
DISABLED = _a.DISABLED,
INVALID = _a.INVALID;
if (isDisabled) {
this.adapter.addClass(DISABLED);
this.adapter.removeClass(INVALID);
} else {
this.adapter.removeClass(DISABLED);
}
if (this.leadingIcon) {
this.leadingIcon.setDisabled(isDisabled);
}
if (this.trailingIcon) {
this.trailingIcon.setDisabled(isDisabled);
}
};
/**
* Styles the component based on the label floating state.
*/
MDCTextFieldFoundation.prototype.styleFloating = function (isFloating) {
var LABEL_FLOATING = MDCTextFieldFoundation.cssClasses.LABEL_FLOATING;
if (isFloating) {
this.adapter.addClass(LABEL_FLOATING);
} else {
this.adapter.removeClass(LABEL_FLOATING);
}
};
/**
* @return The native text input element from the host environment, or an
* object with the same shape for unit tests.
*/
MDCTextFieldFoundation.prototype.getNativeInput = function () {
// this.adapter may be undefined in foundation unit tests. This happens when
// testdouble is creating a mock object and invokes the
// shouldShake/shouldFloat getters (which in turn call getValue(), which
// calls this method) before init() has been called from the MDCTextField
// constructor. To work around that issue, we return a dummy object.
var nativeInput = this.adapter ? this.adapter.getNativeInput() : null;
return nativeInput || {
disabled: false,
maxLength: -1,
required: false,
type: 'input',
validity: {
badInput: false,
valid: true
},
value: ''
};
};
return MDCTextFieldFoundation;
}(foundation_1.MDCFoundation);
exports.MDCTextFieldFoundation = MDCTextFieldFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTextFieldFoundation;
/***/ }),
/***/ "./packages/mdc-textfield/helper-text/adapter.ts":
/*!*******************************************************!*\
!*** ./packages/mdc-textfield/helper-text/adapter.ts ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-textfield/helper-text/component.ts":
/*!*********************************************************!*\
!*** ./packages/mdc-textfield/helper-text/component.ts ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTextFieldHelperText = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/helper-text/foundation.ts");
var MDCTextFieldHelperText = /** @class */function (_super) {
__extends(MDCTextFieldHelperText, _super);
function MDCTextFieldHelperText() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTextFieldHelperText.attachTo = function (root) {
return new MDCTextFieldHelperText(root);
};
Object.defineProperty(MDCTextFieldHelperText.prototype, "foundationForTextField", {
// Provided for access by MDCTextField component
get: function get() {
return this.foundation;
},
enumerable: false,
configurable: true
});
MDCTextFieldHelperText.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
getAttr: function getAttr(attr) {
return _this.root.getAttribute(attr);
},
setAttr: function setAttr(attr, value) {
return _this.root.setAttribute(attr, value);
},
removeAttr: function removeAttr(attr) {
return _this.root.removeAttribute(attr);
},
setContent: function setContent(content) {
_this.root.textContent = content;
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_1.MDCTextFieldHelperTextFoundation(adapter);
};
return MDCTextFieldHelperText;
}(component_1.MDCComponent);
exports.MDCTextFieldHelperText = MDCTextFieldHelperText;
/***/ }),
/***/ "./packages/mdc-textfield/helper-text/constants.ts":
/*!*********************************************************!*\
!*** ./packages/mdc-textfield/helper-text/constants.ts ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssClasses = exports.strings = void 0;
var cssClasses = {
HELPER_TEXT_PERSISTENT: 'mdc-text-field-helper-text--persistent',
HELPER_TEXT_VALIDATION_MSG: 'mdc-text-field-helper-text--validation-msg',
ROOT: 'mdc-text-field-helper-text'
};
exports.cssClasses = cssClasses;
var strings = {
ARIA_HIDDEN: 'aria-hidden',
ROLE: 'role',
ROOT_SELECTOR: "." + cssClasses.ROOT
};
exports.strings = strings;
/***/ }),
/***/ "./packages/mdc-textfield/helper-text/foundation.ts":
/*!**********************************************************!*\
!*** ./packages/mdc-textfield/helper-text/foundation.ts ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTextFieldHelperTextFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/helper-text/constants.ts");
var MDCTextFieldHelperTextFoundation = /** @class */function (_super) {
__extends(MDCTextFieldHelperTextFoundation, _super);
function MDCTextFieldHelperTextFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCTextFieldHelperTextFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCTextFieldHelperTextFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldHelperTextFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldHelperTextFoundation, "defaultAdapter", {
/**
* See {@link MDCTextFieldHelperTextAdapter} for typing information on parameters and return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
hasClass: function hasClass() {
return false;
},
getAttr: function getAttr() {
return null;
},
setAttr: function setAttr() {
return undefined;
},
removeAttr: function removeAttr() {
return undefined;
},
setContent: function setContent() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCTextFieldHelperTextFoundation.prototype.getId = function () {
return this.adapter.getAttr('id');
};
MDCTextFieldHelperTextFoundation.prototype.isVisible = function () {
return this.adapter.getAttr(constants_1.strings.ARIA_HIDDEN) !== 'true';
};
/**
* Sets the content of the helper text field.
*/
MDCTextFieldHelperTextFoundation.prototype.setContent = function (content) {
this.adapter.setContent(content);
};
MDCTextFieldHelperTextFoundation.prototype.isPersistent = function () {
return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
};
/**
* @param isPersistent Sets the persistency of the helper text.
*/
MDCTextFieldHelperTextFoundation.prototype.setPersistent = function (isPersistent) {
if (isPersistent) {
this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
} else {
this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
}
};
/**
* @return whether the helper text acts as an error validation message.
*/
MDCTextFieldHelperTextFoundation.prototype.isValidation = function () {
return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
};
/**
* @param isValidation True to make the helper text act as an error validation message.
*/
MDCTextFieldHelperTextFoundation.prototype.setValidation = function (isValidation) {
if (isValidation) {
this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
} else {
this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
}
};
/**
* Makes the helper text visible to the screen reader.
*/
MDCTextFieldHelperTextFoundation.prototype.showToScreenReader = function () {
this.adapter.removeAttr(constants_1.strings.ARIA_HIDDEN);
};
/**
* Sets the validity of the helper text based on the input validity.
*/
MDCTextFieldHelperTextFoundation.prototype.setValidity = function (inputIsValid) {
var helperTextIsPersistent = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
var helperTextIsValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
var validationMsgNeedsDisplay = helperTextIsValidationMsg && !inputIsValid;
if (validationMsgNeedsDisplay) {
this.showToScreenReader();
// If role is already alert, refresh it to trigger another announcement
// from screenreader.
if (this.adapter.getAttr(constants_1.strings.ROLE) === 'alert') {
this.refreshAlertRole();
} else {
this.adapter.setAttr(constants_1.strings.ROLE, 'alert');
}
} else {
this.adapter.removeAttr(constants_1.strings.ROLE);
}
if (!helperTextIsPersistent && !validationMsgNeedsDisplay) {
this.hide();
}
};
/**
* Hides the help text from screen readers.
*/
MDCTextFieldHelperTextFoundation.prototype.hide = function () {
this.adapter.setAttr(constants_1.strings.ARIA_HIDDEN, 'true');
};
MDCTextFieldHelperTextFoundation.prototype.refreshAlertRole = function () {
var _this = this;
this.adapter.removeAttr(constants_1.strings.ROLE);
requestAnimationFrame(function () {
_this.adapter.setAttr(constants_1.strings.ROLE, 'alert');
});
};
return MDCTextFieldHelperTextFoundation;
}(foundation_1.MDCFoundation);
exports.MDCTextFieldHelperTextFoundation = MDCTextFieldHelperTextFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTextFieldHelperTextFoundation;
/***/ }),
/***/ "./packages/mdc-textfield/helper-text/index.ts":
/*!*****************************************************!*\
!*** ./packages/mdc-textfield/helper-text/index.ts ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.helperTextStrings = exports.helperTextCssClasses = void 0;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-textfield/helper-text/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/helper-text/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/helper-text/foundation.ts"), exports);
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/helper-text/constants.ts");
Object.defineProperty(exports, "helperTextCssClasses", { enumerable: true, get: function get() {
return constants_1.cssClasses;
} });
Object.defineProperty(exports, "helperTextStrings", { enumerable: true, get: function get() {
return constants_1.strings;
} });
/***/ }),
/***/ "./packages/mdc-textfield/icon/adapter.ts":
/*!************************************************!*\
!*** ./packages/mdc-textfield/icon/adapter.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-textfield/icon/component.ts":
/*!**************************************************!*\
!*** ./packages/mdc-textfield/icon/component.ts ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTextFieldIcon = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/icon/foundation.ts");
var MDCTextFieldIcon = /** @class */function (_super) {
__extends(MDCTextFieldIcon, _super);
function MDCTextFieldIcon() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTextFieldIcon.attachTo = function (root) {
return new MDCTextFieldIcon(root);
};
Object.defineProperty(MDCTextFieldIcon.prototype, "foundationForTextField", {
// Provided for access by MDCTextField component
get: function get() {
return this.foundation;
},
enumerable: false,
configurable: true
});
MDCTextFieldIcon.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
getAttr: function getAttr(attr) {
return _this.root.getAttribute(attr);
},
setAttr: function setAttr(attr, value) {
return _this.root.setAttribute(attr, value);
},
removeAttr: function removeAttr(attr) {
return _this.root.removeAttribute(attr);
},
setContent: function setContent(content) {
_this.root.textContent = content;
},
registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
return _this.listen(evtType, handler);
},
deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
return _this.unlisten(evtType, handler);
},
notifyIconAction: function notifyIconAction() {
return _this.emit(foundation_1.MDCTextFieldIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */);
}
};
// tslint:enable:object-literal-sort-keys
return new foundation_1.MDCTextFieldIconFoundation(adapter);
};
return MDCTextFieldIcon;
}(component_1.MDCComponent);
exports.MDCTextFieldIcon = MDCTextFieldIcon;
/***/ }),
/***/ "./packages/mdc-textfield/icon/constants.ts":
/*!**************************************************!*\
!*** ./packages/mdc-textfield/icon/constants.ts ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2016 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssClasses = exports.strings = void 0;
var strings = {
ICON_EVENT: 'MDCTextField:icon',
ICON_ROLE: 'button'
};
exports.strings = strings;
var cssClasses = {
ROOT: 'mdc-text-field__icon'
};
exports.cssClasses = cssClasses;
/***/ }),
/***/ "./packages/mdc-textfield/icon/foundation.ts":
/*!***************************************************!*\
!*** ./packages/mdc-textfield/icon/foundation.ts ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2017 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTextFieldIconFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/icon/constants.ts");
var INTERACTION_EVENTS = ['click', 'keydown'];
var MDCTextFieldIconFoundation = /** @class */function (_super) {
__extends(MDCTextFieldIconFoundation, _super);
function MDCTextFieldIconFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCTextFieldIconFoundation.defaultAdapter), adapter)) || this;
_this.savedTabIndex = null;
_this.interactionHandler = function (evt) {
_this.handleInteraction(evt);
};
return _this;
}
Object.defineProperty(MDCTextFieldIconFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldIconFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTextFieldIconFoundation, "defaultAdapter", {
/**
* See {@link MDCTextFieldIconAdapter} for typing information on parameters and return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
getAttr: function getAttr() {
return null;
},
setAttr: function setAttr() {
return undefined;
},
removeAttr: function removeAttr() {
return undefined;
},
setContent: function setContent() {
return undefined;
},
registerInteractionHandler: function registerInteractionHandler() {
return undefined;
},
deregisterInteractionHandler: function deregisterInteractionHandler() {
return undefined;
},
notifyIconAction: function notifyIconAction() {
return undefined;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
MDCTextFieldIconFoundation.prototype.init = function () {
var e_1, _a;
this.savedTabIndex = this.adapter.getAttr('tabindex');
try {
for (var INTERACTION_EVENTS_1 = __values(INTERACTION_EVENTS), INTERACTION_EVENTS_1_1 = INTERACTION_EVENTS_1.next(); !INTERACTION_EVENTS_1_1.done; INTERACTION_EVENTS_1_1 = INTERACTION_EVENTS_1.next()) {
var evtType = INTERACTION_EVENTS_1_1.value;
this.adapter.registerInteractionHandler(evtType, this.interactionHandler);
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (INTERACTION_EVENTS_1_1 && !INTERACTION_EVENTS_1_1.done && (_a = INTERACTION_EVENTS_1.return)) _a.call(INTERACTION_EVENTS_1);
} finally {
if (e_1) throw e_1.error;
}
}
};
MDCTextFieldIconFoundation.prototype.destroy = function () {
var e_2, _a;
try {
for (var INTERACTION_EVENTS_2 = __values(INTERACTION_EVENTS), INTERACTION_EVENTS_2_1 = INTERACTION_EVENTS_2.next(); !INTERACTION_EVENTS_2_1.done; INTERACTION_EVENTS_2_1 = INTERACTION_EVENTS_2.next()) {
var evtType = INTERACTION_EVENTS_2_1.value;
this.adapter.deregisterInteractionHandler(evtType, this.interactionHandler);
}
} catch (e_2_1) {
e_2 = { error: e_2_1 };
} finally {
try {
if (INTERACTION_EVENTS_2_1 && !INTERACTION_EVENTS_2_1.done && (_a = INTERACTION_EVENTS_2.return)) _a.call(INTERACTION_EVENTS_2);
} finally {
if (e_2) throw e_2.error;
}
}
};
MDCTextFieldIconFoundation.prototype.setDisabled = function (disabled) {
if (!this.savedTabIndex) {
return;
}
if (disabled) {
this.adapter.setAttr('tabindex', '-1');
this.adapter.removeAttr('role');
} else {
this.adapter.setAttr('tabindex', this.savedTabIndex);
this.adapter.setAttr('role', constants_1.strings.ICON_ROLE);
}
};
MDCTextFieldIconFoundation.prototype.setAriaLabel = function (label) {
this.adapter.setAttr('aria-label', label);
};
MDCTextFieldIconFoundation.prototype.setContent = function (content) {
this.adapter.setContent(content);
};
MDCTextFieldIconFoundation.prototype.handleInteraction = function (evt) {
var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13;
if (evt.type === 'click' || isEnterKey) {
evt.preventDefault(); // stop click from causing host label to focus
// input
this.adapter.notifyIconAction();
}
};
return MDCTextFieldIconFoundation;
}(foundation_1.MDCFoundation);
exports.MDCTextFieldIconFoundation = MDCTextFieldIconFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTextFieldIconFoundation;
/***/ }),
/***/ "./packages/mdc-textfield/icon/index.ts":
/*!**********************************************!*\
!*** ./packages/mdc-textfield/icon/index.ts ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.iconStrings = exports.iconCssClasses = void 0;
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-textfield/icon/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/icon/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/icon/foundation.ts"), exports);
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/icon/constants.ts");
Object.defineProperty(exports, "iconCssClasses", { enumerable: true, get: function get() {
return constants_1.cssClasses;
} });
Object.defineProperty(exports, "iconStrings", { enumerable: true, get: function get() {
return constants_1.strings;
} });
/***/ }),
/***/ "./packages/mdc-textfield/index.ts":
/*!*****************************************!*\
!*** ./packages/mdc-textfield/index.ts ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-textfield/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-textfield/types.ts"), exports);
__exportStar(__webpack_require__(/*! ./character-counter/index */ "./packages/mdc-textfield/character-counter/index.ts"), exports);
__exportStar(__webpack_require__(/*! ./helper-text/index */ "./packages/mdc-textfield/helper-text/index.ts"), exports);
__exportStar(__webpack_require__(/*! ./icon/index */ "./packages/mdc-textfield/icon/index.ts"), exports);
/***/ }),
/***/ "./packages/mdc-textfield/types.ts":
/*!*****************************************!*\
!*** ./packages/mdc-textfield/types.ts ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-tooltip/adapter.ts":
/*!*****************************************!*\
!*** ./packages/mdc-tooltip/adapter.ts ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-tooltip/component.ts":
/*!*******************************************!*\
!*** ./packages/mdc-tooltip/component.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTooltip = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.ts");
var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tooltip/foundation.ts");
var MDCTooltip = /** @class */function (_super) {
__extends(MDCTooltip, _super);
function MDCTooltip() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTooltip.attachTo = function (root) {
return new MDCTooltip(root);
};
MDCTooltip.prototype.initialize = function () {
var tooltipId = this.root.getAttribute('id');
if (!tooltipId) {
throw new Error('MDCTooltip: Tooltip component must have an id.');
}
var anchorElem = document.querySelector("[data-tooltip-id=\"" + tooltipId + "\"]") || document.querySelector("[aria-describedby=\"" + tooltipId + "\"]");
if (!anchorElem) {
throw new Error('MDCTooltip: Tooltip component requires an anchor element annotated with [aria-describedby] or [data-tooltip-id].');
}
this.anchorElem = anchorElem;
};
MDCTooltip.prototype.initialSyncWithDOM = function () {
var _this = this;
this.isTooltipRich = this.foundation.isRich();
this.isTooltipPersistent = this.foundation.isPersistent();
this.handleMouseEnter = function () {
_this.foundation.handleAnchorMouseEnter();
};
this.handleFocus = function (evt) {
_this.foundation.handleAnchorFocus(evt);
};
this.handleMouseLeave = function () {
_this.foundation.handleAnchorMouseLeave();
};
this.handleTransitionEnd = function () {
_this.foundation.handleTransitionEnd();
};
this.handleClick = function () {
_this.foundation.handleAnchorClick();
};
this.handleTouchstart = function () {
_this.foundation.handleAnchorTouchstart();
};
this.handleTouchend = function () {
_this.foundation.handleAnchorTouchend();
};
if (this.isTooltipRich && this.isTooltipPersistent) {
this.anchorElem.addEventListener('click', this.handleClick);
} else {
this.anchorElem.addEventListener('mouseenter', this.handleMouseEnter);
// TODO(b/157075286): Listening for a 'focus' event is too broad.
this.anchorElem.addEventListener('focus', this.handleFocus);
this.anchorElem.addEventListener('mouseleave', this.handleMouseLeave);
this.anchorElem.addEventListener('touchstart', this.handleTouchstart);
this.anchorElem.addEventListener('touchend', this.handleTouchend);
}
this.listen('transitionend', this.handleTransitionEnd);
};
MDCTooltip.prototype.destroy = function () {
if (this.anchorElem) {
if (this.isTooltipRich && this.isTooltipPersistent) {
this.anchorElem.removeEventListener('click', this.handleClick);
} else {
this.anchorElem.removeEventListener('mouseenter', this.handleMouseEnter);
this.anchorElem.removeEventListener('focus', this.handleFocus);
this.anchorElem.removeEventListener('mouseleave', this.handleMouseLeave);
this.anchorElem.removeEventListener('touchstart', this.handleTouchstart);
this.anchorElem.removeEventListener('touchend', this.handleTouchend);
}
}
this.unlisten('transitionend', this.handleTransitionEnd);
_super.prototype.destroy.call(this);
};
MDCTooltip.prototype.setTooltipPosition = function (position) {
this.foundation.setTooltipPosition(position);
};
MDCTooltip.prototype.setAnchorBoundaryType = function (type) {
this.foundation.setAnchorBoundaryType(type);
};
MDCTooltip.prototype.setShowDelay = function (delayMs) {
this.foundation.setShowDelay(delayMs);
};
MDCTooltip.prototype.setHideDelay = function (delayMs) {
this.foundation.setHideDelay(delayMs);
};
MDCTooltip.prototype.hide = function () {
this.foundation.hide();
};
MDCTooltip.prototype.isShown = function () {
return this.foundation.isShown();
};
/**
* Method that allows user to specify additional elements that should have a
* scroll event listener attached to it. This should be used in instances
* where the anchor element is placed inside a scrollable container (that is
* not the body element), and will ensure that the tooltip will stay attached
* to the anchor on scroll.
*/
MDCTooltip.prototype.attachScrollHandler = function (addEventListenerFn) {
this.foundation.attachScrollHandler(addEventListenerFn);
};
/**
* Must be used in conjunction with #attachScrollHandler. Removes the scroll
* event handler from elements on the page.
*/
MDCTooltip.prototype.removeScrollHandler = function (removeEventHandlerFn) {
this.foundation.removeScrollHandler(removeEventHandlerFn);
};
MDCTooltip.prototype.getDefaultFoundation = function () {
var _this = this;
var adapter = {
getAttribute: function getAttribute(attr) {
return _this.root.getAttribute(attr);
},
setAttribute: function setAttribute(attr, value) {
_this.root.setAttribute(attr, value);
},
removeAttribute: function removeAttribute(attr) {
_this.root.removeAttribute(attr);
},
addClass: function addClass(className) {
_this.root.classList.add(className);
},
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
removeClass: function removeClass(className) {
_this.root.classList.remove(className);
},
getComputedStyleProperty: function getComputedStyleProperty(propertyName) {
return window.getComputedStyle(_this.root).getPropertyValue(propertyName);
},
setStyleProperty: function setStyleProperty(propertyName, value) {
_this.root.style.setProperty(propertyName, value);
},
setSurfaceAnimationStyleProperty: function setSurfaceAnimationStyleProperty(propertyName, value) {
var surface = _this.root.querySelector("." + constants_1.CssClasses.SURFACE_ANIMATION);
surface === null || surface === void 0 ? void 0 : surface.style.setProperty(propertyName, value);
},
getViewportWidth: function getViewportWidth() {
return window.innerWidth;
},
getViewportHeight: function getViewportHeight() {
return window.innerHeight;
},
getTooltipSize: function getTooltipSize() {
return {
width: _this.root.offsetWidth,
height: _this.root.offsetHeight
};
},
getAnchorBoundingRect: function getAnchorBoundingRect() {
return _this.anchorElem ? _this.anchorElem.getBoundingClientRect() : null;
},
getParentBoundingRect: function getParentBoundingRect() {
var _a, _b;
return (_b = (_a = _this.root.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) !== null && _b !== void 0 ? _b : null;
},
getAnchorAttribute: function getAnchorAttribute(attr) {
return _this.anchorElem ? _this.anchorElem.getAttribute(attr) : null;
},
setAnchorAttribute: function setAnchorAttribute(attr, value) {
var _a;
(_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.setAttribute(attr, value);
},
isRTL: function isRTL() {
return getComputedStyle(_this.root).direction === 'rtl';
},
anchorContainsElement: function anchorContainsElement(element) {
var _a;
return !!((_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.contains(element));
},
tooltipContainsElement: function tooltipContainsElement(element) {
return _this.root.contains(element);
},
focusAnchorElement: function focusAnchorElement() {
var _a;
(_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.focus();
},
registerEventHandler: function registerEventHandler(evt, handler) {
if (_this.root instanceof HTMLElement) {
_this.root.addEventListener(evt, handler);
}
},
deregisterEventHandler: function deregisterEventHandler(evt, handler) {
if (_this.root instanceof HTMLElement) {
_this.root.removeEventListener(evt, handler);
}
},
registerAnchorEventHandler: function registerAnchorEventHandler(evt, handler) {
var _a;
(_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.addEventListener(evt, handler);
},
deregisterAnchorEventHandler: function deregisterAnchorEventHandler(evt, handler) {
var _a;
(_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.removeEventListener(evt, handler);
},
registerDocumentEventHandler: function registerDocumentEventHandler(evt, handler) {
document.body.addEventListener(evt, handler);
},
deregisterDocumentEventHandler: function deregisterDocumentEventHandler(evt, handler) {
document.body.removeEventListener(evt, handler);
},
registerWindowEventHandler: function registerWindowEventHandler(evt, handler) {
window.addEventListener(evt, handler);
},
deregisterWindowEventHandler: function deregisterWindowEventHandler(evt, handler) {
window.removeEventListener(evt, handler);
},
notifyHidden: function notifyHidden() {
_this.emit(constants_1.events.HIDDEN, {});
},
getTooltipCaretBoundingRect: function getTooltipCaretBoundingRect() {
var caret = _this.root.querySelector("." + constants_1.CssClasses.TOOLTIP_CARET_TOP);
if (!caret) {
return null;
}
return caret.getBoundingClientRect();
},
setTooltipCaretStyle: function setTooltipCaretStyle(propertyName, value) {
var topCaret = _this.root.querySelector("." + constants_1.CssClasses.TOOLTIP_CARET_TOP);
var bottomCaret = _this.root.querySelector("." + constants_1.CssClasses.TOOLTIP_CARET_BOTTOM);
if (!topCaret || !bottomCaret) {
return;
}
topCaret.style.setProperty(propertyName, value);
bottomCaret.style.setProperty(propertyName, value);
},
clearTooltipCaretStyles: function clearTooltipCaretStyles() {
var topCaret = _this.root.querySelector("." + constants_1.CssClasses.TOOLTIP_CARET_TOP);
var bottomCaret = _this.root.querySelector("." + constants_1.CssClasses.TOOLTIP_CARET_BOTTOM);
if (!topCaret || !bottomCaret) {
return;
}
topCaret.removeAttribute('style');
bottomCaret.removeAttribute('style');
},
getActiveElement: function getActiveElement() {
return document.activeElement;
}
};
//tslint:enable:object-literal-sort-keys
return new foundation_1.MDCTooltipFoundation(adapter);
};
return MDCTooltip;
}(component_1.MDCComponent);
exports.MDCTooltip = MDCTooltip;
/***/ }),
/***/ "./packages/mdc-tooltip/constants.ts":
/*!*******************************************!*\
!*** ./packages/mdc-tooltip/constants.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.XPositionWithCaret = exports.YPositionWithCaret = exports.PositionWithCaret = exports.strings = exports.YPosition = exports.AnchorBoundaryType = exports.XPosition = exports.events = exports.attributes = exports.numbers = exports.CssClasses = void 0;
var CssClasses;
(function (CssClasses) {
CssClasses["RICH"] = "mdc-tooltip--rich";
CssClasses["SHOWN"] = "mdc-tooltip--shown";
CssClasses["SHOWING"] = "mdc-tooltip--showing";
CssClasses["SHOWING_TRANSITION"] = "mdc-tooltip--showing-transition";
CssClasses["HIDE"] = "mdc-tooltip--hide";
CssClasses["HIDE_TRANSITION"] = "mdc-tooltip--hide-transition";
CssClasses["MULTILINE_TOOLTIP"] = "mdc-tooltip--multiline";
CssClasses["SURFACE"] = "mdc-tooltip__surface";
CssClasses["SURFACE_ANIMATION"] = "mdc-tooltip__surface-animation";
CssClasses["TOOLTIP_CARET_TOP"] = "mdc-tooltip__caret-surface-top";
CssClasses["TOOLTIP_CARET_BOTTOM"] = "mdc-tooltip__caret-surface-bottom";
})(CssClasses || (CssClasses = {}));
exports.CssClasses = CssClasses;
var numbers = {
BOUNDED_ANCHOR_GAP: 4,
UNBOUNDED_ANCHOR_GAP: 8,
MIN_VIEWPORT_TOOLTIP_THRESHOLD: 8,
HIDE_DELAY_MS: 600,
SHOW_DELAY_MS: 500,
// LINT.IfChange(tooltip-dimensions)
MIN_HEIGHT: 24,
MAX_WIDTH: 200,
// LINT.ThenChange(_tooltip.scss:tooltip-dimensions)
CARET_INDENTATION: 24,
// LINT.IfChange(tooltip-anim-scale)
ANIMATION_SCALE: 0.8
};
exports.numbers = numbers;
var attributes = {
ARIA_EXPANDED: 'aria-expanded',
ARIA_HASPOPUP: 'aria-haspopup',
PERSISTENT: 'data-mdc-tooltip-persistent',
SCROLLABLE_ANCESTOR: 'tooltip-scrollable-ancestor',
HAS_CARET: 'data-mdc-tooltip-has-caret'
};
exports.attributes = attributes;
var events = {
HIDDEN: 'MDCTooltip:hidden'
};
exports.events = events;
/** Enum for possible tooltip positioning relative to its anchor element. */
var XPosition;
(function (XPosition) {
XPosition[XPosition["DETECTED"] = 0] = "DETECTED";
XPosition[XPosition["START"] = 1] = "START";
// Note: CENTER is not valid for rich tooltips.
XPosition[XPosition["CENTER"] = 2] = "CENTER";
XPosition[XPosition["END"] = 3] = "END";
})(XPosition || (XPosition = {}));
exports.XPosition = XPosition;
var YPosition;
(function (YPosition) {
YPosition[YPosition["DETECTED"] = 0] = "DETECTED";
YPosition[YPosition["ABOVE"] = 1] = "ABOVE";
YPosition[YPosition["BELOW"] = 2] = "BELOW";
})(YPosition || (YPosition = {}));
exports.YPosition = YPosition;
/**
* Enum for possible anchor boundary types. This determines the gap between the
* bottom of the anchor and the tooltip element.
* Bounded anchors have an identifiable boundary (e.g. buttons).
* Unbounded anchors don't have a visually declared boundary (e.g. plain text).
*/
var AnchorBoundaryType;
(function (AnchorBoundaryType) {
AnchorBoundaryType[AnchorBoundaryType["BOUNDED"] = 0] = "BOUNDED";
AnchorBoundaryType[AnchorBoundaryType["UNBOUNDED"] = 1] = "UNBOUNDED";
})(AnchorBoundaryType || (AnchorBoundaryType = {}));
exports.AnchorBoundaryType = AnchorBoundaryType;
var strings = {
LEFT: 'left',
RIGHT: 'right',
CENTER: 'center',
TOP: 'top',
BOTTOM: 'bottom'
};
exports.strings = strings;
/**
* Enum for possible positions of a tooltip with caret (this specifies the
* positioning of the tooltip relative to the anchor -- the position of the
* caret will follow that of the tooltip). This can NOT be combined with the
* above X/YPosition options. Naming for the enums follows: (vertical
* placement)_(horizontal placement).
*/
var PositionWithCaret;
(function (PositionWithCaret) {
PositionWithCaret[PositionWithCaret["DETECTED"] = 0] = "DETECTED";
PositionWithCaret[PositionWithCaret["ABOVE_START"] = 1] = "ABOVE_START";
PositionWithCaret[PositionWithCaret["ABOVE_CENTER"] = 2] = "ABOVE_CENTER";
PositionWithCaret[PositionWithCaret["ABOVE_END"] = 3] = "ABOVE_END";
PositionWithCaret[PositionWithCaret["TOP_SIDE_START"] = 4] = "TOP_SIDE_START";
PositionWithCaret[PositionWithCaret["CENTER_SIDE_START"] = 5] = "CENTER_SIDE_START";
PositionWithCaret[PositionWithCaret["BOTTOM_SIDE_START"] = 6] = "BOTTOM_SIDE_START";
PositionWithCaret[PositionWithCaret["TOP_SIDE_END"] = 7] = "TOP_SIDE_END";
PositionWithCaret[PositionWithCaret["CENTER_SIDE_END"] = 8] = "CENTER_SIDE_END";
PositionWithCaret[PositionWithCaret["BOTTOM_SIDE_END"] = 9] = "BOTTOM_SIDE_END";
PositionWithCaret[PositionWithCaret["BELOW_START"] = 10] = "BELOW_START";
PositionWithCaret[PositionWithCaret["BELOW_CENTER"] = 11] = "BELOW_CENTER";
PositionWithCaret[PositionWithCaret["BELOW_END"] = 12] = "BELOW_END";
})(PositionWithCaret || (PositionWithCaret = {}));
exports.PositionWithCaret = PositionWithCaret;
var YPositionWithCaret;
(function (YPositionWithCaret) {
YPositionWithCaret[YPositionWithCaret["ABOVE"] = 1] = "ABOVE";
YPositionWithCaret[YPositionWithCaret["BELOW"] = 2] = "BELOW";
YPositionWithCaret[YPositionWithCaret["SIDE_TOP"] = 3] = "SIDE_TOP";
YPositionWithCaret[YPositionWithCaret["SIDE_CENTER"] = 4] = "SIDE_CENTER";
YPositionWithCaret[YPositionWithCaret["SIDE_BOTTOM"] = 5] = "SIDE_BOTTOM";
})(YPositionWithCaret || (YPositionWithCaret = {}));
exports.YPositionWithCaret = YPositionWithCaret;
var XPositionWithCaret;
(function (XPositionWithCaret) {
XPositionWithCaret[XPositionWithCaret["START"] = 1] = "START";
XPositionWithCaret[XPositionWithCaret["CENTER"] = 2] = "CENTER";
XPositionWithCaret[XPositionWithCaret["END"] = 3] = "END";
XPositionWithCaret[XPositionWithCaret["SIDE_START"] = 4] = "SIDE_START";
XPositionWithCaret[XPositionWithCaret["SIDE_END"] = 5] = "SIDE_END";
})(XPositionWithCaret || (XPositionWithCaret = {}));
exports.XPositionWithCaret = XPositionWithCaret;
/***/ }),
/***/ "./packages/mdc-tooltip/foundation.ts":
/*!********************************************!*\
!*** ./packages/mdc-tooltip/foundation.ts ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTooltipFoundation = void 0;
var animationframe_1 = __webpack_require__(/*! @material/animation/animationframe */ "./packages/mdc-animation/animationframe.ts");
var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.ts");
var RICH = constants_1.CssClasses.RICH,
SHOWN = constants_1.CssClasses.SHOWN,
SHOWING = constants_1.CssClasses.SHOWING,
SHOWING_TRANSITION = constants_1.CssClasses.SHOWING_TRANSITION,
HIDE = constants_1.CssClasses.HIDE,
HIDE_TRANSITION = constants_1.CssClasses.HIDE_TRANSITION,
MULTILINE_TOOLTIP = constants_1.CssClasses.MULTILINE_TOOLTIP;
var AnimationKeys;
(function (AnimationKeys) {
AnimationKeys["POLL_ANCHOR"] = "poll_anchor";
})(AnimationKeys || (AnimationKeys = {}));
// Accessing `window` without a `typeof` check will throw on Node environments.
var HAS_WINDOW = typeof window !== 'undefined';
var MDCTooltipFoundation = /** @class */function (_super) {
__extends(MDCTooltipFoundation, _super);
function MDCTooltipFoundation(adapter) {
var _this = _super.call(this, __assign(__assign({}, MDCTooltipFoundation.defaultAdapter), adapter)) || this;
_this.tooltipShown = false;
_this.anchorGap = constants_1.numbers.BOUNDED_ANCHOR_GAP;
_this.xTooltipPos = constants_1.XPosition.DETECTED;
_this.yTooltipPos = constants_1.YPosition.DETECTED;
_this.tooltipPositionWithCaret = constants_1.PositionWithCaret.DETECTED;
// Minimum threshold distance needed between the tooltip and the viewport.
_this.minViewportTooltipThreshold = constants_1.numbers.MIN_VIEWPORT_TOOLTIP_THRESHOLD;
_this.hideDelayMs = constants_1.numbers.HIDE_DELAY_MS;
_this.showDelayMs = constants_1.numbers.SHOW_DELAY_MS;
_this.anchorRect = null;
_this.parentRect = null;
_this.frameId = null;
_this.hideTimeout = null;
_this.showTimeout = null;
_this.addAncestorScrollEventListeners = new Array();
_this.removeAncestorScrollEventListeners = new Array();
_this.animFrame = new animationframe_1.AnimationFrame();
_this.anchorBlurHandler = function (evt) {
_this.handleAnchorBlur(evt);
};
_this.documentClickHandler = function (evt) {
_this.handleDocumentClick(evt);
};
_this.documentKeydownHandler = function (evt) {
_this.handleKeydown(evt);
};
_this.tooltipMouseEnterHandler = function () {
_this.handleTooltipMouseEnter();
};
_this.tooltipMouseLeaveHandler = function () {
_this.handleTooltipMouseLeave();
};
_this.richTooltipFocusOutHandler = function (evt) {
_this.handleRichTooltipFocusOut(evt);
};
_this.windowScrollHandler = function () {
_this.handleWindowScrollEvent();
};
_this.windowResizeHandler = function () {
_this.handleWindowChangeEvent();
};
return _this;
}
Object.defineProperty(MDCTooltipFoundation, "defaultAdapter", {
get: function get() {
return {
getAttribute: function getAttribute() {
return null;
},
setAttribute: function setAttribute() {
return undefined;
},
removeAttribute: function removeAttribute() {
return undefined;
},
addClass: function addClass() {
return undefined;
},
hasClass: function hasClass() {
return false;
},
removeClass: function removeClass() {
return undefined;
},
getComputedStyleProperty: function getComputedStyleProperty() {
return '';
},
setStyleProperty: function setStyleProperty() {
return undefined;
},
setSurfaceAnimationStyleProperty: function setSurfaceAnimationStyleProperty() {
return undefined;
},
getViewportWidth: function getViewportWidth() {
return 0;
},
getViewportHeight: function getViewportHeight() {
return 0;
},
getTooltipSize: function getTooltipSize() {
return { width: 0, height: 0 };
},
getAnchorBoundingRect: function getAnchorBoundingRect() {
return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
},
getParentBoundingRect: function getParentBoundingRect() {
return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
},
getAnchorAttribute: function getAnchorAttribute() {
return null;
},
setAnchorAttribute: function setAnchorAttribute() {
return null;
},
isRTL: function isRTL() {
return false;
},
anchorContainsElement: function anchorContainsElement() {
return false;
},
tooltipContainsElement: function tooltipContainsElement() {
return false;
},
focusAnchorElement: function focusAnchorElement() {
return undefined;
},
registerEventHandler: function registerEventHandler() {
return undefined;
},
deregisterEventHandler: function deregisterEventHandler() {
return undefined;
},
registerAnchorEventHandler: function registerAnchorEventHandler() {
return undefined;
},
deregisterAnchorEventHandler: function deregisterAnchorEventHandler() {
return undefined;
},
registerDocumentEventHandler: function registerDocumentEventHandler() {
return undefined;
},
deregisterDocumentEventHandler: function deregisterDocumentEventHandler() {
return undefined;
},
registerWindowEventHandler: function registerWindowEventHandler() {
return undefined;
},
deregisterWindowEventHandler: function deregisterWindowEventHandler() {
return undefined;
},
notifyHidden: function notifyHidden() {
return undefined;
},
getTooltipCaretBoundingRect: function getTooltipCaretBoundingRect() {
return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
},
setTooltipCaretStyle: function setTooltipCaretStyle() {
return undefined;
},
clearTooltipCaretStyles: function clearTooltipCaretStyles() {
return undefined;
},
getActiveElement: function getActiveElement() {
return null;
}
};
},
enumerable: false,
configurable: true
});
MDCTooltipFoundation.prototype.init = function () {
this.richTooltip = this.adapter.hasClass(RICH);
this.persistentTooltip = this.adapter.getAttribute(constants_1.attributes.PERSISTENT) === 'true';
this.interactiveTooltip = !!this.adapter.getAnchorAttribute(constants_1.attributes.ARIA_EXPANDED) && this.adapter.getAnchorAttribute(constants_1.attributes.ARIA_HASPOPUP) === 'dialog';
this.hasCaret = this.richTooltip && this.adapter.getAttribute(constants_1.attributes.HAS_CARET) === 'true';
};
MDCTooltipFoundation.prototype.isShown = function () {
return this.tooltipShown;
};
MDCTooltipFoundation.prototype.isRich = function () {
return this.richTooltip;
};
MDCTooltipFoundation.prototype.isPersistent = function () {
return this.persistentTooltip;
};
MDCTooltipFoundation.prototype.handleAnchorMouseEnter = function () {
var _this = this;
if (this.tooltipShown) {
// Covers the instance where a user hovers over the anchor to reveal the
// tooltip, and then quickly navigates away and then back to the anchor.
// The tooltip should stay visible without animating out and then back in
// again.
this.show();
} else {
// clearHideTimeout here since handleAnchorMouseLeave sets a hideTimeout
// and that can execute before the showTimeout executes, resulting in hide
// being called and the showTimeout set below to be cleared.
this.clearHideTimeout();
this.showTimeout = setTimeout(function () {
_this.show();
}, this.showDelayMs);
}
};
MDCTooltipFoundation.prototype.handleAnchorTouchstart = function () {
var _this = this;
this.showTimeout = setTimeout(function () {
_this.show();
}, this.showDelayMs);
// Prevent a context menu from appearing if user is long-pressing on a
// tooltip anchor.
this.adapter.registerWindowEventHandler('contextmenu', this.preventContextMenuOnLongTouch);
};
MDCTooltipFoundation.prototype.preventContextMenuOnLongTouch = function (evt) {
evt.preventDefault();
};
MDCTooltipFoundation.prototype.handleAnchorTouchend = function () {
this.clearShowTimeout();
// Only remove the 'contextmenu' listener if the tooltip is not shown. When
// the tooltip *is* shown, listener is removed in the close method.
if (!this.isShown()) {
this.adapter.deregisterWindowEventHandler('contextmenu', this.preventContextMenuOnLongTouch);
}
};
MDCTooltipFoundation.prototype.handleAnchorFocus = function (evt) {
var _this = this;
// TODO(b/157075286): Need to add some way to distinguish keyboard
// navigation focus events from other focus events, and only show the
// tooltip on the former of these events.
var relatedTarget = evt.relatedTarget;
var tooltipContainsRelatedTarget = relatedTarget instanceof HTMLElement && this.adapter.tooltipContainsElement(relatedTarget);
// Do not show tooltip if the previous focus was on a tooltip element. This
// occurs when a rich tooltip is closed and focus is restored to the anchor
// or when user tab-navigates back into the anchor from the rich tooltip.
if (tooltipContainsRelatedTarget) {
return;
}
this.showTimeout = setTimeout(function () {
_this.show();
}, this.showDelayMs);
};
MDCTooltipFoundation.prototype.handleAnchorMouseLeave = function () {
var _this = this;
this.clearShowTimeout();
this.hideTimeout = setTimeout(function () {
_this.hide();
}, this.hideDelayMs);
};
MDCTooltipFoundation.prototype.handleAnchorClick = function () {
if (this.tooltipShown) {
this.hide();
} else {
this.show();
}
};
MDCTooltipFoundation.prototype.handleDocumentClick = function (evt) {
var anchorOrTooltipContainsTargetElement = evt.target instanceof HTMLElement && (this.adapter.anchorContainsElement(evt.target) || this.adapter.tooltipContainsElement(evt.target));
// For persistent rich tooltips, we will not hide if:
// - The click target is within the anchor element. Otherwise, both
// the anchor element's click handler and this handler will handle the
// click (due to event propagation), resulting in a shown tooltip
// being immediately hidden if the tooltip was initially hidden.
// - The click target is within the tooltip element, since clicks
// on the tooltip do not close the tooltip.
if (this.richTooltip && this.persistentTooltip && anchorOrTooltipContainsTargetElement) {
return;
}
// Hide the tooltip immediately on click.
this.hide();
};
MDCTooltipFoundation.prototype.handleKeydown = function (evt) {
// Hide the tooltip immediately on ESC key.
var key = keyboard_1.normalizeKey(evt);
if (key === keyboard_1.KEY.ESCAPE) {
var activeElement = this.adapter.getActiveElement();
var tooltipContainsActiveElement = activeElement instanceof HTMLElement && this.adapter.tooltipContainsElement(activeElement);
if (tooltipContainsActiveElement) {
this.adapter.focusAnchorElement();
}
this.hide();
}
};
MDCTooltipFoundation.prototype.handleAnchorBlur = function (evt) {
if (this.richTooltip) {
var tooltipContainsRelatedTargetElement = evt.relatedTarget instanceof HTMLElement && this.adapter.tooltipContainsElement(evt.relatedTarget);
// If focus changed to the tooltip element, don't hide the tooltip.
if (tooltipContainsRelatedTargetElement) {
return;
}
if (evt.relatedTarget === null && this.interactiveTooltip) {
// If evt.relatedTarget is null, it is because focus is moving to an
// element that is not focusable. This should only occur in instances
// of a screen reader in browse mode/linear navigation mode. If the
// tooltip is interactive (and so the entire content is not read by
// the screen reader upon the tooltip being opened), we want to allow
// users to read the content of the tooltip (and not just the focusable
// elements).
return;
}
}
// Hide tooltip immediately on focus change.
this.hide();
};
MDCTooltipFoundation.prototype.handleTooltipMouseEnter = function () {
this.show();
};
MDCTooltipFoundation.prototype.handleTooltipMouseLeave = function () {
var _this = this;
this.clearShowTimeout();
this.hideTimeout = setTimeout(function () {
_this.hide();
}, this.hideDelayMs);
};
MDCTooltipFoundation.prototype.handleRichTooltipFocusOut = function (evt) {
var anchorOrTooltipContainsRelatedTargetElement = evt.relatedTarget instanceof HTMLElement && (this.adapter.anchorContainsElement(evt.relatedTarget) || this.adapter.tooltipContainsElement(evt.relatedTarget));
// If the focus is still within the anchor or the tooltip, do not hide the
// tooltip.
if (anchorOrTooltipContainsRelatedTargetElement) {
return;
}
if (evt.relatedTarget === null && this.interactiveTooltip) {
// If evt.relatedTarget is null, it is because focus is moving to an
// element that is not focusable. This should only occur in instances
// of a screen reader in browse mode/linear navigation mode. If the
// tooltip is interactive (and so the entire content is not read by
// the screen reader upon the tooltip being opened), we want to allow
// users to read the content of the tooltip (and not just the focusable
// elements).
return;
}
this.hide();
};
MDCTooltipFoundation.prototype.handleWindowScrollEvent = function () {
if (this.persistentTooltip) {
// Persistent tooltips remain visible on user scroll, call appropriate
// handler to ensure the tooltip remains pinned to the anchor on page
// scroll.
this.handleWindowChangeEvent();
return;
}
this.hide();
};
/**
* On window resize or scroll, check the anchor position and size and
* repostion tooltip if necessary.
*/
MDCTooltipFoundation.prototype.handleWindowChangeEvent = function () {
var _this = this;
// Since scroll and resize events can fire at a high rate, we throttle
// the potential re-positioning of tooltip component using
// requestAnimationFrame.
this.animFrame.request(AnimationKeys.POLL_ANCHOR, function () {
_this.repositionTooltipOnAnchorMove();
});
};
MDCTooltipFoundation.prototype.show = function () {
var e_1, _a;
var _this = this;
this.clearHideTimeout();
this.clearShowTimeout();
if (this.tooltipShown) {
return;
}
this.tooltipShown = true;
this.adapter.removeAttribute('aria-hidden');
if (this.richTooltip) {
if (this.interactiveTooltip) {
this.adapter.setAnchorAttribute('aria-expanded', 'true');
}
this.adapter.registerEventHandler('focusout', this.richTooltipFocusOutHandler);
}
if (!this.persistentTooltip) {
this.adapter.registerEventHandler('mouseenter', this.tooltipMouseEnterHandler);
this.adapter.registerEventHandler('mouseleave', this.tooltipMouseLeaveHandler);
}
this.adapter.removeClass(HIDE);
this.adapter.addClass(SHOWING);
if (this.isTooltipMultiline() && !this.richTooltip) {
this.adapter.addClass(MULTILINE_TOOLTIP);
}
this.anchorRect = this.adapter.getAnchorBoundingRect();
this.parentRect = this.adapter.getParentBoundingRect();
this.richTooltip ? this.positionRichTooltip() : this.positionPlainTooltip();
this.adapter.registerAnchorEventHandler('blur', this.anchorBlurHandler);
this.adapter.registerDocumentEventHandler('click', this.documentClickHandler);
this.adapter.registerDocumentEventHandler('keydown', this.documentKeydownHandler);
this.adapter.registerWindowEventHandler('scroll', this.windowScrollHandler);
this.adapter.registerWindowEventHandler('resize', this.windowResizeHandler);
try {
// Register any additional scroll handlers
for (var _b = __values(this.addAncestorScrollEventListeners), _c = _b.next(); !_c.done; _c = _b.next()) {
var fn = _c.value;
fn();
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_1) throw e_1.error;
}
}
this.frameId = requestAnimationFrame(function () {
_this.clearAllAnimationClasses();
_this.adapter.addClass(SHOWN);
_this.adapter.addClass(SHOWING_TRANSITION);
});
};
MDCTooltipFoundation.prototype.hide = function () {
var e_2, _a;
this.clearHideTimeout();
this.clearShowTimeout();
if (!this.tooltipShown) {
return;
}
if (this.frameId) {
cancelAnimationFrame(this.frameId);
}
this.tooltipShown = false;
this.adapter.setAttribute('aria-hidden', 'true');
this.adapter.deregisterEventHandler('focusout', this.richTooltipFocusOutHandler);
if (this.richTooltip) {
if (this.interactiveTooltip) {
this.adapter.setAnchorAttribute('aria-expanded', 'false');
}
}
if (!this.persistentTooltip) {
this.adapter.deregisterEventHandler('mouseenter', this.tooltipMouseEnterHandler);
this.adapter.deregisterEventHandler('mouseleave', this.tooltipMouseLeaveHandler);
}
this.clearAllAnimationClasses();
this.adapter.addClass(HIDE);
this.adapter.addClass(HIDE_TRANSITION);
this.adapter.removeClass(SHOWN);
this.adapter.deregisterAnchorEventHandler('blur', this.anchorBlurHandler);
this.adapter.deregisterDocumentEventHandler('click', this.documentClickHandler);
this.adapter.deregisterDocumentEventHandler('keydown', this.documentKeydownHandler);
this.adapter.deregisterWindowEventHandler('scroll', this.windowScrollHandler);
this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
this.adapter.deregisterWindowEventHandler('contextmenu', this.preventContextMenuOnLongTouch);
try {
// Deregister any additional scroll handlers
for (var _b = __values(this.removeAncestorScrollEventListeners), _c = _b.next(); !_c.done; _c = _b.next()) {
var fn = _c.value;
fn();
}
} catch (e_2_1) {
e_2 = { error: e_2_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_2) throw e_2.error;
}
}
};
MDCTooltipFoundation.prototype.handleTransitionEnd = function () {
var isHidingTooltip = this.adapter.hasClass(HIDE);
this.adapter.removeClass(SHOWING);
this.adapter.removeClass(SHOWING_TRANSITION);
this.adapter.removeClass(HIDE);
this.adapter.removeClass(HIDE_TRANSITION);
// If handleTransitionEnd is called after hiding the tooltip, the tooltip
// will have the HIDE class (before calling the adapter removeClass method).
// If tooltip is now hidden, send a notification that the animation has
// completed and the tooltip is no longer visible.
// We don't send a notification of the animation completing if a showTimeout
// value is set -- this happens when a user triggers a tooltip to be shown
// while that tooltip is fading. Once this hide transition is completed,
// that same tooltip will be re-shown.
if (isHidingTooltip && this.showTimeout === null) {
this.adapter.notifyHidden();
}
};
MDCTooltipFoundation.prototype.clearAllAnimationClasses = function () {
this.adapter.removeClass(SHOWING_TRANSITION);
this.adapter.removeClass(HIDE_TRANSITION);
};
MDCTooltipFoundation.prototype.setTooltipPosition = function (position) {
var xPos = position.xPos,
yPos = position.yPos,
withCaretPos = position.withCaretPos;
if (this.hasCaret && withCaretPos) {
this.tooltipPositionWithCaret = withCaretPos;
return;
}
if (xPos) {
this.xTooltipPos = xPos;
}
if (yPos) {
this.yTooltipPos = yPos;
}
};
MDCTooltipFoundation.prototype.setAnchorBoundaryType = function (type) {
if (type === constants_1.AnchorBoundaryType.UNBOUNDED) {
this.anchorGap = constants_1.numbers.UNBOUNDED_ANCHOR_GAP;
} else {
this.anchorGap = constants_1.numbers.BOUNDED_ANCHOR_GAP;
}
};
MDCTooltipFoundation.prototype.setShowDelay = function (delayMs) {
this.showDelayMs = delayMs;
};
MDCTooltipFoundation.prototype.setHideDelay = function (delayMs) {
this.hideDelayMs = delayMs;
};
MDCTooltipFoundation.prototype.isTooltipMultiline = function () {
var tooltipSize = this.adapter.getTooltipSize();
return tooltipSize.height > constants_1.numbers.MIN_HEIGHT && tooltipSize.width >= constants_1.numbers.MAX_WIDTH;
};
MDCTooltipFoundation.prototype.positionPlainTooltip = function () {
// A plain tooltip has `fixed` positioning and is placed as an immediate
// child of the document body. Its positioning is calculated with respect to
// the viewport.
var _a = this.calculateTooltipStyles(this.anchorRect),
top = _a.top,
yTransformOrigin = _a.yTransformOrigin,
left = _a.left,
xTransformOrigin = _a.xTransformOrigin;
var transformProperty = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
this.adapter.setSurfaceAnimationStyleProperty(transformProperty + "-origin", xTransformOrigin + " " + yTransformOrigin);
this.adapter.setStyleProperty('top', top + "px");
this.adapter.setStyleProperty('left', left + "px");
};
MDCTooltipFoundation.prototype.positionRichTooltip = function () {
// TODO(b/177686782): Remove width setting when max-content is used to style
// the rich tooltip.
var _a, _b, _c, _d;
// getComputedStyleProperty is used instead of getTooltipSize since
// getTooltipSize returns the offSetWidth, which includes the border and
// padding. What we need is the width of the tooltip without border and
// padding.
var width = this.adapter.getComputedStyleProperty('width');
// When rich tooltips are positioned within their parent containers, the
// tooltip width might be shrunk if it collides with the edge of the parent
// container. We set the width of the tooltip to prevent this.
this.adapter.setStyleProperty('width', width);
var _e = this.hasCaret ? this.calculateTooltipWithCaretStyles(this.anchorRect) : this.calculateTooltipStyles(this.anchorRect),
top = _e.top,
yTransformOrigin = _e.yTransformOrigin,
left = _e.left,
xTransformOrigin = _e.xTransformOrigin;
var transformProperty = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
this.adapter.setSurfaceAnimationStyleProperty(transformProperty + "-origin", xTransformOrigin + " " + yTransformOrigin);
// A rich tooltip has `absolute` positioning and is placed as a sibling to
// the anchor element. Its positioning is calculated with respect to the
// parent element, and so the values need to be adjusted against the parent
// element.
var leftAdjustment = left - ((_b = (_a = this.parentRect) === null || _a === void 0 ? void 0 : _a.left) !== null && _b !== void 0 ? _b : 0);
var topAdjustment = top - ((_d = (_c = this.parentRect) === null || _c === void 0 ? void 0 : _c.top) !== null && _d !== void 0 ? _d : 0);
this.adapter.setStyleProperty('top', topAdjustment + "px");
this.adapter.setStyleProperty('left', leftAdjustment + "px");
};
/**
* Calculates the position of the tooltip. A tooltip will be placed beneath
* the anchor element and aligned either with the 'start'/'end' edge of the
* anchor element or the 'center'.
*
* Tooltip alignment is selected such that the tooltip maintains a threshold
* distance away from the viewport (defaulting to 'center' alignment). If the
* placement of the anchor prevents this threshold distance from being
* maintained, the tooltip is positioned so that it does not collide with the
* viewport.
*
* Users can specify an alignment, however, if this alignment results in the
* tooltip colliding with the viewport, this specification is overwritten.
*/
MDCTooltipFoundation.prototype.calculateTooltipStyles = function (anchorRect) {
if (!anchorRect) {
return { top: 0, left: 0 };
}
var tooltipSize = this.adapter.getTooltipSize();
var top = this.calculateYTooltipDistance(anchorRect, tooltipSize.height);
var left = this.calculateXTooltipDistance(anchorRect, tooltipSize.width);
return {
top: top.distance,
yTransformOrigin: top.yTransformOrigin,
left: left.distance,
xTransformOrigin: left.xTransformOrigin
};
};
/**
* Calculates the `left` distance for the tooltip.
* Returns the distance value and a string indicating the x-axis transform-
* origin that should be used when animating the tooltip.
*/
MDCTooltipFoundation.prototype.calculateXTooltipDistance = function (anchorRect, tooltipWidth) {
var isLTR = !this.adapter.isRTL();
var startPos, endPos, centerPos;
var startTransformOrigin, endTransformOrigin;
if (this.richTooltip) {
startPos = isLTR ? anchorRect.left - tooltipWidth : anchorRect.right;
endPos = isLTR ? anchorRect.right : anchorRect.left - tooltipWidth;
startTransformOrigin = isLTR ? constants_1.strings.RIGHT : constants_1.strings.LEFT;
endTransformOrigin = isLTR ? constants_1.strings.LEFT : constants_1.strings.RIGHT;
} else {
startPos = isLTR ? anchorRect.left : anchorRect.right - tooltipWidth;
endPos = isLTR ? anchorRect.right - tooltipWidth : anchorRect.left;
centerPos = anchorRect.left + (anchorRect.width - tooltipWidth) / 2;
startTransformOrigin = isLTR ? constants_1.strings.LEFT : constants_1.strings.RIGHT;
endTransformOrigin = isLTR ? constants_1.strings.RIGHT : constants_1.strings.LEFT;
}
var positionOptions = this.richTooltip ? this.determineValidPositionOptions(startPos, endPos) :
// For plain tooltips, centerPos is defined
this.determineValidPositionOptions(centerPos, startPos, endPos);
if (this.xTooltipPos === constants_1.XPosition.START && positionOptions.has(startPos)) {
return { distance: startPos, xTransformOrigin: startTransformOrigin };
}
if (this.xTooltipPos === constants_1.XPosition.END && positionOptions.has(endPos)) {
return { distance: endPos, xTransformOrigin: endTransformOrigin };
}
if (this.xTooltipPos === constants_1.XPosition.CENTER && positionOptions.has(centerPos)) {
// This code path is only executed if calculating the distance for plain
// tooltips. In this instance, centerPos will always be defined, so we can
// safely assert that the returned value is non-null/undefined.
return { distance: centerPos, xTransformOrigin: constants_1.strings.CENTER };
}
// If no user position is supplied, rich tooltips default to end pos, then
// start position. Plain tooltips default to center, start, then end.
var possiblePositions = this.richTooltip ? [{ distance: endPos, xTransformOrigin: endTransformOrigin }, { distance: startPos, xTransformOrigin: startTransformOrigin }] : [{ distance: centerPos, xTransformOrigin: constants_1.strings.CENTER }, { distance: startPos, xTransformOrigin: startTransformOrigin }, { distance: endPos, xTransformOrigin: endTransformOrigin }];
var validPosition = possiblePositions.find(function (_a) {
var distance = _a.distance;
return positionOptions.has(distance);
});
if (validPosition) {
return validPosition;
}
// Indicates that all potential positions would result in the tooltip
// colliding with the viewport. This would only occur when the anchor
// element itself collides with the viewport, or the viewport is very
// narrow. In this case, we allow the tooltip to be mis-aligned from the
// anchor element.
if (anchorRect.left < 0) {
return {
distance: this.minViewportTooltipThreshold,
xTransformOrigin: constants_1.strings.LEFT
};
} else {
var viewportWidth = this.adapter.getViewportWidth();
var distance = viewportWidth - (tooltipWidth + this.minViewportTooltipThreshold);
return { distance: distance, xTransformOrigin: constants_1.strings.RIGHT };
}
};
/**
* Given the values for the horizontal alignments of the tooltip, calculates
* which of these options would result in the tooltip maintaining the required
* threshold distance vs which would result in the tooltip staying within the
* viewport.
*
* A Set of values is returned holding the distances that would honor the
* above requirements. Following the logic for determining the tooltip
* position, if all alignments violate the threshold, then the returned Set
* contains values that keep the tooltip within the viewport.
*/
MDCTooltipFoundation.prototype.determineValidPositionOptions = function () {
var e_3, _a;
var positions = [];
for (var _i = 0; _i < arguments.length; _i++) {
positions[_i] = arguments[_i];
}
var posWithinThreshold = new Set();
var posWithinViewport = new Set();
try {
for (var positions_1 = __values(positions), positions_1_1 = positions_1.next(); !positions_1_1.done; positions_1_1 = positions_1.next()) {
var position = positions_1_1.value;
if (this.positionHonorsViewportThreshold(position)) {
posWithinThreshold.add(position);
} else if (this.positionDoesntCollideWithViewport(position)) {
posWithinViewport.add(position);
}
}
} catch (e_3_1) {
e_3 = { error: e_3_1 };
} finally {
try {
if (positions_1_1 && !positions_1_1.done && (_a = positions_1.return)) _a.call(positions_1);
} finally {
if (e_3) throw e_3.error;
}
}
return posWithinThreshold.size ? posWithinThreshold : posWithinViewport;
};
MDCTooltipFoundation.prototype.positionHonorsViewportThreshold = function (leftPos) {
var viewportWidth = this.adapter.getViewportWidth();
var tooltipWidth = this.adapter.getTooltipSize().width;
return leftPos + tooltipWidth <= viewportWidth - this.minViewportTooltipThreshold && leftPos >= this.minViewportTooltipThreshold;
};
MDCTooltipFoundation.prototype.positionDoesntCollideWithViewport = function (leftPos) {
var viewportWidth = this.adapter.getViewportWidth();
var tooltipWidth = this.adapter.getTooltipSize().width;
return leftPos + tooltipWidth <= viewportWidth && leftPos >= 0;
};
/**
* Calculates the `top` distance for the tooltip.
* Returns the distance value and a string indicating the y-axis transform-
* origin that should be used when animating the tooltip.
*/
MDCTooltipFoundation.prototype.calculateYTooltipDistance = function (anchorRect, tooltipHeight) {
var belowYPos = anchorRect.bottom + this.anchorGap;
var aboveYPos = anchorRect.top - (this.anchorGap + tooltipHeight);
var yPositionOptions = this.determineValidYPositionOptions(aboveYPos, belowYPos);
if (this.yTooltipPos === constants_1.YPosition.ABOVE && yPositionOptions.has(aboveYPos)) {
return { distance: aboveYPos, yTransformOrigin: constants_1.strings.BOTTOM };
} else if (this.yTooltipPos === constants_1.YPosition.BELOW && yPositionOptions.has(belowYPos)) {
return { distance: belowYPos, yTransformOrigin: constants_1.strings.TOP };
}
if (yPositionOptions.has(belowYPos)) {
return { distance: belowYPos, yTransformOrigin: constants_1.strings.TOP };
}
if (yPositionOptions.has(aboveYPos)) {
return { distance: aboveYPos, yTransformOrigin: constants_1.strings.BOTTOM };
}
// Indicates that all potential positions would result in the tooltip
// colliding with the viewport. This would only occur when the viewport is
// very short.
return { distance: belowYPos, yTransformOrigin: constants_1.strings.TOP };
};
/**
* Given the values for above/below alignment of the tooltip, calculates
* which of these options would result in the tooltip maintaining the required
* threshold distance vs which would result in the tooltip staying within the
* viewport.
*
* A Set of values is returned holding the distances that would honor the
* above requirements. Following the logic for determining the tooltip
* position, if all possible alignments violate the threshold, then the
* returned Set contains values that keep the tooltip within the viewport.
*/
MDCTooltipFoundation.prototype.determineValidYPositionOptions = function (aboveAnchorPos, belowAnchorPos) {
var posWithinThreshold = new Set();
var posWithinViewport = new Set();
if (this.yPositionHonorsViewportThreshold(aboveAnchorPos)) {
posWithinThreshold.add(aboveAnchorPos);
} else if (this.yPositionDoesntCollideWithViewport(aboveAnchorPos)) {
posWithinViewport.add(aboveAnchorPos);
}
if (this.yPositionHonorsViewportThreshold(belowAnchorPos)) {
posWithinThreshold.add(belowAnchorPos);
} else if (this.yPositionDoesntCollideWithViewport(belowAnchorPos)) {
posWithinViewport.add(belowAnchorPos);
}
return posWithinThreshold.size ? posWithinThreshold : posWithinViewport;
};
MDCTooltipFoundation.prototype.yPositionHonorsViewportThreshold = function (yPos) {
var viewportHeight = this.adapter.getViewportHeight();
var tooltipHeight = this.adapter.getTooltipSize().height;
return yPos + tooltipHeight + this.minViewportTooltipThreshold <= viewportHeight && yPos >= this.minViewportTooltipThreshold;
};
MDCTooltipFoundation.prototype.yPositionDoesntCollideWithViewport = function (yPos) {
var viewportHeight = this.adapter.getViewportHeight();
var tooltipHeight = this.adapter.getTooltipSize().height;
return yPos + tooltipHeight <= viewportHeight && yPos >= 0;
};
MDCTooltipFoundation.prototype.calculateTooltipWithCaretStyles = function (anchorRect) {
// Prior to grabbing the caret bounding rect, we clear all styles set on the
// caret. This will ensure the width/height is consistent (since we rotate
// the caret 90deg in some positions which would result in the height and
// width bounding rect measurements flipping).
this.adapter.clearTooltipCaretStyles();
var caretSize = this.adapter.getTooltipCaretBoundingRect();
if (!anchorRect || !caretSize) {
return { position: constants_1.PositionWithCaret.DETECTED, top: 0, left: 0 };
}
// The caret for the rich tooltip is created by rotating/skewing/scaling
// square div into a diamond shape and then hiding half of it so it looks
// like a triangle. We use the boundingClientRect to calculate the
// width/height of the element after the transforms (to the caret) have been
// applied. Since the full tooltip is scaled by 0.8 for the entrance
// animation, we divide by this value to retrieve the actual caret
// dimensions.
var caretWidth = caretSize.width / constants_1.numbers.ANIMATION_SCALE;
// Since we hide half of caret, we divide the returned DOMRect height
// by 2.
var caretHeight = caretSize.height / constants_1.numbers.ANIMATION_SCALE / 2;
var tooltipSize = this.adapter.getTooltipSize();
var yOptions = this.calculateYWithCaretDistanceOptions(anchorRect, tooltipSize.height, { caretWidth: caretWidth, caretHeight: caretHeight });
var xOptions = this.calculateXWithCaretDistanceOptions(anchorRect, tooltipSize.width, { caretWidth: caretWidth, caretHeight: caretHeight });
var positionOptions = this.validateTooltipWithCaretDistances(yOptions, xOptions);
if (positionOptions.size < 1) {
positionOptions = this.generateBackupPositionOption(anchorRect, tooltipSize, { caretWidth: caretWidth, caretHeight: caretHeight });
}
var _a = this.determineTooltipWithCaretDistance(positionOptions),
position = _a.position,
xDistance = _a.xDistance,
yDistance = _a.yDistance;
// After determining the position of the tooltip relative to the anchor,
// place the caret in the corresponding position and retrieve the necessary
// x/y transform origins needed to properly animate the tooltip entrance.
var _b = this.setCaretPositionStyles(position, { caretWidth: caretWidth, caretHeight: caretHeight }),
yTransformOrigin = _b.yTransformOrigin,
xTransformOrigin = _b.xTransformOrigin;
return {
yTransformOrigin: yTransformOrigin,
xTransformOrigin: xTransformOrigin,
top: yDistance,
left: xDistance
};
};
MDCTooltipFoundation.prototype.calculateXWithCaretDistanceOptions = function (anchorRect, tooltipWidth, caretSize) {
var caretWidth = caretSize.caretWidth,
caretHeight = caretSize.caretHeight;
var isLTR = !this.adapter.isRTL();
var anchorMidpoint = anchorRect.left + anchorRect.width / 2;
var sideLeftAligned = anchorRect.left - (tooltipWidth + this.anchorGap + caretHeight);
var sideRightAligned = anchorRect.right + this.anchorGap + caretHeight;
var sideStartPos = isLTR ? sideLeftAligned : sideRightAligned;
var sideEndPos = isLTR ? sideRightAligned : sideLeftAligned;
var verticalLeftAligned = anchorMidpoint - (constants_1.numbers.CARET_INDENTATION + caretWidth / 2);
var verticalRightAligned = anchorMidpoint - (tooltipWidth - constants_1.numbers.CARET_INDENTATION - caretWidth / 2);
var verticalStartPos = isLTR ? verticalLeftAligned : verticalRightAligned;
var verticalEndPos = isLTR ? verticalRightAligned : verticalLeftAligned;
var verticalCenterPos = anchorMidpoint - tooltipWidth / 2;
var possiblePositionsMap = new Map([[constants_1.XPositionWithCaret.START, verticalStartPos], [constants_1.XPositionWithCaret.CENTER, verticalCenterPos], [constants_1.XPositionWithCaret.END, verticalEndPos], [constants_1.XPositionWithCaret.SIDE_END, sideEndPos], [constants_1.XPositionWithCaret.SIDE_START, sideStartPos]]);
return possiblePositionsMap;
};
MDCTooltipFoundation.prototype.calculateYWithCaretDistanceOptions = function (anchorRect, tooltipHeight, caretSize) {
var caretWidth = caretSize.caretWidth,
caretHeight = caretSize.caretHeight;
var anchorMidpoint = anchorRect.top + anchorRect.height / 2;
var belowYPos = anchorRect.bottom + this.anchorGap + caretHeight;
var aboveYPos = anchorRect.top - (this.anchorGap + tooltipHeight + caretHeight);
var sideTopYPos = anchorMidpoint - (constants_1.numbers.CARET_INDENTATION + caretWidth / 2);
var sideCenterYPos = anchorMidpoint - tooltipHeight / 2;
var sideBottomYPos = anchorMidpoint - (tooltipHeight - constants_1.numbers.CARET_INDENTATION - caretWidth / 2);
var possiblePositionsMap = new Map([[constants_1.YPositionWithCaret.ABOVE, aboveYPos], [constants_1.YPositionWithCaret.BELOW, belowYPos], [constants_1.YPositionWithCaret.SIDE_TOP, sideTopYPos], [constants_1.YPositionWithCaret.SIDE_CENTER, sideCenterYPos], [constants_1.YPositionWithCaret.SIDE_BOTTOM, sideBottomYPos]]);
return possiblePositionsMap;
};
MDCTooltipFoundation.prototype.repositionTooltipOnAnchorMove = function () {
var newAnchorRect = this.adapter.getAnchorBoundingRect();
if (!newAnchorRect || !this.anchorRect) return;
if (newAnchorRect.top !== this.anchorRect.top || newAnchorRect.left !== this.anchorRect.left || newAnchorRect.height !== this.anchorRect.height || newAnchorRect.width !== this.anchorRect.width) {
this.anchorRect = newAnchorRect;
this.parentRect = this.adapter.getParentBoundingRect();
this.richTooltip ? this.positionRichTooltip() : this.positionPlainTooltip();
}
};
/**
* Given a list of x/y position options for a rich tooltip with caret, checks
* if valid x/y combinations of these position options are either within the
* viewport threshold, or simply within the viewport. Returns a map with the
* valid x/y position combinations that all either honor the viewport
* threshold or are simply inside within the viewport.
*/
MDCTooltipFoundation.prototype.validateTooltipWithCaretDistances = function (yOptions, xOptions) {
var e_4, _a, e_5, _b, e_6, _c;
var posWithinThreshold = new Map();
var posWithinViewport = new Map();
// If a tooltip has a caret, not all combinations of YPositionWithCarets and
// XPositionWithCarets are possible. Because of this we only check the
// validity of a given XPositionWithCaret if a potential corresponding
// YPositionWithCaret is valid.
var validMappings = new Map([[constants_1.YPositionWithCaret.ABOVE, [constants_1.XPositionWithCaret.START, constants_1.XPositionWithCaret.CENTER, constants_1.XPositionWithCaret.END]], [constants_1.YPositionWithCaret.BELOW, [constants_1.XPositionWithCaret.START, constants_1.XPositionWithCaret.CENTER, constants_1.XPositionWithCaret.END]], [constants_1.YPositionWithCaret.SIDE_TOP, [constants_1.XPositionWithCaret.SIDE_START, constants_1.XPositionWithCaret.SIDE_END]], [constants_1.YPositionWithCaret.SIDE_CENTER, [constants_1.XPositionWithCaret.SIDE_START, constants_1.XPositionWithCaret.SIDE_END]], [constants_1.YPositionWithCaret.SIDE_BOTTOM, [constants_1.XPositionWithCaret.SIDE_START, constants_1.XPositionWithCaret.SIDE_END]]]);
try {
// TODO(b/227383292): Handle instances where one direction can fit in
// in the viewport (whether honoring the threshold or not), and the
// other direction does not.
for (var _d = __values(validMappings.keys()), _e = _d.next(); !_e.done; _e = _d.next()) {
var y = _e.value;
var yDistance = yOptions.get(y);
if (this.yPositionHonorsViewportThreshold(yDistance)) {
try {
for (var _f = (e_5 = void 0, __values(validMappings.get(y))), _g = _f.next(); !_g.done; _g = _f.next()) {
var x = _g.value;
var xDistance = xOptions.get(x);
if (this.positionHonorsViewportThreshold(xDistance)) {
var caretPositionName = this.caretPositionOptionsMapping(x, y);
posWithinThreshold.set(caretPositionName, { xDistance: xDistance, yDistance: yDistance });
}
}
} catch (e_5_1) {
e_5 = { error: e_5_1 };
} finally {
try {
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
} finally {
if (e_5) throw e_5.error;
}
}
}
if (this.yPositionDoesntCollideWithViewport(yDistance)) {
try {
for (var _h = (e_6 = void 0, __values(validMappings.get(y))), _j = _h.next(); !_j.done; _j = _h.next()) {
var x = _j.value;
var xDistance = xOptions.get(x);
if (this.positionDoesntCollideWithViewport(xDistance)) {
var caretPositionName = this.caretPositionOptionsMapping(x, y);
posWithinViewport.set(caretPositionName, { xDistance: xDistance, yDistance: yDistance });
}
}
} catch (e_6_1) {
e_6 = { error: e_6_1 };
} finally {
try {
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
} finally {
if (e_6) throw e_6.error;
}
}
}
}
} catch (e_4_1) {
e_4 = { error: e_4_1 };
} finally {
try {
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
} finally {
if (e_4) throw e_4.error;
}
}
return posWithinThreshold.size ? posWithinThreshold : posWithinViewport;
};
/**
* Method for generating a horizontal and vertical position for the tooltip if
* all other calculated values are considered invalid. This would only happen
* in situations of very small viewports/large tooltips.
*/
MDCTooltipFoundation.prototype.generateBackupPositionOption = function (anchorRect, tooltipSize, caretSize) {
var isLTR = !this.adapter.isRTL();
var xDistance;
var xPos;
if (anchorRect.left < 0) {
xDistance = this.minViewportTooltipThreshold + caretSize.caretHeight;
xPos = isLTR ? constants_1.XPositionWithCaret.END : constants_1.XPositionWithCaret.START;
} else {
var viewportWidth = this.adapter.getViewportWidth();
xDistance = viewportWidth - (tooltipSize.width + this.minViewportTooltipThreshold + caretSize.caretHeight);
xPos = isLTR ? constants_1.XPositionWithCaret.START : constants_1.XPositionWithCaret.END;
}
var yDistance;
var yPos;
if (anchorRect.top < 0) {
yDistance = this.minViewportTooltipThreshold + caretSize.caretHeight;
yPos = constants_1.YPositionWithCaret.BELOW;
} else {
var viewportHeight = this.adapter.getViewportHeight();
yDistance = viewportHeight - (tooltipSize.height + this.minViewportTooltipThreshold + caretSize.caretHeight);
yPos = constants_1.YPositionWithCaret.ABOVE;
}
var caretPositionName = this.caretPositionOptionsMapping(xPos, yPos);
return new Map([[caretPositionName, { xDistance: xDistance, yDistance: yDistance }]]);
};
/**
* Given a list of valid position options for a rich tooltip with caret,
* returns the option that should be used.
*/
MDCTooltipFoundation.prototype.determineTooltipWithCaretDistance = function (options) {
if (options.has(this.tooltipPositionWithCaret)) {
var tooltipPos = options.get(this.tooltipPositionWithCaret);
return {
position: this.tooltipPositionWithCaret,
xDistance: tooltipPos.xDistance,
yDistance: tooltipPos.yDistance
};
}
var orderPref = [constants_1.PositionWithCaret.ABOVE_START, constants_1.PositionWithCaret.ABOVE_CENTER, constants_1.PositionWithCaret.ABOVE_END, constants_1.PositionWithCaret.TOP_SIDE_START, constants_1.PositionWithCaret.CENTER_SIDE_START, constants_1.PositionWithCaret.BOTTOM_SIDE_START, constants_1.PositionWithCaret.TOP_SIDE_END, constants_1.PositionWithCaret.CENTER_SIDE_END, constants_1.PositionWithCaret.BOTTOM_SIDE_END, constants_1.PositionWithCaret.BELOW_START, constants_1.PositionWithCaret.BELOW_CENTER, constants_1.PositionWithCaret.BELOW_END];
// Before calling this method we check whether or not the "options" param
// is empty and invoke a different method. We, therefore, can be certain
// that "validPosition" will always be defined.
var validPosition = orderPref.find(function (pos) {
return options.has(pos);
});
var pos = options.get(validPosition);
return {
position: validPosition,
xDistance: pos.xDistance,
yDistance: pos.yDistance
};
};
/**
* Returns the corresponding PositionWithCaret enum for the proivded
* XPositionWithCaret and YPositionWithCaret enums. This mapping exists so our
* public API accepts only PositionWithCaret enums (as all combinations of
* XPositionWithCaret and YPositionWithCaret are not valid), but internally we
* can calculate the X and Y positions of a rich tooltip with caret
* separately.
*/
MDCTooltipFoundation.prototype.caretPositionOptionsMapping = function (xPos, yPos) {
switch (yPos) {
case constants_1.YPositionWithCaret.ABOVE:
if (xPos === constants_1.XPositionWithCaret.START) {
return constants_1.PositionWithCaret.ABOVE_START;
} else if (xPos === constants_1.XPositionWithCaret.CENTER) {
return constants_1.PositionWithCaret.ABOVE_CENTER;
} else if (xPos === constants_1.XPositionWithCaret.END) {
return constants_1.PositionWithCaret.ABOVE_END;
}
break;
case constants_1.YPositionWithCaret.BELOW:
if (xPos === constants_1.XPositionWithCaret.START) {
return constants_1.PositionWithCaret.BELOW_START;
} else if (xPos === constants_1.XPositionWithCaret.CENTER) {
return constants_1.PositionWithCaret.BELOW_CENTER;
} else if (xPos === constants_1.XPositionWithCaret.END) {
return constants_1.PositionWithCaret.BELOW_END;
}
break;
case constants_1.YPositionWithCaret.SIDE_TOP:
if (xPos === constants_1.XPositionWithCaret.SIDE_START) {
return constants_1.PositionWithCaret.TOP_SIDE_START;
} else if (xPos === constants_1.XPositionWithCaret.SIDE_END) {
return constants_1.PositionWithCaret.TOP_SIDE_END;
}
break;
case constants_1.YPositionWithCaret.SIDE_CENTER:
if (xPos === constants_1.XPositionWithCaret.SIDE_START) {
return constants_1.PositionWithCaret.CENTER_SIDE_START;
} else if (xPos === constants_1.XPositionWithCaret.SIDE_END) {
return constants_1.PositionWithCaret.CENTER_SIDE_END;
}
break;
case constants_1.YPositionWithCaret.SIDE_BOTTOM:
if (xPos === constants_1.XPositionWithCaret.SIDE_START) {
return constants_1.PositionWithCaret.BOTTOM_SIDE_START;
} else if (xPos === constants_1.XPositionWithCaret.SIDE_END) {
return constants_1.PositionWithCaret.BOTTOM_SIDE_END;
}
break;
default:
break;
}
throw new Error("MDCTooltipFoundation: Invalid caret position of " + xPos + ", " + yPos);
};
/**
* Given a PositionWithCaret, applies the correct styles to the caret element
* so that it is positioned properly on the rich tooltip.
* Returns the x and y positions of the caret, to be used as the
* transform-origin on the tooltip itself for entrance animations.
*/
MDCTooltipFoundation.prototype.setCaretPositionStyles = function (position, caretSize) {
var e_7, _a;
var values = this.calculateCaretPositionOnTooltip(position, caretSize);
if (!values) {
return { yTransformOrigin: 0, xTransformOrigin: 0 };
}
// Prior to setting the caret position styles, clear any previous styles
// set. This is necessary as all position options do not use the same
// properties (e.g. using 'left' or 'right') and so old style properties
// might not get overridden, causing misplaced carets.
this.adapter.clearTooltipCaretStyles();
this.adapter.setTooltipCaretStyle(values.yAlignment, values.yAxisPx);
this.adapter.setTooltipCaretStyle(values.xAlignment, values.xAxisPx);
// Value of scaleX is cos(skew), Math.cos() expects radians though, so we
// must first convert the skew value (which is in degrees) to radians.
var skewRadians = values.skew * (Math.PI / 180);
var scaleX = Math.cos(skewRadians);
this.adapter.setTooltipCaretStyle('transform', "rotate(" + values.rotation + "deg) skewY(" + values.skew + "deg) scaleX(" + scaleX + ")");
this.adapter.setTooltipCaretStyle('transform-origin', values.xAlignment + " " + values.yAlignment);
try {
for (var _b = __values(values.caretCorners), _c = _b.next(); !_c.done; _c = _b.next()) {
var corner = _c.value;
this.adapter.setTooltipCaretStyle(corner, '0');
}
} catch (e_7_1) {
e_7 = { error: e_7_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_7) throw e_7.error;
}
}
return {
yTransformOrigin: values.yTransformOrigin,
xTransformOrigin: values.xTransformOrigin
};
};
/**
* Given a PositionWithCaret, determines the correct styles to position the
* caret properly on the rich tooltip.
*/
MDCTooltipFoundation.prototype.calculateCaretPositionOnTooltip = function (tooltipPos, caretSize) {
var isLTR = !this.adapter.isRTL();
var tooltipWidth = this.adapter.getComputedStyleProperty('width');
var tooltipHeight = this.adapter.getComputedStyleProperty('height');
if (!tooltipWidth || !tooltipHeight || !caretSize) {
return;
}
var midpointWidth = "calc((" + tooltipWidth + " - " + caretSize.caretWidth + "px) / 2)";
var midpointHeight = "calc((" + tooltipHeight + " - " + caretSize.caretWidth + "px) / 2)";
var flushWithEdge = '0';
var indentedFromEdge = constants_1.numbers.CARET_INDENTATION + "px";
var indentedFromWidth = "calc(" + tooltipWidth + " - " + indentedFromEdge + ")";
var indentedFromHeight = "calc(" + tooltipHeight + " - " + indentedFromEdge + ")";
var verticalRotation = 35;
var horizontalRotation = Math.abs(90 - verticalRotation);
var bottomRightTopLeftBorderRadius = ['border-bottom-right-radius', 'border-top-left-radius'];
var bottomLeftTopRightBorderRadius = ['border-bottom-left-radius', 'border-top-right-radius'];
var skewDeg = 20;
switch (tooltipPos) {
case constants_1.PositionWithCaret.BELOW_CENTER:
return {
yAlignment: constants_1.strings.TOP,
xAlignment: constants_1.strings.LEFT,
yAxisPx: flushWithEdge,
xAxisPx: midpointWidth,
rotation: -1 * verticalRotation,
skew: -1 * skewDeg,
xTransformOrigin: midpointWidth,
yTransformOrigin: flushWithEdge,
caretCorners: bottomRightTopLeftBorderRadius
};
case constants_1.PositionWithCaret.BELOW_END:
return {
yAlignment: constants_1.strings.TOP,
xAlignment: isLTR ? constants_1.strings.RIGHT : constants_1.strings.LEFT,
yAxisPx: flushWithEdge,
xAxisPx: indentedFromEdge,
rotation: isLTR ? verticalRotation : -1 * verticalRotation,
skew: isLTR ? skewDeg : -1 * skewDeg,
xTransformOrigin: isLTR ? indentedFromWidth : indentedFromEdge,
yTransformOrigin: flushWithEdge,
caretCorners: isLTR ? bottomLeftTopRightBorderRadius : bottomRightTopLeftBorderRadius
};
case constants_1.PositionWithCaret.BELOW_START:
return {
yAlignment: constants_1.strings.TOP,
xAlignment: isLTR ? constants_1.strings.LEFT : constants_1.strings.RIGHT,
yAxisPx: flushWithEdge,
xAxisPx: indentedFromEdge,
rotation: isLTR ? -1 * verticalRotation : verticalRotation,
skew: isLTR ? -1 * skewDeg : skewDeg,
xTransformOrigin: isLTR ? indentedFromEdge : indentedFromWidth,
yTransformOrigin: flushWithEdge,
caretCorners: isLTR ? bottomRightTopLeftBorderRadius : bottomLeftTopRightBorderRadius
};
case constants_1.PositionWithCaret.TOP_SIDE_END:
return {
yAlignment: constants_1.strings.TOP,
xAlignment: isLTR ? constants_1.strings.LEFT : constants_1.strings.RIGHT,
yAxisPx: indentedFromEdge,
xAxisPx: flushWithEdge,
rotation: isLTR ? horizontalRotation : -1 * horizontalRotation,
skew: isLTR ? -1 * skewDeg : skewDeg,
xTransformOrigin: isLTR ? flushWithEdge : tooltipWidth,
yTransformOrigin: indentedFromEdge,
caretCorners: isLTR ? bottomRightTopLeftBorderRadius : bottomLeftTopRightBorderRadius
};
case constants_1.PositionWithCaret.CENTER_SIDE_END:
return {
yAlignment: constants_1.strings.TOP,
xAlignment: isLTR ? constants_1.strings.LEFT : constants_1.strings.RIGHT,
yAxisPx: midpointHeight,
xAxisPx: flushWithEdge,
rotation: isLTR ? horizontalRotation : -1 * horizontalRotation,
skew: isLTR ? -1 * skewDeg : skewDeg,
xTransformOrigin: isLTR ? flushWithEdge : tooltipWidth,
yTransformOrigin: midpointHeight,
caretCorners: isLTR ? bottomRightTopLeftBorderRadius : bottomLeftTopRightBorderRadius
};
case constants_1.PositionWithCaret.BOTTOM_SIDE_END:
return {
yAlignment: constants_1.strings.BOTTOM,
xAlignment: isLTR ? constants_1.strings.LEFT : constants_1.strings.RIGHT,
yAxisPx: indentedFromEdge,
xAxisPx: flushWithEdge,
rotation: isLTR ? -1 * horizontalRotation : horizontalRotation,
skew: isLTR ? skewDeg : -1 * skewDeg,
xTransformOrigin: isLTR ? flushWithEdge : tooltipWidth,
yTransformOrigin: indentedFromHeight,
caretCorners: isLTR ? bottomLeftTopRightBorderRadius : bottomRightTopLeftBorderRadius
};
case constants_1.PositionWithCaret.TOP_SIDE_START:
return {
yAlignment: constants_1.strings.TOP,
xAlignment: isLTR ? constants_1.strings.RIGHT : constants_1.strings.LEFT,
yAxisPx: indentedFromEdge,
xAxisPx: flushWithEdge,
rotation: isLTR ? -1 * horizontalRotation : horizontalRotation,
skew: isLTR ? skewDeg : -1 * skewDeg,
xTransformOrigin: isLTR ? tooltipWidth : flushWithEdge,
yTransformOrigin: indentedFromEdge,
caretCorners: isLTR ? bottomLeftTopRightBorderRadius : bottomRightTopLeftBorderRadius
};
case constants_1.PositionWithCaret.CENTER_SIDE_START:
return {
yAlignment: constants_1.strings.TOP,
xAlignment: isLTR ? constants_1.strings.RIGHT : constants_1.strings.LEFT,
yAxisPx: midpointHeight,
xAxisPx: flushWithEdge,
rotation: isLTR ? -1 * horizontalRotation : horizontalRotation,
skew: isLTR ? skewDeg : -1 * skewDeg,
xTransformOrigin: isLTR ? tooltipWidth : flushWithEdge,
yTransformOrigin: midpointHeight,
caretCorners: isLTR ? bottomLeftTopRightBorderRadius : bottomRightTopLeftBorderRadius
};
case constants_1.PositionWithCaret.BOTTOM_SIDE_START:
return {
yAlignment: constants_1.strings.BOTTOM,
xAlignment: isLTR ? constants_1.strings.RIGHT : constants_1.strings.LEFT,
yAxisPx: indentedFromEdge,
xAxisPx: flushWithEdge,
rotation: isLTR ? horizontalRotation : -1 * horizontalRotation,
skew: isLTR ? -1 * skewDeg : skewDeg,
xTransformOrigin: isLTR ? tooltipWidth : flushWithEdge,
yTransformOrigin: indentedFromHeight,
caretCorners: isLTR ? bottomRightTopLeftBorderRadius : bottomLeftTopRightBorderRadius
};
case constants_1.PositionWithCaret.ABOVE_CENTER:
return {
yAlignment: constants_1.strings.BOTTOM,
xAlignment: constants_1.strings.LEFT,
yAxisPx: flushWithEdge,
xAxisPx: midpointWidth,
rotation: verticalRotation,
skew: skewDeg,
xTransformOrigin: midpointWidth,
yTransformOrigin: tooltipHeight,
caretCorners: bottomLeftTopRightBorderRadius
};
case constants_1.PositionWithCaret.ABOVE_END:
return {
yAlignment: constants_1.strings.BOTTOM,
xAlignment: isLTR ? constants_1.strings.RIGHT : constants_1.strings.LEFT,
yAxisPx: flushWithEdge,
xAxisPx: indentedFromEdge,
rotation: isLTR ? -1 * verticalRotation : verticalRotation,
skew: isLTR ? -1 * skewDeg : skewDeg,
xTransformOrigin: isLTR ? indentedFromWidth : indentedFromEdge,
yTransformOrigin: tooltipHeight,
caretCorners: isLTR ? bottomRightTopLeftBorderRadius : bottomLeftTopRightBorderRadius
};
default:
case constants_1.PositionWithCaret.ABOVE_START:
return {
yAlignment: constants_1.strings.BOTTOM,
xAlignment: isLTR ? constants_1.strings.LEFT : constants_1.strings.RIGHT,
yAxisPx: flushWithEdge,
xAxisPx: indentedFromEdge,
rotation: isLTR ? verticalRotation : -1 * verticalRotation,
skew: isLTR ? skewDeg : -1 * skewDeg,
xTransformOrigin: isLTR ? indentedFromEdge : indentedFromWidth,
yTransformOrigin: tooltipHeight,
caretCorners: isLTR ? bottomLeftTopRightBorderRadius : bottomRightTopLeftBorderRadius
};
}
};
MDCTooltipFoundation.prototype.clearShowTimeout = function () {
if (this.showTimeout) {
clearTimeout(this.showTimeout);
this.showTimeout = null;
}
};
MDCTooltipFoundation.prototype.clearHideTimeout = function () {
if (this.hideTimeout) {
clearTimeout(this.hideTimeout);
this.hideTimeout = null;
}
};
/**
* Method that allows user to specify additional elements that should have a
* scroll event listener attached to it. This should be used in instances
* where the anchor element is placed inside a scrollable container, and will
* ensure that the tooltip will stay attached to the anchor on scroll.
*/
MDCTooltipFoundation.prototype.attachScrollHandler = function (addEventListenerFn) {
var _this = this;
this.addAncestorScrollEventListeners.push(function () {
addEventListenerFn('scroll', _this.windowScrollHandler);
});
};
/**
* Must be used in conjunction with #attachScrollHandler. Removes the scroll
* event handler from elements on the page.
*/
MDCTooltipFoundation.prototype.removeScrollHandler = function (removeEventHandlerFn) {
var _this = this;
this.removeAncestorScrollEventListeners.push(function () {
removeEventHandlerFn('scroll', _this.windowScrollHandler);
});
};
MDCTooltipFoundation.prototype.destroy = function () {
var e_8, _a;
if (this.frameId) {
cancelAnimationFrame(this.frameId);
this.frameId = null;
}
this.clearHideTimeout();
this.clearShowTimeout();
this.adapter.removeClass(SHOWN);
this.adapter.removeClass(SHOWING_TRANSITION);
this.adapter.removeClass(SHOWING);
this.adapter.removeClass(HIDE);
this.adapter.removeClass(HIDE_TRANSITION);
if (this.richTooltip) {
this.adapter.deregisterEventHandler('focusout', this.richTooltipFocusOutHandler);
}
if (!this.persistentTooltip) {
this.adapter.deregisterEventHandler('mouseenter', this.tooltipMouseEnterHandler);
this.adapter.deregisterEventHandler('mouseleave', this.tooltipMouseLeaveHandler);
}
this.adapter.deregisterAnchorEventHandler('blur', this.anchorBlurHandler);
this.adapter.deregisterDocumentEventHandler('click', this.documentClickHandler);
this.adapter.deregisterDocumentEventHandler('keydown', this.documentKeydownHandler);
this.adapter.deregisterWindowEventHandler('scroll', this.windowScrollHandler);
this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
try {
for (var _b = __values(this.removeAncestorScrollEventListeners), _c = _b.next(); !_c.done; _c = _b.next()) {
var fn = _c.value;
fn();
}
} catch (e_8_1) {
e_8 = { error: e_8_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_8) throw e_8.error;
}
}
this.animFrame.cancelAll();
};
return MDCTooltipFoundation;
}(foundation_1.MDCFoundation);
exports.MDCTooltipFoundation = MDCTooltipFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTooltipFoundation;
/***/ }),
/***/ "./packages/mdc-tooltip/index.ts":
/*!***************************************!*\
!*** ./packages/mdc-tooltip/index.ts ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2020 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-tooltip/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-tooltip/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-tooltip/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.ts"), exports);
/***/ }),
/***/ "./packages/mdc-top-app-bar/adapter.ts":
/*!*********************************************!*\
!*** ./packages/mdc-top-app-bar/adapter.ts ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/***/ }),
/***/ "./packages/mdc-top-app-bar/component.ts":
/*!***********************************************!*\
!*** ./packages/mdc-top-app-bar/component.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __values = this && this.__values || function (o) {
var s = typeof Symbol === "function" && Symbol.iterator,
m = s && o[s],
i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTopAppBar = void 0;
var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts");
var foundation_1 = __webpack_require__(/*! ./fixed/foundation */ "./packages/mdc-top-app-bar/fixed/foundation.ts");
var foundation_2 = __webpack_require__(/*! ./short/foundation */ "./packages/mdc-top-app-bar/short/foundation.ts");
var foundation_3 = __webpack_require__(/*! ./standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts");
var MDCTopAppBar = /** @class */function (_super) {
__extends(MDCTopAppBar, _super);
function MDCTopAppBar() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCTopAppBar.attachTo = function (root) {
return new MDCTopAppBar(root);
};
MDCTopAppBar.prototype.initialize = function (rippleFactory) {
if (rippleFactory === void 0) {
rippleFactory = function rippleFactory(el) {
return component_2.MDCRipple.attachTo(el);
};
}
this.navIcon = this.root.querySelector(constants_1.strings.NAVIGATION_ICON_SELECTOR);
// Get all icons in the toolbar and instantiate the ripples
var icons = [].slice.call(this.root.querySelectorAll(constants_1.strings.ACTION_ITEM_SELECTOR));
if (this.navIcon) {
icons.push(this.navIcon);
}
this.iconRipples = icons.map(function (icon) {
var ripple = rippleFactory(icon);
ripple.unbounded = true;
return ripple;
});
this.scrollTarget = window;
};
MDCTopAppBar.prototype.initialSyncWithDOM = function () {
this.handleNavigationClick = this.foundation.handleNavigationClick.bind(this.foundation);
this.handleWindowResize = this.foundation.handleWindowResize.bind(this.foundation);
this.handleTargetScroll = this.foundation.handleTargetScroll.bind(this.foundation);
this.scrollTarget.addEventListener('scroll', this.handleTargetScroll);
if (this.navIcon) {
this.navIcon.addEventListener('click', this.handleNavigationClick);
}
var isFixed = this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS);
var isShort = this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS);
if (!isShort && !isFixed) {
window.addEventListener('resize', this.handleWindowResize);
}
};
MDCTopAppBar.prototype.destroy = function () {
var e_1, _a;
try {
for (var _b = __values(this.iconRipples), _c = _b.next(); !_c.done; _c = _b.next()) {
var iconRipple = _c.value;
iconRipple.destroy();
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
} finally {
if (e_1) throw e_1.error;
}
}
this.scrollTarget.removeEventListener('scroll', this.handleTargetScroll);
if (this.navIcon) {
this.navIcon.removeEventListener('click', this.handleNavigationClick);
}
var isFixed = this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS);
var isShort = this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS);
if (!isShort && !isFixed) {
window.removeEventListener('resize', this.handleWindowResize);
}
_super.prototype.destroy.call(this);
};
MDCTopAppBar.prototype.setScrollTarget = function (target) {
// Remove scroll handler from the previous scroll target
this.scrollTarget.removeEventListener('scroll', this.handleTargetScroll);
this.scrollTarget = target;
// Initialize scroll handler on the new scroll target
this.handleTargetScroll = this.foundation.handleTargetScroll.bind(this.foundation);
this.scrollTarget.addEventListener('scroll', this.handleTargetScroll);
};
MDCTopAppBar.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
hasClass: function hasClass(className) {
return _this.root.classList.contains(className);
},
addClass: function addClass(className) {
return _this.root.classList.add(className);
},
removeClass: function removeClass(className) {
return _this.root.classList.remove(className);
},
setStyle: function setStyle(property, value) {
return _this.root.style.setProperty(property, value);
},
getTopAppBarHeight: function getTopAppBarHeight() {
return _this.root.clientHeight;
},
notifyNavigationIconClicked: function notifyNavigationIconClicked() {
return _this.emit(constants_1.strings.NAVIGATION_EVENT, {});
},
getViewportScrollY: function getViewportScrollY() {
var win = _this.scrollTarget;
var el = _this.scrollTarget;
return win.pageYOffset !== undefined ? win.pageYOffset : el.scrollTop;
},
getTotalActionItems: function getTotalActionItems() {
return _this.root.querySelectorAll(constants_1.strings.ACTION_ITEM_SELECTOR).length;
}
};
// tslint:enable:object-literal-sort-keys
var foundation;
if (this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS)) {
foundation = new foundation_2.MDCShortTopAppBarFoundation(adapter);
} else if (this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS)) {
foundation = new foundation_1.MDCFixedTopAppBarFoundation(adapter);
} else {
foundation = new foundation_3.MDCTopAppBarFoundation(adapter);
}
return foundation;
};
return MDCTopAppBar;
}(component_1.MDCComponent);
exports.MDCTopAppBar = MDCTopAppBar;
/***/ }),
/***/ "./packages/mdc-top-app-bar/constants.ts":
/*!***********************************************!*\
!*** ./packages/mdc-top-app-bar/constants.ts ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.strings = exports.numbers = exports.cssClasses = void 0;
var cssClasses = {
FIXED_CLASS: 'mdc-top-app-bar--fixed',
FIXED_SCROLLED_CLASS: 'mdc-top-app-bar--fixed-scrolled',
SHORT_CLASS: 'mdc-top-app-bar--short',
SHORT_COLLAPSED_CLASS: 'mdc-top-app-bar--short-collapsed',
SHORT_HAS_ACTION_ITEM_CLASS: 'mdc-top-app-bar--short-has-action-item'
};
exports.cssClasses = cssClasses;
var numbers = {
DEBOUNCE_THROTTLE_RESIZE_TIME_MS: 100,
MAX_TOP_APP_BAR_HEIGHT: 128
};
exports.numbers = numbers;
var strings = {
ACTION_ITEM_SELECTOR: '.mdc-top-app-bar__action-item',
NAVIGATION_EVENT: 'MDCTopAppBar:nav',
NAVIGATION_ICON_SELECTOR: '.mdc-top-app-bar__navigation-icon',
ROOT_SELECTOR: '.mdc-top-app-bar',
TITLE_SELECTOR: '.mdc-top-app-bar__title'
};
exports.strings = strings;
/***/ }),
/***/ "./packages/mdc-top-app-bar/fixed/foundation.ts":
/*!******************************************************!*\
!*** ./packages/mdc-top-app-bar/fixed/foundation.ts ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCFixedTopAppBarFoundation = void 0;
var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
var foundation_1 = __webpack_require__(/*! ../standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts");
var MDCFixedTopAppBarFoundation = /** @class */function (_super) {
__extends(MDCFixedTopAppBarFoundation, _super);
function MDCFixedTopAppBarFoundation() {
var _this = _super !== null && _super.apply(this, arguments) || this;
/**
* State variable for the previous scroll iteration top app bar state
*/
_this.wasScrolled = false;
return _this;
}
/**
* Scroll handler for applying/removing the modifier class on the fixed top app bar.
*/
MDCFixedTopAppBarFoundation.prototype.handleTargetScroll = function () {
var currentScroll = this.adapter.getViewportScrollY();
if (currentScroll <= 0) {
if (this.wasScrolled) {
this.adapter.removeClass(constants_1.cssClasses.FIXED_SCROLLED_CLASS);
this.wasScrolled = false;
}
} else {
if (!this.wasScrolled) {
this.adapter.addClass(constants_1.cssClasses.FIXED_SCROLLED_CLASS);
this.wasScrolled = true;
}
}
};
return MDCFixedTopAppBarFoundation;
}(foundation_1.MDCTopAppBarFoundation);
exports.MDCFixedTopAppBarFoundation = MDCFixedTopAppBarFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCFixedTopAppBarFoundation;
/***/ }),
/***/ "./packages/mdc-top-app-bar/foundation.ts":
/*!************************************************!*\
!*** ./packages/mdc-top-app-bar/foundation.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTopAppBarBaseFoundation = void 0;
var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts");
var MDCTopAppBarBaseFoundation = /** @class */function (_super) {
__extends(MDCTopAppBarBaseFoundation, _super);
/* istanbul ignore next: optional argument is not a branch statement */
function MDCTopAppBarBaseFoundation(adapter) {
return _super.call(this, __assign(__assign({}, MDCTopAppBarBaseFoundation.defaultAdapter), adapter)) || this;
}
Object.defineProperty(MDCTopAppBarBaseFoundation, "strings", {
get: function get() {
return constants_1.strings;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTopAppBarBaseFoundation, "cssClasses", {
get: function get() {
return constants_1.cssClasses;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTopAppBarBaseFoundation, "numbers", {
get: function get() {
return constants_1.numbers;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MDCTopAppBarBaseFoundation, "defaultAdapter", {
/**
* See {@link MDCTopAppBarAdapter} for typing information on parameters and return types.
*/
get: function get() {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
addClass: function addClass() {
return undefined;
},
removeClass: function removeClass() {
return undefined;
},
hasClass: function hasClass() {
return false;
},
setStyle: function setStyle() {
return undefined;
},
getTopAppBarHeight: function getTopAppBarHeight() {
return 0;
},
notifyNavigationIconClicked: function notifyNavigationIconClicked() {
return undefined;
},
getViewportScrollY: function getViewportScrollY() {
return 0;
},
getTotalActionItems: function getTotalActionItems() {
return 0;
}
};
// tslint:enable:object-literal-sort-keys
},
enumerable: false,
configurable: true
});
/** Other variants of TopAppBar foundation overrides this method */
MDCTopAppBarBaseFoundation.prototype.handleTargetScroll = function () {}; // tslint:disable-line:no-empty
/** Other variants of TopAppBar foundation overrides this method */
MDCTopAppBarBaseFoundation.prototype.handleWindowResize = function () {}; // tslint:disable-line:no-empty
MDCTopAppBarBaseFoundation.prototype.handleNavigationClick = function () {
this.adapter.notifyNavigationIconClicked();
};
return MDCTopAppBarBaseFoundation;
}(foundation_1.MDCFoundation);
exports.MDCTopAppBarBaseFoundation = MDCTopAppBarBaseFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTopAppBarBaseFoundation;
/***/ }),
/***/ "./packages/mdc-top-app-bar/index.ts":
/*!*******************************************!*\
!*** ./packages/mdc-top-app-bar/index.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @license
* Copyright 2019 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.
*/
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function get() {
return m[k];
} });
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) {
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-top-app-bar/adapter.ts"), exports);
__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-top-app-bar/component.ts"), exports);
__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts"), exports);
__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-top-app-bar/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./fixed/foundation */ "./packages/mdc-top-app-bar/fixed/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./short/foundation */ "./packages/mdc-top-app-bar/short/foundation.ts"), exports);
__exportStar(__webpack_require__(/*! ./standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts"), exports);
/***/ }),
/***/ "./packages/mdc-top-app-bar/short/foundation.ts":
/*!******************************************************!*\
!*** ./packages/mdc-top-app-bar/short/foundation.ts ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCShortTopAppBarFoundation = void 0;
var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
var foundation_1 = __webpack_require__(/*! ../foundation */ "./packages/mdc-top-app-bar/foundation.ts");
var MDCShortTopAppBarFoundation = /** @class */function (_super) {
__extends(MDCShortTopAppBarFoundation, _super);
/* istanbul ignore next: optional argument is not a branch statement */
function MDCShortTopAppBarFoundation(adapter) {
var _this = _super.call(this, adapter) || this;
_this.collapsed = false;
_this.isAlwaysCollapsed = false;
return _this;
}
Object.defineProperty(MDCShortTopAppBarFoundation.prototype, "isCollapsed", {
// Public visibility for backward compatibility.
get: function get() {
return this.collapsed;
},
enumerable: false,
configurable: true
});
MDCShortTopAppBarFoundation.prototype.init = function () {
_super.prototype.init.call(this);
if (this.adapter.getTotalActionItems() > 0) {
this.adapter.addClass(constants_1.cssClasses.SHORT_HAS_ACTION_ITEM_CLASS);
}
// If initialized with SHORT_COLLAPSED_CLASS, the bar should always be collapsed
this.setAlwaysCollapsed(this.adapter.hasClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS));
};
/**
* Set if the short top app bar should always be collapsed.
*
* @param value When `true`, bar will always be collapsed. When `false`, bar may collapse or expand based on scroll.
*/
MDCShortTopAppBarFoundation.prototype.setAlwaysCollapsed = function (value) {
this.isAlwaysCollapsed = !!value;
if (this.isAlwaysCollapsed) {
this.collapse();
} else {
// let maybeCollapseBar determine if the bar should be collapsed
this.maybeCollapseBar();
}
};
MDCShortTopAppBarFoundation.prototype.getAlwaysCollapsed = function () {
return this.isAlwaysCollapsed;
};
/**
* Scroll handler for applying/removing the collapsed modifier class on the short top app bar.
*/
MDCShortTopAppBarFoundation.prototype.handleTargetScroll = function () {
this.maybeCollapseBar();
};
MDCShortTopAppBarFoundation.prototype.maybeCollapseBar = function () {
if (this.isAlwaysCollapsed) {
return;
}
var currentScroll = this.adapter.getViewportScrollY();
if (currentScroll <= 0) {
if (this.collapsed) {
this.uncollapse();
}
} else {
if (!this.collapsed) {
this.collapse();
}
}
};
MDCShortTopAppBarFoundation.prototype.uncollapse = function () {
this.adapter.removeClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS);
this.collapsed = false;
};
MDCShortTopAppBarFoundation.prototype.collapse = function () {
this.adapter.addClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS);
this.collapsed = true;
};
return MDCShortTopAppBarFoundation;
}(foundation_1.MDCTopAppBarBaseFoundation);
exports.MDCShortTopAppBarFoundation = MDCShortTopAppBarFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCShortTopAppBarFoundation;
/***/ }),
/***/ "./packages/mdc-top-app-bar/standard/foundation.ts":
/*!*********************************************************!*\
!*** ./packages/mdc-top-app-bar/standard/foundation.ts ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @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.
*/
var __extends = this && this.__extends || function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MDCTopAppBarFoundation = void 0;
var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
var foundation_1 = __webpack_require__(/*! ../foundation */ "./packages/mdc-top-app-bar/foundation.ts");
var INITIAL_VALUE = 0;
var MDCTopAppBarFoundation = /** @class */function (_super) {
__extends(MDCTopAppBarFoundation, _super);
/* istanbul ignore next: optional argument is not a branch statement */
function MDCTopAppBarFoundation(adapter) {
var _this = _super.call(this, adapter) || this;
/**
* Indicates if the top app bar was docked in the previous scroll handler iteration.
*/
_this.wasDocked = true;
/**
* Indicates if the top app bar is docked in the fully shown position.
*/
_this.isDockedShowing = true;
/**
* Variable for current scroll position of the top app bar
*/
_this.currentAppBarOffsetTop = 0;
/**
* Used to prevent the top app bar from being scrolled out of view during resize events
*/
_this.isCurrentlyBeingResized = false;
/**
* The timeout that's used to throttle the resize events
*/
_this.resizeThrottleId = INITIAL_VALUE;
/**
* The timeout that's used to debounce toggling the isCurrentlyBeingResized
* variable after a resize
*/
_this.resizeDebounceId = INITIAL_VALUE;
_this.lastScrollPosition = _this.adapter.getViewportScrollY();
_this.topAppBarHeight = _this.adapter.getTopAppBarHeight();
return _this;
}
MDCTopAppBarFoundation.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.adapter.setStyle('top', '');
};
/**
* Scroll handler for the default scroll behavior of the top app bar.
*/
MDCTopAppBarFoundation.prototype.handleTargetScroll = function () {
var currentScrollPosition = Math.max(this.adapter.getViewportScrollY(), 0);
var diff = currentScrollPosition - this.lastScrollPosition;
this.lastScrollPosition = currentScrollPosition;
// If the window is being resized the lastScrollPosition needs to be updated
// but the current scroll of the top app bar should stay in the same
// position.
if (!this.isCurrentlyBeingResized) {
this.currentAppBarOffsetTop -= diff;
if (this.currentAppBarOffsetTop > 0) {
this.currentAppBarOffsetTop = 0;
} else if (Math.abs(this.currentAppBarOffsetTop) > this.topAppBarHeight) {
this.currentAppBarOffsetTop = -this.topAppBarHeight;
}
this.moveTopAppBar();
}
};
/**
* Top app bar resize handler that throttle/debounce functions that execute updates.
*/
MDCTopAppBarFoundation.prototype.handleWindowResize = function () {
var _this = this;
// Throttle resize events 10 p/s
if (!this.resizeThrottleId) {
this.resizeThrottleId = setTimeout(function () {
_this.resizeThrottleId = INITIAL_VALUE;
_this.throttledResizeHandler();
}, constants_1.numbers.DEBOUNCE_THROTTLE_RESIZE_TIME_MS);
}
this.isCurrentlyBeingResized = true;
if (this.resizeDebounceId) {
clearTimeout(this.resizeDebounceId);
}
this.resizeDebounceId = setTimeout(function () {
_this.handleTargetScroll();
_this.isCurrentlyBeingResized = false;
_this.resizeDebounceId = INITIAL_VALUE;
}, constants_1.numbers.DEBOUNCE_THROTTLE_RESIZE_TIME_MS);
};
/**
* Function to determine if the DOM needs to update.
*/
MDCTopAppBarFoundation.prototype.checkForUpdate = function () {
var offscreenBoundaryTop = -this.topAppBarHeight;
var hasAnyPixelsOffscreen = this.currentAppBarOffsetTop < 0;
var hasAnyPixelsOnscreen = this.currentAppBarOffsetTop > offscreenBoundaryTop;
var partiallyShowing = hasAnyPixelsOffscreen && hasAnyPixelsOnscreen;
// If it's partially showing, it can't be docked.
if (partiallyShowing) {
this.wasDocked = false;
} else {
// Not previously docked and not partially showing, it's now docked.
if (!this.wasDocked) {
this.wasDocked = true;
return true;
} else if (this.isDockedShowing !== hasAnyPixelsOnscreen) {
this.isDockedShowing = hasAnyPixelsOnscreen;
return true;
}
}
return partiallyShowing;
};
/**
* Function to move the top app bar if needed.
*/
MDCTopAppBarFoundation.prototype.moveTopAppBar = function () {
if (this.checkForUpdate()) {
// Once the top app bar is fully hidden we use the max potential top app bar height as our offset
// so the top app bar doesn't show if the window resizes and the new height > the old height.
var offset = this.currentAppBarOffsetTop;
if (Math.abs(offset) >= this.topAppBarHeight) {
offset = -constants_1.numbers.MAX_TOP_APP_BAR_HEIGHT;
}
this.adapter.setStyle('top', offset + 'px');
}
};
/**
* Throttled function that updates the top app bar scrolled values if the
* top app bar height changes.
*/
MDCTopAppBarFoundation.prototype.throttledResizeHandler = function () {
var currentHeight = this.adapter.getTopAppBarHeight();
if (this.topAppBarHeight !== currentHeight) {
this.wasDocked = false;
// Since the top app bar has a different height depending on the screen width, this
// will ensure that the top app bar remains in the correct location if
// completely hidden and a resize makes the top app bar a different height.
this.currentAppBarOffsetTop -= this.topAppBarHeight - currentHeight;
this.topAppBarHeight = currentHeight;
}
this.handleTargetScroll();
};
return MDCTopAppBarFoundation;
}(foundation_1.MDCTopAppBarBaseFoundation);
exports.MDCTopAppBarFoundation = MDCTopAppBarFoundation;
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = MDCTopAppBarFoundation;
/***/ })
/******/ });
});
//# sourceMappingURL=material-components-web.js.map