instantsearch.js 4.45.1 → 4.46.1
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 +21 -0
- package/cjs/components/Hits/Hits.js +3 -1
- package/cjs/components/InfiniteHits/InfiniteHits.js +3 -1
- package/cjs/components/Template/Template.js +13 -3
- package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
- package/cjs/helpers/components/Highlight.js +7 -7
- package/cjs/helpers/components/ReverseHighlight.js +7 -7
- package/cjs/helpers/components/ReverseSnippet.js +7 -7
- package/cjs/helpers/components/Snippet.js +7 -7
- package/cjs/lib/InstantSearch.js +33 -24
- package/cjs/lib/createHelpers.js +3 -1
- package/cjs/lib/formatNumber.js +10 -0
- package/cjs/lib/utils/capitalize.js +2 -5
- package/cjs/lib/utils/checkIndexUiState.js +3 -5
- package/cjs/lib/utils/checkRendering.js +4 -9
- package/cjs/lib/utils/clearRefinements.js +3 -9
- package/cjs/lib/utils/concatHighlightedParts.js +1 -1
- package/cjs/lib/utils/createSendEventForFacet.js +2 -4
- package/cjs/lib/utils/cx.js +10 -0
- package/cjs/lib/utils/defer.js +3 -6
- package/cjs/lib/utils/detect-insights-client.js +1 -1
- package/cjs/lib/utils/documentation.js +6 -9
- package/cjs/lib/utils/escape-highlight.js +4 -6
- package/cjs/lib/utils/escape-html.js +60 -0
- package/cjs/lib/utils/find.js +2 -5
- package/cjs/lib/utils/findIndex.js +2 -5
- package/cjs/lib/utils/getContainerNode.js +4 -9
- package/cjs/lib/utils/getHighlightFromSiblings.js +3 -5
- package/cjs/lib/utils/getHighlightedParts.js +1 -1
- package/cjs/lib/utils/getObjectType.js +2 -5
- package/cjs/lib/utils/getPropertyByPath.js +2 -5
- package/cjs/lib/utils/getRefinements.js +4 -6
- package/cjs/lib/utils/index.js +563 -432
- package/cjs/lib/utils/isDomElement.js +2 -5
- package/cjs/lib/utils/isEqual.js +2 -5
- package/cjs/lib/utils/isFacetRefined.js +1 -1
- package/cjs/lib/utils/isFiniteNumber.js +3 -5
- package/cjs/lib/utils/isIndexWidget.js +10 -0
- package/cjs/lib/utils/isPlainObject.js +2 -5
- package/cjs/lib/utils/isSpecialClick.js +2 -5
- package/cjs/lib/utils/logger.js +3 -5
- package/cjs/lib/utils/mergeSearchParameters.js +7 -10
- package/cjs/lib/utils/noop.js +2 -5
- package/cjs/lib/utils/prepareTemplateProps.js +4 -9
- package/cjs/lib/utils/range.js +2 -5
- package/cjs/lib/utils/renderTemplate.js +19 -7
- package/cjs/lib/utils/resolveSearchParameters.js +3 -6
- package/cjs/lib/utils/reverseHighlightedParts.js +3 -5
- package/cjs/lib/utils/setIndexHelperState.js +28 -0
- package/cjs/lib/utils/toArray.js +2 -5
- package/cjs/lib/utils/uniq.js +2 -5
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +23 -30
- package/cjs/middlewares/createMetadataMiddleware.js +1 -0
- package/cjs/middlewares/createRouterMiddleware.js +1 -0
- package/cjs/widgets/answers/defaultTemplates.js +6 -2
- package/cjs/widgets/breadcrumb/defaultTemplates.js +6 -2
- package/cjs/widgets/clear-refinements/defaultTemplates.js +3 -1
- package/cjs/widgets/geo-search/createHTMLMarker.js +10 -4
- package/cjs/widgets/geo-search/defaultTemplates.js +18 -4
- package/cjs/widgets/hierarchical-menu/defaultTemplates.js +26 -2
- package/cjs/widgets/hits/defaultTemplates.js +3 -1
- package/cjs/widgets/index/index.js +8 -12
- package/cjs/widgets/infinite-hits/defaultTemplates.js +9 -3
- package/cjs/widgets/menu/defaultTemplates.js +26 -2
- package/cjs/widgets/menu-select/defaultTemplates.js +11 -2
- package/cjs/widgets/numeric-menu/defaultTemplates.js +20 -1
- package/cjs/widgets/range-input/range-input.js +6 -2
- package/cjs/widgets/rating-menu/defaultTemplates.js +57 -1
- package/cjs/widgets/refinement-list/defaultTemplates.js +38 -3
- package/cjs/widgets/relevant-sort/defaultTemplates.js +3 -1
- package/cjs/widgets/search-box/defaultTemplates.js +62 -3
- package/cjs/widgets/stats/stats.js +70 -22
- package/cjs/widgets/toggle-refinement/defaultTemplates.js +4 -1
- package/cjs/widgets/voice-search/defaultTemplates.js +81 -9
- package/dist/instantsearch.development.d.ts +153 -22
- package/dist/instantsearch.development.js +2842 -2112
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +153 -22
- package/dist/instantsearch.production.min.d.ts +153 -22
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/es/components/ClearRefinements/ClearRefinements.d.ts +1 -1
- package/es/components/GeoSearchControls/GeoSearchControls.d.ts +1 -1
- package/es/components/Hits/Hits.d.ts +2 -3
- package/es/components/Hits/Hits.js +3 -1
- package/es/components/InfiniteHits/InfiniteHits.d.ts +1 -1
- package/es/components/InfiniteHits/InfiniteHits.js +3 -1
- package/es/components/RefinementList/RefinementList.d.ts +1 -1
- package/es/components/Template/Template.d.ts +4 -3
- package/es/components/Template/Template.js +14 -4
- package/es/components/ToggleRefinement/ToggleRefinement.d.ts +1 -4
- package/es/components/ToggleRefinement/ToggleRefinement.js +0 -4
- package/es/connectors/toggle-refinement/connectToggleRefinement.d.ts +3 -2
- package/es/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
- package/es/helpers/components/Highlight.js +7 -5
- package/es/helpers/components/ReverseHighlight.js +7 -5
- package/es/helpers/components/ReverseSnippet.js +7 -5
- package/es/helpers/components/Snippet.js +7 -5
- package/es/lib/InstantSearch.d.ts +6 -1
- package/es/lib/InstantSearch.js +34 -21
- package/es/lib/createHelpers.js +2 -1
- package/es/lib/formatNumber.d.ts +1 -0
- package/es/lib/formatNumber.js +3 -0
- package/es/lib/utils/capitalize.d.ts +1 -2
- package/es/lib/utils/capitalize.js +2 -4
- package/es/lib/utils/checkIndexUiState.js +1 -1
- package/es/lib/utils/checkRendering.d.ts +1 -2
- package/es/lib/utils/checkRendering.js +3 -6
- package/es/lib/utils/clearRefinements.d.ts +4 -8
- package/es/lib/utils/clearRefinements.js +3 -8
- package/es/lib/utils/concatHighlightedParts.d.ts +1 -1
- package/es/lib/utils/concatHighlightedParts.js +1 -1
- package/es/lib/utils/createSendEventForFacet.js +1 -1
- package/es/lib/utils/createSendEventForHits.d.ts +0 -3
- package/es/lib/utils/createSendEventForHits.js +0 -3
- package/es/lib/utils/cx.d.ts +1 -0
- package/es/lib/utils/cx.js +3 -0
- package/es/lib/utils/defer.d.ts +2 -2
- package/es/lib/utils/defer.js +2 -5
- package/es/lib/utils/detect-insights-client.d.ts +1 -1
- package/es/lib/utils/detect-insights-client.js +1 -1
- package/es/lib/utils/documentation.d.ts +2 -2
- package/es/lib/utils/documentation.js +4 -4
- package/es/lib/utils/escape-highlight.js +2 -2
- package/es/lib/utils/{escape.d.ts → escape-html.d.ts} +6 -2
- package/es/lib/utils/escape-html.js +51 -0
- package/es/lib/utils/escapeFacetValue.d.ts +1 -1
- package/es/lib/utils/find.d.ts +1 -2
- package/es/lib/utils/find.js +2 -4
- package/es/lib/utils/findIndex.d.ts +1 -2
- package/es/lib/utils/findIndex.js +2 -4
- package/es/lib/utils/getContainerNode.d.ts +1 -2
- package/es/lib/utils/getContainerNode.js +3 -5
- package/es/lib/utils/getHighlightFromSiblings.d.ts +1 -1
- package/es/lib/utils/getHighlightFromSiblings.js +2 -2
- package/es/lib/utils/getHighlightedParts.d.ts +1 -1
- package/es/lib/utils/getHighlightedParts.js +1 -1
- package/es/lib/utils/getObjectType.d.ts +1 -2
- package/es/lib/utils/getObjectType.js +2 -4
- package/es/lib/utils/getPropertyByPath.d.ts +1 -2
- package/es/lib/utils/getPropertyByPath.js +2 -4
- package/es/lib/utils/getRefinements.d.ts +1 -1
- package/es/lib/utils/getRefinements.js +2 -2
- package/es/lib/utils/index.d.ts +46 -45
- package/es/lib/utils/index.js +46 -45
- package/es/lib/utils/isDomElement.d.ts +1 -2
- package/es/lib/utils/isDomElement.js +2 -4
- package/es/lib/utils/isEqual.d.ts +1 -2
- package/es/lib/utils/isEqual.js +2 -4
- package/es/lib/utils/isFacetRefined.d.ts +1 -1
- package/es/lib/utils/isFacetRefined.js +1 -1
- package/es/lib/utils/isFiniteNumber.d.ts +1 -2
- package/es/lib/utils/isFiniteNumber.js +3 -4
- package/es/lib/utils/isIndexWidget.d.ts +3 -0
- package/es/lib/utils/isIndexWidget.js +3 -0
- package/es/lib/utils/isPlainObject.d.ts +1 -2
- package/es/lib/utils/isPlainObject.js +2 -4
- package/es/lib/utils/isSpecialClick.d.ts +1 -2
- package/es/lib/utils/isSpecialClick.js +2 -4
- package/es/lib/utils/logger.js +1 -1
- package/es/lib/utils/mergeSearchParameters.d.ts +1 -2
- package/es/lib/utils/mergeSearchParameters.js +4 -6
- package/es/lib/utils/noop.d.ts +1 -2
- package/es/lib/utils/noop.js +1 -3
- package/es/lib/utils/prepareTemplateProps.d.ts +2 -2
- package/es/lib/utils/prepareTemplateProps.js +3 -5
- package/es/lib/utils/range.d.ts +2 -2
- package/es/lib/utils/range.js +2 -4
- package/es/lib/utils/renderTemplate.d.ts +4 -4
- package/es/lib/utils/renderTemplate.js +17 -6
- package/es/lib/utils/resolveSearchParameters.d.ts +1 -2
- package/es/lib/utils/resolveSearchParameters.js +2 -4
- package/es/lib/utils/reverseHighlightedParts.d.ts +1 -1
- package/es/lib/utils/reverseHighlightedParts.js +2 -2
- package/es/lib/utils/setIndexHelperState.d.ts +3 -0
- package/es/lib/utils/setIndexHelperState.js +19 -0
- package/es/lib/utils/toArray.d.ts +3 -2
- package/es/lib/utils/toArray.js +2 -4
- package/es/lib/utils/uniq.d.ts +1 -2
- package/es/lib/utils/uniq.js +2 -4
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.js +23 -27
- package/es/middlewares/createMetadataMiddleware.js +1 -0
- package/es/middlewares/createRouterMiddleware.js +1 -0
- package/es/types/middleware.d.ts +1 -0
- package/es/types/templates.d.ts +16 -3
- package/es/widgets/answers/defaultTemplates.js +6 -2
- package/es/widgets/breadcrumb/defaultTemplates.js +6 -2
- package/es/widgets/clear-refinements/clear-refinements.d.ts +3 -1
- package/es/widgets/clear-refinements/defaultTemplates.js +3 -1
- package/es/widgets/geo-search/createHTMLMarker.d.ts +2 -1
- package/es/widgets/geo-search/createHTMLMarker.js +8 -1
- package/es/widgets/geo-search/defaultTemplates.d.ts +1 -0
- package/es/widgets/geo-search/defaultTemplates.js +17 -4
- package/es/widgets/hierarchical-menu/defaultTemplates.js +22 -2
- package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +2 -0
- package/es/widgets/hits/defaultTemplates.js +3 -1
- package/es/widgets/hits/hits.d.ts +2 -1
- package/es/widgets/index/index.d.ts +0 -1
- package/es/widgets/index/index.js +5 -6
- package/es/widgets/infinite-hits/defaultTemplates.js +9 -3
- package/es/widgets/infinite-hits/infinite-hits.d.ts +1 -3
- package/es/widgets/menu/defaultTemplates.js +22 -2
- package/es/widgets/menu-select/defaultTemplates.js +9 -2
- package/es/widgets/numeric-menu/defaultTemplates.js +18 -1
- package/es/widgets/range-input/range-input.js +6 -2
- package/es/widgets/rating-menu/defaultTemplates.js +54 -1
- package/es/widgets/rating-menu/rating-menu.d.ts +6 -0
- package/es/widgets/refinement-list/defaultTemplates.js +34 -3
- package/es/widgets/refinement-list/refinement-list.d.ts +7 -1
- package/es/widgets/relevant-sort/defaultTemplates.js +3 -1
- package/es/widgets/search-box/defaultTemplates.js +61 -3
- package/es/widgets/search-box/search-box.d.ts +10 -3
- package/es/widgets/stats/stats.d.ts +10 -6
- package/es/widgets/stats/stats.js +69 -22
- package/es/widgets/toggle-refinement/defaultTemplates.js +4 -1
- package/es/widgets/toggle-refinement/toggle-refinement.d.ts +3 -1
- package/es/widgets/voice-search/defaultTemplates.js +81 -9
- package/package.json +8 -7
- package/cjs/lib/utils/convertNumericRefinementsToFilters.js +0 -31
- package/cjs/lib/utils/escape.js +0 -35
- package/cjs/lib/utils/unescape.js +0 -32
- package/es/lib/utils/convertNumericRefinementsToFilters.d.ts +0 -2
- package/es/lib/utils/convertNumericRefinementsToFilters.js +0 -24
- package/es/lib/utils/escape.js +0 -27
- package/es/lib/utils/unescape.d.ts +0 -9
- package/es/lib/utils/unescape.js +0 -25
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @jest-environment jsdom
|
|
5
|
-
*/
|
|
6
3
|
import { serializePayload } from "./serializer.js";
|
|
7
4
|
|
|
8
5
|
function chunk(arr) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cx(cssClasses?: string | string[] | undefined): string;
|
package/es/lib/utils/defer.d.ts
CHANGED
package/es/lib/utils/defer.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
var nextMicroTask = Promise.resolve();
|
|
2
|
-
|
|
3
|
-
var defer = function defer(callback) {
|
|
2
|
+
export function defer(callback) {
|
|
4
3
|
var progress = null;
|
|
5
4
|
var cancelled = false;
|
|
6
5
|
|
|
@@ -42,6 +41,4 @@ var defer = function defer(callback) {
|
|
|
42
41
|
};
|
|
43
42
|
|
|
44
43
|
return fn;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default defer;
|
|
44
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function hasDetectedInsightsClient(): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { safelyRunOnBrowser } from "./safelyRunOnBrowser.js";
|
|
2
|
-
export
|
|
2
|
+
export function hasDetectedInsightsClient() {
|
|
3
3
|
return safelyRunOnBrowser(function (_ref) {
|
|
4
4
|
var window = _ref.window;
|
|
5
5
|
return Boolean(window.AlgoliaAnalyticsObject);
|
|
@@ -2,7 +2,7 @@ declare type WidgetParam = {
|
|
|
2
2
|
name: string;
|
|
3
3
|
connector?: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare
|
|
5
|
+
export declare function createDocumentationLink({ name, connector, }: WidgetParam): string;
|
|
6
6
|
declare type DocumentationMessageGenerator = (message?: string) => string;
|
|
7
|
-
export declare
|
|
7
|
+
export declare function createDocumentationMessageGenerator(...widgets: WidgetParam[]): DocumentationMessageGenerator;
|
|
8
8
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function createDocumentationLink(_ref) {
|
|
2
2
|
var name = _ref.name,
|
|
3
3
|
_ref$connector = _ref.connector,
|
|
4
4
|
connector = _ref$connector === void 0 ? false : _ref$connector;
|
|
5
5
|
return ['https://www.algolia.com/doc/api-reference/widgets/', name, '/js/', connector ? '#connector' : ''].join('');
|
|
6
|
-
}
|
|
7
|
-
export
|
|
6
|
+
}
|
|
7
|
+
export function createDocumentationMessageGenerator() {
|
|
8
8
|
for (var _len = arguments.length, widgets = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
9
|
widgets[_key] = arguments[_key];
|
|
10
10
|
}
|
|
@@ -15,4 +15,4 @@ export var createDocumentationMessageGenerator = function createDocumentationMes
|
|
|
15
15
|
return function (message) {
|
|
16
16
|
return [message, "See documentation: ".concat(links)].filter(Boolean).join('\n\n');
|
|
17
17
|
};
|
|
18
|
-
}
|
|
18
|
+
}
|
|
@@ -6,8 +6,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
6
6
|
|
|
7
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
8
|
|
|
9
|
-
import escape from "./escape.js";
|
|
10
|
-
import isPlainObject from "./isPlainObject.js";
|
|
9
|
+
import { escape } from "./escape-html.js";
|
|
10
|
+
import { isPlainObject } from "./isPlainObject.js";
|
|
11
11
|
export var TAG_PLACEHOLDER = {
|
|
12
12
|
highlightPreTag: '__ais-highlight__',
|
|
13
13
|
highlightPostTag: '__/ais-highlight__'
|
|
@@ -6,5 +6,9 @@
|
|
|
6
6
|
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
|
7
7
|
* corresponding HTML entities.
|
|
8
8
|
*/
|
|
9
|
-
declare function escape(value: string): string;
|
|
10
|
-
|
|
9
|
+
export declare function escape(value: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
|
|
12
|
+
* characters.
|
|
13
|
+
*/
|
|
14
|
+
export declare function unescape(value: string): string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This implementation is taken from Lodash implementation.
|
|
3
|
+
* See: https://github.com/lodash/lodash/blob/4.17.11-npm/escape.js
|
|
4
|
+
*/
|
|
5
|
+
// Used to map characters to HTML entities.
|
|
6
|
+
var htmlEntities = {
|
|
7
|
+
'&': '&',
|
|
8
|
+
'<': '<',
|
|
9
|
+
'>': '>',
|
|
10
|
+
'"': '"',
|
|
11
|
+
"'": '''
|
|
12
|
+
}; // Used to match HTML entities and HTML characters.
|
|
13
|
+
|
|
14
|
+
var regexUnescapedHtml = /[&<>"']/g;
|
|
15
|
+
var regexHasUnescapedHtml = RegExp(regexUnescapedHtml.source);
|
|
16
|
+
/**
|
|
17
|
+
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
|
18
|
+
* corresponding HTML entities.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export function escape(value) {
|
|
22
|
+
return value && regexHasUnescapedHtml.test(value) ? value.replace(regexUnescapedHtml, function (character) {
|
|
23
|
+
return htmlEntities[character];
|
|
24
|
+
}) : value;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* This implementation is taken from Lodash implementation.
|
|
28
|
+
* See: https://github.com/lodash/lodash/blob/4.17.11-npm/unescape.js
|
|
29
|
+
*/
|
|
30
|
+
// Used to map HTML entities to characters.
|
|
31
|
+
|
|
32
|
+
var htmlCharacters = {
|
|
33
|
+
'&': '&',
|
|
34
|
+
'<': '<',
|
|
35
|
+
'>': '>',
|
|
36
|
+
'"': '"',
|
|
37
|
+
''': "'"
|
|
38
|
+
}; // Used to match HTML entities and HTML characters.
|
|
39
|
+
|
|
40
|
+
var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g;
|
|
41
|
+
var regexHasEscapedHtml = RegExp(regexEscapedHtml.source);
|
|
42
|
+
/**
|
|
43
|
+
* Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
|
|
44
|
+
* characters.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
export function unescape(value) {
|
|
48
|
+
return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) {
|
|
49
|
+
return htmlCharacters[character];
|
|
50
|
+
}) : value;
|
|
51
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare type FacetValue = string | number | undefined;
|
|
1
|
+
declare type FacetValue = string | number | boolean | undefined;
|
|
2
2
|
export declare function unescapeFacetValue<TFacetValue extends FacetValue>(value: TFacetValue): TFacetValue;
|
|
3
3
|
export declare function escapeFacetValue<TFacetValue extends FacetValue>(value: TFacetValue): TFacetValue;
|
|
4
4
|
export {};
|
package/es/lib/utils/find.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare function find<TItem>(items: TItem[], predicate: (value: TItem, index: number, obj: TItem[]) => boolean): TItem | undefined;
|
|
2
|
-
export default find;
|
|
1
|
+
export declare function find<TItem>(items: TItem[], predicate: (value: TItem, index: number, obj: TItem[]) => boolean): TItem | undefined;
|
package/es/lib/utils/find.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// was decided as too risky.
|
|
5
5
|
// @MAJOR Replace with the native `Array.prototype.find` method
|
|
6
6
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
|
|
7
|
-
function find(items, predicate) {
|
|
7
|
+
export function find(items, predicate) {
|
|
8
8
|
var value;
|
|
9
9
|
|
|
10
10
|
for (var i = 0; i < items.length; i++) {
|
|
@@ -16,6 +16,4 @@ function find(items, predicate) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
return undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default find;
|
|
19
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare function findIndex<TItem>(array: TItem[], comparator: (value: TItem) => boolean): number;
|
|
2
|
-
export default findIndex;
|
|
1
|
+
export declare function findIndex<TItem>(array: TItem[], comparator: (value: TItem) => boolean): number;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// was decided as too risky.
|
|
5
5
|
// @MAJOR Replace with the native `Array.prototype.findIndex` method
|
|
6
6
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
|
|
7
|
-
function findIndex(array, comparator) {
|
|
7
|
+
export function findIndex(array, comparator) {
|
|
8
8
|
if (!Array.isArray(array)) {
|
|
9
9
|
return -1;
|
|
10
10
|
}
|
|
@@ -16,6 +16,4 @@ function findIndex(array, comparator) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
return -1;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default findIndex;
|
|
19
|
+
}
|
|
@@ -7,5 +7,4 @@
|
|
|
7
7
|
* @return {HTMLElement} Container node
|
|
8
8
|
* @throws Error when the type is not correct
|
|
9
9
|
*/
|
|
10
|
-
declare function getContainerNode(selectorOrHTMLElement: string | HTMLElement): HTMLElement;
|
|
11
|
-
export default getContainerNode;
|
|
10
|
+
export declare function getContainerNode(selectorOrHTMLElement: string | HTMLElement): HTMLElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import isDomElement from "./isDomElement.js";
|
|
1
|
+
import { isDomElement } from "./isDomElement.js";
|
|
2
2
|
/**
|
|
3
3
|
* Return the container. If it's a string, it is considered a
|
|
4
4
|
* css selector and retrieves the first matching element. Otherwise
|
|
@@ -9,7 +9,7 @@ import isDomElement from "./isDomElement.js";
|
|
|
9
9
|
* @throws Error when the type is not correct
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
function getContainerNode(selectorOrHTMLElement) {
|
|
12
|
+
export function getContainerNode(selectorOrHTMLElement) {
|
|
13
13
|
var isSelectorString = typeof selectorOrHTMLElement === 'string';
|
|
14
14
|
var domElement = isSelectorString ? document.querySelector(selectorOrHTMLElement) : selectorOrHTMLElement;
|
|
15
15
|
|
|
@@ -24,6 +24,4 @@ function getContainerNode(selectorOrHTMLElement) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
return domElement;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default getContainerNode;
|
|
27
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { HighlightedParts } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export declare function getHighlightFromSiblings(parts: HighlightedParts[], i: number): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import unescape from "./
|
|
1
|
+
import { unescape } from "./escape-html.js";
|
|
2
2
|
var hasAlphanumeric = new RegExp(/\w/i);
|
|
3
|
-
export
|
|
3
|
+
export function getHighlightFromSiblings(parts, i) {
|
|
4
4
|
var _parts, _parts2;
|
|
5
5
|
|
|
6
6
|
var current = parts[i];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TAG_REPLACEMENT } from "./escape-highlight.js";
|
|
2
|
-
export
|
|
2
|
+
export function getHighlightedParts(highlightedValue) {
|
|
3
3
|
var highlightPostTag = TAG_REPLACEMENT.highlightPostTag,
|
|
4
4
|
highlightPreTag = TAG_REPLACEMENT.highlightPreTag;
|
|
5
5
|
var splitByPreTag = highlightedValue.split(highlightPreTag);
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare function getObjectType(object: unknown): string;
|
|
2
|
-
export default getObjectType;
|
|
1
|
+
export declare function getObjectType(object: unknown): string;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare function getPropertyByPath(object: Record<string, any> | undefined, path: string | string[]): any;
|
|
2
|
-
export default getPropertyByPath;
|
|
1
|
+
export declare function getPropertyByPath(object: Record<string, any> | undefined, path: string | string[]): any;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
function getPropertyByPath(object, path) {
|
|
1
|
+
export function getPropertyByPath(object, path) {
|
|
2
2
|
var parts = Array.isArray(path) ? path : path.split('.');
|
|
3
3
|
return parts.reduce(function (current, key) {
|
|
4
4
|
return current && current[key];
|
|
5
5
|
}, object);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default getPropertyByPath;
|
|
6
|
+
}
|
|
@@ -36,4 +36,4 @@ export declare type FacetExcludeRefinement = {
|
|
|
36
36
|
exhaustive?: boolean;
|
|
37
37
|
};
|
|
38
38
|
export declare type Refinement = FacetRefinement | QueryRefinement | NumericRefinement | FacetExcludeRefinement | TagRefinement;
|
|
39
|
-
export
|
|
39
|
+
export declare function getRefinements(results: SearchResults | Record<string, never>, state: SearchParameters, includesQuery?: boolean): Refinement[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import find from "./find.js";
|
|
1
|
+
import { find } from "./find.js";
|
|
2
2
|
import { unescapeFacetValue, escapeFacetValue } from "./escapeFacetValue.js";
|
|
3
3
|
|
|
4
4
|
function getRefinement(state, type, attribute, name) {
|
|
@@ -52,7 +52,7 @@ function getRefinement(state, type, attribute, name) {
|
|
|
52
52
|
return res;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export
|
|
55
|
+
export function getRefinements(results, state) {
|
|
56
56
|
var includesQuery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
57
57
|
var refinements = [];
|
|
58
58
|
var _state$facetsRefineme = state.facetsRefinements,
|
package/es/lib/utils/index.d.ts
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export { default as renderTemplate } from './renderTemplate';
|
|
8
|
-
export { default as getRefinements } from './getRefinements';
|
|
9
|
-
export { default as clearRefinements } from './clearRefinements';
|
|
10
|
-
export { escapeFacetValue, unescapeFacetValue } from './escapeFacetValue';
|
|
11
|
-
export { default as checkRendering } from './checkRendering';
|
|
12
|
-
export { checkIndexUiState } from './checkIndexUiState';
|
|
13
|
-
export { default as getPropertyByPath } from './getPropertyByPath';
|
|
14
|
-
export { default as getObjectType } from './getObjectType';
|
|
15
|
-
export { default as noop } from './noop';
|
|
16
|
-
export { default as isFiniteNumber } from './isFiniteNumber';
|
|
17
|
-
export { default as isPlainObject } from './isPlainObject';
|
|
18
|
-
export { default as uniq } from './uniq';
|
|
19
|
-
export { default as range } from './range';
|
|
20
|
-
export { default as isEqual } from './isEqual';
|
|
21
|
-
export { default as escape } from './escape';
|
|
22
|
-
export { default as unescape } from './unescape';
|
|
23
|
-
export { default as concatHighlightedParts } from './concatHighlightedParts';
|
|
24
|
-
export { default as getHighlightedParts } from './getHighlightedParts';
|
|
25
|
-
export { default as getHighlightFromSiblings } from './getHighlightFromSiblings';
|
|
26
|
-
export { default as reverseHighlightedParts } from './reverseHighlightedParts';
|
|
27
|
-
export { default as find } from './find';
|
|
28
|
-
export { default as findIndex } from './findIndex';
|
|
29
|
-
export { default as mergeSearchParameters } from './mergeSearchParameters';
|
|
30
|
-
export { default as resolveSearchParameters } from './resolveSearchParameters';
|
|
31
|
-
export { default as toArray } from './toArray';
|
|
32
|
-
export { warning, deprecate } from './logger';
|
|
33
|
-
export { escapeHits, TAG_PLACEHOLDER, TAG_REPLACEMENT, escapeFacets, } from './escape-highlight';
|
|
34
|
-
export { createDocumentationLink, createDocumentationMessageGenerator, } from './documentation';
|
|
35
|
-
export { aroundLatLngToPosition, insideBoundingBoxToBoundingBox, } from './geo-search';
|
|
36
|
-
export { addAbsolutePosition } from './hits-absolute-position';
|
|
37
|
-
export { addQueryID } from './hits-query-id';
|
|
38
|
-
export { default as isFacetRefined } from './isFacetRefined';
|
|
1
|
+
export * from './capitalize';
|
|
2
|
+
export * from './checkIndexUiState';
|
|
3
|
+
export * from './checkRendering';
|
|
4
|
+
export * from './clearRefinements';
|
|
5
|
+
export * from './concatHighlightedParts';
|
|
6
|
+
export * from './createConcurrentSafePromise';
|
|
39
7
|
export * from './createSendEventForFacet';
|
|
40
8
|
export * from './createSendEventForHits';
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
9
|
+
export * from './setIndexHelperState';
|
|
10
|
+
export * from './isIndexWidget';
|
|
11
|
+
export * from './cx';
|
|
12
|
+
export * from './debounce';
|
|
13
|
+
export * from './defer';
|
|
14
|
+
export * from './documentation';
|
|
15
|
+
export * from './escape-highlight';
|
|
16
|
+
export * from './escape-html';
|
|
17
|
+
export * from './escapeFacetValue';
|
|
18
|
+
export * from './find';
|
|
19
|
+
export * from './findIndex';
|
|
20
|
+
export * from './geo-search';
|
|
21
|
+
export * from './getAppIdAndApiKey';
|
|
22
|
+
export * from './getContainerNode';
|
|
23
|
+
export * from './getHighlightedParts';
|
|
24
|
+
export * from './getHighlightFromSiblings';
|
|
25
|
+
export * from './getObjectType';
|
|
26
|
+
export * from './getPropertyByPath';
|
|
27
|
+
export * from './getRefinements';
|
|
28
|
+
export * from './getWidgetAttribute';
|
|
29
|
+
export * from './hits-absolute-position';
|
|
30
|
+
export * from './hits-query-id';
|
|
31
|
+
export * from './isDomElement';
|
|
32
|
+
export * from './isEqual';
|
|
33
|
+
export * from './isFacetRefined';
|
|
34
|
+
export * from './isFiniteNumber';
|
|
35
|
+
export * from './isPlainObject';
|
|
36
|
+
export * from './isSpecialClick';
|
|
37
|
+
export * from './logger';
|
|
38
|
+
export * from './mergeSearchParameters';
|
|
39
|
+
export * from './noop';
|
|
40
|
+
export * from './prepareTemplateProps';
|
|
41
|
+
export * from './range';
|
|
42
|
+
export * from './renderTemplate';
|
|
43
|
+
export * from './resolveSearchParameters';
|
|
44
|
+
export * from './reverseHighlightedParts';
|
|
45
|
+
export * from './safelyRunOnBrowser';
|
|
46
|
+
export * from './serializer';
|
|
47
|
+
export * from './toArray';
|
|
48
|
+
export * from './uniq';
|
package/es/lib/utils/index.js
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export { default as renderTemplate } from "./renderTemplate.js";
|
|
8
|
-
export { default as getRefinements } from "./getRefinements.js";
|
|
9
|
-
export { default as clearRefinements } from "./clearRefinements.js";
|
|
10
|
-
export { escapeFacetValue, unescapeFacetValue } from "./escapeFacetValue.js";
|
|
11
|
-
export { default as checkRendering } from "./checkRendering.js";
|
|
12
|
-
export { checkIndexUiState } from "./checkIndexUiState.js";
|
|
13
|
-
export { default as getPropertyByPath } from "./getPropertyByPath.js";
|
|
14
|
-
export { default as getObjectType } from "./getObjectType.js";
|
|
15
|
-
export { default as noop } from "./noop.js";
|
|
16
|
-
export { default as isFiniteNumber } from "./isFiniteNumber.js";
|
|
17
|
-
export { default as isPlainObject } from "./isPlainObject.js";
|
|
18
|
-
export { default as uniq } from "./uniq.js";
|
|
19
|
-
export { default as range } from "./range.js";
|
|
20
|
-
export { default as isEqual } from "./isEqual.js";
|
|
21
|
-
export { default as escape } from "./escape.js";
|
|
22
|
-
export { default as unescape } from "./unescape.js";
|
|
23
|
-
export { default as concatHighlightedParts } from "./concatHighlightedParts.js";
|
|
24
|
-
export { default as getHighlightedParts } from "./getHighlightedParts.js";
|
|
25
|
-
export { default as getHighlightFromSiblings } from "./getHighlightFromSiblings.js";
|
|
26
|
-
export { default as reverseHighlightedParts } from "./reverseHighlightedParts.js";
|
|
27
|
-
export { default as find } from "./find.js";
|
|
28
|
-
export { default as findIndex } from "./findIndex.js";
|
|
29
|
-
export { default as mergeSearchParameters } from "./mergeSearchParameters.js";
|
|
30
|
-
export { default as resolveSearchParameters } from "./resolveSearchParameters.js";
|
|
31
|
-
export { default as toArray } from "./toArray.js";
|
|
32
|
-
export { warning, deprecate } from "./logger.js";
|
|
33
|
-
export { escapeHits, TAG_PLACEHOLDER, TAG_REPLACEMENT, escapeFacets } from "./escape-highlight.js";
|
|
34
|
-
export { createDocumentationLink, createDocumentationMessageGenerator } from "./documentation.js";
|
|
35
|
-
export { aroundLatLngToPosition, insideBoundingBoxToBoundingBox } from "./geo-search.js";
|
|
36
|
-
export { addAbsolutePosition } from "./hits-absolute-position.js";
|
|
37
|
-
export { addQueryID } from "./hits-query-id.js";
|
|
38
|
-
export { default as isFacetRefined } from "./isFacetRefined.js";
|
|
1
|
+
export * from "./capitalize.js";
|
|
2
|
+
export * from "./checkIndexUiState.js";
|
|
3
|
+
export * from "./checkRendering.js";
|
|
4
|
+
export * from "./clearRefinements.js";
|
|
5
|
+
export * from "./concatHighlightedParts.js";
|
|
6
|
+
export * from "./createConcurrentSafePromise.js";
|
|
39
7
|
export * from "./createSendEventForFacet.js";
|
|
40
8
|
export * from "./createSendEventForHits.js";
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
9
|
+
export * from "./setIndexHelperState.js";
|
|
10
|
+
export * from "./isIndexWidget.js";
|
|
11
|
+
export * from "./cx.js";
|
|
12
|
+
export * from "./debounce.js";
|
|
13
|
+
export * from "./defer.js";
|
|
14
|
+
export * from "./documentation.js";
|
|
15
|
+
export * from "./escape-highlight.js";
|
|
16
|
+
export * from "./escape-html.js";
|
|
17
|
+
export * from "./escapeFacetValue.js";
|
|
18
|
+
export * from "./find.js";
|
|
19
|
+
export * from "./findIndex.js";
|
|
20
|
+
export * from "./geo-search.js";
|
|
21
|
+
export * from "./getAppIdAndApiKey.js";
|
|
22
|
+
export * from "./getContainerNode.js";
|
|
23
|
+
export * from "./getHighlightedParts.js";
|
|
24
|
+
export * from "./getHighlightFromSiblings.js";
|
|
25
|
+
export * from "./getObjectType.js";
|
|
26
|
+
export * from "./getPropertyByPath.js";
|
|
27
|
+
export * from "./getRefinements.js";
|
|
28
|
+
export * from "./getWidgetAttribute.js";
|
|
29
|
+
export * from "./hits-absolute-position.js";
|
|
30
|
+
export * from "./hits-query-id.js";
|
|
31
|
+
export * from "./isDomElement.js";
|
|
32
|
+
export * from "./isEqual.js";
|
|
33
|
+
export * from "./isFacetRefined.js";
|
|
34
|
+
export * from "./isFiniteNumber.js";
|
|
35
|
+
export * from "./isPlainObject.js";
|
|
36
|
+
export * from "./isSpecialClick.js";
|
|
37
|
+
export * from "./logger.js";
|
|
38
|
+
export * from "./mergeSearchParameters.js";
|
|
39
|
+
export * from "./noop.js";
|
|
40
|
+
export * from "./prepareTemplateProps.js";
|
|
41
|
+
export * from "./range.js";
|
|
42
|
+
export * from "./renderTemplate.js";
|
|
43
|
+
export * from "./resolveSearchParameters.js";
|
|
44
|
+
export * from "./reverseHighlightedParts.js";
|
|
45
|
+
export * from "./safelyRunOnBrowser.js";
|
|
46
|
+
export * from "./serializer.js";
|
|
47
|
+
export * from "./toArray.js";
|
|
48
|
+
export * from "./uniq.js";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare function isDomElement(object: any): object is HTMLElement;
|
|
2
|
-
export default isDomElement;
|
|
1
|
+
export declare function isDomElement(object: any): object is HTMLElement;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare function isEqual(first: any, second: any): boolean;
|
|
2
|
-
export default isEqual;
|
|
1
|
+
export declare function isEqual(first: any, second: any): boolean;
|
package/es/lib/utils/isEqual.js
CHANGED
|
@@ -2,7 +2,7 @@ function isPrimitive(obj) {
|
|
|
2
2
|
return obj !== Object(obj);
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
function isEqual(first, second) {
|
|
5
|
+
export function isEqual(first, second) {
|
|
6
6
|
if (first === second) {
|
|
7
7
|
return true;
|
|
8
8
|
}
|
|
@@ -28,6 +28,4 @@ function isEqual(first, second) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return true;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default isEqual;
|
|
31
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
|
|
2
|
-
export
|
|
2
|
+
export declare function isFacetRefined(helper: AlgoliaSearchHelper, facet: string, value: string): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function isFacetRefined(helper, facet, value) {
|
|
2
2
|
if (helper.state.isHierarchicalFacet(facet)) {
|
|
3
3
|
return helper.state.isHierarchicalFacetRefined(facet, value);
|
|
4
4
|
} else if (helper.state.isConjunctiveFacet(facet)) {
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare function isFiniteNumber(value: any): value is number;
|
|
2
|
-
export default isFiniteNumber;
|
|
1
|
+
export declare function isFiniteNumber(value: any): value is number;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// This is the `Number.isFinite()` polyfill recommended by MDN.
|
|
2
2
|
// We do not provide any tests for this function.
|
|
3
3
|
// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite#Polyfill
|
|
4
|
-
|
|
4
|
+
// @MAJOR Replace with the native `Number.isFinite` method
|
|
5
|
+
export function isFiniteNumber(value) {
|
|
5
6
|
return typeof value === 'number' && isFinite(value);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default isFiniteNumber;
|
|
7
|
+
}
|
|
@@ -23,7 +23,7 @@ function isObjectLike(value) {
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
function isPlainObject(value) {
|
|
26
|
+
export function isPlainObject(value) {
|
|
27
27
|
if (!isObjectLike(value) || getTag(value) !== '[object Object]') {
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
@@ -39,6 +39,4 @@ function isPlainObject(value) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
return Object.getPrototypeOf(value) === proto;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default isPlainObject;
|
|
42
|
+
}
|