UNPKG

@openshift-console/dynamic-plugin-sdk

Version:

Provides core APIs, types and utilities used by dynamic plugins at runtime.

20 lines (19 loc) 764 B
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import * as React from 'react'; const MEMO = {}; const CamelCaseWrap = ({ value, dataTest }) => { if (!value) { return '-'; } if (MEMO[value]) { return MEMO[value]; } // Add word break points before capital letters (but keep consecutive capital letters together). const words = value.match(/[A-Z]+[^A-Z]*|[^A-Z]+/g); const rendered = (_jsx("span", { "data-test": dataTest, children: words.map((word, i) => ( // eslint-disable-next-line react/no-array-index-key _jsxs(React.Fragment, { children: [word, i !== words.length - 1 && _jsx("wbr", {})] }, i))) })); MEMO[value] = rendered; return rendered; }; export default CamelCaseWrap;