react-instantsearch 7.5.5 → 7.7.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 (56) hide show
  1. package/dist/cjs/ui/Breadcrumb.js +8 -8
  2. package/dist/cjs/ui/ClearRefinements.js +3 -3
  3. package/dist/cjs/ui/CurrentRefinements.js +9 -8
  4. package/dist/cjs/ui/HierarchicalMenu.js +9 -9
  5. package/dist/cjs/ui/Highlight.js +5 -5
  6. package/dist/cjs/ui/HitsPerPage.js +4 -4
  7. package/dist/cjs/ui/InfiniteHits.js +6 -6
  8. package/dist/cjs/ui/InternalHighlight.js +8 -51
  9. package/dist/cjs/ui/Menu.js +8 -8
  10. package/dist/cjs/ui/Pagination.js +12 -12
  11. package/dist/cjs/ui/PoweredBy.js +4 -4
  12. package/dist/cjs/ui/RangeInput.js +9 -9
  13. package/dist/cjs/ui/RefinementList.js +11 -11
  14. package/dist/cjs/ui/SearchBox.js +10 -12
  15. package/dist/cjs/ui/Snippet.js +5 -5
  16. package/dist/cjs/ui/SortBy.js +4 -4
  17. package/dist/cjs/ui/Stats.js +2 -2
  18. package/dist/cjs/ui/ToggleRefinement.js +5 -5
  19. package/dist/cjs/ui/lib/index.js +0 -11
  20. package/dist/cjs/widgets/Hits.js +41 -10
  21. package/dist/es/ui/Breadcrumb.js +1 -1
  22. package/dist/es/ui/ClearRefinements.js +1 -1
  23. package/dist/es/ui/CurrentRefinements.js +2 -1
  24. package/dist/es/ui/HierarchicalMenu.js +1 -1
  25. package/dist/es/ui/Highlight.d.ts +1 -1
  26. package/dist/es/ui/Highlight.js +1 -1
  27. package/dist/es/ui/HitsPerPage.js +1 -1
  28. package/dist/es/ui/InfiniteHits.js +1 -1
  29. package/dist/es/ui/InternalHighlight.d.ts +1 -32
  30. package/dist/es/ui/InternalHighlight.js +6 -47
  31. package/dist/es/ui/Menu.js +1 -1
  32. package/dist/es/ui/Pagination.js +1 -1
  33. package/dist/es/ui/PoweredBy.js +1 -1
  34. package/dist/es/ui/RangeInput.js +1 -1
  35. package/dist/es/ui/RefinementList.js +1 -1
  36. package/dist/es/ui/SearchBox.js +2 -4
  37. package/dist/es/ui/Snippet.d.ts +1 -1
  38. package/dist/es/ui/Snippet.js +1 -1
  39. package/dist/es/ui/SortBy.js +1 -1
  40. package/dist/es/ui/Stats.js +1 -1
  41. package/dist/es/ui/ToggleRefinement.js +1 -1
  42. package/dist/es/ui/lib/index.d.ts +0 -1
  43. package/dist/es/ui/lib/index.js +0 -1
  44. package/dist/es/widgets/Hits.d.ts +11 -4
  45. package/dist/es/widgets/Hits.js +37 -8
  46. package/dist/umd/ReactInstantSearch.js +224 -109
  47. package/dist/umd/ReactInstantSearch.js.map +1 -1
  48. package/dist/umd/ReactInstantSearch.min.js +1 -1
  49. package/dist/umd/ReactInstantSearch.min.js.map +1 -1
  50. package/package.json +9 -8
  51. package/dist/cjs/ui/Hits.js +0 -49
  52. package/dist/cjs/ui/lib/cx.js +0 -12
  53. package/dist/es/ui/Hits.d.ts +0 -31
  54. package/dist/es/ui/Hits.js +0 -42
  55. package/dist/es/ui/lib/cx.d.ts +0 -1
  56. package/dist/es/ui/lib/cx.js +0 -6
@@ -2,8 +2,8 @@ var _excluded = ["formRef", "inputRef", "isSearchStalled", "onChange", "onReset"
2
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
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
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 { cx } from 'instantsearch-ui-components';
5
6
  import React from 'react';
6
- import { cx } from "./lib/cx.js";
7
7
  var _ref2 = /*#__PURE__*/React.createElement("path", {
8
8
  d: "M26.804 29.01c-2.832 2.34-6.465 3.746-10.426 3.746C7.333 32.756 0 25.424 0 16.378 0 7.333 7.333 0 16.378 0c9.046 0 16.378 7.333 16.378 16.378 0 3.96-1.406 7.594-3.746 10.426l10.534 10.534c.607.607.61 1.59-.004 2.202-.61.61-1.597.61-2.202.004L26.804 29.01zm-10.426.627c7.323 0 13.26-5.936 13.26-13.26 0-7.32-5.937-13.257-13.26-13.257C9.056 3.12 3.12 9.056 3.12 16.378c0 7.323 5.936 13.26 13.258 13.26z"
9
9
  });
@@ -141,9 +141,7 @@ export function SearchBox(_ref7) {
141
141
  }, /*#__PURE__*/React.createElement(ResetIcon, {
142
142
  classNames: classNames
143
143
  })), /*#__PURE__*/React.createElement("span", {
144
- className: cx('ais-SearchBox-loadingIndicator', classNames.loadingIndicator)
145
- // @ts-ignore (this error is due to conflict with @algolia/ui-components-highlight-vdom, which declares "too global" type for span in case there's no @types/react or preact)
146
- ,
144
+ className: cx('ais-SearchBox-loadingIndicator', classNames.loadingIndicator),
147
145
  hidden: !isSearchStalled
148
146
  }, /*#__PURE__*/React.createElement(LoadingIcon, {
149
147
  classNames: classNames
@@ -1,4 +1,4 @@
1
- import type { InternalHighlightProps, InternalHighlightClassNames } from './InternalHighlight';
1
+ import type { HighlightProps as InternalHighlightProps, HighlightClassNames as InternalHighlightClassNames } from 'instantsearch-ui-components';
2
2
  export type SnippetClassNames = InternalHighlightClassNames;
3
3
  export type SnippetProps = Omit<InternalHighlightProps, 'classNames'> & {
4
4
  classNames?: Partial<SnippetClassNames>;
@@ -2,9 +2,9 @@ var _excluded = ["classNames"];
2
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
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
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 { cx } from 'instantsearch-ui-components';
5
6
  import React from 'react';
6
7
  import { InternalHighlight } from "./InternalHighlight.js";
7
- import { cx } from "./lib/cx.js";
8
8
  export function Snippet(_ref) {
9
9
  var _ref$classNames = _ref.classNames,
10
10
  classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
@@ -2,8 +2,8 @@ var _excluded = ["items", "value", "onChange", "classNames"];
2
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
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
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 { cx } from 'instantsearch-ui-components';
5
6
  import React from 'react';
6
- import { cx } from "./lib/cx.js";
7
7
  export function SortBy(_ref) {
8
8
  var items = _ref.items,
9
9
  value = _ref.value,
@@ -2,8 +2,8 @@ var _excluded = ["classNames", "nbHits", "processingTimeMS", "nbSortedHits", "ar
2
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
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
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 { cx } from 'instantsearch-ui-components';
5
6
  import React from 'react';
6
- import { cx } from "./lib/cx.js";
7
7
  export function Stats(_ref) {
8
8
  var _ref$classNames = _ref.classNames,
9
9
  classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
@@ -2,8 +2,8 @@ var _excluded = ["classNames", "checked", "onChange", "label"];
2
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
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
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 { cx } from 'instantsearch-ui-components';
5
6
  import React from 'react';
6
- import { cx } from "./lib/cx.js";
7
7
  export function ToggleRefinement(_ref) {
8
8
  var _ref$classNames = _ref.classNames,
9
9
  classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
@@ -1,3 +1,2 @@
1
1
  export * from './capitalize';
2
- export * from './cx';
3
2
  export * from './isModifierClick';
@@ -1,3 +1,2 @@
1
1
  export * from "./capitalize.js";
2
- export * from "./cx.js";
3
2
  export * from "./isModifierClick.js";
@@ -1,7 +1,14 @@
1
- import type { HitsProps as HitsUiComponentProps } from '../ui/Hits';
1
+ import React from 'react';
2
+ import type { HitsProps as HitsUiComponentProps } from 'instantsearch-ui-components';
2
3
  import type { Hit, BaseHit } from 'instantsearch.js';
4
+ import type { SendEventForHits } from 'instantsearch.js/es/lib/utils';
3
5
  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;
6
+ type UiProps<THit extends BaseHit> = Pick<HitsUiComponentProps<Hit<THit>>, 'hits' | 'sendEvent' | 'itemComponent' | 'emptyComponent'>;
7
+ export type HitsProps<THit extends BaseHit> = Omit<HitsUiComponentProps<Hit<THit>>, keyof UiProps<THit>> & {
8
+ hitComponent?: React.JSXElementConstructor<{
9
+ hit: Hit<THit>;
10
+ sendEvent: SendEventForHits;
11
+ }>;
12
+ } & UseHitsProps<THit>;
13
+ export declare function Hits<THit extends BaseHit = BaseHit>({ escapeHTML, transformItems, hitComponent: HitComponent, ...props }: HitsProps<THit>): JSX.Element;
7
14
  export {};
@@ -1,14 +1,31 @@
1
- var _excluded = ["escapeHTML", "transformItems"];
1
+ var _excluded = ["escapeHTML", "transformItems", "hitComponent"],
2
+ _excluded2 = ["hit", "index"];
2
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); }
3
4
  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
5
  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 { createHitsComponent } from 'instantsearch-ui-components';
7
+ import React, { createElement, Fragment } from 'react';
6
8
  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);
9
+ // @MAJOR: Move default hit component back to the UI library
10
+ // once flavour specificities are erased
11
+ function DefaultHitComponent(_ref) {
12
+ var hit = _ref.hit;
13
+ return /*#__PURE__*/React.createElement("div", {
14
+ style: {
15
+ wordBreak: 'break-all'
16
+ }
17
+ }, JSON.stringify(hit).slice(0, 100), "\u2026");
18
+ }
19
+ var HitsUiComponent = createHitsComponent({
20
+ createElement: createElement,
21
+ Fragment: Fragment
22
+ });
23
+ export function Hits(_ref2) {
24
+ var escapeHTML = _ref2.escapeHTML,
25
+ transformItems = _ref2.transformItems,
26
+ _ref2$hitComponent = _ref2.hitComponent,
27
+ HitComponent = _ref2$hitComponent === void 0 ? DefaultHitComponent : _ref2$hitComponent,
28
+ props = _objectWithoutProperties(_ref2, _excluded);
12
29
  var _useHits = useHits({
13
30
  escapeHTML: escapeHTML,
14
31
  transformItems: transformItems
@@ -17,9 +34,21 @@ export function Hits(_ref) {
17
34
  }),
18
35
  hits = _useHits.hits,
19
36
  sendEvent = _useHits.sendEvent;
37
+ var itemComponent = function itemComponent(_ref3) {
38
+ var hit = _ref3.hit,
39
+ index = _ref3.index,
40
+ itemProps = _objectWithoutProperties(_ref3, _excluded2);
41
+ return /*#__PURE__*/React.createElement("li", _extends({
42
+ key: hit.objectID
43
+ }, itemProps), /*#__PURE__*/React.createElement(HitComponent, {
44
+ hit: hit,
45
+ sendEvent: sendEvent
46
+ }));
47
+ };
20
48
  var uiProps = {
21
49
  hits: hits,
22
- sendEvent: sendEvent
50
+ sendEvent: sendEvent,
51
+ itemComponent: itemComponent
23
52
  };
24
53
  return /*#__PURE__*/React.createElement(HitsUiComponent, _extends({}, props, uiProps));
25
54
  }