import { useInstanceId } from '@wordpress/compose'; import classnames from 'classnames'; import React from 'react'; import { useDeviceType } from '../../hooks/useDeviceType'; import DeviceSelector from '../device-selector'; import { Icon } from '../index'; import './editor.scss'; interface Props { value: number | string | object; options: { icon: string; value: any; label: string }[]; onChange: CallableFunction; label?: string; responsive?: boolean; inline?: boolean; hasLabel?: boolean; } const AdvanceSelect: React.FC = (props) => { const { value = {}, onChange, responsive = false, label, options, inline = false, hasLabel = false, } = props; const id = useInstanceId(AdvanceSelect); const [deviceType] = useDeviceType(); return (
{label && ( )} {responsive && }
{responsive ? ['desktop', 'tablet', 'mobile'].map( (device) => deviceType === device && options.map((option) => (
{hasLabel && option.hasOwnProperty('label') ? ( ) : ( '' )}
)), ) : options.map((option) => (
{hasLabel && option.hasOwnProperty('label') ? ( ) : ( '' )}
))}
); }; export default AdvanceSelect;