import cx from "classnames"; import React, { forwardRef } from "react"; import TextField from "../TextField/TextField"; import useMergeRef from "../../hooks/useMergeRef"; import { SearchDefaultIconNames, SearchType } from "./SearchConstants"; import CloseIcon from "../Icon/Icons/components/CloseSmall"; import SearchIcon from "../Icon/Icons/components/Search"; import { NOOP } from "../../utils/function-utils"; import { SubIcon, VibeComponentProps, VibeComponent, withStaticProps } from "../../types"; import { TextFieldTextType } from "../TextField/TextFieldConstants"; import { BASE_SIZES } from "../../constants"; import { ComponentDefaultTestId, getTestId } from "../../tests/test-ids-utils"; import styles from "./LegacySearch.module.scss"; export interface SearchProps extends VibeComponentProps { secondaryIconName?: SubIcon; iconName?: SubIcon; onChange?: (value: string) => void; autoFocus?: boolean; value?: string; placeholder?: string; disabled?: boolean; debounceRate?: number; onBlur?: (event: React.FocusEvent) => void; onFocus?: (event: React.FocusEvent) => void; wrapperClassName?: string; setRef?: () => void; autoComplete?: string; /* BASE_SIZES is exposed on the component itself */ size?: (typeof BASE_SIZES)[keyof typeof BASE_SIZES]; /* TYPES is exposed on the component itself */ type?: SearchType; validation?: | { status: "error" | "success"; text: string; } | { text: string }; inputAriaLabel?: string; searchResultsContainerId?: string; activeDescendant?: string; /* Icon names labels for a11y */ iconNames?: { layout: string; primary: string; secondary: string; }; /** shows loading animation */ loading?: boolean; } const LegacySearch: VibeComponent & { sizes?: typeof BASE_SIZES; types?: typeof SearchType; } = forwardRef( ( { secondaryIconName = CloseIcon, iconName = SearchIcon, onChange = NOOP, autoFocus = false, value = "", placeholder = "", disabled = false, debounceRate = 200, onBlur = NOOP, onFocus = NOOP, wrapperClassName = "", setRef = NOOP, autoComplete = "off", size = BASE_SIZES.MEDIUM, type = SearchType.SQUARE, className, id = "search", validation = null, inputAriaLabel, searchResultsContainerId = "", activeDescendant = "", iconNames = SearchDefaultIconNames, loading = false, "data-testid": dataTestId }, ref ) => { const mergedRef = useMergeRef(ref, setRef); return ( ); } ); export default withStaticProps(LegacySearch, { sizes: BASE_SIZES, types: SearchType });