UNPKG

@eccenca/gui-elements

Version:

GUI elements based on other libraries, usable in React application, written in Typescript.

25 lines 1.44 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TextReducer = void 0; const react_1 = __importDefault(require("react")); const reduceToText_1 = require("../../common/utils/reduceToText"); const constants_1 = require("../../configuration/constants"); const Typography_1 = require("./../Typography"); /** * Component to reduce HTML markup content to simple text. * Display can be wrapped easily in `OverflowText`. */ const TextReducer = ({ children, maxNodes, maxLength, useOverflowTextWrapper, overflowTextProps, }) => { if (typeof children === "undefined") { return react_1.default.createElement(react_1.default.Fragment, null); } const shrinkedContent = (0, reduceToText_1.reduceToText)(children, { maxLength, maxNodes }); return useOverflowTextWrapper ? (react_1.default.createElement(Typography_1.OverflowText, Object.assign({}, overflowTextProps, { className: `${constants_1.CLASSPREFIX}-textreducer` + (overflowTextProps && overflowTextProps.className ? ` ${overflowTextProps.className}` : "") }), shrinkedContent)) : (react_1.default.createElement(react_1.default.Fragment, null, shrinkedContent)); }; exports.TextReducer = TextReducer; exports.default = exports.TextReducer; //# sourceMappingURL=TextReducer.js.map