2019-12-03 13:39:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* External dependencies
|
|
|
|
|
*/
|
|
|
|
|
import { __, sprintf } from '@wordpress/i18n';
|
|
|
|
|
|
|
|
|
|
const DropdownSelectorSelectedChip = ( { onRemoveItem, option } ) => {
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
className="wc-block-dropdown-selector__selected-chip"
|
2019-12-05 13:58:44 +00:00
|
|
|
|
onClick={ () => {
|
2019-12-03 13:39:11 +00:00
|
|
|
|
onRemoveItem( option.value );
|
|
|
|
|
} }
|
|
|
|
|
onKeyDown={ ( e ) => {
|
|
|
|
|
if ( e.key === 'Backspace' || e.key === 'Delete' ) {
|
|
|
|
|
onRemoveItem( option.value );
|
|
|
|
|
}
|
|
|
|
|
} }
|
|
|
|
|
aria-label={ sprintf(
|
|
|
|
|
__( 'Remove %s filter', 'woo-gutenberg-products-block' ),
|
|
|
|
|
option.name
|
|
|
|
|
) }
|
|
|
|
|
>
|
2019-12-05 13:58:44 +00:00
|
|
|
|
<span className="wc-block-dropdown-selector__selected-chip__label">
|
|
|
|
|
{ option.label }
|
|
|
|
|
</span>
|
2019-12-03 13:39:11 +00:00
|
|
|
|
<span className="wc-block-dropdown-selector__selected-chip__remove">
|
|
|
|
|
𝘅
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default DropdownSelectorSelectedChip;
|