UNPKG

@fluentui/react-northstar

Version:
108 lines (106 loc) 3.65 kB
import * as customPropTypes from '@fluentui/react-proptypes'; import * as PropTypes from 'prop-types'; import * as React from 'react'; import { childrenExist, createShorthandFactory, commonPropTypes, rtlTextContainer } from '../../utils'; import { getElementType, useUnhandledProps, useFluentContext, useAccessibility, useStyles, useTelemetry } from '@fluentui/react-bindings'; export var textClassName = 'ui-text'; /** * A Text consistently styles and formats occurrences of text. */ export var Text = /*#__PURE__*/function () { var Text = /*#__PURE__*/React.forwardRef(function (props, ref) { var context = useFluentContext(); var _useTelemetry = useTelemetry(Text.displayName, context.telemetry), setStart = _useTelemetry.setStart, setEnd = _useTelemetry.setEnd; setStart(); var accessibility = props.accessibility, align = props.align, atMention = props.atMention, children = props.children, className = props.className, color = props.color, content = props.content, design = props.design, disabled = props.disabled, error = props.error, important = props.important, size = props.size, styles = props.styles, success = props.success, timestamp = props.timestamp, truncated = props.truncated, temporary = props.temporary, variables = props.variables, weight = props.weight; var getA11Props = useAccessibility(accessibility, { debugName: Text.displayName, rtl: context.rtl }); var _useStyles = useStyles(Text.displayName, { className: textClassName, mapPropsToStyles: function mapPropsToStyles() { return { atMention: atMention, color: color, important: important, timestamp: timestamp, truncated: truncated, disabled: disabled, error: error, success: success, temporary: temporary, align: align, weight: weight, size: size }; }, mapPropsToInlineStyles: function mapPropsToInlineStyles() { return { className: className, design: design, styles: styles, variables: variables }; }, rtl: context.rtl }), classes = _useStyles.classes; var unhandledProps = useUnhandledProps(Text.handledProps, props); var ElementType = getElementType(props); var element = /*#__PURE__*/React.createElement(ElementType, getA11Props('root', Object.assign({ className: classes.root, ref: ref }, rtlTextContainer.getAttributes({ forElements: [children, content] }), unhandledProps)), childrenExist(children) ? children : content); setEnd(); return element; }); Text.displayName = 'Text'; Text.defaultProps = { as: 'span' }; Text.propTypes = Object.assign({}, commonPropTypes.createCommon({ color: true }), { atMention: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['me'])]), disabled: PropTypes.bool, error: PropTypes.bool, important: PropTypes.bool, size: customPropTypes.size, weight: PropTypes.oneOf(['light', 'semilight', 'regular', 'semibold', 'bold']), success: PropTypes.bool, temporary: PropTypes.bool, align: customPropTypes.align, timestamp: PropTypes.bool, truncated: PropTypes.bool }); Text.handledProps = Object.keys(Text.propTypes); Text.create = createShorthandFactory({ Component: Text, mappedProp: 'content' }); return Text; }(); //# sourceMappingURL=Text.js.map