@material/auto-init
Advanced tools
Comparing version 0.41.0 to 1.0.0-0
/*! | ||
Material Components for the Web | ||
Copyright (c) 2018 Google Inc. | ||
Copyright (c) 2019 Google Inc. | ||
License: MIT | ||
@@ -78,3 +78,3 @@ */ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 86); | ||
/******/ return __webpack_require__(__webpack_require__.s = 134); | ||
/******/ }) | ||
@@ -84,8 +84,7 @@ /************************************************************************/ | ||
/***/ 86: | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
/***/ 134: | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony export (immutable) */ __webpack_exports__["default"] = mdcAutoInit; | ||
/** | ||
@@ -114,83 +113,314 @@ * @license | ||
var registry = Object.create(null); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = __webpack_require__(135); | ||
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, warn) { | ||
if (root === void 0) { | ||
root = document; | ||
} | ||
if (warn === void 0) { | ||
warn = CONSOLE_WARN; | ||
} | ||
var e_1, _a; | ||
var components = []; | ||
var nodes = [].slice.call(root.querySelectorAll('[data-mdc-auto-init]')); | ||
try { | ||
for (var nodes_1 = tslib_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('data-mdc-auto-init'); | ||
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); | ||
} | ||
if (Object.getOwnPropertyDescriptor(node, ctorName)) { | ||
warn("(mdc-auto-init) Component already initialized for " + node + ". Skipping..."); | ||
continue; | ||
} | ||
// 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); | ||
} | ||
} 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; | ||
var CONSOLE_WARN = console.warn.bind(console); | ||
/***/ }), | ||
function _emit(evtType, evtData) { | ||
var shouldBubble = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
/***/ 135: | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
var evt = void 0; | ||
if (typeof CustomEvent === 'function') { | ||
evt = new CustomEvent(evtType, { | ||
detail: evtData, | ||
bubbles: shouldBubble | ||
}); | ||
} else { | ||
evt = document.createEvent('CustomEvent'); | ||
evt.initCustomEvent(evtType, shouldBubble, false, evtData); | ||
} | ||
"use strict"; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony export (immutable) */ __webpack_exports__["__extends"] = __extends; | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; }); | ||
/* harmony export (immutable) */ __webpack_exports__["__rest"] = __rest; | ||
/* harmony export (immutable) */ __webpack_exports__["__decorate"] = __decorate; | ||
/* harmony export (immutable) */ __webpack_exports__["__param"] = __param; | ||
/* harmony export (immutable) */ __webpack_exports__["__metadata"] = __metadata; | ||
/* harmony export (immutable) */ __webpack_exports__["__awaiter"] = __awaiter; | ||
/* harmony export (immutable) */ __webpack_exports__["__generator"] = __generator; | ||
/* harmony export (immutable) */ __webpack_exports__["__exportStar"] = __exportStar; | ||
/* harmony export (immutable) */ __webpack_exports__["__values"] = __values; | ||
/* harmony export (immutable) */ __webpack_exports__["__read"] = __read; | ||
/* harmony export (immutable) */ __webpack_exports__["__spread"] = __spread; | ||
/* harmony export (immutable) */ __webpack_exports__["__await"] = __await; | ||
/* harmony export (immutable) */ __webpack_exports__["__asyncGenerator"] = __asyncGenerator; | ||
/* harmony export (immutable) */ __webpack_exports__["__asyncDelegator"] = __asyncDelegator; | ||
/* harmony export (immutable) */ __webpack_exports__["__asyncValues"] = __asyncValues; | ||
/* harmony export (immutable) */ __webpack_exports__["__makeTemplateObject"] = __makeTemplateObject; | ||
/* harmony export (immutable) */ __webpack_exports__["__importStar"] = __importStar; | ||
/* harmony export (immutable) */ __webpack_exports__["__importDefault"] = __importDefault; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
document.dispatchEvent(evt); | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
/** | ||
* Auto-initializes all mdc components on a page. | ||
*/ | ||
function mdcAutoInit() { | ||
var root = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; | ||
var warn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CONSOLE_WARN; | ||
var components = []; | ||
var nodes = root.querySelectorAll('[data-mdc-auto-init]'); | ||
for (var i = 0, node; node = nodes[i]; i++) { | ||
var ctorName = node.dataset.mdcAutoInit; | ||
if (!ctorName) { | ||
throw new Error('(mdc-auto-init) Constructor name must be given.'); | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(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 Ctor = registry[ctorName]; | ||
if (typeof Ctor !== 'function') { | ||
throw new Error('(mdc-auto-init) Could not find constructor in registry for ' + ctorName); | ||
function __rest(s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) | ||
t[p[i]] = s[p[i]]; | ||
return t; | ||
} | ||
function __decorate(decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
} | ||
function __param(paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
} | ||
function __metadata(metadataKey, metadataValue) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); | ||
} | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { 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 }; | ||
} | ||
} | ||
if (node[ctorName]) { | ||
warn('(mdc-auto-init) Component already initialized for ' + node + '. Skipping...'); | ||
continue; | ||
function __exportStar(m, exports) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
function __values(o) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; | ||
if (m) return m.call(o); | ||
return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
} | ||
function __read(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; | ||
} | ||
// TODO: Should we make an eslint rule for an attachTo() static method? | ||
var component = Ctor.attachTo(node); | ||
Object.defineProperty(node, ctorName, { | ||
value: component, | ||
writable: false, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
components.push(component); | ||
} | ||
function __spread() { | ||
for (var ar = [], i = 0; i < arguments.length; i++) | ||
ar = ar.concat(__read(arguments[i])); | ||
return ar; | ||
} | ||
_emit('MDCAutoInit:End', {}); | ||
return components; | ||
function __await(v) { | ||
return this instanceof __await ? (this.v = v, this) : new __await(v); | ||
} | ||
mdcAutoInit.register = function (componentName, Ctor) { | ||
var warn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : CONSOLE_WARN; | ||
function __asyncGenerator(thisArg, _arguments, generator) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var g = generator.apply(thisArg, _arguments || []), i, q = []; | ||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; | ||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } | ||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } | ||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } | ||
function fulfill(value) { resume("next", value); } | ||
function reject(value) { resume("throw", value); } | ||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } | ||
} | ||
if (typeof Ctor !== 'function') { | ||
throw new Error('(mdc-auto-init) Invalid Ctor value ' + Ctor + '. Expected function'); | ||
} | ||
if (registry[componentName]) { | ||
warn('(mdc-auto-init) Overriding registration for ' + componentName + ' with ' + Ctor + '. ' + ('Was: ' + registry[componentName])); | ||
} | ||
registry[componentName] = Ctor; | ||
}; | ||
function __asyncDelegator(o) { | ||
var i, p; | ||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; | ||
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } | ||
} | ||
mdcAutoInit.deregister = function (componentName) { | ||
delete registry[componentName]; | ||
}; | ||
function __asyncValues(o) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var m = o[Symbol.asyncIterator], i; | ||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); | ||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } | ||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } | ||
} | ||
mdcAutoInit.deregisterAll = function () { | ||
Object.keys(registry).forEach(this.deregister, this); | ||
function __makeTemplateObject(cooked, raw) { | ||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } | ||
return cooked; | ||
}; | ||
function __importStar(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; | ||
} | ||
function __importDefault(mod) { | ||
return (mod && mod.__esModule) ? mod : { default: mod }; | ||
} | ||
/***/ }) | ||
@@ -197,0 +427,0 @@ |
/*! | ||
Material Components for the Web | ||
Copyright (c) 2018 Google Inc. | ||
Copyright (c) 2019 Google Inc. | ||
License: MIT | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.autoInit=e():(t.mdc=t.mdc||{},t.mdc.autoInit=e())}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=86)}({86:function(t,e,n){"use strict";function o(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=void 0;"function"==typeof CustomEvent?o=new CustomEvent(t,{detail:e,bubbles:n}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(t,n,!1,e)),document.dispatchEvent(o)}function r(){for(var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u,r=[],c=e.querySelectorAll("[data-mdc-auto-init]"),a=0;t=c[a];a++){var d=t.dataset.mdcAutoInit;if(!d)throw new Error("(mdc-auto-init) Constructor name must be given.");var f=i[d];if("function"!=typeof f)throw new Error("(mdc-auto-init) Could not find constructor in registry for "+d);if(t[d])n("(mdc-auto-init) Component already initialized for "+t+". Skipping...");else{var l=f.attachTo(t);Object.defineProperty(t,d,{value:l,writable:!1,enumerable:!1,configurable:!0}),r.push(l)}}return o("MDCAutoInit:End",{}),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;/** | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.autoInit=e():(t.mdc=t.mdc||{},t.mdc.autoInit=e())}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=134)}({134:function(t,e,n){"use strict";function r(t,e,n){void 0===n&&(n=!1);var r;"function"==typeof CustomEvent?r=new CustomEvent(t,{bubbles:n,detail:e}):(r=document.createEvent("CustomEvent"),r.initCustomEvent(t,n,!1,e)),document.dispatchEvent(r)}function o(t,e){void 0===t&&(t=document),void 0===e&&(e=c);var n,o,a=[],f=[].slice.call(t.querySelectorAll("[data-mdc-auto-init]"));try{for(var l=i.__values(f),s=l.next();!s.done;s=l.next()){var p=s.value,y=p.getAttribute("data-mdc-auto-init");if(!y)throw new Error("(mdc-auto-init) Constructor name must be given.");var d=u[y];if("function"!=typeof d)throw new Error("(mdc-auto-init) Could not find constructor in registry for "+y);if(Object.getOwnPropertyDescriptor(p,y))e("(mdc-auto-init) Component already initialized for "+p+". Skipping...");else{var v=d.attachTo(p);Object.defineProperty(p,y,{configurable:!0,enumerable:!1,value:v,writable:!1}),a.push(v)}}}catch(t){n={error:t}}finally{try{s&&!s.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}return r("MDCAutoInit:End",{}),a}/** | ||
* @license | ||
@@ -28,3 +28,17 @@ * Copyright 2016 Google Inc. | ||
*/ | ||
var i=Object.create(null),u=console.warn.bind(console);r.register=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:u;if("function"!=typeof e)throw new Error("(mdc-auto-init) Invalid Ctor value "+e+". Expected function");i[t]&&n("(mdc-auto-init) Overriding registration for "+t+" with "+e+". Was: "+i[t]),i[t]=e},r.deregister=function(t){delete i[t]},r.deregisterAll=function(){Object.keys(i).forEach(this.deregister,this)}}})}); | ||
Object.defineProperty(e,"__esModule",{value:!0});var i=n(135),u={},c=console.warn.bind(console);e.mdcAutoInit=o,o.register=function(t,e,n){if(void 0===n&&(n=c),"function"!=typeof e)throw new Error("(mdc-auto-init) Invalid Constructor value: "+e+". Expected function.");var r=u[t];r&&n("(mdc-auto-init) Overriding registration for "+t+" with "+e+". Was: "+r),u[t]=e},o.deregister=function(t){delete u[t]},o.deregisterAll=function(){Object.keys(u).forEach(this.deregister,this)},e.default=o},135:function(t,e,n){"use strict";function r(t,e){function n(){this.constructor=t}O(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function o(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&(n[r[o]]=t[r[o]]);return n}function i(t,e,n,r){var o,i=arguments.length,u=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,n,r);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(u=(i<3?o(u):i>3?o(e,n,u):o(e,n))||u);return i>3&&u&&Object.defineProperty(e,n,u),u}function u(t,e){return function(n,r){e(n,r,t)}}function c(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function a(t,e,n,r){return new(n||(n=Promise))(function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):new n(function(e){e(t.value)}).then(u,c)}a((r=r.apply(t,e||[])).next())})}function f(t,e){function n(t){return function(e){return r([t,e])}}function r(n){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,i&&(u=2&n[0]?i.return:n[0]?i.throw||((u=i.return)&&u.call(i),0):i.next)&&!(u=u.call(i,n[1])).done)return u;switch(i=0,u&&(n=[2&n[0],u.value]),n[0]){case 0:case 1:u=n;break;case 4:return a.label++,{value:n[1],done:!1};case 5:a.label++,i=n[1],n=[0];continue;case 7:n=a.ops.pop(),a.trys.pop();continue;default:if(u=a.trys,!(u=u.length>0&&u[u.length-1])&&(6===n[0]||2===n[0])){a=0;continue}if(3===n[0]&&(!u||n[1]>u[0]&&n[1]<u[3])){a.label=n[1];break}if(6===n[0]&&a.label<u[1]){a.label=u[1],u=n;break}if(u&&a.label<u[2]){a.label=u[2],a.ops.push(n);break}u[2]&&a.ops.pop(),a.trys.pop();continue}n=e.call(t,a)}catch(t){n=[6,t],i=0}finally{o=u=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var o,i,u,c,a={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]};return c={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c}function l(t,e){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}function s(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function p(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function y(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(p(arguments[e]));return t}function d(t){return this instanceof d?(this.v=t,this):new d(t)}function v(t,e,n){function r(t){l[t]&&(f[t]=function(e){return new Promise(function(n,r){s.push([t,e,n,r])>1||o(t,e)})})}function o(t,e){try{i(l[t](e))}catch(t){a(s[0][3],t)}}function i(t){t.value instanceof d?Promise.resolve(t.value.v).then(u,c):a(s[0][2],t)}function u(t){o("next",t)}function c(t){o("throw",t)}function a(t,e){t(e),s.shift(),s.length&&o(s[0][0],s[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var f,l=n.apply(t,e||[]),s=[];return f={},r("next"),r("throw"),r("return"),f[Symbol.asyncIterator]=function(){return this},f}function b(t){function e(e,o){n[e]=t[e]?function(n){return(r=!r)?{value:d(t[e](n)),done:"return"===e}:o?o(n):n}:o}var n,r;return n={},e("next"),e("throw",function(t){throw t}),e("return"),n[Symbol.iterator]=function(){return this},n}function h(t){function e(e){r[e]=t[e]&&function(r){return new Promise(function(o,i){r=t[e](r),n(o,i,r.done,r.value)})}}function n(t,e,n,r){Promise.resolve(r).then(function(e){t({value:e,done:n})},e)}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=t[Symbol.asyncIterator];return o?o.call(t):(t="function"==typeof s?s(t):t[Symbol.iterator](),r={},e("next"),e("throw"),e("return"),r[Symbol.asyncIterator]=function(){return this},r)}function _(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function m(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function w(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.__extends=r,n.d(e,"__assign",function(){return g}),e.__rest=o,e.__decorate=i,e.__param=u,e.__metadata=c,e.__awaiter=a,e.__generator=f,e.__exportStar=l,e.__values=s,e.__read=p,e.__spread=y,e.__await=d,e.__asyncGenerator=v,e.__asyncDelegator=b,e.__asyncValues=h,e.__makeTemplateObject=_,e.__importStar=m,e.__importDefault=w;/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
var O=function(t,e){return(O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},g=function(){return g=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},g.apply(this,arguments)}}})}); | ||
//# sourceMappingURL=mdc.autoInit.min.js.map |
147
index.js
@@ -23,78 +23,89 @@ /** | ||
*/ | ||
const registry = Object.create(null); | ||
const CONSOLE_WARN = console.warn.bind(console); | ||
function _emit(evtType, evtData, shouldBubble = false) { | ||
let evt; | ||
if (typeof CustomEvent === 'function') { | ||
evt = new CustomEvent(evtType, { | ||
detail: evtData, | ||
bubbles: shouldBubble, | ||
}); | ||
} else { | ||
evt = document.createEvent('CustomEvent'); | ||
evt.initCustomEvent(evtType, shouldBubble, false, evtData); | ||
} | ||
document.dispatchEvent(evt); | ||
import * as tslib_1 from "tslib"; | ||
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. | ||
* Auto-initializes all MDC components on a page. | ||
*/ | ||
export default function mdcAutoInit(root = document, warn = CONSOLE_WARN) { | ||
const components = []; | ||
const nodes = root.querySelectorAll('[data-mdc-auto-init]'); | ||
for (let i = 0, node; (node = nodes[i]); i++) { | ||
const ctorName = node.dataset.mdcAutoInit; | ||
if (!ctorName) { | ||
throw new Error('(mdc-auto-init) Constructor name must be given.'); | ||
export function mdcAutoInit(root, warn) { | ||
if (root === void 0) { root = document; } | ||
if (warn === void 0) { warn = CONSOLE_WARN; } | ||
var e_1, _a; | ||
var components = []; | ||
var nodes = [].slice.call(root.querySelectorAll('[data-mdc-auto-init]')); | ||
try { | ||
for (var nodes_1 = tslib_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('data-mdc-auto-init'); | ||
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); | ||
} | ||
if (Object.getOwnPropertyDescriptor(node, ctorName)) { | ||
warn("(mdc-auto-init) Component already initialized for " + node + ". Skipping..."); | ||
continue; | ||
} | ||
// 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); | ||
} | ||
} | ||
const Ctor = registry[ctorName]; | ||
if (typeof Ctor !== 'function') { | ||
throw new Error( | ||
`(mdc-auto-init) Could not find constructor in registry for ${ctorName}`); | ||
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; } | ||
} | ||
if (node[ctorName]) { | ||
warn(`(mdc-auto-init) Component already initialized for ${node}. Skipping...`); | ||
continue; | ||
emit('MDCAutoInit:End', {}); | ||
return components; | ||
} | ||
// 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."); | ||
} | ||
// TODO: Should we make an eslint rule for an attachTo() static method? | ||
const component = Ctor.attachTo(node); | ||
Object.defineProperty(node, ctorName, { | ||
value: component, | ||
writable: false, | ||
enumerable: false, | ||
configurable: true, | ||
}); | ||
components.push(component); | ||
} | ||
_emit('MDCAutoInit:End', {}); | ||
return components; | ||
} | ||
mdcAutoInit.register = function(componentName, Ctor, warn = CONSOLE_WARN) { | ||
if (typeof Ctor !== 'function') { | ||
throw new Error(`(mdc-auto-init) Invalid Ctor value ${Ctor}. Expected function`); | ||
} | ||
if (registry[componentName]) { | ||
warn( | ||
`(mdc-auto-init) Overriding registration for ${componentName} with ${Ctor}. ` + | ||
`Was: ${registry[componentName]}`); | ||
} | ||
registry[componentName] = Ctor; | ||
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.deregister = function (componentName) { | ||
delete registry[componentName]; | ||
}; | ||
mdcAutoInit.deregisterAll = function() { | ||
Object.keys(registry).forEach(this.deregister, this); | ||
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. | ||
export default mdcAutoInit; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@material/auto-init", | ||
"description": "Declarative, easy-to-use auto-initialization for Material Components for the web", | ||
"version": "0.41.0", | ||
"version": "1.0.0-0", | ||
"main": "dist/mdc.autoInit.js", | ||
"module": "index.js", | ||
"sideEffects": false, | ||
"types": "dist/mdc.autoInit.d.ts", | ||
"license": "MIT", | ||
@@ -10,3 +13,7 @@ "repository": { | ||
"url": "https://github.com/material-components/material-components-web.git" | ||
}, | ||
"dependencies": { | ||
"@material/base": "^1.0.0-0", | ||
"tslib": "^1.9.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
115207
10
652
2
1
+ Added@material/base@^1.0.0-0
+ Addedtslib@^1.9.3
+ Added@material/base@1.0.0(transitive)
+ Addedtslib@1.14.1(transitive)