mdc.base.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
  7. */
  8. (function webpackUniversalModuleDefinition(root, factory) {
  9. if(typeof exports === 'object' && typeof module === 'object')
  10. module.exports = factory();
  11. else if(typeof define === 'function' && define.amd)
  12. define([], factory);
  13. else if(typeof exports === 'object')
  14. exports["base"] = factory();
  15. else
  16. root["mdc"] = root["mdc"] || {}, root["mdc"]["base"] = factory();
  17. })(this, function() {
  18. return /******/ (function(modules) { // webpackBootstrap
  19. /******/ // The module cache
  20. /******/ var installedModules = {};
  21. /******/
  22. /******/ // The require function
  23. /******/ function __webpack_require__(moduleId) {
  24. /******/
  25. /******/ // Check if module is in cache
  26. /******/ if(installedModules[moduleId]) {
  27. /******/ return installedModules[moduleId].exports;
  28. /******/ }
  29. /******/ // Create a new module (and put it into the cache)
  30. /******/ var module = installedModules[moduleId] = {
  31. /******/ i: moduleId,
  32. /******/ l: false,
  33. /******/ exports: {}
  34. /******/ };
  35. /******/
  36. /******/ // Execute the module function
  37. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  38. /******/
  39. /******/ // Flag the module as loaded
  40. /******/ module.l = true;
  41. /******/
  42. /******/ // Return the exports of the module
  43. /******/ return module.exports;
  44. /******/ }
  45. /******/
  46. /******/
  47. /******/ // expose the modules object (__webpack_modules__)
  48. /******/ __webpack_require__.m = modules;
  49. /******/
  50. /******/ // expose the module cache
  51. /******/ __webpack_require__.c = installedModules;
  52. /******/
  53. /******/ // define getter function for harmony exports
  54. /******/ __webpack_require__.d = function(exports, name, getter) {
  55. /******/ if(!__webpack_require__.o(exports, name)) {
  56. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  57. /******/ }
  58. /******/ };
  59. /******/
  60. /******/ // define __esModule on exports
  61. /******/ __webpack_require__.r = function(exports) {
  62. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  63. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  64. /******/ }
  65. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  66. /******/ };
  67. /******/
  68. /******/ // create a fake namespace object
  69. /******/ // mode & 1: value is a module id, require it
  70. /******/ // mode & 2: merge all properties of value into the ns
  71. /******/ // mode & 4: return value when already ns object
  72. /******/ // mode & 8|1: behave like require
  73. /******/ __webpack_require__.t = function(value, mode) {
  74. /******/ if(mode & 1) value = __webpack_require__(value);
  75. /******/ if(mode & 8) return value;
  76. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  77. /******/ var ns = Object.create(null);
  78. /******/ __webpack_require__.r(ns);
  79. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  80. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  81. /******/ return ns;
  82. /******/ };
  83. /******/
  84. /******/ // getDefaultExport function for compatibility with non-harmony modules
  85. /******/ __webpack_require__.n = function(module) {
  86. /******/ var getter = module && module.__esModule ?
  87. /******/ function getDefault() { return module['default']; } :
  88. /******/ function getModuleExports() { return module; };
  89. /******/ __webpack_require__.d(getter, 'a', getter);
  90. /******/ return getter;
  91. /******/ };
  92. /******/
  93. /******/ // Object.prototype.hasOwnProperty.call
  94. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  95. /******/
  96. /******/ // __webpack_public_path__
  97. /******/ __webpack_require__.p = "";
  98. /******/
  99. /******/
  100. /******/ // Load entry module and return exports
  101. /******/ return __webpack_require__(__webpack_require__.s = "./packages/mdc-base/index.ts");
  102. /******/ })
  103. /************************************************************************/
  104. /******/ ({
  105. /***/ "./packages/mdc-base/component.ts":
  106. /*!****************************************!*\
  107. !*** ./packages/mdc-base/component.ts ***!
  108. \****************************************/
  109. /*! no static exports found */
  110. /***/ (function(module, exports, __webpack_require__) {
  111. "use strict";
  112. /**
  113. * @license
  114. * Copyright 2016 Google Inc.
  115. *
  116. * Permission is hereby granted, free of charge, to any person obtaining a copy
  117. * of this software and associated documentation files (the "Software"), to deal
  118. * in the Software without restriction, including without limitation the rights
  119. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  120. * copies of the Software, and to permit persons to whom the Software is
  121. * furnished to do so, subject to the following conditions:
  122. *
  123. * The above copyright notice and this permission notice shall be included in
  124. * all copies or substantial portions of the Software.
  125. *
  126. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  127. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  128. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  129. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  130. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  131. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  132. * THE SOFTWARE.
  133. */
  134. var __read = this && this.__read || function (o, n) {
  135. var m = typeof Symbol === "function" && o[Symbol.iterator];
  136. if (!m) return o;
  137. var i = m.call(o),
  138. r,
  139. ar = [],
  140. e;
  141. try {
  142. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  143. ar.push(r.value);
  144. }
  145. } catch (error) {
  146. e = { error: error };
  147. } finally {
  148. try {
  149. if (r && !r.done && (m = i["return"])) m.call(i);
  150. } finally {
  151. if (e) throw e.error;
  152. }
  153. }
  154. return ar;
  155. };
  156. var __spread = this && this.__spread || function () {
  157. for (var ar = [], i = 0; i < arguments.length; i++) {
  158. ar = ar.concat(__read(arguments[i]));
  159. }return ar;
  160. };
  161. Object.defineProperty(exports, "__esModule", { value: true });
  162. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
  163. var MDCComponent = /** @class */function () {
  164. function MDCComponent(root, foundation) {
  165. var args = [];
  166. for (var _i = 2; _i < arguments.length; _i++) {
  167. args[_i - 2] = arguments[_i];
  168. }
  169. this.root_ = root;
  170. this.initialize.apply(this, __spread(args));
  171. // Note that we initialize foundation here and not within the constructor's default param so that
  172. // this.root_ is defined and can be used within the foundation class.
  173. this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation;
  174. this.foundation_.init();
  175. this.initialSyncWithDOM();
  176. }
  177. MDCComponent.attachTo = function (root) {
  178. // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
  179. // returns an instantiated component with its root set to that element. Also note that in the cases of
  180. // subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
  181. // from getDefaultFoundation().
  182. return new MDCComponent(root, new foundation_1.MDCFoundation({}));
  183. };
  184. /* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */
  185. MDCComponent.prototype.initialize = function () {
  186. var _args = [];
  187. for (var _i = 0; _i < arguments.length; _i++) {
  188. _args[_i] = arguments[_i];
  189. }
  190. // Subclasses can override this to do any additional setup work that would be considered part of a
  191. // "constructor". Essentially, it is a hook into the parent constructor before the foundation is
  192. // initialized. Any additional arguments besides root and foundation will be passed in here.
  193. };
  194. MDCComponent.prototype.getDefaultFoundation = function () {
  195. // Subclasses must override this method to return a properly configured foundation class for the
  196. // component.
  197. throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
  198. };
  199. MDCComponent.prototype.initialSyncWithDOM = function () {
  200. // Subclasses should override this method if they need to perform work to synchronize with a host DOM
  201. // object. An example of this would be a form control wrapper that needs to synchronize its internal state
  202. // to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
  203. // reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
  204. };
  205. MDCComponent.prototype.destroy = function () {
  206. // Subclasses may implement this method to release any resources / deregister any listeners they have
  207. // attached. An example of this might be deregistering a resize event from the window object.
  208. this.foundation_.destroy();
  209. };
  210. MDCComponent.prototype.listen = function (evtType, handler, options) {
  211. this.root_.addEventListener(evtType, handler, options);
  212. };
  213. MDCComponent.prototype.unlisten = function (evtType, handler, options) {
  214. this.root_.removeEventListener(evtType, handler, options);
  215. };
  216. /**
  217. * Fires a cross-browser-compatible custom event from the component root of the given type, with the given data.
  218. */
  219. MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
  220. if (shouldBubble === void 0) {
  221. shouldBubble = false;
  222. }
  223. var evt;
  224. if (typeof CustomEvent === 'function') {
  225. evt = new CustomEvent(evtType, {
  226. bubbles: shouldBubble,
  227. detail: evtData
  228. });
  229. } else {
  230. evt = document.createEvent('CustomEvent');
  231. evt.initCustomEvent(evtType, shouldBubble, false, evtData);
  232. }
  233. this.root_.dispatchEvent(evt);
  234. };
  235. return MDCComponent;
  236. }();
  237. exports.MDCComponent = MDCComponent;
  238. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  239. exports.default = MDCComponent;
  240. /***/ }),
  241. /***/ "./packages/mdc-base/foundation.ts":
  242. /*!*****************************************!*\
  243. !*** ./packages/mdc-base/foundation.ts ***!
  244. \*****************************************/
  245. /*! no static exports found */
  246. /***/ (function(module, exports, __webpack_require__) {
  247. "use strict";
  248. /**
  249. * @license
  250. * Copyright 2016 Google Inc.
  251. *
  252. * Permission is hereby granted, free of charge, to any person obtaining a copy
  253. * of this software and associated documentation files (the "Software"), to deal
  254. * in the Software without restriction, including without limitation the rights
  255. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  256. * copies of the Software, and to permit persons to whom the Software is
  257. * furnished to do so, subject to the following conditions:
  258. *
  259. * The above copyright notice and this permission notice shall be included in
  260. * all copies or substantial portions of the Software.
  261. *
  262. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  263. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  264. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  265. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  266. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  267. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  268. * THE SOFTWARE.
  269. */
  270. Object.defineProperty(exports, "__esModule", { value: true });
  271. var MDCFoundation = /** @class */function () {
  272. function MDCFoundation(adapter) {
  273. if (adapter === void 0) {
  274. adapter = {};
  275. }
  276. this.adapter_ = adapter;
  277. }
  278. Object.defineProperty(MDCFoundation, "cssClasses", {
  279. get: function get() {
  280. // Classes extending MDCFoundation should implement this method to return an object which exports every
  281. // CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
  282. return {};
  283. },
  284. enumerable: true,
  285. configurable: true
  286. });
  287. Object.defineProperty(MDCFoundation, "strings", {
  288. get: function get() {
  289. // Classes extending MDCFoundation should implement this method to return an object which exports all
  290. // semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
  291. return {};
  292. },
  293. enumerable: true,
  294. configurable: true
  295. });
  296. Object.defineProperty(MDCFoundation, "numbers", {
  297. get: function get() {
  298. // Classes extending MDCFoundation should implement this method to return an object which exports all
  299. // of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
  300. return {};
  301. },
  302. enumerable: true,
  303. configurable: true
  304. });
  305. Object.defineProperty(MDCFoundation, "defaultAdapter", {
  306. get: function get() {
  307. // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
  308. // way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
  309. // validation.
  310. return {};
  311. },
  312. enumerable: true,
  313. configurable: true
  314. });
  315. MDCFoundation.prototype.init = function () {
  316. // Subclasses should override this method to perform initialization routines (registering events, etc.)
  317. };
  318. MDCFoundation.prototype.destroy = function () {
  319. // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
  320. };
  321. return MDCFoundation;
  322. }();
  323. exports.MDCFoundation = MDCFoundation;
  324. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  325. exports.default = MDCFoundation;
  326. /***/ }),
  327. /***/ "./packages/mdc-base/index.ts":
  328. /*!************************************!*\
  329. !*** ./packages/mdc-base/index.ts ***!
  330. \************************************/
  331. /*! no static exports found */
  332. /***/ (function(module, exports, __webpack_require__) {
  333. "use strict";
  334. /**
  335. * @license
  336. * Copyright 2019 Google Inc.
  337. *
  338. * Permission is hereby granted, free of charge, to any person obtaining a copy
  339. * of this software and associated documentation files (the "Software"), to deal
  340. * in the Software without restriction, including without limitation the rights
  341. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  342. * copies of the Software, and to permit persons to whom the Software is
  343. * furnished to do so, subject to the following conditions:
  344. *
  345. * The above copyright notice and this permission notice shall be included in
  346. * all copies or substantial portions of the Software.
  347. *
  348. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  349. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  350. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  351. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  352. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  353. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  354. * THE SOFTWARE.
  355. */
  356. function __export(m) {
  357. for (var p in m) {
  358. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  359. }
  360. }
  361. Object.defineProperty(exports, "__esModule", { value: true });
  362. __export(__webpack_require__(/*! ./component */ "./packages/mdc-base/component.ts"));
  363. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts"));
  364. /***/ })
  365. /******/ });
  366. });
  367. //# sourceMappingURL=mdc.base.js.map