instantsearch.js 4.43.1 → 4.45.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 (58) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/cjs/components/Highlight/Highlight.js +33 -0
  3. package/cjs/components/InternalHighlight/InternalHighlight.js +16 -0
  4. package/cjs/components/ReverseHighlight/ReverseHighlight.js +33 -0
  5. package/cjs/components/ReverseSnippet/ReverseSnippet.js +33 -0
  6. package/cjs/components/Snippet/Snippet.js +33 -0
  7. package/cjs/connectors/hits-per-page/connectHitsPerPage.js +3 -1
  8. package/cjs/connectors/numeric-menu/connectNumericMenu.js +31 -43
  9. package/cjs/connectors/range/connectRange.js +7 -46
  10. package/cjs/connectors/rating-menu/connectRatingMenu.js +8 -2
  11. package/cjs/connectors/sort-by/connectSortBy.js +3 -1
  12. package/cjs/helpers/components/Highlight.js +45 -0
  13. package/cjs/helpers/components/ReverseHighlight.js +58 -0
  14. package/cjs/helpers/components/ReverseSnippet.js +58 -0
  15. package/cjs/helpers/components/Snippet.js +45 -0
  16. package/cjs/helpers/components/index.js +57 -0
  17. package/cjs/lib/version.js +1 -1
  18. package/dist/instantsearch.development.d.ts +29 -9
  19. package/dist/instantsearch.development.js +109 -120
  20. package/dist/instantsearch.development.js.map +1 -1
  21. package/dist/instantsearch.production.d.ts +29 -9
  22. package/dist/instantsearch.production.min.d.ts +29 -9
  23. package/dist/instantsearch.production.min.js +2 -2
  24. package/dist/instantsearch.production.min.js.map +1 -1
  25. package/es/components/Highlight/Highlight.d.ts +7 -0
  26. package/es/components/Highlight/Highlight.js +24 -0
  27. package/es/components/InternalHighlight/InternalHighlight.d.ts +2 -0
  28. package/es/components/InternalHighlight/InternalHighlight.js +6 -0
  29. package/es/components/ReverseHighlight/ReverseHighlight.d.ts +7 -0
  30. package/es/components/ReverseHighlight/ReverseHighlight.js +24 -0
  31. package/es/components/ReverseSnippet/ReverseSnippet.d.ts +7 -0
  32. package/es/components/ReverseSnippet/ReverseSnippet.js +24 -0
  33. package/es/components/Snippet/Snippet.d.ts +7 -0
  34. package/es/components/Snippet/Snippet.js +24 -0
  35. package/es/connectors/geo-search/connectGeoSearch.d.ts +10 -10
  36. package/es/connectors/hits-per-page/connectHitsPerPage.d.ts +5 -0
  37. package/es/connectors/hits-per-page/connectHitsPerPage.js +3 -1
  38. package/es/connectors/numeric-menu/connectNumericMenu.d.ts +8 -0
  39. package/es/connectors/numeric-menu/connectNumericMenu.js +32 -44
  40. package/es/connectors/range/connectRange.js +8 -47
  41. package/es/connectors/rating-menu/connectRatingMenu.d.ts +2 -0
  42. package/es/connectors/rating-menu/connectRatingMenu.js +8 -2
  43. package/es/connectors/sort-by/connectSortBy.d.ts +5 -0
  44. package/es/connectors/sort-by/connectSortBy.js +3 -1
  45. package/es/helpers/components/Highlight.d.ts +10 -0
  46. package/es/helpers/components/Highlight.js +31 -0
  47. package/es/helpers/components/ReverseHighlight.d.ts +10 -0
  48. package/es/helpers/components/ReverseHighlight.js +44 -0
  49. package/es/helpers/components/ReverseSnippet.d.ts +10 -0
  50. package/es/helpers/components/ReverseSnippet.js +44 -0
  51. package/es/helpers/components/Snippet.d.ts +10 -0
  52. package/es/helpers/components/Snippet.js +31 -0
  53. package/es/helpers/components/index.d.ts +4 -0
  54. package/es/helpers/components/index.js +4 -0
  55. package/es/lib/version.d.ts +1 -1
  56. package/es/lib/version.js +1 -1
  57. package/es/types/utils.d.ts +4 -0
  58. package/package.json +6 -3
@@ -0,0 +1,44 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+
7
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+
11
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
+
13
+ /** @jsx h */
14
+ import { h } from 'preact';
15
+ import { ReverseHighlight as ReverseHighlightUiComponent } from "../../components/ReverseHighlight/ReverseHighlight.js";
16
+ import getHighlightedParts from "../../lib/utils/getHighlightedParts.js";
17
+ import getPropertyByPath from "../../lib/utils/getPropertyByPath.js";
18
+ import unescape from "../../lib/utils/unescape.js";
19
+ import { warning } from "../../lib/utils/logger.js";
20
+ export function ReverseHighlight(_ref) {
21
+ var hit = _ref.hit,
22
+ attribute = _ref.attribute,
23
+ cssClasses = _ref.cssClasses,
24
+ props = _objectWithoutProperties(_ref, ["hit", "attribute", "cssClasses"]);
25
+
26
+ var property = getPropertyByPath(hit._highlightResult, attribute) || [];
27
+ var properties = Array.isArray(property) ? property : [property];
28
+ process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable highlight for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
29
+ var parts = properties.map(function (_ref2) {
30
+ var value = _ref2.value;
31
+ return getHighlightedParts(unescape(value || '')).map(function (_ref3) {
32
+ var isHighlighted = _ref3.isHighlighted,
33
+ rest = _objectWithoutProperties(_ref3, ["isHighlighted"]);
34
+
35
+ return _objectSpread(_objectSpread({}, rest), {}, {
36
+ isHighlighted: !isHighlighted
37
+ });
38
+ });
39
+ });
40
+ return h(ReverseHighlightUiComponent, _extends({}, props, {
41
+ parts: parts,
42
+ classNames: cssClasses
43
+ }));
44
+ }
@@ -0,0 +1,10 @@
1
+ /** @jsx h */
2
+ import { h } from 'preact';
3
+ import type { BaseHit, Hit, PartialKeys } from '../../types';
4
+ import type { ReverseSnippetProps as ReverseSnippetUiComponentProps } from '../../components/ReverseSnippet/ReverseSnippet';
5
+ export declare type ReverseSnippetProps<THit extends Hit<BaseHit>> = {
6
+ hit: THit;
7
+ attribute: keyof THit | string[];
8
+ cssClasses?: ReverseSnippetUiComponentProps['classNames'];
9
+ } & PartialKeys<Omit<ReverseSnippetUiComponentProps, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
10
+ export declare function ReverseSnippet<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: ReverseSnippetProps<THit>): h.JSX.Element;
@@ -0,0 +1,44 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+
7
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+
11
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
+
13
+ /** @jsx h */
14
+ import { h } from 'preact';
15
+ import { ReverseSnippet as ReverseSnippetUiComponent } from "../../components/ReverseSnippet/ReverseSnippet.js";
16
+ import getHighlightedParts from "../../lib/utils/getHighlightedParts.js";
17
+ import getPropertyByPath from "../../lib/utils/getPropertyByPath.js";
18
+ import unescape from "../../lib/utils/unescape.js";
19
+ import { warning } from "../../lib/utils/logger.js";
20
+ export function ReverseSnippet(_ref) {
21
+ var hit = _ref.hit,
22
+ attribute = _ref.attribute,
23
+ cssClasses = _ref.cssClasses,
24
+ props = _objectWithoutProperties(_ref, ["hit", "attribute", "cssClasses"]);
25
+
26
+ var property = getPropertyByPath(hit._snippetResult, attribute) || [];
27
+ var properties = Array.isArray(property) ? property : [property];
28
+ process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
29
+ var parts = properties.map(function (_ref2) {
30
+ var value = _ref2.value;
31
+ return getHighlightedParts(unescape(value || '')).map(function (_ref3) {
32
+ var isHighlighted = _ref3.isHighlighted,
33
+ rest = _objectWithoutProperties(_ref3, ["isHighlighted"]);
34
+
35
+ return _objectSpread(_objectSpread({}, rest), {}, {
36
+ isHighlighted: !isHighlighted
37
+ });
38
+ });
39
+ });
40
+ return h(ReverseSnippetUiComponent, _extends({}, props, {
41
+ parts: parts,
42
+ classNames: cssClasses
43
+ }));
44
+ }
@@ -0,0 +1,10 @@
1
+ /** @jsx h */
2
+ import { h } from 'preact';
3
+ import type { BaseHit, Hit, PartialKeys } from '../../types';
4
+ import type { SnippetProps as SnippetUiComponentProps } from '../../components/Snippet/Snippet';
5
+ export declare type SnippetProps<THit extends Hit<BaseHit>> = {
6
+ hit: THit;
7
+ attribute: keyof THit | string[];
8
+ cssClasses?: SnippetUiComponentProps['classNames'];
9
+ } & PartialKeys<Omit<SnippetUiComponentProps, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
10
+ export declare function Snippet<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: SnippetProps<THit>): h.JSX.Element;
@@ -0,0 +1,31 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ 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; }
6
+
7
+ /** @jsx h */
8
+ import { h } from 'preact';
9
+ import { Snippet as SnippetUiComponent } from "../../components/Snippet/Snippet.js";
10
+ import getHighlightedParts from "../../lib/utils/getHighlightedParts.js";
11
+ import getPropertyByPath from "../../lib/utils/getPropertyByPath.js";
12
+ import unescape from "../../lib/utils/unescape.js";
13
+ import { warning } from "../../lib/utils/logger.js";
14
+ export function Snippet(_ref) {
15
+ var hit = _ref.hit,
16
+ attribute = _ref.attribute,
17
+ cssClasses = _ref.cssClasses,
18
+ props = _objectWithoutProperties(_ref, ["hit", "attribute", "cssClasses"]);
19
+
20
+ var property = getPropertyByPath(hit._snippetResult, attribute) || [];
21
+ var properties = Array.isArray(property) ? property : [property];
22
+ process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
23
+ var parts = properties.map(function (_ref2) {
24
+ var value = _ref2.value;
25
+ return getHighlightedParts(unescape(value || ''));
26
+ });
27
+ return h(SnippetUiComponent, _extends({}, props, {
28
+ parts: parts,
29
+ classNames: cssClasses
30
+ }));
31
+ }
@@ -0,0 +1,4 @@
1
+ export * from './Highlight';
2
+ export * from './ReverseHighlight';
3
+ export * from './ReverseSnippet';
4
+ export * from './Snippet';
@@ -0,0 +1,4 @@
1
+ export * from "./Highlight.js";
2
+ export * from "./ReverseHighlight.js";
3
+ export * from "./ReverseSnippet.js";
4
+ export * from "./Snippet.js";
@@ -1,2 +1,2 @@
1
- declare const _default: "4.43.1";
1
+ declare const _default: "4.45.0";
2
2
  export default _default;
package/es/lib/version.js CHANGED
@@ -1 +1 @@
1
- export default '4.43.1';
1
+ export default '4.45.0';
@@ -10,3 +10,7 @@ export declare type Expand<T> = T extends infer O ? {
10
10
  } : never;
11
11
  export declare type RequiredKeys<TObject, TKeys extends keyof TObject> = Expand<Required<Pick<TObject, TKeys>> & Omit<TObject, TKeys>>;
12
12
  export declare type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T;
13
+ /**
14
+ * Make certain keys of an object optional.
15
+ */
16
+ export declare type PartialKeys<TObj, TKeys extends keyof TObj> = Omit<TObj, TKeys> & Partial<Pick<TObj, TKeys>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instantsearch.js",
3
- "version": "4.43.1",
3
+ "version": "4.45.0",
4
4
  "description": "InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia.",
5
5
  "homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/",
6
6
  "types": "es/index.d.ts",
@@ -54,12 +54,15 @@
54
54
  ],
55
55
  "dependencies": {
56
56
  "@algolia/events": "^4.0.1",
57
+ "@algolia/ui-components-highlight-vdom": "^1.1.2",
58
+ "@algolia/ui-components-shared": "^1.1.2",
57
59
  "@types/google.maps": "^3.45.3",
58
60
  "@types/hogan.js": "^3.0.0",
59
61
  "@types/qs": "^6.5.3",
60
62
  "algoliasearch-helper": "^3.10.0",
61
63
  "classnames": "^2.2.5",
62
64
  "hogan.js": "^3.0.2",
65
+ "htm": "^3.0.0",
63
66
  "preact": "^10.6.0",
64
67
  "qs": "^6.5.1 < 6.10",
65
68
  "search-insights": "^2.1.0"
@@ -154,11 +157,11 @@
154
157
  "bundlesize": [
155
158
  {
156
159
  "path": "./dist/instantsearch.production.min.js",
157
- "maxSize": "70.25 kB"
160
+ "maxSize": "70.50 kB"
158
161
  },
159
162
  {
160
163
  "path": "./dist/instantsearch.development.js",
161
- "maxSize": "155.00 kB"
164
+ "maxSize": "152.00 kB"
162
165
  }
163
166
  ]
164
167
  }