@algolia/sitesearch
Version:
Opinionated site search modal for the web. Ships zero-build CDN bundles (JS + CSS) and a one-line init API. Powered by Algolia InstantSearch.
103 lines (102 loc) • 4.39 kB
TypeScript
import * as react_jsx_runtime0 from "react/jsx-runtime";
import * as react_jsx_runtime1 from "react/jsx-runtime";
import { ComponentProps, FC, ReactNode } from "react";
//#region src/components/types.d.ts
interface HitsAttributesMapping {
/** Attribute path (supports dotted path) for the primary line of text */
primaryText: string;
/** Attribute path (supports dotted path) for the secondary line of text */
secondaryText?: string;
/** Attribute path (supports dotted path) for an optional tertiary line */
tertiaryText?: string;
/** Attribute path (supports dotted path) for the URL */
url?: string;
/** Attribute path (supports dotted path) for an optional image URL */
image?: string;
}
//#endregion
//#region src/components/search/search-button.d.ts
interface SearchButtonProps$1 {
onClick: () => void;
darkMode?: boolean;
children?: ReactNode;
}
declare const SearchButton$1: FC<SearchButtonProps$1>;
//#endregion
//#region src/components/search/index.d.ts
interface SearchConfig {
/** Algolia Application ID (required) */
applicationId: string;
/** Algolia API Key (required) */
apiKey: string;
/** Algolia Index Name (required) */
indexName: string;
/** Placeholder text for search input (optional, defaults to "What are you looking for?") */
placeholder?: string;
/** Number of hits per page (optional, defaults to 8) */
hitsPerPage?: number;
/** Custom search button text (optional) */
buttonText?: string;
/** Custom search button props (optional) */
buttonProps?: ComponentProps<typeof SearchButton$1>;
/** Enable dark mode (optional) */
darkMode?: boolean;
/** Map which hit attributes to render (supports dotted paths) */
attributes?: HitsAttributesMapping;
/** Enable Algolia Insights (optional, defaults to true) */
insights?: boolean;
/** Additional Algolia search parameters (optional) - e.g., analytics, filters, distinct, etc. */
searchParameters?: Record<string, unknown>;
/** Open hit URLs in a new tab (optional, defaults to true) */
openResultsInNewTab?: boolean;
/** Transform items before rendering (optional) - useful for proxying images or modifying hit data */
transformItems?: (items: any[]) => any[];
}
declare function SearchExperience(config: SearchConfig): react_jsx_runtime0.JSX.Element;
//#endregion
//#region src/components/search-askai/search-button.d.ts
interface SearchButtonProps {
onClick: () => void;
darkMode?: boolean;
children?: ReactNode;
}
declare const SearchButton: FC<SearchButtonProps>;
//#endregion
//#region src/components/search-askai/index.d.ts
interface SearchWithAskAIConfig {
/** Algolia Application ID (required) */
applicationId: string;
/** Algolia API Key (required) */
apiKey: string;
/** Algolia Index Name (required) */
indexName: string;
/** AI Assistant ID (required for chat functionality) */
assistantId: string;
/** Placeholder text for search input (optional, defaults to "What are you looking for?") */
placeholder?: string;
/** Number of hits per page (optional, defaults to 8) */
hitsPerPage?: number;
/** Custom search button text (optional) */
buttonText?: string;
/** Custom search button props (optional) */
buttonProps?: ComponentProps<typeof SearchButton>;
/** Enable dark mode (optional) */
darkMode?: boolean;
/** Map which hit attributes to render (supports dotted paths) */
attributes?: HitsAttributesMapping;
/** Enable Algolia Insights (optional, defaults to true) */
insights?: boolean;
/** Additional Algolia search parameters (optional) - e.g., analytics, filters, distinct, etc. */
searchParameters?: Record<string, unknown>;
/** Suggested Questions Enabled (optional, defaults to false) */
suggestedQuestionsEnabled?: boolean;
/** Open hit URLs in a new tab (optional, defaults to true) */
openResultsInNewTab?: boolean;
/** Transform items before rendering (optional) - useful for proxying images or modifying hit data */
transformItems?: (items: any[]) => any[];
/** Route Ask AI requests through Agent Studio endpoints (optional, defaults to false). */
agentStudio?: boolean;
}
declare function SearchExperience$1(config: SearchWithAskAIConfig): react_jsx_runtime1.JSX.Element;
//#endregion
export { type HitsAttributesMapping, SearchExperience as Search, type SearchConfig, SearchExperience$1 as SearchWithAskAI, type SearchWithAskAIConfig };