import { createElement, useMemo, useRef, useEffect, useContext } from '@wordpress/element' import OptionsPanel from '../OptionsPanel' import { normalizeCondition, matchValuesWithCondition } from 'match-conditions' import { useDeviceManagerState, useDeviceManagerActions } from '../../customizer/components/useDeviceManager' import { capitalizeFirstLetter, optionWithDefault } from '../GenericOptionType' import deepEqual from 'deep-equal' import ResponsiveControls from '../../customizer/components/responsive-controls' import { ColorPickerContext } from '../options/ct-color-picker' import { getOptionLabelFor } from '../helpers/get-label' const SingleChoice = ({ singleChoice, groupOption, purpose, onChange, value, hasRevertButton, parentValue }) => { const ref = useRef() return (
{singleChoice.label && } {groupOption.options[singleChoice.id].type === 'ct-background' && (
e.stopPropagation()} onMouseUp={e => e.stopPropagation()} onClick={e => e.stopPropagation()} /> )} {['ct-color-picker', 'ct-border', 'ct-box-shadow'].includes( groupOption.options[singleChoice.id].type ) &&
}
) } const LabeledGroup = ({ renderingChunk, value, onChange, purpose, parentValue, hasRevertButton }) => { const { currentView } = useDeviceManagerState() const { setDevice } = useDeviceManagerActions() return renderingChunk.map(groupOption => { let valueForCondition = null if (!valueForCondition) { valueForCondition = { ...value, wp_customizer_current_view: currentView } } const totalAmountofMatched = groupOption.choices.filter(singleChoice => singleChoice.condition ? matchValuesWithCondition( normalizeCondition(singleChoice.condition), valueForCondition ) : true ) let maybeLabel = getOptionLabelFor({ id: groupOption.id, option: groupOption, values: value }) if (totalAmountofMatched.length === 0) { return null } if (totalAmountofMatched.length === 1) { return ( ) } return (
{maybeLabel && }
{totalAmountofMatched.map(singleChoice => ( ))}
) }) } export default LabeledGroup