instantsearch.js 4.50.0 → 4.50.2
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/connectors/infinite-hits/connectInfiniteHits.js +8 -1
- package/cjs/lib/templating/prepareTemplateProps.js +1 -2
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/hits/hits.js +3 -4
- package/cjs/widgets/index/index.js +3 -0
- package/cjs/widgets/infinite-hits/infinite-hits.js +3 -4
- package/dist/instantsearch.development.d.ts +2 -1
- package/dist/instantsearch.development.js +36 -19
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +2 -1
- package/dist/instantsearch.production.min.d.ts +2 -1
- 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/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-per-page/connectHitsPerPage.d.ts +6 -6
- package/es/connectors/infinite-hits/connectInfiniteHits.d.ts +8 -8
- package/es/connectors/infinite-hits/connectInfiniteHits.js +8 -1
- 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/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/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 +6 -6
- 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 +5 -5
- 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 +6 -5
- package/es/widgets/index/index.js +3 -0
- 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 +6 -5
|
@@ -3,21 +3,21 @@ import type { Connector, WidgetRenderState } from '../../types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Refine the given search parameters.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
type Refine = (searchParameters: PlainSearchParameters) => void;
|
|
7
|
+
export type ConfigureConnectorParams = {
|
|
8
8
|
/**
|
|
9
9
|
* A list of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/)
|
|
10
10
|
* to enable when the widget mounts.
|
|
11
11
|
*/
|
|
12
12
|
searchParameters: PlainSearchParameters;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type ConfigureRenderState = {
|
|
15
15
|
/**
|
|
16
16
|
* Refine the given search parameters.
|
|
17
17
|
*/
|
|
18
18
|
refine: Refine;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type ConfigureWidgetDescription = {
|
|
21
21
|
$$type: 'ais.configure';
|
|
22
22
|
renderState: ConfigureRenderState;
|
|
23
23
|
indexRenderState: {
|
|
@@ -27,6 +27,6 @@ export declare type ConfigureWidgetDescription = {
|
|
|
27
27
|
configure: PlainSearchParameters;
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
export
|
|
30
|
+
export type ConfigureConnector = Connector<ConfigureWidgetDescription, ConfigureConnectorParams>;
|
|
31
31
|
declare const connectConfigure: ConfigureConnector;
|
|
32
32
|
export default connectConfigure;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SearchParameters, PlainSearchParameters } from 'algoliasearch-helper';
|
|
2
2
|
import type { AlgoliaHit, Connector } from '../../types';
|
|
3
3
|
import type { ConfigureWidgetDescription } from '../configure/connectConfigure';
|
|
4
|
-
export
|
|
4
|
+
export type MatchingPatterns = {
|
|
5
5
|
[attribute: string]: {
|
|
6
6
|
/**
|
|
7
7
|
* The score of the optional filter.
|
|
@@ -11,8 +11,8 @@ export declare type MatchingPatterns = {
|
|
|
11
11
|
score: number;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export
|
|
15
|
-
export
|
|
14
|
+
export type TransformSearchParameters = (searchParameters: SearchParameters) => PlainSearchParameters;
|
|
15
|
+
export type ConfigureRelatedItemsConnectorParams = {
|
|
16
16
|
/**
|
|
17
17
|
* The reference hit to extract the filters from.
|
|
18
18
|
*/
|
|
@@ -27,9 +27,9 @@ export declare type ConfigureRelatedItemsConnectorParams = {
|
|
|
27
27
|
*/
|
|
28
28
|
transformSearchParameters?: TransformSearchParameters;
|
|
29
29
|
};
|
|
30
|
-
export
|
|
30
|
+
export type ConfigureRelatedItemsWidgetDescription = {
|
|
31
31
|
$$type: 'ais.configureRelatedItems';
|
|
32
32
|
} & Omit<ConfigureWidgetDescription, '$$type'>;
|
|
33
|
-
export
|
|
33
|
+
export type ConfigureRelatedItemsConnector = Connector<ConfigureRelatedItemsWidgetDescription, ConfigureRelatedItemsConnectorParams>;
|
|
34
34
|
declare const connectConfigureRelatedItems: ConfigureRelatedItemsConnector;
|
|
35
35
|
export default connectConfigureRelatedItems;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Connector, TransformItems, CreateURL, WidgetRenderState } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export type CurrentRefinementsConnectorParamsRefinement = {
|
|
3
3
|
/**
|
|
4
4
|
* The attribute on which the refinement is applied.
|
|
5
5
|
*/
|
|
@@ -29,7 +29,7 @@ export declare type CurrentRefinementsConnectorParamsRefinement = {
|
|
|
29
29
|
*/
|
|
30
30
|
exhaustive?: boolean;
|
|
31
31
|
};
|
|
32
|
-
export
|
|
32
|
+
export type CurrentRefinementsConnectorParamsItem = {
|
|
33
33
|
/**
|
|
34
34
|
* The index name.
|
|
35
35
|
*/
|
|
@@ -51,7 +51,7 @@ export declare type CurrentRefinementsConnectorParamsItem = {
|
|
|
51
51
|
*/
|
|
52
52
|
refine(refinement: CurrentRefinementsConnectorParamsRefinement): void;
|
|
53
53
|
};
|
|
54
|
-
export
|
|
54
|
+
export type CurrentRefinementsConnectorParams = {
|
|
55
55
|
/**
|
|
56
56
|
* The attributes to include in the widget (all by default).
|
|
57
57
|
* Cannot be used with `excludedAttributes`.
|
|
@@ -71,7 +71,7 @@ export declare type CurrentRefinementsConnectorParams = {
|
|
|
71
71
|
*/
|
|
72
72
|
transformItems?: TransformItems<CurrentRefinementsConnectorParamsItem>;
|
|
73
73
|
};
|
|
74
|
-
export
|
|
74
|
+
export type CurrentRefinementsRenderState = {
|
|
75
75
|
/**
|
|
76
76
|
* All the currently refined items, grouped by attribute.
|
|
77
77
|
*/
|
|
@@ -89,13 +89,13 @@ export declare type CurrentRefinementsRenderState = {
|
|
|
89
89
|
*/
|
|
90
90
|
createURL: CreateURL<CurrentRefinementsConnectorParamsRefinement>;
|
|
91
91
|
};
|
|
92
|
-
export
|
|
92
|
+
export type CurrentRefinementsWidgetDescription = {
|
|
93
93
|
$$type: 'ais.currentRefinements';
|
|
94
94
|
renderState: CurrentRefinementsRenderState;
|
|
95
95
|
indexRenderState: {
|
|
96
96
|
currentRefinements: WidgetRenderState<CurrentRefinementsRenderState, CurrentRefinementsConnectorParams>;
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
|
-
export
|
|
99
|
+
export type CurrentRefinementsConnector = Connector<CurrentRefinementsWidgetDescription, CurrentRefinementsConnectorParams>;
|
|
100
100
|
declare const connectCurrentRefinements: CurrentRefinementsConnector;
|
|
101
101
|
export default connectCurrentRefinements;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Connector, TransformItems, TransformItemsMetadata, Widget } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export type DynamicWidgetsRenderState = {
|
|
3
3
|
attributesToRender: string[];
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export type DynamicWidgetsConnectorParams = {
|
|
6
6
|
/**
|
|
7
7
|
* An array of widgets, displayed in the order defined by `facetOrdering`.
|
|
8
8
|
*/
|
|
@@ -37,13 +37,13 @@ export declare type DynamicWidgetsConnectorParams = {
|
|
|
37
37
|
*/
|
|
38
38
|
maxValuesPerFacet?: number;
|
|
39
39
|
};
|
|
40
|
-
export
|
|
40
|
+
export type DynamicWidgetsWidgetDescription = {
|
|
41
41
|
$$type: 'ais.dynamicWidgets';
|
|
42
42
|
renderState: DynamicWidgetsRenderState;
|
|
43
43
|
indexRenderState: {
|
|
44
44
|
dynamicWidgets: DynamicWidgetsRenderState;
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
|
-
export
|
|
47
|
+
export type DynamicWidgetsConnector = Connector<DynamicWidgetsWidgetDescription, DynamicWidgetsConnectorParams>;
|
|
48
48
|
declare const connectDynamicWidgets: DynamicWidgetsConnector;
|
|
49
49
|
export default connectDynamicWidgets;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SendEventForHits } from '../../lib/utils';
|
|
2
2
|
import type { BaseHit, Connector, GeoLoc, Hit, TransformItems, WidgetRenderState } from '../../types';
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export type GeoHit<THit extends BaseHit = Record<string, any>> = Hit<THit> & Required<Pick<Hit, '_geoloc'>>;
|
|
4
|
+
type Bounds = {
|
|
5
5
|
/**
|
|
6
6
|
* The top right corner of the map view.
|
|
7
7
|
*/
|
|
@@ -11,7 +11,7 @@ declare type Bounds = {
|
|
|
11
11
|
*/
|
|
12
12
|
southWest: GeoLoc;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type GeoSearchRenderState<THit extends BaseHit = Record<string, any>> = {
|
|
15
15
|
/**
|
|
16
16
|
* Reset the current bounding box refinement.
|
|
17
17
|
*/
|
|
@@ -59,7 +59,7 @@ export declare type GeoSearchRenderState<THit extends BaseHit = Record<string, a
|
|
|
59
59
|
*/
|
|
60
60
|
toggleRefineOnMapMove(): void;
|
|
61
61
|
};
|
|
62
|
-
export
|
|
62
|
+
export type GeoSearchConnectorParams<THit extends BaseHit = Record<string, any>> = {
|
|
63
63
|
/**
|
|
64
64
|
* If true, refine will be triggered as you move the map.
|
|
65
65
|
* @default true
|
|
@@ -71,7 +71,7 @@ export declare type GeoSearchConnectorParams<THit extends BaseHit = Record<strin
|
|
|
71
71
|
*/
|
|
72
72
|
transformItems?: TransformItems<GeoHit<THit>>;
|
|
73
73
|
};
|
|
74
|
-
export
|
|
74
|
+
export type GeoSearchWidgetDescription<THit extends BaseHit = Record<string, any>> = {
|
|
75
75
|
$$type: 'ais.geoSearch';
|
|
76
76
|
renderState: GeoSearchRenderState<THit>;
|
|
77
77
|
indexRenderState: {
|
|
@@ -90,7 +90,7 @@ export declare type GeoSearchWidgetDescription<THit extends BaseHit = Record<str
|
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
-
export
|
|
93
|
+
export type GeoSearchConnector<THit extends BaseHit = Record<string, any>> = Connector<GeoSearchWidgetDescription<THit>, GeoSearchConnectorParams<THit>>;
|
|
94
94
|
/**
|
|
95
95
|
* The **GeoSearch** connector provides the logic to build a widget that will display the results on a map. It also provides a way to search for results based on their position. The connector provides functions to manage the search experience (search on map interaction or control the interaction for example).
|
|
96
96
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SendEventForFacet } from '../../lib/utils';
|
|
2
2
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
3
3
|
import type { Connector, CreateURL, TransformItems, SortBy, WidgetRenderState } from '../../types';
|
|
4
|
-
export
|
|
4
|
+
export type HierarchicalMenuItem = {
|
|
5
5
|
/**
|
|
6
6
|
* Value of the menu item.
|
|
7
7
|
*/
|
|
@@ -23,7 +23,7 @@ export declare type HierarchicalMenuItem = {
|
|
|
23
23
|
*/
|
|
24
24
|
data: HierarchicalMenuItem[] | null;
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export type HierarchicalMenuConnectorParams = {
|
|
27
27
|
/**
|
|
28
28
|
* Attributes to use to generate the hierarchy of the menu.
|
|
29
29
|
*/
|
|
@@ -65,7 +65,7 @@ export declare type HierarchicalMenuConnectorParams = {
|
|
|
65
65
|
*/
|
|
66
66
|
transformItems?: TransformItems<HierarchicalMenuItem>;
|
|
67
67
|
};
|
|
68
|
-
export
|
|
68
|
+
export type HierarchicalMenuRenderState = {
|
|
69
69
|
/**
|
|
70
70
|
* Creates an url for the next state for a clicked item.
|
|
71
71
|
*/
|
|
@@ -100,7 +100,7 @@ export declare type HierarchicalMenuRenderState = {
|
|
|
100
100
|
*/
|
|
101
101
|
sendEvent: SendEventForFacet;
|
|
102
102
|
};
|
|
103
|
-
export
|
|
103
|
+
export type HierarchicalMenuWidgetDescription = {
|
|
104
104
|
$$type: 'ais.hierarchicalMenu';
|
|
105
105
|
renderState: HierarchicalMenuRenderState;
|
|
106
106
|
indexRenderState: {
|
|
@@ -114,7 +114,7 @@ export declare type HierarchicalMenuWidgetDescription = {
|
|
|
114
114
|
};
|
|
115
115
|
};
|
|
116
116
|
};
|
|
117
|
-
export
|
|
117
|
+
export type HierarchicalMenuConnector = Connector<HierarchicalMenuWidgetDescription, HierarchicalMenuConnectorParams>;
|
|
118
118
|
/**
|
|
119
119
|
* **HierarchicalMenu** connector provides the logic to build a custom widget
|
|
120
120
|
* that will give the user the ability to explore facets in a tree-like structure.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SendEventForHits, BindEventForHits } from '../../lib/utils';
|
|
2
2
|
import type { TransformItems, Connector, Hit, WidgetRenderState, BaseHit } from '../../types';
|
|
3
3
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
4
|
-
export
|
|
4
|
+
export type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
5
5
|
/**
|
|
6
6
|
* The matched hits from Algolia API.
|
|
7
7
|
*/
|
|
@@ -19,7 +19,7 @@ export declare type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
|
19
19
|
*/
|
|
20
20
|
bindEvent: BindEventForHits;
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export type HitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
23
23
|
/**
|
|
24
24
|
* Whether to escape HTML tags from hits string values.
|
|
25
25
|
*
|
|
@@ -31,13 +31,13 @@ export declare type HitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
|
31
31
|
*/
|
|
32
32
|
transformItems?: TransformItems<Hit<THit>>;
|
|
33
33
|
};
|
|
34
|
-
export
|
|
34
|
+
export type HitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
35
35
|
$$type: 'ais.hits';
|
|
36
36
|
renderState: HitsRenderState<THit>;
|
|
37
37
|
indexRenderState: {
|
|
38
38
|
hits: WidgetRenderState<HitsRenderState<THit>, HitsConnectorParams<THit>>;
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
-
export
|
|
41
|
+
export type HitsConnector<THit extends BaseHit = BaseHit> = Connector<HitsWidgetDescription<THit>, HitsConnectorParams<THit>>;
|
|
42
42
|
declare const connectHits: HitsConnector;
|
|
43
43
|
export default connectHits;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Connector, TransformItems, WidgetRenderState } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export type HitsPerPageRenderStateItem = {
|
|
3
3
|
/**
|
|
4
4
|
* Label to display in the option.
|
|
5
5
|
*/
|
|
@@ -13,7 +13,7 @@ export declare type HitsPerPageRenderStateItem = {
|
|
|
13
13
|
*/
|
|
14
14
|
isRefined: boolean;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type HitsPerPageConnectorParamsItem = {
|
|
17
17
|
/**
|
|
18
18
|
* Label to display in the option.
|
|
19
19
|
*/
|
|
@@ -29,7 +29,7 @@ export declare type HitsPerPageConnectorParamsItem = {
|
|
|
29
29
|
*/
|
|
30
30
|
default?: boolean;
|
|
31
31
|
};
|
|
32
|
-
export
|
|
32
|
+
export type HitsPerPageConnectorParams = {
|
|
33
33
|
/**
|
|
34
34
|
* Array of objects defining the different values and labels.
|
|
35
35
|
*/
|
|
@@ -39,7 +39,7 @@ export declare type HitsPerPageConnectorParams = {
|
|
|
39
39
|
*/
|
|
40
40
|
transformItems?: TransformItems<HitsPerPageRenderStateItem>;
|
|
41
41
|
};
|
|
42
|
-
export
|
|
42
|
+
export type HitsPerPageRenderState = {
|
|
43
43
|
/**
|
|
44
44
|
* Array of objects defining the different values and labels.
|
|
45
45
|
*/
|
|
@@ -58,7 +58,7 @@ export declare type HitsPerPageRenderState = {
|
|
|
58
58
|
*/
|
|
59
59
|
canRefine: boolean;
|
|
60
60
|
};
|
|
61
|
-
export
|
|
61
|
+
export type HitsPerPageWidgetDescription = {
|
|
62
62
|
$$type: 'ais.hitsPerPage';
|
|
63
63
|
renderState: HitsPerPageRenderState;
|
|
64
64
|
indexRenderState: {
|
|
@@ -68,6 +68,6 @@ export declare type HitsPerPageWidgetDescription = {
|
|
|
68
68
|
hitsPerPage: number;
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
|
-
export
|
|
71
|
+
export type HitsPerPageConnector = Connector<HitsPerPageWidgetDescription, HitsPerPageConnectorParams>;
|
|
72
72
|
declare const connectHitsPerPage: HitsPerPageConnector;
|
|
73
73
|
export default connectHitsPerPage;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { PlainSearchParameters, SearchResults } from 'algoliasearch-helper';
|
|
2
2
|
import type { Connector, TransformItems, Hit, WidgetRenderState, BaseHit } from '../../types';
|
|
3
3
|
import type { SendEventForHits, BindEventForHits } from '../../lib/utils';
|
|
4
|
-
export
|
|
4
|
+
export type InfiniteHitsCachedHits<THit extends BaseHit> = {
|
|
5
5
|
[page: number]: Array<Hit<THit>>;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type Read<THit extends BaseHit> = ({ state, }: {
|
|
8
8
|
state: PlainSearchParameters;
|
|
9
9
|
}) => InfiniteHitsCachedHits<THit> | null;
|
|
10
|
-
|
|
10
|
+
type Write<THit extends BaseHit> = ({ state, hits, }: {
|
|
11
11
|
state: PlainSearchParameters;
|
|
12
12
|
hits: InfiniteHitsCachedHits<THit>;
|
|
13
13
|
}) => void;
|
|
14
|
-
export
|
|
14
|
+
export type InfiniteHitsCache<THit extends BaseHit = BaseHit> = {
|
|
15
15
|
read: Read<THit>;
|
|
16
16
|
write: Write<THit>;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type InfiniteHitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
19
19
|
/**
|
|
20
20
|
* Escapes HTML entities from hits string values.
|
|
21
21
|
*
|
|
@@ -40,7 +40,7 @@ export declare type InfiniteHitsConnectorParams<THit extends BaseHit = BaseHit>
|
|
|
40
40
|
*/
|
|
41
41
|
cache?: InfiniteHitsCache<THit>;
|
|
42
42
|
};
|
|
43
|
-
export
|
|
43
|
+
export type InfiniteHitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
44
44
|
/**
|
|
45
45
|
* Loads the previous results.
|
|
46
46
|
*/
|
|
@@ -78,7 +78,7 @@ export declare type InfiniteHitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
|
78
78
|
*/
|
|
79
79
|
results?: SearchResults<Hit<THit>>;
|
|
80
80
|
};
|
|
81
|
-
export
|
|
81
|
+
export type InfiniteHitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
82
82
|
$$type: 'ais.infiniteHits';
|
|
83
83
|
renderState: InfiniteHitsRenderState<THit>;
|
|
84
84
|
indexRenderState: {
|
|
@@ -88,6 +88,6 @@ export declare type InfiniteHitsWidgetDescription<THit extends BaseHit = BaseHit
|
|
|
88
88
|
page: number;
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
|
-
export
|
|
91
|
+
export type InfiniteHitsConnector<THit extends BaseHit = BaseHit> = Connector<InfiniteHitsWidgetDescription<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
92
92
|
declare const connectInfiniteHits: InfiniteHitsConnector;
|
|
93
93
|
export default connectInfiniteHits;
|
|
@@ -128,10 +128,17 @@ var connectInfiniteHits = function connectInfiniteHits(renderFn) {
|
|
|
128
128
|
getWidgetRenderState: function getWidgetRenderState(_ref5) {
|
|
129
129
|
var results = _ref5.results,
|
|
130
130
|
helper = _ref5.helper,
|
|
131
|
-
|
|
131
|
+
parent = _ref5.parent,
|
|
132
|
+
existingState = _ref5.state,
|
|
132
133
|
instantSearchInstance = _ref5.instantSearchInstance;
|
|
133
134
|
var isFirstPage;
|
|
134
135
|
var currentPageHits = [];
|
|
136
|
+
/**
|
|
137
|
+
* We bail out of optimistic UI here, as the cache is based on search
|
|
138
|
+
* parameters, and we don't want to invalidate the cache when the search
|
|
139
|
+
* is loading.
|
|
140
|
+
*/
|
|
141
|
+
var state = parent.getPreviousState() || existingState;
|
|
135
142
|
var cachedHits = cache.read({
|
|
136
143
|
state: state
|
|
137
144
|
}) || {};
|
|
@@ -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, CreateURL, SortBy, TransformItems, WidgetRenderState } from '../../types';
|
|
4
|
-
export
|
|
4
|
+
export type MenuItem = {
|
|
5
5
|
/**
|
|
6
6
|
* The value of the menu item.
|
|
7
7
|
*/
|
|
@@ -19,7 +19,7 @@ export declare type MenuItem = {
|
|
|
19
19
|
*/
|
|
20
20
|
isRefined: boolean;
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export type MenuConnectorParams = {
|
|
23
23
|
/**
|
|
24
24
|
* Name of the attribute for faceting (eg. "free_shipping").
|
|
25
25
|
*/
|
|
@@ -49,7 +49,7 @@ export declare type MenuConnectorParams = {
|
|
|
49
49
|
*/
|
|
50
50
|
transformItems?: TransformItems<MenuItem>;
|
|
51
51
|
};
|
|
52
|
-
export
|
|
52
|
+
export type MenuRenderState = {
|
|
53
53
|
/**
|
|
54
54
|
* The elements that can be refined for the current search results.
|
|
55
55
|
*/
|
|
@@ -84,7 +84,7 @@ export declare type MenuRenderState = {
|
|
|
84
84
|
*/
|
|
85
85
|
sendEvent: SendEventForFacet;
|
|
86
86
|
};
|
|
87
|
-
export
|
|
87
|
+
export type MenuWidgetDescription = {
|
|
88
88
|
$$type: 'ais.menu';
|
|
89
89
|
renderState: MenuRenderState;
|
|
90
90
|
indexRenderState: {
|
|
@@ -98,7 +98,7 @@ export declare type MenuWidgetDescription = {
|
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
100
|
};
|
|
101
|
-
export
|
|
101
|
+
export type MenuConnector = Connector<MenuWidgetDescription, MenuConnectorParams>;
|
|
102
102
|
/**
|
|
103
103
|
* **Menu** connector provides the logic to build a widget that will give the user the ability to choose a single value for a specific facet. The typical usage of menu is for navigation in categories.
|
|
104
104
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SendEventForFacet } from '../../lib/utils';
|
|
2
2
|
import type { Connector, CreateURL, TransformItems, WidgetRenderState } from '../../types';
|
|
3
|
-
export
|
|
3
|
+
export type NumericMenuConnectorParamsItem = {
|
|
4
4
|
/**
|
|
5
5
|
* Name of the option
|
|
6
6
|
*/
|
|
@@ -14,7 +14,7 @@ export declare type NumericMenuConnectorParamsItem = {
|
|
|
14
14
|
*/
|
|
15
15
|
end?: number;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type NumericMenuRenderStateItem = {
|
|
18
18
|
/**
|
|
19
19
|
* Name of the option.
|
|
20
20
|
*/
|
|
@@ -31,7 +31,7 @@ export declare type NumericMenuRenderStateItem = {
|
|
|
31
31
|
*/
|
|
32
32
|
isRefined: boolean;
|
|
33
33
|
};
|
|
34
|
-
export
|
|
34
|
+
export type NumericMenuConnectorParams = {
|
|
35
35
|
/**
|
|
36
36
|
* Name of the attribute for filtering
|
|
37
37
|
*/
|
|
@@ -45,7 +45,7 @@ export declare type NumericMenuConnectorParams = {
|
|
|
45
45
|
*/
|
|
46
46
|
transformItems?: TransformItems<NumericMenuRenderStateItem>;
|
|
47
47
|
};
|
|
48
|
-
export
|
|
48
|
+
export type NumericMenuRenderState = {
|
|
49
49
|
/**
|
|
50
50
|
* The list of available choices
|
|
51
51
|
*/
|
|
@@ -75,7 +75,7 @@ export declare type NumericMenuRenderState = {
|
|
|
75
75
|
*/
|
|
76
76
|
sendEvent: SendEventForFacet;
|
|
77
77
|
};
|
|
78
|
-
export
|
|
78
|
+
export type NumericMenuWidgetDescription = {
|
|
79
79
|
$$type: 'ais.numericMenu';
|
|
80
80
|
renderState: NumericMenuRenderState;
|
|
81
81
|
indexRenderState: {
|
|
@@ -89,6 +89,6 @@ export declare type NumericMenuWidgetDescription = {
|
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
|
-
export
|
|
92
|
+
export type NumericMenuConnector = Connector<NumericMenuWidgetDescription, NumericMenuConnectorParams>;
|
|
93
93
|
declare const connectNumericMenu: NumericMenuConnector;
|
|
94
94
|
export default connectNumericMenu;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Connector, CreateURL, WidgetRenderState } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export type PaginationConnectorParams = {
|
|
3
3
|
/**
|
|
4
4
|
* The total number of pages to browse.
|
|
5
5
|
*/
|
|
@@ -10,7 +10,7 @@ export declare type PaginationConnectorParams = {
|
|
|
10
10
|
*/
|
|
11
11
|
padding?: number;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type PaginationRenderState = {
|
|
14
14
|
/** Creates URLs for the next state, the number is the page to generate the URL for. */
|
|
15
15
|
createURL: CreateURL<number>;
|
|
16
16
|
/** Sets the current page and triggers a search. */
|
|
@@ -30,7 +30,7 @@ export declare type PaginationRenderState = {
|
|
|
30
30
|
/** true if the current page is also the last page. */
|
|
31
31
|
isLastPage: boolean;
|
|
32
32
|
};
|
|
33
|
-
export
|
|
33
|
+
export type PaginationWidgetDescription = {
|
|
34
34
|
$$type: 'ais.pagination';
|
|
35
35
|
renderState: PaginationRenderState;
|
|
36
36
|
indexRenderState: {
|
|
@@ -40,7 +40,7 @@ export declare type PaginationWidgetDescription = {
|
|
|
40
40
|
page: number;
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
|
-
export
|
|
43
|
+
export type PaginationConnector = Connector<PaginationWidgetDescription, PaginationConnectorParams>;
|
|
44
44
|
/**
|
|
45
45
|
* **Pagination** connector provides the logic to build a widget that will let the user
|
|
46
46
|
* choose the current page of the results.
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { Connector, WidgetRenderState } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export type PoweredByRenderState = {
|
|
3
3
|
/** the url to redirect to on click */
|
|
4
4
|
url: string;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type PoweredByConnectorParams = {
|
|
7
7
|
/** the url to redirect to on click */
|
|
8
8
|
url?: string;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type PoweredByWidgetDescription = {
|
|
11
11
|
$$type: 'ais.poweredBy';
|
|
12
12
|
renderState: PoweredByRenderState;
|
|
13
13
|
indexRenderState: {
|
|
14
14
|
poweredBy: WidgetRenderState<PoweredByRenderState, PoweredByConnectorParams>;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type PoweredByConnector = Connector<PoweredByWidgetDescription, PoweredByConnectorParams>;
|
|
18
18
|
/**
|
|
19
19
|
* **PoweredBy** connector provides the logic to build a custom widget that will displays
|
|
20
20
|
* the logo to redirect to Algolia.
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import type { Connector, TransformItems, WidgetRenderState } from '../../types';
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
type TrackedFilterRefinement = string | number | boolean;
|
|
3
|
+
export type ParamTrackedFilters = {
|
|
4
4
|
[facetName: string]: (facetValues: TrackedFilterRefinement[]) => TrackedFilterRefinement[];
|
|
5
5
|
};
|
|
6
|
-
export
|
|
7
|
-
export
|
|
6
|
+
export type ParamTransformRuleContexts = (ruleContexts: string[]) => string[];
|
|
7
|
+
export type QueryRulesConnectorParams = {
|
|
8
8
|
trackedFilters?: ParamTrackedFilters;
|
|
9
9
|
transformRuleContexts?: ParamTransformRuleContexts;
|
|
10
10
|
transformItems?: TransformItems<any>;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type QueryRulesRenderState = {
|
|
13
13
|
items: any[];
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type QueryRulesWidgetDescription = {
|
|
16
16
|
$$type: 'ais.queryRules';
|
|
17
17
|
renderState: QueryRulesRenderState;
|
|
18
18
|
indexRenderState: {
|
|
19
19
|
queryRules: WidgetRenderState<QueryRulesRenderState, QueryRulesConnectorParams>;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export type QueryRulesConnector = Connector<QueryRulesWidgetDescription, QueryRulesConnectorParams>;
|
|
23
23
|
declare const connectQueryRules: QueryRulesConnector;
|
|
24
24
|
export default connectQueryRules;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { SendEventForFacet } from '../../lib/utils';
|
|
2
2
|
import type { Connector, WidgetRenderState } from '../../types';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
3
|
+
export type RangeMin = number | undefined;
|
|
4
|
+
export type RangeMax = number | undefined;
|
|
5
|
+
export type RangeBoundaries = [RangeMin, RangeMax];
|
|
6
|
+
export type Range = {
|
|
7
7
|
min: RangeMin;
|
|
8
8
|
max: RangeMax;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type RangeRenderState = {
|
|
11
11
|
/**
|
|
12
12
|
* Sets a range to filter the results on. Both values
|
|
13
13
|
* are optional, and will default to the higher and lower bounds. You can use `undefined` to remove a
|
|
@@ -40,7 +40,7 @@ export declare type RangeRenderState = {
|
|
|
40
40
|
to(toValue: number): string;
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
|
-
export
|
|
43
|
+
export type RangeConnectorParams = {
|
|
44
44
|
/**
|
|
45
45
|
* Name of the attribute for faceting.
|
|
46
46
|
*/
|
|
@@ -58,7 +58,7 @@ export declare type RangeConnectorParams = {
|
|
|
58
58
|
*/
|
|
59
59
|
precision?: number;
|
|
60
60
|
};
|
|
61
|
-
export
|
|
61
|
+
export type RangeWidgetDescription = {
|
|
62
62
|
$$type: 'ais.range';
|
|
63
63
|
renderState: RangeRenderState;
|
|
64
64
|
indexRenderState: {
|
|
@@ -72,7 +72,7 @@ export declare type RangeWidgetDescription = {
|
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
|
-
export
|
|
75
|
+
export type RangeConnector = Connector<RangeWidgetDescription, RangeConnectorParams>;
|
|
76
76
|
/**
|
|
77
77
|
* **Range** connector provides the logic to create custom widget that will let
|
|
78
78
|
* the user refine results using a numeric range.
|