instantsearch.js 4.66.1 → 4.68.0
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/Template/Template.js +11 -2
- package/cjs/connectors/hits/connectHits.js +4 -0
- package/cjs/lib/InstantSearch.js +1 -1
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/hits/hits.js +14 -3
- package/cjs/widgets/index/index.js +80 -16
- package/dist/instantsearch.development.d.ts +38 -2
- package/dist/instantsearch.development.js +568 -46
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +38 -2
- package/dist/instantsearch.production.min.d.ts +38 -2
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Template/Template.js +11 -2
- package/es/connectors/hits/connectHits.d.ts +5 -0
- package/es/connectors/hits/connectHits.js +4 -0
- package/es/lib/InstantSearch.js +1 -1
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/types/widget.d.ts +21 -2
- package/es/widgets/hits/defaultTemplates.d.ts +1 -1
- package/es/widgets/hits/hits.d.ts +8 -1
- package/es/widgets/hits/hits.js +14 -3
- package/es/widgets/index/index.js +80 -16
- package/es/widgets/panel/panel.d.ts +1 -1
- package/package.json +8 -8
|
@@ -15,6 +15,7 @@ import type { InsightsMethodMap as InsightsMethodMap_2 } from 'search-insights';
|
|
|
15
15
|
import type * as Places from 'places.js';
|
|
16
16
|
import type { PlainSearchParameters } from 'algoliasearch-helper';
|
|
17
17
|
import { default as qs_2 } from 'qs';
|
|
18
|
+
import type { RecommendParameters } from 'algoliasearch-helper';
|
|
18
19
|
import { SearchClient } from 'algoliasearch-helper/types/algoliasearch.js';
|
|
19
20
|
import { SearchOptions } from 'algoliasearch-helper/types/algoliasearch.js';
|
|
20
21
|
import type { SearchParameters } from 'algoliasearch-helper';
|
|
@@ -242,7 +243,7 @@ declare type AtLeastOne<TTarget, TMapped = {
|
|
|
242
243
|
[Key in keyof TTarget]: Pick<TTarget, Key>;
|
|
243
244
|
}> = Partial<TTarget> & TMapped[keyof TMapped];
|
|
244
245
|
|
|
245
|
-
declare type AugmentedWidget<TWidgetFactory extends AnyWidgetFactory, TOverriddenKeys extends keyof Widget = 'init' | 'render' | 'dispose'> = Omit<ReturnType<TWidgetFactory>, TOverriddenKeys> & Pick<Required<Widget>, TOverriddenKeys>;
|
|
246
|
+
declare type AugmentedWidget<TWidgetFactory extends AnyWidgetFactory, TOverriddenKeys extends keyof Widget = 'init' | 'render' | 'dispose'> = Omit<ReturnType<TWidgetFactory>, TOverriddenKeys | 'dependsOn' | 'getWidgetParameters'> & Pick<Required<Widget>, TOverriddenKeys>;
|
|
246
247
|
|
|
247
248
|
declare type AutocompleteConnector = Connector<AutocompleteWidgetDescription, AutocompleteConnectorParams>;
|
|
248
249
|
|
|
@@ -302,6 +303,8 @@ declare type AutocompleteWidgetDescription = {
|
|
|
302
303
|
};
|
|
303
304
|
};
|
|
304
305
|
|
|
306
|
+
declare type Banner = NonNullable<NonNullable<Required<SearchResults<Hit>['renderingContent']>>['widgets']['banners']>[number];
|
|
307
|
+
|
|
305
308
|
declare type BaseHit = Record<string, unknown>;
|
|
306
309
|
|
|
307
310
|
declare type BindEventForHits = BuiltInBindEventForHits & CustomBindEventForHits;
|
|
@@ -1993,6 +1996,10 @@ declare type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
|
1993
1996
|
* The response from the Algolia API.
|
|
1994
1997
|
*/
|
|
1995
1998
|
results?: SearchResults<Hit<THit>>;
|
|
1999
|
+
/**
|
|
2000
|
+
* The banner to display above the hits.
|
|
2001
|
+
*/
|
|
2002
|
+
banner?: Banner;
|
|
1996
2003
|
/**
|
|
1997
2004
|
* Sends an event to the Insights middleware.
|
|
1998
2005
|
*/
|
|
@@ -2019,6 +2026,13 @@ declare type HitsTemplates = Partial<{
|
|
|
2019
2026
|
/** @deprecated the index in the hits array, use __position instead, which is the absolute position */
|
|
2020
2027
|
__hitIndex: number;
|
|
2021
2028
|
}>;
|
|
2029
|
+
/**
|
|
2030
|
+
* Template to use for the banner.
|
|
2031
|
+
*/
|
|
2032
|
+
banner: Template<{
|
|
2033
|
+
banner: Required<HitsRenderState['banner']>;
|
|
2034
|
+
className: string;
|
|
2035
|
+
}>;
|
|
2022
2036
|
}>;
|
|
2023
2037
|
|
|
2024
2038
|
declare type HitsWidget = WidgetFactory<HitsWidgetDescription & {
|
|
@@ -4007,6 +4021,13 @@ declare type Read<THit extends BaseHit> = ({ state, }: {
|
|
|
4007
4021
|
state: PlainSearchParameters;
|
|
4008
4022
|
}) => InfiniteHitsCachedHits<THit> | null;
|
|
4009
4023
|
|
|
4024
|
+
declare type RecommendWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
|
|
4025
|
+
dependsOn?: 'recommend';
|
|
4026
|
+
getWidgetParameters: (state: RecommendParameters, widgetParametersOptions: {
|
|
4027
|
+
uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
|
|
4028
|
+
}) => RecommendParameters;
|
|
4029
|
+
};
|
|
4030
|
+
|
|
4010
4031
|
declare type ReconfigurableOptions = Places.ReconfigurableOptions;
|
|
4011
4032
|
|
|
4012
4033
|
/**
|
|
@@ -4517,7 +4538,7 @@ declare type RequiredUiStateLifeCycle<TWidgetDescription extends WidgetDescripti
|
|
|
4517
4538
|
getWidgetSearchParameters: (state: SearchParameters, widgetSearchParametersOptions: {
|
|
4518
4539
|
uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
|
|
4519
4540
|
}) => SearchParameters;
|
|
4520
|
-
};
|
|
4541
|
+
} & (SearchWidgetLifeCycle<TWidgetDescription> | RecommendWidgetLifeCycle<TWidgetDescription>);
|
|
4521
4542
|
|
|
4522
4543
|
declare type RequiredWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
|
|
4523
4544
|
/**
|
|
@@ -4528,6 +4549,10 @@ declare type RequiredWidgetLifeCycle<TWidgetDescription extends WidgetDescriptio
|
|
|
4528
4549
|
* Called once before the first search.
|
|
4529
4550
|
*/
|
|
4530
4551
|
init?: (options: InitOptions) => void;
|
|
4552
|
+
/**
|
|
4553
|
+
* Whether `render` should be called
|
|
4554
|
+
*/
|
|
4555
|
+
shouldRender?: (options: ShouldRenderOptions) => boolean;
|
|
4531
4556
|
/**
|
|
4532
4557
|
* Called after each search response has been received.
|
|
4533
4558
|
*/
|
|
@@ -4843,6 +4868,13 @@ declare type SearchBoxWidgetParams = {
|
|
|
4843
4868
|
queryHook?: (query: string, hook: (value: string) => void) => void;
|
|
4844
4869
|
};
|
|
4845
4870
|
|
|
4871
|
+
declare type SearchWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
|
|
4872
|
+
dependsOn?: 'search';
|
|
4873
|
+
getWidgetParameters?: (state: SearchParameters, widgetParametersOptions: {
|
|
4874
|
+
uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
|
|
4875
|
+
}) => SearchParameters;
|
|
4876
|
+
};
|
|
4877
|
+
|
|
4846
4878
|
declare type SendEvent = (...args: [InsightsEvent] | [string, string, string?]) => void;
|
|
4847
4879
|
|
|
4848
4880
|
declare type SendEventForFacet = BuiltInSendEventForFacet & CustomSendEventForFacet;
|
|
@@ -4869,6 +4901,10 @@ declare type SharedRenderOptions = {
|
|
|
4869
4901
|
createURL: (nextState: SearchParameters | ((state: IndexUiState) => IndexUiState)) => string;
|
|
4870
4902
|
};
|
|
4871
4903
|
|
|
4904
|
+
declare type ShouldRenderOptions = {
|
|
4905
|
+
instantSearchInstance: InstantSearch;
|
|
4906
|
+
};
|
|
4907
|
+
|
|
4872
4908
|
declare function simpleStateMapping<TUiState extends UiState = UiState>(): StateMapping<TUiState, TUiState>;
|
|
4873
4909
|
|
|
4874
4910
|
declare function singleIndexStateMapping<TUiState extends UiState = UiState>(indexName: keyof TUiState): StateMapping<TUiState, TUiState[typeof indexName]>;
|
|
@@ -15,6 +15,7 @@ import type { InsightsMethodMap as InsightsMethodMap_2 } from 'search-insights';
|
|
|
15
15
|
import type * as Places from 'places.js';
|
|
16
16
|
import type { PlainSearchParameters } from 'algoliasearch-helper';
|
|
17
17
|
import { default as qs_2 } from 'qs';
|
|
18
|
+
import type { RecommendParameters } from 'algoliasearch-helper';
|
|
18
19
|
import { SearchClient } from 'algoliasearch-helper/types/algoliasearch.js';
|
|
19
20
|
import { SearchOptions } from 'algoliasearch-helper/types/algoliasearch.js';
|
|
20
21
|
import type { SearchParameters } from 'algoliasearch-helper';
|
|
@@ -242,7 +243,7 @@ declare type AtLeastOne<TTarget, TMapped = {
|
|
|
242
243
|
[Key in keyof TTarget]: Pick<TTarget, Key>;
|
|
243
244
|
}> = Partial<TTarget> & TMapped[keyof TMapped];
|
|
244
245
|
|
|
245
|
-
declare type AugmentedWidget<TWidgetFactory extends AnyWidgetFactory, TOverriddenKeys extends keyof Widget = 'init' | 'render' | 'dispose'> = Omit<ReturnType<TWidgetFactory>, TOverriddenKeys> & Pick<Required<Widget>, TOverriddenKeys>;
|
|
246
|
+
declare type AugmentedWidget<TWidgetFactory extends AnyWidgetFactory, TOverriddenKeys extends keyof Widget = 'init' | 'render' | 'dispose'> = Omit<ReturnType<TWidgetFactory>, TOverriddenKeys | 'dependsOn' | 'getWidgetParameters'> & Pick<Required<Widget>, TOverriddenKeys>;
|
|
246
247
|
|
|
247
248
|
declare type AutocompleteConnector = Connector<AutocompleteWidgetDescription, AutocompleteConnectorParams>;
|
|
248
249
|
|
|
@@ -302,6 +303,8 @@ declare type AutocompleteWidgetDescription = {
|
|
|
302
303
|
};
|
|
303
304
|
};
|
|
304
305
|
|
|
306
|
+
declare type Banner = NonNullable<NonNullable<Required<SearchResults<Hit>['renderingContent']>>['widgets']['banners']>[number];
|
|
307
|
+
|
|
305
308
|
declare type BaseHit = Record<string, unknown>;
|
|
306
309
|
|
|
307
310
|
declare type BindEventForHits = BuiltInBindEventForHits & CustomBindEventForHits;
|
|
@@ -1993,6 +1996,10 @@ declare type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
|
1993
1996
|
* The response from the Algolia API.
|
|
1994
1997
|
*/
|
|
1995
1998
|
results?: SearchResults<Hit<THit>>;
|
|
1999
|
+
/**
|
|
2000
|
+
* The banner to display above the hits.
|
|
2001
|
+
*/
|
|
2002
|
+
banner?: Banner;
|
|
1996
2003
|
/**
|
|
1997
2004
|
* Sends an event to the Insights middleware.
|
|
1998
2005
|
*/
|
|
@@ -2019,6 +2026,13 @@ declare type HitsTemplates = Partial<{
|
|
|
2019
2026
|
/** @deprecated the index in the hits array, use __position instead, which is the absolute position */
|
|
2020
2027
|
__hitIndex: number;
|
|
2021
2028
|
}>;
|
|
2029
|
+
/**
|
|
2030
|
+
* Template to use for the banner.
|
|
2031
|
+
*/
|
|
2032
|
+
banner: Template<{
|
|
2033
|
+
banner: Required<HitsRenderState['banner']>;
|
|
2034
|
+
className: string;
|
|
2035
|
+
}>;
|
|
2022
2036
|
}>;
|
|
2023
2037
|
|
|
2024
2038
|
declare type HitsWidget = WidgetFactory<HitsWidgetDescription & {
|
|
@@ -4007,6 +4021,13 @@ declare type Read<THit extends BaseHit> = ({ state, }: {
|
|
|
4007
4021
|
state: PlainSearchParameters;
|
|
4008
4022
|
}) => InfiniteHitsCachedHits<THit> | null;
|
|
4009
4023
|
|
|
4024
|
+
declare type RecommendWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
|
|
4025
|
+
dependsOn?: 'recommend';
|
|
4026
|
+
getWidgetParameters: (state: RecommendParameters, widgetParametersOptions: {
|
|
4027
|
+
uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
|
|
4028
|
+
}) => RecommendParameters;
|
|
4029
|
+
};
|
|
4030
|
+
|
|
4010
4031
|
declare type ReconfigurableOptions = Places.ReconfigurableOptions;
|
|
4011
4032
|
|
|
4012
4033
|
/**
|
|
@@ -4517,7 +4538,7 @@ declare type RequiredUiStateLifeCycle<TWidgetDescription extends WidgetDescripti
|
|
|
4517
4538
|
getWidgetSearchParameters: (state: SearchParameters, widgetSearchParametersOptions: {
|
|
4518
4539
|
uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
|
|
4519
4540
|
}) => SearchParameters;
|
|
4520
|
-
};
|
|
4541
|
+
} & (SearchWidgetLifeCycle<TWidgetDescription> | RecommendWidgetLifeCycle<TWidgetDescription>);
|
|
4521
4542
|
|
|
4522
4543
|
declare type RequiredWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
|
|
4523
4544
|
/**
|
|
@@ -4528,6 +4549,10 @@ declare type RequiredWidgetLifeCycle<TWidgetDescription extends WidgetDescriptio
|
|
|
4528
4549
|
* Called once before the first search.
|
|
4529
4550
|
*/
|
|
4530
4551
|
init?: (options: InitOptions) => void;
|
|
4552
|
+
/**
|
|
4553
|
+
* Whether `render` should be called
|
|
4554
|
+
*/
|
|
4555
|
+
shouldRender?: (options: ShouldRenderOptions) => boolean;
|
|
4531
4556
|
/**
|
|
4532
4557
|
* Called after each search response has been received.
|
|
4533
4558
|
*/
|
|
@@ -4843,6 +4868,13 @@ declare type SearchBoxWidgetParams = {
|
|
|
4843
4868
|
queryHook?: (query: string, hook: (value: string) => void) => void;
|
|
4844
4869
|
};
|
|
4845
4870
|
|
|
4871
|
+
declare type SearchWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
|
|
4872
|
+
dependsOn?: 'search';
|
|
4873
|
+
getWidgetParameters?: (state: SearchParameters, widgetParametersOptions: {
|
|
4874
|
+
uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
|
|
4875
|
+
}) => SearchParameters;
|
|
4876
|
+
};
|
|
4877
|
+
|
|
4846
4878
|
declare type SendEvent = (...args: [InsightsEvent] | [string, string, string?]) => void;
|
|
4847
4879
|
|
|
4848
4880
|
declare type SendEventForFacet = BuiltInSendEventForFacet & CustomSendEventForFacet;
|
|
@@ -4869,6 +4901,10 @@ declare type SharedRenderOptions = {
|
|
|
4869
4901
|
createURL: (nextState: SearchParameters | ((state: IndexUiState) => IndexUiState)) => string;
|
|
4870
4902
|
};
|
|
4871
4903
|
|
|
4904
|
+
declare type ShouldRenderOptions = {
|
|
4905
|
+
instantSearchInstance: InstantSearch;
|
|
4906
|
+
};
|
|
4907
|
+
|
|
4872
4908
|
declare function simpleStateMapping<TUiState extends UiState = UiState>(): StateMapping<TUiState, TUiState>;
|
|
4873
4909
|
|
|
4874
4910
|
declare function singleIndexStateMapping<TUiState extends UiState = UiState>(indexName: keyof TUiState): StateMapping<TUiState, TUiState[typeof indexName]>;
|