Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@docsearch/react

Package Overview
Dependencies
Maintainers
3
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@docsearch/react - npm Package Compare versions

Comparing version 3.0.0-alpha.41 to 3.0.0-alpha.42

dist/esm/__tests__/api.test.js

9

dist/esm/AlgoliaLogo.d.ts
/// <reference types="react" />
export declare function AlgoliaLogo(): JSX.Element;
declare type AlgoliaLogoTranslations = Partial<{
searchByText: string;
}>;
declare type AlgoliaLogoProps = {
translations?: AlgoliaLogoTranslations;
};
export declare function AlgoliaLogo({ translations }: AlgoliaLogoProps): JSX.Element;
export {};

8

dist/esm/AlgoliaLogo.js
import React from 'react';
export function AlgoliaLogo() {
export function AlgoliaLogo(_ref) {
var _ref$translations = _ref.translations,
translations = _ref$translations === void 0 ? {} : _ref$translations;
var _translations$searchB = translations.searchByText,
searchByText = _translations$searchB === void 0 ? 'Search by' : _translations$searchB;
return /*#__PURE__*/React.createElement("a", {

@@ -9,3 +13,3 @@ href: "https://www.algolia.com/docsearch",

className: "DocSearch-Label"
}, "Search by"), /*#__PURE__*/React.createElement("svg", {
}, searchByText), /*#__PURE__*/React.createElement("svg", {
width: "77",

@@ -12,0 +16,0 @@ height: "19"

@@ -1,5 +0,11 @@

import { AutocompleteState, AutocompleteOptions } from '@algolia/autocomplete-core';
import { SearchClient } from 'algoliasearch/lite';
import type { AutocompleteState, AutocompleteOptions } from '@algolia/autocomplete-core';
import type { SearchOptions } from '@algolia/client-search';
import type { SearchClient } from 'algoliasearch/lite';
import React from 'react';
import { DocSearchHit, InternalDocSearchHit, StoredDocSearchHit } from './types';
import type { DocSearchHit, InternalDocSearchHit, StoredDocSearchHit } from './types';
import type { ButtonTranslations, ModalTranslations } from '.';
export declare type DocSearchTranslations = Partial<{
button: ButtonTranslations;
modal: ModalTranslations;
}>;
export interface DocSearchProps {

@@ -10,16 +16,17 @@ appId?: string;

placeholder?: string;
searchParameters?: any;
transformItems?(items: DocSearchHit[]): DocSearchHit[];
hitComponent?(props: {
searchParameters?: SearchOptions;
transformItems?: (items: DocSearchHit[]) => DocSearchHit[];
hitComponent?: (props: {
hit: InternalDocSearchHit | StoredDocSearchHit;
children: React.ReactNode;
}): JSX.Element;
resultsFooterComponent?(props: {
}) => JSX.Element;
resultsFooterComponent?: (props: {
state: AutocompleteState<InternalDocSearchHit>;
}): JSX.Element | null;
transformSearchClient?(searchClient: SearchClient): SearchClient;
}) => JSX.Element | null;
transformSearchClient?: (searchClient: SearchClient) => SearchClient;
disableUserPersonalization?: boolean;
initialQuery?: string;
navigator?: AutocompleteOptions<InternalDocSearchHit>['navigator'];
translations?: DocSearchTranslations;
}
export declare function DocSearch(props: DocSearchProps): JSX.Element;

@@ -11,3 +11,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

@@ -22,2 +22,4 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

export function DocSearch(props) {
var _props$translations, _props$translations2;
var searchButtonRef = React.useRef(null);

@@ -53,9 +55,11 @@

return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DocSearchButton, {
onClick: onOpen,
ref: searchButtonRef
ref: searchButtonRef,
translations: props === null || props === void 0 ? void 0 : (_props$translations = props.translations) === null || _props$translations === void 0 ? void 0 : _props$translations.button,
onClick: onOpen
}), isOpen && createPortal( /*#__PURE__*/React.createElement(DocSearchModal, _extends({}, props, {
initialScrollY: window.scrollY,
initialQuery: initialQuery,
translations: props === null || props === void 0 ? void 0 : (_props$translations2 = props.translations) === null || _props$translations2 === void 0 ? void 0 : _props$translations2.modal,
onClose: onClose
})), document.body));
}
import React from 'react';
declare type Translations = Partial<{
export declare type ButtonTranslations = Partial<{
buttonText: string;

@@ -7,5 +7,4 @@ buttonAriaLabel: string;

export declare type DocSearchButtonProps = React.ComponentProps<'button'> & {
translations?: Translations;
translations?: ButtonTranslations;
};
export declare const DocSearchButton: React.ForwardRefExoticComponent<Pick<DocSearchButtonProps, "form" | "slot" | "style" | "title" | "children" | "translations" | "key" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React.RefAttributes<HTMLButtonElement>>;
export {};
export declare const DocSearchButton: React.ForwardRefExoticComponent<Pick<DocSearchButtonProps, "translations" | "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement>> & React.RefAttributes<HTMLButtonElement>>;

@@ -0,1 +1,3 @@

var _excluded = ["translations"];
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

@@ -20,3 +22,3 @@

translations = _ref$translations === void 0 ? {} : _ref$translations,
props = _objectWithoutProperties(_ref, ["translations"]);
props = _objectWithoutProperties(_ref, _excluded);

@@ -23,0 +25,0 @@ var _translations$buttonT = translations.buttonText,

/// <reference types="react" />
import { DocSearchProps } from './DocSearch';
export interface DocSearchModalProps extends DocSearchProps {
import type { DocSearchProps } from './DocSearch';
import type { FooterTranslations } from './Footer';
import type { ScreenStateTranslations } from './ScreenState';
import type { SearchBoxTranslations } from './SearchBox';
export declare type ModalTranslations = Partial<{
searchBox: SearchBoxTranslations;
footer: FooterTranslations;
}> & ScreenStateTranslations;
export declare type DocSearchModalProps = DocSearchProps & {
initialScrollY: number;
onClose?(): void;
}
export declare function DocSearchModal({ appId, apiKey, indexName, placeholder, searchParameters, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, }: DocSearchModalProps): JSX.Element;
onClose?: () => void;
translations?: ModalTranslations;
};
export declare function DocSearchModal({ appId, apiKey, indexName, placeholder, searchParameters, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, }: DocSearchModalProps): JSX.Element;

@@ -0,4 +1,6 @@

var _excluded = ["footer", "searchBox"];
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

@@ -17,6 +19,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { createAutocomplete } from '@algolia/autocomplete-core';

@@ -60,4 +66,10 @@ import React from 'react';

_ref$initialQuery = _ref.initialQuery,
initialQueryFromProp = _ref$initialQuery === void 0 ? '' : _ref$initialQuery;
initialQueryFromProp = _ref$initialQuery === void 0 ? '' : _ref$initialQuery,
_ref$translations = _ref.translations,
translations = _ref$translations === void 0 ? {} : _ref$translations;
var footerTranslations = translations.footer,
searchBoxTranslations = translations.searchBox,
screenStateTranslations = _objectWithoutProperties(translations, _excluded);
var _React$useState = React.useState({

@@ -122,12 +134,10 @@ query: '',

navigator: navigator,
onStateChange: function onStateChange(_ref2) {
var state = _ref2.state;
setState(state);
onStateChange: function onStateChange(props) {
setState(props.state);
},
// @ts-ignore Temporarily ignore bad typing in autocomplete-core.
getSources: function getSources(_ref3) {
var query = _ref3.query,
state = _ref3.state,
setContext = _ref3.setContext,
setStatus = _ref3.setStatus;
getSources: function getSources(_ref2) {
var query = _ref2.query,
sourcesState = _ref2.state,
setContext = _ref2.setContext,
setStatus = _ref2.setStatus;

@@ -141,5 +151,5 @@ if (!query) {

sourceId: 'recentSearches',
onSelect: function onSelect(_ref4) {
var item = _ref4.item,
event = _ref4.event;
onSelect: function onSelect(_ref3) {
var item = _ref3.item,
event = _ref3.event;
saveRecentSearch(item);

@@ -151,4 +161,4 @@

},
getItemUrl: function getItemUrl(_ref5) {
var item = _ref5.item;
getItemUrl: function getItemUrl(_ref4) {
var item = _ref4.item;
return item.url;

@@ -161,5 +171,5 @@ },

sourceId: 'favoriteSearches',
onSelect: function onSelect(_ref6) {
var item = _ref6.item,
event = _ref6.event;
onSelect: function onSelect(_ref5) {
var item = _ref5.item,
event = _ref5.event;
saveRecentSearch(item);

@@ -171,4 +181,4 @@

},
getItemUrl: function getItemUrl(_ref7) {
var item = _ref7.item;
getItemUrl: function getItemUrl(_ref6) {
var item = _ref6.item;
return item.url;

@@ -203,4 +213,4 @@ },

throw error;
}).then(function (_ref8) {
var results = _ref8.results;
}).then(function (_ref7) {
var results = _ref7.results;
var _results$ = results[0],

@@ -214,3 +224,3 @@ hits = _results$.hits,

if (state.context.searchSuggestions.length < Object.keys(sources).length) {
if (sourcesState.context.searchSuggestions.length < Object.keys(sources).length) {
setContext({

@@ -227,5 +237,5 @@ searchSuggestions: Object.keys(sources)

sourceId: "hits".concat(index),
onSelect: function onSelect(_ref9) {
var item = _ref9.item,
event = _ref9.event;
onSelect: function onSelect(_ref8) {
var item = _ref8.item,
event = _ref8.event;
saveRecentSearch(item);

@@ -237,4 +247,4 @@

},
getItemUrl: function getItemUrl(_ref10) {
var item = _ref10.item;
getItemUrl: function getItemUrl(_ref9) {
var item = _ref9.item;
return item.url;

@@ -245,7 +255,6 @@ },

return item.hierarchy.lvl1;
})).map(transformItems).map(function (hits) {
return hits.map(function (item) {
})).map(transformItems).map(function (groupedHits) {
return groupedHits.map(function (item) {
return _objectSpread(_objectSpread({}, item), {}, {
// eslint-disable-next-line @typescript-eslint/camelcase
__docsearch_parent: item.type !== 'lvl1' && hits.find(function (siblingItem) {
__docsearch_parent: item.type !== 'lvl1' && groupedHits.find(function (siblingItem) {
return siblingItem.type === 'lvl1' && siblingItem.hierarchy.lvl1 === item.hierarchy.lvl1;

@@ -335,2 +344,4 @@ })

className: ['DocSearch', 'DocSearch-Container', state.status === 'stalled' && 'DocSearch-Container--Stalled', state.status === 'error' && 'DocSearch-Container--Errored'].filter(Boolean).join(' '),
role: "button",
tabIndex: 0,
onMouseDown: function onMouseDown(event) {

@@ -350,5 +361,6 @@ if (event.target === event.currentTarget) {

autoFocus: initialQuery.length === 0,
onClose: onClose,
inputRef: inputRef,
isFromSelection: Boolean(initialQuery) && initialQuery === initialQueryFromSelection
isFromSelection: Boolean(initialQuery) && initialQuery === initialQueryFromSelection,
translations: searchBoxTranslations,
onClose: onClose
}))), /*#__PURE__*/React.createElement("div", {

@@ -365,10 +377,13 @@ className: "DocSearch-Dropdown",

favoriteSearches: favoriteSearches,
inputRef: inputRef,
translations: screenStateTranslations,
onItemClick: function onItemClick(item) {
saveRecentSearch(item);
onClose();
},
inputRef: inputRef
}
}))), /*#__PURE__*/React.createElement("footer", {
className: "DocSearch-Footer"
}, /*#__PURE__*/React.createElement(Footer, null))));
}, /*#__PURE__*/React.createElement(Footer, {
translations: footerTranslations
}))));
}
/// <reference types="react" />
export declare function ErrorScreen(): JSX.Element;
export declare type ErrorScreenTranslations = Partial<{
titleText: string;
helpText: string;
}>;
declare type ErrorScreenProps = {
translations?: ErrorScreenTranslations;
};
export declare function ErrorScreen({ translations }: ErrorScreenProps): JSX.Element;
export {};
import React from 'react';
import { ErrorIcon } from './icons';
export function ErrorScreen() {
export function ErrorScreen(_ref) {
var _ref$translations = _ref.translations,
translations = _ref$translations === void 0 ? {} : _ref$translations;
var _translations$titleTe = translations.titleText,
titleText = _translations$titleTe === void 0 ? 'Unable to fetch results' : _translations$titleTe,
_translations$helpTex = translations.helpText,
helpText = _translations$helpTex === void 0 ? 'You might want to check your network connection.' : _translations$helpTex;
return /*#__PURE__*/React.createElement("div", {

@@ -10,5 +16,5 @@ className: "DocSearch-ErrorScreen"

className: "DocSearch-Title"
}, "Unable to fetch results"), /*#__PURE__*/React.createElement("p", {
}, titleText), /*#__PURE__*/React.createElement("p", {
className: "DocSearch-Help"
}, "You might want to check your network connection."));
}, helpText));
}
/// <reference types="react" />
export declare function Footer(): JSX.Element;
export declare type FooterTranslations = Partial<{
selectText: string;
navigateText: string;
closeText: string;
searchByText: string;
}>;
declare type FooterProps = Partial<{
translations: FooterTranslations;
}>;
export declare function Footer({ translations }: FooterProps): JSX.Element;
export {};
import React from 'react';
import { AlgoliaLogo } from './AlgoliaLogo';
export function Footer() {
function CommandIcon(props) {
return /*#__PURE__*/React.createElement("svg", {
width: "15",
height: "15"
}, /*#__PURE__*/React.createElement("g", {
fill: "none",
stroke: "currentColor",
strokeLinecap: "round",
strokeLinejoin: "round",
strokeWidth: "1.2"
}, props.children));
}
export function Footer(_ref) {
var _ref$translations = _ref.translations,
translations = _ref$translations === void 0 ? {} : _ref$translations;
var _translations$selectT = translations.selectText,
selectText = _translations$selectT === void 0 ? 'to select' : _translations$selectT,
_translations$navigat = translations.navigateText,
navigateText = _translations$navigat === void 0 ? 'to navigate' : _translations$navigat,
_translations$closeTe = translations.closeText,
closeText = _translations$closeTe === void 0 ? 'to close' : _translations$closeTe,
_translations$searchB = translations.searchByText,
searchByText = _translations$searchB === void 0 ? 'Search by' : _translations$searchB;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
className: "DocSearch-Logo"
}, /*#__PURE__*/React.createElement(AlgoliaLogo, null)), /*#__PURE__*/React.createElement("ul", {
}, /*#__PURE__*/React.createElement(AlgoliaLogo, {
translations: {
searchByText: searchByText
}
})), /*#__PURE__*/React.createElement("ul", {
className: "DocSearch-Commands"

@@ -14,3 +42,3 @@ }, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("span", {

className: "DocSearch-Label"
}, "to select")), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("span", {
}, selectText)), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("span", {
className: "DocSearch-Commands-Key"

@@ -25,3 +53,3 @@ }, /*#__PURE__*/React.createElement(CommandIcon, null, /*#__PURE__*/React.createElement("path", {

className: "DocSearch-Label"
}, "to navigate")), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("span", {
}, navigateText)), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("span", {
className: "DocSearch-Commands-Key"

@@ -32,16 +60,3 @@ }, /*#__PURE__*/React.createElement(CommandIcon, null, /*#__PURE__*/React.createElement("path", {

className: "DocSearch-Label"
}, "to close"))));
}
function CommandIcon(props) {
return /*#__PURE__*/React.createElement("svg", {
width: "15",
height: "15"
}, /*#__PURE__*/React.createElement("g", {
fill: "none",
stroke: "currentColor",
strokeLinecap: "round",
strokeLinejoin: "round",
strokeWidth: "1.2"
}, props.children));
}, closeText))));
}
import React from 'react';
import { DocSearchHit } from './types';
import type { InternalDocSearchHit, StoredDocSearchHit } from './types';
interface HitProps {
hit: DocSearchHit;
hit: InternalDocSearchHit | StoredDocSearchHit;
children: React.ReactNode;

@@ -6,0 +6,0 @@ }

import React from 'react';
export function SourceIcon(props) {
switch (props.type) {
case 'lvl1':
return /*#__PURE__*/React.createElement(LvlIcon, null);
case 'content':
return /*#__PURE__*/React.createElement(ContentIcon, null);
default:
return /*#__PURE__*/React.createElement(AnchorIcon, null);
}
}
function LvlIcon() {
var LvlIcon = function LvlIcon() {
return /*#__PURE__*/React.createElement("svg", {

@@ -27,2 +15,15 @@ width: "20",

}));
};
export function SourceIcon(props) {
switch (props.type) {
case 'lvl1':
return /*#__PURE__*/React.createElement(LvlIcon, null);
case 'content':
return /*#__PURE__*/React.createElement(ContentIcon, null);
default:
return /*#__PURE__*/React.createElement(AnchorIcon, null);
}
}

@@ -29,0 +30,0 @@

/// <reference types="react" />
import { ScreenStateProps } from './ScreenState';
import { InternalDocSearchHit } from './types';
declare type NoResultsScreenProps = ScreenStateProps<InternalDocSearchHit>;
export declare function NoResultsScreen(props: NoResultsScreenProps): JSX.Element;
import type { ScreenStateProps } from './ScreenState';
import type { InternalDocSearchHit } from './types';
export declare type NoResultsScreenTranslations = Partial<{
noResultsText: string;
suggestedQueryText: string;
openIssueText: string;
openIssueLinkText: string;
}>;
declare type NoResultsScreenProps = Omit<ScreenStateProps<InternalDocSearchHit>, 'translations'> & {
translations?: NoResultsScreenTranslations;
};
export declare function NoResultsScreen({ translations, ...props }: NoResultsScreenProps): JSX.Element;
export {};

@@ -0,1 +1,3 @@

var _excluded = ["translations"];
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

@@ -7,3 +9,3 @@

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }

@@ -14,5 +16,21 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React from 'react';
import { NoResultsIcon } from './icons';
export function NoResultsScreen(props) {
export function NoResultsScreen(_ref) {
var _ref$translations = _ref.translations,
translations = _ref$translations === void 0 ? {} : _ref$translations,
props = _objectWithoutProperties(_ref, _excluded);
var _translations$noResul = translations.noResultsText,
noResultsText = _translations$noResul === void 0 ? 'No results for' : _translations$noResul,
_translations$suggest = translations.suggestedQueryText,
suggestedQueryText = _translations$suggest === void 0 ? 'Try searching for' : _translations$suggest,
_translations$openIss = translations.openIssueText,
openIssueText = _translations$openIss === void 0 ? 'Believe this query should return results?' : _translations$openIss,
_translations$openIss2 = translations.openIssueLinkText,
openIssueLinkText = _translations$openIss2 === void 0 ? 'Let us know' : _translations$openIss2;
var searchSuggestions = props.state.context.searchSuggestions;

@@ -25,7 +43,7 @@ return /*#__PURE__*/React.createElement("div", {

className: "DocSearch-Title"
}, "No results for \"", /*#__PURE__*/React.createElement("strong", null, props.state.query), "\""), searchSuggestions && searchSuggestions.length > 0 && /*#__PURE__*/React.createElement("div", {
}, noResultsText, " \"", /*#__PURE__*/React.createElement("strong", null, props.state.query), "\""), searchSuggestions && searchSuggestions.length > 0 && /*#__PURE__*/React.createElement("div", {
className: "DocSearch-NoResults-Prefill-List"
}, /*#__PURE__*/React.createElement("p", {
className: "DocSearch-Help"
}, "Try searching for:"), /*#__PURE__*/React.createElement("ul", null, searchSuggestions.slice(0, 3).reduce(function (acc, search) {
}, suggestedQueryText, ":"), /*#__PURE__*/React.createElement("ul", null, searchSuggestions.slice(0, 3).reduce(function (acc, search) {
return [].concat(_toConsumableArray(acc), [/*#__PURE__*/React.createElement("li", {

@@ -36,2 +54,3 @@ key: search

key: search,
type: "button",
onClick: function onClick() {

@@ -45,7 +64,7 @@ props.setQuery(search.toLowerCase() + ' ');

className: "DocSearch-Help"
}, "Believe this query should return results?", ' ', /*#__PURE__*/React.createElement("a", {
}, "".concat(openIssueText, " "), /*#__PURE__*/React.createElement("a", {
href: "https://github.com/algolia/docsearch-configs/issues/new?template=Missing_results.md&title=[".concat(props.indexName, "]+Missing+results+for+query+\"").concat(props.state.query, "\""),
target: "_blank",
rel: "noopener noreferrer"
}, "Let us know"), "."));
}, openIssueLinkText), "."));
}

@@ -1,18 +0,18 @@

import { AutocompleteApi, AutocompleteState, BaseItem } from '@algolia/autocomplete-core';
import type { AutocompleteApi, AutocompleteState, BaseItem } from '@algolia/autocomplete-core';
import React from 'react';
import { DocSearchProps } from './DocSearch';
import { StoredDocSearchHit } from './types';
import type { DocSearchProps } from './DocSearch';
import type { StoredDocSearchHit } from './types';
interface ResultsProps<TItem extends BaseItem> extends AutocompleteApi<TItem, React.FormEvent, React.MouseEvent, React.KeyboardEvent> {
title: string;
collection: AutocompleteState<TItem>['collections'][0];
renderIcon(props: {
renderIcon: (props: {
item: TItem;
index: number;
}): React.ReactNode;
renderAction(props: {
}) => React.ReactNode;
renderAction: (props: {
item: TItem;
runDeleteTransition: (cb: () => void) => void;
runFavoriteTransition: (cb: () => void) => void;
}): React.ReactNode;
onItemClick(item: TItem): void;
}) => React.ReactNode;
onItemClick: (item: TItem) => void;
hitComponent: DocSearchProps['hitComponent'];

@@ -19,0 +19,0 @@ }

@@ -9,3 +9,3 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

@@ -12,0 +12,0 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

/// <reference types="react" />
import { ScreenStateProps } from './ScreenState';
import { InternalDocSearchHit } from './types';
declare type ResultsScreenProps = ScreenStateProps<InternalDocSearchHit>;
import type { ScreenStateProps } from './ScreenState';
import type { InternalDocSearchHit } from './types';
declare type ResultsScreenProps = Omit<ScreenStateProps<InternalDocSearchHit>, 'translations'>;
export declare function ResultsScreen(props: ResultsScreenProps): JSX.Element;
export {};

@@ -10,3 +10,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

className: "DocSearch-Dropdown-Container"
}, props.state.collections.map(function (collection, index) {
}, props.state.collections.map(function (collection) {
if (collection.items.length === 0) {

@@ -18,3 +18,3 @@ return null;

return /*#__PURE__*/React.createElement(Results, _extends({}, props, {
key: index,
key: collection.source.sourceId,
title: title,

@@ -21,0 +21,0 @@ collection: collection,

@@ -1,6 +0,14 @@

import { AutocompleteApi, AutocompleteState, BaseItem } from '@algolia/autocomplete-core';
import type { AutocompleteApi, AutocompleteState, BaseItem } from '@algolia/autocomplete-core';
import React from 'react';
import { DocSearchProps } from './DocSearch';
import { StoredSearchPlugin } from './stored-searches';
import { InternalDocSearchHit, StoredDocSearchHit } from './types';
import type { DocSearchProps } from './DocSearch';
import type { ErrorScreenTranslations } from './ErrorScreen';
import type { NoResultsScreenTranslations } from './NoResultsScreen';
import type { StartScreenTranslations } from './StartScreen';
import type { StoredSearchPlugin } from './stored-searches';
import type { InternalDocSearchHit, StoredDocSearchHit } from './types';
export declare type ScreenStateTranslations = Partial<{
errorScreen: ErrorScreenTranslations;
startScreen: StartScreenTranslations;
noResultsScreen: NoResultsScreenTranslations;
}>;
export interface ScreenStateProps<TItem extends BaseItem> extends AutocompleteApi<TItem, React.FormEvent, React.MouseEvent, React.KeyboardEvent> {

@@ -10,4 +18,4 @@ state: AutocompleteState<TItem>;

favoriteSearches: StoredSearchPlugin<StoredDocSearchHit>;
onItemClick(item: InternalDocSearchHit): void;
inputRef: React.MutableRefObject<null | HTMLInputElement>;
onItemClick: (item: InternalDocSearchHit) => void;
inputRef: React.MutableRefObject<HTMLInputElement | null>;
hitComponent: DocSearchProps['hitComponent'];

@@ -17,3 +25,4 @@ indexName: DocSearchProps['indexName'];

resultsFooterComponent: DocSearchProps['resultsFooterComponent'];
translations: ScreenStateTranslations;
}
export declare const ScreenState: React.MemoExoticComponent<(props: ScreenStateProps<InternalDocSearchHit>) => JSX.Element>;
export declare const ScreenState: React.MemoExoticComponent<({ translations, ...props }: ScreenStateProps<InternalDocSearchHit>) => JSX.Element>;

@@ -0,3 +1,9 @@

var _excluded = ["translations"];
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React from 'react';

@@ -8,5 +14,11 @@ import { ErrorScreen } from './ErrorScreen';

import { StartScreen } from './StartScreen';
export var ScreenState = React.memo(function (props) {
export var ScreenState = React.memo(function (_ref) {
var _ref$translations = _ref.translations,
translations = _ref$translations === void 0 ? {} : _ref$translations,
props = _objectWithoutProperties(_ref, _excluded);
if (props.state.status === 'error') {
return /*#__PURE__*/React.createElement(ErrorScreen, null);
return /*#__PURE__*/React.createElement(ErrorScreen, {
translations: translations === null || translations === void 0 ? void 0 : translations.errorScreen
});
}

@@ -20,3 +32,4 @@

return /*#__PURE__*/React.createElement(StartScreen, _extends({}, props, {
hasCollections: hasCollections
hasCollections: hasCollections,
translations: translations === null || translations === void 0 ? void 0 : translations.startScreen
}));

@@ -26,3 +39,5 @@ }

if (hasCollections === false) {
return /*#__PURE__*/React.createElement(NoResultsScreen, props);
return /*#__PURE__*/React.createElement(NoResultsScreen, _extends({}, props, {
translations: translations === null || translations === void 0 ? void 0 : translations.noResultsScreen
}));
}

@@ -29,0 +44,0 @@

@@ -1,4 +0,11 @@

import { AutocompleteApi, AutocompleteState } from '@algolia/autocomplete-core';
import React, { MutableRefObject } from 'react';
import { InternalDocSearchHit } from './types';
import type { AutocompleteApi, AutocompleteState } from '@algolia/autocomplete-core';
import type { MutableRefObject } from 'react';
import React from 'react';
import type { InternalDocSearchHit } from './types';
export declare type SearchBoxTranslations = Partial<{
resetButtonTitle: string;
resetButtonAriaLabel: string;
cancelButtonText: string;
cancelButtonAriaLabel: string;
}>;
interface SearchBoxProps extends AutocompleteApi<InternalDocSearchHit, React.FormEvent, React.MouseEvent, React.KeyboardEvent> {

@@ -8,6 +15,7 @@ state: AutocompleteState<InternalDocSearchHit>;

inputRef: MutableRefObject<HTMLInputElement | null>;
onClose(): void;
onClose: () => void;
isFromSelection: boolean;
translations?: SearchBoxTranslations;
}
export declare function SearchBox(props: SearchBoxProps): JSX.Element;
export declare function SearchBox({ translations, ...props }: SearchBoxProps): JSX.Element;
export {};

@@ -0,3 +1,9 @@

var _excluded = ["translations"];
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React from 'react';

@@ -8,3 +14,16 @@ import { MAX_QUERY_SIZE } from './constants';

import { SearchIcon } from './icons/SearchIcon';
export function SearchBox(props) {
export function SearchBox(_ref) {
var _ref$translations = _ref.translations,
translations = _ref$translations === void 0 ? {} : _ref$translations,
props = _objectWithoutProperties(_ref, _excluded);
var _translations$resetBu = translations.resetButtonTitle,
resetButtonTitle = _translations$resetBu === void 0 ? 'Clear the query' : _translations$resetBu,
_translations$resetBu2 = translations.resetButtonAriaLabel,
resetButtonAriaLabel = _translations$resetBu2 === void 0 ? 'Clear the query' : _translations$resetBu2,
_translations$cancelB = translations.cancelButtonText,
cancelButtonText = _translations$cancelB === void 0 ? 'Cancel' : _translations$cancelB,
_translations$cancelB2 = translations.cancelButtonAriaLabel,
cancelButtonAriaLabel = _translations$cancelB2 === void 0 ? 'Cancel' : _translations$cancelB2;
var _props$getFormProps = props.getFormProps({

@@ -44,9 +63,12 @@ inputElement: props.inputRef.current

type: "reset",
title: "Clear the query",
title: resetButtonTitle,
className: "DocSearch-Reset",
"aria-label": resetButtonAriaLabel,
hidden: !props.state.query
}, /*#__PURE__*/React.createElement(ResetIcon, null))), /*#__PURE__*/React.createElement("button", {
className: "DocSearch-Cancel",
type: "reset",
"aria-label": cancelButtonAriaLabel,
onClick: props.onClose
}, "Cancel"));
}, cancelButtonText));
}
/// <reference types="react" />
import { StoredDocSearchHit } from './types';
import type { StoredDocSearchHit } from './types';
interface SnippetProps<TItem> {
[prop: string]: unknown;
hit: TItem;
attribute: string;
tagName?: string;
[prop: string]: unknown;
}

@@ -9,0 +9,0 @@ export declare function Snippet<TItem extends StoredDocSearchHit>({ hit, attribute, tagName, ...rest }: SnippetProps<TItem>): import("react").DOMElement<{

@@ -1,3 +0,5 @@

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
var _excluded = ["hit", "attribute", "tagName"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

@@ -15,4 +17,5 @@

var parts = path.split('.');
return parts.reduce(function (current, key) {
return current && current[key];
return parts.reduce(function (prev, current) {
if (prev !== null && prev !== void 0 && prev[current]) return prev[current];
return null;
}, object);

@@ -26,3 +29,3 @@ }

tagName = _ref$tagName === void 0 ? 'span' : _ref$tagName,
rest = _objectWithoutProperties(_ref, ["hit", "attribute", "tagName"]);
rest = _objectWithoutProperties(_ref, _excluded);

@@ -29,0 +32,0 @@ return createElement(tagName, _objectSpread(_objectSpread({}, rest), {}, {

/// <reference types="react" />
import { ScreenStateProps } from './ScreenState';
import { InternalDocSearchHit } from './types';
interface StartScreenProps extends ScreenStateProps<InternalDocSearchHit> {
import type { ScreenStateProps } from './ScreenState';
import type { InternalDocSearchHit } from './types';
export declare type StartScreenTranslations = Partial<{
recentSearchesTitle: string;
noRecentSearchesText: string;
saveRecentSearchButtonTitle: string;
removeRecentSearchButtonTitle: string;
favoriteSearchesTitle: string;
removeFavoriteSearchButtonTitle: string;
}>;
declare type StartScreenProps = Omit<ScreenStateProps<InternalDocSearchHit>, 'translations'> & {
hasCollections: boolean;
}
export declare function StartScreen(props: StartScreenProps): JSX.Element | null;
translations?: StartScreenTranslations;
};
export declare function StartScreen({ translations, ...props }: StartScreenProps): JSX.Element | null;
export {};

@@ -0,7 +1,30 @@

var _excluded = ["translations"];
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React from 'react';
import { RecentIcon, ResetIcon, StarIcon } from './icons';
import { Results } from './Results';
export function StartScreen(props) {
export function StartScreen(_ref) {
var _ref$translations = _ref.translations,
translations = _ref$translations === void 0 ? {} : _ref$translations,
props = _objectWithoutProperties(_ref, _excluded);
var _translations$recentS = translations.recentSearchesTitle,
recentSearchesTitle = _translations$recentS === void 0 ? 'Recent' : _translations$recentS,
_translations$noRecen = translations.noRecentSearchesText,
noRecentSearchesText = _translations$noRecen === void 0 ? 'No recent searches' : _translations$noRecen,
_translations$saveRec = translations.saveRecentSearchButtonTitle,
saveRecentSearchButtonTitle = _translations$saveRec === void 0 ? 'Save this search' : _translations$saveRec,
_translations$removeR = translations.removeRecentSearchButtonTitle,
removeRecentSearchButtonTitle = _translations$removeR === void 0 ? 'Remove this search from history' : _translations$removeR,
_translations$favorit = translations.favoriteSearchesTitle,
favoriteSearchesTitle = _translations$favorit === void 0 ? 'Favorite' : _translations$favorit,
_translations$removeF = translations.removeFavoriteSearchButtonTitle,
removeFavoriteSearchButtonTitle = _translations$removeF === void 0 ? 'Remove this search from favorites' : _translations$removeF;
if (props.state.status === 'idle' && props.hasCollections === false) {

@@ -16,3 +39,3 @@ if (props.disableUserPersonalization) {

className: "DocSearch-Help"
}, "No recent searches"));
}, noRecentSearchesText));
}

@@ -27,3 +50,3 @@

}, /*#__PURE__*/React.createElement(Results, _extends({}, props, {
title: "Recent",
title: recentSearchesTitle,
collection: props.state.collections[0],

@@ -35,6 +58,6 @@ renderIcon: function renderIcon() {

},
renderAction: function renderAction(_ref) {
var item = _ref.item,
runFavoriteTransition = _ref.runFavoriteTransition,
runDeleteTransition = _ref.runDeleteTransition;
renderAction: function renderAction(_ref2) {
var item = _ref2.item,
runFavoriteTransition = _ref2.runFavoriteTransition,
runDeleteTransition = _ref2.runDeleteTransition;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {

@@ -44,3 +67,4 @@ className: "DocSearch-Hit-action"

className: "DocSearch-Hit-action-button",
title: "Save this search",
title: saveRecentSearchButtonTitle,
type: "submit",
onClick: function onClick(event) {

@@ -59,3 +83,4 @@ event.preventDefault();

className: "DocSearch-Hit-action-button",
title: "Remove this search from history",
title: removeRecentSearchButtonTitle,
type: "submit",
onClick: function onClick(event) {

@@ -72,3 +97,3 @@ event.preventDefault();

})), /*#__PURE__*/React.createElement(Results, _extends({}, props, {
title: "Favorites",
title: favoriteSearchesTitle,
collection: props.state.collections[1],

@@ -80,5 +105,5 @@ renderIcon: function renderIcon() {

},
renderAction: function renderAction(_ref2) {
var item = _ref2.item,
runDeleteTransition = _ref2.runDeleteTransition;
renderAction: function renderAction(_ref3) {
var item = _ref3.item,
runDeleteTransition = _ref3.runDeleteTransition;
return /*#__PURE__*/React.createElement("div", {

@@ -88,3 +113,4 @@ className: "DocSearch-Hit-action"

className: "DocSearch-Hit-action-button",
title: "Remove this search from favorites",
title: removeFavoriteSearchButtonTitle,
type: "submit",
onClick: function onClick(event) {

@@ -91,0 +117,0 @@ event.preventDefault();

@@ -1,2 +0,2 @@

import { StoredDocSearchHit } from './types';
import type { StoredDocSearchHit } from './types';
declare type CreateStoredSearchesOptions = {

@@ -7,7 +7,7 @@ key: string;

export declare type StoredSearchPlugin<TItem> = {
add(item: TItem): void;
remove(item: TItem): void;
getAll(): TItem[];
add: (item: TItem) => void;
remove: (item: TItem) => void;
getAll: () => TItem[];
};
export declare function createStoredSearches<TItem extends StoredDocSearchHit>({ key, limit, }: CreateStoredSearchesOptions): StoredSearchPlugin<TItem>;
export {};

@@ -0,1 +1,3 @@

var _excluded = ["_highlightResult", "_snippetResult"];
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

@@ -49,3 +51,3 @@

_snippetResult = _ref2._snippetResult,
hit = _objectWithoutProperties(_ref2, ["_highlightResult", "_snippetResult"]);
hit = _objectWithoutProperties(_ref2, _excluded);

@@ -52,0 +54,0 @@ var isQueryAlreadySaved = items.findIndex(function (x) {

declare type ContentType = 'content' | 'lvl0' | 'lvl1' | 'lvl2' | 'lvl3' | 'lvl4' | 'lvl5' | 'lvl6';
interface DocSearchHitAttributeHighlightResult {
value: string;
matchLevel: 'none' | 'partial' | 'full';
matchLevel: 'full' | 'none' | 'partial';
matchedWords: string[];

@@ -24,3 +24,3 @@ fullyHighlighted?: boolean;

value: string;
matchLevel: 'none' | 'partial' | 'full';
matchLevel: 'full' | 'none' | 'partial';
}

@@ -27,0 +27,0 @@ interface DocSearchHitSnippetResult {

@@ -1,4 +0,4 @@

import { DocSearchHit } from './DocSearchHit';
import type { DocSearchHit } from './DocSearchHit';
export declare type InternalDocSearchHit = DocSearchHit & {
__docsearch_parent: null | InternalDocSearchHit;
__docsearch_parent: InternalDocSearchHit | null;
};

@@ -1,2 +0,2 @@

import { DocSearchHit } from './DocSearchHit';
import type { DocSearchHit } from './DocSearchHit';
export declare type StoredDocSearchHit = Omit<DocSearchHit, '_highlightResult' | '_snippetResult'>;
import React from 'react';
export interface UseDocSearchKeyboardEventsProps {
isOpen: boolean;
onOpen(): void;
onClose(): void;
onInput?(event: KeyboardEvent): void;
onOpen: () => void;
onClose: () => void;
onInput?: (event: KeyboardEvent) => void;
searchButtonRef?: React.RefObject<HTMLButtonElement>;
}
export declare function useDocSearchKeyboardEvents({ isOpen, onOpen, onClose, onInput, searchButtonRef, }: UseDocSearchKeyboardEventsProps): void;

@@ -25,3 +25,6 @@ import React from 'react';

if (event.keyCode === 27 && isOpen || event.key === 'k' && (event.metaKey || event.ctrlKey) || !isEditingContent(event) && event.key === '/' && !isOpen) {
if (event.keyCode === 27 && isOpen || // The `Cmd+K` shortcut both opens and closes the modal.
event.key === 'k' && (event.metaKey || event.ctrlKey) || // The `/` shortcut opens but doesn't close the modal because it's
// a character.
!isEditingContent(event) && event.key === '/' && !isOpen) {
event.preventDefault();

@@ -28,0 +31,0 @@

@@ -1,2 +0,2 @@

import { SearchClient } from 'algoliasearch/lite';
import type { SearchClient } from 'algoliasearch/lite';
export declare function useSearchClient(appId: string, apiKey: string, transformSearchClient: (searchClient: SearchClient) => SearchClient): SearchClient;

@@ -1,2 +0,2 @@

import { AutocompleteApi } from '@algolia/autocomplete-core';
import type { AutocompleteApi } from '@algolia/autocomplete-core';
interface UseTouchEventsProps {

@@ -3,0 +3,0 @@ getEnvironmentProps: AutocompleteApi<any>['getEnvironmentProps'];

@@ -1,1 +0,1 @@

export declare function groupBy<TValue extends object>(values: TValue[], predicate: (value: TValue) => string): Record<string, TValue[]>;
export declare function groupBy<TValue extends Record<string, unknown>>(values: TValue[], predicate: (value: TValue) => string): Record<string, TValue[]>;

@@ -1,2 +0,2 @@

import { DocSearchHit, InternalDocSearchHit } from './../types';
import type { DocSearchHit, InternalDocSearchHit } from '../types';
export declare function removeHighlightTags(hit: DocSearchHit | InternalDocSearchHit): string;

@@ -1,1 +0,1 @@

export declare const version = "3.0.0-alpha.41";
export declare const version = "3.0.0-alpha.42";

@@ -1,1 +0,1 @@

export var version = '3.0.0-alpha.41';
export var version = '3.0.0-alpha.42';
{
"name": "@docsearch/react",
"description": "React package for DocSearch, the best search experience for docs.",
"version": "3.0.0-alpha.41",
"version": "3.0.0-alpha.42",
"license": "MIT",

@@ -37,5 +37,5 @@ "homepage": "https://docsearch.algolia.com",

"dependencies": {
"@algolia/autocomplete-core": "1.2.2",
"@algolia/autocomplete-preset-algolia": "1.2.2",
"@docsearch/css": "3.0.0-alpha.41",
"@algolia/autocomplete-core": "1.5.0",
"@algolia/autocomplete-preset-algolia": "1.5.0",
"@docsearch/css": "3.0.0-alpha.42",
"algoliasearch": "^4.0.0"

@@ -42,0 +42,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc