import React from 'react'; import PropTypes from 'prop-types'; import { ComponentProps } from '../utils/types'; type OptionClickHandler = (event: React.MouseEvent, data: { to?: string; value: string; }) => boolean | void; interface OptionPropsBase { /** @private */ active?: boolean; /** * Additional information to explain the option, such as "Recommended". */ description?: string; /** * The description text may appear to the right of the label or under the label. */ descriptionPosition?: 'right' | 'bottom'; /** * If disabled=true, the option is grayed out and cannot be clicked. */ disabled?: boolean; /** * A React ref which is set to the DOM element when the component mounts and null when it unmounts. */ elementRef?: React.Ref; /** Adornment after the label. */ endAdornment?: React.ReactNode; /** * When provided, `label` is rendered instead of the `value`. */ label?: string; /** * Sections of the label string to highlight as a match. */ matchRanges?: { start: number; end: number; }[]; /** * Callback for click events. * Returning "false" from the callback will prevent the parent Search component from updating its value, * closing the popover, or firing the `onChange` callback. */ onClick?: OptionClickHandler; /** * To open the link in a new window, set `openInNewContext` to `true`. An icon is added * indicating the behavior. */ openInNewContext?: boolean; /** Adornment in front of the label. */ startAdornment?: React.ReactNode; /** * The URL or path to link to. */ to?: string; /** * When `true`, wrapping is disabled and any additional text is ellipsised. */ truncate?: boolean; /** * The value of this option and the label shown for it. */ value: string; } type OptionProps = ComponentProps; /** * An option within a `Search`. */ declare function Option({ active, description, descriptionPosition, disabled, elementRef, endAdornment, label, matchRanges, onClick, openInNewContext, startAdornment, to, truncate, value, ...otherProps }: OptionProps): React.JSX.Element; declare namespace Option { var propTypes: { /** @private */ active: PropTypes.Requireable; description: PropTypes.Requireable; descriptionPosition: PropTypes.Requireable; disabled: PropTypes.Requireable; elementRef: PropTypes.Requireable; endAdornment: PropTypes.Requireable; label: PropTypes.Requireable; matchRanges: PropTypes.Requireable<(PropTypes.InferProps<{ start: PropTypes.Validator; end: PropTypes.Validator; }> | null | undefined)[]>; onClick: PropTypes.Requireable<(...args: any[]) => any>; openInNewContext: PropTypes.Requireable; startAdornment: PropTypes.Requireable; to: PropTypes.Requireable; truncate: PropTypes.Requireable; value: PropTypes.Validator; }; var as: string; } export default Option; export { OptionClickHandler };