@docsearch/react 3.5.2 → 3.6.1
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/button.js +1 -1
- package/dist/esm/index.d.ts +195 -5
- package/dist/esm/index.js +1 -5
- package/dist/umd/index.js +2 -2
- package/dist/umd/index.js.map +1 -1
- package/modal.js +1 -1
- package/package.json +6 -7
- package/dist/esm/AlgoliaLogo.d.ts +0 -8
- package/dist/esm/AlgoliaLogo.js +0 -54
- package/dist/esm/DocSearch.d.ts +0 -36
- package/dist/esm/DocSearch.js +0 -62
- package/dist/esm/DocSearchButton.d.ts +0 -9
- package/dist/esm/DocSearchButton.js +0 -68
- package/dist/esm/DocSearchModal.d.ts +0 -14
- package/dist/esm/DocSearchModal.js +0 -418
- package/dist/esm/ErrorScreen.d.ts +0 -9
- package/dist/esm/ErrorScreen.js +0 -19
- package/dist/esm/Footer.d.ts +0 -15
- package/dist/esm/Footer.js +0 -77
- package/dist/esm/Hit.d.ts +0 -8
- package/dist/esm/Hit.js +0 -8
- package/dist/esm/NoResultsScreen.d.ts +0 -13
- package/dist/esm/NoResultsScreen.js +0 -67
- package/dist/esm/Results.d.ts +0 -21
- package/dist/esm/Results.js +0 -123
- package/dist/esm/ResultsScreen.d.ts +0 -5
- package/dist/esm/ResultsScreen.js +0 -55
- package/dist/esm/ScreenState.d.ts +0 -27
- package/dist/esm/ScreenState.js +0 -49
- package/dist/esm/SearchBox.d.ts +0 -20
- package/dist/esm/SearchBox.js +0 -72
- package/dist/esm/Snippet.d.ts +0 -14
- package/dist/esm/Snippet.js +0 -35
- package/dist/esm/StartScreen.d.ts +0 -16
- package/dist/esm/StartScreen.js +0 -119
- package/dist/esm/__tests__/api.test.js +0 -461
- package/dist/esm/constants.d.ts +0 -1
- package/dist/esm/constants.js +0 -1
- package/dist/esm/icons/ControlKeyIcon.d.ts +0 -1
- package/dist/esm/icons/ControlKeyIcon.js +0 -14
- package/dist/esm/icons/ErrorIcon.d.ts +0 -1
- package/dist/esm/icons/ErrorIcon.js +0 -15
- package/dist/esm/icons/GoToExternalIcon.d.ts +0 -1
- package/dist/esm/icons/GoToExternalIcon.js +0 -11
- package/dist/esm/icons/LoadingIcon.d.ts +0 -1
- package/dist/esm/icons/LoadingIcon.js +0 -28
- package/dist/esm/icons/NoResultsIcon.d.ts +0 -1
- package/dist/esm/icons/NoResultsIcon.js +0 -15
- package/dist/esm/icons/RecentIcon.d.ts +0 -1
- package/dist/esm/icons/RecentIcon.js +0 -18
- package/dist/esm/icons/ResetIcon.d.ts +0 -1
- package/dist/esm/icons/ResetIcon.js +0 -15
- package/dist/esm/icons/SearchIcon.d.ts +0 -1
- package/dist/esm/icons/SearchIcon.js +0 -16
- package/dist/esm/icons/SelectIcon.d.ts +0 -1
- package/dist/esm/icons/SelectIcon.js +0 -19
- package/dist/esm/icons/SourceIcon.d.ts +0 -3
- package/dist/esm/icons/SourceIcon.js +0 -57
- package/dist/esm/icons/StarIcon.d.ts +0 -1
- package/dist/esm/icons/StarIcon.js +0 -14
- package/dist/esm/icons/index.d.ts +0 -10
- package/dist/esm/icons/index.js +0 -10
- package/dist/esm/stored-searches.d.ts +0 -12
- package/dist/esm/stored-searches.js +0 -75
- package/dist/esm/types/DocSearchHit.d.ts +0 -75
- package/dist/esm/types/DocSearchHit.js +0 -1
- package/dist/esm/types/DocSearchState.d.ts +0 -10
- package/dist/esm/types/DocSearchState.js +0 -1
- package/dist/esm/types/InternalDocSearchHit.d.ts +0 -4
- package/dist/esm/types/InternalDocSearchHit.js +0 -1
- package/dist/esm/types/StoredDocSearchHit.d.ts +0 -2
- package/dist/esm/types/StoredDocSearchHit.js +0 -1
- package/dist/esm/types/index.d.ts +0 -4
- package/dist/esm/types/index.js +0 -4
- package/dist/esm/useDocSearchKeyboardEvents.d.ts +0 -9
- package/dist/esm/useDocSearchKeyboardEvents.js +0 -55
- package/dist/esm/useSearchClient.d.ts +0 -2
- package/dist/esm/useSearchClient.js +0 -20
- package/dist/esm/useTouchEvents.d.ts +0 -9
- package/dist/esm/useTouchEvents.js +0 -27
- package/dist/esm/useTrapFocus.d.ts +0 -5
- package/dist/esm/useTrapFocus.js +0 -34
- package/dist/esm/utils/groupBy.d.ts +0 -1
- package/dist/esm/utils/groupBy.js +0 -17
- package/dist/esm/utils/identity.d.ts +0 -1
- package/dist/esm/utils/identity.js +0 -3
- package/dist/esm/utils/index.d.ts +0 -5
- package/dist/esm/utils/index.js +0 -5
- package/dist/esm/utils/isModifierEvent.d.ts +0 -5
- package/dist/esm/utils/isModifierEvent.js +0 -8
- package/dist/esm/utils/noop.d.ts +0 -1
- package/dist/esm/utils/noop.js +0 -1
- package/dist/esm/utils/removeHighlightTags.d.ts +0 -2
- package/dist/esm/utils/removeHighlightTags.js +0 -16
- package/dist/esm/version.d.ts +0 -1
- package/dist/esm/version.js +0 -1
package/dist/esm/Results.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
-
|
|
9
|
-
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; }
|
|
10
|
-
|
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
|
-
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); }
|
|
14
|
-
|
|
15
|
-
import React from 'react';
|
|
16
|
-
import { Snippet } from './Snippet';
|
|
17
|
-
export function Results(props) {
|
|
18
|
-
if (!props.collection || props.collection.items.length === 0) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return /*#__PURE__*/React.createElement("section", {
|
|
23
|
-
className: "DocSearch-Hits"
|
|
24
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
25
|
-
className: "DocSearch-Hit-source"
|
|
26
|
-
}, props.title), /*#__PURE__*/React.createElement("ul", props.getListProps(), props.collection.items.map(function (item, index) {
|
|
27
|
-
return /*#__PURE__*/React.createElement(Result, _extends({
|
|
28
|
-
key: [props.title, item.objectID].join(':'),
|
|
29
|
-
item: item,
|
|
30
|
-
index: index
|
|
31
|
-
}, props));
|
|
32
|
-
})));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function Result(_ref) {
|
|
36
|
-
var item = _ref.item,
|
|
37
|
-
index = _ref.index,
|
|
38
|
-
renderIcon = _ref.renderIcon,
|
|
39
|
-
renderAction = _ref.renderAction,
|
|
40
|
-
getItemProps = _ref.getItemProps,
|
|
41
|
-
onItemClick = _ref.onItemClick,
|
|
42
|
-
collection = _ref.collection,
|
|
43
|
-
hitComponent = _ref.hitComponent;
|
|
44
|
-
|
|
45
|
-
var _React$useState = React.useState(false),
|
|
46
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
47
|
-
isDeleting = _React$useState2[0],
|
|
48
|
-
setIsDeleting = _React$useState2[1];
|
|
49
|
-
|
|
50
|
-
var _React$useState3 = React.useState(false),
|
|
51
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
52
|
-
isFavoriting = _React$useState4[0],
|
|
53
|
-
setIsFavoriting = _React$useState4[1];
|
|
54
|
-
|
|
55
|
-
var action = React.useRef(null);
|
|
56
|
-
var Hit = hitComponent;
|
|
57
|
-
|
|
58
|
-
function runDeleteTransition(cb) {
|
|
59
|
-
setIsDeleting(true);
|
|
60
|
-
action.current = cb;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function runFavoriteTransition(cb) {
|
|
64
|
-
setIsFavoriting(true);
|
|
65
|
-
action.current = cb;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return /*#__PURE__*/React.createElement("li", _extends({
|
|
69
|
-
className: ['DocSearch-Hit', item.__docsearch_parent && 'DocSearch-Hit--Child', isDeleting && 'DocSearch-Hit--deleting', isFavoriting && 'DocSearch-Hit--favoriting'].filter(Boolean).join(' '),
|
|
70
|
-
onTransitionEnd: function onTransitionEnd() {
|
|
71
|
-
if (action.current) {
|
|
72
|
-
action.current();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}, getItemProps({
|
|
76
|
-
item: item,
|
|
77
|
-
source: collection.source,
|
|
78
|
-
onClick: function onClick(event) {
|
|
79
|
-
onItemClick(item, event);
|
|
80
|
-
}
|
|
81
|
-
})), /*#__PURE__*/React.createElement(Hit, {
|
|
82
|
-
hit: item
|
|
83
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
84
|
-
className: "DocSearch-Hit-Container"
|
|
85
|
-
}, renderIcon({
|
|
86
|
-
item: item,
|
|
87
|
-
index: index
|
|
88
|
-
}), item.hierarchy[item.type] && item.type === 'lvl1' && /*#__PURE__*/React.createElement("div", {
|
|
89
|
-
className: "DocSearch-Hit-content-wrapper"
|
|
90
|
-
}, /*#__PURE__*/React.createElement(Snippet, {
|
|
91
|
-
className: "DocSearch-Hit-title",
|
|
92
|
-
hit: item,
|
|
93
|
-
attribute: "hierarchy.lvl1"
|
|
94
|
-
}), item.content && /*#__PURE__*/React.createElement(Snippet, {
|
|
95
|
-
className: "DocSearch-Hit-path",
|
|
96
|
-
hit: item,
|
|
97
|
-
attribute: "content"
|
|
98
|
-
})), item.hierarchy[item.type] && (item.type === 'lvl2' || item.type === 'lvl3' || item.type === 'lvl4' || item.type === 'lvl5' || item.type === 'lvl6') && /*#__PURE__*/React.createElement("div", {
|
|
99
|
-
className: "DocSearch-Hit-content-wrapper"
|
|
100
|
-
}, /*#__PURE__*/React.createElement(Snippet, {
|
|
101
|
-
className: "DocSearch-Hit-title",
|
|
102
|
-
hit: item,
|
|
103
|
-
attribute: "hierarchy.".concat(item.type)
|
|
104
|
-
}), /*#__PURE__*/React.createElement(Snippet, {
|
|
105
|
-
className: "DocSearch-Hit-path",
|
|
106
|
-
hit: item,
|
|
107
|
-
attribute: "hierarchy.lvl1"
|
|
108
|
-
})), item.type === 'content' && /*#__PURE__*/React.createElement("div", {
|
|
109
|
-
className: "DocSearch-Hit-content-wrapper"
|
|
110
|
-
}, /*#__PURE__*/React.createElement(Snippet, {
|
|
111
|
-
className: "DocSearch-Hit-title",
|
|
112
|
-
hit: item,
|
|
113
|
-
attribute: "content"
|
|
114
|
-
}), /*#__PURE__*/React.createElement(Snippet, {
|
|
115
|
-
className: "DocSearch-Hit-path",
|
|
116
|
-
hit: item,
|
|
117
|
-
attribute: "hierarchy.lvl1"
|
|
118
|
-
})), renderAction({
|
|
119
|
-
item: item,
|
|
120
|
-
runDeleteTransition: runDeleteTransition,
|
|
121
|
-
runFavoriteTransition: runFavoriteTransition
|
|
122
|
-
}))));
|
|
123
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ScreenStateProps } from './ScreenState';
|
|
2
|
-
import type { InternalDocSearchHit } from './types';
|
|
3
|
-
declare type ResultsScreenProps = Omit<ScreenStateProps<InternalDocSearchHit>, 'translations'>;
|
|
4
|
-
export declare function ResultsScreen(props: ResultsScreenProps): JSX.Element;
|
|
5
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
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); }
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { SelectIcon, SourceIcon } from './icons';
|
|
5
|
-
import { Results } from './Results';
|
|
6
|
-
import { removeHighlightTags } from './utils';
|
|
7
|
-
export function ResultsScreen(props) {
|
|
8
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
9
|
-
className: "DocSearch-Dropdown-Container"
|
|
10
|
-
}, props.state.collections.map(function (collection) {
|
|
11
|
-
if (collection.items.length === 0) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
var title = removeHighlightTags(collection.items[0]);
|
|
16
|
-
return /*#__PURE__*/React.createElement(Results, _extends({}, props, {
|
|
17
|
-
key: collection.source.sourceId,
|
|
18
|
-
title: title,
|
|
19
|
-
collection: collection,
|
|
20
|
-
renderIcon: function renderIcon(_ref) {
|
|
21
|
-
var _collection$items;
|
|
22
|
-
|
|
23
|
-
var item = _ref.item,
|
|
24
|
-
index = _ref.index;
|
|
25
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, item.__docsearch_parent && /*#__PURE__*/React.createElement("svg", {
|
|
26
|
-
className: "DocSearch-Hit-Tree",
|
|
27
|
-
viewBox: "0 0 24 54"
|
|
28
|
-
}, /*#__PURE__*/React.createElement("g", {
|
|
29
|
-
stroke: "currentColor",
|
|
30
|
-
fill: "none",
|
|
31
|
-
fillRule: "evenodd",
|
|
32
|
-
strokeLinecap: "round",
|
|
33
|
-
strokeLinejoin: "round"
|
|
34
|
-
}, item.__docsearch_parent !== ((_collection$items = collection.items[index + 1]) === null || _collection$items === void 0 ? void 0 : _collection$items.__docsearch_parent) ? /*#__PURE__*/React.createElement("path", {
|
|
35
|
-
d: "M8 6v21M20 27H8.3"
|
|
36
|
-
}) : /*#__PURE__*/React.createElement("path", {
|
|
37
|
-
d: "M8 6v42M20 27H8.3"
|
|
38
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
39
|
-
className: "DocSearch-Hit-icon"
|
|
40
|
-
}, /*#__PURE__*/React.createElement(SourceIcon, {
|
|
41
|
-
type: item.type
|
|
42
|
-
})));
|
|
43
|
-
},
|
|
44
|
-
renderAction: function renderAction() {
|
|
45
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
46
|
-
className: "DocSearch-Hit-action"
|
|
47
|
-
}, /*#__PURE__*/React.createElement(SelectIcon, null));
|
|
48
|
-
}
|
|
49
|
-
}));
|
|
50
|
-
}), props.resultsFooterComponent && /*#__PURE__*/React.createElement("section", {
|
|
51
|
-
className: "DocSearch-HitsFooter"
|
|
52
|
-
}, /*#__PURE__*/React.createElement(props.resultsFooterComponent, {
|
|
53
|
-
state: props.state
|
|
54
|
-
})));
|
|
55
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { AutocompleteApi, AutocompleteState, BaseItem } from '@algolia/autocomplete-core';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { DocSearchProps } from './DocSearch';
|
|
4
|
-
import type { ErrorScreenTranslations } from './ErrorScreen';
|
|
5
|
-
import type { NoResultsScreenTranslations } from './NoResultsScreen';
|
|
6
|
-
import type { StartScreenTranslations } from './StartScreen';
|
|
7
|
-
import type { StoredSearchPlugin } from './stored-searches';
|
|
8
|
-
import type { InternalDocSearchHit, StoredDocSearchHit } from './types';
|
|
9
|
-
export declare type ScreenStateTranslations = Partial<{
|
|
10
|
-
errorScreen: ErrorScreenTranslations;
|
|
11
|
-
startScreen: StartScreenTranslations;
|
|
12
|
-
noResultsScreen: NoResultsScreenTranslations;
|
|
13
|
-
}>;
|
|
14
|
-
export interface ScreenStateProps<TItem extends BaseItem> extends AutocompleteApi<TItem, React.FormEvent, React.MouseEvent, React.KeyboardEvent> {
|
|
15
|
-
state: AutocompleteState<TItem>;
|
|
16
|
-
recentSearches: StoredSearchPlugin<StoredDocSearchHit>;
|
|
17
|
-
favoriteSearches: StoredSearchPlugin<StoredDocSearchHit>;
|
|
18
|
-
onItemClick: (item: InternalDocSearchHit, event: KeyboardEvent | MouseEvent) => void;
|
|
19
|
-
inputRef: React.MutableRefObject<HTMLInputElement | null>;
|
|
20
|
-
hitComponent: DocSearchProps['hitComponent'];
|
|
21
|
-
indexName: DocSearchProps['indexName'];
|
|
22
|
-
disableUserPersonalization: boolean;
|
|
23
|
-
resultsFooterComponent: DocSearchProps['resultsFooterComponent'];
|
|
24
|
-
translations: ScreenStateTranslations;
|
|
25
|
-
getMissingResultsUrl?: DocSearchProps['getMissingResultsUrl'];
|
|
26
|
-
}
|
|
27
|
-
export declare const ScreenState: React.MemoExoticComponent<({ translations, ...props }: ScreenStateProps<InternalDocSearchHit>) => JSX.Element>;
|
package/dist/esm/ScreenState.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var _excluded = ["translations"];
|
|
2
|
-
|
|
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); }
|
|
4
|
-
|
|
5
|
-
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; }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import { ErrorScreen } from './ErrorScreen';
|
|
11
|
-
import { NoResultsScreen } from './NoResultsScreen';
|
|
12
|
-
import { ResultsScreen } from './ResultsScreen';
|
|
13
|
-
import { StartScreen } from './StartScreen';
|
|
14
|
-
export var ScreenState = React.memo(function (_ref) {
|
|
15
|
-
var _ref$translations = _ref.translations,
|
|
16
|
-
translations = _ref$translations === void 0 ? {} : _ref$translations,
|
|
17
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
18
|
-
|
|
19
|
-
if (props.state.status === 'error') {
|
|
20
|
-
return /*#__PURE__*/React.createElement(ErrorScreen, {
|
|
21
|
-
translations: translations === null || translations === void 0 ? void 0 : translations.errorScreen
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var hasCollections = props.state.collections.some(function (collection) {
|
|
26
|
-
return collection.items.length > 0;
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
if (!props.state.query) {
|
|
30
|
-
return /*#__PURE__*/React.createElement(StartScreen, _extends({}, props, {
|
|
31
|
-
hasCollections: hasCollections,
|
|
32
|
-
translations: translations === null || translations === void 0 ? void 0 : translations.startScreen
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (hasCollections === false) {
|
|
37
|
-
return /*#__PURE__*/React.createElement(NoResultsScreen, _extends({}, props, {
|
|
38
|
-
translations: translations === null || translations === void 0 ? void 0 : translations.noResultsScreen
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return /*#__PURE__*/React.createElement(ResultsScreen, props);
|
|
43
|
-
}, function areEqual(_prevProps, nextProps) {
|
|
44
|
-
// We don't update the screen when Autocomplete is loading or stalled to
|
|
45
|
-
// avoid UI flashes:
|
|
46
|
-
// - Empty screen → Results screen
|
|
47
|
-
// - NoResults screen → NoResults screen with another query
|
|
48
|
-
return nextProps.state.status === 'loading' || nextProps.state.status === 'stalled';
|
|
49
|
-
});
|
package/dist/esm/SearchBox.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { AutocompleteApi, AutocompleteState } from '@algolia/autocomplete-core';
|
|
2
|
-
import type { MutableRefObject } from 'react';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import type { InternalDocSearchHit } from './types';
|
|
5
|
-
export declare type SearchBoxTranslations = Partial<{
|
|
6
|
-
resetButtonTitle: string;
|
|
7
|
-
resetButtonAriaLabel: string;
|
|
8
|
-
cancelButtonText: string;
|
|
9
|
-
cancelButtonAriaLabel: string;
|
|
10
|
-
}>;
|
|
11
|
-
interface SearchBoxProps extends AutocompleteApi<InternalDocSearchHit, React.FormEvent, React.MouseEvent, React.KeyboardEvent> {
|
|
12
|
-
state: AutocompleteState<InternalDocSearchHit>;
|
|
13
|
-
autoFocus: boolean;
|
|
14
|
-
inputRef: MutableRefObject<HTMLInputElement | null>;
|
|
15
|
-
onClose: () => void;
|
|
16
|
-
isFromSelection: boolean;
|
|
17
|
-
translations?: SearchBoxTranslations;
|
|
18
|
-
}
|
|
19
|
-
export declare function SearchBox({ translations, ...props }: SearchBoxProps): JSX.Element;
|
|
20
|
-
export {};
|
package/dist/esm/SearchBox.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
var _excluded = ["translations"];
|
|
2
|
-
|
|
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); }
|
|
4
|
-
|
|
5
|
-
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; }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import { MAX_QUERY_SIZE } from './constants';
|
|
11
|
-
import { LoadingIcon } from './icons/LoadingIcon';
|
|
12
|
-
import { ResetIcon } from './icons/ResetIcon';
|
|
13
|
-
import { SearchIcon } from './icons/SearchIcon';
|
|
14
|
-
export function SearchBox(_ref) {
|
|
15
|
-
var _ref$translations = _ref.translations,
|
|
16
|
-
translations = _ref$translations === void 0 ? {} : _ref$translations,
|
|
17
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
18
|
-
|
|
19
|
-
var _translations$resetBu = translations.resetButtonTitle,
|
|
20
|
-
resetButtonTitle = _translations$resetBu === void 0 ? 'Clear the query' : _translations$resetBu,
|
|
21
|
-
_translations$resetBu2 = translations.resetButtonAriaLabel,
|
|
22
|
-
resetButtonAriaLabel = _translations$resetBu2 === void 0 ? 'Clear the query' : _translations$resetBu2,
|
|
23
|
-
_translations$cancelB = translations.cancelButtonText,
|
|
24
|
-
cancelButtonText = _translations$cancelB === void 0 ? 'Cancel' : _translations$cancelB,
|
|
25
|
-
_translations$cancelB2 = translations.cancelButtonAriaLabel,
|
|
26
|
-
cancelButtonAriaLabel = _translations$cancelB2 === void 0 ? 'Cancel' : _translations$cancelB2;
|
|
27
|
-
|
|
28
|
-
var _props$getFormProps = props.getFormProps({
|
|
29
|
-
inputElement: props.inputRef.current
|
|
30
|
-
}),
|
|
31
|
-
onReset = _props$getFormProps.onReset;
|
|
32
|
-
|
|
33
|
-
React.useEffect(function () {
|
|
34
|
-
if (props.autoFocus && props.inputRef.current) {
|
|
35
|
-
props.inputRef.current.focus();
|
|
36
|
-
}
|
|
37
|
-
}, [props.autoFocus, props.inputRef]);
|
|
38
|
-
React.useEffect(function () {
|
|
39
|
-
if (props.isFromSelection && props.inputRef.current) {
|
|
40
|
-
props.inputRef.current.select();
|
|
41
|
-
}
|
|
42
|
-
}, [props.isFromSelection, props.inputRef]);
|
|
43
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("form", {
|
|
44
|
-
className: "DocSearch-Form",
|
|
45
|
-
onSubmit: function onSubmit(event) {
|
|
46
|
-
event.preventDefault();
|
|
47
|
-
},
|
|
48
|
-
onReset: onReset
|
|
49
|
-
}, /*#__PURE__*/React.createElement("label", _extends({
|
|
50
|
-
className: "DocSearch-MagnifierLabel"
|
|
51
|
-
}, props.getLabelProps()), /*#__PURE__*/React.createElement(SearchIcon, null)), /*#__PURE__*/React.createElement("div", {
|
|
52
|
-
className: "DocSearch-LoadingIndicator"
|
|
53
|
-
}, /*#__PURE__*/React.createElement(LoadingIcon, null)), /*#__PURE__*/React.createElement("input", _extends({
|
|
54
|
-
className: "DocSearch-Input",
|
|
55
|
-
ref: props.inputRef
|
|
56
|
-
}, props.getInputProps({
|
|
57
|
-
inputElement: props.inputRef.current,
|
|
58
|
-
autoFocus: props.autoFocus,
|
|
59
|
-
maxLength: MAX_QUERY_SIZE
|
|
60
|
-
}))), /*#__PURE__*/React.createElement("button", {
|
|
61
|
-
type: "reset",
|
|
62
|
-
title: resetButtonTitle,
|
|
63
|
-
className: "DocSearch-Reset",
|
|
64
|
-
"aria-label": resetButtonAriaLabel,
|
|
65
|
-
hidden: !props.state.query
|
|
66
|
-
}, /*#__PURE__*/React.createElement(ResetIcon, null))), /*#__PURE__*/React.createElement("button", {
|
|
67
|
-
className: "DocSearch-Cancel",
|
|
68
|
-
type: "reset",
|
|
69
|
-
"aria-label": cancelButtonAriaLabel,
|
|
70
|
-
onClick: props.onClose
|
|
71
|
-
}, cancelButtonText));
|
|
72
|
-
}
|
package/dist/esm/Snippet.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { StoredDocSearchHit } from './types';
|
|
3
|
-
interface SnippetProps<TItem> {
|
|
4
|
-
hit: TItem;
|
|
5
|
-
attribute: string;
|
|
6
|
-
tagName?: string;
|
|
7
|
-
[prop: string]: unknown;
|
|
8
|
-
}
|
|
9
|
-
export declare function Snippet<TItem extends StoredDocSearchHit>({ hit, attribute, tagName, ...rest }: SnippetProps<TItem>): import("react").DOMElement<{
|
|
10
|
-
dangerouslySetInnerHTML: {
|
|
11
|
-
__html: any;
|
|
12
|
-
};
|
|
13
|
-
}, Element>;
|
|
14
|
-
export {};
|
package/dist/esm/Snippet.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
var _excluded = ["hit", "attribute", "tagName"];
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
|
|
9
|
-
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; }
|
|
10
|
-
|
|
11
|
-
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; }
|
|
12
|
-
|
|
13
|
-
import { createElement } from 'react';
|
|
14
|
-
|
|
15
|
-
function getPropertyByPath(object, path) {
|
|
16
|
-
var parts = path.split('.');
|
|
17
|
-
return parts.reduce(function (prev, current) {
|
|
18
|
-
if (prev !== null && prev !== void 0 && prev[current]) return prev[current];
|
|
19
|
-
return null;
|
|
20
|
-
}, object);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function Snippet(_ref) {
|
|
24
|
-
var hit = _ref.hit,
|
|
25
|
-
attribute = _ref.attribute,
|
|
26
|
-
_ref$tagName = _ref.tagName,
|
|
27
|
-
tagName = _ref$tagName === void 0 ? 'span' : _ref$tagName,
|
|
28
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
-
|
|
30
|
-
return createElement(tagName, _objectSpread(_objectSpread({}, rest), {}, {
|
|
31
|
-
dangerouslySetInnerHTML: {
|
|
32
|
-
__html: getPropertyByPath(hit, "_snippetResult.".concat(attribute, ".value")) || getPropertyByPath(hit, attribute)
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ScreenStateProps } from './ScreenState';
|
|
2
|
-
import type { InternalDocSearchHit } from './types';
|
|
3
|
-
export declare type StartScreenTranslations = Partial<{
|
|
4
|
-
recentSearchesTitle: string;
|
|
5
|
-
noRecentSearchesText: string;
|
|
6
|
-
saveRecentSearchButtonTitle: string;
|
|
7
|
-
removeRecentSearchButtonTitle: string;
|
|
8
|
-
favoriteSearchesTitle: string;
|
|
9
|
-
removeFavoriteSearchButtonTitle: string;
|
|
10
|
-
}>;
|
|
11
|
-
declare type StartScreenProps = Omit<ScreenStateProps<InternalDocSearchHit>, 'translations'> & {
|
|
12
|
-
hasCollections: boolean;
|
|
13
|
-
translations?: StartScreenTranslations;
|
|
14
|
-
};
|
|
15
|
-
export declare function StartScreen({ translations, ...props }: StartScreenProps): JSX.Element | null;
|
|
16
|
-
export {};
|
package/dist/esm/StartScreen.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
var _excluded = ["translations"];
|
|
2
|
-
|
|
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); }
|
|
4
|
-
|
|
5
|
-
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; }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import { RecentIcon, ResetIcon, StarIcon } from './icons';
|
|
11
|
-
import { Results } from './Results';
|
|
12
|
-
export function StartScreen(_ref) {
|
|
13
|
-
var _ref$translations = _ref.translations,
|
|
14
|
-
translations = _ref$translations === void 0 ? {} : _ref$translations,
|
|
15
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
-
|
|
17
|
-
var _translations$recentS = translations.recentSearchesTitle,
|
|
18
|
-
recentSearchesTitle = _translations$recentS === void 0 ? 'Recent' : _translations$recentS,
|
|
19
|
-
_translations$noRecen = translations.noRecentSearchesText,
|
|
20
|
-
noRecentSearchesText = _translations$noRecen === void 0 ? 'No recent searches' : _translations$noRecen,
|
|
21
|
-
_translations$saveRec = translations.saveRecentSearchButtonTitle,
|
|
22
|
-
saveRecentSearchButtonTitle = _translations$saveRec === void 0 ? 'Save this search' : _translations$saveRec,
|
|
23
|
-
_translations$removeR = translations.removeRecentSearchButtonTitle,
|
|
24
|
-
removeRecentSearchButtonTitle = _translations$removeR === void 0 ? 'Remove this search from history' : _translations$removeR,
|
|
25
|
-
_translations$favorit = translations.favoriteSearchesTitle,
|
|
26
|
-
favoriteSearchesTitle = _translations$favorit === void 0 ? 'Favorite' : _translations$favorit,
|
|
27
|
-
_translations$removeF = translations.removeFavoriteSearchButtonTitle,
|
|
28
|
-
removeFavoriteSearchButtonTitle = _translations$removeF === void 0 ? 'Remove this search from favorites' : _translations$removeF;
|
|
29
|
-
|
|
30
|
-
if (props.state.status === 'idle' && props.hasCollections === false) {
|
|
31
|
-
if (props.disableUserPersonalization) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
-
className: "DocSearch-StartScreen"
|
|
37
|
-
}, /*#__PURE__*/React.createElement("p", {
|
|
38
|
-
className: "DocSearch-Help"
|
|
39
|
-
}, noRecentSearchesText));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (props.hasCollections === false) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
-
className: "DocSearch-Dropdown-Container"
|
|
48
|
-
}, /*#__PURE__*/React.createElement(Results, _extends({}, props, {
|
|
49
|
-
title: recentSearchesTitle,
|
|
50
|
-
collection: props.state.collections[0],
|
|
51
|
-
renderIcon: function renderIcon() {
|
|
52
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
53
|
-
className: "DocSearch-Hit-icon"
|
|
54
|
-
}, /*#__PURE__*/React.createElement(RecentIcon, null));
|
|
55
|
-
},
|
|
56
|
-
renderAction: function renderAction(_ref2) {
|
|
57
|
-
var item = _ref2.item,
|
|
58
|
-
runFavoriteTransition = _ref2.runFavoriteTransition,
|
|
59
|
-
runDeleteTransition = _ref2.runDeleteTransition;
|
|
60
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
61
|
-
className: "DocSearch-Hit-action"
|
|
62
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
63
|
-
className: "DocSearch-Hit-action-button",
|
|
64
|
-
title: saveRecentSearchButtonTitle,
|
|
65
|
-
type: "submit",
|
|
66
|
-
onClick: function onClick(event) {
|
|
67
|
-
event.preventDefault();
|
|
68
|
-
event.stopPropagation();
|
|
69
|
-
runFavoriteTransition(function () {
|
|
70
|
-
props.favoriteSearches.add(item);
|
|
71
|
-
props.recentSearches.remove(item);
|
|
72
|
-
props.refresh();
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}, /*#__PURE__*/React.createElement(StarIcon, null))), /*#__PURE__*/React.createElement("div", {
|
|
76
|
-
className: "DocSearch-Hit-action"
|
|
77
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
78
|
-
className: "DocSearch-Hit-action-button",
|
|
79
|
-
title: removeRecentSearchButtonTitle,
|
|
80
|
-
type: "submit",
|
|
81
|
-
onClick: function onClick(event) {
|
|
82
|
-
event.preventDefault();
|
|
83
|
-
event.stopPropagation();
|
|
84
|
-
runDeleteTransition(function () {
|
|
85
|
-
props.recentSearches.remove(item);
|
|
86
|
-
props.refresh();
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}, /*#__PURE__*/React.createElement(ResetIcon, null))));
|
|
90
|
-
}
|
|
91
|
-
})), /*#__PURE__*/React.createElement(Results, _extends({}, props, {
|
|
92
|
-
title: favoriteSearchesTitle,
|
|
93
|
-
collection: props.state.collections[1],
|
|
94
|
-
renderIcon: function renderIcon() {
|
|
95
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
96
|
-
className: "DocSearch-Hit-icon"
|
|
97
|
-
}, /*#__PURE__*/React.createElement(StarIcon, null));
|
|
98
|
-
},
|
|
99
|
-
renderAction: function renderAction(_ref3) {
|
|
100
|
-
var item = _ref3.item,
|
|
101
|
-
runDeleteTransition = _ref3.runDeleteTransition;
|
|
102
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
103
|
-
className: "DocSearch-Hit-action"
|
|
104
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
105
|
-
className: "DocSearch-Hit-action-button",
|
|
106
|
-
title: removeFavoriteSearchButtonTitle,
|
|
107
|
-
type: "submit",
|
|
108
|
-
onClick: function onClick(event) {
|
|
109
|
-
event.preventDefault();
|
|
110
|
-
event.stopPropagation();
|
|
111
|
-
runDeleteTransition(function () {
|
|
112
|
-
props.favoriteSearches.remove(item);
|
|
113
|
-
props.refresh();
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}, /*#__PURE__*/React.createElement(ResetIcon, null)));
|
|
117
|
-
}
|
|
118
|
-
})));
|
|
119
|
-
}
|