@docsearch/react 4.6.3 → 5.0.0-beta.0
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 +0 -2
- package/dist/esm/AskAiScreenState-D0IZsCMJ.d.ts +106 -0
- package/dist/esm/DocSearch-Dq5Utfyb.d.ts +295 -0
- package/dist/esm/DocSearchAskAiModal-BwbMrrHv.d.ts +48 -0
- package/dist/esm/DocSearchAskAiModal-CCrk6YLb.js +954 -0
- package/dist/esm/DocSearchAskAiModal-CCrk6YLb.js.map +1 -0
- package/dist/esm/DocSearchButton-CRlNPf5k.d.ts +18 -0
- package/dist/esm/DocSearchButton-CaxxOzQU.js +71 -0
- package/dist/esm/DocSearchButton-CaxxOzQU.js.map +1 -0
- package/dist/esm/DocSearchModal-CpvDjo1O.js +250 -0
- package/dist/esm/DocSearchModal-CpvDjo1O.js.map +1 -0
- package/dist/esm/DocSearchTheme-DvL4mf0D.d.ts +5 -0
- package/dist/esm/askaiModal.d.ts +2 -0
- package/dist/esm/askaiModal.js +3 -0
- package/dist/esm/button.d.ts +2 -0
- package/dist/esm/button.js +3 -0
- package/dist/esm/docsearchAi.d.ts +220 -0
- package/dist/esm/docsearchAi.js +34 -0
- package/dist/esm/docsearchAi.js.map +1 -0
- package/dist/esm/index-Dl8FMlR5.d.ts +223 -0
- package/dist/esm/index.d.ts +9 -655
- package/dist/esm/index.js +35 -3
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/keyboard-BkSdCzTU.js +9 -0
- package/dist/esm/keyboard-BkSdCzTU.js.map +1 -0
- package/dist/esm/keyboardShortcuts-C-lx6Xt7.js +25 -0
- package/dist/esm/keyboardShortcuts-C-lx6Xt7.js.map +1 -0
- package/dist/esm/modal.d.ts +2 -0
- package/dist/esm/modal.js +3 -0
- package/dist/esm/normalizeDocSearchIndexes-DAzlMybx.js +1240 -0
- package/dist/esm/normalizeDocSearchIndexes-DAzlMybx.js.map +1 -0
- package/dist/esm/objectSpread2-BNmiQYyW.js +67 -0
- package/dist/esm/objectWithoutProperties-phqYxDS0.js +53 -0
- package/dist/esm/objectWithoutProperties-phqYxDS0.js.map +1 -0
- package/dist/esm/sidepanel.d.ts +395 -0
- package/dist/esm/sidepanel.js +773 -0
- package/dist/esm/sidepanel.js.map +1 -0
- package/dist/esm/useDocSearchKeyboardEvents-68G8dw6c.d.ts +43 -0
- package/dist/esm/useDocSearchKeyboardEvents.d.ts +2 -41
- package/dist/esm/useDocSearchKeyboardEvents.js +43 -1
- package/dist/esm/useDocSearchKeyboardEvents.js.map +1 -0
- package/dist/esm/useSearchClient-mIHVB6ga.js +433 -0
- package/dist/esm/useSearchClient-mIHVB6ga.js.map +1 -0
- package/dist/esm/useSuggestedQuestions-D2TGVPsI.js +1112 -0
- package/dist/esm/useSuggestedQuestions-D2TGVPsI.js.map +1 -0
- package/dist/esm/useTheme.d.ts +7 -6
- package/dist/esm/useTheme.js +21 -1
- package/dist/esm/useTheme.js.map +1 -0
- package/dist/esm/version.d.ts +4 -2
- package/dist/esm/version.js +6 -1
- package/dist/esm/version.js.map +1 -0
- package/dist/umd/index.js +175 -5
- package/dist/umd/index.js.map +1 -1
- package/package.json +31 -34
- package/style/askai.js +1 -0
- package/button.js +0 -1
- package/dist/esm/DocSearchButton.d.ts +0 -18
- package/dist/esm/DocSearchButton.js +0 -1
- package/dist/esm/DocSearchModal.d.ts +0 -444
- package/dist/esm/DocSearchModal.js +0 -3
- package/dist/esm/Sidepanel.d.ts +0 -371
- package/dist/esm/Sidepanel.js +0 -3
- package/dist/umd/DocSearchModal.js +0 -5
- package/dist/umd/DocSearchModal.js.map +0 -1
- package/dist/umd/DocsearchButton.js +0 -3
- package/dist/umd/DocsearchButton.js.map +0 -1
- package/dist/umd/Sidepanel.js +0 -5
- package/dist/umd/Sidepanel.js.map +0 -1
- package/dist/umd/useDocSearchKeyboardEvents.js +0 -3
- package/dist/umd/useDocSearchKeyboardEvents.js.map +0 -1
- package/dist/umd/useTheme.js +0 -3
- package/dist/umd/useTheme.js.map +0 -1
- package/dist/umd/version.js +0 -3
- package/dist/umd/version.js.map +0 -1
- package/modal.js +0 -1
- package/sidepanel.js +0 -1
- package/useDocSearchKeyboardEvents.js +0 -1
- package/useTheme.js +0 -1
- package/version.js +0 -1
|
@@ -0,0 +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 * Name of the algolia index to query.\n *\n * @deprecated `indexName` will be removed in a future version. Please use\n * `indices` property going forward.\n */\n indexName?: 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 /**\n * Additional algolia search parameters to merge into each query.\n *\n * @deprecated `searchParameters` will be removed in a future version. Please\n * use `indices` property going forward.\n */\n searchParameters?: SearchParamsObject;\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 props: DocSearchProps,\n ref: React.ForwardedRef<DocSearchRef>\n): JSX.Element {\n return (\n <DocSearchProvider {...props} ref={ref}>\n <DocSearchInner {...props} />\n </DocSearchProvider>\n );\n}\n\nexport const DocSearch = React.forwardRef(DocSearchComponent);\n\nexport function DocSearchInner(props: DocSearchProps): JSX.Element {\n const {\n searchButtonRef,\n keyboardShortcuts,\n isModalActive,\n initialQuery,\n openModal,\n closeModal,\n } = useDocSearch();\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 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":";;;;;;;;;;;;AA4KA,SAAS,mBACP,OACA,KACa;CACb,OACE,oCAACA,+CAAsB,cAAY,KAEhB,GADjB,oCAAC,gBAAmB,KAAQ,CACX;AAEvB;AAEA,MAAa,YAAY,MAAM,WAAW,kBAAkB;AAE5D,SAAgB,eAAe,OAAoC;;CACjE,MAAM,EACJ,iBACA,mBACA,eACA,cACA,WACA,eACE,aAAa;CAEjB,OACE,0DACE,oCAAC,iBAAD;EACqB;EACnB,KAAK;EACL,qCAAc,MAAM,wFAAc;EAClC,SAAS;CACV,IACA,iBACC,aACE,oCAAC,kDACK;EACJ,gBAAgB,OAAO;EACT;EACd,4EAAc,MAAO,0FAAc;EACnC,SAAS;EACV,6BACD,MAAM,wFAAmB,SAAS,IACpC,CACF;AAEN"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/utils/keyboard.ts
|
|
2
|
+
const ACTION_KEY_DEFAULT = "Ctrl";
|
|
3
|
+
function isAppleDevice() {
|
|
4
|
+
return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { isAppleDevice as n, ACTION_KEY_DEFAULT as t };
|
|
9
|
+
//# sourceMappingURL=keyboard-BkSdCzTU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboard-BkSdCzTU.js","names":[],"sources":["../../src/utils/keyboard.ts"],"sourcesContent":["export const ACTION_KEY_DEFAULT = 'Ctrl';\nexport const ACTION_KEY_APPLE = '⌘';\n\nexport function isAppleDevice(): boolean {\n return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);\n}\n"],"mappings":";AAAA,MAAa,qBAAqB;AAGlC,SAAgB,gBAAyB;CACvC,OAAO,0BAA0B,KAAK,UAAU,QAAQ;AAC1D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { t as _objectSpread2 } from "./objectSpread2-BNmiQYyW.js";
|
|
2
|
+
|
|
3
|
+
//#region src/constants/keyboardShortcuts.ts
|
|
4
|
+
/**
|
|
5
|
+
* Default keyboard shortcuts configuration for DocSearch. These values are used
|
|
6
|
+
* when no keyboardShortcuts prop is provided or when specific shortcuts are not
|
|
7
|
+
* configured.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_KEYBOARD_SHORTCUTS = {
|
|
10
|
+
"Ctrl/Cmd+K": true,
|
|
11
|
+
"/": true
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Merges user-provided keyboard shortcuts with defaults.
|
|
15
|
+
*
|
|
16
|
+
* @param userShortcuts - Optional user configuration.
|
|
17
|
+
* @returns Complete keyboard shortcuts configuration with defaults applied.
|
|
18
|
+
*/
|
|
19
|
+
function getKeyboardShortcuts(userShortcuts) {
|
|
20
|
+
return _objectSpread2(_objectSpread2({}, DEFAULT_KEYBOARD_SHORTCUTS), userShortcuts);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { getKeyboardShortcuts as t };
|
|
25
|
+
//# sourceMappingURL=keyboardShortcuts-C-lx6Xt7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboardShortcuts-C-lx6Xt7.js","names":[],"sources":["../../src/constants/keyboardShortcuts.ts"],"sourcesContent":["import type { KeyboardShortcuts } from '../types';\n\n/**\n * Default keyboard shortcuts configuration for DocSearch. These values are used\n * when no keyboardShortcuts prop is provided or when specific shortcuts are not\n * configured.\n */\nexport const DEFAULT_KEYBOARD_SHORTCUTS: Required<KeyboardShortcuts> = {\n 'Ctrl/Cmd+K': true,\n '/': true,\n} as const;\n\n/**\n * Merges user-provided keyboard shortcuts with defaults.\n *\n * @param userShortcuts - Optional user configuration.\n * @returns Complete keyboard shortcuts configuration with defaults applied.\n */\nexport function getKeyboardShortcuts(\n userShortcuts?: KeyboardShortcuts\n): Required<KeyboardShortcuts> {\n return {\n ...DEFAULT_KEYBOARD_SHORTCUTS,\n ...userShortcuts,\n };\n}\n"],"mappings":";;;;;;;;AAOA,MAAa,6BAA0D;CACrE,cAAc;CACd,KAAK;AACP;;;;;;;AAQA,SAAgB,qBACd,eAC6B;CAC7B,yCACK,6BACA,aACL;AACF"}
|