diff --git a/lib/components.js b/lib/components.js
index 1e2a791..4246f9e 100644
--- a/lib/components.js
+++ b/lib/components.js
@@ -43,12 +43,14 @@ var Layer = exports.Layer = function Layer() {var namespace = arguments.length >
_react2.default.createClass({
componentWillMount: function componentWillMount() {
this.props.register(this.props.id, this.props.children, this.props.mountPointId);
- if (this.props.showInitially) {
- this.props.show(this.props.id, this.props.defaultArgs || []);
+ if (this.props.showInitially) {var _props;
+ (_props = this.props).show.apply(_props, [this.props.id].concat(_toConsumableArray(this.props.initialArgs || [])));
+ } else {var _props2;
+ (_props2 = this.props).setArgs.apply(_props2, [this.props.id].concat(_toConsumableArray(this.props.initialArgs || [])));
}
},
- shouldComponentUpdate: function shouldComponentUpdate(newProps) {var _props =
- this.props;var use = _props.use;var children = _props.children;var register = _props.register;var id = _props.id;var mountPointId = _props.mountPointId;
+ shouldComponentUpdate: function shouldComponentUpdate(newProps) {var _props3 =
+ this.props;var use = _props3.use;var children = _props3.children;var register = _props3.register;var id = _props3.id;var mountPointId = _props3.mountPointId;
var needUpdate = false;
if (id !== newProps.id || mountPointId !== newProps.mountPointId) {
needUpdate = true;
@@ -93,12 +95,12 @@ var LayerContext = exports.LayerContext = function LayerContext() {var namespace
{var children = _ref2.children;var id = _ref2.id;var displaying = _ref2.displaying;var show = _ref2.show;var hide = _ref2.hide;var hideAll = _ref2.hideAll;var views = _ref2.views;
- return children({
+ return children.apply(undefined, [{
show: show, hide: hide, hideAll: hideAll, displaying: displaying, views: views,
isActive: displaying.indexOf(id) !== -1,
showMe: function showMe() {for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {args[_key3] = arguments[_key3];}return show.apply(undefined, [id].concat(args));},
showOnlyMe: function showOnlyMe() {for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {args[_key4] = arguments[_key4];}return hideAll() || show.apply(undefined, [id].concat(args));},
- hideMe: function hideMe() {return hide(id);} });
-
+ hideMe: function hideMe() {return hide(id);} }].concat(_toConsumableArray(
+ views[id].args)));
});};
//# sourceMappingURL=components.js.map
\ No newline at end of file
diff --git a/lib/components.js.map b/lib/components.js.map
index 00b3fa7..a2b0b2a 100644
--- a/lib/components.js.map
+++ b/lib/components.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../src/components.js"],"names":["LayerStackMountPoint","namespace","store","dispatch","mountPointId","id","mountPointArgs","args","renderFn","views","displaying","show","hide","hideAll","length","map","index","view","showOnlyMe","hideMe","showMe","Error","Layer","createClass","componentWillMount","props","register","children","showInitially","defaultArgs","shouldComponentUpdate","newProps","use","needUpdate","toString","i","JSON","stringify","componentWillUnmount","render","LayerContext","isActive","indexOf"],"mappings":"2JAAA,8B;AACA;AACA;;AAEA,oC;;AAEO,IAAMA,sDAAuB,SAAvBA,oBAAuB,QAACC,SAAD,uEAAa,aAAb,QAA+B;AACjE,YAACC,KAAD,UAAWA,MAAMD,SAAN,CAAX,EADiE;AAEjE,8BAAY,iDAA4BE,QAA5B,CAAZ,EAFiE;AAGjE;;;AAGI,OAFAC,YAEA,QAFJC,EAEI,KAFoBC,cAEpB,QAFcC,IAEd,KADJC,QACI,QADJA,QACI,KADMC,KACN,QADMA,KACN,KADaC,UACb,QADaA,UACb,KADyBC,IACzB,QADyBA,IACzB,KAD+BC,IAC/B,QAD+BA,IAC/B,KADqCC,OACrC,QADqCA,OACrC;AACJ;AACE,sDAAQL,WAAWA,SAAS,EAACC,YAAD,EAAQC,sBAAR,EAAoBC,UAApB,EAA0BC,UAA1B,EAAgCC,gBAAhC,EAAyCT,0BAAzC,EAAuDE,8BAAvD,EAAT,CAAX,CAA4F;AAA5F,UACHI,WAAWI,MAAX,GAAoBJ,WAAWK,GAAX,CAAgB,UAACV,EAAD,EAAKW,KAAL,UAAe;AACpD,mDAAK,KAAKX,EAAV;AACI,0BAAM;AACN,oBAAMY,OAAOR,MAAMJ,EAAN,CAAb;AACA,oBAAIY,QAAQA,KAAKT,QAAb,IAAyBS,KAAKb,YAAL,K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,SAAN,CAAX,EADyD;AAEzD,8BAAY,iDAA4BE,QAA5B,CAAZ,EAFyD;AAGzD;;;AAGI,OAFJwB,QAEI,SAFJA,QAEI,KAFMtB,EAEN,SAFMA,EAEN,KADJK,UACI,SADJA,UACI,KADQC,IACR,SADQA,IACR,KADcC,IACd,SADcA,IACd,KADoBC,OACpB,SADoBA,OACpB,KAD6BJ,KAC7B,SAD6BA,KAC7B;AACJ,WAAOkB,SAAS;AACdhB,gBADc,EACRC,UADQ,EACFC,gBADE,EACOH,sBADP,EACmBD,YADnB;AAEdgC,gBAAU/B,WAAWgC,OAAX,CAAmBrC,EAAnB,MAA2B,CAAC,CAFxB;AAGde,cAAQ,sDAAIb,IAAJ,qDAAIA,IAAJ,mCAAaI,uBAAKN,EAAL,SAAYE,IAAZ,EAAb,EAHM;AAIdW,kBAAY,0DAAIX,IAAJ,qDAAIA,IAAJ,mCAAaM,aAAaF,uBAAKN,EAAL,SAAYE,IAAZ,EAA1B,EAJE;AAKdY,cAAQ,0BAAMP,KAAKP,EAAL,CAAN,EALM,EAAT,CAAP;;AAOD,GAd0D,CAA/B,EAArB","file":"components.js","sourcesContent":["import React, { PropTypes } from 'react'\nimport { connect } from 'react-redux'\nimport { bindActionCreators } from 'redux'\n\nimport { ACTIONS } from './reducer'\n\nexport const LayerStackMountPoint = (namespace = 'layer_stack') => connect(\n (store) => store[namespace],\n dispatch => bindActionCreators(ACTIONS, dispatch)\n)(({\n id: mountPointId, args: mountPointArgs, // from props\n renderFn, views, displaying, show, hide, hideAll // from store\n}) => {\n return (\n
{ renderFn ? renderFn({views, displaying, show, hide, hideAll, mountPointId, mountPointArgs}) // it's possible to provide alternative renderFn for the MountPoint\n : (displaying.length ? displaying.map ((id, index) => // if no alternative renderFn provided we'll use the default one\n
\n {(() => {\n const view = views[id];\n if (view && view.renderFn && view.mountPointId === mountPointId) {\n return view.renderFn({\n index, id, show, hide, hideAll, displaying, views, mountPointArgs, // seems like there is no valid use-case mountPointId in the Layer render function\n showOnlyMe: (...args) => hideAll() || show(id, ...args), // TODO: think about improvement\n hideMe: () => hide(id), // intention here is to hide ID's management from Layer and let app developer manage these IDs independently\n // which will give an ability to write general-purpose Layers and share them b/w projects\n showMe: (...args) => show(id, ...args) // sometimes you may want to change args of the current layer\n }, ...view.args)\n }\n if (typeof view === 'undefined' || typeof view.renderFn === 'undefined') {\n throw new Error(`\nIt seems like you're using LayerContext with id=\"${ id }\" but corresponding Layer isn't declared in the current Components tree.\nMake sure that Layer with id=\"${ id }\" is rendered into the current tree.\n`)\n }})()}\n
{ renderFn ? renderFn({views, displaying, show, hide, hideAll, mountPointId, mountPointArgs}) // it's possible to provide alternative renderFn for the MountPoint\n : (displaying.length ? displaying.map ((id, index) => // if no alternative renderFn provided we'll use the default one\n
\n {(() => {\n const view = views[id];\n if (view && view.renderFn && view.mountPointId === mountPointId) {\n return view.renderFn({\n index, id, show, hide, hideAll, displaying, views, mountPointArgs, // seems like there is no valid use-case mountPointId in the Layer render function\n showOnlyMe: (...args) => hideAll() || show(id, ...args), // TODO: think about improvement\n hideMe: () => hide(id), // intention here is to hide ID's management from Layer and let app developer manage these IDs independently\n // which will give an ability to write general-purpose Layers and share them b/w projects\n showMe: (...args) => show(id, ...args) // sometimes you may want to change args of the current layer\n }, ...view.args)\n }\n if (typeof view === 'undefined' || typeof view.renderFn === 'undefined') {\n throw new Error(`\nIt seems like you're using LayerContext with id=\"${ id }\" but corresponding Layer isn't declared in the current Components tree.\nMake sure that Layer with id=\"${ id }\" is rendered into the current tree.\n`)\n }})()}\n