import type { CommerceAPIErrorStatusResponse } from '../../../api/commerce/commerce-api-error-response.js'; import type { ChildProduct, Product } from '../../../api/commerce/common/product.js'; import type { Result } from '../../../api/commerce/common/result.js'; import type { CommerceEngine } from '../../../app/commerce-engine/commerce-engine.js'; import { type Controller } from '../../controller/headless-controller.js'; import { type SearchSubControllers } from '../core/sub-controller/headless-sub-controller.js'; /** * The `Search` controller lets you create a commerce search page. * * Example: [search.fn.tsx](https://github.com/coveo/ui-kit/blob/main/samples/headless/search-react/src/components/commerce/search.fn.tsx) * * @group Buildable controllers * @category Search */ export interface Search extends Controller, SearchSubControllers { /** * Executes the first search. */ executeFirstSearch(): void; /** * Finds the specified parent product and the specified child product of that parent, and makes that child the new * parent. The `children` and `totalNumberOfChildren` properties of the original parent are preserved in the new * parent. * * This method is useful when leveraging the product grouping feature to allow users to select nested products. * * For example, if a product has children (such as color variations), you can call this method when the user selects a child * to make that child the new parent product, and re-render the product as such in the storefront. * * **Note:** In the controller state, a product that has children will always include itself as its own child so that * it can be rendered as a nested product, and restored as the parent product through this method as needed. * * @param child The child product that will become the new parent. */ promoteChildToParent(child: ChildProduct): void; /** * A scoped and simplified part of the headless state that is relevant to the `Search` controller. */ state: SearchState; } /** * @group Buildable controllers * @category Search */ export interface SearchState { products: Product[]; results: Result[]; error: CommerceAPIErrorStatusResponse | null; isLoading: boolean; responseId: string; } /** * Options for configuring the `Search` controller. * @group Buildable controllers * @category Search */ export interface SearchOptions { /** * When set to true, fills the `results` field rather than the `products` field * in the response. It may also include Spotlight Content in the results. * @default false */ enableResults?: boolean; } /** * Builds a `Search` controller for the given commerce engine. * @param engine - The commerce engine. * @param options - The configurable `Search` controller options. * @returns A `Search` controller. * * @group Buildable controllers * @category Search */ export declare function buildSearch(engine: CommerceEngine, { enableResults }?: SearchOptions): Search;