@carbon/react
Version:
React components for the Carbon Design System
24 lines (19 loc) • 773 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.
*/
;
var invariant = require('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);
};
exports.defaultItemToString = defaultItemToString;