instantsearch.js 4.43.1 → 4.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/cjs/components/Highlight/Highlight.js +33 -0
- package/cjs/components/InternalHighlight/InternalHighlight.js +16 -0
- package/cjs/components/ReverseHighlight/ReverseHighlight.js +33 -0
- package/cjs/components/ReverseSnippet/ReverseSnippet.js +33 -0
- package/cjs/components/Snippet/Snippet.js +33 -0
- package/cjs/helpers/components/Highlight.js +45 -0
- package/cjs/helpers/components/ReverseHighlight.js +58 -0
- package/cjs/helpers/components/ReverseSnippet.js +58 -0
- package/cjs/helpers/components/Snippet.js +45 -0
- package/cjs/helpers/components/index.js +57 -0
- package/cjs/lib/version.js +1 -1
- package/dist/instantsearch.development.d.ts +9 -9
- package/dist/instantsearch.development.js +2 -2
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +9 -9
- package/dist/instantsearch.production.min.d.ts +9 -9
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Highlight/Highlight.d.ts +7 -0
- package/es/components/Highlight/Highlight.js +24 -0
- package/es/components/InternalHighlight/InternalHighlight.d.ts +2 -0
- package/es/components/InternalHighlight/InternalHighlight.js +6 -0
- package/es/components/ReverseHighlight/ReverseHighlight.d.ts +7 -0
- package/es/components/ReverseHighlight/ReverseHighlight.js +24 -0
- package/es/components/ReverseSnippet/ReverseSnippet.d.ts +7 -0
- package/es/components/ReverseSnippet/ReverseSnippet.js +24 -0
- package/es/components/Snippet/Snippet.d.ts +7 -0
- package/es/components/Snippet/Snippet.js +24 -0
- package/es/connectors/geo-search/connectGeoSearch.d.ts +10 -10
- package/es/helpers/components/Highlight.d.ts +10 -0
- package/es/helpers/components/Highlight.js +31 -0
- package/es/helpers/components/ReverseHighlight.d.ts +10 -0
- package/es/helpers/components/ReverseHighlight.js +44 -0
- package/es/helpers/components/ReverseSnippet.d.ts +10 -0
- package/es/helpers/components/ReverseSnippet.js +44 -0
- package/es/helpers/components/Snippet.d.ts +10 -0
- package/es/helpers/components/Snippet.js +31 -0
- package/es/helpers/components/index.d.ts +4 -0
- package/es/helpers/components/index.js +4 -0
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/types/utils.d.ts +4 -0
- package/package.json +4 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { h } from 'preact';
|
|
2
|
+
import type { HighlightProps as InternalHighlightProps, HighlightClassNames as InternalHighlightClassNames } from '@algolia/ui-components-highlight-vdom';
|
|
3
|
+
export declare type HighlightClassNames = InternalHighlightClassNames;
|
|
4
|
+
export declare type HighlightProps = Omit<InternalHighlightProps, 'classNames'> & {
|
|
5
|
+
classNames?: Partial<HighlightClassNames>;
|
|
6
|
+
};
|
|
7
|
+
export declare function Highlight({ classNames, ...props }: HighlightProps): h.JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { cx } from '@algolia/ui-components-shared';
|
|
9
|
+
import { h } from 'preact';
|
|
10
|
+
import { InternalHighlight } from "../InternalHighlight/InternalHighlight.js";
|
|
11
|
+
export function Highlight(_ref) {
|
|
12
|
+
var _ref$classNames = _ref.classNames,
|
|
13
|
+
classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
|
|
14
|
+
props = _objectWithoutProperties(_ref, ["classNames"]);
|
|
15
|
+
|
|
16
|
+
return h(InternalHighlight, _extends({
|
|
17
|
+
classNames: {
|
|
18
|
+
root: cx('ais-Highlight', classNames.root),
|
|
19
|
+
highlighted: cx('ais-Highlight-highlighted', classNames.highlighted),
|
|
20
|
+
nonHighlighted: cx('ais-Highlight-nonHighlighted', classNames.nonHighlighted),
|
|
21
|
+
separator: cx('ais-Highlight-separator', classNames.separator)
|
|
22
|
+
}
|
|
23
|
+
}, props));
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { h } from 'preact';
|
|
2
|
+
import type { HighlightProps as InternalHighlightProps, HighlightClassNames as InternalHighlightClassNames } from '@algolia/ui-components-highlight-vdom';
|
|
3
|
+
export declare type ReverseHighlightClassNames = InternalHighlightClassNames;
|
|
4
|
+
export declare type ReverseHighlightProps = Omit<InternalHighlightProps, 'classNames'> & {
|
|
5
|
+
classNames?: Partial<ReverseHighlightClassNames>;
|
|
6
|
+
};
|
|
7
|
+
export declare function ReverseHighlight({ classNames, ...props }: ReverseHighlightProps): h.JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { cx } from '@algolia/ui-components-shared';
|
|
9
|
+
import { h } from 'preact';
|
|
10
|
+
import { InternalHighlight } from "../InternalHighlight/InternalHighlight.js";
|
|
11
|
+
export function ReverseHighlight(_ref) {
|
|
12
|
+
var _ref$classNames = _ref.classNames,
|
|
13
|
+
classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
|
|
14
|
+
props = _objectWithoutProperties(_ref, ["classNames"]);
|
|
15
|
+
|
|
16
|
+
return h(InternalHighlight, _extends({
|
|
17
|
+
classNames: {
|
|
18
|
+
root: cx('ais-ReverseHighlight', classNames.root),
|
|
19
|
+
highlighted: cx('ais-ReverseHighlight-highlighted', classNames.highlighted),
|
|
20
|
+
nonHighlighted: cx('ais-ReverseHighlight-nonHighlighted', classNames.nonHighlighted),
|
|
21
|
+
separator: cx('ais-ReverseHighlight-separator', classNames.separator)
|
|
22
|
+
}
|
|
23
|
+
}, props));
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { h } from 'preact';
|
|
2
|
+
import type { HighlightProps as InternalHighlightProps, HighlightClassNames as InternalHighlightClassNames } from '@algolia/ui-components-highlight-vdom';
|
|
3
|
+
export declare type ReverseSnippetClassNames = InternalHighlightClassNames;
|
|
4
|
+
export declare type ReverseSnippetProps = Omit<InternalHighlightProps, 'classNames'> & {
|
|
5
|
+
classNames?: Partial<ReverseSnippetClassNames>;
|
|
6
|
+
};
|
|
7
|
+
export declare function ReverseSnippet({ classNames, ...props }: ReverseSnippetProps): h.JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { cx } from '@algolia/ui-components-shared';
|
|
9
|
+
import { h } from 'preact';
|
|
10
|
+
import { InternalHighlight } from "../InternalHighlight/InternalHighlight.js";
|
|
11
|
+
export function ReverseSnippet(_ref) {
|
|
12
|
+
var _ref$classNames = _ref.classNames,
|
|
13
|
+
classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
|
|
14
|
+
props = _objectWithoutProperties(_ref, ["classNames"]);
|
|
15
|
+
|
|
16
|
+
return h(InternalHighlight, _extends({
|
|
17
|
+
classNames: {
|
|
18
|
+
root: cx('ais-ReverseSnippet', classNames.root),
|
|
19
|
+
highlighted: cx('ais-ReverseSnippet-highlighted', classNames.highlighted),
|
|
20
|
+
nonHighlighted: cx('ais-ReverseSnippet-nonHighlighted', classNames.nonHighlighted),
|
|
21
|
+
separator: cx('ais-ReverseSnippet-separator', classNames.separator)
|
|
22
|
+
}
|
|
23
|
+
}, props));
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { h } from 'preact';
|
|
2
|
+
import type { HighlightProps as InternalHighlightProps, HighlightClassNames as InternalHighlightClassNames } from '@algolia/ui-components-highlight-vdom';
|
|
3
|
+
export declare type SnippetClassNames = InternalHighlightClassNames;
|
|
4
|
+
export declare type SnippetProps = Omit<InternalHighlightProps, 'classNames'> & {
|
|
5
|
+
classNames?: Partial<SnippetClassNames>;
|
|
6
|
+
};
|
|
7
|
+
export declare function Snippet({ classNames, ...props }: SnippetProps): h.JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { cx } from '@algolia/ui-components-shared';
|
|
9
|
+
import { h } from 'preact';
|
|
10
|
+
import { InternalHighlight } from "../InternalHighlight/InternalHighlight.js";
|
|
11
|
+
export function Snippet(_ref) {
|
|
12
|
+
var _ref$classNames = _ref.classNames,
|
|
13
|
+
classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
|
|
14
|
+
props = _objectWithoutProperties(_ref, ["classNames"]);
|
|
15
|
+
|
|
16
|
+
return h(InternalHighlight, _extends({
|
|
17
|
+
classNames: {
|
|
18
|
+
root: cx('ais-Snippet', classNames.root),
|
|
19
|
+
highlighted: cx('ais-Snippet-highlighted', classNames.highlighted),
|
|
20
|
+
nonHighlighted: cx('ais-Snippet-nonHighlighted', classNames.nonHighlighted),
|
|
21
|
+
separator: cx('ais-Snippet-separator', classNames.separator)
|
|
22
|
+
}
|
|
23
|
+
}, props));
|
|
24
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SendEventForHits } from '../../lib/utils';
|
|
2
|
-
import type { Connector, GeoLoc, Hit, TransformItems, WidgetRenderState } from '../../types';
|
|
3
|
-
export declare type GeoHit = Hit & Required<Pick<Hit, '_geoloc'>>;
|
|
2
|
+
import type { BaseHit, Connector, GeoLoc, Hit, TransformItems, WidgetRenderState } from '../../types';
|
|
3
|
+
export declare type GeoHit<THit extends BaseHit = Record<string, any>> = Hit<THit> & Required<Pick<Hit, '_geoloc'>>;
|
|
4
4
|
declare type Bounds = {
|
|
5
5
|
/**
|
|
6
6
|
* The top right corner of the map view.
|
|
@@ -11,7 +11,7 @@ declare type Bounds = {
|
|
|
11
11
|
*/
|
|
12
12
|
southWest: GeoLoc;
|
|
13
13
|
};
|
|
14
|
-
export declare type GeoSearchRenderState = {
|
|
14
|
+
export declare type GeoSearchRenderState<THit extends BaseHit = Record<string, any>> = {
|
|
15
15
|
/**
|
|
16
16
|
* Reset the current bounding box refinement.
|
|
17
17
|
*/
|
|
@@ -35,7 +35,7 @@ export declare type GeoSearchRenderState = {
|
|
|
35
35
|
/**
|
|
36
36
|
* The matched hits from Algolia API.
|
|
37
37
|
*/
|
|
38
|
-
items: GeoHit
|
|
38
|
+
items: Array<GeoHit<THit>>;
|
|
39
39
|
/**
|
|
40
40
|
* The current position of the search.
|
|
41
41
|
*/
|
|
@@ -59,7 +59,7 @@ export declare type GeoSearchRenderState = {
|
|
|
59
59
|
*/
|
|
60
60
|
toggleRefineOnMapMove(): void;
|
|
61
61
|
};
|
|
62
|
-
export declare type GeoSearchConnectorParams = {
|
|
62
|
+
export declare type GeoSearchConnectorParams<THit extends BaseHit = Record<string, any>> = {
|
|
63
63
|
/**
|
|
64
64
|
* If true, refine will be triggered as you move the map.
|
|
65
65
|
* @default true
|
|
@@ -69,13 +69,13 @@ export declare type GeoSearchConnectorParams = {
|
|
|
69
69
|
* Function to transform the items passed to the templates.
|
|
70
70
|
* @default items => items
|
|
71
71
|
*/
|
|
72
|
-
transformItems?: TransformItems<GeoHit
|
|
72
|
+
transformItems?: TransformItems<GeoHit<THit>>;
|
|
73
73
|
};
|
|
74
|
-
export declare type GeoSearchWidgetDescription = {
|
|
74
|
+
export declare type GeoSearchWidgetDescription<THit extends BaseHit = Record<string, any>> = {
|
|
75
75
|
$$type: 'ais.geoSearch';
|
|
76
|
-
renderState: GeoSearchRenderState
|
|
76
|
+
renderState: GeoSearchRenderState<THit>;
|
|
77
77
|
indexRenderState: {
|
|
78
|
-
geoSearch: WidgetRenderState<GeoSearchRenderState
|
|
78
|
+
geoSearch: WidgetRenderState<GeoSearchRenderState<THit>, GeoSearchConnectorParams<THit>>;
|
|
79
79
|
};
|
|
80
80
|
indexUiState: {
|
|
81
81
|
geoSearch: {
|
|
@@ -90,7 +90,7 @@ export declare type GeoSearchWidgetDescription = {
|
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
-
export declare type GeoSearchConnector = Connector<GeoSearchWidgetDescription
|
|
93
|
+
export declare type GeoSearchConnector<THit extends BaseHit = Record<string, any>> = Connector<GeoSearchWidgetDescription<THit>, GeoSearchConnectorParams<THit>>;
|
|
94
94
|
/**
|
|
95
95
|
* The **GeoSearch** connector provides the logic to build a widget that will display the results on a map. It also provides a way to search for results based on their position. The connector provides functions to manage the search experience (search on map interaction or control the interaction for example).
|
|
96
96
|
*
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsx h */
|
|
2
|
+
import { h } from 'preact';
|
|
3
|
+
import type { BaseHit, Hit, PartialKeys } from '../../types';
|
|
4
|
+
import type { HighlightProps as HighlightUiComponentProps } from '../../components/Highlight/Highlight';
|
|
5
|
+
export declare type HighlightProps<THit extends Hit<BaseHit>> = {
|
|
6
|
+
hit: THit;
|
|
7
|
+
attribute: keyof THit | string[];
|
|
8
|
+
cssClasses?: HighlightUiComponentProps['classNames'];
|
|
9
|
+
} & PartialKeys<Omit<HighlightUiComponentProps, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
|
|
10
|
+
export declare function Highlight<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: HighlightProps<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 { Highlight as HighlightUiComponent } from "../../components/Highlight/Highlight.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 Highlight(_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._highlightResult, attribute) || [];
|
|
21
|
+
var properties = Array.isArray(property) ? property : [property];
|
|
22
|
+
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;
|
|
23
|
+
var parts = properties.map(function (_ref2) {
|
|
24
|
+
var value = _ref2.value;
|
|
25
|
+
return getHighlightedParts(unescape(value || ''));
|
|
26
|
+
});
|
|
27
|
+
return h(HighlightUiComponent, _extends({}, props, {
|
|
28
|
+
parts: parts,
|
|
29
|
+
classNames: cssClasses
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsx h */
|
|
2
|
+
import { h } from 'preact';
|
|
3
|
+
import type { BaseHit, Hit, PartialKeys } from '../../types';
|
|
4
|
+
import type { ReverseHighlightProps as ReverseHighlightUiComponentProps } from '../../components/ReverseHighlight/ReverseHighlight';
|
|
5
|
+
export declare type ReverseHighlightProps<THit extends Hit<BaseHit>> = {
|
|
6
|
+
hit: THit;
|
|
7
|
+
attribute: keyof THit | string[];
|
|
8
|
+
cssClasses?: ReverseHighlightUiComponentProps['classNames'];
|
|
9
|
+
} & PartialKeys<Omit<ReverseHighlightUiComponentProps, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
|
|
10
|
+
export declare function ReverseHighlight<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: ReverseHighlightProps<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 { 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
|
+
}
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.
|
|
1
|
+
declare const _default: "4.44.0";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.
|
|
1
|
+
export default '4.44.0';
|
package/es/types/utils.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "4.44.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"
|