material-components-web
Version:
Modular and customizable Material Design UI components for the web
1,140 lines (1,092 loc) • 951 kB
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([], 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 __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) {
if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
}result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var index_1 = __importDefault(__webpack_require__(/*! @material/auto-init/index */ "./packages/mdc-auto-init/index.ts"));
exports.autoInit = index_1.default;
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/index */ "./packages/mdc-chips/index.ts"));
exports.chips = chips;
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 gridList = __importStar(__webpack_require__(/*! @material/grid-list/index */ "./packages/mdc-grid-list/index.ts"));
exports.gridList = gridList;
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 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 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('MDCCheckbox', checkbox.MDCCheckbox);
index_1.default.register('MDCChip', chips.MDCChip);
index_1.default.register('MDCChipSet', chips.MDCChipSet);
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('MDCGridList', gridList.MDCGridList);
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('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('MDCTopAppBar', topAppBar.MDCTopAppBar);
/***/ }),
/***/ "./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 });
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 = {
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 m = typeof Symbol === "function" && o[Symbol.iterator],
i = 0;
if (m) return m.call(o);
return {
next: function next() {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
Object.defineProperty(exports, "__esModule", { value: true });
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];
};
mdcAutoInit.deregisterAll = function () {
var keys = Object.keys(registry);
keys.forEach(this.deregister, this);
};
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
exports.default = mdcAutoInit;
/***/ }),
/***/ "./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 __spread = this && this.__spread || function () {
for (var ar = [], i = 0; i < arguments.length; i++) {
ar = ar.concat(__read(arguments[i]));
}return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
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, __spread(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 });
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: true,
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: true,
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: true,
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: true,
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.
*/
function __export(m) {
for (var p in m) {
if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(__webpack_require__(/*! ./component */ "./packages/mdc-base/component.ts"));
__export(__webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts"));
/***/ }),
/***/ "./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 __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 (b.hasOwnProperty(p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
_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 });
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 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.ripple_ = _this.createRipple_();
return _this;
}
MDCCheckbox.attachTo = function (root) {
return new MDCCheckbox(root);
};
Object.defineProperty(MDCCheckbox.prototype, "ripple", {
get: function get() {
return this.ripple_;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCCheckbox.prototype, "checked", {
get: function get() {
return this.nativeControl_.checked;
},
set: function set(checked) {
this.nativeControl_.checked = checked;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCCheckbox.prototype, "indeterminate", {
get: function get() {
return this.nativeControl_.indeterminate;
},
set: function set(indeterminate) {
this.nativeControl_.indeterminate = indeterminate;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCCheckbox.prototype, "disabled", {
get: function get() {
return this.nativeControl_.disabled;
},
set: function set(disabled) {
this.foundation_.setDisabled(disabled);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCCheckbox.prototype, "value", {
get: function get() {
return this.nativeControl_.value;
},
set: function set(value) {
this.nativeControl_.value = value;
},
enumerable: true,
configurable: true
});
MDCCheckbox.prototype.initialSyncWithDOM = function () {
var _this = this;
this.handleChange_ = function () {
return _this.foundation_.handleChange();
};
this.handleAnimationEnd_ = function () {
return _this.foundation_.handleAnimationEnd();
};
this.nativeControl_.addEventListener('change', this.handleChange_);
this.listen(util_1.getCorrectEventName(window, 'animationend'), this.handleAnimationEnd_);
this.installPropertyChangeHooks_();
};
MDCCheckbox.prototype.destroy = function () {
this.ripple_.destroy();
this.nativeControl_.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.nativeControl_;
},
isAttachedToDOM: function isAttachedToDOM() {
return Boolean(_this.root_.parentNode);
},
isChecked: function isChecked() {
return _this.checked;
},
isIndeterminate: function isIndeterminate() {
return _this.indeterminate;
},
removeClass: function removeClass(className) {
return _this.root_.classList.remove(className);
},
removeNativeControlAttr: function removeNativeControlAttr(attr) {
return _this.nativeControl_.removeAttribute(attr);
},
setNativeControlAttr: function setNativeControlAttr(attr, value) {
return _this.nativeControl_.setAttribute(attr, value);
},
setNativeControlDisabled: function setNativeControlDisabled(disabled) {
return _this.nativeControl_.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({}, component_2.MDCRipple.createAdapter(this), { deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
return _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) {
return _this.nativeControl_.addEventListener(evtType, handler, events_1.applyPassive());
} });
return new component_2.MDCRipple(this.root_, new foundation_1.MDCRippleFoundation(adapter));
};
MDCCheckbox.prototype.installPropertyChangeHooks_ = function () {
var _this = this;
var nativeCb = this.nativeControl_;
var cbProto = Object.getPrototypeOf(nativeCb);
CB_PROTO_PROPS.forEach(function (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;
}
// 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);
});
};
MDCCheckbox.prototype.uninstallPropertyChangeHooks_ = function () {
var nativeCb = this.nativeControl_;
var cbProto = Object.getPrototypeOf(nativeCb);
CB_PROTO_PROPS.forEach(function (controlState) {
var desc = Object.getOwnPropertyDescriptor(cbProto, controlState);
if (!validDescriptor(desc)) {
return;
}
Object.defineProperty(nativeCb, controlState, desc);
});
};
Object.defineProperty(MDCCheckbox.prototype, "nativeControl_", {
get: function get() {
var NATIVE_CONTROL_SELECTOR = foundation_2.MDCCheckboxFoundation.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;
},
enumerable: true,
configurable: true
});
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.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',
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 t