import { createElement, Component, Fragment } from '@wordpress/element' import SinglePicker from './color-picker/single-picker.js' import './color-picker/quick-color-picker.js' import OutsideClickHandler from './react-outside-click-handler' import { normalizeCondition, matchValuesWithCondition } from 'match-conditions' class ColorPicker extends Component { static ControlEnd = () => (
{ e.stopPropagation() }} onMouseUp={e => { e.stopPropagation() }} /> ) state = { isPicking: null, isTransitioning: null } render() { return ( this.setState({ isPicking: null, isTransitioning: this.state.isPicking }) }> {this.props.option.pickers .filter( picker => !picker.condition || matchValuesWithCondition( normalizeCondition(picker.condition), this.props.values ) ) .map(picker => ( this.setState({ isTransitioning: picker.id, isPicking }) } stopTransitioning={() => this.setState({ isTransitioning: false }) } onChange={newPicker => this.props.onChange({ ...this.props.value, [picker.id]: newPicker }) } value={ this.props.value[picker.id] || this.props.option.value[picker.id] } /> ))} ) } } export default ColorPicker