instantsearch.js 4.37.1 → 4.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/cjs/components/Hits/Hits.js +0 -6
- package/cjs/components/Pagination/Pagination.js +60 -41
- package/cjs/connectors/breadcrumb/connectBreadcrumb.js +6 -1
- package/cjs/connectors/clear-refinements/connectClearRefinements.js +11 -6
- package/cjs/connectors/current-refinements/connectCurrentRefinements.js +6 -2
- package/cjs/connectors/geo-search/connectGeoSearch.js +3 -1
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +3 -1
- package/cjs/connectors/hits/connectHits.js +3 -1
- package/cjs/connectors/hits-per-page/connectHitsPerPage.js +3 -1
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +3 -1
- package/cjs/connectors/menu/connectMenu.js +3 -1
- package/cjs/connectors/numeric-menu/connectNumericMenu.js +5 -3
- package/cjs/connectors/query-rules/connectQueryRules.js +3 -1
- package/cjs/connectors/refinement-list/connectRefinementList.js +8 -3
- package/cjs/connectors/search-box/connectSearchBox.js +15 -25
- package/cjs/connectors/sort-by/connectSortBy.js +3 -1
- package/cjs/helpers/highlight.js +4 -1
- package/cjs/helpers/reverseHighlight.js +4 -1
- package/cjs/helpers/reverseSnippet.js +4 -1
- package/cjs/helpers/snippet.js +4 -1
- package/cjs/lib/routers/history.js +44 -29
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createMetadataMiddleware.js +3 -1
- package/dist/instantsearch.development.d.ts +56 -14
- package/dist/instantsearch.development.js +194 -171
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +56 -14
- package/dist/instantsearch.production.min.d.ts +56 -14
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Hits/Hits.d.ts +1 -9
- package/es/components/Hits/Hits.js +0 -6
- package/es/components/Pagination/Pagination.d.ts +3 -10
- package/es/components/Pagination/Pagination.js +55 -34
- package/es/connectors/breadcrumb/connectBreadcrumb.js +6 -1
- package/es/connectors/clear-refinements/connectClearRefinements.js +11 -6
- package/es/connectors/current-refinements/connectCurrentRefinements.js +6 -2
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +4 -5
- package/es/connectors/geo-search/connectGeoSearch.js +3 -1
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +3 -1
- package/es/connectors/hits/connectHits.js +3 -1
- package/es/connectors/hits-per-page/connectHitsPerPage.js +3 -1
- package/es/connectors/infinite-hits/connectInfiniteHits.js +3 -1
- package/es/connectors/menu/connectMenu.js +3 -1
- package/es/connectors/numeric-menu/connectNumericMenu.js +5 -3
- package/es/connectors/query-rules/connectQueryRules.d.ts +1 -2
- package/es/connectors/query-rules/connectQueryRules.js +3 -1
- package/es/connectors/refinement-list/connectRefinementList.js +8 -3
- package/es/connectors/search-box/connectSearchBox.js +15 -25
- package/es/connectors/sort-by/connectSortBy.js +3 -1
- package/es/connectors/toggle-refinement/connectToggleRefinement.d.ts +36 -7
- package/es/helpers/highlight.js +5 -2
- package/es/helpers/reverseHighlight.js +5 -2
- package/es/helpers/reverseSnippet.js +5 -2
- package/es/helpers/snippet.js +5 -2
- package/es/lib/routers/history.d.ts +11 -0
- package/es/lib/routers/history.js +44 -29
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createMetadataMiddleware.js +3 -1
- package/es/types/widget.d.ts +4 -1
- package/package.json +3 -3
- package/cjs/components/Pagination/PaginationLink.js +0 -60
- package/dist/instantsearch.development.min.d.ts +0 -5217
- package/es/components/Pagination/PaginationLink.d.ts +0 -16
- package/es/components/Pagination/PaginationLink.js +0 -49
|
@@ -466,6 +466,17 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
|
466
466
|
* It needs to avoid pushing state to history in case of back/forward in browser
|
|
467
467
|
*/
|
|
468
468
|
private shouldPushState;
|
|
469
|
+
/**
|
|
470
|
+
* Indicates whether the history router is disposed or not.
|
|
471
|
+
*/
|
|
472
|
+
private isDisposed;
|
|
473
|
+
/**
|
|
474
|
+
* Indicates the window.history.length before the last call to
|
|
475
|
+
* window.history.pushState (called in `write`).
|
|
476
|
+
* It allows to determine if a `pushState` has been triggered elsewhere,
|
|
477
|
+
* and thus to prevent the `write` method from calling `pushState`.
|
|
478
|
+
*/
|
|
479
|
+
private latestAcknowledgedHistory;
|
|
469
480
|
/**
|
|
470
481
|
* Initializes a new storage provider that syncs the search state to the URL
|
|
471
482
|
* using web APIs (`window.location.pushState` and `onpopstate` event).
|
|
@@ -1098,9 +1109,9 @@ declare type DynamicWidgetsConnectorParams = {
|
|
|
1098
1109
|
* Function to transform the items to render.
|
|
1099
1110
|
* The function also exposes the full search response.
|
|
1100
1111
|
*/
|
|
1101
|
-
transformItems
|
|
1102
|
-
results:
|
|
1103
|
-
}
|
|
1112
|
+
transformItems?: TransformItems<string, Omit<TransformItemsMetadata, 'results'> & {
|
|
1113
|
+
results: NonNullable<TransformItemsMetadata['results']>;
|
|
1114
|
+
}>;
|
|
1104
1115
|
/**
|
|
1105
1116
|
* To prevent unneeded extra network requests when widgets mount or unmount,
|
|
1106
1117
|
* we request all facet values.
|
|
@@ -3203,8 +3214,6 @@ declare type ParamTrackedFilters = {
|
|
|
3203
3214
|
[facetName: string]: (facetValues: TrackedFilterRefinement[]) => TrackedFilterRefinement[];
|
|
3204
3215
|
};
|
|
3205
3216
|
|
|
3206
|
-
declare type ParamTransformItems = TransformItems<any>;
|
|
3207
|
-
|
|
3208
3217
|
declare type ParamTransformRuleContexts = (ruleContexts: string[]) => string[];
|
|
3209
3218
|
|
|
3210
3219
|
declare type ParseURL<TRouteState> = (args: {
|
|
@@ -3345,7 +3354,7 @@ declare type QueryRulesConnector = Connector<QueryRulesWidgetDescription, QueryR
|
|
|
3345
3354
|
declare type QueryRulesConnectorParams = {
|
|
3346
3355
|
trackedFilters?: ParamTrackedFilters;
|
|
3347
3356
|
transformRuleContexts?: ParamTransformRuleContexts;
|
|
3348
|
-
transformItems?:
|
|
3357
|
+
transformItems?: TransformItems<any>;
|
|
3349
3358
|
};
|
|
3350
3359
|
|
|
3351
3360
|
declare type QueryRulesRenderState = {
|
|
@@ -4915,7 +4924,9 @@ declare const toggleRefinement: ToggleRefinementWidget;
|
|
|
4915
4924
|
declare type ToggleRefinementConnector = Connector<ToggleRefinementWidgetDescription, ToggleRefinementConnectorParams>;
|
|
4916
4925
|
|
|
4917
4926
|
declare type ToggleRefinementConnectorParams = {
|
|
4918
|
-
/**
|
|
4927
|
+
/**
|
|
4928
|
+
* Name of the attribute for faceting (e.g., "free_shipping").
|
|
4929
|
+
*/
|
|
4919
4930
|
attribute: string;
|
|
4920
4931
|
/**
|
|
4921
4932
|
* Value to filter on when toggled.
|
|
@@ -4950,19 +4961,42 @@ declare type ToggleRefinementCSSClasses = Partial<{
|
|
|
4950
4961
|
declare type ToggleRefinementRenderState = {
|
|
4951
4962
|
/** The current toggle value */
|
|
4952
4963
|
value: {
|
|
4964
|
+
/**
|
|
4965
|
+
* The attribute name of this toggle.
|
|
4966
|
+
*/
|
|
4953
4967
|
name: string;
|
|
4968
|
+
/**
|
|
4969
|
+
* Whether the current option is "on" (true) or "off" (false)
|
|
4970
|
+
*/
|
|
4954
4971
|
isRefined: boolean;
|
|
4972
|
+
/**
|
|
4973
|
+
* Number of results if this option is toggled.
|
|
4974
|
+
*/
|
|
4955
4975
|
count: number | null;
|
|
4976
|
+
/**
|
|
4977
|
+
* Information about the "on" toggle.
|
|
4978
|
+
*/
|
|
4956
4979
|
onFacetValue: ToggleRefinementValue;
|
|
4980
|
+
/**
|
|
4981
|
+
* Information about the "off" toggle.
|
|
4982
|
+
*/
|
|
4957
4983
|
offFacetValue: ToggleRefinementValue;
|
|
4958
4984
|
};
|
|
4959
|
-
/**
|
|
4985
|
+
/**
|
|
4986
|
+
* Creates an URL for the next state.
|
|
4987
|
+
*/
|
|
4960
4988
|
createURL: CreateURL<string>;
|
|
4961
|
-
/**
|
|
4989
|
+
/**
|
|
4990
|
+
* Send a "Facet Clicked" Insights event.
|
|
4991
|
+
*/
|
|
4962
4992
|
sendEvent: SendEventForToggle;
|
|
4963
|
-
/**
|
|
4993
|
+
/**
|
|
4994
|
+
* Indicates if search state can be refined.
|
|
4995
|
+
*/
|
|
4964
4996
|
canRefine: boolean;
|
|
4965
|
-
/**
|
|
4997
|
+
/**
|
|
4998
|
+
* Updates to the next state by applying the toggle refinement.
|
|
4999
|
+
*/
|
|
4966
5000
|
refine: (value?: {
|
|
4967
5001
|
isRefined: boolean;
|
|
4968
5002
|
}) => void;
|
|
@@ -4976,9 +5010,13 @@ declare type ToggleRefinementTemplates = Partial<{
|
|
|
4976
5010
|
}>;
|
|
4977
5011
|
|
|
4978
5012
|
declare type ToggleRefinementValue = {
|
|
4979
|
-
/**
|
|
5013
|
+
/**
|
|
5014
|
+
* Whether this option is enabled.
|
|
5015
|
+
*/
|
|
4980
5016
|
isRefined: boolean;
|
|
4981
|
-
/**
|
|
5017
|
+
/**
|
|
5018
|
+
* Number of result if this option is toggled.
|
|
5019
|
+
*/
|
|
4982
5020
|
count: number | null;
|
|
4983
5021
|
};
|
|
4984
5022
|
|
|
@@ -5021,7 +5059,11 @@ declare type TrackedFilterRefinement = string | number | boolean;
|
|
|
5021
5059
|
/**
|
|
5022
5060
|
* Transforms the given items.
|
|
5023
5061
|
*/
|
|
5024
|
-
declare type TransformItems<TItem> = (items: TItem[]) => TItem[];
|
|
5062
|
+
declare type TransformItems<TItem, TMetadata = TransformItemsMetadata> = (items: TItem[], metadata: TMetadata) => TItem[];
|
|
5063
|
+
|
|
5064
|
+
declare type TransformItemsMetadata = {
|
|
5065
|
+
results?: SearchResults;
|
|
5066
|
+
};
|
|
5025
5067
|
|
|
5026
5068
|
declare type TransformSearchParameters = (searchParameters: SearchParameters) => PlainSearchParameters;
|
|
5027
5069
|
|
|
@@ -466,6 +466,17 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
|
466
466
|
* It needs to avoid pushing state to history in case of back/forward in browser
|
|
467
467
|
*/
|
|
468
468
|
private shouldPushState;
|
|
469
|
+
/**
|
|
470
|
+
* Indicates whether the history router is disposed or not.
|
|
471
|
+
*/
|
|
472
|
+
private isDisposed;
|
|
473
|
+
/**
|
|
474
|
+
* Indicates the window.history.length before the last call to
|
|
475
|
+
* window.history.pushState (called in `write`).
|
|
476
|
+
* It allows to determine if a `pushState` has been triggered elsewhere,
|
|
477
|
+
* and thus to prevent the `write` method from calling `pushState`.
|
|
478
|
+
*/
|
|
479
|
+
private latestAcknowledgedHistory;
|
|
469
480
|
/**
|
|
470
481
|
* Initializes a new storage provider that syncs the search state to the URL
|
|
471
482
|
* using web APIs (`window.location.pushState` and `onpopstate` event).
|
|
@@ -1098,9 +1109,9 @@ declare type DynamicWidgetsConnectorParams = {
|
|
|
1098
1109
|
* Function to transform the items to render.
|
|
1099
1110
|
* The function also exposes the full search response.
|
|
1100
1111
|
*/
|
|
1101
|
-
transformItems
|
|
1102
|
-
results:
|
|
1103
|
-
}
|
|
1112
|
+
transformItems?: TransformItems<string, Omit<TransformItemsMetadata, 'results'> & {
|
|
1113
|
+
results: NonNullable<TransformItemsMetadata['results']>;
|
|
1114
|
+
}>;
|
|
1104
1115
|
/**
|
|
1105
1116
|
* To prevent unneeded extra network requests when widgets mount or unmount,
|
|
1106
1117
|
* we request all facet values.
|
|
@@ -3203,8 +3214,6 @@ declare type ParamTrackedFilters = {
|
|
|
3203
3214
|
[facetName: string]: (facetValues: TrackedFilterRefinement[]) => TrackedFilterRefinement[];
|
|
3204
3215
|
};
|
|
3205
3216
|
|
|
3206
|
-
declare type ParamTransformItems = TransformItems<any>;
|
|
3207
|
-
|
|
3208
3217
|
declare type ParamTransformRuleContexts = (ruleContexts: string[]) => string[];
|
|
3209
3218
|
|
|
3210
3219
|
declare type ParseURL<TRouteState> = (args: {
|
|
@@ -3345,7 +3354,7 @@ declare type QueryRulesConnector = Connector<QueryRulesWidgetDescription, QueryR
|
|
|
3345
3354
|
declare type QueryRulesConnectorParams = {
|
|
3346
3355
|
trackedFilters?: ParamTrackedFilters;
|
|
3347
3356
|
transformRuleContexts?: ParamTransformRuleContexts;
|
|
3348
|
-
transformItems?:
|
|
3357
|
+
transformItems?: TransformItems<any>;
|
|
3349
3358
|
};
|
|
3350
3359
|
|
|
3351
3360
|
declare type QueryRulesRenderState = {
|
|
@@ -4915,7 +4924,9 @@ declare const toggleRefinement: ToggleRefinementWidget;
|
|
|
4915
4924
|
declare type ToggleRefinementConnector = Connector<ToggleRefinementWidgetDescription, ToggleRefinementConnectorParams>;
|
|
4916
4925
|
|
|
4917
4926
|
declare type ToggleRefinementConnectorParams = {
|
|
4918
|
-
/**
|
|
4927
|
+
/**
|
|
4928
|
+
* Name of the attribute for faceting (e.g., "free_shipping").
|
|
4929
|
+
*/
|
|
4919
4930
|
attribute: string;
|
|
4920
4931
|
/**
|
|
4921
4932
|
* Value to filter on when toggled.
|
|
@@ -4950,19 +4961,42 @@ declare type ToggleRefinementCSSClasses = Partial<{
|
|
|
4950
4961
|
declare type ToggleRefinementRenderState = {
|
|
4951
4962
|
/** The current toggle value */
|
|
4952
4963
|
value: {
|
|
4964
|
+
/**
|
|
4965
|
+
* The attribute name of this toggle.
|
|
4966
|
+
*/
|
|
4953
4967
|
name: string;
|
|
4968
|
+
/**
|
|
4969
|
+
* Whether the current option is "on" (true) or "off" (false)
|
|
4970
|
+
*/
|
|
4954
4971
|
isRefined: boolean;
|
|
4972
|
+
/**
|
|
4973
|
+
* Number of results if this option is toggled.
|
|
4974
|
+
*/
|
|
4955
4975
|
count: number | null;
|
|
4976
|
+
/**
|
|
4977
|
+
* Information about the "on" toggle.
|
|
4978
|
+
*/
|
|
4956
4979
|
onFacetValue: ToggleRefinementValue;
|
|
4980
|
+
/**
|
|
4981
|
+
* Information about the "off" toggle.
|
|
4982
|
+
*/
|
|
4957
4983
|
offFacetValue: ToggleRefinementValue;
|
|
4958
4984
|
};
|
|
4959
|
-
/**
|
|
4985
|
+
/**
|
|
4986
|
+
* Creates an URL for the next state.
|
|
4987
|
+
*/
|
|
4960
4988
|
createURL: CreateURL<string>;
|
|
4961
|
-
/**
|
|
4989
|
+
/**
|
|
4990
|
+
* Send a "Facet Clicked" Insights event.
|
|
4991
|
+
*/
|
|
4962
4992
|
sendEvent: SendEventForToggle;
|
|
4963
|
-
/**
|
|
4993
|
+
/**
|
|
4994
|
+
* Indicates if search state can be refined.
|
|
4995
|
+
*/
|
|
4964
4996
|
canRefine: boolean;
|
|
4965
|
-
/**
|
|
4997
|
+
/**
|
|
4998
|
+
* Updates to the next state by applying the toggle refinement.
|
|
4999
|
+
*/
|
|
4966
5000
|
refine: (value?: {
|
|
4967
5001
|
isRefined: boolean;
|
|
4968
5002
|
}) => void;
|
|
@@ -4976,9 +5010,13 @@ declare type ToggleRefinementTemplates = Partial<{
|
|
|
4976
5010
|
}>;
|
|
4977
5011
|
|
|
4978
5012
|
declare type ToggleRefinementValue = {
|
|
4979
|
-
/**
|
|
5013
|
+
/**
|
|
5014
|
+
* Whether this option is enabled.
|
|
5015
|
+
*/
|
|
4980
5016
|
isRefined: boolean;
|
|
4981
|
-
/**
|
|
5017
|
+
/**
|
|
5018
|
+
* Number of result if this option is toggled.
|
|
5019
|
+
*/
|
|
4982
5020
|
count: number | null;
|
|
4983
5021
|
};
|
|
4984
5022
|
|
|
@@ -5021,7 +5059,11 @@ declare type TrackedFilterRefinement = string | number | boolean;
|
|
|
5021
5059
|
/**
|
|
5022
5060
|
* Transforms the given items.
|
|
5023
5061
|
*/
|
|
5024
|
-
declare type TransformItems<TItem> = (items: TItem[]) => TItem[];
|
|
5062
|
+
declare type TransformItems<TItem, TMetadata = TransformItemsMetadata> = (items: TItem[], metadata: TMetadata) => TItem[];
|
|
5063
|
+
|
|
5064
|
+
declare type TransformItemsMetadata = {
|
|
5065
|
+
results?: SearchResults;
|
|
5066
|
+
};
|
|
5025
5067
|
|
|
5026
5068
|
declare type TransformSearchParameters = (searchParameters: SearchParameters) => PlainSearchParameters;
|
|
5027
5069
|
|