import React from "react"; import { MarginProps } from "styled-system"; import { TagProps } from "../../__internal__/utils/helpers/tags"; import { CommonTextboxProps } from "../textbox"; import { ValidationProps } from "../../__internal__/validations"; export interface SearchEvent { target: { name?: string; id?: string; value: string; }; } export type SearchTextboxProps = Pick; export interface SearchListData { /** The value identifying this item */ value: string; /** The display label text */ label: string; /** Optional prefix shown before the label */ labelPrefix?: string; /** Optional subtext shown below the label */ subtext?: string; /** Whether the selected tick icon should be shown for this item. Defaults to false. */ selectedIcon?: boolean; /** Optional leading slot content (e.g. an icon) */ leading?: React.ReactNode; /** Whether the item is disabled */ disabled?: boolean; /** Optional id for the list item element */ id?: string; /** Optional click handler for the item. Receives the mouse event and the item's value. */ onClick?: (event: React.MouseEvent, value: string) => void; } export interface SearchListGroup { /** The heading label for this group, e.g. "Recent" | "Suggested" */ heading: string; /** Optional icon rendered before the heading text */ icon?: React.ReactNode; items: SearchListData[]; } export interface SearchPopoverProps { /** When `true`, renders the new popover menu anchored to the Search input. */ open?: boolean; /** Optional max-height for the dropdown list. Overrides size-based defaults when provided. */ maxHeight?: string; /** Minimum number of characters required before announcing available results. */ minQueryLength?: number; /** Structured list data to render as grouped menu items in the popover. */ listData?: SearchListGroup[]; /** Callback fired when a list item is selected. Receives the item's value. */ onListItemSelect?: (value: string) => void; /** Callback fired when the popover requests to close. */ onClose?: (event?: Event, value?: string) => void; } export interface SearchProps extends Omit, MarginProps, TagProps, SearchTextboxProps, SearchPopoverProps { /** Prop to specify the accessible name of the Search input. To be used when no visible label is provided */ "aria-label"?: string; /** Prop to specify the accessible name of the Search button */ searchButtonAriaLabel?: string; /** Prop for `onChange` events on the Search input */ onChange: (ev: SearchEvent) => void; /** Prop for `onClick` events on the Search button. * `onClick` events are triggered when the Search button is clicked * or when the Search input's cross icon is clicked if the `triggerOnClear` prop is set to `true`. */ onClick?: (ev: SearchEvent) => void; /** Sets whether the `onClick` action should be triggered when the Search cross icon is clicked. */ triggerOnClear?: boolean; /** * @deprecated This prop no longer has any effect. This prop will eventually be removed. * Pass a boolean to render a search Button with default text. * Pass a string to override the text in the search Button * */ searchButton?: boolean | string; /** Data tag prop bag for searchButton */ searchButtonDataProps?: TagProps; /** * @deprecated This prop no longer has any effect. This prop will eventually be removed. Use `inputWidth` instead. * Prop for specifying the width of the Search container. This value is mapped to `inputWidth`. * Leaving the `searchWidth` prop with no value will default the width to '100%' */ searchWidth?: string; /** * Prop for specifying the max-width of the Search input. * Leaving the `maxWidth` prop with no value will default the width to '100%' */ maxWidth?: string; /** @deprecated This prop no longer has any effect. This prop will eventually be removed. */ placeholder?: CommonTextboxProps["placeholder"]; /** Current value */ value: string; /** @deprecated This prop no longer has any effect. This prop will eventually be removed. `variant="dark"` is mapped to `inverse={true}` to preserve legacy behavior. */ variant?: "default" | "dark"; /** @deprecated This prop no longer has any effect. This prop will eventually be removed. Input tabindex */ tabIndex?: number; /** When set to `true`, inverts the Search input and button styling for use on darker backgrounds. */ inverse?: boolean; /** @deprecated This prop no longer has any effect. This prop will eventually be removed. */ warning?: CommonTextboxProps["warning"]; /** @deprecated This prop no longer has any effect. This prop will eventually be removed. */ info?: CommonTextboxProps["info"]; } export type SearchHandle = { /** Programmatically focus the search input. */ focus: () => void; /** Programmatically focus the search button. */ focusButton: () => void; } | null; export declare const Search: React.ForwardRefExoticComponent>; export default Search;