instantsearch.js 4.46.2 → 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 (46) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/cjs/components/CurrentRefinements/CurrentRefinements.js +9 -2
  3. package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -1
  4. package/cjs/lib/InstantSearch.js +45 -6
  5. package/cjs/lib/utils/createSendEventForFacet.js +2 -1
  6. package/cjs/lib/utils/createSendEventForHits.js +1 -1
  7. package/cjs/lib/utils/index.js +13 -0
  8. package/cjs/lib/utils/render-args.js +47 -0
  9. package/cjs/lib/version.js +1 -1
  10. package/cjs/middlewares/createMetadataMiddleware.js +1 -15
  11. package/cjs/widgets/current-refinements/current-refinements.js +7 -2
  12. package/cjs/widgets/hierarchical-menu/defaultTemplates.js +3 -2
  13. package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +4 -0
  14. package/cjs/widgets/index/index.js +6 -84
  15. package/dist/instantsearch.development.d.ts +31 -4
  16. package/dist/instantsearch.development.js +117 -116
  17. package/dist/instantsearch.development.js.map +1 -1
  18. package/dist/instantsearch.production.d.ts +31 -4
  19. package/dist/instantsearch.production.min.d.ts +31 -4
  20. package/dist/instantsearch.production.min.js +2 -2
  21. package/dist/instantsearch.production.min.js.map +1 -1
  22. package/es/components/CurrentRefinements/CurrentRefinements.d.ts +2 -1
  23. package/es/components/CurrentRefinements/CurrentRefinements.js +6 -2
  24. package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -1
  25. package/es/connectors/search-box/connectSearchBox.d.ts +1 -0
  26. package/es/lib/InstantSearch.d.ts +17 -4
  27. package/es/lib/InstantSearch.js +45 -6
  28. package/es/lib/utils/createSendEventForFacet.d.ts +4 -3
  29. package/es/lib/utils/createSendEventForFacet.js +2 -1
  30. package/es/lib/utils/createSendEventForHits.js +1 -1
  31. package/es/lib/utils/defer.d.ts +2 -2
  32. package/es/lib/utils/index.d.ts +1 -0
  33. package/es/lib/utils/index.js +1 -0
  34. package/es/lib/utils/render-args.d.ts +34 -0
  35. package/es/lib/utils/render-args.js +38 -0
  36. package/es/lib/version.d.ts +1 -1
  37. package/es/lib/version.js +1 -1
  38. package/es/middlewares/createMetadataMiddleware.js +2 -16
  39. package/es/types/widget.d.ts +4 -0
  40. package/es/widgets/current-refinements/current-refinements.d.ts +4 -0
  41. package/es/widgets/current-refinements/current-refinements.js +7 -2
  42. package/es/widgets/hierarchical-menu/defaultTemplates.js +3 -2
  43. package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +4 -0
  44. package/es/widgets/hierarchical-menu/hierarchical-menu.js +4 -0
  45. package/es/widgets/index/index.js +7 -85
  46. package/package.json +7 -7
@@ -1007,6 +1007,10 @@ declare type CurrentRefinementsCSSClasses = Partial<{
1007
1007
  * CSS class to add to the root element.
1008
1008
  */
1009
1009
  root: string | string[];
1010
+ /**
1011
+ * CSS class to add to the root element when no refinements.
1012
+ */
1013
+ noRefinementRoot: string | string[];
1010
1014
  /**
1011
1015
  * CSS class to add to the list element.
1012
1016
  */
@@ -1512,6 +1516,10 @@ declare type HierarchicalMenuCSSClasses = Partial<{
1512
1516
  * CSS class to add to each link (when using the default template).
1513
1517
  */
1514
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[];
1515
1523
  /**
1516
1524
  * CSS class to add to each label (when using the default template).
1517
1525
  */
@@ -2313,7 +2321,6 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
2313
2321
  renderState: RenderState;
2314
2322
  _stalledSearchDelay: number;
2315
2323
  _searchStalledTimer: any;
2316
- _isSearchStalled: boolean;
2317
2324
  _initialUiState: TUiState;
2318
2325
  _initialResults: InitialResults | null;
2319
2326
  _createURL: CreateURL<TUiState>;
@@ -2324,6 +2331,19 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
2324
2331
  instance: MiddlewareDefinition;
2325
2332
  }>;
2326
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;
2327
2347
  constructor(options: InstantSearchOptions<TUiState, TRouteState>);
2328
2348
  /**
2329
2349
  * Hooks a middleware into the InstantSearch lifecycle.
@@ -2377,11 +2397,11 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
2377
2397
  * @return {undefined} This method does not return anything
2378
2398
  */
2379
2399
  dispose(): void;
2380
- scheduleSearch: ((...args: any[]) => void) & {
2400
+ scheduleSearch: (() => void) & {
2381
2401
  wait(): Promise<void>;
2382
2402
  cancel(): void;
2383
2403
  };
2384
- scheduleRender: ((...args: any[]) => void) & {
2404
+ scheduleRender: ((shouldResetStatus?: boolean) => void) & {
2385
2405
  wait(): Promise<void>;
2386
2406
  cancel(): void;
2387
2407
  };
@@ -2393,7 +2413,7 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
2393
2413
  */
2394
2414
  setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState), callOnStateChange?: boolean): void;
2395
2415
  getUiState(): TUiState;
2396
- onInternalStateChange: ((...args: any[]) => void) & {
2416
+ onInternalStateChange: (() => void) & {
2397
2417
  wait(): Promise<void>;
2398
2418
  cancel(): void;
2399
2419
  };
@@ -2521,6 +2541,8 @@ declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteStat
2521
2541
  insightsClient?: InsightsClient;
2522
2542
  };
2523
2543
 
2544
+ declare type InstantSearchStatus = 'idle' | 'loading' | 'stalled' | 'error';
2545
+
2524
2546
  declare type InternalMiddleware<TUiState extends UiState = UiState> = (options: MiddlewareOptions) => MiddlewareDefinition<TUiState>;
2525
2547
 
2526
2548
  declare function isMetadataEnabled(): boolean;
@@ -4588,6 +4610,7 @@ declare type SearchBoxRenderState = {
4588
4610
  * `true` if the search results takes more than a certain time to come back
4589
4611
  * from Algolia servers. This can be configured on the InstantSearch constructor with the attribute
4590
4612
  * `stalledSearchDelay` which is 200ms, by default.
4613
+ * @deprecated use `instantSearchInstance.status` instead
4591
4614
  */
4592
4615
  isSearchStalled: boolean;
4593
4616
  };
@@ -4699,9 +4722,13 @@ declare type SharedRenderOptions = {
4699
4722
  state: SearchParameters;
4700
4723
  renderState: IndexRenderState;
4701
4724
  helper: AlgoliaSearchHelper;
4725
+ /** @deprecated use `status` instead */
4702
4726
  searchMetadata: {
4727
+ /** @deprecated use `status === "stalled"` instead */
4703
4728
  isSearchStalled: boolean;
4704
4729
  };
4730
+ status: InstantSearch['status'];
4731
+ error: InstantSearch['error'];
4705
4732
  createURL(state: SearchParameters): string;
4706
4733
  };
4707
4734
 
@@ -1007,6 +1007,10 @@ declare type CurrentRefinementsCSSClasses = Partial<{
1007
1007
  * CSS class to add to the root element.
1008
1008
  */
1009
1009
  root: string | string[];
1010
+ /**
1011
+ * CSS class to add to the root element when no refinements.
1012
+ */
1013
+ noRefinementRoot: string | string[];
1010
1014
  /**
1011
1015
  * CSS class to add to the list element.
1012
1016
  */
@@ -1512,6 +1516,10 @@ declare type HierarchicalMenuCSSClasses = Partial<{
1512
1516
  * CSS class to add to each link (when using the default template).
1513
1517
  */
1514
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[];
1515
1523
  /**
1516
1524
  * CSS class to add to each label (when using the default template).
1517
1525
  */
@@ -2313,7 +2321,6 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
2313
2321
  renderState: RenderState;
2314
2322
  _stalledSearchDelay: number;
2315
2323
  _searchStalledTimer: any;
2316
- _isSearchStalled: boolean;
2317
2324
  _initialUiState: TUiState;
2318
2325
  _initialResults: InitialResults | null;
2319
2326
  _createURL: CreateURL<TUiState>;
@@ -2324,6 +2331,19 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
2324
2331
  instance: MiddlewareDefinition;
2325
2332
  }>;
2326
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;
2327
2347
  constructor(options: InstantSearchOptions<TUiState, TRouteState>);
2328
2348
  /**
2329
2349
  * Hooks a middleware into the InstantSearch lifecycle.
@@ -2377,11 +2397,11 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
2377
2397
  * @return {undefined} This method does not return anything
2378
2398
  */
2379
2399
  dispose(): void;
2380
- scheduleSearch: ((...args: any[]) => void) & {
2400
+ scheduleSearch: (() => void) & {
2381
2401
  wait(): Promise<void>;
2382
2402
  cancel(): void;
2383
2403
  };
2384
- scheduleRender: ((...args: any[]) => void) & {
2404
+ scheduleRender: ((shouldResetStatus?: boolean) => void) & {
2385
2405
  wait(): Promise<void>;
2386
2406
  cancel(): void;
2387
2407
  };
@@ -2393,7 +2413,7 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
2393
2413
  */
2394
2414
  setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState), callOnStateChange?: boolean): void;
2395
2415
  getUiState(): TUiState;
2396
- onInternalStateChange: ((...args: any[]) => void) & {
2416
+ onInternalStateChange: (() => void) & {
2397
2417
  wait(): Promise<void>;
2398
2418
  cancel(): void;
2399
2419
  };
@@ -2521,6 +2541,8 @@ declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteStat
2521
2541
  insightsClient?: InsightsClient;
2522
2542
  };
2523
2543
 
2544
+ declare type InstantSearchStatus = 'idle' | 'loading' | 'stalled' | 'error';
2545
+
2524
2546
  declare type InternalMiddleware<TUiState extends UiState = UiState> = (options: MiddlewareOptions) => MiddlewareDefinition<TUiState>;
2525
2547
 
2526
2548
  declare function isMetadataEnabled(): boolean;
@@ -4588,6 +4610,7 @@ declare type SearchBoxRenderState = {
4588
4610
  * `true` if the search results takes more than a certain time to come back
4589
4611
  * from Algolia servers. This can be configured on the InstantSearch constructor with the attribute
4590
4612
  * `stalledSearchDelay` which is 200ms, by default.
4613
+ * @deprecated use `instantSearchInstance.status` instead
4591
4614
  */
4592
4615
  isSearchStalled: boolean;
4593
4616
  };
@@ -4699,9 +4722,13 @@ declare type SharedRenderOptions = {
4699
4722
  state: SearchParameters;
4700
4723
  renderState: IndexRenderState;
4701
4724
  helper: AlgoliaSearchHelper;
4725
+ /** @deprecated use `status` instead */
4702
4726
  searchMetadata: {
4727
+ /** @deprecated use `status === "stalled"` instead */
4703
4728
  isSearchStalled: boolean;
4704
4729
  };
4730
+ status: InstantSearch['status'];
4731
+ error: InstantSearch['error'];
4705
4732
  createURL(state: SearchParameters): string;
4706
4733
  };
4707
4734