@docsearch/react 5.0.0 → 5.0.2
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.
- package/README.md +3 -3
- package/dist/esm/{AskAiScreenState-Sqbn60f2.d.ts → AskAiScreenState-DuzmHxUz.d.ts} +3 -3
- package/dist/esm/{DocSearch-BVqxFxTw.d.ts → DocSearch-2gNxdJcC.d.ts} +3 -3
- package/dist/esm/{DocSearchAskAiModal-DpB7pLCC.d.ts → DocSearchAskAiModal-BY3KtJ54.d.ts} +4 -4
- package/dist/esm/{DocSearchAskAiModal-ByqIW5ZA.js → DocSearchAskAiModal-mjZ_EYK1.js} +7 -4
- package/dist/esm/{DocSearchAskAiModal-ByqIW5ZA.js.map → DocSearchAskAiModal-mjZ_EYK1.js.map} +1 -1
- package/dist/esm/{DocSearchButton-CZM_jACU.d.ts → DocSearchButton-DyJd_QGM.d.ts} +2 -2
- package/dist/esm/{DocSearchModal-CITTG0fe.js → DocSearchModal-Cgdi4eHY.js} +2 -2
- package/dist/esm/{DocSearchModal-CITTG0fe.js.map → DocSearchModal-Cgdi4eHY.js.map} +1 -1
- package/dist/esm/askaiModal.d.ts +1 -1
- package/dist/esm/askaiModal.js +1 -1
- package/dist/esm/button.d.ts +1 -1
- package/dist/esm/docsearch.d.ts +2 -0
- package/dist/esm/docsearch.js +41 -0
- package/dist/esm/docsearch.js.map +1 -0
- package/dist/esm/docsearchAi.d.ts +2 -2
- package/dist/esm/docsearchAi.js +1 -1
- package/dist/esm/{index-Bqqv4HmN.d.ts → index-BijiN4hK.d.ts} +2 -2
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +4 -40
- package/dist/esm/modal.d.ts +1 -1
- package/dist/esm/modal.js +1 -1
- package/dist/esm/{normalizeDocSearchIndexes-ChnVvoVt.js → normalizeDocSearchIndexes-CFHzf-sx.js} +2 -2
- package/dist/esm/normalizeDocSearchIndexes-CFHzf-sx.js.map +1 -0
- package/dist/esm/sidepanel.d.ts +3 -3
- package/dist/esm/sidepanel.js +1 -1
- package/dist/esm/{useDocSearchKeyboardEvents-u23fFhR9.d.ts → useDocSearchKeyboardEvents-B7PKBkuX.d.ts} +2 -2
- package/dist/esm/useDocSearchKeyboardEvents.d.ts +1 -1
- package/dist/esm/{useSuggestedQuestions-BjSZvxwr.js → useSuggestedQuestions-DitQZbae.js} +7 -3
- package/dist/esm/useSuggestedQuestions-DitQZbae.js.map +1 -0
- package/dist/esm/useTheme.d.ts +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/umd/index.js +81 -81
- package/dist/umd/index.js.map +1 -1
- package/package.json +5 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/normalizeDocSearchIndexes-ChnVvoVt.js.map +0 -1
- package/dist/esm/useSuggestedQuestions-BjSZvxwr.js.map +0 -1
|
@@ -1 +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,UA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,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
|
+
{"version":3,"file":"DocSearchModal-Cgdi4eHY.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,EAC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d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as DocSearchAskAiModalProps, r as DocSearchAskAiModalTranslations, t as DocSearchAskAiModal } from "./DocSearchAskAiModal-
|
|
1
|
+
import { n as DocSearchAskAiModalProps, r as DocSearchAskAiModalTranslations, t as DocSearchAskAiModal } from "./DocSearchAskAiModal-BY3KtJ54.js";
|
|
2
2
|
export { DocSearchAskAiModal, DocSearchAskAiModalProps, DocSearchAskAiModalTranslations };
|
package/dist/esm/askaiModal.js
CHANGED
package/dist/esm/button.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as DocSearchButton, r as DocSearchButtonProps, t as ButtonTranslations } from "./DocSearchButton-
|
|
1
|
+
import { n as DocSearchButton, r as DocSearchButtonProps, t as ButtonTranslations } from "./DocSearchButton-DyJd_QGM.js";
|
|
2
2
|
export { ButtonTranslations, DocSearchButton, DocSearchButtonProps };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DocSearchProps, c as DocSearchTranslations, i as DocSearchInner, l as HitComponentProps, n as DocSearchFacet, o as DocSearchRef, r as DocSearchIndex, s as DocSearchTransformClient, t as DocSearch, u as ResultsFooterComponentProps } from "./DocSearch-2gNxdJcC.js";
|
|
2
|
+
export { DocSearch, DocSearchFacet, DocSearchIndex, DocSearchInner, DocSearchProps, type DocSearchRef, DocSearchTransformClient, DocSearchTranslations, HitComponentProps, ResultsFooterComponentProps };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { t as _objectSpread2 } from "./objectSpread2-BNmiQYyW.js";
|
|
2
|
+
import { t as DocSearchButton } from "./DocSearchButton-CaxxOzQU.js";
|
|
3
|
+
import { t as _objectWithoutProperties } from "./objectWithoutProperties-phqYxDS0.js";
|
|
4
|
+
import { t as DocSearchModal } from "./DocSearchModal-Cgdi4eHY.js";
|
|
5
|
+
import { DocSearch as DocSearch$1, useDocSearch } from "@docsearch/core";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { createPortal } from "react-dom";
|
|
8
|
+
|
|
9
|
+
//#region src/DocSearch.tsx
|
|
10
|
+
const _excluded = ["appId", "apiKey"];
|
|
11
|
+
function DocSearchComponent(_ref, ref) {
|
|
12
|
+
let { appId, apiKey } = _ref, props = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
+
return /* @__PURE__ */ React.createElement(DocSearch$1, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
14
|
+
appId,
|
|
15
|
+
apiKey,
|
|
16
|
+
ref
|
|
17
|
+
}), /* @__PURE__ */ React.createElement(DocSearchInner, props));
|
|
18
|
+
}
|
|
19
|
+
const DocSearch = React.forwardRef(DocSearchComponent);
|
|
20
|
+
function DocSearchInner(props) {
|
|
21
|
+
var _props$translations, _props$translations2, _props$portalContaine;
|
|
22
|
+
const { searchButtonRef, keyboardShortcuts, isModalActive, initialQuery, openModal, closeModal, appId, apiKey } = useDocSearch();
|
|
23
|
+
if (!appId || !apiKey) throw new Error("`DocSearch` requires `appId` and `apiKey` props.");
|
|
24
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DocSearchButton, {
|
|
25
|
+
keyboardShortcuts,
|
|
26
|
+
ref: searchButtonRef,
|
|
27
|
+
translations: (_props$translations = props.translations) === null || _props$translations === void 0 ? void 0 : _props$translations.button,
|
|
28
|
+
onClick: openModal
|
|
29
|
+
}), isModalActive && createPortal(/* @__PURE__ */ React.createElement(DocSearchModal, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
30
|
+
appId,
|
|
31
|
+
apiKey,
|
|
32
|
+
initialScrollY: window.scrollY,
|
|
33
|
+
initialQuery,
|
|
34
|
+
translations: props === null || props === void 0 || (_props$translations2 = props.translations) === null || _props$translations2 === void 0 ? void 0 : _props$translations2.modal,
|
|
35
|
+
onClose: closeModal
|
|
36
|
+
})), (_props$portalContaine = props.portalContainer) !== null && _props$portalContaine !== void 0 ? _props$portalContaine : document.body));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { DocSearch, DocSearchInner };
|
|
41
|
+
//# sourceMappingURL=docsearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docsearch.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,5 +1,5 @@
|
|
|
1
|
-
import { o as ToolCalls } from "./index-
|
|
2
|
-
import { a as DocSearchProps } from "./DocSearch-
|
|
1
|
+
import { o as ToolCalls } from "./index-BijiN4hK.js";
|
|
2
|
+
import { a as DocSearchProps } from "./DocSearch-2gNxdJcC.js";
|
|
3
3
|
import { DocSearchRef, InitialAskAiMessage } from "@docsearch/core";
|
|
4
4
|
import React, { JSX } from "react";
|
|
5
5
|
//#region src/DocSearchAI.d.ts
|
package/dist/esm/docsearchAi.js
CHANGED
|
@@ -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-
|
|
4
|
+
import { t as DocSearchAskAiModal } from "./DocSearchAskAiModal-mjZ_EYK1.js";
|
|
5
5
|
import { DocSearch, useDocSearch } from "@docsearch/core";
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { createPortal } from "react-dom";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AutocompleteContext, AutocompleteInsightsApi, AutocompleteState, BaseItem } from "@algolia/autocomplete-core";
|
|
2
2
|
import { Hit } from "algoliasearch/lite";
|
|
3
|
-
import { UIMessage } from "@ai-sdk/react";
|
|
4
3
|
import "ai";
|
|
4
|
+
import { UIMessage } from "@ai-sdk/react";
|
|
5
5
|
//#region src/types/DocSearchHit.d.ts
|
|
6
6
|
type ContentType = 'askAI' | 'content' | 'lvl0' | 'lvl1' | 'lvl2' | 'lvl3' | 'lvl4' | 'lvl5' | 'lvl6';
|
|
7
7
|
interface DocSearchHitAttributeHighlightResult {
|
|
@@ -230,4 +230,4 @@ type SuggestedQuestion = {
|
|
|
230
230
|
type SuggestedQuestionHit = Hit<SuggestedQuestion>;
|
|
231
231
|
//#endregion
|
|
232
232
|
export { StoredDocSearchHit as a, AskAiFeedbackReason as c, DocSearchHit as d, StoredAskAiState as i, OnAskAiFeedback as l, SuggestedQuestionHit as n, ToolCalls as o, StoredAskAiMessage as r, AskAiFeedbackPayload as s, SuggestedQuestion as t, DocSearchState as u };
|
|
233
|
-
//# sourceMappingURL=index-
|
|
233
|
+
//# sourceMappingURL=index-BijiN4hK.d.ts.map
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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-
|
|
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-BijiN4hK.js";
|
|
2
2
|
import { t as DocSearchTheme } from "./DocSearchTheme-DvL4mf0D.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-
|
|
4
|
-
import { n as useDocSearchKeyboardEvents, r as KeyboardShortcuts, t as UseDocSearchKeyboardEventsProps } from "./useDocSearchKeyboardEvents-
|
|
5
|
-
import { n as DocSearchButton, r as DocSearchButtonProps, t as ButtonTranslations } from "./DocSearchButton-
|
|
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-2gNxdJcC.js";
|
|
4
|
+
import { n as useDocSearchKeyboardEvents, r as KeyboardShortcuts, t as UseDocSearchKeyboardEventsProps } from "./useDocSearchKeyboardEvents-B7PKBkuX.js";
|
|
5
|
+
import { n as DocSearchButton, r as DocSearchButtonProps, t as ButtonTranslations } from "./DocSearchButton-DyJd_QGM.js";
|
|
6
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-
|
|
7
|
+
import { n as DocSearchAskAiModalProps, r as DocSearchAskAiModalTranslations, t as DocSearchAskAiModal } from "./DocSearchAskAiModal-BY3KtJ54.js";
|
|
8
8
|
import { version } from "./version.js";
|
|
9
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,45 +1,9 @@
|
|
|
1
|
-
import { t as _objectSpread2 } from "./objectSpread2-BNmiQYyW.js";
|
|
2
1
|
import { t as DocSearchButton } from "./DocSearchButton-CaxxOzQU.js";
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as DocSearchModal } from "./DocSearchModal-CITTG0fe.js";
|
|
2
|
+
import { t as DocSearchAskAiModal } from "./DocSearchAskAiModal-mjZ_EYK1.js";
|
|
3
|
+
import { t as DocSearchModal } from "./DocSearchModal-Cgdi4eHY.js";
|
|
6
4
|
import { version } from "./version.js";
|
|
5
|
+
import { DocSearch, DocSearchInner } from "./docsearch.js";
|
|
7
6
|
import { DocSearchAI, DocSearchAIInner } from "./docsearchAi.js";
|
|
8
7
|
import { useDocSearchKeyboardEvents } from "./useDocSearchKeyboardEvents.js";
|
|
9
|
-
import { DocSearch as DocSearch$1, useDocSearch } from "@docsearch/core";
|
|
10
|
-
import React from "react";
|
|
11
|
-
import { createPortal } from "react-dom";
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
const _excluded = ["appId", "apiKey"];
|
|
15
|
-
function DocSearchComponent(_ref, ref) {
|
|
16
|
-
let { appId, apiKey } = _ref, props = _objectWithoutProperties(_ref, _excluded);
|
|
17
|
-
return /* @__PURE__ */ React.createElement(DocSearch$1, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
18
|
-
appId,
|
|
19
|
-
apiKey,
|
|
20
|
-
ref
|
|
21
|
-
}), /* @__PURE__ */ React.createElement(DocSearchInner, props));
|
|
22
|
-
}
|
|
23
|
-
const DocSearch = React.forwardRef(DocSearchComponent);
|
|
24
|
-
function DocSearchInner(props) {
|
|
25
|
-
var _props$translations, _props$translations2, _props$portalContaine;
|
|
26
|
-
const { searchButtonRef, keyboardShortcuts, isModalActive, initialQuery, openModal, closeModal, appId, apiKey } = useDocSearch();
|
|
27
|
-
if (!appId || !apiKey) throw new Error("`DocSearch` requires `appId` and `apiKey` props.");
|
|
28
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DocSearchButton, {
|
|
29
|
-
keyboardShortcuts,
|
|
30
|
-
ref: searchButtonRef,
|
|
31
|
-
translations: (_props$translations = props.translations) === null || _props$translations === void 0 ? void 0 : _props$translations.button,
|
|
32
|
-
onClick: openModal
|
|
33
|
-
}), isModalActive && createPortal(/* @__PURE__ */ React.createElement(DocSearchModal, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
34
|
-
appId,
|
|
35
|
-
apiKey,
|
|
36
|
-
initialScrollY: window.scrollY,
|
|
37
|
-
initialQuery,
|
|
38
|
-
translations: props === null || props === void 0 || (_props$translations2 = props.translations) === null || _props$translations2 === void 0 ? void 0 : _props$translations2.modal,
|
|
39
|
-
onClose: closeModal
|
|
40
|
-
})), (_props$portalContaine = props.portalContainer) !== null && _props$portalContaine !== void 0 ? _props$portalContaine : document.body));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
|
-
export { DocSearch, DocSearchAI, DocSearchAIInner, DocSearchAskAiModal, DocSearchButton, DocSearchInner, DocSearchModal, useDocSearchKeyboardEvents, version };
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
|
9
|
+
export { DocSearch, DocSearchAI, DocSearchAIInner, DocSearchAskAiModal, DocSearchButton, DocSearchInner, DocSearchModal, useDocSearchKeyboardEvents, version };
|
package/dist/esm/modal.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as DocSearchModal, f as DocSearchModalProps, p as ModalTranslations } from "./DocSearch-
|
|
1
|
+
import { d as DocSearchModal, f as DocSearchModalProps, p as ModalTranslations } from "./DocSearch-2gNxdJcC.js";
|
|
2
2
|
export { DocSearchModal, DocSearchModalProps, ModalTranslations };
|
package/dist/esm/modal.js
CHANGED
package/dist/esm/{normalizeDocSearchIndexes-ChnVvoVt.js → normalizeDocSearchIndexes-CFHzf-sx.js}
RENAMED
|
@@ -578,7 +578,7 @@ function useFacetValues({ facets, indexes, searchClient }) {
|
|
|
578
578
|
var _result$facets;
|
|
579
579
|
Object.entries((_result$facets = res.facets) !== null && _result$facets !== void 0 ? _result$facets : {}).forEach(([facet, values]) => {
|
|
580
580
|
if (!valuesByFacet[facet]) return;
|
|
581
|
-
valuesByFacet[facet] = Array.from(/* @__PURE__ */ new Set([...valuesByFacet[facet], ...Object.keys(values)])).sort();
|
|
581
|
+
valuesByFacet[facet] = Array.from(/* @__PURE__ */ new Set([...valuesByFacet[facet], ...Object.keys(values)])).sort((a, b) => a.localeCompare(b, void 0, { sensitivity: "base" }));
|
|
582
582
|
});
|
|
583
583
|
});
|
|
584
584
|
setFacetValues(valuesByFacet);
|
|
@@ -1268,4 +1268,4 @@ function normalizeDocSearchIndexes({ indices }) {
|
|
|
1268
1268
|
|
|
1269
1269
|
//#endregion
|
|
1270
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 };
|
|
1271
|
-
//# sourceMappingURL=normalizeDocSearchIndexes-
|
|
1271
|
+
//# sourceMappingURL=normalizeDocSearchIndexes-CFHzf-sx.js.map
|