import { CheckboxControl } from '@wordpress/components'; import classNames from 'classnames'; export const PayPalCheckbox = ( { currentValue, label, value, checked = null, disabled = null, changeCallback, } ) => { let isChecked = checked; if ( null === isChecked ) { if ( Array.isArray( currentValue ) ) { isChecked = currentValue.includes( value ); } else { isChecked = currentValue; } } const className = classNames( { 'is-disabled': disabled } ); const onChange = ( newState ) => { let newValue; if ( ! Array.isArray( currentValue ) ) { newValue = newState; } else if ( newState ) { newValue = [ ...currentValue, value ]; } else { newValue = currentValue.filter( ( optionValue ) => optionValue !== value ); } changeCallback( newValue ); }; return ( ); }; export const CheckboxGroup = ( { options, value, onChange } ) => ( <> { options.map( ( checkbox ) => ( ) ) } ); export const PayPalRdb = ( { id, name, value, currentValue, handleRdbState, } ) => { return (
{ /* todo: Can we remove the wrapper div? */ } handleRdbState( value ) } />
); }; export const PayPalRdbWithContent = ( { className, id, name, label, description, value, currentValue, handleRdbState, toggleAdditionalContent, children, } ) => { const wrapperClasses = classNames( 'ppcp-r__radio-wrapper', className ); return (
{ description && (

) }

{ toggleAdditionalContent && children && value === currentValue && (
{ children }
) }
); };