@bem-react/di
Advanced tools
Comparing version 1.3.1-dev.7 to 1.3.1-dev.8
@@ -74,3 +74,3 @@ 'use strict'; | ||
Registry.prototype.set = function (id, component) { | ||
this.components[this.componentId(id)] = component; | ||
this.components[id] = component; | ||
return this; | ||
@@ -85,7 +85,7 @@ }; | ||
{ | ||
if (!this.components[this.componentId(id)]) { | ||
if (!this.components[id]) { | ||
throw new Error("Component with id '" + id + "' not found."); | ||
} | ||
} | ||
return this.components[this.componentId(id)]; | ||
return this.components[id]; | ||
}; | ||
@@ -95,5 +95,2 @@ Registry.prototype.snapshot = function () { | ||
}; | ||
Registry.prototype.componentId = function (id) { | ||
return id.replace(this.id, ''); | ||
}; | ||
return Registry; | ||
@@ -100,0 +97,0 @@ }()); |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),__assign=function(){return(__assign=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},registryContext=React.createContext({}),RegistryProvider=registryContext.Provider,RegistryConsumer=registryContext.Consumer;function withRegistry(){for(var o=[],t=0;t<arguments.length;t++)o[t]=arguments[t];return function(e){var t=function(t){return React.createElement(RegistryConsumer,null,function(r){var n={};return o.forEach(function(t){var e=r[t.id];n[t.id]=t.inverted?e||t:t||e}),React.createElement(RegistryProvider,{value:n},React.createElement(e,__assign({},t)))})};return t.displayName="RegistryResolver("+o.map(function(t){return t.id}).join(", ")+")",t}}var ComponentRegistryConsumer=function(e){return React.createElement(RegistryConsumer,null,function(t){return e.children(t[e.id].snapshot())})},Registry=function(){function t(t){var e=t.id,r=t.inverted,n=void 0!==r&&r;this.components={},this.id=e,this.inverted=n}return t.prototype.set=function(t,e){return this.components[this.componentId(t)]=e,this},t.prototype.get=function(t){return this.components[this.componentId(t)]},t.prototype.snapshot=function(){return this.components},t.prototype.componentId=function(t){return t.replace(this.id,"")},t}();exports.RegistryConsumer=RegistryConsumer,exports.withRegistry=withRegistry,exports.ComponentRegistryConsumer=ComponentRegistryConsumer,exports.Registry=Registry; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),__assign=function(){return(__assign=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},registryContext=React.createContext({}),RegistryProvider=registryContext.Provider,RegistryConsumer=registryContext.Consumer;function withRegistry(){for(var i=[],t=0;t<arguments.length;t++)i[t]=arguments[t];return function(e){var t=function(t){return React.createElement(RegistryConsumer,null,function(r){var n={};return i.forEach(function(t){var e=r[t.id];n[t.id]=t.inverted?e||t:t||e}),React.createElement(RegistryProvider,{value:n},React.createElement(e,__assign({},t)))})};return t.displayName="RegistryResolver("+i.map(function(t){return t.id}).join(", ")+")",t}}var ComponentRegistryConsumer=function(e){return React.createElement(RegistryConsumer,null,function(t){return e.children(t[e.id].snapshot())})},Registry=function(){function t(t){var e=t.id,r=t.inverted,n=void 0!==r&&r;this.components={},this.id=e,this.inverted=n}return t.prototype.set=function(t,e){return this.components[t]=e,this},t.prototype.get=function(t){return this.components[t]},t.prototype.snapshot=function(){return this.components},t}();exports.RegistryConsumer=RegistryConsumer,exports.withRegistry=withRegistry,exports.ComponentRegistryConsumer=ComponentRegistryConsumer,exports.Registry=Registry; |
@@ -34,3 +34,2 @@ import React, { ComponentType } from 'react'; | ||
snapshot<RT>(): RT; | ||
private componentId; | ||
} |
{ | ||
"name": "@bem-react/di", | ||
"version": "1.3.1-dev.7", | ||
"version": "1.3.1-dev.8", | ||
"description": "BEM React Dependency Injection", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/bem/bem-react/tree/master/packages/di", |
16699
137