@material/base
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -19,3 +19,11 @@ /** | ||
/** | ||
* @template F | ||
*/ | ||
export default class MDCComponent { | ||
/** | ||
* @param {!Element} root | ||
* @return {!MDCComponent} | ||
*/ | ||
static attachTo(root) { | ||
@@ -29,3 +37,9 @@ // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and | ||
/** | ||
* @param {!Element} root | ||
* @param {!F} foundation | ||
* @param {...?} args | ||
*/ | ||
constructor(root, foundation = undefined, ...args) { | ||
/** @private {!Element} */ | ||
this.root_ = root; | ||
@@ -35,2 +49,3 @@ this.initialize(...args); | ||
// this.root_ is defined and can be used within the foundation class. | ||
/** @private {!F} */ | ||
this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation; | ||
@@ -47,2 +62,5 @@ this.foundation_.init(); | ||
/** | ||
* @return {!F} foundation | ||
*/ | ||
getDefaultFoundation() { | ||
@@ -68,4 +86,8 @@ // Subclasses must override this method to return a properly configured foundation class for the | ||
// Wrapper method to add an event listener to the component's root element. This is most useful when | ||
// listening for custom events. | ||
/** | ||
* Wrapper method to add an event listener to the component's root element. This is most useful when | ||
* listening for custom events. | ||
* @param {string} evtType | ||
* @param {!Function} handler | ||
*/ | ||
listen(evtType, handler) { | ||
@@ -75,4 +97,8 @@ this.root_.addEventListener(evtType, handler); | ||
// Wrapper method to remove an event listener to the component's root element. This is most useful when | ||
// unlistening for custom events. | ||
/** | ||
* Wrapper method to remove an event listener to the component's root element. This is most useful when | ||
* unlistening for custom events. | ||
* @param {string} evtType | ||
* @param {!Function} handler | ||
*/ | ||
unlisten(evtType, handler) { | ||
@@ -82,4 +108,9 @@ this.root_.removeEventListener(evtType, handler); | ||
// Fires a cross-browser-compatible custom event from the component root of the given type, | ||
// with the given data. | ||
/** | ||
* Fires a cross-browser-compatible custom event from the component root of the given type, | ||
* with the given data. | ||
* @param {string} evtType | ||
* @param {!Object} evtData | ||
* @param {boolean} shouldBubble | ||
*/ | ||
emit(evtType, evtData, shouldBubble = false) { | ||
@@ -86,0 +117,0 @@ let evt; |
@@ -24,5 +24,5 @@ /*! | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ | ||
/******/ // Create a new module (and put it into the cache) | ||
@@ -82,3 +82,3 @@ /******/ var module = installedModules[moduleId] = { | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 68); | ||
/******/ return __webpack_require__(__webpack_require__.s = 71); | ||
/******/ }) | ||
@@ -142,5 +142,11 @@ /************************************************************************/ | ||
/** | ||
* @template A | ||
*/ | ||
var MDCFoundation = function () { | ||
_createClass(MDCFoundation, null, [{ | ||
key: "cssClasses", | ||
/** @return enum{cssClasses} */ | ||
get: function get() { | ||
@@ -151,2 +157,5 @@ // Classes extending MDCFoundation should implement this method to return an object which exports every | ||
} | ||
/** @return enum{strings} */ | ||
}, { | ||
@@ -159,2 +168,5 @@ key: "strings", | ||
} | ||
/** @return enum{numbers} */ | ||
}, { | ||
@@ -167,2 +179,5 @@ key: "numbers", | ||
} | ||
/** @return {!Object} */ | ||
}, { | ||
@@ -176,2 +191,7 @@ key: "defaultAdapter", | ||
} | ||
/** | ||
* @param {!A} adapter | ||
*/ | ||
}]); | ||
@@ -184,2 +204,3 @@ | ||
/** @private {!A} */ | ||
this.adapter_ = adapter; | ||
@@ -234,5 +255,15 @@ } | ||
/** | ||
* @template F | ||
*/ | ||
var MDCComponent = function () { | ||
_createClass(MDCComponent, null, [{ | ||
key: 'attachTo', | ||
/** | ||
* @param {!Element} root | ||
* @return {!MDCComponent} | ||
*/ | ||
value: function attachTo(root) { | ||
@@ -245,2 +276,9 @@ // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and | ||
} | ||
/** | ||
* @param {!Element} root | ||
* @param {!F} foundation | ||
* @param {...?} args | ||
*/ | ||
}]); | ||
@@ -253,2 +291,3 @@ | ||
/** @private {!Element} */ | ||
this.root_ = root; | ||
@@ -263,2 +302,3 @@ | ||
// this.root_ is defined and can be used within the foundation class. | ||
/** @private {!F} */ | ||
this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation; | ||
@@ -271,7 +311,12 @@ this.foundation_.init(); | ||
key: 'initialize', | ||
value: function initialize() /* ...args */{ | ||
// 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. | ||
} | ||
value: function initialize() /* ...args */{} | ||
// 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. | ||
/** | ||
* @return {!F} foundation | ||
*/ | ||
}, { | ||
@@ -300,4 +345,8 @@ key: 'getDefaultFoundation', | ||
// Wrapper method to add an event listener to the component's root element. This is most useful when | ||
// listening for custom events. | ||
/** | ||
* Wrapper method to add an event listener to the component's root element. This is most useful when | ||
* listening for custom events. | ||
* @param {string} evtType | ||
* @param {!Function} handler | ||
*/ | ||
@@ -310,4 +359,8 @@ }, { | ||
// Wrapper method to remove an event listener to the component's root element. This is most useful when | ||
// unlistening for custom events. | ||
/** | ||
* Wrapper method to remove an event listener to the component's root element. This is most useful when | ||
* unlistening for custom events. | ||
* @param {string} evtType | ||
* @param {!Function} handler | ||
*/ | ||
@@ -320,4 +373,9 @@ }, { | ||
// Fires a cross-browser-compatible custom event from the component root of the given type, | ||
// with the given data. | ||
/** | ||
* Fires a cross-browser-compatible custom event from the component root of the given type, | ||
* with the given data. | ||
* @param {string} evtType | ||
* @param {!Object} evtData | ||
* @param {boolean} shouldBubble | ||
*/ | ||
@@ -351,3 +409,3 @@ }, { | ||
/***/ 68: | ||
/***/ 71: | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -354,0 +412,0 @@ |
@@ -6,2 +6,2 @@ /*! | ||
*/ | ||
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.base=n():(t.mdc=t.mdc||{},t.mdc.base=n())}(this,function(){return function(t){function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var e={};return n.m=t,n.c=e,n.i=function(t){return t},n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="/assets/",n(n.s=68)}({0:function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=e(1);e.d(n,"MDCFoundation",function(){return o.a});var r=e(2);e.d(n,"MDCComponent",function(){return r.a})},1:function(t,n,e){"use strict";function o(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(n,e,o){return e&&t(n.prototype,e),o&&t(n,o),n}}(),i=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.adapter_=n}return r(t,null,[{key:"cssClasses",get:function(){return{}}},{key:"strings",get:function(){return{}}},{key:"numbers",get:function(){return{}}},{key:"defaultAdapter",get:function(){return{}}}]),r(t,[{key:"init",value:function(){}},{key:"destroy",value:function(){}}]),t}();n.a=i},2:function(t,n,e){"use strict";function o(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var r=e(1),i=function(){function t(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(n,e,o){return e&&t(n.prototype,e),o&&t(n,o),n}}(),u=function(){function t(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;o(this,t),this.root_=n;for(var r=arguments.length,i=Array(r>2?r-2:0),u=2;u<r;u++)i[u-2]=arguments[u];this.initialize.apply(this,i),this.foundation_=void 0===e?this.getDefaultFoundation():e,this.foundation_.init(),this.initialSyncWithDOM()}return i(t,null,[{key:"attachTo",value:function(n){return new t(n,new r.a)}}]),i(t,[{key:"initialize",value:function(){}},{key:"getDefaultFoundation",value:function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")}},{key:"initialSyncWithDOM",value:function(){}},{key:"destroy",value:function(){this.foundation_.destroy()}},{key:"listen",value:function(t,n){this.root_.addEventListener(t,n)}},{key:"unlisten",value:function(t,n){this.root_.removeEventListener(t,n)}},{key:"emit",value:function(t,n){var e=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=void 0;"function"==typeof CustomEvent?o=new CustomEvent(t,{detail:n,bubbles:e}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(t,e,!1,n)),this.root_.dispatchEvent(o)}}]),t}();n.a=u},68:function(t,n,e){t.exports=e(0)}})}); | ||
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.base=n():(t.mdc=t.mdc||{},t.mdc.base=n())}(this,function(){return function(t){function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var e={};return n.m=t,n.c=e,n.i=function(t){return t},n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="/assets/",n(n.s=71)}({0:function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=e(1);e.d(n,"MDCFoundation",function(){return o.a});var r=e(2);e.d(n,"MDCComponent",function(){return r.a})},1:function(t,n,e){"use strict";function o(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(n,e,o){return e&&t(n.prototype,e),o&&t(n,o),n}}(),i=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.adapter_=n}return r(t,null,[{key:"cssClasses",get:function(){return{}}},{key:"strings",get:function(){return{}}},{key:"numbers",get:function(){return{}}},{key:"defaultAdapter",get:function(){return{}}}]),r(t,[{key:"init",value:function(){}},{key:"destroy",value:function(){}}]),t}();n.a=i},2:function(t,n,e){"use strict";function o(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var r=e(1),i=function(){function t(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(n,e,o){return e&&t(n.prototype,e),o&&t(n,o),n}}(),u=function(){function t(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;o(this,t),this.root_=n;for(var r=arguments.length,i=Array(r>2?r-2:0),u=2;u<r;u++)i[u-2]=arguments[u];this.initialize.apply(this,i),this.foundation_=void 0===e?this.getDefaultFoundation():e,this.foundation_.init(),this.initialSyncWithDOM()}return i(t,null,[{key:"attachTo",value:function(n){return new t(n,new r.a)}}]),i(t,[{key:"initialize",value:function(){}},{key:"getDefaultFoundation",value:function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")}},{key:"initialSyncWithDOM",value:function(){}},{key:"destroy",value:function(){this.foundation_.destroy()}},{key:"listen",value:function(t,n){this.root_.addEventListener(t,n)}},{key:"unlisten",value:function(t,n){this.root_.removeEventListener(t,n)}},{key:"emit",value:function(t,n){var e=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=void 0;"function"==typeof CustomEvent?o=new CustomEvent(t,{detail:n,bubbles:e}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(t,e,!1,n)),this.root_.dispatchEvent(o)}}]),t}();n.a=u},71:function(t,n,e){t.exports=e(0)}})}); |
@@ -17,3 +17,8 @@ /** | ||
/** | ||
* @template A | ||
*/ | ||
export default class MDCFoundation { | ||
/** @return enum{cssClasses} */ | ||
static get cssClasses() { | ||
@@ -25,2 +30,3 @@ // Classes extending MDCFoundation should implement this method to return an object which exports every | ||
/** @return enum{strings} */ | ||
static get strings() { | ||
@@ -32,2 +38,3 @@ // Classes extending MDCFoundation should implement this method to return an object which exports all | ||
/** @return enum{numbers} */ | ||
static get numbers() { | ||
@@ -39,2 +46,3 @@ // Classes extending MDCFoundation should implement this method to return an object which exports all | ||
/** @return {!Object} */ | ||
static get defaultAdapter() { | ||
@@ -47,3 +55,7 @@ // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient | ||
/** | ||
* @param {!A} adapter | ||
*/ | ||
constructor(adapter = {}) { | ||
/** @private {!A} */ | ||
this.adapter_ = adapter; | ||
@@ -50,0 +62,0 @@ } |
{ | ||
"name": "@material/base", | ||
"description": "The set of base classes for Material Components for the web", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
35972
529