@zohodesk/components
Version:
Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development
73 lines (57 loc) • 3.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _defaultProps = require("./props/defaultProps");
var _propTypes = require("./props/propTypes");
var _cssJSLogic2 = _interopRequireDefault(require("./css/cssJSLogic"));
var _utils = require("@zohodesk/utils");
var _textHighlighter = require("./utils/textHighlighter");
var _TypographyModule = _interopRequireDefault(require("./css/Typography.module.css"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var Typography = function Typography(props) {
var children = props.children,
as = props.as,
$ui_tagName = props.$ui_tagName,
dataTitle = props.dataTitle,
$i18n_dataTitle = props.$i18n_dataTitle,
testId = props.testId,
customId = props.customId,
tagAttributes = props.tagAttributes,
$tagAttributes_text = props.$tagAttributes_text,
a11yAttributes = props.a11yAttributes,
$a11yAttributes_text = props.$a11yAttributes_text,
customStyle = props.customStyle,
highlightConfig = props.highlightConfig,
$ui_highlightConfig = props.$ui_highlightConfig;
var style = (0, _utils.mergeStyle)(_TypographyModule["default"], customStyle);
var _cssJSLogic = (0, _cssJSLogic2["default"])({
props: props,
style: style
}),
typographyClass = _cssJSLogic.typographyClass;
var finalTagName = as !== undefined ? as : $ui_tagName;
var finalA11yAttributes = a11yAttributes !== undefined ? a11yAttributes : $a11yAttributes_text;
var finalTagAttributes = tagAttributes !== undefined ? tagAttributes : $tagAttributes_text;
var finalDataTitle = dataTitle !== undefined ? dataTitle : $i18n_dataTitle;
var finalHighlightConfig = highlightConfig !== undefined ? highlightConfig : $ui_highlightConfig;
var _finalHighlightConfig = finalHighlightConfig.data,
highlightData = _finalHighlightConfig === void 0 ? [] : _finalHighlightConfig;
return /*#__PURE__*/_react["default"].createElement(finalTagName, _objectSpread(_objectSpread({
className: typographyClass,
'data-title': finalDataTitle,
'data-id': customId,
'data-test-id': testId
}, finalTagAttributes), finalA11yAttributes), highlightData && highlightData.length > 0 && typeof children === 'string' ? (0, _textHighlighter.highlightText)(_objectSpread(_objectSpread({}, finalHighlightConfig), {}, {
text: children
})) : children);
};
Typography.propTypes = _propTypes.propTypes;
Typography.defaultProps = _defaultProps.defaultProps;
var _default = Typography;
exports["default"] = _default;