UNPKG

@carbon/ibm-products

Version:
68 lines (66 loc) 2.21 kB
/** * Copyright IBM Corp. 2020, 2026 * * 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 { __toESM } from "../../_virtual/_rolldown/runtime.js"; import { require_classnames } from "../../node_modules/classnames/index.js"; import { pkg } from "../../settings.js"; import { getDevtoolsProps } from "../../global/js/utils/devtools.js"; import React from "react"; import PropTypes from "prop-types"; //#region src/components/DelimitedList/DelimitedList.tsx /** * Copyright IBM Corp. 2024, 2024 * * 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 import_classnames = /* @__PURE__ */ __toESM(require_classnames()); const blockClass = `${pkg.prefix}--delimited-list`; const componentName = "DelimitedList"; const defaults = { delimiter: ", ", items: [], truncate: true }; /** * `DelimitedList` converts an array of items into a single line of * comma-separated values. * @deprecated This component is deprecated and will be removed in the next major version. */ const DelimitedList = React.forwardRef(({ className, delimiter = defaults.delimiter, items = defaults.items, truncate = defaults.truncate, ...rest }, ref) => { return /* @__PURE__ */ React.createElement("div", { ...rest, className: (0, import_classnames.default)(blockClass, className, [truncate && `${blockClass}-truncate`]), ref, ...getDevtoolsProps(componentName) }, items.length > 0 ? items.join(delimiter) : "–"); }); /**@ts-ignore*/ DelimitedList.deprecated = { level: "warn", details: `${componentName} is deprecated and will be removed in the next major version` }; DelimitedList.displayName = componentName; DelimitedList.propTypes = { /** * Provide an optional class to be applied to the containing node. */ className: PropTypes.string, /** * The character(s) used to separate the items. */ delimiter: PropTypes.string, /** * Array of items to be listed. */ items: PropTypes.arrayOf(PropTypes.any), /** * Toggle the component's ability to truncate or not. */ truncate: PropTypes.bool }; //#endregion export { DelimitedList };