instantsearch.js 4.49.4 → 4.50.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/cjs/components/Pagination/Pagination.js +1 -1
- package/cjs/connectors/hits/connectHits.js +2 -1
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +3 -2
- package/cjs/lib/InstantSearch.js +3 -7
- package/cjs/lib/templating/prepareTemplateProps.js +1 -2
- package/cjs/lib/templating/renderTemplate.js +3 -0
- package/cjs/lib/utils/createSendEventForHits.js +6 -5
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/hits/hits.js +3 -4
- package/cjs/widgets/index/index.js +18 -1
- package/cjs/widgets/infinite-hits/infinite-hits.js +3 -4
- package/dist/instantsearch.development.d.ts +11 -3
- package/dist/instantsearch.development.js +89 -37
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +11 -3
- package/dist/instantsearch.production.min.d.ts +11 -3
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Answers/Answers.d.ts +3 -3
- package/es/components/Breadcrumb/Breadcrumb.d.ts +3 -3
- package/es/components/ClearRefinements/ClearRefinements.d.ts +3 -3
- package/es/components/CurrentRefinements/CurrentRefinements.d.ts +2 -2
- package/es/components/GeoSearchControls/GeoSearchButton.d.ts +1 -1
- package/es/components/GeoSearchControls/GeoSearchControls.d.ts +1 -1
- package/es/components/GeoSearchControls/GeoSearchToggle.d.ts +1 -1
- package/es/components/Highlight/Highlight.d.ts +2 -2
- package/es/components/Hits/Hits.d.ts +3 -3
- package/es/components/InfiniteHits/InfiniteHits.d.ts +3 -3
- package/es/components/MenuSelect/MenuSelect.d.ts +4 -4
- package/es/components/Pagination/Pagination.d.ts +3 -3
- package/es/components/Pagination/Pagination.js +1 -1
- package/es/components/Panel/Panel.d.ts +3 -3
- package/es/components/PoweredBy/PoweredBy.d.ts +2 -2
- package/es/components/QueryRuleCustomData/QueryRuleCustomData.d.ts +3 -3
- package/es/components/RangeInput/RangeInput.d.ts +3 -3
- package/es/components/RefinementList/RefinementList.d.ts +7 -7
- package/es/components/RefinementList/RefinementListItem.d.ts +1 -1
- package/es/components/RelevantSort/RelevantSort.d.ts +3 -3
- package/es/components/ReverseHighlight/ReverseHighlight.d.ts +2 -2
- package/es/components/ReverseSnippet/ReverseSnippet.d.ts +2 -2
- package/es/components/SearchBox/SearchBox.d.ts +5 -5
- package/es/components/Selector/Selector.d.ts +3 -3
- package/es/components/Slider/Rheostat.d.ts +6 -6
- package/es/components/Slider/Slider.d.ts +2 -2
- package/es/components/Snippet/Snippet.d.ts +2 -2
- package/es/components/Stats/Stats.d.ts +3 -3
- package/es/components/Template/Template.d.ts +1 -1
- package/es/components/ToggleRefinement/ToggleRefinement.d.ts +3 -3
- package/es/components/VoiceSearch/VoiceSearch.d.ts +3 -3
- package/es/connectors/answers/connectAnswers.d.ts +4 -4
- package/es/connectors/autocomplete/connectAutocomplete.d.ts +4 -4
- package/es/connectors/breadcrumb/connectBreadcrumb.d.ts +5 -5
- package/es/connectors/clear-refinements/connectClearRefinements.d.ts +4 -4
- package/es/connectors/configure/connectConfigure.d.ts +5 -5
- package/es/connectors/configure-related-items/connectConfigureRelatedItems.d.ts +5 -5
- package/es/connectors/current-refinements/connectCurrentRefinements.d.ts +6 -6
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +4 -4
- package/es/connectors/geo-search/connectGeoSearch.d.ts +6 -6
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.d.ts +5 -5
- package/es/connectors/hits/connectHits.d.ts +4 -4
- package/es/connectors/hits/connectHits.js +2 -1
- package/es/connectors/hits-per-page/connectHitsPerPage.d.ts +6 -6
- package/es/connectors/infinite-hits/connectInfiniteHits.d.ts +8 -8
- package/es/connectors/infinite-hits/connectInfiniteHits.js +3 -2
- package/es/connectors/menu/connectMenu.d.ts +5 -5
- package/es/connectors/numeric-menu/connectNumericMenu.d.ts +6 -6
- package/es/connectors/pagination/connectPagination.d.ts +4 -4
- package/es/connectors/powered-by/connectPoweredBy.d.ts +4 -4
- package/es/connectors/query-rules/connectQueryRules.d.ts +7 -7
- package/es/connectors/range/connectRange.d.ts +8 -8
- package/es/connectors/rating-menu/connectRatingMenu.d.ts +6 -6
- package/es/connectors/refinement-list/connectRefinementList.d.ts +5 -5
- package/es/connectors/relevant-sort/connectRelevantSort.d.ts +5 -5
- package/es/connectors/search-box/connectSearchBox.d.ts +4 -4
- package/es/connectors/sort-by/connectSortBy.d.ts +5 -5
- package/es/connectors/stats/connectStats.d.ts +4 -4
- package/es/connectors/toggle-refinement/connectToggleRefinement.d.ts +9 -9
- package/es/connectors/toggle-refinement/types.d.ts +5 -5
- package/es/connectors/voice-search/connectVoiceSearch.d.ts +4 -4
- package/es/helpers/components/Highlight.d.ts +1 -1
- package/es/helpers/components/ReverseHighlight.d.ts +1 -1
- package/es/helpers/components/ReverseSnippet.d.ts +1 -1
- package/es/helpers/components/Snippet.d.ts +1 -1
- package/es/helpers/highlight.d.ts +1 -1
- package/es/helpers/reverseHighlight.d.ts +1 -1
- package/es/helpers/reverseSnippet.d.ts +1 -1
- package/es/helpers/snippet.d.ts +1 -1
- package/es/index.d.ts +1 -1
- package/es/lib/InstantSearch.d.ts +3 -3
- package/es/lib/InstantSearch.js +3 -7
- package/es/lib/createHelpers.d.ts +1 -1
- package/es/lib/insights/listener.d.ts +1 -1
- package/es/lib/routers/history.d.ts +3 -3
- package/es/lib/suit.d.ts +2 -2
- package/es/lib/templating/prepareTemplateProps.d.ts +2 -2
- package/es/lib/templating/prepareTemplateProps.js +1 -2
- package/es/lib/templating/renderTemplate.js +3 -0
- package/es/lib/utils/checkIndexUiState.d.ts +1 -1
- package/es/lib/utils/createConcurrentSafePromise.d.ts +2 -2
- package/es/lib/utils/createSendEventForFacet.d.ts +4 -4
- package/es/lib/utils/createSendEventForHits.d.ts +8 -7
- package/es/lib/utils/createSendEventForHits.js +6 -5
- package/es/lib/utils/debounce.d.ts +2 -2
- package/es/lib/utils/defer.d.ts +2 -2
- package/es/lib/utils/documentation.d.ts +2 -2
- package/es/lib/utils/escapeFacetValue.d.ts +1 -1
- package/es/lib/utils/geo-search.d.ts +1 -1
- package/es/lib/utils/getRefinements.d.ts +6 -6
- package/es/lib/utils/logger.d.ts +2 -2
- package/es/lib/utils/range.d.ts +1 -1
- package/es/lib/utils/safelyRunOnBrowser.d.ts +2 -2
- package/es/lib/utils/toArray.d.ts +1 -1
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/lib/voiceSearchHelper/types.d.ts +5 -5
- package/es/middlewares/createInsightsMiddleware.d.ts +3 -3
- package/es/middlewares/createRouterMiddleware.d.ts +1 -1
- package/es/types/component.d.ts +1 -1
- package/es/types/connector.d.ts +4 -4
- package/es/types/insights.d.ts +5 -5
- package/es/types/middleware.d.ts +4 -4
- package/es/types/render-state.d.ts +5 -5
- package/es/types/results.d.ts +16 -16
- package/es/types/router.d.ts +2 -2
- package/es/types/templates.d.ts +14 -6
- package/es/types/ui-state.d.ts +4 -4
- package/es/types/utils.d.ts +6 -6
- package/es/types/widget-factory.d.ts +2 -2
- package/es/types/widget.d.ts +23 -23
- package/es/widgets/analytics/analytics.d.ts +4 -4
- package/es/widgets/answers/answers.d.ts +4 -4
- package/es/widgets/breadcrumb/breadcrumb.d.ts +4 -4
- package/es/widgets/clear-refinements/clear-refinements.d.ts +4 -4
- package/es/widgets/configure/configure.d.ts +2 -2
- package/es/widgets/configure-related-items/configure-related-items.d.ts +2 -2
- package/es/widgets/current-refinements/current-refinements.d.ts +3 -3
- package/es/widgets/dynamic-widgets/dynamic-widgets.d.ts +2 -2
- package/es/widgets/geo-search/createHTMLMarker.d.ts +1 -1
- package/es/widgets/geo-search/geo-search.d.ts +7 -7
- package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +6 -6
- package/es/widgets/hits/hits.d.ts +4 -4
- package/es/widgets/hits/hits.js +3 -4
- package/es/widgets/hits-per-page/hits-per-page.d.ts +3 -3
- package/es/widgets/index/index.d.ts +5 -5
- package/es/widgets/index/index.js +18 -1
- package/es/widgets/infinite-hits/infinite-hits.d.ts +4 -4
- package/es/widgets/infinite-hits/infinite-hits.js +3 -4
- package/es/widgets/menu/menu.d.ts +6 -6
- package/es/widgets/menu-select/menu-select.d.ts +4 -4
- package/es/widgets/numeric-menu/numeric-menu.d.ts +6 -6
- package/es/widgets/pagination/pagination.d.ts +4 -4
- package/es/widgets/panel/panel.d.ts +9 -9
- package/es/widgets/places/places.d.ts +6 -6
- package/es/widgets/powered-by/powered-by.d.ts +3 -3
- package/es/widgets/query-rule-context/query-rule-context.d.ts +2 -2
- package/es/widgets/query-rule-custom-data/query-rule-custom-data.d.ts +4 -4
- package/es/widgets/range-input/range-input.d.ts +4 -4
- package/es/widgets/range-slider/range-slider.d.ts +4 -4
- package/es/widgets/rating-menu/rating-menu.d.ts +6 -6
- package/es/widgets/refinement-list/refinement-list.d.ts +10 -10
- package/es/widgets/relevant-sort/relevant-sort.d.ts +4 -4
- package/es/widgets/search-box/search-box.d.ts +4 -4
- package/es/widgets/sort-by/sort-by.d.ts +4 -4
- package/es/widgets/stats/stats.d.ts +5 -5
- package/es/widgets/toggle-refinement/toggle-refinement.d.ts +4 -4
- package/es/widgets/voice-search/voice-search.d.ts +5 -5
- package/package.json +7 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Connector, CreateURL, WidgetRenderState } from '../../types';
|
|
2
2
|
import type { InsightsEvent } from '../../middlewares';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
type SendEvent = (...args: [InsightsEvent] | [string, string, string?]) => void;
|
|
4
|
+
type StarRatingItems = {
|
|
5
5
|
/**
|
|
6
6
|
* Name corresponding to the number of stars.
|
|
7
7
|
*/
|
|
@@ -27,7 +27,7 @@ declare type StarRatingItems = {
|
|
|
27
27
|
*/
|
|
28
28
|
isRefined: boolean;
|
|
29
29
|
};
|
|
30
|
-
export
|
|
30
|
+
export type RatingMenuConnectorParams = {
|
|
31
31
|
/**
|
|
32
32
|
* Name of the attribute for faceting (eg. "free_shipping").
|
|
33
33
|
*/
|
|
@@ -37,7 +37,7 @@ export declare type RatingMenuConnectorParams = {
|
|
|
37
37
|
*/
|
|
38
38
|
max?: number;
|
|
39
39
|
};
|
|
40
|
-
export
|
|
40
|
+
export type RatingMenuRenderState = {
|
|
41
41
|
/**
|
|
42
42
|
* Possible star ratings the user can apply.
|
|
43
43
|
*/
|
|
@@ -65,7 +65,7 @@ export declare type RatingMenuRenderState = {
|
|
|
65
65
|
*/
|
|
66
66
|
sendEvent: SendEvent;
|
|
67
67
|
};
|
|
68
|
-
export
|
|
68
|
+
export type RatingMenuWidgetDescription = {
|
|
69
69
|
$$type: 'ais.ratingMenu';
|
|
70
70
|
renderState: RatingMenuRenderState;
|
|
71
71
|
indexRenderState: {
|
|
@@ -79,7 +79,7 @@ export declare type RatingMenuWidgetDescription = {
|
|
|
79
79
|
};
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
|
-
export
|
|
82
|
+
export type RatingMenuConnector = Connector<RatingMenuWidgetDescription, RatingMenuConnectorParams>;
|
|
83
83
|
/**
|
|
84
84
|
* **StarRating** connector provides the logic to build a custom widget that will let
|
|
85
85
|
* the user refine search results based on ratings.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
2
2
|
import type { SendEventForFacet } from '../../lib/utils';
|
|
3
3
|
import type { Connector, TransformItems, SortBy, CreateURL, WidgetRenderState } from '../../types';
|
|
4
|
-
export
|
|
4
|
+
export type RefinementListItem = {
|
|
5
5
|
/**
|
|
6
6
|
* The value of the refinement list item.
|
|
7
7
|
*/
|
|
@@ -23,7 +23,7 @@ export declare type RefinementListItem = {
|
|
|
23
23
|
*/
|
|
24
24
|
isRefined: boolean;
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export type RefinementListConnectorParams = {
|
|
27
27
|
/**
|
|
28
28
|
* The name of the attribute in the records.
|
|
29
29
|
*/
|
|
@@ -63,7 +63,7 @@ export declare type RefinementListConnectorParams = {
|
|
|
63
63
|
*/
|
|
64
64
|
transformItems?: TransformItems<RefinementListItem>;
|
|
65
65
|
};
|
|
66
|
-
export
|
|
66
|
+
export type RefinementListRenderState = {
|
|
67
67
|
/**
|
|
68
68
|
* The list of filtering values returned from Algolia API.
|
|
69
69
|
*/
|
|
@@ -110,7 +110,7 @@ export declare type RefinementListRenderState = {
|
|
|
110
110
|
*/
|
|
111
111
|
toggleShowMore(): void;
|
|
112
112
|
};
|
|
113
|
-
export
|
|
113
|
+
export type RefinementListWidgetDescription = {
|
|
114
114
|
$$type: 'ais.refinementList';
|
|
115
115
|
renderState: RefinementListRenderState;
|
|
116
116
|
indexRenderState: {
|
|
@@ -124,7 +124,7 @@ export declare type RefinementListWidgetDescription = {
|
|
|
124
124
|
};
|
|
125
125
|
};
|
|
126
126
|
};
|
|
127
|
-
export
|
|
127
|
+
export type RefinementListConnector = Connector<RefinementListWidgetDescription, RefinementListConnectorParams>;
|
|
128
128
|
/**
|
|
129
129
|
* **RefinementList** connector provides the logic to build a custom widget that
|
|
130
130
|
* will let the user filter the results based on the values of a specific facet.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Connector, WidgetRenderState } from '../../types';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export
|
|
2
|
+
export type RelevantSortConnectorParams = Record<string, unknown>;
|
|
3
|
+
type Refine = (relevancyStrictness: number) => void;
|
|
4
|
+
export type RelevantSortRenderState = {
|
|
5
5
|
/**
|
|
6
6
|
* Indicates if it has appliedRelevancyStrictness greater than zero
|
|
7
7
|
*/
|
|
@@ -19,7 +19,7 @@ export declare type RelevantSortRenderState = {
|
|
|
19
19
|
*/
|
|
20
20
|
refine: Refine;
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export type RelevantSortWidgetDescription = {
|
|
23
23
|
$$type: 'ais.relevantSort';
|
|
24
24
|
renderState: RelevantSortRenderState;
|
|
25
25
|
indexRenderState: {
|
|
@@ -29,6 +29,6 @@ export declare type RelevantSortWidgetDescription = {
|
|
|
29
29
|
relevantSort: number;
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
-
export
|
|
32
|
+
export type RelevantSortConnector = Connector<RelevantSortWidgetDescription, RelevantSortConnectorParams>;
|
|
33
33
|
declare const connectRelevantSort: RelevantSortConnector;
|
|
34
34
|
export default connectRelevantSort;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Connector, WidgetRenderState } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export type SearchBoxConnectorParams = {
|
|
3
3
|
/**
|
|
4
4
|
* A function that will be called every time
|
|
5
5
|
* a new value for the query is set. The first parameter is the query and the second is a
|
|
@@ -17,7 +17,7 @@ export declare type SearchBoxConnectorParams = {
|
|
|
17
17
|
*
|
|
18
18
|
* This queryHook can be used to debounce the number of searches done from the searchBox.
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export type SearchBoxRenderState = {
|
|
21
21
|
/**
|
|
22
22
|
* The query from the last search.
|
|
23
23
|
*/
|
|
@@ -38,7 +38,7 @@ export declare type SearchBoxRenderState = {
|
|
|
38
38
|
*/
|
|
39
39
|
isSearchStalled: boolean;
|
|
40
40
|
};
|
|
41
|
-
export
|
|
41
|
+
export type SearchBoxWidgetDescription = {
|
|
42
42
|
$$type: 'ais.searchBox';
|
|
43
43
|
renderState: SearchBoxRenderState;
|
|
44
44
|
indexRenderState: {
|
|
@@ -48,7 +48,7 @@ export declare type SearchBoxWidgetDescription = {
|
|
|
48
48
|
query: string;
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
|
-
export
|
|
51
|
+
export type SearchBoxConnector = Connector<SearchBoxWidgetDescription, SearchBoxConnectorParams>;
|
|
52
52
|
/**
|
|
53
53
|
* **SearchBox** connector provides the logic to build a widget that will let the user search for a query.
|
|
54
54
|
*
|
|
@@ -4,7 +4,7 @@ import type { Connector, TransformItems, WidgetRenderState } from '../../types';
|
|
|
4
4
|
* list of indices. With Algolia, this is most commonly used for changing ranking strategy. This allows
|
|
5
5
|
* a user to change how the hits are being sorted.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type SortByItem = {
|
|
8
8
|
/**
|
|
9
9
|
* The name of the index to target.
|
|
10
10
|
*/
|
|
@@ -14,7 +14,7 @@ export declare type SortByItem = {
|
|
|
14
14
|
*/
|
|
15
15
|
label: string;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type SortByConnectorParams = {
|
|
18
18
|
/**
|
|
19
19
|
* Array of objects defining the different indices to choose from.
|
|
20
20
|
*/
|
|
@@ -24,7 +24,7 @@ export declare type SortByConnectorParams = {
|
|
|
24
24
|
*/
|
|
25
25
|
transformItems?: TransformItems<SortByItem>;
|
|
26
26
|
};
|
|
27
|
-
export
|
|
27
|
+
export type SortByRenderState = {
|
|
28
28
|
/**
|
|
29
29
|
* The initially selected index.
|
|
30
30
|
*/
|
|
@@ -51,7 +51,7 @@ export declare type SortByRenderState = {
|
|
|
51
51
|
*/
|
|
52
52
|
canRefine: boolean;
|
|
53
53
|
};
|
|
54
|
-
export
|
|
54
|
+
export type SortByWidgetDescription = {
|
|
55
55
|
$$type: 'ais.sortBy';
|
|
56
56
|
renderState: SortByRenderState;
|
|
57
57
|
indexRenderState: {
|
|
@@ -61,6 +61,6 @@ export declare type SortByWidgetDescription = {
|
|
|
61
61
|
sortBy: string;
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
|
-
export
|
|
64
|
+
export type SortByConnector = Connector<SortByWidgetDescription, SortByConnectorParams>;
|
|
65
65
|
declare const connectSortBy: SortByConnector;
|
|
66
66
|
export default connectSortBy;
|
|
@@ -3,7 +3,7 @@ import type { Connector, WidgetRenderState } from '../../types';
|
|
|
3
3
|
* **Stats** connector provides the logic to build a custom widget that will displays
|
|
4
4
|
* search statistics (hits number and processing time).
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type StatsRenderState = {
|
|
7
7
|
/**
|
|
8
8
|
* The maximum number of hits per page returned by Algolia.
|
|
9
9
|
*/
|
|
@@ -37,14 +37,14 @@ export declare type StatsRenderState = {
|
|
|
37
37
|
*/
|
|
38
38
|
query: string;
|
|
39
39
|
};
|
|
40
|
-
export
|
|
41
|
-
export
|
|
40
|
+
export type StatsConnectorParams = Record<string, unknown>;
|
|
41
|
+
export type StatsWidgetDescription = {
|
|
42
42
|
$$type: 'ais.stats';
|
|
43
43
|
renderState: StatsRenderState;
|
|
44
44
|
indexRenderState: {
|
|
45
45
|
stats: WidgetRenderState<StatsRenderState, StatsConnectorParams>;
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
|
-
export
|
|
48
|
+
export type StatsConnector = Connector<StatsWidgetDescription, StatsConnectorParams>;
|
|
49
49
|
declare const connectStats: StatsConnector;
|
|
50
50
|
export default connectStats;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Connector, CreateURL, WidgetRenderState } from '../../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export
|
|
2
|
+
type BuiltInSendEventForToggle = (eventType: string, isRefined: boolean, eventName?: string) => void;
|
|
3
|
+
type CustomSendEventForToggle = (customPayload: any) => void;
|
|
4
|
+
export type SendEventForToggle = BuiltInSendEventForToggle & CustomSendEventForToggle;
|
|
5
|
+
export type ToggleRefinementValue = {
|
|
6
6
|
/**
|
|
7
7
|
* Whether this option is enabled.
|
|
8
8
|
*/
|
|
@@ -12,7 +12,7 @@ export declare type ToggleRefinementValue = {
|
|
|
12
12
|
*/
|
|
13
13
|
count: number | null;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type ToggleRefinementConnectorParams = {
|
|
16
16
|
/**
|
|
17
17
|
* Name of the attribute for faceting (e.g., "free_shipping").
|
|
18
18
|
*/
|
|
@@ -27,8 +27,8 @@ export declare type ToggleRefinementConnectorParams = {
|
|
|
27
27
|
*/
|
|
28
28
|
off?: FacetValue | FacetValue[];
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
export
|
|
30
|
+
type FacetValue = string | boolean | number;
|
|
31
|
+
export type ToggleRefinementRenderState = {
|
|
32
32
|
/** The current toggle value */
|
|
33
33
|
value: {
|
|
34
34
|
/**
|
|
@@ -71,7 +71,7 @@ export declare type ToggleRefinementRenderState = {
|
|
|
71
71
|
isRefined: boolean;
|
|
72
72
|
}) => void;
|
|
73
73
|
};
|
|
74
|
-
export
|
|
74
|
+
export type ToggleRefinementWidgetDescription = {
|
|
75
75
|
$$type: 'ais.toggleRefinement';
|
|
76
76
|
renderState: ToggleRefinementRenderState;
|
|
77
77
|
indexRenderState: {
|
|
@@ -85,7 +85,7 @@ export declare type ToggleRefinementWidgetDescription = {
|
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
|
-
export
|
|
88
|
+
export type ToggleRefinementConnector = Connector<ToggleRefinementWidgetDescription, ToggleRefinementConnectorParams>;
|
|
89
89
|
/**
|
|
90
90
|
* **Toggle** connector provides the logic to build a custom widget that will provide
|
|
91
91
|
* an on/off filtering feature based on an attribute value or values.
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { SendEventForFacet } from '../../lib/utils';
|
|
2
2
|
import type { Connector, CreateURL, WidgetRenderState } from '../../types';
|
|
3
|
-
|
|
3
|
+
type ToggleRefinementConnectorParams = {
|
|
4
4
|
attribute: string;
|
|
5
5
|
on: string | string[];
|
|
6
6
|
off: string | string[];
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type FacetValue = {
|
|
9
9
|
isRefined: boolean;
|
|
10
10
|
count: number;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type ToggleRefinementRenderState = {
|
|
13
13
|
value: {
|
|
14
14
|
name: string;
|
|
15
15
|
isRefined: boolean;
|
|
@@ -22,7 +22,7 @@ declare type ToggleRefinementRenderState = {
|
|
|
22
22
|
canRefine: boolean;
|
|
23
23
|
refine: (value: string) => void;
|
|
24
24
|
};
|
|
25
|
-
export
|
|
25
|
+
export type ToggleRefinementWidgetDescription = {
|
|
26
26
|
$$type: 'ais.toggleRefinement';
|
|
27
27
|
renderState: ToggleRefinementRenderState;
|
|
28
28
|
indexRenderState: {
|
|
@@ -36,5 +36,5 @@ export declare type ToggleRefinementWidgetDescription = {
|
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
|
-
export
|
|
39
|
+
export type ToggleRefinementConnector = Connector<ToggleRefinementWidgetDescription, ToggleRefinementConnectorParams>;
|
|
40
40
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PlainSearchParameters } from 'algoliasearch-helper';
|
|
2
2
|
import type { Connector, WidgetRenderState } from '../../types';
|
|
3
3
|
import type { CreateVoiceSearchHelper, VoiceListeningState } from '../../lib/voiceSearchHelper/types';
|
|
4
|
-
export
|
|
4
|
+
export type VoiceSearchConnectorParams = {
|
|
5
5
|
searchAsYouSpeak?: boolean;
|
|
6
6
|
language?: string;
|
|
7
7
|
additionalQueryParameters?: (params: {
|
|
@@ -9,13 +9,13 @@ export declare type VoiceSearchConnectorParams = {
|
|
|
9
9
|
}) => PlainSearchParameters | void;
|
|
10
10
|
createVoiceSearchHelper?: CreateVoiceSearchHelper;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type VoiceSearchRenderState = {
|
|
13
13
|
isBrowserSupported: boolean;
|
|
14
14
|
isListening: boolean;
|
|
15
15
|
toggleListening: () => void;
|
|
16
16
|
voiceListeningState: VoiceListeningState;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type VoiceSearchWidgetDescription = {
|
|
19
19
|
$$type: 'ais.voiceSearch';
|
|
20
20
|
renderState: VoiceSearchRenderState;
|
|
21
21
|
indexRenderState: {
|
|
@@ -25,6 +25,6 @@ export declare type VoiceSearchWidgetDescription = {
|
|
|
25
25
|
query: string;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
export
|
|
28
|
+
export type VoiceSearchConnector = Connector<VoiceSearchWidgetDescription, VoiceSearchConnectorParams>;
|
|
29
29
|
declare const connectVoiceSearch: VoiceSearchConnector;
|
|
30
30
|
export default connectVoiceSearch;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { h } from 'preact';
|
|
3
3
|
import type { BaseHit, Hit, PartialKeys } from '../../types';
|
|
4
4
|
import type { HighlightProps as HighlightUiComponentProps } from '../../components/Highlight/Highlight';
|
|
5
|
-
export
|
|
5
|
+
export type HighlightProps<THit extends Hit<BaseHit>> = {
|
|
6
6
|
hit: THit;
|
|
7
7
|
attribute: keyof THit | string[];
|
|
8
8
|
cssClasses?: HighlightUiComponentProps['classNames'];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { h } from 'preact';
|
|
3
3
|
import type { BaseHit, Hit, PartialKeys } from '../../types';
|
|
4
4
|
import type { ReverseHighlightProps as ReverseHighlightUiComponentProps } from '../../components/ReverseHighlight/ReverseHighlight';
|
|
5
|
-
export
|
|
5
|
+
export type ReverseHighlightProps<THit extends Hit<BaseHit>> = {
|
|
6
6
|
hit: THit;
|
|
7
7
|
attribute: keyof THit | string[];
|
|
8
8
|
cssClasses?: ReverseHighlightUiComponentProps['classNames'];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { h } from 'preact';
|
|
3
3
|
import type { BaseHit, Hit, PartialKeys } from '../../types';
|
|
4
4
|
import type { ReverseSnippetProps as ReverseSnippetUiComponentProps } from '../../components/ReverseSnippet/ReverseSnippet';
|
|
5
|
-
export
|
|
5
|
+
export type ReverseSnippetProps<THit extends Hit<BaseHit>> = {
|
|
6
6
|
hit: THit;
|
|
7
7
|
attribute: keyof THit | string[];
|
|
8
8
|
cssClasses?: ReverseSnippetUiComponentProps['classNames'];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { h } from 'preact';
|
|
3
3
|
import type { BaseHit, Hit, PartialKeys } from '../../types';
|
|
4
4
|
import type { SnippetProps as SnippetUiComponentProps } from '../../components/Snippet/Snippet';
|
|
5
|
-
export
|
|
5
|
+
export type SnippetProps<THit extends Hit<BaseHit>> = {
|
|
6
6
|
hit: THit;
|
|
7
7
|
attribute: keyof THit | string[];
|
|
8
8
|
cssClasses?: SnippetUiComponentProps['classNames'];
|
package/es/helpers/snippet.d.ts
CHANGED
package/es/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { InstantSearchOptions } from './lib/InstantSearch';
|
|
|
3
3
|
import InstantSearch from './lib/InstantSearch';
|
|
4
4
|
import { snippet, reverseSnippet, highlight, reverseHighlight, insights, getInsightsAnonymousUserToken } from './helpers';
|
|
5
5
|
import { createInfiniteHitsSessionStorageCache } from './lib/infiniteHitsCache';
|
|
6
|
-
|
|
6
|
+
type InstantSearchModule = {
|
|
7
7
|
<TUiState = Record<string, unknown>, TRouteState = TUiState>(options: InstantSearchOptions<Expand<UiState & TUiState>, TRouteState>): InstantSearch<Expand<UiState & TUiState>, TRouteState>;
|
|
8
8
|
version: string;
|
|
9
9
|
/** @deprecated import { createInfiniteHitsSessionStorageCache } from 'instantsearch.js/es/lib/infiniteHitsCache' */
|
|
@@ -4,11 +4,11 @@ import type { IndexWidget } from '../widgets/index/index';
|
|
|
4
4
|
import type { InsightsClient as AlgoliaInsightsClient, SearchClient, Widget, UiState, CreateURL, Middleware, MiddlewareDefinition, RenderState, InitialResults } from '../types';
|
|
5
5
|
import type { RouterProps } from '../middlewares/createRouterMiddleware';
|
|
6
6
|
import type { InsightsEvent } from '../middlewares/createInsightsMiddleware';
|
|
7
|
-
|
|
7
|
+
type NoInfer<T> = T extends infer S ? S : never;
|
|
8
8
|
/**
|
|
9
9
|
* Global options for an InstantSearch instance.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type InstantSearchOptions<TUiState extends UiState = UiState, TRouteState = TUiState> = {
|
|
12
12
|
/**
|
|
13
13
|
* The name of the main index
|
|
14
14
|
*/
|
|
@@ -86,7 +86,7 @@ export declare type InstantSearchOptions<TUiState extends UiState = UiState, TRo
|
|
|
86
86
|
*/
|
|
87
87
|
insightsClient?: AlgoliaInsightsClient;
|
|
88
88
|
};
|
|
89
|
-
export
|
|
89
|
+
export type InstantSearchStatus = 'idle' | 'loading' | 'stalled' | 'error';
|
|
90
90
|
/**
|
|
91
91
|
* The actual implementation of the InstantSearch. This is
|
|
92
92
|
* created using the `instantsearch` factory function.
|
package/es/lib/InstantSearch.js
CHANGED
|
@@ -73,8 +73,9 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
73
73
|
}
|
|
74
74
|
}));
|
|
75
75
|
_defineProperty(_assertThisInitialized(_this), "scheduleRender", defer(function () {
|
|
76
|
+
var _this$mainHelper;
|
|
76
77
|
var shouldResetStatus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
77
|
-
if (!_this.mainHelper.hasPendingRequests()) {
|
|
78
|
+
if (!((_this$mainHelper = _this.mainHelper) !== null && _this$mainHelper !== void 0 && _this$mainHelper.hasPendingRequests())) {
|
|
78
79
|
clearTimeout(_this._searchStalledTimer);
|
|
79
80
|
_this._searchStalledTimer = null;
|
|
80
81
|
if (shouldResetStatus) {
|
|
@@ -342,12 +343,7 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
342
343
|
var mainHelper = this.mainHelper || algoliasearchHelper(this.client, this.indexName);
|
|
343
344
|
mainHelper.search = function () {
|
|
344
345
|
_this3.status = 'loading';
|
|
345
|
-
|
|
346
|
-
// For now, widgets don't expect to be rendered at the start of `loading`,
|
|
347
|
-
// so it would be a breaking change to add an extra render. We don't have
|
|
348
|
-
// these guarantees about the render event, thus emitting it once more
|
|
349
|
-
// isn't a breaking change.
|
|
350
|
-
_this3.emit('render');
|
|
346
|
+
_this3.scheduleRender(false);
|
|
351
347
|
|
|
352
348
|
// This solution allows us to keep the exact same API for the users but
|
|
353
349
|
// under the hood, we have a different implementation. It should be
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HoganHelpers } from '../types';
|
|
2
|
-
|
|
2
|
+
type DefaultHoganHelpers = HoganHelpers<'formatNumber' | 'highlight' | 'reverseHighlight' | 'snippet' | 'reverseSnippet' | 'insights'>;
|
|
3
3
|
export default function hoganHelpers({ numberLocale, }: {
|
|
4
4
|
numberLocale?: string;
|
|
5
5
|
}): DefaultHoganHelpers;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { h } from 'preact';
|
|
3
3
|
import type { InsightsClient } from '../../types';
|
|
4
4
|
import type { InsightsEvent } from '../../middlewares/createInsightsMiddleware';
|
|
5
|
-
|
|
5
|
+
type WithInsightsListenerProps = {
|
|
6
6
|
[key: string]: unknown;
|
|
7
7
|
insights: InsightsClient;
|
|
8
8
|
sendEvent?: (event: InsightsEvent) => void;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import qs from 'qs';
|
|
2
2
|
import type { Router, UiState } from '../../types';
|
|
3
|
-
|
|
3
|
+
type CreateURL<TRouteState> = (args: {
|
|
4
4
|
qsModule: typeof qs;
|
|
5
5
|
routeState: TRouteState;
|
|
6
6
|
location: Location;
|
|
7
7
|
}) => string;
|
|
8
|
-
|
|
8
|
+
type ParseURL<TRouteState> = (args: {
|
|
9
9
|
qsModule: typeof qs;
|
|
10
10
|
location: Location;
|
|
11
11
|
}) => TRouteState;
|
|
12
|
-
|
|
12
|
+
type BrowserHistoryArgs<TRouteState> = {
|
|
13
13
|
windowTitle?: (routeState: TRouteState) => string;
|
|
14
14
|
writeDelay: number;
|
|
15
15
|
createURL: CreateURL<TRouteState>;
|
package/es/lib/suit.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
type SuitOptions = {
|
|
2
2
|
descendantName?: string;
|
|
3
3
|
modifierName?: string;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
type SuitSelector = (names?: SuitOptions) => string;
|
|
6
6
|
export declare const component: (componentName: string) => SuitSelector;
|
|
7
7
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { HoganHelpers, Templates } from '../../types';
|
|
2
2
|
import type { HoganOptions } from 'hogan.js';
|
|
3
|
-
|
|
3
|
+
type TemplatesConfig = {
|
|
4
4
|
helpers?: HoganHelpers;
|
|
5
5
|
compileOptions?: HoganOptions;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type PreparedTemplateProps<TTemplates extends Templates> = {
|
|
8
8
|
templatesConfig: TemplatesConfig;
|
|
9
9
|
templates: TTemplates;
|
|
10
10
|
useCustomCompileOptions: {
|
|
@@ -20,8 +20,7 @@ defaultTemplates) {
|
|
|
20
20
|
var defaultTemplate = defaultTemplates ? defaultTemplates[key] : undefined;
|
|
21
21
|
var customTemplate = templates[key];
|
|
22
22
|
var isCustomTemplate = customTemplate !== undefined && customTemplate !== defaultTemplate;
|
|
23
|
-
config.templates[key] = isCustomTemplate ? customTemplate
|
|
24
|
-
: defaultTemplate;
|
|
23
|
+
config.templates[key] = isCustomTemplate ? customTemplate : defaultTemplate;
|
|
25
24
|
config.useCustomCompileOptions[key] = isCustomTemplate;
|
|
26
25
|
return config;
|
|
27
26
|
}, {
|
|
@@ -50,6 +50,9 @@ export function renderTemplate(_ref) {
|
|
|
50
50
|
Snippet: Snippet,
|
|
51
51
|
ReverseSnippet: ReverseSnippet
|
|
52
52
|
};
|
|
53
|
+
|
|
54
|
+
// @MAJOR remove the `as any` when string templates are removed
|
|
55
|
+
// needed because not every template receives sendEvent
|
|
53
56
|
return template(data, params);
|
|
54
57
|
}
|
|
55
58
|
var transformedHelpers = transformHelpersToHogan(helpers, compileOptions, data);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type MaybePromise<TResolution> = Readonly<Promise<TResolution>> | Promise<TResolution> | TResolution;
|
|
2
2
|
/**
|
|
3
3
|
* Creates a runner that executes promises in a concurrent-safe way.
|
|
4
4
|
*
|
|
5
5
|
* This is useful to prevent older promises to resolve after a newer promise,
|
|
6
6
|
* otherwise resulting in stale resolved values.
|
|
7
7
|
*/
|
|
8
|
-
export declare function createConcurrentSafePromise<TValue>(): (promise: MaybePromise<TValue>) => Promise<TValue
|
|
8
|
+
export declare function createConcurrentSafePromise<TValue>(): (promise: MaybePromise<TValue>) => Promise<NonNullable<TValue> | Awaited<TValue>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
|
|
2
2
|
import type { InstantSearch } from '../../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
3
|
+
type BuiltInSendEventForFacet = (eventType: string, facetValue: string, eventName?: string) => void;
|
|
4
|
+
type CustomSendEventForFacet = (customPayload: any) => void;
|
|
5
|
+
export type SendEventForFacet = BuiltInSendEventForFacet & CustomSendEventForFacet;
|
|
6
|
+
type CreateSendEventForFacetOptions = {
|
|
7
7
|
instantSearchInstance: InstantSearch;
|
|
8
8
|
helper: AlgoliaSearchHelper;
|
|
9
9
|
attribute: string | ((facetValue: string) => string);
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { InstantSearch, Hit } from '../../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
2
|
+
type BuiltInSendEventForHits = (eventType: string, hits: Hit | Hit[], eventName?: string) => void;
|
|
3
|
+
type CustomSendEventForHits = (customPayload: any) => void;
|
|
4
|
+
export type SendEventForHits = BuiltInSendEventForHits & CustomSendEventForHits;
|
|
5
|
+
export type BuiltInBindEventForHits = (eventType: string, hits: Hit | Hit[], eventName?: string) => string;
|
|
6
|
+
export type CustomBindEventForHits = (customPayload: any) => string;
|
|
7
|
+
export type BindEventForHits = BuiltInBindEventForHits & CustomBindEventForHits;
|
|
8
8
|
export declare function createSendEventForHits({ instantSearchInstance, index, widgetType, }: {
|
|
9
9
|
instantSearchInstance: InstantSearch;
|
|
10
10
|
index: string;
|
|
11
11
|
widgetType: string;
|
|
12
12
|
}): SendEventForHits;
|
|
13
|
-
export declare function createBindEventForHits({ index, widgetType, }: {
|
|
13
|
+
export declare function createBindEventForHits({ index, widgetType, instantSearchInstance, }: {
|
|
14
14
|
index: string;
|
|
15
15
|
widgetType: string;
|
|
16
|
+
instantSearchInstance: InstantSearch;
|
|
16
17
|
}): BindEventForHits;
|
|
17
18
|
export {};
|