import type { SearchEngine } from '../../../app/search-engine/search-engine.js'; import { type Controller } from '../../controller/headless-controller.js'; import type { FacetValue } from '../facet/headless-facet.js'; import { type AutomaticFacetGeneratorOptions } from './headless-automatic-facet-generator-options.js'; export type { AutomaticFacetGeneratorOptions }; /** * The `AutomaticFacetGenerator` headless controller offers a high-level interface for rendering automatic facets. * * Unlike regular facets that need to be explicitly defined and requested in the query, automatic facets are dynamically * generated by the index in response to the query. * * To learn more about the automatic facet generator feature, see: [About the Facet Generator](https://docs.coveo.com/en/n9sd0159/). * * Examples: * - [automatic-facet-generator.fn.tsx](https://github.com/coveo/ui-kit/blob/main/samples/headless/search-react/src/components/automatic-facet-generator/automatic-facet-generator.fn.tsx) * - [automatic-facet-generator.class.tsx](https://github.com/coveo/ui-kit/blob/main/samples/headless/search-react/src/components/automatic-facet-generator/automatic-facet-generator.class.tsx) * * @group Controllers * @category AutomaticFacetGenerator */ export interface AutomaticFacetGenerator extends Controller { /** * The state of the `AutomaticFacetGenerator` controller. */ state: AutomaticFacetGeneratorState; } /** * A scoped and simplified part of the headless state that is relevant to the `AutomaticFacetGenerator` controller. * * @group Controllers * @category AutomaticFacetGenerator */ export interface AutomaticFacetGeneratorState { /** * The list of automatic facet controllers. */ automaticFacets: AutomaticFacet[]; } export interface AutomaticFacetGeneratorProps { /** * The options for the `AutomaticFacetGenerator` controller. * */ options: AutomaticFacetGeneratorOptions; } /** * A scoped and simplified part of the headless state that is relevant to the `Automatic Facet` controller. * * @group Controllers * @category AutomaticFacetGenerator */ export interface AutomaticFacetState { /** * The automatic facet field. */ field: string; /** * The automatic facet label. */ label: string; /** * The automatic facet values. */ values: FacetValue[]; } /** * The `AutomaticFacet` controller allows you to create a search interface component that the end user * can interact with to refine a query by selecting filters based on item metadata (that is, field values). Unlike regular facets that * need to be explicitly defined and requested in the query, automatic facets are dynamically generated by the index * in response to the query. * * To learn more about the automatic facet generator feature, see: [About the Facet Generator](https://docs.coveo.com/en/n9sd0159/). * * @group Controllers * @category AutomaticFacetGenerator */ export interface AutomaticFacet extends Controller { /** * Toggles the specified automatic facet value. * * @param selection - The facet value to toggle. */ toggleSelect(selection: FacetValue): void; /** * Deselects all automatic facet values. * */ deselectAll(): void; /** * The state of the `AutomaticFacet` controller. */ state: AutomaticFacetState; } /** * Creates a `AutomaticFacetGenerator` instance. * * @param engine - The headless engine. * @param props - The automatic facets props. * @returns A `AutomaticFacetGenerator` controller instance. * * @group Controllers * @category AutomaticFacetGenerator */ export declare function buildAutomaticFacetGenerator(engine: SearchEngine, props: AutomaticFacetGeneratorProps): AutomaticFacetGenerator;