import { createElement, Component, useState, useRef, useContext, } from '@wordpress/element' import OutsideClickHandler from './react-outside-click-handler' import classnames from 'classnames' import ColorPicker, { ColorPickerContext } from './ct-color-picker' import { __ } from 'ct-i18n' const clamp = (min, max, value) => Math.max(min, Math.min(max, value)) const Border = ({ value, option, onChange }) => { const [isOpen, setIsOpen] = useState(false) const { modalWrapper } = useContext(ColorPickerContext) return (
onChange({ ...value, width: clamp(1, 5, parseInt(width, 10) || 1), }) } /> setIsOpen(!isOpen)}> {value.inherit ? __('Inherit', 'blc') : value.style === 'none' ? value.style : null} { if (!isOpen) return setIsOpen(false) }}>
    {['solid', 'dashed', 'dotted', 'none'] .reduce( (current, el, index) => [ ...current.slice( 0, index % 2 === 0 ? undefined : -1 ), ...(index % 2 === 0 ? [[el]] : [ [ current[ current.length - 1 ][0], el, ], ]), ], [] ) .map((group) => (
  • {group.map((style) => ( { onChange({ ...value, style, ...(Object.keys( option.value ).indexOf('inherit') > -1 ? { inherit: false, } : {}), }) setIsOpen(false) }} data-style={style}> {style === 'none' ? style : null} ))}
  • ))}
onChange({ ...value, color: colorValue.default, }) } option={{ pickers: [ { id: 'default', title: 'Initial', }, ], }} value={{ default: value.color, }} />
) } Border.ControlEnd = () =>
Border.ControlEnd = () => { const { modalWrapper } = useContext(ColorPickerContext) return
} Border.MetaWrapper = ({ getActualOption }) => { const ref = useRef() return ( {getActualOption()} ) } export default Border