react-instantsearch 7.16.3 → 7.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Autocomplete.js +114 -0
- package/dist/cjs/components/Carousel.js +19 -1
- package/dist/cjs/components/useAutocomplete.js +237 -0
- package/dist/cjs/index.umd.js +38 -0
- package/dist/cjs/lib/useStickToBottom.js +20 -0
- package/dist/cjs/ui/SearchBox.js +5 -4
- package/dist/cjs/widgets/Chat.js +258 -0
- package/dist/cjs/widgets/chat/tools/SearchIndexTool.js +120 -0
- package/dist/cjs/widgets/index.js +22 -11
- package/dist/cjs/widgets/index.umd.js +282 -0
- package/dist/es/components/Autocomplete.d.ts +20 -0
- package/dist/es/components/Autocomplete.js +106 -0
- package/dist/es/components/Carousel.d.ts +1 -1
- package/dist/es/components/Carousel.js +20 -2
- package/dist/es/components/useAutocomplete.d.ts +35 -0
- package/dist/es/components/useAutocomplete.js +231 -0
- package/dist/es/index.umd.d.ts +3 -0
- package/dist/es/index.umd.js +3 -0
- package/dist/es/lib/useStickToBottom.d.ts +1 -0
- package/dist/es/lib/useStickToBottom.js +14 -0
- package/dist/es/ui/SearchBox.d.ts +2 -1
- package/dist/es/ui/SearchBox.js +5 -4
- package/dist/es/widgets/Chat.d.ts +45 -0
- package/dist/es/widgets/Chat.js +238 -0
- package/dist/es/widgets/chat/tools/SearchIndexTool.d.ts +5 -0
- package/dist/es/widgets/chat/tools/SearchIndexTool.js +113 -0
- package/dist/es/widgets/index.d.ts +2 -1
- package/dist/es/widgets/index.js +3 -2
- package/dist/es/widgets/index.umd.d.ts +26 -0
- package/dist/es/widgets/index.umd.js +28 -0
- package/dist/umd/ReactInstantSearch.js +216 -162
- package/dist/umd/ReactInstantSearch.js.map +1 -1
- package/dist/umd/ReactInstantSearch.min.js +1 -1
- package/dist/umd/ReactInstantSearch.min.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
8
|
+
import { ChevronLeftIconComponent, ChevronRightIconComponent, ArrowRightIconComponent, createButtonComponent } from 'instantsearch-ui-components';
|
|
9
|
+
import React, { createElement } from 'react';
|
|
10
|
+
import { Carousel } from "../../../components/index.js";
|
|
11
|
+
function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
12
|
+
var Button = createButtonComponent({
|
|
13
|
+
createElement: createElement
|
|
14
|
+
});
|
|
15
|
+
function SearchLayoutComponent(_ref) {
|
|
16
|
+
var message = _ref.message,
|
|
17
|
+
indexUiState = _ref.indexUiState,
|
|
18
|
+
setIndexUiState = _ref.setIndexUiState,
|
|
19
|
+
onClose = _ref.onClose;
|
|
20
|
+
var input = message === null || message === void 0 ? void 0 : message.input;
|
|
21
|
+
var output = message === null || message === void 0 ? void 0 : message.output;
|
|
22
|
+
var items = (output === null || output === void 0 ? void 0 : output.hits) || [];
|
|
23
|
+
var MemoedHeaderComponent = React.useMemo(function () {
|
|
24
|
+
return function (props) {
|
|
25
|
+
return /*#__PURE__*/React.createElement(HeaderComponent, _extends({
|
|
26
|
+
nbHits: output === null || output === void 0 ? void 0 : output.nbHits,
|
|
27
|
+
query: input === null || input === void 0 ? void 0 : input.query,
|
|
28
|
+
hitsPerPage: items.length,
|
|
29
|
+
setIndexUiState: setIndexUiState,
|
|
30
|
+
indexUiState: indexUiState,
|
|
31
|
+
getSearchPageURL: getSearchPageURL,
|
|
32
|
+
onClose: onClose
|
|
33
|
+
}, props));
|
|
34
|
+
};
|
|
35
|
+
}, [items.length, input === null || input === void 0 ? void 0 : input.query, output === null || output === void 0 ? void 0 : output.nbHits, setIndexUiState, onClose, indexUiState]);
|
|
36
|
+
return /*#__PURE__*/React.createElement(Carousel, {
|
|
37
|
+
items: items,
|
|
38
|
+
itemComponent: itemComponent,
|
|
39
|
+
sendEvent: function sendEvent() {},
|
|
40
|
+
showNavigation: false,
|
|
41
|
+
headerComponent: MemoedHeaderComponent
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function HeaderComponent(_ref2) {
|
|
45
|
+
var canScrollLeft = _ref2.canScrollLeft,
|
|
46
|
+
canScrollRight = _ref2.canScrollRight,
|
|
47
|
+
scrollLeft = _ref2.scrollLeft,
|
|
48
|
+
scrollRight = _ref2.scrollRight,
|
|
49
|
+
nbHits = _ref2.nbHits,
|
|
50
|
+
query = _ref2.query,
|
|
51
|
+
hitsPerPage = _ref2.hitsPerPage,
|
|
52
|
+
setIndexUiState = _ref2.setIndexUiState,
|
|
53
|
+
indexUiState = _ref2.indexUiState,
|
|
54
|
+
getSearchPageURL = _ref2.getSearchPageURL,
|
|
55
|
+
onClose = _ref2.onClose;
|
|
56
|
+
if ((hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) < 1) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: "ais-ChatToolSearchIndexCarouselHeader"
|
|
61
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderResults"
|
|
63
|
+
}, nbHits && /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderCount"
|
|
65
|
+
}, hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0, " of ", nbHits.toLocaleString(), " result", nbHits > 1 ? 's' : ''), showViewAll && /*#__PURE__*/React.createElement(Button, {
|
|
66
|
+
variant: "ghost",
|
|
67
|
+
size: "sm",
|
|
68
|
+
onClick: function onClick() {
|
|
69
|
+
if (!query) return;
|
|
70
|
+
var nextUiState = _objectSpread(_objectSpread({}, indexUiState), {}, {
|
|
71
|
+
query: query
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// If no main search page URL or we are on the search page, just update the state
|
|
75
|
+
if (!getSearchPageURL || getSearchPageURL && new URL(getSearchPageURL(nextUiState)).pathname === window.location.pathname) {
|
|
76
|
+
setIndexUiState(nextUiState);
|
|
77
|
+
onClose();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Navigate to different page
|
|
82
|
+
window.location.href = getSearchPageURL(nextUiState);
|
|
83
|
+
},
|
|
84
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderViewAll"
|
|
85
|
+
}, "View all", /*#__PURE__*/React.createElement(ArrowRightIconComponent, {
|
|
86
|
+
createElement: createElement
|
|
87
|
+
}))), (hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) > 2 && /*#__PURE__*/React.createElement("div", {
|
|
88
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButtons"
|
|
89
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
90
|
+
variant: "outline",
|
|
91
|
+
size: "sm",
|
|
92
|
+
iconOnly: true,
|
|
93
|
+
onClick: scrollLeft,
|
|
94
|
+
disabled: !canScrollLeft,
|
|
95
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
96
|
+
}, /*#__PURE__*/React.createElement(ChevronLeftIconComponent, {
|
|
97
|
+
createElement: createElement
|
|
98
|
+
})), /*#__PURE__*/React.createElement(Button, {
|
|
99
|
+
variant: "outline",
|
|
100
|
+
size: "sm",
|
|
101
|
+
iconOnly: true,
|
|
102
|
+
onClick: scrollRight,
|
|
103
|
+
disabled: !canScrollRight,
|
|
104
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
105
|
+
}, /*#__PURE__*/React.createElement(ChevronRightIconComponent, {
|
|
106
|
+
createElement: createElement
|
|
107
|
+
}))));
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
layoutComponent: SearchLayoutComponent
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export { createCarouselTool };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './Breadcrumb';
|
|
2
|
+
export * from './Chat';
|
|
2
3
|
export * from './ClearRefinements';
|
|
3
4
|
export * from './CurrentRefinements';
|
|
4
5
|
export * from './FrequentlyBoughtTogether';
|
|
@@ -7,6 +8,7 @@ export * from './Highlight';
|
|
|
7
8
|
export * from './Hits';
|
|
8
9
|
export * from './HitsPerPage';
|
|
9
10
|
export * from './InfiniteHits';
|
|
11
|
+
export * from './LookingSimilar';
|
|
10
12
|
export * from './Menu';
|
|
11
13
|
export * from './Pagination';
|
|
12
14
|
export * from './PoweredBy';
|
|
@@ -19,4 +21,3 @@ export * from './SortBy';
|
|
|
19
21
|
export * from './Stats';
|
|
20
22
|
export * from './ToggleRefinement';
|
|
21
23
|
export * from './TrendingItems';
|
|
22
|
-
export * from './LookingSimilar';
|
package/dist/es/widgets/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./Breadcrumb.js";
|
|
2
|
+
export * from "./Chat.js";
|
|
2
3
|
export * from "./ClearRefinements.js";
|
|
3
4
|
export * from "./CurrentRefinements.js";
|
|
4
5
|
export * from "./FrequentlyBoughtTogether.js";
|
|
@@ -7,6 +8,7 @@ export * from "./Highlight.js";
|
|
|
7
8
|
export * from "./Hits.js";
|
|
8
9
|
export * from "./HitsPerPage.js";
|
|
9
10
|
export * from "./InfiniteHits.js";
|
|
11
|
+
export * from "./LookingSimilar.js";
|
|
10
12
|
export * from "./Menu.js";
|
|
11
13
|
export * from "./Pagination.js";
|
|
12
14
|
export * from "./PoweredBy.js";
|
|
@@ -18,5 +20,4 @@ export * from "./Snippet.js";
|
|
|
18
20
|
export * from "./SortBy.js";
|
|
19
21
|
export * from "./Stats.js";
|
|
20
22
|
export * from "./ToggleRefinement.js";
|
|
21
|
-
export * from "./TrendingItems.js";
|
|
22
|
-
export * from "./LookingSimilar.js";
|
|
23
|
+
export * from "./TrendingItems.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from './Breadcrumb';
|
|
2
|
+
export declare const Chat: () => never;
|
|
3
|
+
export declare const SearchIndexToolType: undefined;
|
|
4
|
+
export declare const RecommendToolType: undefined;
|
|
5
|
+
export declare const createDefaultTools: () => void;
|
|
6
|
+
export * from './ClearRefinements';
|
|
7
|
+
export * from './CurrentRefinements';
|
|
8
|
+
export * from './FrequentlyBoughtTogether';
|
|
9
|
+
export * from './HierarchicalMenu';
|
|
10
|
+
export * from './Highlight';
|
|
11
|
+
export * from './Hits';
|
|
12
|
+
export * from './HitsPerPage';
|
|
13
|
+
export * from './InfiniteHits';
|
|
14
|
+
export * from './LookingSimilar';
|
|
15
|
+
export * from './Menu';
|
|
16
|
+
export * from './Pagination';
|
|
17
|
+
export * from './PoweredBy';
|
|
18
|
+
export * from './RangeInput';
|
|
19
|
+
export * from './RefinementList';
|
|
20
|
+
export * from './RelatedProducts';
|
|
21
|
+
export * from './SearchBox';
|
|
22
|
+
export * from './Snippet';
|
|
23
|
+
export * from './SortBy';
|
|
24
|
+
export * from './Stats';
|
|
25
|
+
export * from './ToggleRefinement';
|
|
26
|
+
export * from './TrendingItems';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * from "./Breadcrumb.js";
|
|
2
|
+
export var Chat = function Chat() {
|
|
3
|
+
throw new Error("\"<Chat>\" is not available from the UMD build.\n\nPlease use React InstantSearch with a packaging system:\nhttps://www.algolia.com/doc/guides/building-search-ui/installation/react/#install-react-instantsearch-as-an-npm-package");
|
|
4
|
+
};
|
|
5
|
+
export var SearchIndexToolType = undefined;
|
|
6
|
+
export var RecommendToolType = undefined;
|
|
7
|
+
export var createDefaultTools = function createDefaultTools() {};
|
|
8
|
+
export * from "./ClearRefinements.js";
|
|
9
|
+
export * from "./CurrentRefinements.js";
|
|
10
|
+
export * from "./FrequentlyBoughtTogether.js";
|
|
11
|
+
export * from "./HierarchicalMenu.js";
|
|
12
|
+
export * from "./Highlight.js";
|
|
13
|
+
export * from "./Hits.js";
|
|
14
|
+
export * from "./HitsPerPage.js";
|
|
15
|
+
export * from "./InfiniteHits.js";
|
|
16
|
+
export * from "./LookingSimilar.js";
|
|
17
|
+
export * from "./Menu.js";
|
|
18
|
+
export * from "./Pagination.js";
|
|
19
|
+
export * from "./PoweredBy.js";
|
|
20
|
+
export * from "./RangeInput.js";
|
|
21
|
+
export * from "./RefinementList.js";
|
|
22
|
+
export * from "./RelatedProducts.js";
|
|
23
|
+
export * from "./SearchBox.js";
|
|
24
|
+
export * from "./Snippet.js";
|
|
25
|
+
export * from "./SortBy.js";
|
|
26
|
+
export * from "./Stats.js";
|
|
27
|
+
export * from "./ToggleRefinement.js";
|
|
28
|
+
export * from "./TrendingItems.js";
|