instantsearch.js 4.46.3 → 4.48.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/CHANGELOG.md +28 -0
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -1
- package/cjs/lib/InstantSearch.js +45 -6
- package/cjs/lib/utils/createSendEventForFacet.js +2 -1
- package/cjs/lib/utils/createSendEventForHits.js +1 -1
- package/cjs/lib/utils/index.js +13 -0
- package/cjs/lib/utils/render-args.js +47 -0
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +3 -5
- package/cjs/middlewares/createMetadataMiddleware.js +1 -15
- package/cjs/widgets/hierarchical-menu/defaultTemplates.js +3 -2
- package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +4 -0
- package/cjs/widgets/index/index.js +7 -85
- package/dist/instantsearch.development.d.ts +34 -11
- package/dist/instantsearch.development.js +110 -115
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +34 -11
- package/dist/instantsearch.production.min.d.ts +34 -11
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -1
- package/es/connectors/search-box/connectSearchBox.d.ts +1 -0
- package/es/lib/InstantSearch.d.ts +17 -4
- package/es/lib/InstantSearch.js +45 -6
- package/es/lib/utils/createSendEventForFacet.d.ts +4 -3
- package/es/lib/utils/createSendEventForFacet.js +2 -1
- package/es/lib/utils/createSendEventForHits.js +1 -1
- package/es/lib/utils/defer.d.ts +2 -2
- package/es/lib/utils/index.d.ts +1 -0
- package/es/lib/utils/index.js +1 -0
- package/es/lib/utils/render-args.d.ts +34 -0
- package/es/lib/utils/render-args.js +38 -0
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.d.ts +5 -5
- package/es/middlewares/createInsightsMiddleware.js +2 -2
- package/es/middlewares/createMetadataMiddleware.js +2 -16
- package/es/types/widget.d.ts +4 -0
- package/es/widgets/hierarchical-menu/defaultTemplates.js +3 -2
- package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +4 -0
- package/es/widgets/hierarchical-menu/hierarchical-menu.js +4 -0
- package/es/widgets/index/index.d.ts +1 -1
- package/es/widgets/index/index.js +8 -86
- package/package.json +7 -8
|
@@ -895,9 +895,9 @@ declare const connectVoiceSearch: VoiceSearchConnector;
|
|
|
895
895
|
|
|
896
896
|
declare function createInfiniteHitsSessionStorageCache(): InfiniteHitsCache;
|
|
897
897
|
|
|
898
|
-
declare type CreateInsightsMiddleware =
|
|
898
|
+
declare type CreateInsightsMiddleware = typeof createInsightsMiddleware;
|
|
899
899
|
|
|
900
|
-
declare
|
|
900
|
+
declare function createInsightsMiddleware<TInsightsClient extends null | InsightsClient>(props: InsightsProps<TInsightsClient>): InternalMiddleware;
|
|
901
901
|
|
|
902
902
|
/**
|
|
903
903
|
* Exposes the metadata of mounted widgets in a custom
|
|
@@ -1516,6 +1516,10 @@ declare type HierarchicalMenuCSSClasses = Partial<{
|
|
|
1516
1516
|
* CSS class to add to each link (when using the default template).
|
|
1517
1517
|
*/
|
|
1518
1518
|
link: string | string[];
|
|
1519
|
+
/**
|
|
1520
|
+
* CSS class to add to the link of each selected item element (when using the default template).
|
|
1521
|
+
*/
|
|
1522
|
+
selectedItemLink: string | string[];
|
|
1519
1523
|
/**
|
|
1520
1524
|
* CSS class to add to each label (when using the default template).
|
|
1521
1525
|
*/
|
|
@@ -2061,7 +2065,7 @@ declare type IndexWidget = Omit<Widget<IndexWidgetDescription & {
|
|
|
2061
2065
|
* @deprecated
|
|
2062
2066
|
*/
|
|
2063
2067
|
getWidgetState(uiState: UiState): UiState;
|
|
2064
|
-
getWidgetUiState<TUiState = UiState>(uiState: TUiState): TUiState;
|
|
2068
|
+
getWidgetUiState<TUiState extends UiState = UiState>(uiState: TUiState): TUiState;
|
|
2065
2069
|
getWidgetSearchParameters(searchParameters: SearchParameters, searchParametersOptions: {
|
|
2066
2070
|
uiState: IndexUiState;
|
|
2067
2071
|
}): SearchParameters;
|
|
@@ -2288,15 +2292,15 @@ declare type InsightsEvent = {
|
|
|
2288
2292
|
attribute?: string;
|
|
2289
2293
|
};
|
|
2290
2294
|
|
|
2291
|
-
declare type InsightsProps = {
|
|
2292
|
-
insightsClient:
|
|
2295
|
+
declare type InsightsProps<TInsightsClient extends null | InsightsClient = InsightsClient | null> = {
|
|
2296
|
+
insightsClient: TInsightsClient;
|
|
2293
2297
|
insightsInitParams?: {
|
|
2294
2298
|
userHasOptedOut?: boolean;
|
|
2295
2299
|
useCookie?: boolean;
|
|
2296
2300
|
cookieDuration?: number;
|
|
2297
2301
|
region?: 'de' | 'us';
|
|
2298
2302
|
};
|
|
2299
|
-
onEvent?: (event: InsightsEvent, insightsClient:
|
|
2303
|
+
onEvent?: (event: InsightsEvent, insightsClient: TInsightsClient) => void;
|
|
2300
2304
|
};
|
|
2301
2305
|
|
|
2302
2306
|
/**
|
|
@@ -2317,7 +2321,6 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2317
2321
|
renderState: RenderState;
|
|
2318
2322
|
_stalledSearchDelay: number;
|
|
2319
2323
|
_searchStalledTimer: any;
|
|
2320
|
-
_isSearchStalled: boolean;
|
|
2321
2324
|
_initialUiState: TUiState;
|
|
2322
2325
|
_initialResults: InitialResults | null;
|
|
2323
2326
|
_createURL: CreateURL<TUiState>;
|
|
@@ -2328,6 +2331,19 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2328
2331
|
instance: MiddlewareDefinition;
|
|
2329
2332
|
}>;
|
|
2330
2333
|
sendEventToInsights: (event: InsightsEvent) => void;
|
|
2334
|
+
/**
|
|
2335
|
+
* The status of the search. Can be "idle", "loading", "stalled", or "error".
|
|
2336
|
+
*/
|
|
2337
|
+
status: InstantSearchStatus;
|
|
2338
|
+
/**
|
|
2339
|
+
* The last returned error from the Search API.
|
|
2340
|
+
* The error gets cleared when the next valid search response is rendered.
|
|
2341
|
+
*/
|
|
2342
|
+
error: Error | undefined;
|
|
2343
|
+
/**
|
|
2344
|
+
* @deprecated use `status === 'stalled'` instead
|
|
2345
|
+
*/
|
|
2346
|
+
get _isSearchStalled(): boolean;
|
|
2331
2347
|
constructor(options: InstantSearchOptions<TUiState, TRouteState>);
|
|
2332
2348
|
/**
|
|
2333
2349
|
* Hooks a middleware into the InstantSearch lifecycle.
|
|
@@ -2381,11 +2397,11 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2381
2397
|
* @return {undefined} This method does not return anything
|
|
2382
2398
|
*/
|
|
2383
2399
|
dispose(): void;
|
|
2384
|
-
scheduleSearch: ((
|
|
2400
|
+
scheduleSearch: (() => void) & {
|
|
2385
2401
|
wait(): Promise<void>;
|
|
2386
2402
|
cancel(): void;
|
|
2387
2403
|
};
|
|
2388
|
-
scheduleRender: ((
|
|
2404
|
+
scheduleRender: ((shouldResetStatus?: boolean) => void) & {
|
|
2389
2405
|
wait(): Promise<void>;
|
|
2390
2406
|
cancel(): void;
|
|
2391
2407
|
};
|
|
@@ -2397,7 +2413,7 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2397
2413
|
*/
|
|
2398
2414
|
setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState), callOnStateChange?: boolean): void;
|
|
2399
2415
|
getUiState(): TUiState;
|
|
2400
|
-
onInternalStateChange: ((
|
|
2416
|
+
onInternalStateChange: (() => void) & {
|
|
2401
2417
|
wait(): Promise<void>;
|
|
2402
2418
|
cancel(): void;
|
|
2403
2419
|
};
|
|
@@ -2525,6 +2541,8 @@ declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteStat
|
|
|
2525
2541
|
insightsClient?: InsightsClient;
|
|
2526
2542
|
};
|
|
2527
2543
|
|
|
2544
|
+
declare type InstantSearchStatus = 'idle' | 'loading' | 'stalled' | 'error';
|
|
2545
|
+
|
|
2528
2546
|
declare type InternalMiddleware<TUiState extends UiState = UiState> = (options: MiddlewareOptions) => MiddlewareDefinition<TUiState>;
|
|
2529
2547
|
|
|
2530
2548
|
declare function isMetadataEnabled(): boolean;
|
|
@@ -2800,10 +2818,10 @@ declare type MiddlewareOptions = {
|
|
|
2800
2818
|
|
|
2801
2819
|
declare namespace middlewares {
|
|
2802
2820
|
export {
|
|
2821
|
+
createInsightsMiddleware,
|
|
2803
2822
|
InsightsEvent,
|
|
2804
2823
|
InsightsProps,
|
|
2805
2824
|
CreateInsightsMiddleware,
|
|
2806
|
-
createInsightsMiddleware,
|
|
2807
2825
|
RouterProps,
|
|
2808
2826
|
createRouterMiddleware,
|
|
2809
2827
|
isMetadataEnabled,
|
|
@@ -4592,6 +4610,7 @@ declare type SearchBoxRenderState = {
|
|
|
4592
4610
|
* `true` if the search results takes more than a certain time to come back
|
|
4593
4611
|
* from Algolia servers. This can be configured on the InstantSearch constructor with the attribute
|
|
4594
4612
|
* `stalledSearchDelay` which is 200ms, by default.
|
|
4613
|
+
* @deprecated use `instantSearchInstance.status` instead
|
|
4595
4614
|
*/
|
|
4596
4615
|
isSearchStalled: boolean;
|
|
4597
4616
|
};
|
|
@@ -4703,9 +4722,13 @@ declare type SharedRenderOptions = {
|
|
|
4703
4722
|
state: SearchParameters;
|
|
4704
4723
|
renderState: IndexRenderState;
|
|
4705
4724
|
helper: AlgoliaSearchHelper;
|
|
4725
|
+
/** @deprecated use `status` instead */
|
|
4706
4726
|
searchMetadata: {
|
|
4727
|
+
/** @deprecated use `status === "stalled"` instead */
|
|
4707
4728
|
isSearchStalled: boolean;
|
|
4708
4729
|
};
|
|
4730
|
+
status: InstantSearch['status'];
|
|
4731
|
+
error: InstantSearch['error'];
|
|
4709
4732
|
createURL(state: SearchParameters): string;
|
|
4710
4733
|
};
|
|
4711
4734
|
|
|
@@ -895,9 +895,9 @@ declare const connectVoiceSearch: VoiceSearchConnector;
|
|
|
895
895
|
|
|
896
896
|
declare function createInfiniteHitsSessionStorageCache(): InfiniteHitsCache;
|
|
897
897
|
|
|
898
|
-
declare type CreateInsightsMiddleware =
|
|
898
|
+
declare type CreateInsightsMiddleware = typeof createInsightsMiddleware;
|
|
899
899
|
|
|
900
|
-
declare
|
|
900
|
+
declare function createInsightsMiddleware<TInsightsClient extends null | InsightsClient>(props: InsightsProps<TInsightsClient>): InternalMiddleware;
|
|
901
901
|
|
|
902
902
|
/**
|
|
903
903
|
* Exposes the metadata of mounted widgets in a custom
|
|
@@ -1516,6 +1516,10 @@ declare type HierarchicalMenuCSSClasses = Partial<{
|
|
|
1516
1516
|
* CSS class to add to each link (when using the default template).
|
|
1517
1517
|
*/
|
|
1518
1518
|
link: string | string[];
|
|
1519
|
+
/**
|
|
1520
|
+
* CSS class to add to the link of each selected item element (when using the default template).
|
|
1521
|
+
*/
|
|
1522
|
+
selectedItemLink: string | string[];
|
|
1519
1523
|
/**
|
|
1520
1524
|
* CSS class to add to each label (when using the default template).
|
|
1521
1525
|
*/
|
|
@@ -2061,7 +2065,7 @@ declare type IndexWidget = Omit<Widget<IndexWidgetDescription & {
|
|
|
2061
2065
|
* @deprecated
|
|
2062
2066
|
*/
|
|
2063
2067
|
getWidgetState(uiState: UiState): UiState;
|
|
2064
|
-
getWidgetUiState<TUiState = UiState>(uiState: TUiState): TUiState;
|
|
2068
|
+
getWidgetUiState<TUiState extends UiState = UiState>(uiState: TUiState): TUiState;
|
|
2065
2069
|
getWidgetSearchParameters(searchParameters: SearchParameters, searchParametersOptions: {
|
|
2066
2070
|
uiState: IndexUiState;
|
|
2067
2071
|
}): SearchParameters;
|
|
@@ -2288,15 +2292,15 @@ declare type InsightsEvent = {
|
|
|
2288
2292
|
attribute?: string;
|
|
2289
2293
|
};
|
|
2290
2294
|
|
|
2291
|
-
declare type InsightsProps = {
|
|
2292
|
-
insightsClient:
|
|
2295
|
+
declare type InsightsProps<TInsightsClient extends null | InsightsClient = InsightsClient | null> = {
|
|
2296
|
+
insightsClient: TInsightsClient;
|
|
2293
2297
|
insightsInitParams?: {
|
|
2294
2298
|
userHasOptedOut?: boolean;
|
|
2295
2299
|
useCookie?: boolean;
|
|
2296
2300
|
cookieDuration?: number;
|
|
2297
2301
|
region?: 'de' | 'us';
|
|
2298
2302
|
};
|
|
2299
|
-
onEvent?: (event: InsightsEvent, insightsClient:
|
|
2303
|
+
onEvent?: (event: InsightsEvent, insightsClient: TInsightsClient) => void;
|
|
2300
2304
|
};
|
|
2301
2305
|
|
|
2302
2306
|
/**
|
|
@@ -2317,7 +2321,6 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2317
2321
|
renderState: RenderState;
|
|
2318
2322
|
_stalledSearchDelay: number;
|
|
2319
2323
|
_searchStalledTimer: any;
|
|
2320
|
-
_isSearchStalled: boolean;
|
|
2321
2324
|
_initialUiState: TUiState;
|
|
2322
2325
|
_initialResults: InitialResults | null;
|
|
2323
2326
|
_createURL: CreateURL<TUiState>;
|
|
@@ -2328,6 +2331,19 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2328
2331
|
instance: MiddlewareDefinition;
|
|
2329
2332
|
}>;
|
|
2330
2333
|
sendEventToInsights: (event: InsightsEvent) => void;
|
|
2334
|
+
/**
|
|
2335
|
+
* The status of the search. Can be "idle", "loading", "stalled", or "error".
|
|
2336
|
+
*/
|
|
2337
|
+
status: InstantSearchStatus;
|
|
2338
|
+
/**
|
|
2339
|
+
* The last returned error from the Search API.
|
|
2340
|
+
* The error gets cleared when the next valid search response is rendered.
|
|
2341
|
+
*/
|
|
2342
|
+
error: Error | undefined;
|
|
2343
|
+
/**
|
|
2344
|
+
* @deprecated use `status === 'stalled'` instead
|
|
2345
|
+
*/
|
|
2346
|
+
get _isSearchStalled(): boolean;
|
|
2331
2347
|
constructor(options: InstantSearchOptions<TUiState, TRouteState>);
|
|
2332
2348
|
/**
|
|
2333
2349
|
* Hooks a middleware into the InstantSearch lifecycle.
|
|
@@ -2381,11 +2397,11 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2381
2397
|
* @return {undefined} This method does not return anything
|
|
2382
2398
|
*/
|
|
2383
2399
|
dispose(): void;
|
|
2384
|
-
scheduleSearch: ((
|
|
2400
|
+
scheduleSearch: (() => void) & {
|
|
2385
2401
|
wait(): Promise<void>;
|
|
2386
2402
|
cancel(): void;
|
|
2387
2403
|
};
|
|
2388
|
-
scheduleRender: ((
|
|
2404
|
+
scheduleRender: ((shouldResetStatus?: boolean) => void) & {
|
|
2389
2405
|
wait(): Promise<void>;
|
|
2390
2406
|
cancel(): void;
|
|
2391
2407
|
};
|
|
@@ -2397,7 +2413,7 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2397
2413
|
*/
|
|
2398
2414
|
setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState), callOnStateChange?: boolean): void;
|
|
2399
2415
|
getUiState(): TUiState;
|
|
2400
|
-
onInternalStateChange: ((
|
|
2416
|
+
onInternalStateChange: (() => void) & {
|
|
2401
2417
|
wait(): Promise<void>;
|
|
2402
2418
|
cancel(): void;
|
|
2403
2419
|
};
|
|
@@ -2525,6 +2541,8 @@ declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteStat
|
|
|
2525
2541
|
insightsClient?: InsightsClient;
|
|
2526
2542
|
};
|
|
2527
2543
|
|
|
2544
|
+
declare type InstantSearchStatus = 'idle' | 'loading' | 'stalled' | 'error';
|
|
2545
|
+
|
|
2528
2546
|
declare type InternalMiddleware<TUiState extends UiState = UiState> = (options: MiddlewareOptions) => MiddlewareDefinition<TUiState>;
|
|
2529
2547
|
|
|
2530
2548
|
declare function isMetadataEnabled(): boolean;
|
|
@@ -2800,10 +2818,10 @@ declare type MiddlewareOptions = {
|
|
|
2800
2818
|
|
|
2801
2819
|
declare namespace middlewares {
|
|
2802
2820
|
export {
|
|
2821
|
+
createInsightsMiddleware,
|
|
2803
2822
|
InsightsEvent,
|
|
2804
2823
|
InsightsProps,
|
|
2805
2824
|
CreateInsightsMiddleware,
|
|
2806
|
-
createInsightsMiddleware,
|
|
2807
2825
|
RouterProps,
|
|
2808
2826
|
createRouterMiddleware,
|
|
2809
2827
|
isMetadataEnabled,
|
|
@@ -4592,6 +4610,7 @@ declare type SearchBoxRenderState = {
|
|
|
4592
4610
|
* `true` if the search results takes more than a certain time to come back
|
|
4593
4611
|
* from Algolia servers. This can be configured on the InstantSearch constructor with the attribute
|
|
4594
4612
|
* `stalledSearchDelay` which is 200ms, by default.
|
|
4613
|
+
* @deprecated use `instantSearchInstance.status` instead
|
|
4595
4614
|
*/
|
|
4596
4615
|
isSearchStalled: boolean;
|
|
4597
4616
|
};
|
|
@@ -4703,9 +4722,13 @@ declare type SharedRenderOptions = {
|
|
|
4703
4722
|
state: SearchParameters;
|
|
4704
4723
|
renderState: IndexRenderState;
|
|
4705
4724
|
helper: AlgoliaSearchHelper;
|
|
4725
|
+
/** @deprecated use `status` instead */
|
|
4706
4726
|
searchMetadata: {
|
|
4727
|
+
/** @deprecated use `status === "stalled"` instead */
|
|
4707
4728
|
isSearchStalled: boolean;
|
|
4708
4729
|
};
|
|
4730
|
+
status: InstantSearch['status'];
|
|
4731
|
+
error: InstantSearch['error'];
|
|
4709
4732
|
createURL(state: SearchParameters): string;
|
|
4710
4733
|
};
|
|
4711
4734
|
|