instantsearch.js 4.73.4 → 4.74.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/README.md +1 -2
- package/cjs/connectors/answers/connectAnswers.js +3 -2
- package/cjs/connectors/configure-related-items/connectConfigureRelatedItems.js +2 -0
- package/cjs/connectors/index.js +7 -10
- package/cjs/connectors/voice-search/connectVoiceSearch.js +2 -1
- package/cjs/helpers/highlight.js +1 -1
- package/cjs/helpers/reverseHighlight.js +1 -1
- package/cjs/helpers/reverseSnippet.js +1 -1
- package/cjs/helpers/snippet.js +1 -1
- package/cjs/index.js +2 -0
- package/cjs/lib/utils/hydrateSearchClient.js +1 -1
- package/cjs/lib/version.js +1 -1
- package/cjs/templates/carousel/carousel.js +62 -0
- package/cjs/templates/index.js +16 -0
- package/cjs/widgets/configure-related-items/configure-related-items.js +2 -0
- package/cjs/widgets/frequently-bought-together/frequently-bought-together.js +36 -12
- package/cjs/widgets/index.js +7 -10
- package/cjs/widgets/looking-similar/looking-similar.js +37 -13
- package/cjs/widgets/related-products/related-products.js +37 -13
- package/cjs/widgets/trending-items/trending-items.js +38 -14
- package/dist/instantsearch.development.d.ts +119 -51
- package/dist/instantsearch.development.js +10293 -9967
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +119 -51
- package/dist/instantsearch.production.min.d.ts +119 -51
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/connectors/answers/connectAnswers.js +3 -2
- package/es/connectors/configure-related-items/connectConfigureRelatedItems.d.ts +1 -0
- package/es/connectors/configure-related-items/connectConfigureRelatedItems.js +2 -0
- package/es/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.d.ts +7 -7
- package/es/connectors/index.d.ts +2 -1
- package/es/connectors/index.js +4 -1
- package/es/connectors/looking-similar/connectLookingSimilar.d.ts +7 -7
- package/es/connectors/related-products/connectRelatedProducts.d.ts +7 -7
- package/es/connectors/trending-items/connectTrendingItems.d.ts +7 -7
- package/es/connectors/voice-search/connectVoiceSearch.js +2 -1
- package/es/helpers/highlight.js +1 -1
- package/es/helpers/reverseHighlight.js +1 -1
- package/es/helpers/reverseSnippet.js +1 -1
- package/es/helpers/snippet.js +1 -1
- package/es/index.js +5 -0
- package/es/lib/utils/hydrateSearchClient.js +1 -1
- package/es/lib/utils/render-args.d.ts +2 -2
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/templates/carousel/carousel.d.ts +22 -0
- package/es/templates/carousel/carousel.js +56 -0
- package/es/templates/index.d.ts +1 -0
- package/es/templates/index.js +1 -0
- package/es/types/widget.d.ts +3 -2
- package/es/widgets/configure-related-items/configure-related-items.d.ts +1 -0
- package/es/widgets/configure-related-items/configure-related-items.js +2 -0
- package/es/widgets/frequently-bought-together/frequently-bought-together.d.ts +15 -7
- package/es/widgets/frequently-bought-together/frequently-bought-together.js +36 -12
- package/es/widgets/geo-search/geo-search.d.ts +1 -1
- package/es/widgets/index/index.d.ts +3 -3
- package/es/widgets/index.d.ts +2 -1
- package/es/widgets/index.js +4 -1
- package/es/widgets/looking-similar/looking-similar.d.ts +15 -7
- package/es/widgets/looking-similar/looking-similar.js +37 -13
- package/es/widgets/related-products/related-products.d.ts +15 -7
- package/es/widgets/related-products/related-products.js +37 -13
- package/es/widgets/trending-items/trending-items.d.ts +15 -7
- package/es/widgets/trending-items/trending-items.js +38 -14
- package/package.json +9 -9
|
@@ -41,14 +41,15 @@ var connectAnswers = function connectAnswers(renderFn) {
|
|
|
41
41
|
var lastHits = [];
|
|
42
42
|
var isLoading = false;
|
|
43
43
|
var debouncedRender = debounce(renderFn, renderDebounceTime);
|
|
44
|
-
|
|
45
|
-
// this does not directly use DebouncedFunction<findAnswers>, since then the generic will disappear
|
|
46
44
|
var debouncedRefine;
|
|
47
45
|
return {
|
|
48
46
|
$$type: 'ais.answers',
|
|
49
47
|
init: function init(initOptions) {
|
|
50
48
|
var state = initOptions.state,
|
|
51
49
|
instantSearchInstance = initOptions.instantSearchInstance;
|
|
50
|
+
if (typeof instantSearchInstance.client.initIndex !== 'function') {
|
|
51
|
+
throw new Error(withUsage('`algoliasearch` <5 required.'));
|
|
52
|
+
}
|
|
52
53
|
var answersIndex = instantSearchInstance.client.initIndex(state.index);
|
|
53
54
|
if (!hasFindAnswersMethod(answersIndex)) {
|
|
54
55
|
throw new Error(withUsage('`algoliasearch` >= 4.8.0 required.'));
|
|
@@ -32,4 +32,5 @@ export type ConfigureRelatedItemsWidgetDescription = {
|
|
|
32
32
|
} & Omit<ConfigureWidgetDescription, '$$type'>;
|
|
33
33
|
export type ConfigureRelatedItemsConnector = Connector<ConfigureRelatedItemsWidgetDescription, ConfigureRelatedItemsConnectorParams>;
|
|
34
34
|
declare const connectConfigureRelatedItems: ConfigureRelatedItemsConnector;
|
|
35
|
+
/** @deprecated use connectRelatedItems instead */
|
|
35
36
|
export default connectConfigureRelatedItems;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Connector, TransformItems,
|
|
2
|
-
import type { PlainSearchParameters
|
|
1
|
+
import type { Connector, TransformItems, BaseHit, Renderer, Unmounter, UnknownWidgetParams, RecommendResponse, AlgoliaHit } from '../../types';
|
|
2
|
+
import type { PlainSearchParameters } from 'algoliasearch-helper';
|
|
3
3
|
export type FrequentlyBoughtTogetherRenderState<THit extends NonNullable<object> = BaseHit> = {
|
|
4
4
|
/**
|
|
5
5
|
* The matched recommendations from Algolia API.
|
|
6
6
|
*/
|
|
7
|
-
items: Array<
|
|
7
|
+
items: Array<AlgoliaHit<THit>>;
|
|
8
8
|
};
|
|
9
9
|
export type FrequentlyBoughtTogetherConnectorParams<THit extends NonNullable<object> = BaseHit> = {
|
|
10
10
|
/**
|
|
@@ -32,8 +32,8 @@ export type FrequentlyBoughtTogetherConnectorParams<THit extends NonNullable<obj
|
|
|
32
32
|
/**
|
|
33
33
|
* Function to transform the items passed to the templates.
|
|
34
34
|
*/
|
|
35
|
-
transformItems?: TransformItems<
|
|
36
|
-
results:
|
|
35
|
+
transformItems?: TransformItems<AlgoliaHit<THit>, {
|
|
36
|
+
results: RecommendResponse<AlgoliaHit<THit>>;
|
|
37
37
|
}>;
|
|
38
38
|
};
|
|
39
39
|
export type FrequentlyBoughtTogetherWidgetDescription<THit extends NonNullable<object> = BaseHit> = {
|
|
@@ -150,9 +150,9 @@ declare const _default: <TWidgetParams extends UnknownWidgetParams>(renderFn: Re
|
|
|
150
150
|
error: import("../../types").InstantSearch["error"];
|
|
151
151
|
createURL: (nextState: import("algoliasearch-helper").SearchParameters | ((state: import("../../types").IndexUiState) => import("../../types").IndexUiState)) => string;
|
|
152
152
|
} & {
|
|
153
|
-
results:
|
|
153
|
+
results: RecommendResponse<any>;
|
|
154
154
|
})): {
|
|
155
|
-
items:
|
|
155
|
+
items: AlgoliaHit<THit>[];
|
|
156
156
|
widgetParams: TWidgetParams & FrequentlyBoughtTogetherConnectorParams<THit>;
|
|
157
157
|
};
|
|
158
158
|
dispose({ recommendState }: import("../../types").DisposeOptions): import("algoliasearch-helper").RecommendParameters;
|
package/es/connectors/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import connectDynamicWidgets from './dynamic-widgets/connectDynamicWidgets';
|
|
2
2
|
/** @deprecated answers is no longer supported */
|
|
3
3
|
export declare const EXPERIMENTAL_connectAnswers: import("./answers/connectAnswers").AnswersConnector;
|
|
4
|
+
/** @deprecated use connectRelatedItems instead */
|
|
5
|
+
export declare const EXPERIMENTAL_connectConfigureRelatedItems: import("./configure-related-items/connectConfigureRelatedItems").ConfigureRelatedItemsConnector;
|
|
4
6
|
/** @deprecated use connectDynamicWidgets */
|
|
5
7
|
export declare const EXPERIMENTAL_connectDynamicWidgets: import("./dynamic-widgets/connectDynamicWidgets").DynamicWidgetsConnector;
|
|
6
8
|
export { connectDynamicWidgets };
|
|
@@ -28,7 +30,6 @@ export { default as connectBreadcrumb } from './breadcrumb/connectBreadcrumb';
|
|
|
28
30
|
export { default as connectGeoSearch } from './geo-search/connectGeoSearch';
|
|
29
31
|
export { default as connectPoweredBy } from './powered-by/connectPoweredBy';
|
|
30
32
|
export { default as connectConfigure } from './configure/connectConfigure';
|
|
31
|
-
export { default as EXPERIMENTAL_connectConfigureRelatedItems } from './configure-related-items/connectConfigureRelatedItems';
|
|
32
33
|
export { default as connectAutocomplete } from './autocomplete/connectAutocomplete';
|
|
33
34
|
export { default as connectQueryRules } from './query-rules/connectQueryRules';
|
|
34
35
|
export { default as connectVoiceSearch } from './voice-search/connectVoiceSearch';
|
package/es/connectors/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { deprecate } from "../lib/utils/index.js";
|
|
2
2
|
import connectAnswers from "./answers/connectAnswers.js";
|
|
3
|
+
import connectConfigureRelatedItems from "./configure-related-items/connectConfigureRelatedItems.js";
|
|
3
4
|
import connectDynamicWidgets from "./dynamic-widgets/connectDynamicWidgets.js";
|
|
4
5
|
|
|
5
6
|
/** @deprecated answers is no longer supported */
|
|
6
7
|
export var EXPERIMENTAL_connectAnswers = deprecate(connectAnswers, 'answers is no longer supported');
|
|
7
8
|
|
|
9
|
+
/** @deprecated use connectRelatedItems instead */
|
|
10
|
+
export var EXPERIMENTAL_connectConfigureRelatedItems = deprecate(connectConfigureRelatedItems, 'EXPERIMENTAL_connectConfigureRelatedItems is deprecated and will be removed in a next minor version of InstantSearch. Please use connectRelatedItems instead.');
|
|
11
|
+
|
|
8
12
|
/** @deprecated use connectDynamicWidgets */
|
|
9
13
|
export var EXPERIMENTAL_connectDynamicWidgets = deprecate(connectDynamicWidgets, 'use connectDynamicWidgets');
|
|
10
14
|
export { connectDynamicWidgets };
|
|
@@ -32,7 +36,6 @@ export { default as connectBreadcrumb } from "./breadcrumb/connectBreadcrumb.js"
|
|
|
32
36
|
export { default as connectGeoSearch } from "./geo-search/connectGeoSearch.js";
|
|
33
37
|
export { default as connectPoweredBy } from "./powered-by/connectPoweredBy.js";
|
|
34
38
|
export { default as connectConfigure } from "./configure/connectConfigure.js";
|
|
35
|
-
export { default as EXPERIMENTAL_connectConfigureRelatedItems } from "./configure-related-items/connectConfigureRelatedItems.js";
|
|
36
39
|
export { default as connectAutocomplete } from "./autocomplete/connectAutocomplete.js";
|
|
37
40
|
export { default as connectQueryRules } from "./query-rules/connectQueryRules.js";
|
|
38
41
|
export { default as connectVoiceSearch } from "./voice-search/connectVoiceSearch.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Connector, TransformItems,
|
|
2
|
-
import type { PlainSearchParameters
|
|
1
|
+
import type { Connector, TransformItems, BaseHit, Renderer, Unmounter, UnknownWidgetParams, RecommendResponse, AlgoliaHit } from '../../types';
|
|
2
|
+
import type { PlainSearchParameters } from 'algoliasearch-helper';
|
|
3
3
|
export type LookingSimilarRenderState<THit extends NonNullable<object> = BaseHit> = {
|
|
4
4
|
/**
|
|
5
5
|
* The matched recommendations from the Algolia API.
|
|
6
6
|
*/
|
|
7
|
-
items: Array<
|
|
7
|
+
items: Array<AlgoliaHit<THit>>;
|
|
8
8
|
};
|
|
9
9
|
export type LookingSimilarConnectorParams<THit extends NonNullable<object> = BaseHit> = {
|
|
10
10
|
/**
|
|
@@ -36,8 +36,8 @@ export type LookingSimilarConnectorParams<THit extends NonNullable<object> = Bas
|
|
|
36
36
|
/**
|
|
37
37
|
* Function to transform the items passed to the templates.
|
|
38
38
|
*/
|
|
39
|
-
transformItems?: TransformItems<
|
|
40
|
-
results:
|
|
39
|
+
transformItems?: TransformItems<AlgoliaHit<THit>, {
|
|
40
|
+
results: RecommendResponse<AlgoliaHit<THit>>;
|
|
41
41
|
}>;
|
|
42
42
|
};
|
|
43
43
|
export type LookingSimilarWidgetDescription<THit extends NonNullable<object> = BaseHit> = {
|
|
@@ -154,9 +154,9 @@ declare const _default: <TWidgetParams extends UnknownWidgetParams>(renderFn: Re
|
|
|
154
154
|
error: import("../../types").InstantSearch["error"];
|
|
155
155
|
createURL: (nextState: import("algoliasearch-helper").SearchParameters | ((state: import("../../types").IndexUiState) => import("../../types").IndexUiState)) => string;
|
|
156
156
|
} & {
|
|
157
|
-
results:
|
|
157
|
+
results: RecommendResponse<any>;
|
|
158
158
|
})): {
|
|
159
|
-
items:
|
|
159
|
+
items: AlgoliaHit<THit>[];
|
|
160
160
|
widgetParams: TWidgetParams & LookingSimilarConnectorParams<THit>;
|
|
161
161
|
};
|
|
162
162
|
dispose({ recommendState }: import("../../types").DisposeOptions): import("algoliasearch-helper").RecommendParameters;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Connector, TransformItems,
|
|
2
|
-
import type { PlainSearchParameters
|
|
1
|
+
import type { Connector, TransformItems, BaseHit, Renderer, Unmounter, UnknownWidgetParams, RecommendResponse, AlgoliaHit } from '../../types';
|
|
2
|
+
import type { PlainSearchParameters } from 'algoliasearch-helper';
|
|
3
3
|
export type RelatedProductsRenderState<THit extends NonNullable<object> = BaseHit> = {
|
|
4
4
|
/**
|
|
5
5
|
* The matched recommendations from the Algolia API.
|
|
6
6
|
*/
|
|
7
|
-
items: Array<
|
|
7
|
+
items: Array<AlgoliaHit<THit>>;
|
|
8
8
|
};
|
|
9
9
|
export type RelatedProductsConnectorParams<THit extends NonNullable<object> = BaseHit> = {
|
|
10
10
|
/**
|
|
@@ -36,8 +36,8 @@ export type RelatedProductsConnectorParams<THit extends NonNullable<object> = Ba
|
|
|
36
36
|
/**
|
|
37
37
|
* Function to transform the items passed to the templates.
|
|
38
38
|
*/
|
|
39
|
-
transformItems?: TransformItems<
|
|
40
|
-
results:
|
|
39
|
+
transformItems?: TransformItems<AlgoliaHit<THit>, {
|
|
40
|
+
results: RecommendResponse<AlgoliaHit<THit>>;
|
|
41
41
|
}>;
|
|
42
42
|
};
|
|
43
43
|
export type RelatedProductsWidgetDescription<THit extends NonNullable<object> = BaseHit> = {
|
|
@@ -154,9 +154,9 @@ declare const _default: <TWidgetParams extends UnknownWidgetParams>(renderFn: Re
|
|
|
154
154
|
error: import("../../types").InstantSearch["error"];
|
|
155
155
|
createURL: (nextState: import("algoliasearch-helper").SearchParameters | ((state: import("../../types").IndexUiState) => import("../../types").IndexUiState)) => string;
|
|
156
156
|
} & {
|
|
157
|
-
results:
|
|
157
|
+
results: RecommendResponse<any>;
|
|
158
158
|
})): {
|
|
159
|
-
items:
|
|
159
|
+
items: AlgoliaHit<BaseHit>[] | AlgoliaHit<THit>[];
|
|
160
160
|
widgetParams: TWidgetParams & RelatedProductsConnectorParams<THit>;
|
|
161
161
|
};
|
|
162
162
|
dispose({ recommendState }: import("../../types").DisposeOptions): import("algoliasearch-helper").RecommendParameters;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Connector, TransformItems,
|
|
2
|
-
import type { PlainSearchParameters
|
|
1
|
+
import type { Connector, TransformItems, BaseHit, Renderer, Unmounter, UnknownWidgetParams, RecommendResponse, AlgoliaHit } from '../../types';
|
|
2
|
+
import type { PlainSearchParameters } from 'algoliasearch-helper';
|
|
3
3
|
export type TrendingItemsRenderState<THit extends NonNullable<object> = BaseHit> = {
|
|
4
4
|
/**
|
|
5
5
|
* The matched recommendations from the Algolia API.
|
|
6
6
|
*/
|
|
7
|
-
items: Array<
|
|
7
|
+
items: Array<AlgoliaHit<THit>>;
|
|
8
8
|
};
|
|
9
9
|
export type TrendingItemsConnectorParams<THit extends NonNullable<object> = BaseHit> = ({
|
|
10
10
|
/**
|
|
@@ -44,8 +44,8 @@ export type TrendingItemsConnectorParams<THit extends NonNullable<object> = Base
|
|
|
44
44
|
/**
|
|
45
45
|
* Function to transform the items passed to the templates.
|
|
46
46
|
*/
|
|
47
|
-
transformItems?: TransformItems<
|
|
48
|
-
results:
|
|
47
|
+
transformItems?: TransformItems<AlgoliaHit<THit>, {
|
|
48
|
+
results: RecommendResponse<AlgoliaHit<THit>>;
|
|
49
49
|
}>;
|
|
50
50
|
};
|
|
51
51
|
export type TrendingItemsWidgetDescription<THit extends NonNullable<object> = BaseHit> = {
|
|
@@ -162,9 +162,9 @@ declare const _default: <TWidgetParams extends UnknownWidgetParams>(renderFn: Re
|
|
|
162
162
|
error: import("../../types").InstantSearch["error"];
|
|
163
163
|
createURL: (nextState: import("algoliasearch-helper").SearchParameters | ((state: import("../../types").IndexUiState) => import("../../types").IndexUiState)) => string;
|
|
164
164
|
} & {
|
|
165
|
-
results:
|
|
165
|
+
results: RecommendResponse<any>;
|
|
166
166
|
})): {
|
|
167
|
-
items:
|
|
167
|
+
items: AlgoliaHit<THit>[];
|
|
168
168
|
widgetParams: TWidgetParams & TrendingItemsConnectorParams<THit>;
|
|
169
169
|
};
|
|
170
170
|
dispose({ recommendState }: import("../../types").DisposeOptions): import("algoliasearch-helper").RecommendParameters;
|
|
@@ -47,12 +47,13 @@ var connectVoiceSearch = function connectVoiceSearch(renderFn) {
|
|
|
47
47
|
this._refine = function (query) {
|
|
48
48
|
if (query !== helper.state.query) {
|
|
49
49
|
var queryLanguages = language ? [language.split('-')[0]] : undefined;
|
|
50
|
+
// @ts-ignore queryLanguages is allowed to be a string, not just an array
|
|
50
51
|
helper.setQueryParameter('queryLanguages', queryLanguages);
|
|
51
52
|
if (typeof additionalQueryParameters === 'function') {
|
|
52
53
|
helper.setState(helper.state.setQueryParameters(_objectSpread({
|
|
53
54
|
ignorePlurals: true,
|
|
54
55
|
removeStopWords: true,
|
|
55
|
-
// @ts-ignore
|
|
56
|
+
// @ts-ignore optionalWords is allowed to be a string too
|
|
56
57
|
optionalWords: query
|
|
57
58
|
}, additionalQueryParameters({
|
|
58
59
|
query: query
|
package/es/helpers/highlight.js
CHANGED
|
@@ -21,7 +21,7 @@ export default function highlight(_ref) {
|
|
|
21
21
|
_ref2$value = _ref2.value,
|
|
22
22
|
attributeValue = _ref2$value === void 0 ? '' : _ref2$value;
|
|
23
23
|
|
|
24
|
-
// cx is not used, since it would be bundled as a dependency for Vue
|
|
24
|
+
// cx is not used, since it would be bundled as a dependency for Vue
|
|
25
25
|
var className = suit({
|
|
26
26
|
descendantName: 'highlighted'
|
|
27
27
|
}) + (cssClasses.highlighted ? " ".concat(cssClasses.highlighted) : '');
|
|
@@ -21,7 +21,7 @@ export default function reverseHighlight(_ref) {
|
|
|
21
21
|
_ref2$value = _ref2.value,
|
|
22
22
|
attributeValue = _ref2$value === void 0 ? '' : _ref2$value;
|
|
23
23
|
|
|
24
|
-
// cx is not used, since it would be bundled as a dependency for Vue
|
|
24
|
+
// cx is not used, since it would be bundled as a dependency for Vue
|
|
25
25
|
var className = suit({
|
|
26
26
|
descendantName: 'highlighted'
|
|
27
27
|
}) + (cssClasses.highlighted ? " ".concat(cssClasses.highlighted) : '');
|
|
@@ -21,7 +21,7 @@ export default function reverseSnippet(_ref) {
|
|
|
21
21
|
_ref2$value = _ref2.value,
|
|
22
22
|
attributeValue = _ref2$value === void 0 ? '' : _ref2$value;
|
|
23
23
|
|
|
24
|
-
// cx is not used, since it would be bundled as a dependency for Vue
|
|
24
|
+
// cx is not used, since it would be bundled as a dependency for Vue
|
|
25
25
|
var className = suit({
|
|
26
26
|
descendantName: 'highlighted'
|
|
27
27
|
}) + (cssClasses.highlighted ? " ".concat(cssClasses.highlighted) : '');
|
package/es/helpers/snippet.js
CHANGED
|
@@ -21,7 +21,7 @@ export default function snippet(_ref) {
|
|
|
21
21
|
_ref2$value = _ref2.value,
|
|
22
22
|
attributeValue = _ref2$value === void 0 ? '' : _ref2$value;
|
|
23
23
|
|
|
24
|
-
// cx is not used, since it would be bundled as a dependency for Vue
|
|
24
|
+
// cx is not used, since it would be bundled as a dependency for Vue
|
|
25
25
|
var className = suit({
|
|
26
26
|
descendantName: 'highlighted'
|
|
27
27
|
}) + (cssClasses.highlighted ? " ".concat(cssClasses.highlighted) : '');
|
package/es/index.js
CHANGED
|
@@ -39,5 +39,10 @@ Object.defineProperty(instantsearch, 'connectors', {
|
|
|
39
39
|
throw new ReferenceError("\"instantsearch.connectors\" are not available from the ES build.\n\nTo import the connectors:\n\nimport { connectSearchBox } from 'instantsearch.js/es/connectors'");
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
+
Object.defineProperty(instantsearch, 'templates', {
|
|
43
|
+
get: function get() {
|
|
44
|
+
throw new ReferenceError("\"instantsearch.templates\" are not available from the ES build.\n\nTo import the templates:\n\nimport { carousel } from 'instantsearch.js/es/templates'");
|
|
45
|
+
}
|
|
46
|
+
});
|
|
42
47
|
export default instantsearch;
|
|
43
48
|
export * from "./types/index.js";
|
|
@@ -53,7 +53,7 @@ export function hydrateSearchClient(client, results) {
|
|
|
53
53
|
// search on it first.
|
|
54
54
|
if ('transporter' in client && !client._cacheHydrated) {
|
|
55
55
|
client._cacheHydrated = true;
|
|
56
|
-
var baseMethod = client.search;
|
|
56
|
+
var baseMethod = client.search.bind(client);
|
|
57
57
|
// @ts-ignore wanting type checks for v3 on this would make this too complex
|
|
58
58
|
client.search = function (requests) {
|
|
59
59
|
for (var _len = arguments.length, methodArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
@@ -19,9 +19,9 @@ export declare function createRenderArgs(instantSearchInstance: InstantSearch, p
|
|
|
19
19
|
helper: import("algoliasearch-helper").AlgoliaSearchHelper;
|
|
20
20
|
parent: IndexWidget;
|
|
21
21
|
instantSearchInstance: InstantSearch<UiState, UiState>;
|
|
22
|
-
results: import("algoliasearch
|
|
22
|
+
results: import("algoliasearch").RecommendationsResults | import("algoliasearch-helper").SearchResults<any>;
|
|
23
23
|
scopedResults: import("../../types").ScopedResult[];
|
|
24
|
-
state:
|
|
24
|
+
state: any;
|
|
25
25
|
renderState: import("../../types").RenderState;
|
|
26
26
|
templatesConfig: Record<string, unknown>;
|
|
27
27
|
createURL: (nextState: import("algoliasearch-helper").SearchParameters | ((state: import("../../types").IndexUiState) => import("../../types").IndexUiState)) => string;
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.
|
|
1
|
+
declare const _default: "4.74.1";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.
|
|
1
|
+
export default '4.74.1';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import { html } from 'htm/preact';
|
|
3
|
+
import { h } from 'preact';
|
|
4
|
+
import type { CarouselProps as CarouselUiProps, VNode } from 'instantsearch-ui-components';
|
|
5
|
+
type Template = (params: {
|
|
6
|
+
html: typeof html;
|
|
7
|
+
}) => VNode | VNode[] | null;
|
|
8
|
+
type CreateCarouselTemplateProps<TObject extends Record<string, unknown>> = {
|
|
9
|
+
templates?: Partial<{
|
|
10
|
+
previous: Exclude<Template, string>;
|
|
11
|
+
next: Exclude<Template, string>;
|
|
12
|
+
}>;
|
|
13
|
+
cssClasses?: Partial<CarouselUiProps<TObject>['classNames']>;
|
|
14
|
+
};
|
|
15
|
+
type CarouselTemplateProps<TObject extends Record<string, unknown>> = Pick<CarouselUiProps<TObject>, 'items'> & {
|
|
16
|
+
templates: {
|
|
17
|
+
item?: CarouselUiProps<TObject>['itemComponent'];
|
|
18
|
+
};
|
|
19
|
+
cssClasses?: Partial<CarouselUiProps<TObject>['classNames']>;
|
|
20
|
+
};
|
|
21
|
+
export declare function carousel<TObject extends Record<string, unknown>>({ cssClasses, templates, }?: CreateCarouselTemplateProps<TObject>): ({ items, templates: widgetTemplates, cssClasses: widgetCssClasses, }: CarouselTemplateProps<TObject>) => h.JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
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); }
|
|
8
|
+
import { html } from 'htm/preact';
|
|
9
|
+
import { createCarouselComponent, cx, generateCarouselId } from 'instantsearch-ui-components';
|
|
10
|
+
import { Fragment, h } from 'preact';
|
|
11
|
+
import { useRef } from 'preact/hooks';
|
|
12
|
+
var Carousel = createCarouselComponent({
|
|
13
|
+
createElement: h,
|
|
14
|
+
Fragment: Fragment
|
|
15
|
+
});
|
|
16
|
+
function CarouselWithRefs(props) {
|
|
17
|
+
var carouselRefs = {
|
|
18
|
+
listRef: useRef(null),
|
|
19
|
+
nextButtonRef: useRef(null),
|
|
20
|
+
previousButtonRef: useRef(null),
|
|
21
|
+
carouselIdRef: useRef(generateCarouselId())
|
|
22
|
+
};
|
|
23
|
+
return h(Carousel, _extends({}, carouselRefs, props));
|
|
24
|
+
}
|
|
25
|
+
export function carousel() {
|
|
26
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
27
|
+
cssClasses = _ref.cssClasses,
|
|
28
|
+
_ref$templates = _ref.templates,
|
|
29
|
+
templates = _ref$templates === void 0 ? {} : _ref$templates;
|
|
30
|
+
return function CarouselTemplate(_ref2) {
|
|
31
|
+
var items = _ref2.items,
|
|
32
|
+
widgetTemplates = _ref2.templates,
|
|
33
|
+
_ref2$cssClasses = _ref2.cssClasses,
|
|
34
|
+
widgetCssClasses = _ref2$cssClasses === void 0 ? {} : _ref2$cssClasses;
|
|
35
|
+
var previous = templates.previous,
|
|
36
|
+
next = templates.next;
|
|
37
|
+
return h(CarouselWithRefs, {
|
|
38
|
+
items: items,
|
|
39
|
+
itemComponent: widgetTemplates.item,
|
|
40
|
+
previousIconComponent: previous ? function () {
|
|
41
|
+
return previous({
|
|
42
|
+
html: html
|
|
43
|
+
});
|
|
44
|
+
} : undefined,
|
|
45
|
+
nextIconComponent: next ? function () {
|
|
46
|
+
return next({
|
|
47
|
+
html: html
|
|
48
|
+
});
|
|
49
|
+
} : undefined,
|
|
50
|
+
classNames: _objectSpread(_objectSpread({}, cssClasses), {
|
|
51
|
+
list: cx(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.list, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.list),
|
|
52
|
+
item: cx(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.item, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.item)
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './carousel/carousel';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./carousel/carousel.js";
|
package/es/types/widget.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { IndexWidget } from '../widgets';
|
|
2
|
+
import type { RecommendResponse } from './algoliasearch';
|
|
2
3
|
import type { InstantSearch } from './instantsearch';
|
|
3
4
|
import type { IndexRenderState, WidgetRenderState } from './render-state';
|
|
4
5
|
import type { IndexUiState, UiState } from './ui-state';
|
|
5
6
|
import type { Expand, RequiredKeys } from './utils';
|
|
6
|
-
import type { AlgoliaSearchHelper as Helper, SearchParameters, SearchResults, RecommendParameters
|
|
7
|
+
import type { AlgoliaSearchHelper as Helper, SearchParameters, SearchResults, RecommendParameters } from 'algoliasearch-helper';
|
|
7
8
|
export type ScopedResult = {
|
|
8
9
|
indexId: string;
|
|
9
10
|
results: SearchResults;
|
|
@@ -62,7 +63,7 @@ type SearchWidget<TWidgetDescription extends WidgetDescription> = {
|
|
|
62
63
|
}) => SearchParameters;
|
|
63
64
|
};
|
|
64
65
|
type RecommendRenderOptions = SharedRenderOptions & {
|
|
65
|
-
results:
|
|
66
|
+
results: RecommendResponse<any>;
|
|
66
67
|
};
|
|
67
68
|
type RecommendWidget<TWidgetDescription extends WidgetDescription & WidgetParams> = {
|
|
68
69
|
dependsOn: 'recommend';
|
|
@@ -6,4 +6,5 @@ export type ConfigureRelatedItemsWidget = WidgetFactory<ConfigureRelatedItemsWid
|
|
|
6
6
|
}, ConfigureRelatedItemsConnectorParams, ConfigureRelatedItemsWidgetParams>;
|
|
7
7
|
export type ConfigureRelatedItemsWidgetParams = PlainSearchParameters;
|
|
8
8
|
declare const configureRelatedItems: ConfigureRelatedItemsWidget;
|
|
9
|
+
/** @deprecated use relatedItems instead */
|
|
9
10
|
export default configureRelatedItems;
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
|
|
2
2
|
import type { FrequentlyBoughtTogetherWidgetDescription, FrequentlyBoughtTogetherConnectorParams } from '../../connectors/frequently-bought-together/connectFrequentlyBoughtTogether';
|
|
3
|
-
import type { Template, WidgetFactory,
|
|
4
|
-
import type { RecommendResultItem } from 'algoliasearch-helper';
|
|
3
|
+
import type { Template, WidgetFactory, AlgoliaHit, BaseHit, RecommendResponse } from '../../types';
|
|
5
4
|
import type { RecommendClassNames, FrequentlyBoughtTogetherProps as FrequentlyBoughtTogetherUiProps } from 'instantsearch-ui-components';
|
|
6
5
|
export type FrequentlyBoughtTogetherCSSClasses = Partial<RecommendClassNames>;
|
|
7
6
|
export type FrequentlyBoughtTogetherTemplates<THit extends NonNullable<object> = BaseHit> = Partial<{
|
|
8
7
|
/**
|
|
9
8
|
* Template to use when there are no results.
|
|
10
9
|
*/
|
|
11
|
-
empty: Template<
|
|
10
|
+
empty: Template<RecommendResponse<AlgoliaHit<THit>>>;
|
|
12
11
|
/**
|
|
13
12
|
* Template to use for the header of the widget.
|
|
14
13
|
*/
|
|
15
|
-
header: Template<Pick<Parameters<NonNullable<FrequentlyBoughtTogetherUiProps<
|
|
14
|
+
header: Template<Pick<Parameters<NonNullable<FrequentlyBoughtTogetherUiProps<AlgoliaHit<THit>>['headerComponent']>>[0], 'items'> & {
|
|
16
15
|
cssClasses: RecommendClassNames;
|
|
17
16
|
}>;
|
|
18
17
|
/**
|
|
19
18
|
* Template to use for each result. This template will receive an object containing a single record.
|
|
20
19
|
*/
|
|
21
|
-
item: Template<
|
|
20
|
+
item: Template<AlgoliaHit<THit>>;
|
|
21
|
+
/**
|
|
22
|
+
* Template to use to wrap all items.
|
|
23
|
+
*/
|
|
24
|
+
layout: Template<Pick<Parameters<NonNullable<FrequentlyBoughtTogetherUiProps<AlgoliaHit<THit>>['layout']>>[0], 'items'> & {
|
|
25
|
+
templates: {
|
|
26
|
+
item: FrequentlyBoughtTogetherUiProps<AlgoliaHit<THit>>['itemComponent'];
|
|
27
|
+
};
|
|
28
|
+
cssClasses: Pick<FrequentlyBoughtTogetherCSSClasses, 'list' | 'item'>;
|
|
29
|
+
}>;
|
|
22
30
|
}>;
|
|
23
31
|
type FrequentlyBoughtTogetherWidgetParams<THit extends NonNullable<object> = BaseHit> = {
|
|
24
32
|
/**
|
|
@@ -217,9 +225,9 @@ declare const _default: <THit extends NonNullable<object> = BaseHit>(widgetParam
|
|
|
217
225
|
error: import("../../types").InstantSearch["error"];
|
|
218
226
|
createURL: (nextState: import("algoliasearch-helper").SearchParameters | ((state: import("../../types").IndexUiState) => import("../../types").IndexUiState)) => string;
|
|
219
227
|
} & {
|
|
220
|
-
results:
|
|
228
|
+
results: RecommendResponse<any>;
|
|
221
229
|
})): {
|
|
222
|
-
items:
|
|
230
|
+
items: AlgoliaHit<THit>[];
|
|
223
231
|
widgetParams: Partial<FrequentlyBoughtTogetherWidgetParams<BaseHit>> & FrequentlyBoughtTogetherConnectorParams<THit>;
|
|
224
232
|
};
|
|
225
233
|
dispose({ recommendState }: import("../../types").DisposeOptions): import("algoliasearch-helper").RecommendParameters;
|
|
@@ -60,6 +60,29 @@ var renderer = function renderer(_ref) {
|
|
|
60
60
|
data: results
|
|
61
61
|
}));
|
|
62
62
|
} : undefined;
|
|
63
|
+
var layoutComponent = templates.layout ? function (data) {
|
|
64
|
+
return h(TemplateComponent, _extends({}, renderState.templateProps, {
|
|
65
|
+
templateKey: "layout",
|
|
66
|
+
rootTagName: "fragment",
|
|
67
|
+
data: {
|
|
68
|
+
items: data.items,
|
|
69
|
+
templates: {
|
|
70
|
+
item: templates.item ? function (_ref4) {
|
|
71
|
+
var item = _ref4.item;
|
|
72
|
+
return h(TemplateComponent, _extends({}, renderState.templateProps, {
|
|
73
|
+
templateKey: "item",
|
|
74
|
+
rootTagName: "fragment",
|
|
75
|
+
data: item
|
|
76
|
+
}));
|
|
77
|
+
} : undefined
|
|
78
|
+
},
|
|
79
|
+
cssClasses: {
|
|
80
|
+
list: data.classNames.list,
|
|
81
|
+
item: data.classNames.item
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
} : undefined;
|
|
63
86
|
render(h(FrequentlyBoughtTogether, {
|
|
64
87
|
items: items,
|
|
65
88
|
headerComponent: headerComponent,
|
|
@@ -67,23 +90,24 @@ var renderer = function renderer(_ref) {
|
|
|
67
90
|
sendEvent: function sendEvent() {},
|
|
68
91
|
classNames: cssClasses,
|
|
69
92
|
emptyComponent: emptyComponent,
|
|
93
|
+
layout: layoutComponent,
|
|
70
94
|
status: instantSearchInstance.status
|
|
71
95
|
}), containerNode);
|
|
72
96
|
};
|
|
73
97
|
};
|
|
74
98
|
export default (function frequentlyBoughtTogether(widgetParams) {
|
|
75
|
-
var
|
|
76
|
-
container =
|
|
77
|
-
objectIDs =
|
|
78
|
-
limit =
|
|
79
|
-
queryParameters =
|
|
80
|
-
threshold =
|
|
81
|
-
escapeHTML =
|
|
82
|
-
transformItems =
|
|
83
|
-
|
|
84
|
-
templates =
|
|
85
|
-
|
|
86
|
-
cssClasses =
|
|
99
|
+
var _ref5 = widgetParams || {},
|
|
100
|
+
container = _ref5.container,
|
|
101
|
+
objectIDs = _ref5.objectIDs,
|
|
102
|
+
limit = _ref5.limit,
|
|
103
|
+
queryParameters = _ref5.queryParameters,
|
|
104
|
+
threshold = _ref5.threshold,
|
|
105
|
+
escapeHTML = _ref5.escapeHTML,
|
|
106
|
+
transformItems = _ref5.transformItems,
|
|
107
|
+
_ref5$templates = _ref5.templates,
|
|
108
|
+
templates = _ref5$templates === void 0 ? {} : _ref5$templates,
|
|
109
|
+
_ref5$cssClasses = _ref5.cssClasses,
|
|
110
|
+
cssClasses = _ref5$cssClasses === void 0 ? {} : _ref5$cssClasses;
|
|
87
111
|
if (!container) {
|
|
88
112
|
throw new Error(withUsage('The `container` option is required.'));
|
|
89
113
|
}
|
|
@@ -210,7 +210,7 @@ declare const _default: <THit extends GeoHit = GeoHit>(widgetParams: GeoSearchWi
|
|
|
210
210
|
reset: string | string[];
|
|
211
211
|
}> | undefined>;
|
|
212
212
|
createMarker: CreateMarker;
|
|
213
|
-
markerOptions: GeoSearchMarker<
|
|
213
|
+
markerOptions: GeoSearchMarker<google.maps.MarkerOptions | Partial<HTMLMarkerArguments>>;
|
|
214
214
|
enableRefine: GeoSearchWidgetParams["enableRefine"];
|
|
215
215
|
enableClearMapRefinement: GeoSearchWidgetParams["enableClearMapRefinement"];
|
|
216
216
|
enableRefineControl: GeoSearchWidgetParams["enableRefineControl"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { InstantSearch, UiState, IndexUiState, Widget, ScopedResult } from '../../types';
|
|
2
|
-
import type { AlgoliaSearchHelper as Helper, SearchParameters, SearchResults
|
|
1
|
+
import type { InstantSearch, UiState, IndexUiState, Widget, ScopedResult, RecommendResponse } from '../../types';
|
|
2
|
+
import type { AlgoliaSearchHelper as Helper, SearchParameters, SearchResults } from 'algoliasearch-helper';
|
|
3
3
|
export type IndexWidgetParams = {
|
|
4
4
|
indexName: string;
|
|
5
5
|
indexId?: string;
|
|
@@ -23,7 +23,7 @@ export type IndexWidget<TUiState extends UiState = UiState> = Omit<Widget<IndexW
|
|
|
23
23
|
getIndexId: () => string;
|
|
24
24
|
getHelper: () => Helper | null;
|
|
25
25
|
getResults: () => SearchResults | null;
|
|
26
|
-
getResultsForWidget: (widget: IndexWidget | Widget) => SearchResults |
|
|
26
|
+
getResultsForWidget: (widget: IndexWidget | Widget) => SearchResults | RecommendResponse<any> | null;
|
|
27
27
|
getPreviousState: () => SearchParameters | null;
|
|
28
28
|
getScopedResults: () => ScopedResult[];
|
|
29
29
|
getParent: () => IndexWidget | null;
|
package/es/widgets/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import dynamicWidgets from './dynamic-widgets/dynamic-widgets';
|
|
2
2
|
/** @deprecated answers is no longer supported */
|
|
3
3
|
export declare const EXPERIMENTAL_answers: import("./answers/answers").AnswersWidget;
|
|
4
|
+
/** @deprecated use relatedItems instead */
|
|
5
|
+
export declare const EXPERIMENTAL_configureRelatedItems: import("./configure-related-items/configure-related-items").ConfigureRelatedItemsWidget;
|
|
4
6
|
/** @deprecated use dynamicWidgets */
|
|
5
7
|
export declare const EXPERIMENTAL_dynamicWidgets: import("./dynamic-widgets/dynamic-widgets").DynamicWidgetsWidget;
|
|
6
8
|
export { dynamicWidgets };
|
|
@@ -9,7 +11,6 @@ export { default as breadcrumb } from './breadcrumb/breadcrumb';
|
|
|
9
11
|
export { default as clearRefinements } from './clear-refinements/clear-refinements';
|
|
10
12
|
export { default as configure } from './configure/configure';
|
|
11
13
|
export { default as currentRefinements } from './current-refinements/current-refinements';
|
|
12
|
-
export { default as EXPERIMENTAL_configureRelatedItems } from './configure-related-items/configure-related-items';
|
|
13
14
|
export { default as geoSearch } from './geo-search/geo-search';
|
|
14
15
|
export { default as hierarchicalMenu } from './hierarchical-menu/hierarchical-menu';
|
|
15
16
|
export { default as hits } from './hits/hits';
|