react-instantsearch 6.40.4 → 7.0.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.
Files changed (170) hide show
  1. package/README.md +113 -2
  2. package/dist/cjs/index.js +27 -0
  3. package/dist/cjs/package.json +1 -0
  4. package/dist/cjs/types/PartialKeys.js +1 -0
  5. package/dist/cjs/types/Translatable.js +1 -0
  6. package/dist/cjs/types/index.js +27 -0
  7. package/dist/cjs/ui/Breadcrumb.js +59 -0
  8. package/dist/cjs/ui/ClearRefinements.js +30 -0
  9. package/dist/cjs/ui/CurrentRefinements.js +53 -0
  10. package/dist/cjs/ui/HierarchicalMenu.js +82 -0
  11. package/dist/cjs/ui/Highlight.js +27 -0
  12. package/dist/cjs/ui/Hits.js +49 -0
  13. package/dist/cjs/ui/HitsPerPage.js +36 -0
  14. package/dist/cjs/ui/InfiniteHits.js +62 -0
  15. package/dist/cjs/ui/InternalHighlight.js +56 -0
  16. package/dist/cjs/ui/Menu.js +54 -0
  17. package/dist/cjs/ui/Pagination.js +127 -0
  18. package/dist/cjs/ui/PoweredBy.js +39 -0
  19. package/dist/cjs/ui/RangeInput.js +124 -0
  20. package/dist/cjs/ui/RefinementList.js +69 -0
  21. package/dist/cjs/ui/SearchBox.js +153 -0
  22. package/dist/cjs/ui/ShowMoreButton.js +19 -0
  23. package/dist/cjs/ui/Snippet.js +27 -0
  24. package/dist/cjs/ui/SortBy.js +37 -0
  25. package/dist/cjs/ui/Stats.js +34 -0
  26. package/dist/cjs/ui/ToggleRefinement.js +35 -0
  27. package/dist/cjs/ui/lib/cx.js +12 -0
  28. package/dist/cjs/ui/lib/isModifierClick.js +10 -0
  29. package/dist/cjs/widgets/Breadcrumb.js +49 -0
  30. package/dist/cjs/widgets/ClearRefinements.js +44 -0
  31. package/dist/cjs/widgets/CurrentRefinements.js +36 -0
  32. package/dist/cjs/widgets/HierarchicalMenu.js +70 -0
  33. package/dist/cjs/widgets/Highlight.js +33 -0
  34. package/dist/cjs/widgets/Hits.js +32 -0
  35. package/dist/cjs/widgets/HitsPerPage.js +40 -0
  36. package/dist/cjs/widgets/InfiniteHits.js +57 -0
  37. package/dist/cjs/widgets/Menu.js +64 -0
  38. package/dist/cjs/widgets/Pagination.js +76 -0
  39. package/dist/cjs/widgets/PoweredBy.js +19 -0
  40. package/dist/cjs/widgets/RangeInput.js +53 -0
  41. package/dist/cjs/widgets/RefinementList.js +124 -0
  42. package/dist/cjs/widgets/SearchBox.js +91 -0
  43. package/dist/cjs/widgets/Snippet.js +33 -0
  44. package/dist/cjs/widgets/SortBy.js +34 -0
  45. package/dist/cjs/widgets/Stats.js +43 -0
  46. package/dist/cjs/widgets/ToggleRefinement.js +40 -0
  47. package/dist/cjs/widgets/index.js +203 -0
  48. package/dist/es/index.d.ts +2 -0
  49. package/dist/es/index.js +2 -1
  50. package/dist/es/types/PartialKeys.d.ts +4 -0
  51. package/dist/es/types/PartialKeys.js +1 -0
  52. package/dist/es/types/Translatable.d.ts +5 -0
  53. package/dist/es/types/Translatable.js +1 -0
  54. package/dist/es/types/index.d.ts +2 -0
  55. package/dist/es/types/index.js +2 -0
  56. package/dist/es/ui/Breadcrumb.d.ts +48 -0
  57. package/dist/es/ui/Breadcrumb.js +52 -0
  58. package/dist/es/ui/ClearRefinements.d.ts +26 -0
  59. package/dist/es/ui/ClearRefinements.js +23 -0
  60. package/dist/es/ui/CurrentRefinements.d.ts +47 -0
  61. package/dist/es/ui/CurrentRefinements.js +46 -0
  62. package/dist/es/ui/HierarchicalMenu.d.ts +73 -0
  63. package/dist/es/ui/HierarchicalMenu.js +75 -0
  64. package/dist/es/ui/Highlight.d.ts +6 -0
  65. package/dist/es/ui/Highlight.js +20 -0
  66. package/dist/es/ui/Hits.d.ts +31 -0
  67. package/dist/es/ui/Hits.js +42 -0
  68. package/dist/es/ui/HitsPerPage.d.ts +23 -0
  69. package/dist/es/ui/HitsPerPage.js +29 -0
  70. package/dist/es/ui/InfiniteHits.d.ts +56 -0
  71. package/dist/es/ui/InfiniteHits.js +55 -0
  72. package/dist/es/ui/InternalHighlight.d.ts +32 -0
  73. package/dist/es/ui/InternalHighlight.js +47 -0
  74. package/dist/es/ui/Menu.d.ts +59 -0
  75. package/dist/es/ui/Menu.js +47 -0
  76. package/dist/es/ui/Pagination.d.ts +121 -0
  77. package/dist/es/ui/Pagination.js +120 -0
  78. package/dist/es/ui/PoweredBy.d.ts +29 -0
  79. package/dist/es/ui/PoweredBy.js +32 -0
  80. package/dist/es/ui/RangeInput.d.ts +60 -0
  81. package/dist/es/ui/RangeInput.js +115 -0
  82. package/dist/es/ui/RefinementList.d.ts +73 -0
  83. package/dist/es/ui/RefinementList.js +62 -0
  84. package/dist/es/ui/SearchBox.d.ts +64 -0
  85. package/dist/es/ui/SearchBox.js +146 -0
  86. package/dist/es/ui/ShowMoreButton.d.ts +19 -0
  87. package/dist/es/ui/ShowMoreButton.js +12 -0
  88. package/dist/es/ui/Snippet.d.ts +6 -0
  89. package/dist/es/ui/Snippet.js +20 -0
  90. package/dist/es/ui/SortBy.d.ts +21 -0
  91. package/dist/es/ui/SortBy.js +30 -0
  92. package/dist/es/ui/Stats.d.ts +20 -0
  93. package/dist/es/ui/Stats.js +27 -0
  94. package/dist/es/ui/ToggleRefinement.d.ts +25 -0
  95. package/dist/es/ui/ToggleRefinement.js +28 -0
  96. package/dist/es/ui/lib/cx.d.ts +1 -0
  97. package/dist/es/ui/lib/cx.js +6 -0
  98. package/dist/es/ui/lib/isModifierClick.d.ts +2 -0
  99. package/dist/es/ui/lib/isModifierClick.js +4 -0
  100. package/dist/es/widgets/Breadcrumb.d.ts +8 -0
  101. package/dist/es/widgets/Breadcrumb.js +42 -0
  102. package/dist/es/widgets/ClearRefinements.d.ts +8 -0
  103. package/dist/es/widgets/ClearRefinements.js +37 -0
  104. package/dist/es/widgets/CurrentRefinements.d.ts +6 -0
  105. package/dist/es/widgets/CurrentRefinements.js +29 -0
  106. package/dist/es/widgets/HierarchicalMenu.d.ts +8 -0
  107. package/dist/es/widgets/HierarchicalMenu.js +63 -0
  108. package/dist/es/widgets/Highlight.d.ts +8 -0
  109. package/dist/es/widgets/Highlight.js +26 -0
  110. package/dist/es/widgets/Hits.d.ts +7 -0
  111. package/dist/es/widgets/Hits.js +25 -0
  112. package/dist/es/widgets/HitsPerPage.d.ts +6 -0
  113. package/dist/es/widgets/HitsPerPage.js +33 -0
  114. package/dist/es/widgets/InfiniteHits.d.ts +15 -0
  115. package/dist/es/widgets/InfiniteHits.js +50 -0
  116. package/dist/es/widgets/Menu.d.ts +8 -0
  117. package/dist/es/widgets/Menu.js +57 -0
  118. package/dist/es/widgets/Pagination.d.ts +8 -0
  119. package/dist/es/widgets/Pagination.js +69 -0
  120. package/dist/es/widgets/PoweredBy.d.ts +5 -0
  121. package/dist/es/widgets/PoweredBy.js +12 -0
  122. package/dist/es/widgets/RangeInput.d.ts +8 -0
  123. package/dist/es/widgets/RangeInput.js +46 -0
  124. package/dist/es/widgets/RefinementList.d.ts +15 -0
  125. package/dist/es/widgets/RefinementList.js +116 -0
  126. package/dist/es/widgets/SearchBox.d.ts +13 -0
  127. package/dist/es/widgets/SearchBox.js +83 -0
  128. package/dist/es/widgets/Snippet.d.ts +8 -0
  129. package/dist/es/widgets/Snippet.js +26 -0
  130. package/dist/es/widgets/SortBy.d.ts +6 -0
  131. package/dist/es/widgets/SortBy.js +27 -0
  132. package/dist/es/widgets/Stats.d.ts +8 -0
  133. package/dist/es/widgets/Stats.js +36 -0
  134. package/dist/es/widgets/ToggleRefinement.d.ts +7 -0
  135. package/dist/es/widgets/ToggleRefinement.js +33 -0
  136. package/dist/es/widgets/index.d.ts +18 -0
  137. package/dist/es/widgets/index.js +18 -0
  138. package/dist/umd/ReactInstantSearch.js +19990 -0
  139. package/dist/umd/ReactInstantSearch.js.map +1 -0
  140. package/dist/umd/ReactInstantSearch.min.js +3 -0
  141. package/dist/umd/ReactInstantSearch.min.js.map +1 -0
  142. package/package.json +28 -24
  143. package/connectors.js +0 -29
  144. package/dist/README.md +0 -101
  145. package/dist/connectors.js +0 -168
  146. package/dist/dom.js +0 -198
  147. package/dist/es/connectors.js +0 -26
  148. package/dist/es/dom.js +0 -31
  149. package/dist/es/native.js +0 -5
  150. package/dist/es/server.js +0 -1
  151. package/dist/index.js +0 -12
  152. package/dist/native.js +0 -42
  153. package/dist/package.json +0 -56
  154. package/dist/server.js +0 -12
  155. package/dist/umd/Connectors.js +0 -11215
  156. package/dist/umd/Connectors.js.map +0 -1
  157. package/dist/umd/Connectors.min.js +0 -3
  158. package/dist/umd/Connectors.min.js.map +0 -1
  159. package/dist/umd/Core.js +0 -650
  160. package/dist/umd/Core.js.map +0 -1
  161. package/dist/umd/Core.min.js +0 -3
  162. package/dist/umd/Core.min.js.map +0 -1
  163. package/dist/umd/Dom.js +0 -18935
  164. package/dist/umd/Dom.js.map +0 -1
  165. package/dist/umd/Dom.min.js +0 -3
  166. package/dist/umd/Dom.min.js.map +0 -1
  167. package/dom.js +0 -34
  168. package/index.js +0 -1
  169. package/native.js +0 -8
  170. package/server.js +0 -1
@@ -0,0 +1,26 @@
1
+ var _excluded = ["hit", "attribute", "highlightedTagName", "nonHighlightedTagName", "separator"];
2
+ 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); }
3
+ 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; }
4
+ 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; }
5
+ import { getHighlightedParts, getPropertyByPath, unescape } from "instantsearch.js/es/lib/utils/index.js";
6
+ import React from 'react';
7
+ import { Highlight as HighlightUiComponent } from "../ui/Highlight.js";
8
+ export function Highlight(_ref) {
9
+ var hit = _ref.hit,
10
+ attribute = _ref.attribute,
11
+ highlightedTagName = _ref.highlightedTagName,
12
+ nonHighlightedTagName = _ref.nonHighlightedTagName,
13
+ separator = _ref.separator,
14
+ props = _objectWithoutProperties(_ref, _excluded);
15
+ var property = getPropertyByPath(hit._highlightResult, attribute) || [];
16
+ var properties = Array.isArray(property) ? property : [property];
17
+ var parts = properties.map(function (singleValue) {
18
+ return getHighlightedParts(unescape(singleValue.value || ''));
19
+ });
20
+ return /*#__PURE__*/React.createElement(HighlightUiComponent, _extends({}, props, {
21
+ parts: parts,
22
+ highlightedTagName: highlightedTagName,
23
+ nonHighlightedTagName: nonHighlightedTagName,
24
+ separator: separator
25
+ }));
26
+ }
@@ -0,0 +1,7 @@
1
+ import type { HitsProps as HitsUiComponentProps } from '../ui/Hits';
2
+ import type { Hit, BaseHit } from 'instantsearch.js';
3
+ import type { UseHitsProps } from 'react-instantsearch-core';
4
+ type UiProps<THit extends BaseHit> = Pick<HitsUiComponentProps<Hit<THit>>, 'hits' | 'sendEvent'>;
5
+ export type HitsProps<THit extends BaseHit> = Omit<HitsUiComponentProps<Hit<THit>>, keyof UiProps<THit>> & UseHitsProps<THit>;
6
+ export declare function Hits<THit extends BaseHit = BaseHit>({ escapeHTML, transformItems, ...props }: HitsProps<THit>): JSX.Element;
7
+ export {};
@@ -0,0 +1,25 @@
1
+ var _excluded = ["escapeHTML", "transformItems"];
2
+ 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); }
3
+ 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; }
4
+ 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; }
5
+ import React from 'react';
6
+ import { useHits } from 'react-instantsearch-core';
7
+ import { Hits as HitsUiComponent } from "../ui/Hits.js";
8
+ export function Hits(_ref) {
9
+ var escapeHTML = _ref.escapeHTML,
10
+ transformItems = _ref.transformItems,
11
+ props = _objectWithoutProperties(_ref, _excluded);
12
+ var _useHits = useHits({
13
+ escapeHTML: escapeHTML,
14
+ transformItems: transformItems
15
+ }, {
16
+ $$widgetType: 'ais.hits'
17
+ }),
18
+ hits = _useHits.hits,
19
+ sendEvent = _useHits.sendEvent;
20
+ var uiProps = {
21
+ hits: hits,
22
+ sendEvent: sendEvent
23
+ };
24
+ return /*#__PURE__*/React.createElement(HitsUiComponent, _extends({}, props, uiProps));
25
+ }
@@ -0,0 +1,6 @@
1
+ import type { HitsPerPageProps as HitsPerPageUiComponentProps } from '../ui/HitsPerPage';
2
+ import type { UseHitsPerPageProps } from 'react-instantsearch-core';
3
+ type UiProps = Pick<HitsPerPageUiComponentProps, 'items' | 'onChange' | 'currentValue'>;
4
+ export type HitsPerPageProps = Omit<HitsPerPageUiComponentProps, keyof UiProps> & UseHitsPerPageProps;
5
+ export declare function HitsPerPage({ items: userItems, transformItems, ...props }: HitsPerPageProps): JSX.Element;
6
+ export {};
@@ -0,0 +1,33 @@
1
+ var _excluded = ["items", "transformItems"];
2
+ 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); }
3
+ 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; }
4
+ 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; }
5
+ import React from 'react';
6
+ import { useHitsPerPage } from 'react-instantsearch-core';
7
+ import { HitsPerPage as HitsPerPageUiComponent } from "../ui/HitsPerPage.js";
8
+ export function HitsPerPage(_ref) {
9
+ var userItems = _ref.items,
10
+ transformItems = _ref.transformItems,
11
+ props = _objectWithoutProperties(_ref, _excluded);
12
+ var _useHitsPerPage = useHitsPerPage({
13
+ items: userItems,
14
+ transformItems: transformItems
15
+ }, {
16
+ $$widgetType: 'ais.hitsPerPage'
17
+ }),
18
+ items = _useHitsPerPage.items,
19
+ refine = _useHitsPerPage.refine;
20
+ var _ref2 = items.find(function (_ref3) {
21
+ var isRefined = _ref3.isRefined;
22
+ return isRefined;
23
+ }) || {},
24
+ currentValue = _ref2.value;
25
+ var uiProps = {
26
+ items: items,
27
+ currentValue: currentValue,
28
+ onChange: function onChange(value) {
29
+ return refine(value);
30
+ }
31
+ };
32
+ return /*#__PURE__*/React.createElement(HitsPerPageUiComponent, _extends({}, props, uiProps));
33
+ }
@@ -0,0 +1,15 @@
1
+ import type { InfiniteHitsProps as InfiniteHitsUiComponentProps } from '../ui/InfiniteHits';
2
+ import type { BaseHit, Hit } from 'instantsearch.js';
3
+ import type { UseInfiniteHitsProps } from 'react-instantsearch-core';
4
+ type UiProps<THit extends BaseHit = BaseHit> = Pick<InfiniteHitsUiComponentProps<Hit<THit>>, 'hits' | 'sendEvent' | 'onShowPrevious' | 'onShowMore' | 'isFirstPage' | 'isLastPage' | 'translations'>;
5
+ export type InfiniteHitsProps<THit extends BaseHit = BaseHit> = Omit<InfiniteHitsUiComponentProps<Hit<THit>>, keyof UiProps<THit>> & UseInfiniteHitsProps<THit> & {
6
+ /**
7
+ * Displays the "Show Previous" button when the UI is loaded from a page
8
+ * beyond the first one.
9
+ * @default true
10
+ */
11
+ showPrevious?: boolean;
12
+ translations?: Partial<UiProps<THit>['translations']>;
13
+ };
14
+ export declare function InfiniteHits<THit extends BaseHit = BaseHit>({ showPrevious: shouldShowPrevious, cache, escapeHTML, showPrevious: userShowPrevious, transformItems, translations, ...props }: InfiniteHitsProps<THit>): JSX.Element;
15
+ export {};
@@ -0,0 +1,50 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _excluded = ["showPrevious", "cache", "escapeHTML", "showPrevious", "transformItems", "translations"];
3
+ 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); }
4
+ 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; }
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
+ 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; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
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
+ 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; }
11
+ import React from 'react';
12
+ import { useInfiniteHits } from 'react-instantsearch-core';
13
+ import { InfiniteHits as InfiniteHitsUiComponent } from "../ui/InfiniteHits.js";
14
+ export function InfiniteHits(_ref) {
15
+ var _ref$showPrevious = _ref.showPrevious,
16
+ shouldShowPrevious = _ref$showPrevious === void 0 ? true : _ref$showPrevious,
17
+ cache = _ref.cache,
18
+ escapeHTML = _ref.escapeHTML,
19
+ userShowPrevious = _ref.showPrevious,
20
+ transformItems = _ref.transformItems,
21
+ translations = _ref.translations,
22
+ props = _objectWithoutProperties(_ref, _excluded);
23
+ var _useInfiniteHits = useInfiniteHits({
24
+ cache: cache,
25
+ escapeHTML: escapeHTML,
26
+ showPrevious: userShowPrevious,
27
+ transformItems: transformItems
28
+ }, {
29
+ $$widgetType: 'ais.infiniteHits'
30
+ }),
31
+ hits = _useInfiniteHits.hits,
32
+ sendEvent = _useInfiniteHits.sendEvent,
33
+ showPrevious = _useInfiniteHits.showPrevious,
34
+ showMore = _useInfiniteHits.showMore,
35
+ isFirstPage = _useInfiniteHits.isFirstPage,
36
+ isLastPage = _useInfiniteHits.isLastPage;
37
+ var uiProps = {
38
+ hits: hits,
39
+ sendEvent: sendEvent,
40
+ onShowPrevious: shouldShowPrevious ? showPrevious : undefined,
41
+ onShowMore: showMore,
42
+ isFirstPage: isFirstPage,
43
+ isLastPage: isLastPage,
44
+ translations: _objectSpread({
45
+ showPreviousButtonText: 'Show previous results',
46
+ showMoreButtonText: 'Show more results'
47
+ }, translations)
48
+ };
49
+ return /*#__PURE__*/React.createElement(InfiniteHitsUiComponent, _extends({}, props, uiProps));
50
+ }
@@ -0,0 +1,8 @@
1
+ import type { MenuProps as MenuUiComponentProps } from '../ui/Menu';
2
+ import type { UseMenuProps } from 'react-instantsearch-core';
3
+ type UiProps = Pick<MenuUiComponentProps, 'items' | 'onRefine' | 'createURL' | 'canToggleShowMore' | 'onToggleShowMore' | 'isShowingMore' | 'translations'>;
4
+ export type MenuProps = Omit<MenuUiComponentProps, keyof UiProps> & UseMenuProps & {
5
+ translations?: Partial<UiProps['translations']>;
6
+ };
7
+ export declare function Menu({ attribute, limit, showMore, showMoreLimit, sortBy, transformItems, translations, ...props }: MenuProps): JSX.Element;
8
+ export {};
@@ -0,0 +1,57 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _excluded = ["attribute", "limit", "showMore", "showMoreLimit", "sortBy", "transformItems", "translations"];
3
+ 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); }
4
+ 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; }
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
+ 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; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
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
+ 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; }
11
+ import React from 'react';
12
+ import { useMenu } from 'react-instantsearch-core';
13
+ import { Menu as MenuUiComponent } from "../ui/Menu.js";
14
+ export function Menu(_ref) {
15
+ var attribute = _ref.attribute,
16
+ limit = _ref.limit,
17
+ showMore = _ref.showMore,
18
+ showMoreLimit = _ref.showMoreLimit,
19
+ sortBy = _ref.sortBy,
20
+ transformItems = _ref.transformItems,
21
+ translations = _ref.translations,
22
+ props = _objectWithoutProperties(_ref, _excluded);
23
+ var _useMenu = useMenu({
24
+ attribute: attribute,
25
+ limit: limit,
26
+ showMore: showMore,
27
+ showMoreLimit: showMoreLimit,
28
+ sortBy: sortBy,
29
+ transformItems: transformItems
30
+ }, {
31
+ $$widgetType: 'ais.menu'
32
+ }),
33
+ canToggleShowMore = _useMenu.canToggleShowMore,
34
+ isShowingMore = _useMenu.isShowingMore,
35
+ items = _useMenu.items,
36
+ refine = _useMenu.refine,
37
+ createURL = _useMenu.createURL,
38
+ toggleShowMore = _useMenu.toggleShowMore;
39
+ var uiProps = {
40
+ items: items,
41
+ createURL: createURL,
42
+ onRefine: function onRefine(item) {
43
+ return refine(item.value);
44
+ },
45
+ canToggleShowMore: canToggleShowMore,
46
+ onToggleShowMore: toggleShowMore,
47
+ isShowingMore: isShowingMore,
48
+ translations: _objectSpread({
49
+ showMoreButtonText: function showMoreButtonText(options) {
50
+ return options.isShowingMore ? 'Show less' : 'Show more';
51
+ }
52
+ }, translations)
53
+ };
54
+ return /*#__PURE__*/React.createElement(MenuUiComponent, _extends({}, props, uiProps, {
55
+ showMore: showMore
56
+ }));
57
+ }
@@ -0,0 +1,8 @@
1
+ import type { PaginationProps as PaginationUiComponentProps } from '../ui/Pagination';
2
+ import type { UsePaginationProps } from 'react-instantsearch-core';
3
+ type UiProps = Pick<PaginationUiComponentProps, 'pages' | 'currentPage' | 'isFirstPage' | 'isLastPage' | 'nbPages' | 'createURL' | 'onNavigate' | 'translations'>;
4
+ export type PaginationProps = Omit<PaginationUiComponentProps, keyof UiProps> & UsePaginationProps & {
5
+ translations?: Partial<UiProps['translations']>;
6
+ };
7
+ export declare function Pagination({ showFirst, showPrevious, showNext, showLast, padding, totalPages, translations, ...props }: PaginationProps): JSX.Element;
8
+ export {};
@@ -0,0 +1,69 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _excluded = ["showFirst", "showPrevious", "showNext", "showLast", "padding", "totalPages", "translations"];
3
+ 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); }
4
+ 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; }
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
+ 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; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
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
+ 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; }
11
+ import React from 'react';
12
+ import { usePagination } from 'react-instantsearch-core';
13
+ import { Pagination as PaginationUiComponent } from "../ui/Pagination.js";
14
+ export function Pagination(_ref) {
15
+ var showFirst = _ref.showFirst,
16
+ showPrevious = _ref.showPrevious,
17
+ showNext = _ref.showNext,
18
+ showLast = _ref.showLast,
19
+ padding = _ref.padding,
20
+ totalPages = _ref.totalPages,
21
+ translations = _ref.translations,
22
+ props = _objectWithoutProperties(_ref, _excluded);
23
+ var _usePagination = usePagination({
24
+ padding: padding,
25
+ totalPages: totalPages
26
+ }, {
27
+ $$widgetType: 'ais.pagination'
28
+ }),
29
+ pages = _usePagination.pages,
30
+ currentRefinement = _usePagination.currentRefinement,
31
+ isFirstPage = _usePagination.isFirstPage,
32
+ isLastPage = _usePagination.isLastPage,
33
+ nbPages = _usePagination.nbPages,
34
+ createURL = _usePagination.createURL,
35
+ refine = _usePagination.refine;
36
+ var uiProps = {
37
+ pages: pages,
38
+ currentPage: currentRefinement,
39
+ isFirstPage: isFirstPage,
40
+ isLastPage: isLastPage,
41
+ nbPages: nbPages,
42
+ createURL: createURL,
43
+ onNavigate: refine,
44
+ translations: _objectSpread({
45
+ firstPageItemText: '‹‹',
46
+ previousPageItemText: '‹',
47
+ nextPageItemText: '›',
48
+ lastPageItemText: '››',
49
+ pageItemText: function pageItemText(_ref2) {
50
+ var currentPage = _ref2.currentPage;
51
+ return String(currentPage);
52
+ },
53
+ firstPageItemAriaLabel: 'First',
54
+ previousPageItemAriaLabel: 'Previous',
55
+ nextPageItemAriaLabel: 'Next',
56
+ lastPageItemAriaLabel: 'Last',
57
+ pageItemAriaLabel: function pageItemAriaLabel(_ref3) {
58
+ var currentPage = _ref3.currentPage;
59
+ return "Page ".concat(currentPage);
60
+ }
61
+ }, translations)
62
+ };
63
+ return /*#__PURE__*/React.createElement(PaginationUiComponent, _extends({}, props, uiProps, {
64
+ showFirst: showFirst,
65
+ showPrevious: showPrevious,
66
+ showNext: showNext,
67
+ showLast: showLast
68
+ }));
69
+ }
@@ -0,0 +1,5 @@
1
+ import type { PoweredByProps as PoweredByUiComponentProps } from '../ui/PoweredBy';
2
+ type UiProps = Pick<PoweredByUiComponentProps, 'url'>;
3
+ export type PoweredByProps = Omit<PoweredByUiComponentProps, keyof UiProps>;
4
+ export declare function PoweredBy(props: PoweredByProps): JSX.Element;
5
+ export {};
@@ -0,0 +1,12 @@
1
+ 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); }
2
+ import React from 'react';
3
+ import { usePoweredBy } from 'react-instantsearch-core';
4
+ import { PoweredBy as PoweredByUiComponent } from "../ui/PoweredBy.js";
5
+ export function PoweredBy(props) {
6
+ var _usePoweredBy = usePoweredBy(),
7
+ url = _usePoweredBy.url;
8
+ var uiProps = {
9
+ url: url
10
+ };
11
+ return /*#__PURE__*/React.createElement(PoweredByUiComponent, _extends({}, props, uiProps));
12
+ }
@@ -0,0 +1,8 @@
1
+ import type { RangeInputProps as RangeInputUiProps } from '../ui/RangeInput';
2
+ import type { UseRangeProps } from 'react-instantsearch-core';
3
+ type UiProps = Pick<RangeInputUiProps, 'disabled' | 'onSubmit' | 'range' | 'start' | 'step' | 'translations'>;
4
+ export type RangeInputProps = Omit<RangeInputUiProps, keyof UiProps> & UseRangeProps & {
5
+ translations?: Partial<UiProps['translations']>;
6
+ };
7
+ export declare function RangeInput({ attribute, min, max, precision, translations, ...props }: RangeInputProps): JSX.Element;
8
+ export {};
@@ -0,0 +1,46 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _excluded = ["attribute", "min", "max", "precision", "translations"];
3
+ 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); }
4
+ 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; }
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
+ 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; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
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
+ 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; }
11
+ import React from 'react';
12
+ import { useRange } from 'react-instantsearch-core';
13
+ import { RangeInput as RangeInputUiComponent } from "../ui/RangeInput.js";
14
+ export function RangeInput(_ref) {
15
+ var attribute = _ref.attribute,
16
+ min = _ref.min,
17
+ max = _ref.max,
18
+ precision = _ref.precision,
19
+ translations = _ref.translations,
20
+ props = _objectWithoutProperties(_ref, _excluded);
21
+ var _useRange = useRange({
22
+ attribute: attribute,
23
+ min: min,
24
+ max: max,
25
+ precision: precision
26
+ }, {
27
+ $$widgetType: 'ais.rangeInput'
28
+ }),
29
+ range = _useRange.range,
30
+ start = _useRange.start,
31
+ canRefine = _useRange.canRefine,
32
+ refine = _useRange.refine;
33
+ var step = 1 / Math.pow(10, precision || 0);
34
+ var uiProps = {
35
+ range: range,
36
+ start: start,
37
+ step: step,
38
+ disabled: !canRefine,
39
+ onSubmit: refine,
40
+ translations: _objectSpread({
41
+ separatorElementText: 'to',
42
+ submitButtonText: 'Go'
43
+ }, translations)
44
+ };
45
+ return /*#__PURE__*/React.createElement(RangeInputUiComponent, _extends({}, props, uiProps));
46
+ }
@@ -0,0 +1,15 @@
1
+ import type { RefinementListProps as RefinementListUiComponentProps } from '../ui/RefinementList';
2
+ import type { SearchBoxTranslations } from '../ui/SearchBox';
3
+ import type { RefinementListWidgetParams } from 'instantsearch.js/es/widgets/refinement-list/refinement-list';
4
+ import type { UseRefinementListProps } from 'react-instantsearch-core';
5
+ type UiProps = Pick<RefinementListUiComponentProps, 'canRefine' | 'items' | 'onRefine' | 'query' | 'searchBox' | 'noResults' | 'canToggleShowMore' | 'onToggleShowMore' | 'isShowingMore' | 'translations'>;
6
+ export type RefinementListProps = Omit<RefinementListUiComponentProps, keyof UiProps> & UseRefinementListProps & Pick<RefinementListWidgetParams, 'searchable' | 'searchablePlaceholder'> & {
7
+ translations?: Partial<UiProps['translations'] & SearchBoxTranslations & {
8
+ /**
9
+ * What to display when there are no results.
10
+ */
11
+ noResultsText: string;
12
+ }>;
13
+ };
14
+ export declare function RefinementList({ searchable, searchablePlaceholder, attribute, operator, limit, showMore, showMoreLimit, sortBy, escapeFacetValues, transformItems, translations, ...props }: RefinementListProps): JSX.Element;
15
+ export {};
@@ -0,0 +1,116 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _excluded = ["searchable", "searchablePlaceholder", "attribute", "operator", "limit", "showMore", "showMoreLimit", "sortBy", "escapeFacetValues", "transformItems", "translations"];
3
+ 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); }
4
+ 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; }
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
+ 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; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
+ 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."); }
11
+ 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); }
12
+ 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; }
13
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
14
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
+ 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; }
16
+ 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; }
17
+ import React, { useRef, useState } from 'react';
18
+ import { useRefinementList } from 'react-instantsearch-core';
19
+ import { RefinementList as RefinementListUiComponent } from "../ui/RefinementList.js";
20
+ import { SearchBox as SearchBoxUiComponent } from "../ui/SearchBox.js";
21
+ export function RefinementList(_ref) {
22
+ var searchable = _ref.searchable,
23
+ searchablePlaceholder = _ref.searchablePlaceholder,
24
+ attribute = _ref.attribute,
25
+ operator = _ref.operator,
26
+ limit = _ref.limit,
27
+ showMore = _ref.showMore,
28
+ showMoreLimit = _ref.showMoreLimit,
29
+ sortBy = _ref.sortBy,
30
+ escapeFacetValues = _ref.escapeFacetValues,
31
+ transformItems = _ref.transformItems,
32
+ translations = _ref.translations,
33
+ props = _objectWithoutProperties(_ref, _excluded);
34
+ var _useRefinementList = useRefinementList({
35
+ attribute: attribute,
36
+ operator: operator,
37
+ limit: limit,
38
+ showMore: showMore,
39
+ showMoreLimit: showMoreLimit,
40
+ sortBy: sortBy,
41
+ escapeFacetValues: escapeFacetValues,
42
+ transformItems: transformItems
43
+ }, {
44
+ $$widgetType: 'ais.refinementList'
45
+ }),
46
+ canRefine = _useRefinementList.canRefine,
47
+ canToggleShowMore = _useRefinementList.canToggleShowMore,
48
+ isFromSearch = _useRefinementList.isFromSearch,
49
+ isShowingMore = _useRefinementList.isShowingMore,
50
+ items = _useRefinementList.items,
51
+ refine = _useRefinementList.refine,
52
+ searchForItems = _useRefinementList.searchForItems,
53
+ toggleShowMore = _useRefinementList.toggleShowMore;
54
+ var _useState = useState(''),
55
+ _useState2 = _slicedToArray(_useState, 2),
56
+ inputValue = _useState2[0],
57
+ setInputValue = _useState2[1];
58
+ var inputRef = useRef(null);
59
+ function setQuery(newQuery) {
60
+ setInputValue(newQuery);
61
+ searchForItems(newQuery);
62
+ }
63
+ function onRefine(item) {
64
+ refine(item.value);
65
+ setQuery('');
66
+ }
67
+ function onChange(event) {
68
+ setQuery(event.currentTarget.value);
69
+ }
70
+ function onReset() {
71
+ setQuery('');
72
+ }
73
+ function onSubmit() {
74
+ if (items.length > 0) {
75
+ refine(items[0].value);
76
+ setQuery('');
77
+ }
78
+ }
79
+ var mergedTranslations = _objectSpread({
80
+ resetButtonTitle: 'Clear the search query',
81
+ submitButtonTitle: 'Submit the search query',
82
+ noResultsText: 'No results.',
83
+ showMoreButtonText: function showMoreButtonText(options) {
84
+ return options.isShowingMore ? 'Show less' : 'Show more';
85
+ }
86
+ }, translations);
87
+ var uiProps = {
88
+ items: items,
89
+ canRefine: canRefine,
90
+ onRefine: onRefine,
91
+ query: inputValue,
92
+ searchBox: searchable && /*#__PURE__*/React.createElement(SearchBoxUiComponent, {
93
+ inputRef: inputRef,
94
+ placeholder: searchablePlaceholder,
95
+ isSearchStalled: false,
96
+ value: inputValue,
97
+ onChange: onChange,
98
+ onReset: onReset,
99
+ onSubmit: onSubmit,
100
+ translations: {
101
+ submitButtonTitle: mergedTranslations.submitButtonTitle,
102
+ resetButtonTitle: mergedTranslations.resetButtonTitle
103
+ }
104
+ }),
105
+ noResults: searchable && isFromSearch && items.length === 0 && mergedTranslations.noResultsText,
106
+ canToggleShowMore: canToggleShowMore,
107
+ onToggleShowMore: toggleShowMore,
108
+ isShowingMore: isShowingMore,
109
+ translations: {
110
+ showMoreButtonText: mergedTranslations.showMoreButtonText
111
+ }
112
+ };
113
+ return /*#__PURE__*/React.createElement(RefinementListUiComponent, _extends({}, props, uiProps, {
114
+ showMore: showMore
115
+ }));
116
+ }
@@ -0,0 +1,13 @@
1
+ import type { SearchBoxProps as SearchBoxUiComponentProps } from '../ui/SearchBox';
2
+ import type { UseSearchBoxProps } from 'react-instantsearch-core';
3
+ type UiProps = Pick<SearchBoxUiComponentProps, 'inputRef' | 'isSearchStalled' | 'onChange' | 'onReset' | 'onSubmit' | 'value' | 'autoFocus' | 'translations'>;
4
+ export type SearchBoxProps = Omit<SearchBoxUiComponentProps, Exclude<keyof UiProps, 'onSubmit' | 'autoFocus'>> & UseSearchBoxProps & {
5
+ /**
6
+ * Whether to trigger the search only on submit.
7
+ * @default true
8
+ */
9
+ searchAsYouType?: boolean;
10
+ translations?: Partial<UiProps['translations']>;
11
+ };
12
+ export declare function SearchBox({ queryHook, searchAsYouType, translations, ...props }: SearchBoxProps): JSX.Element;
13
+ export {};