var React = require('react')
var cx = require('classnames')
var PT = React.PropTypes
var SimpleBody = require('../body/simple')
var FlexPanes = require('./flex-panes')
var Listener = require('../../listener')
var FocusItem = React.createClass({
mixins: [
Listener({
storeAttrs: function (getters, props) {
return {
node: getters.getNode(props.id),
isActiveView: getters.isActiveView(),
editState: getters.editState(props.id),
}
},
shouldGetNew: function (nextProps) {
return nextProps.id !== this.props.id || nextProps.store !== this.props.store
},
getListeners: function (props, events) {
return [events.nodeChanged(props.id), events.nodeViewChanged(props.id)]
},
})
],
componentWillMount: function () {
// get plugin update functions
this._plugin_updates = null
this.props.plugins.forEach((plugin) => {
if (!plugin.componentDidUpdate) return
if (!this._plugin_updates) {
this._plugin_updates = [plugin.componentDidUpdate]
} else {
this._plugin_updates.push(plugin.componentDidUpdate)
}
})
},
propTypes: {
id: PT.string.isRequired,
plugins: PT.array,
bodies: PT.object,
isRoot: PT.bool,
},
shouldComponentUpdate: function (nextProps, nextState) {
return (
nextState !== this.state ||
(nextProps.index !== this.props.index && nextState.isActive)
)
},
/** Use to check what things are updating when */
componentDidUpdate: function (prevProps, prevState) {
if (this._plugin_updates) {
this._plugin_updates.map((fn) => fn.call(this, prevProps, prevState))
}
},
// **/
fromMix: function (part) {
if (!this.props.plugins) return
var items = []
for (var i=0; i