instantsearch.js 4.46.3 → 4.47.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -1
  3. package/cjs/lib/InstantSearch.js +45 -6
  4. package/cjs/lib/utils/createSendEventForFacet.js +2 -1
  5. package/cjs/lib/utils/createSendEventForHits.js +1 -1
  6. package/cjs/lib/utils/index.js +13 -0
  7. package/cjs/lib/utils/render-args.js +47 -0
  8. package/cjs/lib/version.js +1 -1
  9. package/cjs/middlewares/createMetadataMiddleware.js +1 -15
  10. package/cjs/widgets/hierarchical-menu/defaultTemplates.js +3 -2
  11. package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +4 -0
  12. package/cjs/widgets/index/index.js +6 -84
  13. package/dist/instantsearch.development.d.ts +27 -4
  14. package/dist/instantsearch.development.js +107 -112
  15. package/dist/instantsearch.development.js.map +1 -1
  16. package/dist/instantsearch.production.d.ts +27 -4
  17. package/dist/instantsearch.production.min.d.ts +27 -4
  18. package/dist/instantsearch.production.min.js +2 -2
  19. package/dist/instantsearch.production.min.js.map +1 -1
  20. package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -1
  21. package/es/connectors/search-box/connectSearchBox.d.ts +1 -0
  22. package/es/lib/InstantSearch.d.ts +17 -4
  23. package/es/lib/InstantSearch.js +45 -6
  24. package/es/lib/utils/createSendEventForFacet.d.ts +4 -3
  25. package/es/lib/utils/createSendEventForFacet.js +2 -1
  26. package/es/lib/utils/createSendEventForHits.js +1 -1
  27. package/es/lib/utils/defer.d.ts +2 -2
  28. package/es/lib/utils/index.d.ts +1 -0
  29. package/es/lib/utils/index.js +1 -0
  30. package/es/lib/utils/render-args.d.ts +34 -0
  31. package/es/lib/utils/render-args.js +38 -0
  32. package/es/lib/version.d.ts +1 -1
  33. package/es/lib/version.js +1 -1
  34. package/es/middlewares/createMetadataMiddleware.js +2 -16
  35. package/es/types/widget.d.ts +4 -0
  36. package/es/widgets/hierarchical-menu/defaultTemplates.js +3 -2
  37. package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +4 -0
  38. package/es/widgets/hierarchical-menu/hierarchical-menu.js +4 -0
  39. package/es/widgets/index/index.js +7 -85
  40. package/package.json +7 -7
@@ -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
  */
@@ -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: ((...args: any[]) => void) & {
2400
+ scheduleSearch: (() => void) & {
2385
2401
  wait(): Promise<void>;
2386
2402
  cancel(): void;
2387
2403
  };
2388
- scheduleRender: ((...args: any[]) => void) & {
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: ((...args: any[]) => void) & {
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;
@@ -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
 
@@ -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
  */
@@ -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: ((...args: any[]) => void) & {
2400
+ scheduleSearch: (() => void) & {
2385
2401
  wait(): Promise<void>;
2386
2402
  cancel(): void;
2387
2403
  };
2388
- scheduleRender: ((...args: any[]) => void) & {
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: ((...args: any[]) => void) & {
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;
@@ -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