@docsearch/react 5.0.0-beta.2 → 5.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/esm/{AskAiScreenState-Bw2WIgv_.d.ts → AskAiScreenState-Sqbn60f2.d.ts} +2 -2
  2. package/dist/esm/{DocSearch-CVj6U-nI.d.ts → DocSearch-BVqxFxTw.d.ts} +18 -27
  3. package/dist/esm/{DocSearchAskAiModal-BczGFkvR.js → DocSearchAskAiModal-ByqIW5ZA.js} +56 -31
  4. package/dist/esm/DocSearchAskAiModal-ByqIW5ZA.js.map +1 -0
  5. package/dist/esm/{DocSearchAskAiModal-MF2py4NM.d.ts → DocSearchAskAiModal-DpB7pLCC.d.ts} +4 -4
  6. package/dist/esm/{DocSearchModal-D_tfhoN1.js → DocSearchModal-CITTG0fe.js} +10 -8
  7. package/dist/esm/DocSearchModal-CITTG0fe.js.map +1 -0
  8. package/dist/esm/askaiModal.d.ts +1 -1
  9. package/dist/esm/askaiModal.js +1 -1
  10. package/dist/esm/docsearchAi.d.ts +10 -102
  11. package/dist/esm/docsearchAi.js +1 -1
  12. package/dist/esm/docsearchAi.js.map +1 -1
  13. package/dist/esm/index.d.ts +4 -4
  14. package/dist/esm/index.js +2 -2
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/modal.d.ts +1 -1
  17. package/dist/esm/modal.js +1 -1
  18. package/dist/esm/{normalizeDocSearchIndexes-D8P3VEXa.js → normalizeDocSearchIndexes-ChnVvoVt.js} +16 -20
  19. package/dist/esm/normalizeDocSearchIndexes-ChnVvoVt.js.map +1 -0
  20. package/dist/esm/sidepanel.d.ts +22 -7
  21. package/dist/esm/sidepanel.js +27 -10
  22. package/dist/esm/sidepanel.js.map +1 -1
  23. package/dist/esm/useDocSearchKeyboardEvents.js +1 -1
  24. package/dist/esm/useDocSearchKeyboardEvents.js.map +1 -1
  25. package/dist/esm/useSearchClient-mIHVB6ga.js.map +1 -1
  26. package/dist/esm/{useSuggestedQuestions-Ds7H1JCr.js → useSuggestedQuestions-BjSZvxwr.js} +233 -36
  27. package/dist/esm/useSuggestedQuestions-BjSZvxwr.js.map +1 -0
  28. package/dist/esm/version.d.ts +1 -1
  29. package/dist/esm/version.js +1 -1
  30. package/dist/esm/version.js.map +1 -1
  31. package/dist/umd/index.js +33 -33
  32. package/dist/umd/index.js.map +1 -1
  33. package/package.json +4 -4
  34. package/dist/esm/DocSearchAskAiModal-BczGFkvR.js.map +0 -1
  35. package/dist/esm/DocSearchModal-D_tfhoN1.js.map +0 -1
  36. package/dist/esm/normalizeDocSearchIndexes-D8P3VEXa.js.map +0 -1
  37. package/dist/esm/useSuggestedQuestions-Ds7H1JCr.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { t as _objectSpread2 } from "./objectSpread2-BNmiQYyW.js";
2
- import { C as noop, E as identity, S as scrollTo, T as isModifierEvent, _ as Hit, a as NoResultsScreen, b as SearchBoxForm, d as useRefreshOnInitialQuery, f as useModalRefs, g as useDocSearchFacets, h as useSendItemClickEvent, i as ResultsScreen, l as useStoredDocSearches, m as useInitialModalQuery, n as buildNoQuerySources, o as ErrorScreen, p as useModalEnvironment, r as buildQuerySources, s as StoredSearchesSections, t as normalizeDocSearchIndexes, u as useSaveRecentSearch, v as Footer, w as isQueryEmpty, x as FacetBar, y as ModalShell } from "./normalizeDocSearchIndexes-D8P3VEXa.js";
2
+ import { C as noop, E as identity, S as scrollTo, T as isModifierEvent, _ as Hit, a as NoResultsScreen, b as SearchBoxForm, d as useRefreshOnInitialQuery, f as useModalRefs, g as useDocSearchFacets, h as useSendItemClickEvent, i as ResultsScreen, l as useStoredDocSearches, m as useInitialModalQuery, n as buildNoQuerySources, o as ErrorScreen, p as useModalEnvironment, r as buildQuerySources, s as StoredSearchesSections, t as normalizeDocSearchIndexes, u as useSaveRecentSearch, v as Footer, w as isQueryEmpty, x as FacetBar, y as ModalShell } from "./normalizeDocSearchIndexes-ChnVvoVt.js";
3
3
  import { t as _objectWithoutProperties } from "./objectWithoutProperties-phqYxDS0.js";
4
4
  import { t as useSearchClient } from "./useSearchClient-mIHVB6ga.js";
5
5
  import React from "react";
@@ -78,7 +78,8 @@ const _excluded = [
78
78
  "recentSearchesLimit",
79
79
  "recentSearchesWithFavoritesLimit",
80
80
  "indices",
81
- "facets"
81
+ "facets",
82
+ "footerAction"
82
83
  ];
83
84
  const _excluded2 = [
84
85
  "footer",
@@ -87,7 +88,7 @@ const _excluded2 = [
87
88
  ];
88
89
  function DocSearchModal(_ref) {
89
90
  var _translations$searchB;
90
- let { appId, apiKey, maxResultsPerGroup, theme, onClose = noop, transformItems = identity, hitComponent = Hit, resultsFooterComponent = () => null, navigator, initialScrollY = 0, transformSearchClient = identity, disableUserPersonalization = false, initialQuery: initialQueryFromProp = "", translations = {}, getMissingResultsUrl, insights = false, recentSearchesLimit = 7, recentSearchesWithFavoritesLimit = 4, indices, facets } = _ref, props = _objectWithoutProperties(_ref, _excluded);
91
+ let { appId, apiKey, maxResultsPerGroup, theme, onClose = noop, transformItems = identity, hitComponent = Hit, resultsFooterComponent = () => null, navigator, initialScrollY = 0, transformSearchClient = identity, disableUserPersonalization = false, initialQuery: initialQueryFromProp = "", translations = {}, getMissingResultsUrl, insights = false, recentSearchesLimit = 7, recentSearchesWithFavoritesLimit = 4, indices, facets, footerAction } = _ref, props = _objectWithoutProperties(_ref, _excluded);
91
92
  const { footer: footerTranslations, searchBox: searchBoxTranslations, facets: facetBarTranslations } = translations, screenStateTranslations = _objectWithoutProperties(translations, _excluded2);
92
93
  const [state, setState] = React.useState({
93
94
  query: "",
@@ -99,7 +100,7 @@ function DocSearchModal(_ref) {
99
100
  status: "idle"
100
101
  });
101
102
  const placeholder = (translations === null || translations === void 0 || (_translations$searchB = translations.searchBox) === null || _translations$searchB === void 0 ? void 0 : _translations$searchB.placeholderText) || props.placeholder || "Search docs";
102
- const { containerRef, modalRef, formElementRef, dropdownRef, inputRef, snippetLength } = useModalRefs();
103
+ const { containerRef, modalRef, formElementRef, dropdownRef, inputRef } = useModalRefs();
103
104
  const { initialQuery, initialQueryFromSelection } = useInitialModalQuery(initialQueryFromProp);
104
105
  const searchClient = useSearchClient(appId, apiKey, transformSearchClient);
105
106
  const indexes = React.useMemo(() => normalizeDocSearchIndexes({ indices }), [indices]);
@@ -153,7 +154,6 @@ function DocSearchModal(_ref) {
153
154
  setStatus,
154
155
  searchClient,
155
156
  indexes,
156
- snippetLength,
157
157
  insights: Boolean(insights),
158
158
  appId,
159
159
  apiKey,
@@ -175,7 +175,6 @@ function DocSearchModal(_ref) {
175
175
  inputRef,
176
176
  initialScrollY,
177
177
  modalRef,
178
- snippetLength,
179
178
  theme
180
179
  });
181
180
  React.useEffect(() => {
@@ -232,11 +231,14 @@ function DocSearchModal(_ref) {
232
231
  if (!isModifierEvent(event)) onClose();
233
232
  }
234
233
  })),
235
- footer: /* @__PURE__ */ React.createElement(Footer, { translations: footerTranslations }),
234
+ footer: /* @__PURE__ */ React.createElement(Footer, {
235
+ translations: footerTranslations,
236
+ footerAction
237
+ }),
236
238
  onClose
237
239
  });
238
240
  }
239
241
 
240
242
  //#endregion
241
243
  export { DocSearchModal as t };
242
- //# sourceMappingURL=DocSearchModal-D_tfhoN1.js.map
244
+ //# sourceMappingURL=DocSearchModal-CITTG0fe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocSearchModal-CITTG0fe.js","names":[],"sources":["../../src/components/KeywordSearchBox.tsx","../../src/components/KeywordStartScreen.tsx","../../src/ScreenState.tsx","../../src/DocSearchModal.tsx"],"sourcesContent":["import type {\n AutocompleteApi,\n AutocompleteState,\n} from '@algolia/autocomplete-core';\nimport React, { type JSX, type RefObject } from 'react';\n\nimport type { InternalDocSearchHit } from '../types';\n\nimport { SearchBoxForm } from './ui/SearchBoxForm';\n\nexport type KeywordSearchBoxTranslations = Partial<{\n clearButtonTitle: string;\n clearButtonAriaLabel: string;\n closeButtonText: string;\n closeButtonAriaLabel: string;\n placeholderText: string;\n enterKeyHint: string;\n searchInputLabel: string;\n}>;\n\ninterface KeywordSearchBoxProps extends AutocompleteApi<\n InternalDocSearchHit,\n React.FormEvent,\n React.MouseEvent,\n React.KeyboardEvent\n> {\n state: AutocompleteState<InternalDocSearchHit>;\n autoFocus: boolean;\n inputRef: RefObject<HTMLInputElement | null>;\n onClose: () => void;\n placeholder: string;\n isFromSelection: boolean;\n translations?: KeywordSearchBoxTranslations;\n}\n\nexport function KeywordSearchBox({\n translations = {},\n ...props\n}: KeywordSearchBoxProps): JSX.Element {\n const {\n clearButtonTitle = 'Clear',\n clearButtonAriaLabel = 'Clear the query',\n closeButtonText = 'Close',\n closeButtonAriaLabel = 'Close',\n searchInputLabel = 'Search',\n } = translations;\n\n const actionsBeforeClose = (\n <>\n <button\n className=\"DocSearch-Clear\"\n type=\"reset\"\n aria-label={clearButtonAriaLabel}\n hidden={!props.state.query}\n tabIndex={props.state.query ? 0 : -1}\n aria-hidden={!props.state.query ? 'true' : 'false'}\n >\n {clearButtonTitle}\n </button>\n\n {props.state.query && <div className=\"DocSearch-Divider\" />}\n </>\n );\n\n return (\n <SearchBoxForm\n {...props}\n clearButtonTitle={clearButtonTitle}\n clearButtonAriaLabel={clearButtonAriaLabel}\n closeButtonText={closeButtonText}\n closeButtonAriaLabel={closeButtonAriaLabel}\n searchInputLabel={searchInputLabel}\n inputProps={{\n enterKeyHint: 'search',\n }}\n actionsBeforeClose={actionsBeforeClose}\n />\n );\n}\n","import React, { type JSX } from 'react';\n\nimport type { ScreenStateProps } from '../ScreenState';\nimport type { InternalDocSearchHit } from '../types';\n\nimport type { StoredSearchesSectionsTranslations } from './ui/StoredSearchesSections';\nimport { StoredSearchesSections } from './ui/StoredSearchesSections';\n\nexport type KeywordStartScreenTranslations = StoredSearchesSectionsTranslations;\n\ntype KeywordStartScreenProps = Omit<\n ScreenStateProps<InternalDocSearchHit>,\n 'translations'\n> & {\n hasCollections: boolean;\n translations?: KeywordStartScreenTranslations;\n};\n\nexport function KeywordStartScreen({\n translations = {},\n ...props\n}: KeywordStartScreenProps): JSX.Element | null {\n return (\n <div className=\"DocSearch-Dropdown-Container\">\n <StoredSearchesSections {...props} translations={translations} />\n </div>\n );\n}\n","import type {\n AutocompleteApi,\n AutocompleteState,\n BaseItem,\n} from '@algolia/autocomplete-core';\nimport React from 'react';\n\nimport type { KeywordStartScreenTranslations } from './components/KeywordStartScreen';\nimport { KeywordStartScreen } from './components/KeywordStartScreen';\nimport type { DocSearchProps } from './DocSearch';\nimport type { ErrorScreenTranslations } from './ErrorScreen';\nimport { ErrorScreen } from './ErrorScreen';\nimport type { NoResultsScreenTranslations } from './NoResultsScreen';\nimport { NoResultsScreen } from './NoResultsScreen';\nimport type { ResultsScreenTranslations } from './ResultsScreen';\nimport { ResultsScreen } from './ResultsScreen';\nimport type { StoredSearchPlugin } from './stored-searches';\nimport type { InternalDocSearchHit, StoredDocSearchHit } from './types';\nimport { isQueryEmpty } from './utils';\n\nexport type ScreenStateTranslations = Partial<{\n errorScreen: ErrorScreenTranslations;\n startScreen: KeywordStartScreenTranslations;\n noResultsScreen: NoResultsScreenTranslations;\n resultsScreen: ResultsScreenTranslations;\n}>;\n\nexport interface ScreenStateProps<\n TItem extends BaseItem,\n> extends AutocompleteApi<\n TItem,\n React.FormEvent,\n React.MouseEvent,\n React.KeyboardEvent\n> {\n state: AutocompleteState<TItem>;\n recentSearches: StoredSearchPlugin<StoredDocSearchHit>;\n favoriteSearches: StoredSearchPlugin<StoredDocSearchHit>;\n onItemClick: (\n item: InternalDocSearchHit,\n event: KeyboardEvent | MouseEvent\n ) => void;\n inputRef: React.MutableRefObject<HTMLInputElement | null>;\n hitComponent: DocSearchProps['hitComponent'];\n indexName: string;\n disableUserPersonalization: boolean;\n resultsFooterComponent: DocSearchProps['resultsFooterComponent'];\n translations: ScreenStateTranslations;\n getMissingResultsUrl?: DocSearchProps['getMissingResultsUrl'];\n hasCollections: boolean;\n resultBadgeKey?: string;\n}\n\nexport const ScreenState = React.memo(\n ({ translations = {}, ...props }: ScreenStateProps<InternalDocSearchHit>) => {\n if (props.state?.status === 'error') {\n return <ErrorScreen translations={translations?.errorScreen} />;\n }\n\n if (isQueryEmpty(props.state.query)) {\n return (\n <KeywordStartScreen\n {...props}\n hasCollections={props.hasCollections}\n translations={translations?.startScreen}\n />\n );\n }\n\n if (!props.hasCollections) {\n return (\n <NoResultsScreen\n {...props}\n translations={translations?.noResultsScreen}\n />\n );\n }\n\n return (\n <ResultsScreen {...props} translations={translations?.resultsScreen} />\n );\n },\n function areEqual(prevProps, nextProps) {\n const isLoading =\n nextProps.state.status === 'loading' ||\n nextProps.state.status === 'stalled';\n\n const isWaitingForCollections =\n nextProps.state.status === 'idle' &&\n !isQueryEmpty(nextProps.state.query) &&\n prevProps.state.query !== nextProps.state.query &&\n prevProps.state.collections === nextProps.state.collections;\n\n return isLoading || isWaitingForCollections;\n }\n);\n","import { createAutocomplete } from '@algolia/autocomplete-core';\nimport React, { type JSX } from 'react';\n\nimport type { FacetBarTranslations } from './components/FacetBar';\nimport { FacetBar } from './components/FacetBar';\nimport type { KeywordSearchBoxTranslations } from './components/KeywordSearchBox';\nimport { KeywordSearchBox } from './components/KeywordSearchBox';\nimport { ModalShell } from './components/ui/ModalShell';\nimport type { DocSearchProps } from './DocSearch';\nimport type { FooterTranslations } from './Footer';\nimport { Footer } from './Footer';\nimport { Hit } from './Hit';\nimport { useDocSearchFacets } from './hooks/useDocSearchFacets';\nimport { useSendItemClickEvent } from './hooks/useDocSearchInsights';\nimport { useInitialModalQuery } from './hooks/useInitialModalQuery';\nimport { useModalEnvironment } from './hooks/useModalEnvironment';\nimport { useModalRefs } from './hooks/useModalRefs';\nimport { useRefreshOnInitialQuery } from './hooks/useRefreshOnInitialQuery';\nimport { useSaveRecentSearch } from './hooks/useSaveRecentSearch';\nimport { useStoredDocSearches } from './hooks/useStoredDocSearches';\nimport type { ScreenStateTranslations } from './ScreenState';\nimport { ScreenState } from './ScreenState';\nimport type { DocSearchState, InternalDocSearchHit } from './types';\nimport { useSearchClient } from './useSearchClient';\nimport {\n identity,\n isModifierEvent,\n isQueryEmpty,\n noop,\n scrollTo as scrollToUtils,\n} from './utils';\nimport {\n buildNoQuerySources,\n buildQuerySources,\n type BuildQuerySourcesState,\n} from './utils/createDocSearchSources';\nimport { normalizeDocSearchIndexes } from './utils/normalizeDocSearchIndexes';\n\nexport type ModalTranslations = Partial<{\n searchBox: KeywordSearchBoxTranslations;\n footer: FooterTranslations;\n facets: FacetBarTranslations;\n}> &\n ScreenStateTranslations;\n\nexport type DocSearchModalProps = DocSearchProps & {\n initialScrollY: number;\n onClose?: () => void;\n translations?: ModalTranslations;\n};\n\nexport function DocSearchModal({\n appId,\n apiKey,\n maxResultsPerGroup,\n theme,\n onClose = noop,\n transformItems = identity,\n hitComponent = Hit,\n resultsFooterComponent = (): JSX.Element | null => null,\n navigator,\n initialScrollY = 0,\n transformSearchClient = identity,\n disableUserPersonalization = false,\n initialQuery: initialQueryFromProp = '',\n translations = {},\n getMissingResultsUrl,\n insights = false,\n recentSearchesLimit = 7,\n recentSearchesWithFavoritesLimit = 4,\n indices,\n facets,\n footerAction,\n ...props\n}: DocSearchModalProps): JSX.Element {\n const {\n footer: footerTranslations,\n searchBox: searchBoxTranslations,\n facets: facetBarTranslations,\n ...screenStateTranslations\n } = translations;\n const [state, setState] = React.useState<\n DocSearchState<InternalDocSearchHit>\n >({\n query: '',\n collections: [],\n completion: null,\n context: {},\n isOpen: false,\n activeItemId: null,\n status: 'idle',\n });\n\n const placeholder =\n translations?.searchBox?.placeholderText ||\n props.placeholder ||\n 'Search docs';\n\n const { containerRef, modalRef, formElementRef, dropdownRef, inputRef } =\n useModalRefs();\n const { initialQuery, initialQueryFromSelection } =\n useInitialModalQuery(initialQueryFromProp);\n\n const searchClient = useSearchClient(appId, apiKey, transformSearchClient);\n\n const indexes = React.useMemo(\n () =>\n normalizeDocSearchIndexes({\n indices,\n }),\n [indices]\n );\n const defaultIndexName = indexes[0].name;\n\n const autocompleteRef =\n React.useRef<\n ReturnType<\n typeof createAutocomplete<\n InternalDocSearchHit,\n React.FormEvent<HTMLFormElement>,\n React.MouseEvent,\n React.KeyboardEvent\n >\n >\n >(undefined);\n\n const {\n visibleFacets,\n facetSelections,\n facetSelectionsRef,\n handleFacetSelectionChange,\n clearFacetSelections,\n } = useDocSearchFacets({\n facets,\n indexes,\n searchClient,\n onSelectionsChange: () => autocompleteRef.current?.refresh(),\n });\n\n const { favoriteSearches, recentSearches } = useStoredDocSearches({\n defaultIndexName,\n recentSearchesLimit,\n recentSearchesWithFavoritesLimit,\n });\n const saveRecentSearch = useSaveRecentSearch({\n favoriteSearches,\n recentSearches,\n disableUserPersonalization,\n });\n const sendItemClickEvent = useSendItemClickEvent(state);\n\n if (!autocompleteRef.current) {\n autocompleteRef.current = createAutocomplete({\n id: 'docsearch',\n defaultActiveItemId: 0,\n openOnFocus: true,\n initialState: {\n query: initialQuery,\n context: {\n searchSuggestions: [],\n },\n },\n insights: Boolean(insights),\n navigator,\n onStateChange(changes) {\n setState(changes.state);\n },\n getSources({ query, state: sourcesState, setContext, setStatus }) {\n if (isQueryEmpty(query)) {\n const noQuerySources = buildNoQuerySources({\n recentSearches,\n favoriteSearches,\n saveRecentSearch,\n onClose,\n disableUserPersonalization,\n });\n return noQuerySources;\n }\n\n const querySourcesState: BuildQuerySourcesState = {\n context: sourcesState.context,\n };\n\n const algoliaSourcesPromise = buildQuerySources({\n query,\n state: querySourcesState,\n setContext,\n setStatus,\n searchClient,\n indexes,\n insights: Boolean(insights),\n appId,\n apiKey,\n maxResultsPerGroup,\n transformItems,\n saveRecentSearch,\n onClose,\n facetSelections: facetSelectionsRef,\n });\n\n return algoliaSourcesPromise;\n },\n });\n }\n\n const autocomplete = autocompleteRef.current;\n\n const { getEnvironmentProps, getRootProps, refresh } = autocomplete;\n\n useModalEnvironment({\n getEnvironmentProps,\n containerRef,\n dropdownRef,\n formElementRef,\n inputRef,\n initialScrollY,\n modalRef,\n theme,\n });\n\n React.useEffect(() => {\n if (dropdownRef.current) {\n scrollToUtils(dropdownRef.current);\n }\n }, [state.query, dropdownRef]);\n\n useRefreshOnInitialQuery({ initialQuery, inputRef, refresh });\n\n // hide the dropdown on idle and no collections\n let showDocsearchDropdown = true;\n const hasCollections = state.collections.some(\n (collection) => collection.items.length > 0\n );\n if (\n state.status === 'idle' &&\n hasCollections === false &&\n isQueryEmpty(state.query)\n ) {\n showDocsearchDropdown = false;\n }\n\n return (\n <ModalShell\n state={state}\n containerRef={containerRef}\n modalRef={modalRef}\n formElementRef={formElementRef}\n dropdownRef={dropdownRef}\n getRootProps={getRootProps}\n showDropdown={showDocsearchDropdown}\n searchBox={\n <KeywordSearchBox\n {...autocomplete}\n state={state}\n placeholder={placeholder || 'Search docs'}\n autoFocus={isQueryEmpty(initialQuery)}\n inputRef={inputRef}\n isFromSelection={\n Boolean(initialQuery) && initialQuery === initialQueryFromSelection\n }\n translations={searchBoxTranslations}\n onClose={onClose}\n />\n }\n filterBar={\n !isQueryEmpty(state.query) ? (\n <FacetBar\n facets={visibleFacets}\n selections={facetSelections}\n translations={facetBarTranslations}\n clearSelections={clearFacetSelections}\n onSelectionChange={handleFacetSelectionChange}\n />\n ) : null\n }\n screenState={\n <ScreenState\n {...autocomplete}\n indexName={defaultIndexName}\n state={state}\n hitComponent={hitComponent}\n resultsFooterComponent={resultsFooterComponent}\n disableUserPersonalization={disableUserPersonalization}\n recentSearches={recentSearches}\n favoriteSearches={favoriteSearches}\n inputRef={inputRef}\n translations={screenStateTranslations}\n getMissingResultsUrl={getMissingResultsUrl}\n hasCollections={hasCollections}\n resultBadgeKey={props.resultBadgeKey}\n onItemClick={(item, event) => {\n sendItemClickEvent(item);\n saveRecentSearch(item);\n if (!isModifierEvent(event)) {\n onClose();\n }\n }}\n />\n }\n footer={\n <Footer translations={footerTranslations} footerAction={footerAction} />\n }\n onClose={onClose}\n />\n );\n}\n"],"mappings":";;;;;;;;qBAoCE;AADF,SAAgB,iBAAiB,MAGM;KAHN,EAC/B,eAAe,CAAC,YACb;CAEH,MAAM,EACJ,mBAAmB,SACnB,uBAAuB,mBACvB,kBAAkB,SAClB,uBAAuB,SACvB,mBAAmB,aACjB;CAEJ,MAAM,qBACJ,0DACE,oCAAC,UAAD;EACE,WAAU;EACV,MAAK;EACL,cAAY;EACZ,QAAQ,CAAC,MAAM,MAAM;EACrB,UAAU,MAAM,MAAM,QAAQ,IAAI;EAClC,eAAa,CAAC,MAAM,MAAM,QAAQ,SAAS;CAGrC,GADL,gBACK,GAEP,MAAM,MAAM,SAAS,oCAAC,OAAD,EAAK,WAAU,oBAAqB,EAC1D;CAGJ,OACE,oCAAC,iDACK;EACc;EACI;EACL;EACK;EACJ;EAClB,YAAY,EACV,cAAc,SAChB;EACoB;EACrB;AAEL;;;;qBC3DE;AADF,SAAgB,mBAAmB,MAGa;KAHb,EACjC,eAAe,CAAC,YACb;CAEH,OACE,oCAAC,OAAD,EAAK,WAAU,+BAEV,GADH,oCAAC,0DAA2B,cAAqB,cAAe,EAC7D;AAET;;;;qBC2BK;AADL,MAAa,cAAc,MAAM,MAC9B,SAA4E;;KAA5E,EAAE,eAAe,CAAC,YAAM;CACvB,qBAAI,MAAM,mEAAO,YAAW,SAC1B,OAAO,oCAAC,aAAD,EAAa,0EAAc,aAAc,YAAc;CAGhE,IAAI,aAAa,MAAM,MAAM,KAAK,GAChC,OACE,oCAAC,sDACK;EACJ,gBAAgB,MAAM;EACtB,0EAAc,aAAc;EAC7B;CAIL,IAAI,CAAC,MAAM,gBACT,OACE,oCAAC,mDACK,cACJ,0EAAc,aAAc,iBAC7B;CAIL,OACE,oCAAC,iDAAkB,cAAO,0EAAc,aAAc,eAAgB;AAE1E,GACA,SAAS,SAAS,WAAW,WAAW;CACtC,MAAM,YACJ,UAAU,MAAM,WAAW,aAC3B,UAAU,MAAM,WAAW;CAE7B,MAAM,0BACJ,UAAU,MAAM,WAAW,UAC3B,CAAC,aAAa,UAAU,MAAM,KAAK,KACnC,UAAU,MAAM,UAAU,UAAU,MAAM,SAC1C,UAAU,MAAM,gBAAgB,UAAU,MAAM;CAElD,OAAO,aAAa;AACtB,CACF;;;;;CC3CE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAIE;CACA;CACA;;AA3BJ,SAAgB,eAAe,MAuBM;;KAvBN,EAC7B,OACA,QACA,oBACA,OACA,UAAU,MACV,iBAAiB,UACjB,eAAe,KACf,+BAAmD,MACnD,WACA,iBAAiB,GACjB,wBAAwB,UACxB,6BAA6B,OAC7B,cAAc,uBAAuB,IACrC,eAAe,CAAC,GAChB,sBACA,WAAW,OACX,sBAAsB,GACtB,mCAAmC,GACnC,SACA,QACA,uBACG;CAEH,MAAM,EACJ,QAAQ,oBACR,WAAW,uBACX,QAAQ,uCACL,mDACD;CACJ,MAAM,CAAC,OAAO,YAAY,MAAM,SAE9B;EACA,OAAO;EACP,aAAa,CAAC;EACd,YAAY;EACZ,SAAS,CAAC;EACV,QAAQ;EACR,cAAc;EACd,QAAQ;CACV,CAAC;CAED,MAAM,4FACJ,aAAc,yFAAW,oBACzB,MAAM,eACN;CAEF,MAAM,EAAE,cAAc,UAAU,gBAAgB,aAAa,aAC3D,aAAa;CACf,MAAM,EAAE,cAAc,8BACpB,qBAAqB,oBAAoB;CAE3C,MAAM,eAAe,gBAAgB,OAAO,QAAQ,qBAAqB;CAEzE,MAAM,UAAU,MAAM,cAElB,0BAA0B,EACxB,QACF,CAAC,GACH,CAAC,OAAO,CACV;CACA,MAAM,mBAAmB,QAAQ,EAAE,CAAC;CAEpC,MAAM,kBACJ,MAAM,OASJ,MAAS;CAEb,MAAM,EACJ,eACA,iBACA,oBACA,4BACA,yBACE,mBAAmB;EACrB;EACA;EACA;EACA,0BAA0B;;mDAAgB,uFAAS,QAAQ;;CAC7D,CAAC;CAED,MAAM,EAAE,kBAAkB,mBAAmB,qBAAqB;EAChE;EACA;EACA;CACF,CAAC;CACD,MAAM,mBAAmB,oBAAoB;EAC3C;EACA;EACA;CACF,CAAC;CACD,MAAM,qBAAqB,sBAAsB,KAAK;CAEtD,IAAI,CAAC,gBAAgB,SACnB,gBAAgB,UAAU,mBAAmB;EAC3C,IAAI;EACJ,qBAAqB;EACrB,aAAa;EACb,cAAc;GACZ,OAAO;GACP,SAAS,EACP,mBAAmB,CAAC,EACtB;EACF;EACA,UAAU,QAAQ,QAAQ;EAC1B;EACA,cAAc,SAAS;GACrB,SAAS,QAAQ,KAAK;EACxB;EACA,WAAW,EAAE,OAAO,OAAO,cAAc,YAAY,aAAa;GAChE,IAAI,aAAa,KAAK,GAQpB,OAPuB,oBAAoB;IACzC;IACA;IACA;IACA;IACA;GACF,CACoB;GAwBtB,OAjB8B,kBAAkB;IAC9C;IACA,OAAO,EALP,SAAS,aAAa,QAKC;IACvB;IACA;IACA;IACA;IACA,UAAU,QAAQ,QAAQ;IAC1B;IACA;IACA;IACA;IACA;IACA;IACA,iBAAiB;GACnB,CAE2B;EAC7B;CACF,CAAC;CAGH,MAAM,eAAe,gBAAgB;CAErC,MAAM,EAAE,qBAAqB,cAAc,YAAY;CAEvD,oBAAoB;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,gBAAgB;EACpB,IAAI,YAAY,SACd,SAAc,YAAY,OAAO;CAErC,GAAG,CAAC,MAAM,OAAO,WAAW,CAAC;CAE7B,yBAAyB;EAAE;EAAc;EAAU;CAAQ,CAAC;CAG5D,IAAI,wBAAwB;CAC5B,MAAM,iBAAiB,MAAM,YAAY,MACtC,eAAe,WAAW,MAAM,SAAS,CAC5C;CACA,IACE,MAAM,WAAW,UACjB,mBAAmB,SACnB,aAAa,MAAM,KAAK,GAExB,wBAAwB;CAG1B,OACE,oCAAC,YAAD;EACS;EACO;EACJ;EACM;EACH;EACC;EACd,cAAc;EACd,WACE,oCAAC,oDACK;GACG;GACP,aAAa,eAAe;GAC5B,WAAW,aAAa,YAAY;GAC1B;GACV,iBACE,QAAQ,YAAY,KAAK,iBAAiB;GAE5C,cAAc;GACL;GACV;EAEH,WACE,CAAC,aAAa,MAAM,KAAK,IACvB,oCAAC,UAAD;GACE,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,iBAAiB;GACjB,mBAAmB;EACpB,KACC;EAEN,aACE,oCAAC,+CACK;GACJ,WAAW;GACJ;GACO;GACU;GACI;GACZ;GACE;GACR;GACV,cAAc;GACQ;GACN;GAChB,gBAAgB,MAAM;GACtB,cAAc,MAAM,UAAU;IAC5B,mBAAmB,IAAI;IACvB,iBAAiB,IAAI;IACrB,IAAI,CAAC,gBAAgB,KAAK,GACxB,QAAQ;GAEZ;GACD;EAEH,QACE,oCAAC,QAAD;GAAQ,cAAc;GAAkC;EAAe;EAEhE;CACV;AAEL"}
@@ -1,2 +1,2 @@
1
- import { n as DocSearchAskAiModalProps, r as DocSearchAskAiModalTranslations, t as DocSearchAskAiModal } from "./DocSearchAskAiModal-MF2py4NM.js";
1
+ import { n as DocSearchAskAiModalProps, r as DocSearchAskAiModalTranslations, t as DocSearchAskAiModal } from "./DocSearchAskAiModal-DpB7pLCC.js";
2
2
  export { DocSearchAskAiModal, DocSearchAskAiModalProps, DocSearchAskAiModalTranslations };
@@ -1,3 +1,3 @@
1
- import { t as DocSearchAskAiModal } from "./DocSearchAskAiModal-BczGFkvR.js";
1
+ import { t as DocSearchAskAiModal } from "./DocSearchAskAiModal-ByqIW5ZA.js";
2
2
 
3
3
  export { DocSearchAskAiModal };
@@ -1,8 +1,7 @@
1
1
  import { o as ToolCalls } from "./index-Bqqv4HmN.js";
2
- import { a as DocSearchProps } from "./DocSearch-CVj6U-nI.js";
2
+ import { a as DocSearchProps } from "./DocSearch-BVqxFxTw.js";
3
3
  import { DocSearchRef, InitialAskAiMessage } from "@docsearch/core";
4
4
  import React, { JSX } from "react";
5
- import { SearchParamsObject } from "algoliasearch/lite";
6
5
  //#region src/DocSearchAI.d.ts
7
6
  interface AskAiSearchParameters {
8
7
  facetFilters?: string[];
@@ -12,103 +11,6 @@ interface AskAiSearchParameters {
12
11
  distinct?: boolean | number | string;
13
12
  }
14
13
  type AgentStudioSearchParameters = Record<string, Omit<AskAiSearchParameters, 'facetFilters'>>;
15
- interface IndexTextParam {
16
- exposed: boolean;
17
- default?: string;
18
- }
19
- interface NumberConstraint {
20
- min?: number;
21
- max?: number;
22
- }
23
- interface IndexNumberParam {
24
- exposed: boolean;
25
- default?: number;
26
- constraint?: NumberConstraint;
27
- }
28
- interface StringArrayConstraints {
29
- values?: string[];
30
- }
31
- interface IndexStringArrayParam {
32
- exposed: boolean;
33
- default?: string[];
34
- constraint?: StringArrayConstraints;
35
- merge?: boolean;
36
- }
37
- interface IndexFacetParam {
38
- exposed: false;
39
- default?: string[];
40
- }
41
- interface AgentStudioSearchControls {
42
- /**
43
- * Augmented query for the MCP search tool to use.
44
- *
45
- * @default undefined
46
- */
47
- query?: IndexTextParam;
48
- /**
49
- * Number of hits for the MCP to return per page.
50
- *
51
- * @default { exposed: false, default: 7 }
52
- */
53
- hits_per_page?: IndexNumberParam;
54
- /**
55
- * The page number the MCP should pull results from.
56
- *
57
- * @default { exposed: false, default: 0 }
58
- */
59
- page?: IndexNumberParam;
60
- /**
61
- * List of attributes that the MCP can retrieve from the index.
62
- *
63
- * @default { exposed: false, default: ['*'] }
64
- */
65
- attributesToRetrieve?: IndexStringArrayParam;
66
- /**
67
- * List of fields that the MCP will return to the Agent.
68
- *
69
- * @default { exposed: false, default: ["hits", "nbHits", "page", "nbPages", "hitsPerPage", "facets"] }
70
- */
71
- responseFields?: IndexStringArrayParam;
72
- /**
73
- * Defined facets the MCP will use when querying the index.
74
- *
75
- * @default undefined
76
- */
77
- facets?: IndexFacetParam;
78
- /**
79
- * Any other custom properties the MCP should send when querying the index.
80
- *
81
- * @default undefined
82
- */
83
- custom?: Record<string, unknown>;
84
- }
85
- interface AgentStudioIndices {
86
- /** The name of the index used by the search tool. */
87
- index: string;
88
- /** A brief description for the search tool. */
89
- description: string;
90
- /**
91
- * A description used to steer the agent on how/when to use the search tool.
92
- *
93
- * @default ''
94
- */
95
- enhancedDescription?: string;
96
- /**
97
- * Default search parameters for the internal (non-MCP) search tool path.
98
- *
99
- * @default undefined
100
- */
101
- searchParameters?: SearchParamsObject;
102
- /**
103
- * Structured search parameters for the MCP-based search tool path.
104
- *
105
- * Each parameter controls whether it is exposed to the LLM and it's default
106
- * value.
107
- *
108
- * @default undefined
109
- */
110
- searchControls?: AgentStudioSearchControls;
111
- }
112
14
  interface Memory {
113
15
  /**
114
16
  * Determines whether or not to display the memory based tool calls.
@@ -162,8 +64,14 @@ interface DocSearchAskAi {
162
64
  * }
163
65
  */
164
66
  searchParameters?: AgentStudioSearchParameters;
165
- /** List of dynamic indices for the Agent Studio search tool to use. */
166
- indices?: AgentStudioIndices[];
67
+ /**
68
+ * Index names for the Agent Studio search tool on this request.
69
+ *
70
+ * Agent Studio expects names only. Put descriptions and tool defaults on the
71
+ * agent configuration. Put per-index runtime overrides in
72
+ * `searchParameters`.
73
+ */
74
+ indices?: string[];
167
75
  /**
168
76
  * Use custom tools driven by Agent Studio.
169
77
  *
@@ -211,5 +119,5 @@ interface DocSearchAIProps extends DocSearchProps {
211
119
  declare const DocSearchAI: React.ForwardRefExoticComponent<DocSearchAIProps & React.RefAttributes<DocSearchRef>>;
212
120
  declare function DocSearchAIInner(props: Omit<DocSearchAIProps, 'appId' | 'apiKey'>): JSX.Element;
213
121
  //#endregion
214
- export { AgentStudioIndices, AgentStudioSearchControls, AgentStudioSearchParameters, AskAiSearchParameters, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAskAi, Memory, PromptSuggestions, type ToolCalls };
122
+ export { AgentStudioSearchParameters, AskAiSearchParameters, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAskAi, Memory, PromptSuggestions, type ToolCalls };
215
123
  //# sourceMappingURL=docsearchAi.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { t as _objectSpread2 } from "./objectSpread2-BNmiQYyW.js";
2
2
  import { t as DocSearchButton } from "./DocSearchButton-CaxxOzQU.js";
3
3
  import { t as _objectWithoutProperties } from "./objectWithoutProperties-phqYxDS0.js";
4
- import { t as DocSearchAskAiModal } from "./DocSearchAskAiModal-BczGFkvR.js";
4
+ import { t as DocSearchAskAiModal } from "./DocSearchAskAiModal-ByqIW5ZA.js";
5
5
  import { DocSearch, useDocSearch } from "@docsearch/core";
6
6
  import React from "react";
7
7
  import { createPortal } from "react-dom";
@@ -1 +1 @@
1
- {"version":3,"file":"docsearchAi.js","names":["DocSearchProvider"],"sources":["../../src/DocSearchAI.tsx"],"sourcesContent":["import { DocSearch as DocSearchProvider, useDocSearch } from '@docsearch/core';\nimport type { DocSearchRef, InitialAskAiMessage } from '@docsearch/core';\nimport type { SearchParamsObject } from 'algoliasearch/lite';\nimport React, { type JSX } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport type { DocSearchProps } from './DocSearch';\nimport { DocSearchAskAiModal } from './DocSearchAskAiModal';\nimport { DocSearchButton } from './DocSearchButton';\nimport type { ToolCalls } from './types/AskiAi';\n\nexport interface AskAiSearchParameters {\n facetFilters?: string[];\n filters?: string;\n attributesToRetrieve?: string[];\n restrictSearchableAttributes?: string[];\n distinct?: boolean | number | string;\n}\n\nexport type AgentStudioSearchParameters = Record<\n string,\n Omit<AskAiSearchParameters, 'facetFilters'>\n>;\n\ninterface IndexTextParam {\n exposed: boolean;\n default?: string;\n}\n\ninterface NumberConstraint {\n min?: number;\n max?: number;\n}\n\ninterface IndexNumberParam {\n exposed: boolean;\n default?: number;\n constraint?: NumberConstraint;\n}\n\ninterface StringArrayConstraints {\n values?: string[];\n}\n\ninterface IndexStringArrayParam {\n exposed: boolean;\n default?: string[];\n constraint?: StringArrayConstraints;\n merge?: boolean;\n}\n\ninterface IndexFacetParam {\n exposed: false;\n default?: string[];\n}\n\nexport interface AgentStudioSearchControls {\n /**\n * Augmented query for the MCP search tool to use.\n *\n * @default undefined\n */\n query?: IndexTextParam;\n /**\n * Number of hits for the MCP to return per page.\n *\n * @default { exposed: false, default: 7 }\n */\n hits_per_page?: IndexNumberParam;\n /**\n * The page number the MCP should pull results from.\n *\n * @default { exposed: false, default: 0 }\n */\n page?: IndexNumberParam;\n /**\n * List of attributes that the MCP can retrieve from the index.\n *\n * @default { exposed: false, default: ['*'] }\n */\n attributesToRetrieve?: IndexStringArrayParam;\n /**\n * List of fields that the MCP will return to the Agent.\n *\n * @default { exposed: false, default: [\"hits\", \"nbHits\", \"page\", \"nbPages\", \"hitsPerPage\", \"facets\"] }\n */\n responseFields?: IndexStringArrayParam;\n /**\n * Defined facets the MCP will use when querying the index.\n *\n * @default undefined\n */\n facets?: IndexFacetParam;\n /**\n * Any other custom properties the MCP should send when querying the index.\n *\n * @default undefined\n */\n custom?: Record<string, unknown>;\n}\n\nexport interface AgentStudioIndices {\n /** The name of the index used by the search tool. */\n index: string;\n /** A brief description for the search tool. */\n description: string;\n /**\n * A description used to steer the agent on how/when to use the search tool.\n *\n * @default ''\n */\n enhancedDescription?: string;\n /**\n * Default search parameters for the internal (non-MCP) search tool path.\n *\n * @default undefined\n */\n searchParameters?: SearchParamsObject;\n /**\n * Structured search parameters for the MCP-based search tool path.\n *\n * Each parameter controls whether it is exposed to the LLM and it's default\n * value.\n *\n * @default undefined\n */\n searchControls?: AgentStudioSearchControls;\n}\n\nexport interface Memory {\n /**\n * Determines whether or not to display the memory based tool calls.\n *\n * @default false\n */\n enabled?: boolean;\n /**\n * The JWT used by the agent to know which user's memory to read.\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/user-authentication\n */\n userToken?: string;\n}\n\nexport interface PromptSuggestions {\n /** The name of the index where the prompt suggestions are stored. */\n indexName: string;\n /**\n * The number of prompt suggestions that are retrieved and displayed.\n *\n * @default 3\n */\n hitsPerPage?: number;\n}\n\nexport interface DocSearchAskAi {\n /**\n * The API key to use for the ask AI feature. Your assistant will use this API\n * key to search the index. If not provided, the API key will be used.\n */\n apiKey?: string;\n /**\n * The app ID to use for the ask AI feature. Your assistant will use this app\n * ID to search the index. If not provided, the app ID will be used.\n */\n appId?: string;\n /** The Agent Studio Agent ID to use for the Ask AI feature. */\n agentId: string;\n /**\n * Enables displaying suggested questions on Ask AI's new conversation screen.\n *\n * @default false\n */\n suggestedQuestions?: boolean;\n /**\n * The search parameters to use for the ask AI feature. Keyed by the index\n * name.\n *\n * @example\n * {\n * \"INDEX_NAME\": { distinct: false }\n * }\n */\n searchParameters?: AgentStudioSearchParameters;\n /** List of dynamic indices for the Agent Studio search tool to use. */\n indices?: AgentStudioIndices[];\n /**\n * Use custom tools driven by Agent Studio.\n *\n * For best performance, memoize this object with `useMemo` or define it\n * outside the component. Inline object literals will be recreated every\n * render but will not affect correctness.\n */\n tools?: ToolCalls;\n /**\n * Configuration for the Agent Studio memory feature.\n *\n * @example\n * { enabled: true, userToken: '{{SERVER_GENERATED_JWT_TOKEN}}' }\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/memory/overview\n */\n memory?: Memory;\n /**\n * Enables and configures prompt suggestions that are displayed during keyword\n * search.\n *\n * @example\n * { indexName: 'docsearch-markdown_prompt_suggestions', hitsPerPage: 1 }\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/integration#prompt-suggestions\n */\n promptSuggestions?: PromptSuggestions;\n}\n\nexport interface DocSearchAIProps extends DocSearchProps {\n /**\n * Configuration or assistant id to enable ask ai mode. Pass a string\n * assistant id or a full config object.\n */\n askAi: DocSearchAskAi | string;\n /**\n * Intercept Ask AI requests (e.g. Submitting a prompt or selecting a\n * suggested question).\n *\n * Return `true` to prevent the default modal Ask AI flow (no toggle, no\n * sendMessage). Useful to route Ask AI into a different UI (e.g.\n * `@docsearch/sidepanel-js`) without flicker.\n */\n interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;\n}\n\nfunction DocSearchAIComponent(\n { appId, apiKey, ...props }: DocSearchAIProps,\n ref: React.ForwardedRef<DocSearchRef>\n): JSX.Element {\n return (\n <DocSearchProvider\n {...props}\n appId={appId}\n apiKey={apiKey}\n ref={ref}\n >\n <DocSearchAIInner {...props} />\n </DocSearchProvider>\n );\n}\n\nexport const DocSearchAI = React.forwardRef(DocSearchAIComponent);\n\nexport function DocSearchAIInner(\n props: Omit<DocSearchAIProps, 'appId' | 'apiKey'>\n): JSX.Element {\n const {\n searchButtonRef,\n keyboardShortcuts,\n isModalActive,\n isAskAiActive,\n initialQuery,\n onAskAiToggle,\n openModal,\n closeModal,\n isHybridModeSupported,\n appId,\n apiKey,\n } = useDocSearch();\n\n if (!appId || !apiKey) {\n throw new Error('`DocSearchAI` requires `appId` and `apiKey` props.');\n }\n\n return (\n <>\n <DocSearchButton\n keyboardShortcuts={keyboardShortcuts}\n ref={searchButtonRef}\n translations={props.translations?.button}\n onClick={openModal}\n />\n {isModalActive &&\n createPortal(\n <DocSearchAskAiModal\n {...props}\n appId={appId}\n apiKey={apiKey}\n initialScrollY={window.scrollY}\n initialQuery={initialQuery}\n translations={props?.translations?.modal}\n isAskAiActive={isAskAiActive}\n isHybridModeSupported={isHybridModeSupported}\n onAskAiToggle={onAskAiToggle}\n onClose={closeModal}\n />,\n props.portalContainer ?? document.body\n )}\n </>\n );\n}\n\nexport type { ToolCalls } from './types/AskiAi';\n"],"mappings":";;;;;;;;;mBAyOI,SAAO;AADX,SAAS,qBACP,MACA,KACa;KAFb,EAAE,OAAO,iBAAW;CAGpB,OACE,oCAACA,6CACK;EACG;EACC;EACH;EAGY,GADjB,oCAAC,kBAAqB,KAAQ,CACb;AAEvB;AAEA,MAAa,cAAc,MAAM,WAAW,oBAAoB;AAEhE,SAAgB,iBACd,OACa;;CACb,MAAM,EACJ,iBACA,mBACA,eACA,eACA,cACA,eACA,WACA,YACA,uBACA,OACA,WACE,aAAa;CAEjB,IAAI,CAAC,SAAS,CAAC,QACb,MAAM,IAAI,MAAM,oDAAoD;CAGtE,OACE,0DACE,oCAAC,iBAAD;EACqB;EACnB,KAAK;EACL,qCAAc,MAAM,wFAAc;EAClC,SAAS;CACV,IACA,iBACC,aACE,oCAAC,uDACK;EACG;EACC;EACR,gBAAgB,OAAO;EACT;EACd,4EAAc,MAAO,0FAAc;EACpB;EACQ;EACR;EACf,SAAS;EACV,6BACD,MAAM,wFAAmB,SAAS,IACpC,CACF;AAEN"}
1
+ {"version":3,"file":"docsearchAi.js","names":["DocSearchProvider"],"sources":["../../src/DocSearchAI.tsx"],"sourcesContent":["import { DocSearch as DocSearchProvider, useDocSearch } from '@docsearch/core';\nimport type { DocSearchRef, InitialAskAiMessage } from '@docsearch/core';\nimport React, { type JSX } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport type { DocSearchProps } from './DocSearch';\nimport { DocSearchAskAiModal } from './DocSearchAskAiModal';\nimport { DocSearchButton } from './DocSearchButton';\nimport type { ToolCalls } from './types/AskiAi';\n\nexport interface AskAiSearchParameters {\n facetFilters?: string[];\n filters?: string;\n attributesToRetrieve?: string[];\n restrictSearchableAttributes?: string[];\n distinct?: boolean | number | string;\n}\n\nexport type AgentStudioSearchParameters = Record<\n string,\n Omit<AskAiSearchParameters, 'facetFilters'>\n>;\n\nexport interface Memory {\n /**\n * Determines whether or not to display the memory based tool calls.\n *\n * @default false\n */\n enabled?: boolean;\n /**\n * The JWT used by the agent to know which user's memory to read.\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/user-authentication\n */\n userToken?: string;\n}\n\nexport interface PromptSuggestions {\n /** The name of the index where the prompt suggestions are stored. */\n indexName: string;\n /**\n * The number of prompt suggestions that are retrieved and displayed.\n *\n * @default 3\n */\n hitsPerPage?: number;\n}\n\nexport interface DocSearchAskAi {\n /**\n * The API key to use for the ask AI feature. Your assistant will use this API\n * key to search the index. If not provided, the API key will be used.\n */\n apiKey?: string;\n /**\n * The app ID to use for the ask AI feature. Your assistant will use this app\n * ID to search the index. If not provided, the app ID will be used.\n */\n appId?: string;\n /** The Agent Studio Agent ID to use for the Ask AI feature. */\n agentId: string;\n /**\n * Enables displaying suggested questions on Ask AI's new conversation screen.\n *\n * @default false\n */\n suggestedQuestions?: boolean;\n /**\n * The search parameters to use for the ask AI feature. Keyed by the index\n * name.\n *\n * @example\n * {\n * \"INDEX_NAME\": { distinct: false }\n * }\n */\n searchParameters?: AgentStudioSearchParameters;\n /**\n * Index names for the Agent Studio search tool on this request.\n *\n * Agent Studio expects names only. Put descriptions and tool defaults on the\n * agent configuration. Put per-index runtime overrides in\n * `searchParameters`.\n */\n indices?: string[];\n /**\n * Use custom tools driven by Agent Studio.\n *\n * For best performance, memoize this object with `useMemo` or define it\n * outside the component. Inline object literals will be recreated every\n * render but will not affect correctness.\n */\n tools?: ToolCalls;\n /**\n * Configuration for the Agent Studio memory feature.\n *\n * @example\n * { enabled: true, userToken: '{{SERVER_GENERATED_JWT_TOKEN}}' }\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/memory/overview\n */\n memory?: Memory;\n /**\n * Enables and configures prompt suggestions that are displayed during keyword\n * search.\n *\n * @example\n * { indexName: 'docsearch-markdown_prompt_suggestions', hitsPerPage: 1 }\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/integration#prompt-suggestions\n */\n promptSuggestions?: PromptSuggestions;\n}\n\nexport interface DocSearchAIProps extends DocSearchProps {\n /**\n * Configuration or assistant id to enable ask ai mode. Pass a string\n * assistant id or a full config object.\n */\n askAi: DocSearchAskAi | string;\n /**\n * Intercept Ask AI requests (e.g. Submitting a prompt or selecting a\n * suggested question).\n *\n * Return `true` to prevent the default modal Ask AI flow (no toggle, no\n * sendMessage). Useful to route Ask AI into a different UI (e.g.\n * `@docsearch/sidepanel-js`) without flicker.\n */\n interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;\n}\n\nfunction DocSearchAIComponent(\n { appId, apiKey, ...props }: DocSearchAIProps,\n ref: React.ForwardedRef<DocSearchRef>\n): JSX.Element {\n return (\n <DocSearchProvider {...props} appId={appId} apiKey={apiKey} ref={ref}>\n <DocSearchAIInner {...props} />\n </DocSearchProvider>\n );\n}\n\nexport const DocSearchAI = React.forwardRef(DocSearchAIComponent);\n\nexport function DocSearchAIInner(\n props: Omit<DocSearchAIProps, 'appId' | 'apiKey'>\n): JSX.Element {\n const {\n searchButtonRef,\n keyboardShortcuts,\n isModalActive,\n isAskAiActive,\n initialQuery,\n onAskAiToggle,\n openModal,\n closeModal,\n isHybridModeSupported,\n appId,\n apiKey,\n } = useDocSearch();\n\n if (!appId || !apiKey) {\n throw new Error('`DocSearchAI` requires `appId` and `apiKey` props.');\n }\n\n return (\n <>\n <DocSearchButton\n keyboardShortcuts={keyboardShortcuts}\n ref={searchButtonRef}\n translations={props.translations?.button}\n onClick={openModal}\n />\n {isModalActive &&\n createPortal(\n <DocSearchAskAiModal\n {...props}\n appId={appId}\n apiKey={apiKey}\n initialScrollY={window.scrollY}\n initialQuery={initialQuery}\n translations={props?.translations?.modal}\n isAskAiActive={isAskAiActive}\n isHybridModeSupported={isHybridModeSupported}\n onAskAiToggle={onAskAiToggle}\n onClose={closeModal}\n />,\n props.portalContainer ?? document.body\n )}\n </>\n );\n}\n\nexport type { ToolCalls } from './types/AskiAi';\n"],"mappings":";;;;;;;;;mBAqII,SAAO;AADX,SAAS,qBACP,MACA,KACa;KAFb,EAAE,OAAO,iBAAW;CAGpB,OACE,oCAACA,6CAAsB;EAAc;EAAe;EAAa;EAE9C,GADjB,oCAAC,kBAAqB,KAAQ,CACb;AAEvB;AAEA,MAAa,cAAc,MAAM,WAAW,oBAAoB;AAEhE,SAAgB,iBACd,OACa;;CACb,MAAM,EACJ,iBACA,mBACA,eACA,eACA,cACA,eACA,WACA,YACA,uBACA,OACA,WACE,aAAa;CAEjB,IAAI,CAAC,SAAS,CAAC,QACb,MAAM,IAAI,MAAM,oDAAoD;CAGtE,OACE,0DACE,oCAAC,iBAAD;EACqB;EACnB,KAAK;EACL,qCAAc,MAAM,wFAAc;EAClC,SAAS;CACV,IACA,iBACC,aACE,oCAAC,uDACK;EACG;EACC;EACR,gBAAgB,OAAO;EACT;EACd,4EAAc,MAAO,0FAAc;EACpB;EACQ;EACR;EACf,SAAS;EACV,6BACD,MAAM,wFAAmB,SAAS,IACpC,CACF;AAEN"}
@@ -1,9 +1,9 @@
1
1
  import { a as StoredDocSearchHit, c as AskAiFeedbackReason, d as DocSearchHit, i as StoredAskAiState, l as OnAskAiFeedback, n as SuggestedQuestionHit, o as ToolCalls, r as StoredAskAiMessage, s as AskAiFeedbackPayload, t as SuggestedQuestion, u as DocSearchState } from "./index-Bqqv4HmN.js";
2
2
  import { t as DocSearchTheme } from "./DocSearchTheme-DvL4mf0D.js";
3
- import { a as DocSearchProps, c as DocSearchTranslations, d as ModalTranslations, i as DocSearchInner, l as DocSearchModal, n as DocSearchFacet, o as DocSearchRef, r as DocSearchIndex, s as DocSearchTransformClient, t as DocSearch, u as DocSearchModalProps, v as InternalDocSearchHit } from "./DocSearch-CVj6U-nI.js";
3
+ import { a as DocSearchProps, b as InternalDocSearchHit, c as DocSearchTranslations, d as DocSearchModal, f as DocSearchModalProps, i as DocSearchInner, l as HitComponentProps, n as DocSearchFacet, o as DocSearchRef, p as ModalTranslations, r as DocSearchIndex, s as DocSearchTransformClient, t as DocSearch, u as ResultsFooterComponentProps } from "./DocSearch-BVqxFxTw.js";
4
4
  import { n as useDocSearchKeyboardEvents, r as KeyboardShortcuts, t as UseDocSearchKeyboardEventsProps } from "./useDocSearchKeyboardEvents-u23fFhR9.js";
5
5
  import { n as DocSearchButton, r as DocSearchButtonProps, t as ButtonTranslations } from "./DocSearchButton-CZM_jACU.js";
6
- import { AgentStudioIndices, AgentStudioSearchControls, AgentStudioSearchParameters, AskAiSearchParameters, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAskAi, Memory, PromptSuggestions } from "./docsearchAi.js";
7
- import { n as DocSearchAskAiModalProps, r as DocSearchAskAiModalTranslations, t as DocSearchAskAiModal } from "./DocSearchAskAiModal-MF2py4NM.js";
6
+ import { AgentStudioSearchParameters, AskAiSearchParameters, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAskAi, Memory, PromptSuggestions } from "./docsearchAi.js";
7
+ import { n as DocSearchAskAiModalProps, r as DocSearchAskAiModalTranslations, t as DocSearchAskAiModal } from "./DocSearchAskAiModal-DpB7pLCC.js";
8
8
  import { version } from "./version.js";
9
- export { AgentStudioIndices, AgentStudioSearchControls, AgentStudioSearchParameters, AskAiFeedbackPayload, AskAiFeedbackReason, AskAiSearchParameters, ButtonTranslations, DocSearch, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAskAi, DocSearchAskAiModal, DocSearchAskAiModalProps, DocSearchAskAiModalTranslations, DocSearchButton, DocSearchButtonProps, DocSearchFacet, DocSearchHit, DocSearchIndex, DocSearchInner, DocSearchModal, DocSearchModalProps, DocSearchProps, type DocSearchRef, DocSearchState, DocSearchTheme, DocSearchTransformClient, DocSearchTranslations, InternalDocSearchHit, KeyboardShortcuts, Memory, ModalTranslations, OnAskAiFeedback, PromptSuggestions, StoredAskAiMessage, StoredAskAiState, StoredDocSearchHit, SuggestedQuestion, SuggestedQuestionHit, type ToolCalls, UseDocSearchKeyboardEventsProps, useDocSearchKeyboardEvents, version };
9
+ export { AgentStudioSearchParameters, AskAiFeedbackPayload, AskAiFeedbackReason, AskAiSearchParameters, ButtonTranslations, DocSearch, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAskAi, DocSearchAskAiModal, DocSearchAskAiModalProps, DocSearchAskAiModalTranslations, DocSearchButton, DocSearchButtonProps, DocSearchFacet, DocSearchHit, DocSearchIndex, DocSearchInner, DocSearchModal, DocSearchModalProps, DocSearchProps, type DocSearchRef, DocSearchState, DocSearchTheme, DocSearchTransformClient, DocSearchTranslations, HitComponentProps, InternalDocSearchHit, KeyboardShortcuts, Memory, ModalTranslations, OnAskAiFeedback, PromptSuggestions, ResultsFooterComponentProps, StoredAskAiMessage, StoredAskAiState, StoredDocSearchHit, SuggestedQuestion, SuggestedQuestionHit, type ToolCalls, UseDocSearchKeyboardEventsProps, useDocSearchKeyboardEvents, version };
package/dist/esm/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { t as _objectSpread2 } from "./objectSpread2-BNmiQYyW.js";
2
2
  import { t as DocSearchButton } from "./DocSearchButton-CaxxOzQU.js";
3
3
  import { t as _objectWithoutProperties } from "./objectWithoutProperties-phqYxDS0.js";
4
- import { t as DocSearchAskAiModal } from "./DocSearchAskAiModal-BczGFkvR.js";
5
- import { t as DocSearchModal } from "./DocSearchModal-D_tfhoN1.js";
4
+ import { t as DocSearchAskAiModal } from "./DocSearchAskAiModal-ByqIW5ZA.js";
5
+ import { t as DocSearchModal } from "./DocSearchModal-CITTG0fe.js";
6
6
  import { version } from "./version.js";
7
7
  import { DocSearchAI, DocSearchAIInner } from "./docsearchAi.js";
8
8
  import { useDocSearchKeyboardEvents } from "./useDocSearchKeyboardEvents.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["DocSearchProvider"],"sources":["../../src/DocSearch.tsx"],"sourcesContent":["import type {\n AutocompleteOptions,\n AutocompleteState,\n} from '@algolia/autocomplete-core';\nimport { DocSearch as DocSearchProvider, useDocSearch } from '@docsearch/core';\nimport type { DocSearchModalShortcuts, DocSearchRef } from '@docsearch/core';\nimport type { LiteClient, SearchParamsObject } from 'algoliasearch/lite';\nimport React, { type JSX } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { DocSearchButton } from './DocSearchButton';\nimport type { ButtonTranslations } from './DocSearchButton';\nimport { DocSearchModal } from './DocSearchModal';\nimport type { ModalTranslations } from './DocSearchModal';\nimport type {\n DocSearchHit,\n DocSearchTheme,\n InternalDocSearchHit,\n StoredDocSearchHit,\n} from './types';\n\nexport type { DocSearchRef } from '@docsearch/core';\n\nexport type DocSearchTranslations = Partial<{\n button: ButtonTranslations;\n modal: ModalTranslations;\n}>;\n\n// The interface that describes the minimal implementation required for the algoliasearch client, when using the [`transformSearchClient`](https://docsearch.algolia.com/docs/api/#transformsearchclient) option.\nexport type DocSearchTransformClient = {\n search: LiteClient['search'];\n addAlgoliaAgent: LiteClient['addAlgoliaAgent'];\n transporter: Pick<LiteClient['transporter'], 'algoliaAgent'>;\n};\n\nexport interface DocSearchIndex {\n name: string;\n searchParameters?: SearchParamsObject;\n}\n\nexport interface DocSearchFacet {\n key: string;\n label?: string;\n}\n\nexport interface DocSearchProps {\n /** Algolia application id used by the search client. */\n appId: string;\n /** Public api key with search permissions for the index. */\n apiKey: string;\n /**\n * List of indices and _optional_ searchParameters to be used for search.\n *\n * @see {@link https://docsearch.algolia.com/docs/api#indices}\n */\n indices: Array<DocSearchIndex | string>;\n /**\n * Facets to display as keyword-search filter controls. Values are read\n * dynamically from the configured Algolia indices.\n *\n * @default [ ]\n */\n facets?: DocSearchFacet[];\n /** Theme overrides applied to the modal and related components. */\n theme?: DocSearchTheme;\n /** Placeholder text for the search input. */\n placeholder?: string;\n /** Maximum number of hits to display per source/group. */\n maxResultsPerGroup?: number;\n /** Hook to post-process hits before rendering. */\n transformItems?: (items: DocSearchHit[]) => DocSearchHit[];\n /**\n * Custom component to render an individual hit. Supports template patterns:\n *\n * - HTML strings with html helper: (props, { html }) => html`<div>...</div>`\n * - JSX templates: (props) => <div>...</div>\n * - Function-based templates: (props) => string | JSX.Element | Function.\n */\n hitComponent?: (\n props: {\n hit: InternalDocSearchHit | StoredDocSearchHit;\n children: React.ReactNode;\n },\n helpers?: {\n html: (template: TemplateStringsArray, ...values: any[]) => any;\n }\n ) => JSX.Element;\n /**\n * Custom component rendered at the bottom of the results panel. Supports\n * template patterns:\n *\n * - HTML strings with html helper: (props, { html }) => html`<div>...</div>`\n * - JSX templates: (props) => <div>...</div>\n * - Function-based templates: (props) => string | JSX.Element | Function.\n */\n resultsFooterComponent?: (\n props: {\n state: AutocompleteState<InternalDocSearchHit>;\n },\n helpers?: {\n html: (template: TemplateStringsArray, ...values: any[]) => any;\n }\n ) => JSX.Element | null;\n /** Hook to wrap or modify the algolia search client. */\n transformSearchClient?: (\n searchClient: DocSearchTransformClient\n ) => DocSearchTransformClient;\n /** Disable storage and usage of recent and favorite searches. */\n disableUserPersonalization?: boolean;\n /** Query string to prefill when opening the modal. */\n initialQuery?: string;\n /** Custom navigator for controlling link navigation. */\n navigator?: AutocompleteOptions<InternalDocSearchHit>['navigator'];\n /** Localized strings for the button and modal ui. */\n translations?: DocSearchTranslations;\n /** Builds a url to report missing results for a given query. */\n getMissingResultsUrl?: ({ query }: { query: string }) => string;\n /** Insights client integration options to send analytics events. */\n insights?: AutocompleteOptions<InternalDocSearchHit>['insights'];\n /**\n * The container element where the modal should be portaled to. Defaults to\n * document.body.\n */\n portalContainer?: DocumentFragment | Element;\n /**\n * Limit of how many recent searches should be saved/displayed..\n *\n * @default 7\n */\n recentSearchesLimit?: number;\n /**\n * Limit of how many recent searches should be saved/displayed when there are\n * favorited searches..\n *\n * @default 4\n */\n recentSearchesWithFavoritesLimit?: number;\n /**\n * Configuration for keyboard shortcuts. Allows enabling/disabling specific\n * shortcuts.\n *\n * @default `{ 'Ctrl/Cmd+K': true, '/': true }`\n */\n keyboardShortcuts?: DocSearchModalShortcuts;\n /**\n * The key used to render a custom badge for each hit. Key must match a\n * property returned in `searchParameters.attributesToRetrieve`.\n *\n * @example\n * 'version';\n * 'hierarchy.lvl1';\n * 'tags[2]';\n *\n * @default undefined\n */\n resultBadgeKey?: string;\n}\n\nfunction DocSearchComponent(\n { appId, apiKey, ...props }: DocSearchProps,\n ref: React.ForwardedRef<DocSearchRef>\n): JSX.Element {\n return (\n <DocSearchProvider {...props} appId={appId} apiKey={apiKey} ref={ref}>\n <DocSearchInner {...props} />\n </DocSearchProvider>\n );\n}\n\nexport const DocSearch = React.forwardRef(DocSearchComponent);\n\nexport function DocSearchInner(\n props: Omit<DocSearchProps, 'appId' | 'apiKey'>\n): JSX.Element {\n const {\n searchButtonRef,\n keyboardShortcuts,\n isModalActive,\n initialQuery,\n openModal,\n closeModal,\n appId,\n apiKey,\n } = useDocSearch();\n\n if (!appId || !apiKey) {\n throw new Error('`DocSearch` requires `appId` and `apiKey` props.');\n }\n\n return (\n <>\n <DocSearchButton\n keyboardShortcuts={keyboardShortcuts}\n ref={searchButtonRef}\n translations={props.translations?.button}\n onClick={openModal}\n />\n {isModalActive &&\n createPortal(\n <DocSearchModal\n {...props}\n appId={appId}\n apiKey={apiKey}\n initialScrollY={window.scrollY}\n initialQuery={initialQuery}\n translations={props?.translations?.modal}\n onClose={closeModal}\n />,\n props.portalContainer ?? document.body\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;mBA+JI,SAAO;AADX,SAAS,mBACP,MACA,KACa;KAFb,EAAE,OAAO,iBAAW;CAGpB,OACE,oCAACA,+CAAsB;EAAc;EAAe;EAAa;EAE9C,GADjB,oCAAC,gBAAmB,KAAQ,CACX;AAEvB;AAEA,MAAa,YAAY,MAAM,WAAW,kBAAkB;AAE5D,SAAgB,eACd,OACa;;CACb,MAAM,EACJ,iBACA,mBACA,eACA,cACA,WACA,YACA,OACA,WACE,aAAa;CAEjB,IAAI,CAAC,SAAS,CAAC,QACb,MAAM,IAAI,MAAM,kDAAkD;CAGpE,OACE,0DACE,oCAAC,iBAAD;EACqB;EACnB,KAAK;EACL,qCAAc,MAAM,wFAAc;EAClC,SAAS;CACV,IACA,iBACC,aACE,oCAAC,kDACK;EACG;EACC;EACR,gBAAgB,OAAO;EACT;EACd,4EAAc,MAAO,0FAAc;EACnC,SAAS;EACV,6BACD,MAAM,wFAAmB,SAAS,IACpC,CACF;AAEN"}
1
+ {"version":3,"file":"index.js","names":["DocSearchProvider"],"sources":["../../src/DocSearch.tsx"],"sourcesContent":["import type {\n AutocompleteOptions,\n AutocompleteState,\n} from '@algolia/autocomplete-core';\nimport { DocSearch as DocSearchProvider, useDocSearch } from '@docsearch/core';\nimport type { DocSearchModalShortcuts, DocSearchRef } from '@docsearch/core';\nimport type { LiteClient, SearchParamsObject } from 'algoliasearch/lite';\nimport React, { type JSX } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { DocSearchButton } from './DocSearchButton';\nimport type { ButtonTranslations } from './DocSearchButton';\nimport { DocSearchModal } from './DocSearchModal';\nimport type { ModalTranslations } from './DocSearchModal';\nimport type {\n DocSearchHit,\n DocSearchTheme,\n InternalDocSearchHit,\n StoredDocSearchHit,\n} from './types';\n\nexport type { DocSearchRef } from '@docsearch/core';\n\nexport type DocSearchTranslations = Partial<{\n button: ButtonTranslations;\n modal: ModalTranslations;\n}>;\n\n// The interface that describes the minimal implementation required for the algoliasearch client, when using the [`transformSearchClient`](https://docsearch.algolia.com/docs/api/#transformsearchclient) option.\nexport type DocSearchTransformClient = {\n search: LiteClient['search'];\n addAlgoliaAgent: LiteClient['addAlgoliaAgent'];\n transporter: Pick<LiteClient['transporter'], 'algoliaAgent'>;\n};\n\nexport interface DocSearchIndex {\n name: string;\n searchParameters?: SearchParamsObject;\n}\n\nexport interface DocSearchFacet {\n key: string;\n label?: string;\n}\n\nexport interface HitComponentProps {\n hit: InternalDocSearchHit | StoredDocSearchHit;\n children: React.ReactNode;\n}\n\nexport interface ResultsFooterComponentProps {\n state: AutocompleteState<InternalDocSearchHit>;\n}\n\nexport interface DocSearchProps {\n /** Algolia application id used by the search client. */\n appId: string;\n /** Public api key with search permissions for the index. */\n apiKey: string;\n /**\n * List of indices and _optional_ searchParameters to be used for search.\n *\n * @see {@link https://docsearch.algolia.com/docs/api#indices}\n */\n indices: Array<DocSearchIndex | string>;\n /**\n * Facets to display as keyword-search filter controls. Values are read\n * dynamically from the configured Algolia indices.\n *\n * @default [ ]\n */\n facets?: DocSearchFacet[];\n /** Theme overrides applied to the modal and related components. */\n theme?: DocSearchTheme;\n /** Placeholder text for the search input. */\n placeholder?: string;\n /** Maximum number of hits to display per source/group. */\n maxResultsPerGroup?: number;\n /** Hook to post-process hits before rendering. */\n transformItems?: (items: DocSearchHit[]) => DocSearchHit[];\n /** Custom component to render an individual hit. */\n hitComponent?: (props: HitComponentProps) => JSX.Element;\n /** Custom component rendered at the bottom of the results panel. */\n resultsFooterComponent?: (\n props: ResultsFooterComponentProps\n ) => JSX.Element | null;\n /**\n * A custom action that can be rendered in the Modal's footer before the\n * Algolia logo. The component will be rendered as a child of `<div\n * className=\"DocSearch-Footer-Action\" />`.\n */\n footerAction?: React.ReactNode;\n /** Hook to wrap or modify the algolia search client. */\n transformSearchClient?: (\n searchClient: DocSearchTransformClient\n ) => DocSearchTransformClient;\n /** Disable storage and usage of recent and favorite searches. */\n disableUserPersonalization?: boolean;\n /** Query string to prefill when opening the modal. */\n initialQuery?: string;\n /** Custom navigator for controlling link navigation. */\n navigator?: AutocompleteOptions<InternalDocSearchHit>['navigator'];\n /** Localized strings for the button and modal ui. */\n translations?: DocSearchTranslations;\n /** Builds a url to report missing results for a given query. */\n getMissingResultsUrl?: ({ query }: { query: string }) => string;\n /** Insights client integration options to send analytics events. */\n insights?: AutocompleteOptions<InternalDocSearchHit>['insights'];\n /**\n * The container element where the modal should be portaled to. Defaults to\n * document.body.\n */\n portalContainer?: DocumentFragment | Element;\n /**\n * Limit of how many recent searches should be saved/displayed..\n *\n * @default 7\n */\n recentSearchesLimit?: number;\n /**\n * Limit of how many recent searches should be saved/displayed when there are\n * favorited searches..\n *\n * @default 4\n */\n recentSearchesWithFavoritesLimit?: number;\n /**\n * Configuration for keyboard shortcuts. Allows enabling/disabling specific\n * shortcuts.\n *\n * @default `{ 'Ctrl/Cmd+K': true, '/': true }`\n */\n keyboardShortcuts?: DocSearchModalShortcuts;\n /**\n * The key used to render a custom badge for each hit. Key must match a\n * property returned in `searchParameters.attributesToRetrieve`.\n *\n * @example\n * 'version';\n * 'hierarchy.lvl1';\n * 'tags[2]';\n *\n * @default undefined\n */\n resultBadgeKey?: string;\n}\n\nfunction DocSearchComponent(\n { appId, apiKey, ...props }: DocSearchProps,\n ref: React.ForwardedRef<DocSearchRef>\n): JSX.Element {\n return (\n <DocSearchProvider {...props} appId={appId} apiKey={apiKey} ref={ref}>\n <DocSearchInner {...props} />\n </DocSearchProvider>\n );\n}\n\nexport const DocSearch = React.forwardRef(DocSearchComponent);\n\nexport function DocSearchInner(\n props: Omit<DocSearchProps, 'appId' | 'apiKey'>\n): JSX.Element {\n const {\n searchButtonRef,\n keyboardShortcuts,\n isModalActive,\n initialQuery,\n openModal,\n closeModal,\n appId,\n apiKey,\n } = useDocSearch();\n\n if (!appId || !apiKey) {\n throw new Error('`DocSearch` requires `appId` and `apiKey` props.');\n }\n\n return (\n <>\n <DocSearchButton\n keyboardShortcuts={keyboardShortcuts}\n ref={searchButtonRef}\n translations={props.translations?.button}\n onClick={openModal}\n />\n {isModalActive &&\n createPortal(\n <DocSearchModal\n {...props}\n appId={appId}\n apiKey={apiKey}\n initialScrollY={window.scrollY}\n initialQuery={initialQuery}\n translations={props?.translations?.modal}\n onClose={closeModal}\n />,\n props.portalContainer ?? document.body\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;mBAoJI,SAAO;AADX,SAAS,mBACP,MACA,KACa;KAFb,EAAE,OAAO,iBAAW;CAGpB,OACE,oCAACA,+CAAsB;EAAc;EAAe;EAAa;EAE9C,GADjB,oCAAC,gBAAmB,KAAQ,CACX;AAEvB;AAEA,MAAa,YAAY,MAAM,WAAW,kBAAkB;AAE5D,SAAgB,eACd,OACa;;CACb,MAAM,EACJ,iBACA,mBACA,eACA,cACA,WACA,YACA,OACA,WACE,aAAa;CAEjB,IAAI,CAAC,SAAS,CAAC,QACb,MAAM,IAAI,MAAM,kDAAkD;CAGpE,OACE,0DACE,oCAAC,iBAAD;EACqB;EACnB,KAAK;EACL,qCAAc,MAAM,wFAAc;EAClC,SAAS;CACV,IACA,iBACC,aACE,oCAAC,kDACK;EACG;EACC;EACR,gBAAgB,OAAO;EACT;EACd,4EAAc,MAAO,0FAAc;EACnC,SAAS;EACV,6BACD,MAAM,wFAAmB,SAAS,IACpC,CACF;AAEN"}
@@ -1,2 +1,2 @@
1
- import { d as ModalTranslations, l as DocSearchModal, u as DocSearchModalProps } from "./DocSearch-CVj6U-nI.js";
1
+ import { d as DocSearchModal, f as DocSearchModalProps, p as ModalTranslations } from "./DocSearch-BVqxFxTw.js";
2
2
  export { DocSearchModal, DocSearchModalProps, ModalTranslations };
package/dist/esm/modal.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as DocSearchModal } from "./DocSearchModal-D_tfhoN1.js";
1
+ import { t as DocSearchModal } from "./DocSearchModal-CITTG0fe.js";
2
2
 
3
3
  export { DocSearchModal };
@@ -533,12 +533,13 @@ function CommandIcon(props) {
533
533
  strokeWidth: "1.4"
534
534
  }, props.children));
535
535
  }
536
- function Footer({ translations = {}, isAskAiActive = false }) {
536
+ function Footer({ translations = {}, isAskAiActive = false, footerAction }) {
537
537
  const { selectText = "Select", selectKeyAriaLabel = "Enter key", submitQuestionText = "Submit question", navigateText = "Navigate", navigateUpKeyAriaLabel = "Arrow up", navigateDownKeyAriaLabel = "Arrow down", closeText = "Close", backToSearchText = "Back to search", closeKeyAriaLabel = "Escape key", poweredByText = "Powered by" } = translations;
538
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "DocSearch-Logo" }, /* @__PURE__ */ React.createElement(AlgoliaLogo, { translations: { poweredByText } })), /* @__PURE__ */ React.createElement("ul", { className: "DocSearch-Commands" }, /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ React.createElement(CommandIcon, { ariaLabel: navigateDownKeyAriaLabel }, /* @__PURE__ */ React.createElement("path", { d: "M12 5v14" }), /* @__PURE__ */ React.createElement("path", { d: "m19 12-7 7-7-7" }))), /* @__PURE__ */ React.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ React.createElement(CommandIcon, { ariaLabel: navigateUpKeyAriaLabel }, /* @__PURE__ */ React.createElement("path", { d: "m5 12 7-7 7 7" }), /* @__PURE__ */ React.createElement("path", { d: "M12 19V5" }))), /* @__PURE__ */ React.createElement("span", { className: "DocSearch-Label" }, navigateText)), /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ React.createElement(CommandIcon, { ariaLabel: selectKeyAriaLabel }, /* @__PURE__ */ React.createElement("polyline", { points: "9 10 4 15 9 20" }), /* @__PURE__ */ React.createElement("path", { d: "M20 4v7a4 4 0 0 1-4 4H4" }))), /* @__PURE__ */ React.createElement("span", { className: "DocSearch-Label" }, isAskAiActive ? submitQuestionText : selectText)), /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ React.createElement("span", { className: "DocSearch-Escape-Key" }, "ESC")), /* @__PURE__ */ React.createElement("span", {
538
+ const hasFooterAction = footerAction !== null && footerAction !== void 0 && typeof footerAction !== "boolean";
539
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("ul", { className: "DocSearch-Commands" }, /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ React.createElement(CommandIcon, { ariaLabel: navigateDownKeyAriaLabel }, /* @__PURE__ */ React.createElement("path", { d: "M12 5v14" }), /* @__PURE__ */ React.createElement("path", { d: "m19 12-7 7-7-7" }))), /* @__PURE__ */ React.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ React.createElement(CommandIcon, { ariaLabel: navigateUpKeyAriaLabel }, /* @__PURE__ */ React.createElement("path", { d: "m5 12 7-7 7 7" }), /* @__PURE__ */ React.createElement("path", { d: "M12 19V5" }))), /* @__PURE__ */ React.createElement("span", { className: "DocSearch-Label" }, navigateText)), /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ React.createElement(CommandIcon, { ariaLabel: selectKeyAriaLabel }, /* @__PURE__ */ React.createElement("polyline", { points: "9 10 4 15 9 20" }), /* @__PURE__ */ React.createElement("path", { d: "M20 4v7a4 4 0 0 1-4 4H4" }))), /* @__PURE__ */ React.createElement("span", { className: "DocSearch-Label" }, isAskAiActive ? submitQuestionText : selectText)), /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("kbd", { className: "DocSearch-Commands-Key" }, /* @__PURE__ */ React.createElement("span", { className: "DocSearch-Escape-Key" }, "ESC")), /* @__PURE__ */ React.createElement("span", {
539
540
  className: "DocSearch-Label",
540
541
  "aria-label": closeKeyAriaLabel
541
- }, isAskAiActive ? backToSearchText : closeText))));
542
+ }, isAskAiActive ? backToSearchText : closeText))), /* @__PURE__ */ React.createElement("div", { className: "DocSearch-Footer-Actions" }, hasFooterAction && /* @__PURE__ */ React.createElement("div", { className: "DocSearch-Footer-Action" }, footerAction), /* @__PURE__ */ React.createElement("div", { className: "DocSearch-Logo" }, /* @__PURE__ */ React.createElement(AlgoliaLogo, { translations: { poweredByText } }))));
542
543
  }
543
544
 
544
545
  //#endregion
@@ -720,7 +721,7 @@ function useTrapFocus({ container }) {
720
721
 
721
722
  //#endregion
722
723
  //#region src/hooks/useDocSearchModalEffects.ts
723
- function useDocSearchModalEffects({ initialScrollY, modalRef, snippetLength, theme }) {
724
+ function useDocSearchModalEffects({ initialScrollY, modalRef, theme }) {
724
725
  useTheme({ theme });
725
726
  React.useEffect(() => {
726
727
  document.body.classList.add("DocSearch--active");
@@ -740,9 +741,6 @@ function useDocSearchModalEffects({ initialScrollY, modalRef, snippetLength, the
740
741
  document.body.style.marginInlineEnd = "0px";
741
742
  };
742
743
  }, []);
743
- React.useEffect(() => {
744
- if (window.matchMedia("(max-width: 768px)").matches) snippetLength.current = 5;
745
- }, [snippetLength]);
746
744
  React.useEffect(() => {
747
745
  function setFullViewportHeight() {
748
746
  if (modalRef.current) {
@@ -760,7 +758,7 @@ function useDocSearchModalEffects({ initialScrollY, modalRef, snippetLength, the
760
758
 
761
759
  //#endregion
762
760
  //#region src/hooks/useModalEnvironment.ts
763
- function useModalEnvironment({ getEnvironmentProps, containerRef, dropdownRef, formElementRef, inputRef, initialScrollY, modalRef, snippetLength, theme }) {
761
+ function useModalEnvironment({ getEnvironmentProps, containerRef, dropdownRef, formElementRef, inputRef, initialScrollY, modalRef, theme }) {
764
762
  useTouchEvents({
765
763
  getEnvironmentProps,
766
764
  panelElement: dropdownRef.current,
@@ -771,7 +769,6 @@ function useModalEnvironment({ getEnvironmentProps, containerRef, dropdownRef, f
771
769
  useDocSearchModalEffects({
772
770
  initialScrollY,
773
771
  modalRef,
774
- snippetLength,
775
772
  theme
776
773
  });
777
774
  }
@@ -784,8 +781,7 @@ function useModalRefs() {
784
781
  modalRef: React.useRef(null),
785
782
  formElementRef: React.useRef(null),
786
783
  dropdownRef: React.useRef(null),
787
- inputRef: React.useRef(null),
788
- snippetLength: React.useRef(15)
784
+ inputRef: React.useRef(null)
789
785
  };
790
786
  }
791
787
 
@@ -1178,7 +1174,7 @@ function buildNoQuerySources({ recentSearches, favoriteSearches, saveRecentSearc
1178
1174
  }
1179
1175
  }];
1180
1176
  }
1181
- async function buildQuerySources({ query, state: sourcesState, setContext, setStatus, searchClient, indexes, snippetLength, insights, appId, apiKey, maxResultsPerGroup, transformItems = identity, saveRecentSearch, onClose, facetSelections }) {
1177
+ async function buildQuerySources({ query, state: sourcesState, setContext, setStatus, searchClient, indexes, insights, appId, apiKey, maxResultsPerGroup, transformItems = identity, saveRecentSearch, onClose, facetSelections }) {
1182
1178
  const insightsActive = insights;
1183
1179
  try {
1184
1180
  const { results } = await searchClient.search({ requests: indexes.map((index) => {
@@ -1202,13 +1198,13 @@ async function buildQuerySources({ query, state: sourcesState, setContext, setSt
1202
1198
  "url"
1203
1199
  ],
1204
1200
  attributesToSnippet: (_searchParams$attribu2 = searchParams === null || searchParams === void 0 ? void 0 : searchParams.attributesToSnippet) !== null && _searchParams$attribu2 !== void 0 ? _searchParams$attribu2 : [
1205
- `hierarchy.lvl1:${snippetLength.current}`,
1206
- `hierarchy.lvl2:${snippetLength.current}`,
1207
- `hierarchy.lvl3:${snippetLength.current}`,
1208
- `hierarchy.lvl4:${snippetLength.current}`,
1209
- `hierarchy.lvl5:${snippetLength.current}`,
1210
- `hierarchy.lvl6:${snippetLength.current}`,
1211
- `content:${snippetLength.current}`
1201
+ `hierarchy.lvl1:${15}`,
1202
+ `hierarchy.lvl2:${15}`,
1203
+ `hierarchy.lvl3:${15}`,
1204
+ `hierarchy.lvl4:${15}`,
1205
+ `hierarchy.lvl5:${15}`,
1206
+ `hierarchy.lvl6:${15}`,
1207
+ `content:${15}`
1212
1208
  ],
1213
1209
  snippetEllipsisText: (_searchParams$snippet = searchParams === null || searchParams === void 0 ? void 0 : searchParams.snippetEllipsisText) !== null && _searchParams$snippet !== void 0 ? _searchParams$snippet : "…",
1214
1210
  highlightPreTag: (_searchParams$highlig = searchParams === null || searchParams === void 0 ? void 0 : searchParams.highlightPreTag) !== null && _searchParams$highlig !== void 0 ? _searchParams$highlig : "<mark>",
@@ -1272,4 +1268,4 @@ function normalizeDocSearchIndexes({ indices }) {
1272
1268
 
1273
1269
  //#endregion
1274
1270
  export { noop as C, SOURCE_IDS as D, identity as E, getCollection as O, scrollTo as S, isModifierEvent as T, Hit as _, NoResultsScreen as a, SearchBoxForm as b, Results as c, useRefreshOnInitialQuery as d, useModalRefs as f, useDocSearchFacets as g, useSendItemClickEvent as h, ResultsScreen as i, useStoredDocSearches as l, useInitialModalQuery as m, buildNoQuerySources as n, ErrorScreen as o, useModalEnvironment as p, buildQuerySources as r, StoredSearchesSections as s, normalizeDocSearchIndexes as t, useSaveRecentSearch as u, Footer as v, isQueryEmpty as w, FacetBar as x, ModalShell as y };
1275
- //# sourceMappingURL=normalizeDocSearchIndexes-D8P3VEXa.js.map
1271
+ //# sourceMappingURL=normalizeDocSearchIndexes-ChnVvoVt.js.map