@carbon/react
Version:
React components for the Carbon Design System
30 lines (22 loc) • 1.07 kB
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.
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var invariant = require('invariant');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant);
const itemToString = item => {
!(typeof item.label === 'string') ? process.env.NODE_ENV !== "production" ? invariant__default["default"](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__default["default"](false) : void 0;
return item.label || '';
};
const defaultItemToString = item => {
if (Array.isArray(item)) {
return item.map(itemToString);
}
return itemToString(item);
};
exports.defaultItemToString = defaultItemToString;