import React from 'react'; import PropTypes from 'prop-types'; import { ComponentProps } from '../utils/types'; /** @public */ type MonogramClickHandler = (event: React.MouseEvent, data: { name?: string; }) => void; type MonogramSize = 'small' | 'medium' | 'large' | number; interface MonogramPropsBase { /** * All CSS color definitions are supported, such as `#223344` or `red`. * If set to `auto` the background color is derived from the `initials` prop. * Using `theme` enables the theme default. */ backgroundColor?: string; /** A React ref which is set to the DOM element when the component mounts and `null` when it unmounts. */ elementRef?: React.Ref; /** The contents of this `Monogram`. Must not exceed three characters in length. */ initials: string; /** * The name is returned with `onClick` events, which can be used to identify the * control when multiple controls share an `onClick` callback. Not to be confused with `initials`. */ name?: string; /** Enables interactive mode. */ onClick?: MonogramClickHandler; /** Adjusts the size of the `Monogram`. */ size?: MonogramSize; } type MonogramInteractiveProps = ComponentProps & { elementRef?: React.Ref; onClick: MonogramClickHandler; }; type MonogramNonInteractiveProps = ComponentProps & { elementRef?: React.Ref; onClick?: never; }; type MonogramProps = MonogramInteractiveProps | MonogramNonInteractiveProps; /** * Returns a suitable set of initials for a name. Uses the first character of each * name segment and omits middle segments if the segment count is greater than three. * @param {string} name - The full name. * @returns {string} Limited to three characters. Empty if `name` is empty. * @public */ declare function getInitials(name: string): string; /** * @deprecated * Monogram has been deprecated and will be removed in a future major version. Use Avatar instead. */ declare function Monogram({ backgroundColor, initials, size, ...otherProps }: MonogramProps): React.JSX.Element; declare namespace Monogram { var propTypes: { backgroundColor: PropTypes.Requireable; elementRef: PropTypes.Requireable; initials: PropTypes.Validator; name: PropTypes.Requireable; onClick: PropTypes.Requireable<(...args: any[]) => any>; size: PropTypes.Requireable>; }; } export default Monogram; export { getInitials, MonogramClickHandler };