UNPKG

@carbon/ibm-products

Version:
32 lines (30 loc) 1.08 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. */ //#region src/components/InlineTip/utils.js /** * Copyright IBM Corp. 2023, 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. */ const getComponentText = (reactNode) => { const tmpChildren = reactNode?.props?.children || void 0; if (Array.isArray(reactNode)) { let joinedNodes = []; reactNode.forEach((node) => { if (typeof node === "object") joinedNodes.push(getComponentText(node)); else if (typeof node === "string") joinedNodes.push(node); }); return joinedNodes.join(" "); } if (tmpChildren === void 0) if (typeof reactNode === "string") return reactNode; else return " "; if (typeof tmpChildren === "object") return getComponentText(reactNode.props.children); if (typeof tmpChildren === "string") return reactNode.props.children; }; //#endregion exports.getComponentText = getComponentText;