import React, { Component, PropTypes } from 'react'; import { Map } from 'immutable'; import { resolveWidget } from '../Widgets'; import controlStyles from '../ControlPanel/ControlPane.css'; import styles from './ObjectControl.css'; export default class ObjectControl extends Component { static propTypes = { onChange: PropTypes.func.isRequired, onAddAsset: PropTypes.func.isRequired, onRemoveAsset: PropTypes.func.isRequired, getAsset: PropTypes.func.isRequired, value: PropTypes.oneOfType([ PropTypes.node, PropTypes.object, PropTypes.bool, ]), field: PropTypes.object, forID: PropTypes.string, className: PropTypes.string, }; controlFor(field) { const { onAddAsset, onRemoveAsset, getAsset, value, onChange } = this.props; if (field.get('widget') === 'hidden') { return null; } const widget = resolveWidget(field.get('widget') || 'string'); const fieldValue = value && Map.isMap(value) ? value.get(field.get('name')) : value; return (