Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-habitat

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-habitat - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

56

dist/react-habitat.js

@@ -313,4 +313,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

}, {
key: 'registerComponent',
value: function registerComponent(name, comp) {
key: 'register',
value: function register(name, comp) {
if (typeof name !== 'string') {

@@ -328,4 +328,4 @@ throw new Error('Unexpected component key. Expects a string.', name);

}, {
key: 'registerComponents',
value: function registerComponents(comps) {
key: 'registerAll',
value: function registerAll(comps) {
if ((typeof comps === 'undefined' ? 'undefined' : _typeof(comps)) !== 'object') {

@@ -351,2 +351,39 @@ throw new Error('Unexpected components type. Expects type object', comps);

/**
* Returns the containers dom factory
* @returns {ReactDomFactory}
*/
}, {
key: 'domFactory',
value: function domFactory() {
return _ReactDomFactory2.default;
}
/**
* Register a component in the container
* @param {string} name - A unique component key
* @param {object} comp - The component
* @deprecated
*/
}, {
key: 'registerComponent',
value: function registerComponent(name, comp) {
console.warn('registerComponent is being deprecated. ' + 'Please update to use "register()" instead.');
this.register(name, comp);
}
/**
* Register multiple components to the container
* @param {object} comps - The components
*/
}, {
key: 'registerComponents',
value: function registerComponents(comps) {
console.warn('registerComponents is being deprecated. ' + 'Please update to use "registerAll()" instead.');
this.registerAll(comps);
}
/**
* Gets a component for key

@@ -364,13 +401,2 @@ * @param name

}
/**
* Returns the containers dom factory
* @returns {ReactDomFactory}
*/
}, {
key: 'domFactory',
value: function domFactory() {
return _ReactDomFactory2.default;
}
}]);

@@ -377,0 +403,0 @@

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","ReactDOM"],t):"object"==typeof exports?exports.ReactHabitat=t(require("React"),require("ReactDOM")):e.ReactHabitat=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),a=o(r),i=n(2),u=o(i),c=n(4);t.default={Bootstrapper:a.default,Container:u.default,createBootstrapper:c.createBootstrapper}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t,n){for(var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=e.domFactory(),a=e.id(),i=0;t.length>i;++i){var u=t[i],l=u.getAttribute(n),s=e.resolve(l);s?r.inject(s,c.default.parseProps(u),c.default.create(u,a)):null===l||""===l||void 0===l?console.warn("Cannot read attribute value with '"+n+"' for element.",u):console.warn('Cannot resolve component "'+l+'" for',u)}"function"==typeof o&&o.call()}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;t.length>n;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(3),c=o(u),l="data-component",s=function(){function e(){if(r(this,e),!window||!window&&!window.document)throw Error("React Habitat requires a window but cannot see one :(");this.componentSelector=l,this._elements=null,this._container=null}return i(e,[{key:"setContainer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null!==this._container)throw Error("A container is already set. Please call dispose() before assigning a new one.");this._container=e,this._elements=window.document.body.querySelectorAll("["+this.componentSelector+"]"),a(this._container,this._elements,this.componentSelector,t)}},{key:"dispose",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=this._container.domFactory(),n=window.document.body.querySelectorAll('[data-habitat="'+this._container.id()+'"]'),o=0;n.length>o;++o)t.dispose(n[o]),c.default.destroy(n[o]);this._container=null,this._elements=null,"function"==typeof e&&e.call()}}]),e}();t.default=s},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},i=function(){function e(e,t){for(var n=0;t.length>n;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(5),c=o(u),l=function(){var e=0;return function(){return e++,"C"+e}}(),s=function(){function e(){r(this,e),this._components={},this._id=l()}return i(e,[{key:"id",value:function(){return this._id}},{key:"registerComponent",value:function(e,t){if("string"!=typeof e)throw Error("Unexpected component key. Expects a string.",e);this._components[e]=t}},{key:"registerComponents",value:function(e){if("object"!==(void 0===e?"undefined":a(e)))throw Error("Unexpected components type. Expects type object",e);Object.assign(this._components,e)}},{key:"resolve",value:function(e){return this._components[e]}},{key:"getComponent",value:function(e){return console.warn('getComponent is being deprecated. Please update to use "resolve()" instead.'),this.resolve(e)}},{key:"domFactory",value:function(){return c.default}}]),e}();t.default=s},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return e[1].toUpperCase()}function r(e){var t=e.currentStyle||window.getComputedStyle(e,"");return t.display}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;t.length>n;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i="habitatHostElement",u="data-habitat",c="data-has-habitat",l=function(){function e(){n(this,e)}return a(e,null,[{key:"parseProps",value:function(e){for(var t={proxy:e},n=0;e.attributes.length>n;n++){var r=e.attributes[n];if(r.name.indexOf("data-prop-")<0)"data-props"===r.name&&Object.assign(t,JSON.parse(r.value));else{var a=r.name.replace("data-prop-","").replace(/-([a-z])/g,o),i=r.value||"";"string"==typeof i&&"false"===i.toLocaleLowerCase()&&(i=!1),"string"==typeof i&&"true"===i.toLocaleLowerCase()&&(i=!0),"string"==typeof i&&i.length>2&&("{"===i[0]&&"}"===i[i.length-1]||"["===i[0]&&"]"===i[i.length-1])&&(i=JSON.parse(i)),t[a]=i}}return t}},{key:"create",value:function(e,t){if(window.document.body===e||null===e||void 0===e)return console.warn("Cannot open a habitat for ",e),null;var n="span";"block"===r(e)&&(n="div");var o=window.document.createElement(n),a=e.getAttribute("data-habitat-class")||null,l=!1;if(null!==e.getAttribute("data-habitat-no-replace")&&(l="true"===e.getAttribute("data-habitat-no-replace").toLocaleLowerCase()),o.setAttribute(u,t),a&&(o.className=""+a),e.parentNode.insertBefore(o,e.nextSibling),"INPUT"!==e.tagName){if(""!==e.innerHTML)throw Error("React Habitat elements must be empty. Any child components should be added inside React.");if(!l){var s=e.parentNode.removeChild(e);try{o[i]=s}catch(f){console.warn("Arbitrary properties are disabled and Habitat may not dispose correctly.",f)}}}else e.setAttribute(c,"true"),"hidden"!==e.getAttribute("type")&&e.setAttribute("style","display: none;");return o}},{key:"hasHabitat",value:function(e){return null!==e.getAttribute(c)}},{key:"destroy",value:function(e){try{void 0!==e[i]&&e.parentNode.insertBefore(e[i],e)}finally{e.parentNode.removeChild(e)}}}]),e}();t.default=l},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e){return new p(e)}Object.defineProperty(t,"__esModule",{value:!0}),t._Mixin=void 0,t.createBootstrapper=u;var c=n(1),l=o(c),s=n(2),f=o(s),p=t._Mixin=function(e){function t(e){r(this,t);var n=a(this,Object.getPrototypeOf(t).call(this));if(!e.container)return console.warn('"Container" property was not supplied'),a(n);e.componentSelector&&(n.componentSelector=e.componentSelector);for(var o=new f.default,i=0;e.container.length>i;i++)o.registerComponent(e.container[i].register,e.container[i].for);return n.setContainer(o),n}return i(t,e),t}(l.default)},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;t.length>n;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(6),u=o(i),c=n(7),l=o(c),s=function(){function e(){r(this,e)}return a(e,null,[{key:"inject",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2];n?l.default.render(u.default.createElement(e,t||{}),n):console.warn("Target element is null or undefined. Cannot inject component")}},{key:"dispose",value:function(e){e&&l.default.unmountComponentAtNode(e)}}]),e}();t.default=s},function(t,n){t.exports=e},function(e,n){e.exports=t}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","ReactDOM"],t):"object"==typeof exports?exports.ReactHabitat=t(require("React"),require("ReactDOM")):e.ReactHabitat=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),a=o(r),i=n(2),u=o(i),l=n(4);t.default={Bootstrapper:a.default,Container:u.default,createBootstrapper:l.createBootstrapper}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t,n){for(var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=e.domFactory(),a=e.id(),i=0;t.length>i;++i){var u=t[i],c=u.getAttribute(n),s=e.resolve(c);s?r.inject(s,l.default.parseProps(u),l.default.create(u,a)):null===c||""===c||void 0===c?console.warn("Cannot read attribute value with '"+n+"' for element.",u):console.warn('Cannot resolve component "'+c+'" for',u)}"function"==typeof o&&o.call()}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;t.length>n;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(3),l=o(u),c="data-component",s=function(){function e(){if(r(this,e),!window||!window&&!window.document)throw Error("React Habitat requires a window but cannot see one :(");this.componentSelector=c,this._elements=null,this._container=null}return i(e,[{key:"setContainer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null!==this._container)throw Error("A container is already set. Please call dispose() before assigning a new one.");this._container=e,this._elements=window.document.body.querySelectorAll("["+this.componentSelector+"]"),a(this._container,this._elements,this.componentSelector,t)}},{key:"dispose",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=this._container.domFactory(),n=window.document.body.querySelectorAll('[data-habitat="'+this._container.id()+'"]'),o=0;n.length>o;++o)t.dispose(n[o]),l.default.destroy(n[o]);this._container=null,this._elements=null,"function"==typeof e&&e.call()}}]),e}();t.default=s},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},i=function(){function e(e,t){for(var n=0;t.length>n;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(5),l=o(u),c=function(){var e=0;return function(){return e++,"C"+e}}(),s=function(){function e(){r(this,e),this._components={},this._id=c()}return i(e,[{key:"id",value:function(){return this._id}},{key:"register",value:function(e,t){if("string"!=typeof e)throw Error("Unexpected component key. Expects a string.",e);this._components[e]=t}},{key:"registerAll",value:function(e){if("object"!==(void 0===e?"undefined":a(e)))throw Error("Unexpected components type. Expects type object",e);Object.assign(this._components,e)}},{key:"resolve",value:function(e){return this._components[e]}},{key:"domFactory",value:function(){return l.default}},{key:"registerComponent",value:function(e,t){console.warn('registerComponent is being deprecated. Please update to use "register()" instead.'),this.register(e,t)}},{key:"registerComponents",value:function(e){console.warn('registerComponents is being deprecated. Please update to use "registerAll()" instead.'),this.registerAll(e)}},{key:"getComponent",value:function(e){return console.warn('getComponent is being deprecated. Please update to use "resolve()" instead.'),this.resolve(e)}}]),e}();t.default=s},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return e[1].toUpperCase()}function r(e){var t=e.currentStyle||window.getComputedStyle(e,"");return t.display}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;t.length>n;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i="habitatHostElement",u="data-habitat",l="data-has-habitat",c=function(){function e(){n(this,e)}return a(e,null,[{key:"parseProps",value:function(e){for(var t={proxy:e},n=0;e.attributes.length>n;n++){var r=e.attributes[n];if(r.name.indexOf("data-prop-")<0)"data-props"===r.name&&Object.assign(t,JSON.parse(r.value));else{var a=r.name.replace("data-prop-","").replace(/-([a-z])/g,o),i=r.value||"";"string"==typeof i&&"false"===i.toLocaleLowerCase()&&(i=!1),"string"==typeof i&&"true"===i.toLocaleLowerCase()&&(i=!0),"string"==typeof i&&i.length>2&&("{"===i[0]&&"}"===i[i.length-1]||"["===i[0]&&"]"===i[i.length-1])&&(i=JSON.parse(i)),t[a]=i}}return t}},{key:"create",value:function(e,t){if(window.document.body===e||null===e||void 0===e)return console.warn("Cannot open a habitat for ",e),null;var n="span";"block"===r(e)&&(n="div");var o=window.document.createElement(n),a=e.getAttribute("data-habitat-class")||null,c=!1;if(null!==e.getAttribute("data-habitat-no-replace")&&(c="true"===e.getAttribute("data-habitat-no-replace").toLocaleLowerCase()),o.setAttribute(u,t),a&&(o.className=""+a),e.parentNode.insertBefore(o,e.nextSibling),"INPUT"!==e.tagName){if(""!==e.innerHTML)throw Error("React Habitat elements must be empty. Any child components should be added inside React.");if(!c){var s=e.parentNode.removeChild(e);try{o[i]=s}catch(f){console.warn("Arbitrary properties are disabled and Habitat may not dispose correctly.",f)}}}else e.setAttribute(l,"true"),"hidden"!==e.getAttribute("type")&&e.setAttribute("style","display: none;");return o}},{key:"hasHabitat",value:function(e){return null!==e.getAttribute(l)}},{key:"destroy",value:function(e){try{void 0!==e[i]&&e.parentNode.insertBefore(e[i],e)}finally{e.parentNode.removeChild(e)}}}]),e}();t.default=c},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e){return new d(e)}Object.defineProperty(t,"__esModule",{value:!0}),t._Mixin=void 0,t.createBootstrapper=u;var l=n(1),c=o(l),s=n(2),f=o(s),d=t._Mixin=function(e){function t(e){r(this,t);var n=a(this,Object.getPrototypeOf(t).call(this));if(!e.container)return console.warn('"Container" property was not supplied'),a(n);e.componentSelector&&(n.componentSelector=e.componentSelector);for(var o=new f.default,i=0;e.container.length>i;i++)o.registerComponent(e.container[i].register,e.container[i].for);return n.setContainer(o),n}return i(t,e),t}(c.default)},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;t.length>n;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(6),u=o(i),l=n(7),c=o(l),s=function(){function e(){r(this,e)}return a(e,null,[{key:"inject",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2];n?c.default.render(u.default.createElement(e,t||{}),n):console.warn("Target element is null or undefined. Cannot inject component")}},{key:"dispose",value:function(e){e&&c.default.unmountComponentAtNode(e)}}]),e}();t.default=s},function(t,n){t.exports=e},function(e,n){e.exports=t}])});

@@ -27,2 +27,3 @@ /**

export interface IContainer {
/**

@@ -33,5 +34,11 @@ * Register a new component in the container

*/
registerComponent: (name: string, comp: any) => void;
register: (name: string, comp: any) => void;
/**
* Register multiple components in the container
* @param {object} comps - The components
*/
registerAll: (comps: {}) => void;
/**
* Get a registered component for a key

@@ -71,3 +78,3 @@ * @param {string} name - The key name of the component that has been registered

export class Bootstrapper implements IBootstrapper {
/**

@@ -104,5 +111,10 @@ * Sets the container

*/
registerComponent: (name: string, comp: any) => void;
register: (name: string, comp: any) => void;
/**
* Register a component
*/
registerAll: (comps: {}) => void;
/**
* Resolve a component

@@ -109,0 +121,0 @@ */

@@ -74,4 +74,4 @@ 'use strict';

}, {
key: 'registerComponent',
value: function registerComponent(name, comp) {
key: 'register',
value: function register(name, comp) {
if (typeof name !== 'string') {

@@ -89,4 +89,4 @@ throw new Error('Unexpected component key. Expects a string.', name);

}, {
key: 'registerComponents',
value: function registerComponents(comps) {
key: 'registerAll',
value: function registerAll(comps) {
if ((typeof comps === 'undefined' ? 'undefined' : _typeof(comps)) !== 'object') {

@@ -112,2 +112,39 @@ throw new Error('Unexpected components type. Expects type object', comps);

/**
* Returns the containers dom factory
* @returns {ReactDomFactory}
*/
}, {
key: 'domFactory',
value: function domFactory() {
return _ReactDomFactory2.default;
}
/**
* Register a component in the container
* @param {string} name - A unique component key
* @param {object} comp - The component
* @deprecated
*/
}, {
key: 'registerComponent',
value: function registerComponent(name, comp) {
console.warn('registerComponent is being deprecated. ' + 'Please update to use "register()" instead.');
this.register(name, comp);
}
/**
* Register multiple components to the container
* @param {object} comps - The components
*/
}, {
key: 'registerComponents',
value: function registerComponents(comps) {
console.warn('registerComponents is being deprecated. ' + 'Please update to use "registerAll()" instead.');
this.registerAll(comps);
}
/**
* Gets a component for key

@@ -125,13 +162,2 @@ * @param name

}
/**
* Returns the containers dom factory
* @returns {ReactDomFactory}
*/
}, {
key: 'domFactory',
value: function domFactory() {
return _ReactDomFactory2.default;
}
}]);

@@ -138,0 +164,0 @@

{
"name": "react-habitat",
"version": "0.2.0",
"version": "0.2.1",
"description": "A React DOM Bootstrapper designed to harmonise a hybrid application",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -51,3 +51,3 @@ ![Deloitte Digital](https://raw.githubusercontent.com/DeloitteDigital/DDBreakpoints/master/docs/deloittedigital-logo-white.png)

- Tiny code footprint (only 8KB)
- **Redux** supported by including [react-habitat-redux](https://github.com/DeloitteDigitalAPAC/react-habitat-rexux)
- **Redux** supported by including [react-habitat-redux](https://github.com/DeloitteDigitalAPAC/react-habitat-redux)
- Pass data (props) to your components directly from HTML attributes and back again

@@ -141,3 +141,3 @@ - Automatic data/JSON parsing

You will need to use a different container. Please install & configure the [react-habitat-redux library](https://github.com/DeloitteDigitalAPAC/react-habitat-rexux). Then continue with step 2 below.
You will need to use a different container. Please install & configure the [react-habitat-redux library](https://github.com/DeloitteDigitalAPAC/react-habitat-redux). Then continue with step 2 below.

@@ -144,0 +144,0 @@

@@ -51,3 +51,3 @@ ![Deloitte Digital](https://raw.githubusercontent.com/DeloitteDigital/DDBreakpoints/master/docs/deloittedigital-logo-white.png)

- Tiny code footprint (only 8KB)
- **Redux** supported by including [react-habitat-redux](https://github.com/DeloitteDigitalAPAC/react-habitat-rexux)
- **Redux** supported by including [react-habitat-redux](https://github.com/DeloitteDigitalAPAC/react-habitat-redux)
- Pass data (props) to your components directly from HTML attributes and back again

@@ -106,3 +106,3 @@ - Automatic data/JSON parsing

In React Habitat, you'd register a component something like this
In React Habitat, you'd register a component for a key something like this

@@ -140,5 +140,14 @@ ```javascript

You can also register multiple component's all at once with `registerAll` like this
```javascript
container.registerAll({
'SomeReactComponent', SomeReactComponent,
'AnotherReactComponent', AnotherReactComponent
});
```
**If you are using Redux**
You will need to use a different container. Please install & configure the [react-habitat-redux library](https://github.com/DeloitteDigitalAPAC/react-habitat-rexux). Then continue with step 2 below.
You will need to use a different container. Please install & configure the [react-habitat-redux library](https://github.com/DeloitteDigitalAPAC/react-habitat-redux). Then continue with step 2 below.

@@ -145,0 +154,0 @@

@@ -53,3 +53,3 @@ /**

*/
registerComponent(name, comp) {
register(name, comp) {
if (typeof name !== 'string') {

@@ -65,3 +65,3 @@ throw new Error('Unexpected component key. Expects a string.', name);

*/
registerComponents(comps) {
registerAll(comps) {
if (typeof comps !== 'object') {

@@ -84,2 +84,36 @@ throw new Error('Unexpected components type. Expects type object', comps);

/**
* Returns the containers dom factory
* @returns {ReactDomFactory}
*/
domFactory() {
return ReactDomFactory;
}
/**
* Register a component in the container
* @param {string} name - A unique component key
* @param {object} comp - The component
* @deprecated
*/
registerComponent(name, comp) {
console.warn(
'registerComponent is being deprecated. ' +
'Please update to use "register()" instead.'
);
this.register(name, comp);
}
/**
* Register multiple components to the container
* @param {object} comps - The components
*/
registerComponents(comps) {
console.warn(
'registerComponents is being deprecated. ' +
'Please update to use "registerAll()" instead.'
);
this.registerAll(comps);
}
/**
* Gets a component for key

@@ -95,10 +129,2 @@ * @param name

/**
* Returns the containers dom factory
* @returns {ReactDomFactory}
*/
domFactory() {
return ReactDomFactory;
}
}

@@ -49,3 +49,3 @@ /**

const container = new Container();
container.registerComponent('IMochComponent', MochComponent);
container.register('IMochComponent', MochComponent);
// --------------------------- //

@@ -66,3 +66,3 @@

const container = new Container();
container.registerComponent('IMochComponent', MochComponent);
container.register('IMochComponent', MochComponent);
const mochCallbackHandler = jasmine.createSpy('My Method');

@@ -87,3 +87,3 @@ // --------------------------- //

const container = new Container();
container.registerComponent('IMochComponent', MochComponent);
container.register('IMochComponent', MochComponent);
// --------------------------- //

@@ -107,4 +107,4 @@

const container = new Container();
container.registerComponent('IMochComponent', MochComponent);
container.registerComponent('IMochComponentTwo', MochComponentTwo);
container.register('IMochComponent', MochComponent);
container.register('IMochComponentTwo', MochComponentTwo);
// --------------------------- //

@@ -128,3 +128,3 @@

const container = new Container();
container.registerComponent('IMochComponent', MochComponent);
container.register('IMochComponent', MochComponent);
// --------------------------- //

@@ -164,3 +164,3 @@

const container = new Container();
container.registerComponent('IMochComponent', MochComponent);
container.register('IMochComponent', MochComponent);
// --------------------------- //

@@ -167,0 +167,0 @@

@@ -24,3 +24,3 @@ /**

it('does register components', () => {
container.registerComponent('aComponent', MochComponent);
container.register('aComponent', MochComponent);

@@ -34,3 +34,3 @@ expect(container).toBeDefined();

const testContainer = new Container();
testContainer.registerComponents({
testContainer.registerAll({
aComponent: MochComponent,

@@ -47,4 +47,4 @@ anotherComponent: MochComponentTwo,

it('does override registered components', () => {
container.registerComponent('aComponent', MochComponent);
container.registerComponent('aComponent', MochComponentTwo);
container.register('aComponent', MochComponent);
container.register('aComponent', MochComponentTwo);

@@ -57,4 +57,4 @@ expect(container).toBeDefined();

it('does resolve distinct components', () => {
container.registerComponent('aComponent', MochComponent);
container.registerComponent('aComponent2', MochComponentTwo);
container.register('aComponent', MochComponent);
container.register('aComponent2', MochComponentTwo);

@@ -61,0 +61,0 @@ expect(container.resolve('aComponent')).toBe(MochComponent);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc