import React from 'react';
import { SelectControl } from '@wordpress/components';
import { Option } from '../../types/types';
/**
* Type for SelectGroup
*/
type InlineSelectGroupArgs = {
value: string | string[];
onChange: ( nextValue: string ) => void;
options: Option[];
label: string;
disabled: boolean;
};
/**
* Select component that supports OptGroup.
*
* @param {InlineSelectGroupArgs} args
* @class
*/
const InlineSelectGroup = ( {
value,
onChange,
options,
label,
disabled = false,
}: InlineSelectGroupArgs ) => {
return (
{ label && (
{ label }
) }
{ options.map( ( option: Option, index ) => {
if ( Array.isArray( option.value ) ) {
const optGroupKey =
option.id || `${ option.label }-${ index }`;
return (
);
}
const key =
option.id ||
`${ option.label }-${ option.value }-${ index }`;
return (
);
} ) }
);
};
export default InlineSelectGroup;