@elastic/eui
Version:
Elastic UI Component Library
57 lines (56 loc) • 2.15 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["component", "size", "color", "grow", "textAlign", "children", "className"];
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import React from 'react';
import classNames from 'classnames';
import { useEuiMemoizedStyles } from '../../services';
import { EuiTextColor } from './text_color';
import { EuiTextAlign } from './text_align';
import { euiTextStyles } from './text.styles';
import { jsx as ___EmotionJSX } from "@emotion/react";
export var TEXT_SIZES = ['xs', 's', 'm', 'relative'];
export var EuiText = function EuiText(_ref) {
var _ref$component = _ref.component,
component = _ref$component === void 0 ? 'div' : _ref$component,
_ref$size = _ref.size,
size = _ref$size === void 0 ? 'm' : _ref$size,
color = _ref.color,
_ref$grow = _ref.grow,
grow = _ref$grow === void 0 ? true : _ref$grow,
textAlign = _ref.textAlign,
children = _ref.children,
className = _ref.className,
rest = _objectWithoutProperties(_ref, _excluded);
var styles = useEuiMemoizedStyles(euiTextStyles);
var cssStyles = [styles.euiText, !grow ? styles.constrainedWidth : undefined, styles[size]];
var classes = classNames('euiText', className);
var Component = component;
var text = ___EmotionJSX(Component, _extends({
css: cssStyles,
className: classes
}, rest), children);
if (color) {
text = ___EmotionJSX(EuiTextColor, {
component: component,
color: color,
className: classes,
cloneElement: true
}, text);
}
if (textAlign) {
text = ___EmotionJSX(EuiTextAlign, {
component: component,
textAlign: textAlign,
className: classes,
cloneElement: true
}, text);
}
return text;
};