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,20 @@
1
+ var _excluded = ["classNames"];
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 { InternalHighlight } from "./InternalHighlight.js";
7
+ import { cx } from "./lib/cx.js";
8
+ export function Highlight(_ref) {
9
+ var _ref$classNames = _ref.classNames,
10
+ classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
11
+ props = _objectWithoutProperties(_ref, _excluded);
12
+ return /*#__PURE__*/React.createElement(InternalHighlight, _extends({
13
+ classNames: {
14
+ root: cx('ais-Highlight', classNames.root),
15
+ highlighted: cx('ais-Highlight-highlighted', classNames.highlighted),
16
+ nonHighlighted: cx('ais-Highlight-nonHighlighted', classNames.nonHighlighted),
17
+ separator: cx('ais-Highlight-separator', classNames.separator)
18
+ }
19
+ }, props));
20
+ }
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import type { Hit } from 'instantsearch.js';
3
+ import type { SendEventForHits } from 'instantsearch.js/es/lib/utils';
4
+ export type HitsProps<THit> = React.ComponentProps<'div'> & {
5
+ hits: THit[];
6
+ sendEvent: SendEventForHits;
7
+ hitComponent?: React.JSXElementConstructor<{
8
+ hit: THit;
9
+ sendEvent: SendEventForHits;
10
+ }>;
11
+ classNames?: Partial<HitsClassNames>;
12
+ };
13
+ export type HitsClassNames = {
14
+ /**
15
+ * Class names to apply to the root element
16
+ */
17
+ root: string;
18
+ /**
19
+ * Class names to apply to the root element without results
20
+ */
21
+ emptyRoot: string;
22
+ /**
23
+ * Class names to apply to the list element
24
+ */
25
+ list: string;
26
+ /**
27
+ * Class names to apply to each item element
28
+ */
29
+ item: string;
30
+ };
31
+ export declare function Hits<THit extends Hit>({ hits, sendEvent, hitComponent: HitComponent, classNames, ...props }: HitsProps<THit>): JSX.Element;
@@ -0,0 +1,42 @@
1
+ var _excluded = ["hits", "sendEvent", "hitComponent", "classNames"];
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 { cx } from "./lib/cx.js";
7
+ function DefaultHitComponent(_ref) {
8
+ var hit = _ref.hit;
9
+ return /*#__PURE__*/React.createElement("div", {
10
+ style: {
11
+ wordBreak: 'break-all'
12
+ }
13
+ }, JSON.stringify(hit).slice(0, 100), "\u2026");
14
+ }
15
+ export function Hits(_ref2) {
16
+ var hits = _ref2.hits,
17
+ sendEvent = _ref2.sendEvent,
18
+ _ref2$hitComponent = _ref2.hitComponent,
19
+ HitComponent = _ref2$hitComponent === void 0 ? DefaultHitComponent : _ref2$hitComponent,
20
+ _ref2$classNames = _ref2.classNames,
21
+ classNames = _ref2$classNames === void 0 ? {} : _ref2$classNames,
22
+ props = _objectWithoutProperties(_ref2, _excluded);
23
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
24
+ className: cx('ais-Hits', classNames.root, hits.length === 0 && cx('ais-Hits--empty', classNames.emptyRoot), props.className)
25
+ }), /*#__PURE__*/React.createElement("ol", {
26
+ className: cx('ais-Hits-list', classNames.list)
27
+ }, hits.map(function (hit) {
28
+ return /*#__PURE__*/React.createElement("li", {
29
+ key: hit.objectID,
30
+ className: cx('ais-Hits-item', classNames.item),
31
+ onClick: function onClick() {
32
+ sendEvent('click:internal', hit, 'Hit Clicked');
33
+ },
34
+ onAuxClick: function onAuxClick() {
35
+ sendEvent('click:internal', hit, 'Hit Clicked');
36
+ }
37
+ }, /*#__PURE__*/React.createElement(HitComponent, {
38
+ hit: hit,
39
+ sendEvent: sendEvent
40
+ }));
41
+ })));
42
+ }
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import type { HitsPerPageConnectorParamsItem as HitsPerPageItem } from 'instantsearch.js/es/connectors/hits-per-page/connectHitsPerPage';
3
+ export type HitsPerPageProps = Omit<React.ComponentProps<'div'>, 'onChange'> & {
4
+ items: HitsPerPageItem[];
5
+ onChange: (value: number) => void;
6
+ currentValue: number;
7
+ classNames?: Partial<HitsPerPageClassNames>;
8
+ };
9
+ export type HitsPerPageClassNames = {
10
+ /**
11
+ * Class names to apply to the root element
12
+ */
13
+ root: string;
14
+ /**
15
+ * Class names to apply to the select element
16
+ */
17
+ select: string;
18
+ /**
19
+ * Class names to apply to the option element
20
+ */
21
+ option: string;
22
+ };
23
+ export declare function HitsPerPage({ items, onChange, currentValue, classNames, ...props }: HitsPerPageProps): JSX.Element;
@@ -0,0 +1,29 @@
1
+ var _excluded = ["items", "onChange", "currentValue", "classNames"];
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 { cx } from "./lib/cx.js";
7
+ export function HitsPerPage(_ref) {
8
+ var items = _ref.items,
9
+ _onChange = _ref.onChange,
10
+ currentValue = _ref.currentValue,
11
+ _ref$classNames = _ref.classNames,
12
+ classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
13
+ props = _objectWithoutProperties(_ref, _excluded);
14
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
15
+ className: cx('ais-HitsPerPage', classNames.root, props.className)
16
+ }), /*#__PURE__*/React.createElement("select", {
17
+ className: cx('ais-HitsPerPage-select', classNames.select),
18
+ onChange: function onChange(event) {
19
+ _onChange(Number(event.target.value));
20
+ },
21
+ value: String(currentValue)
22
+ }, items.map(function (item) {
23
+ return /*#__PURE__*/React.createElement("option", {
24
+ key: item.value,
25
+ className: cx('ais-HitsPerPage-option', classNames.option),
26
+ value: item.value
27
+ }, item.label);
28
+ })));
29
+ }
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import type { Hit } from 'instantsearch.js';
3
+ import type { SendEventForHits } from 'instantsearch.js/es/lib/utils';
4
+ export type InfiniteHitsProps<THit> = React.ComponentProps<'div'> & {
5
+ hits: THit[];
6
+ sendEvent: SendEventForHits;
7
+ hitComponent?: React.JSXElementConstructor<{
8
+ hit: THit;
9
+ sendEvent: SendEventForHits;
10
+ }>;
11
+ isFirstPage: boolean;
12
+ isLastPage: boolean;
13
+ onShowPrevious?: () => void;
14
+ onShowMore: () => void;
15
+ classNames?: Partial<InfiniteHitsClassNames>;
16
+ translations: InfiniteHitsTranslations;
17
+ };
18
+ export type InfiniteHitsClassNames = {
19
+ /**
20
+ * Class names to apply to the root element
21
+ */
22
+ root: string;
23
+ /**
24
+ * Class names to apply to the root element without results
25
+ */
26
+ emptyRoot: string;
27
+ /**
28
+ * Class names to apply to the "load previous" button
29
+ */
30
+ loadPrevious: string;
31
+ /**
32
+ * Class names to apply to the "load previous" button when it's disabled
33
+ */
34
+ disabledLoadPrevious: string;
35
+ /**
36
+ * Class names to apply to the "load more" button
37
+ */
38
+ loadMore: string;
39
+ /**
40
+ * Class names to apply to the "load more" button when it's disabled
41
+ */
42
+ disabledLoadMore: string;
43
+ /**
44
+ * Class names to apply to the list element
45
+ */
46
+ list: string;
47
+ /**
48
+ * Class names to apply to each item element
49
+ */
50
+ item: string;
51
+ };
52
+ export type InfiniteHitsTranslations = {
53
+ showPreviousButtonText: string;
54
+ showMoreButtonText: string;
55
+ };
56
+ export declare function InfiniteHits<THit extends Hit>({ hitComponent: HitComponent, hits, sendEvent, isFirstPage, isLastPage, onShowPrevious, onShowMore, classNames, translations, ...props }: InfiniteHitsProps<THit>): JSX.Element;
@@ -0,0 +1,55 @@
1
+ var _excluded = ["hitComponent", "hits", "sendEvent", "isFirstPage", "isLastPage", "onShowPrevious", "onShowMore", "classNames", "translations"];
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 { cx } from "./lib/cx.js";
7
+ function DefaultHitComponent(_ref) {
8
+ var hit = _ref.hit;
9
+ return /*#__PURE__*/React.createElement("div", {
10
+ style: {
11
+ wordBreak: 'break-all'
12
+ }
13
+ }, JSON.stringify(hit).slice(0, 100), "\u2026");
14
+ }
15
+ export function InfiniteHits(_ref2) {
16
+ var _ref2$hitComponent = _ref2.hitComponent,
17
+ HitComponent = _ref2$hitComponent === void 0 ? DefaultHitComponent : _ref2$hitComponent,
18
+ hits = _ref2.hits,
19
+ sendEvent = _ref2.sendEvent,
20
+ isFirstPage = _ref2.isFirstPage,
21
+ isLastPage = _ref2.isLastPage,
22
+ onShowPrevious = _ref2.onShowPrevious,
23
+ onShowMore = _ref2.onShowMore,
24
+ _ref2$classNames = _ref2.classNames,
25
+ classNames = _ref2$classNames === void 0 ? {} : _ref2$classNames,
26
+ translations = _ref2.translations,
27
+ props = _objectWithoutProperties(_ref2, _excluded);
28
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
29
+ className: cx('ais-InfiniteHits', classNames.root, hits.length === 0 && cx('ais-InfiniteHits--empty', classNames.emptyRoot), props.className)
30
+ }), onShowPrevious && /*#__PURE__*/React.createElement("button", {
31
+ className: cx('ais-InfiniteHits-loadPrevious', classNames.loadPrevious, isFirstPage && cx('ais-InfiniteHits-loadPrevious--disabled', classNames.disabledLoadPrevious)),
32
+ onClick: onShowPrevious,
33
+ disabled: isFirstPage
34
+ }, translations.showPreviousButtonText), /*#__PURE__*/React.createElement("ol", {
35
+ className: cx('ais-InfiniteHits-list', classNames.list)
36
+ }, hits.map(function (hit) {
37
+ return /*#__PURE__*/React.createElement("li", {
38
+ key: hit.objectID,
39
+ className: cx('ais-InfiniteHits-item', classNames.item),
40
+ onClick: function onClick() {
41
+ sendEvent('click:internal', hit, 'Hit Clicked');
42
+ },
43
+ onAuxClick: function onAuxClick() {
44
+ sendEvent('click:internal', hit, 'Hit Clicked');
45
+ }
46
+ }, /*#__PURE__*/React.createElement(HitComponent, {
47
+ hit: hit,
48
+ sendEvent: sendEvent
49
+ }));
50
+ })), /*#__PURE__*/React.createElement("button", {
51
+ className: cx('ais-InfiniteHits-loadMore', classNames.loadMore, isLastPage && cx('ais-InfiniteHits-loadMore--disabled', classNames.disabledLoadMore)),
52
+ onClick: onShowMore,
53
+ disabled: isLastPage
54
+ }, translations.showMoreButtonText));
55
+ }
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ type HighlightedPart = {
3
+ isHighlighted: boolean;
4
+ value: string;
5
+ };
6
+ export type InternalHighlightClassNames = {
7
+ /**
8
+ * Class names to apply to the root element
9
+ */
10
+ root: string;
11
+ /**
12
+ * Class names to apply to the highlighted parts
13
+ */
14
+ highlighted: string;
15
+ /**
16
+ * Class names to apply to the non-highlighted parts
17
+ */
18
+ nonHighlighted: string;
19
+ /**
20
+ * Class names to apply to the separator between highlighted parts
21
+ */
22
+ separator: string;
23
+ };
24
+ export type InternalHighlightProps = React.HTMLAttributes<HTMLSpanElement> & {
25
+ classNames: InternalHighlightClassNames;
26
+ highlightedTagName?: React.ElementType;
27
+ nonHighlightedTagName?: React.ElementType;
28
+ separator?: React.ReactNode;
29
+ parts: HighlightedPart[][];
30
+ };
31
+ export declare function InternalHighlight({ parts, highlightedTagName, nonHighlightedTagName, separator, className, classNames, ...props }: InternalHighlightProps): JSX.Element;
32
+ export {};
@@ -0,0 +1,47 @@
1
+ var _excluded = ["parts", "highlightedTagName", "nonHighlightedTagName", "separator", "className", "classNames"];
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, { Fragment } from 'react';
6
+ import { cx } from "./lib/cx.js";
7
+ function HighlightPart(_ref) {
8
+ var classNames = _ref.classNames,
9
+ children = _ref.children,
10
+ highlightedTagName = _ref.highlightedTagName,
11
+ isHighlighted = _ref.isHighlighted,
12
+ nonHighlightedTagName = _ref.nonHighlightedTagName;
13
+ var TagName = isHighlighted ? highlightedTagName : nonHighlightedTagName;
14
+ return /*#__PURE__*/React.createElement(TagName, {
15
+ className: isHighlighted ? classNames.highlighted : classNames.nonHighlighted
16
+ }, children);
17
+ }
18
+ export function InternalHighlight(_ref2) {
19
+ var parts = _ref2.parts,
20
+ _ref2$highlightedTagN = _ref2.highlightedTagName,
21
+ highlightedTagName = _ref2$highlightedTagN === void 0 ? 'mark' : _ref2$highlightedTagN,
22
+ _ref2$nonHighlightedT = _ref2.nonHighlightedTagName,
23
+ nonHighlightedTagName = _ref2$nonHighlightedT === void 0 ? 'span' : _ref2$nonHighlightedT,
24
+ _ref2$separator = _ref2.separator,
25
+ separator = _ref2$separator === void 0 ? ', ' : _ref2$separator,
26
+ className = _ref2.className,
27
+ classNames = _ref2.classNames,
28
+ props = _objectWithoutProperties(_ref2, _excluded);
29
+ return /*#__PURE__*/React.createElement("span", _extends({}, props, {
30
+ className: cx(classNames.root, className)
31
+ }), parts.map(function (part, partIndex) {
32
+ var isLastPart = partIndex === parts.length - 1;
33
+ return /*#__PURE__*/React.createElement(Fragment, {
34
+ key: partIndex
35
+ }, part.map(function (subPart, subPartIndex) {
36
+ return /*#__PURE__*/React.createElement(HighlightPart, {
37
+ key: subPartIndex,
38
+ classNames: classNames,
39
+ highlightedTagName: highlightedTagName,
40
+ nonHighlightedTagName: nonHighlightedTagName,
41
+ isHighlighted: subPart.isHighlighted
42
+ }, subPart.value);
43
+ }), !isLastPart && /*#__PURE__*/React.createElement("span", {
44
+ className: classNames.separator
45
+ }, separator));
46
+ }));
47
+ }
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import type { ShowMoreButtonTranslations } from './ShowMoreButton';
3
+ import type { CreateURL } from 'instantsearch.js';
4
+ import type { MenuItem } from 'instantsearch.js/es/connectors/menu/connectMenu';
5
+ export type MenuProps = React.ComponentProps<'div'> & {
6
+ items: MenuItem[];
7
+ classNames?: Partial<MenuCSSClasses>;
8
+ showMore?: boolean;
9
+ canToggleShowMore: boolean;
10
+ onToggleShowMore: () => void;
11
+ isShowingMore: boolean;
12
+ createURL: CreateURL<MenuItem['value']>;
13
+ onRefine: (item: MenuItem) => void;
14
+ translations: MenuTranslations;
15
+ };
16
+ export type MenuCSSClasses = {
17
+ /**
18
+ * Class names to apply to the root element
19
+ */
20
+ root: string;
21
+ /**
22
+ * Class names to apply to the root element when there are no refinements possible
23
+ */
24
+ noRefinementRoot: string;
25
+ /**
26
+ * Class names to apply to the list element
27
+ */
28
+ list: string;
29
+ /**
30
+ * Class names to apply to each item element
31
+ */
32
+ item: string;
33
+ /**
34
+ * Class names to apply to each selected item element
35
+ */
36
+ selectedItem: string;
37
+ /**
38
+ * Class names to apply to each link element
39
+ */
40
+ link: string;
41
+ /**
42
+ * Class names to apply to each label element
43
+ */
44
+ label: string;
45
+ /**
46
+ * Class names to apply to each facet count element
47
+ */
48
+ count: string;
49
+ /**
50
+ * Class names to apply to the "Show more" button
51
+ */
52
+ showMore: string;
53
+ /**
54
+ * Class names to apply to the "Show more" button if it's disabled
55
+ */
56
+ disabledShowMore: string;
57
+ };
58
+ export type MenuTranslations = ShowMoreButtonTranslations;
59
+ export declare function Menu({ items, classNames, showMore, canToggleShowMore, onToggleShowMore, isShowingMore, createURL, onRefine, translations, ...props }: MenuProps): JSX.Element;
@@ -0,0 +1,47 @@
1
+ var _excluded = ["items", "classNames", "showMore", "canToggleShowMore", "onToggleShowMore", "isShowingMore", "createURL", "onRefine", "translations"];
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 { cx } from "./lib/cx.js";
7
+ import { ShowMoreButton } from "./ShowMoreButton.js";
8
+ export function Menu(_ref) {
9
+ var items = _ref.items,
10
+ _ref$classNames = _ref.classNames,
11
+ classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
12
+ showMore = _ref.showMore,
13
+ canToggleShowMore = _ref.canToggleShowMore,
14
+ onToggleShowMore = _ref.onToggleShowMore,
15
+ isShowingMore = _ref.isShowingMore,
16
+ createURL = _ref.createURL,
17
+ onRefine = _ref.onRefine,
18
+ translations = _ref.translations,
19
+ props = _objectWithoutProperties(_ref, _excluded);
20
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
21
+ className: cx('ais-Menu', classNames.root, items.length === 0 && cx('ais-Menu--noRefinement', classNames.noRefinementRoot), props.className)
22
+ }), /*#__PURE__*/React.createElement("ul", {
23
+ className: cx('ais-Menu-list', classNames.list)
24
+ }, items.map(function (item) {
25
+ return /*#__PURE__*/React.createElement("li", {
26
+ key: item.label,
27
+ className: cx('ais-Menu-item', classNames.item, item.isRefined && cx('ais-Menu-item--selected', classNames.selectedItem))
28
+ }, /*#__PURE__*/React.createElement("a", {
29
+ className: cx('ais-Menu-link', classNames.link),
30
+ href: createURL(item.value),
31
+ onClick: function onClick(event) {
32
+ event.preventDefault();
33
+ onRefine(item);
34
+ }
35
+ }, /*#__PURE__*/React.createElement("span", {
36
+ className: cx('ais-Menu-label', classNames.label)
37
+ }, item.label), /*#__PURE__*/React.createElement("span", {
38
+ className: cx('ais-Menu-count', classNames.count)
39
+ }, item.count)));
40
+ })), showMore && /*#__PURE__*/React.createElement(ShowMoreButton, {
41
+ className: cx('ais-Menu-showMore', classNames.showMore, !canToggleShowMore && cx('ais-Menu-showMore--disabled', classNames.disabledShowMore)),
42
+ disabled: !canToggleShowMore,
43
+ onClick: onToggleShowMore,
44
+ isShowingMore: isShowingMore,
45
+ translations: translations
46
+ }));
47
+ }
@@ -0,0 +1,121 @@
1
+ import React from 'react';
2
+ import type { CreateURL } from 'instantsearch.js';
3
+ export type PageItemTextOptions = {
4
+ /**
5
+ * The page number to be displayed.
6
+ */
7
+ currentPage: number;
8
+ /**
9
+ * The total number of pages.
10
+ */
11
+ nbPages: number;
12
+ };
13
+ export type PaginationTranslations = {
14
+ /**
15
+ * The label for the first page's button.
16
+ */
17
+ firstPageItemText: string;
18
+ /**
19
+ * The label for the previous page's button.
20
+ */
21
+ previousPageItemText: string;
22
+ /**
23
+ * The label for the next page's button.
24
+ */
25
+ nextPageItemText: string;
26
+ /**
27
+ * The label for the last page's button.
28
+ */
29
+ lastPageItemText: string;
30
+ /**
31
+ * The label for a page's button.
32
+ */
33
+ pageItemText: (options: PageItemTextOptions) => string;
34
+ /**
35
+ * The accessible label for the first page's button.
36
+ */
37
+ firstPageItemAriaLabel: string;
38
+ /**
39
+ * The accessible label for the previous page's button.
40
+ */
41
+ previousPageItemAriaLabel: string;
42
+ /**
43
+ * The accessible label for the next page's button.
44
+ */
45
+ nextPageItemAriaLabel: string;
46
+ /**
47
+ * The accessible label for the last page's button.
48
+ */
49
+ lastPageItemAriaLabel: string;
50
+ /**
51
+ * The accessible label for a page's button.
52
+ */
53
+ pageItemAriaLabel: (options: PageItemTextOptions) => string;
54
+ };
55
+ export type PaginationProps = React.ComponentProps<'div'> & {
56
+ classNames?: Partial<PaginationClassNames>;
57
+ pages: number[];
58
+ currentPage: number;
59
+ isFirstPage: boolean;
60
+ isLastPage: boolean;
61
+ nbPages: number;
62
+ showFirst?: boolean;
63
+ showPrevious?: boolean;
64
+ showNext?: boolean;
65
+ showLast?: boolean;
66
+ createURL: CreateURL<number>;
67
+ onNavigate: (page: number) => void;
68
+ } & {
69
+ translations: PaginationTranslations;
70
+ };
71
+ export type PaginationClassNames = {
72
+ /**
73
+ * Class names to apply to the root element
74
+ */
75
+ root: string;
76
+ /**
77
+ * Class names to apply to the root element when there are no refinements possible
78
+ */
79
+ noRefinementRoot: string;
80
+ /**
81
+ * Class names to apply to the list element
82
+ */
83
+ list: string;
84
+ /**
85
+ * Class names to apply to each item element
86
+ */
87
+ item: string;
88
+ /**
89
+ * Class names to apply to the first page element
90
+ */
91
+ firstPageItem: string;
92
+ /**
93
+ * Class names to apply to the previous page element
94
+ */
95
+ previousPageItem: string;
96
+ /**
97
+ * Class names to apply to each page element
98
+ */
99
+ pageItem: string;
100
+ /**
101
+ * Class names to apply to a selected page element
102
+ */
103
+ selectedItem: string;
104
+ /**
105
+ * Class names to apply to a disabled page element
106
+ */
107
+ disabledItem: string;
108
+ /**
109
+ * Class names to apply to the next page element
110
+ */
111
+ nextPageItem: string;
112
+ /**
113
+ * Class names to apply to the last page element
114
+ */
115
+ lastPageItem: string;
116
+ /**
117
+ * Class names to apply to each link element
118
+ */
119
+ link: string;
120
+ };
121
+ export declare function Pagination({ pages, currentPage, nbPages, isFirstPage, isLastPage, showFirst, showPrevious, showNext, showLast, createURL, onNavigate, translations, classNames, ...props }: PaginationProps): JSX.Element;