woocommerce/packages/js/components/src/experimental-select-control/utils.ts

21 lines
444 B
TypeScript
Raw Normal View History

/**
* Internal dependencies
*/
import { ItemType, SelectedType } from './types';
export const itemToString = ( item: ItemType | null ) => {
return item ? item.label : '';
};
export const getFilteredItems = (
allItems: ItemType[],
inputValue: string,
selectedItems: ItemType[]
) => {
return allItems.filter(
( item ) =>
selectedItems.indexOf( item ) < 0 &&
item.label.toLowerCase().startsWith( inputValue.toLowerCase() )
);
};