@carbon/react
Version:
React components for the Carbon Design System
22 lines (18 loc) • 736 B
JavaScript
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import invariant from 'invariant';
const itemToString = item => {
!(typeof item.label === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, '[MultiSelect] the default `itemToString` method expected to receive ' + 'an item with a `label` field of type `string`. Instead received: `%s`', typeof item.label) : invariant(false) : void 0;
return item.label || '';
};
const defaultItemToString = item => {
if (Array.isArray(item)) {
return item.map(itemToString);
}
return itemToString(item);
};
export { defaultItemToString };