UNPKG

@fluentui/react-northstar

Version:
96 lines (94 loc) 3.1 kB
import { imageBehavior } from '@fluentui/accessibility'; import { getElementType, useUnhandledProps, useAccessibility, useFluentContext, useStyles, useTelemetry } from '@fluentui/react-bindings'; import * as PropTypes from 'prop-types'; import * as React from 'react'; import { commonPropTypes, createShorthandFactory } from '../../utils'; import { imageClassName } from '../Image/Image'; export var avatarImageClassName = imageClassName; /** * An AvatarImage is a graphic representation used by Avatar. */ export var AvatarImage = /*#__PURE__*/function () { var AvatarImage = /*#__PURE__*/React.forwardRef(function (props, ref) { var context = useFluentContext(); var _useTelemetry = useTelemetry(AvatarImage.displayName, context.telemetry), setStart = _useTelemetry.setStart, setEnd = _useTelemetry.setEnd; setStart(); var accessibility = props.accessibility, alt = props.alt, ariaLabel = props['aria-label'], avatar = props.avatar, circular = props.circular, className = props.className, design = props.design, fluid = props.fluid, styles = props.styles, variables = props.variables, size = props.size; var getA11Props = useAccessibility(accessibility, { debugName: AvatarImage.displayName, mapPropsToBehavior: function mapPropsToBehavior() { return { alt: alt, 'aria-label': ariaLabel }; }, rtl: context.rtl }); var _useStyles = useStyles(AvatarImage.displayName, { className: avatarImageClassName, mapPropsToStyles: function mapPropsToStyles() { return { avatar: avatar, circular: circular, fluid: fluid, size: size }; }, mapPropsToInlineStyles: function mapPropsToInlineStyles() { return { className: className, design: design, styles: styles, variables: variables }; }, rtl: context.rtl }), classes = _useStyles.classes; var ElementType = getElementType(props); var unhandledProps = useUnhandledProps(AvatarImage.handledProps, props); var result = /*#__PURE__*/React.createElement(ElementType, getA11Props('root', Object.assign({ className: classes.root, ref: ref }, unhandledProps))); setEnd(); return result; }); AvatarImage.displayName = 'AvatarImage'; AvatarImage.defaultProps = { as: 'img', accessibility: imageBehavior }; AvatarImage.propTypes = Object.assign({}, commonPropTypes.createCommon({ children: false, content: false }), { avatar: PropTypes.bool, circular: PropTypes.bool, fluid: PropTypes.bool }); AvatarImage.shorthandConfig = { mappedProp: 'src', allowsJSX: false }; AvatarImage.handledProps = Object.keys(AvatarImage.propTypes); AvatarImage.create = createShorthandFactory({ Component: AvatarImage, mappedProp: 'src', allowsJSX: false }); return AvatarImage; }(); //# sourceMappingURL=AvatarImage.js.map