import { FormRenderProps, VariantProps } from '../../../utils'; export interface SearchOption { label: string; value: string | number; [key: string]: any; } /** * Single-select autocomplete that fetches options from a remote API. * * ### Authentication * Prefer `fetchOptions` — a consumer-supplied async function that handles auth * internally and returns `SearchOption[]`. Falls back to `item.api` + * `item.jwtHeader` via axios when `fetchOptions` is not provided. * * ### Pre-selected values (edit mode) * Pass the pre-selected option in `item.options` so the label displays * immediately without a round-trip search. If `item.options` is empty and * `autoFill` is true, the component seeds the search input with the form value * so options load on mount. * * ### API call guard * Searches fire only after `minSearchLength` chars AND after the `debounceMs` * debounce delay — preventing a request per keystroke. * * ### Selected-value tooltip — currently suppressed via `open={false}` * The input is wrapped in a MUI `Tooltip` that would show `resolvedValue.label` * on hover (useful when a narrow column truncates the label). It carries * `placement="top-start"`, `arrow`, `disableInteractive`, and a * `slotProps.popper` block with Popper.js modifiers (`hide` disabled, `offset`, * `preventOverflow`, `flip`) that correctly anchor it to the input even inside * an `overflow: hidden` ancestor (e.g. a table cell in `material-react-table` / * `GenericPaginatedGrid`) — **verified working in Storybook on MUI v7**. * * However, that fix does not reproduce in consumer apps still pinned to * MUI v6 (below our `@mui/material >=7.3.1` peer requirement): the v6 * Popper/Tooltip runtime ignores the modifier configuration and the tooltip * still mis-anchors to the viewport's top-left corner (0,0). Rather than ship * a tooltip that only behaves correctly on some MUI majors, we suppress it at * the prop level — `open={false}` puts MUI's `Tooltip` into fully-controlled * mode so it never opens, while the `` element (and its modifier * config) stays in the tree, deliberately *not removed*. Once the anchoring * fix is confirmed across all supported MUI majors, removing `open={false}` * re-enables the tooltip with no other changes needed. See the * "Tooltip inside a clipped container" Storybook story for the anchoring repro * and the `open={false}` suppression in context. */ declare const SingleSelectSearchApi: ({ props, variant, minSearchLength, debounceMs, fetchOptions, }: { props: FormRenderProps; variant: VariantProps; /** * Minimum characters before the search fires. * Default: `3`. */ minSearchLength?: number; /** * Debounce delay in milliseconds. * Default: `300`. */ debounceMs?: number; /** * Preferred way to load options. Takes precedence over `item.api`. * Receives the current search text and an AbortSignal for cancellation. * * ```tsx * fetchOptions={async (text, signal) => { * const res = await myAuthenticatedApi.search(text, { signal }); * return res.items.map(r => ({ label: r.name, value: r.id })); * }} * ``` */ fetchOptions?: (searchText: string, signal: AbortSignal) => Promise; }) => import("react/jsx-runtime").JSX.Element; export default SingleSelectSearchApi;