instantsearch.js 4.44.1 → 4.46.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 (105) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/cjs/components/Hits/Hits.js +3 -1
  3. package/cjs/components/InfiniteHits/InfiniteHits.js +3 -1
  4. package/cjs/components/Template/Template.js +13 -3
  5. package/cjs/connectors/hits-per-page/connectHitsPerPage.js +3 -1
  6. package/cjs/connectors/numeric-menu/connectNumericMenu.js +27 -2
  7. package/cjs/connectors/rating-menu/connectRatingMenu.js +10 -4
  8. package/cjs/connectors/sort-by/connectSortBy.js +3 -1
  9. package/cjs/lib/createHelpers.js +3 -1
  10. package/cjs/lib/formatNumber.js +10 -0
  11. package/cjs/lib/utils/cx.js +10 -0
  12. package/cjs/lib/utils/index.js +10 -1
  13. package/cjs/lib/utils/renderTemplate.js +17 -2
  14. package/cjs/lib/version.js +1 -1
  15. package/cjs/widgets/answers/defaultTemplates.js +6 -2
  16. package/cjs/widgets/breadcrumb/defaultTemplates.js +6 -2
  17. package/cjs/widgets/clear-refinements/clear-refinements.js +2 -2
  18. package/cjs/widgets/clear-refinements/defaultTemplates.js +3 -1
  19. package/cjs/widgets/geo-search/createHTMLMarker.js +10 -4
  20. package/cjs/widgets/geo-search/defaultTemplates.js +18 -4
  21. package/cjs/widgets/hierarchical-menu/defaultTemplates.js +26 -2
  22. package/cjs/widgets/hits/defaultTemplates.js +3 -1
  23. package/cjs/widgets/infinite-hits/defaultTemplates.js +9 -3
  24. package/cjs/widgets/menu/defaultTemplates.js +26 -2
  25. package/cjs/widgets/menu-select/defaultTemplates.js +11 -2
  26. package/cjs/widgets/numeric-menu/defaultTemplates.js +20 -1
  27. package/cjs/widgets/range-input/range-input.js +6 -2
  28. package/cjs/widgets/rating-menu/defaultTemplates.js +57 -1
  29. package/cjs/widgets/refinement-list/defaultTemplates.js +38 -3
  30. package/cjs/widgets/relevant-sort/defaultTemplates.js +3 -1
  31. package/cjs/widgets/search-box/defaultTemplates.js +62 -3
  32. package/cjs/widgets/stats/stats.js +70 -22
  33. package/cjs/widgets/toggle-refinement/defaultTemplates.js +4 -1
  34. package/cjs/widgets/voice-search/defaultTemplates.js +81 -9
  35. package/dist/instantsearch.development.d.ts +171 -29
  36. package/dist/instantsearch.development.js +1430 -671
  37. package/dist/instantsearch.development.js.map +1 -1
  38. package/dist/instantsearch.production.d.ts +171 -29
  39. package/dist/instantsearch.production.min.d.ts +171 -29
  40. package/dist/instantsearch.production.min.js +2 -2
  41. package/dist/instantsearch.production.min.js.map +1 -1
  42. package/es/components/Answers/Answers.d.ts +2 -2
  43. package/es/components/Hits/Hits.d.ts +3 -3
  44. package/es/components/Hits/Hits.js +3 -1
  45. package/es/components/InfiniteHits/InfiniteHits.d.ts +3 -3
  46. package/es/components/InfiniteHits/InfiniteHits.js +3 -1
  47. package/es/components/Template/Template.d.ts +4 -2
  48. package/es/components/Template/Template.js +14 -4
  49. package/es/connectors/answers/connectAnswers.d.ts +2 -2
  50. package/es/connectors/autocomplete/connectAutocomplete.d.ts +2 -2
  51. package/es/connectors/hits-per-page/connectHitsPerPage.d.ts +5 -0
  52. package/es/connectors/hits-per-page/connectHitsPerPage.js +3 -1
  53. package/es/connectors/numeric-menu/connectNumericMenu.d.ts +8 -0
  54. package/es/connectors/numeric-menu/connectNumericMenu.js +27 -2
  55. package/es/connectors/rating-menu/connectRatingMenu.d.ts +2 -0
  56. package/es/connectors/rating-menu/connectRatingMenu.js +10 -4
  57. package/es/connectors/sort-by/connectSortBy.d.ts +5 -0
  58. package/es/connectors/sort-by/connectSortBy.js +3 -1
  59. package/es/lib/createHelpers.js +2 -1
  60. package/es/lib/formatNumber.d.ts +1 -0
  61. package/es/lib/formatNumber.js +3 -0
  62. package/es/lib/insights/client.d.ts +2 -2
  63. package/es/lib/utils/createSendEventForHits.d.ts +3 -3
  64. package/es/lib/utils/cx.d.ts +1 -0
  65. package/es/lib/utils/cx.js +3 -0
  66. package/es/lib/utils/index.d.ts +1 -0
  67. package/es/lib/utils/index.js +2 -1
  68. package/es/lib/utils/renderTemplate.d.ts +4 -3
  69. package/es/lib/utils/renderTemplate.js +15 -2
  70. package/es/lib/version.d.ts +1 -1
  71. package/es/lib/version.js +1 -1
  72. package/es/types/connector.d.ts +2 -2
  73. package/es/types/templates.d.ts +16 -3
  74. package/es/widgets/answers/defaultTemplates.js +6 -2
  75. package/es/widgets/breadcrumb/defaultTemplates.js +6 -2
  76. package/es/widgets/clear-refinements/clear-refinements.d.ts +3 -1
  77. package/es/widgets/clear-refinements/clear-refinements.js +2 -2
  78. package/es/widgets/clear-refinements/defaultTemplates.js +3 -1
  79. package/es/widgets/geo-search/createHTMLMarker.d.ts +2 -1
  80. package/es/widgets/geo-search/createHTMLMarker.js +8 -1
  81. package/es/widgets/geo-search/defaultTemplates.d.ts +1 -0
  82. package/es/widgets/geo-search/defaultTemplates.js +17 -4
  83. package/es/widgets/hierarchical-menu/defaultTemplates.js +22 -2
  84. package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +2 -0
  85. package/es/widgets/hits/defaultTemplates.js +3 -1
  86. package/es/widgets/hits/hits.d.ts +2 -1
  87. package/es/widgets/infinite-hits/defaultTemplates.js +9 -3
  88. package/es/widgets/infinite-hits/infinite-hits.d.ts +1 -3
  89. package/es/widgets/menu/defaultTemplates.js +22 -2
  90. package/es/widgets/menu-select/defaultTemplates.js +9 -2
  91. package/es/widgets/numeric-menu/defaultTemplates.js +18 -1
  92. package/es/widgets/range-input/range-input.js +6 -2
  93. package/es/widgets/rating-menu/defaultTemplates.js +54 -1
  94. package/es/widgets/rating-menu/rating-menu.d.ts +6 -0
  95. package/es/widgets/refinement-list/defaultTemplates.js +34 -3
  96. package/es/widgets/refinement-list/refinement-list.d.ts +7 -1
  97. package/es/widgets/relevant-sort/defaultTemplates.js +3 -1
  98. package/es/widgets/search-box/defaultTemplates.js +61 -3
  99. package/es/widgets/search-box/search-box.d.ts +10 -3
  100. package/es/widgets/stats/stats.d.ts +10 -6
  101. package/es/widgets/stats/stats.js +69 -22
  102. package/es/widgets/toggle-refinement/defaultTemplates.js +4 -1
  103. package/es/widgets/toggle-refinement/toggle-refinement.d.ts +3 -1
  104. package/es/widgets/voice-search/defaultTemplates.js +81 -9
  105. package/package.json +7 -5
@@ -3,6 +3,11 @@
3
3
  import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
4
4
  import EventEmitter from '@algolia/events';
5
5
  import { FindAnswersOptions } from 'algoliasearch-helper/types/algoliasearch.js';
6
+ import { h } from 'preact';
7
+ import type { HighlightClassNames as HighlightClassNames_2 } from '@algolia/ui-components-highlight-vdom';
8
+ import type { HighlightProps as HighlightProps_3 } from '@algolia/ui-components-highlight-vdom';
9
+ import type { HoganOptions } from 'hogan.js';
10
+ import type { html } from 'htm/preact';
6
11
  import type { InsightsClient as InsightsClient_2 } from 'search-insights';
7
12
  import type { InsightsMethodMap } from 'search-insights';
8
13
  import type * as Places from 'places.js';
@@ -11,6 +16,7 @@ import { default as qs_2 } from 'qs';
11
16
  import { SearchClient } from 'algoliasearch-helper/types/algoliasearch.js';
12
17
  import type { SearchParameters } from 'algoliasearch-helper';
13
18
  import type { SearchResults } from 'algoliasearch-helper';
19
+ import { VNode } from 'preact';
14
20
 
15
21
  declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
16
22
  objectID: string;
@@ -173,7 +179,7 @@ declare type AnswersRenderState = {
173
179
  /**
174
180
  * The matched hits from Algolia API.
175
181
  */
176
- hits: Hits;
182
+ hits: Hit[];
177
183
  /**
178
184
  * Whether it's still loading the results from the Answers API.
179
185
  */
@@ -264,7 +270,7 @@ declare type AutocompleteRenderState = {
264
270
  /**
265
271
  * The resolved hits from the index matching the query.
266
272
  */
267
- hits: Hits;
273
+ hits: Hit[];
268
274
  /**
269
275
  * The full results object from the Algolia API.
270
276
  */
@@ -518,11 +524,11 @@ declare type BrowserHistoryArgs<TRouteState> = {
518
524
  getLocation(): Location;
519
525
  };
520
526
 
521
- declare type BuiltInBindEventForHits = (eventType: string, hits: Hit | Hits, eventName?: string) => string;
527
+ declare type BuiltInBindEventForHits = (eventType: string, hits: Hit | Hit[], eventName?: string) => string;
522
528
 
523
529
  declare type BuiltInSendEventForFacet = (eventType: string, facetValue: string, eventName?: string) => void;
524
530
 
525
- declare type BuiltInSendEventForHits = (eventType: string, hits: Hit | Hits, eventName?: string) => void;
531
+ declare type BuiltInSendEventForHits = (eventType: string, hits: Hit | Hit[], eventName?: string) => void;
526
532
 
527
533
  declare type BuiltInSendEventForToggle = (eventType: string, isRefined: boolean, eventName?: string) => void;
528
534
 
@@ -584,7 +590,9 @@ declare type ClearRefinementsTemplates = Partial<{
584
590
  /**
585
591
  * Template for the content of the button
586
592
  */
587
- resetLabel: Template;
593
+ resetLabel: Template<{
594
+ hasRefinements: boolean;
595
+ }>;
588
596
  }>;
589
597
 
590
598
  declare type ClearRefinementsWidget = WidgetFactory<ClearRefinementsWidgetDescription & {
@@ -1588,6 +1596,8 @@ declare type HierarchicalMenuTemplates = Partial<{
1588
1596
  count: number;
1589
1597
  isRefined: boolean;
1590
1598
  url: string;
1599
+ label: string;
1600
+ cssClasses: HierarchicalMenuCSSClasses;
1591
1601
  }>;
1592
1602
  /**
1593
1603
  * Template used for the show more text, provided with `isShowingMore` data property.
@@ -1738,8 +1748,12 @@ declare type HierarchicalMenuWidgetParams = {
1738
1748
  cssClasses?: HierarchicalMenuCSSClasses;
1739
1749
  };
1740
1750
 
1751
+ declare function Highlight<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: HighlightProps<THit>): h.JSX.Element;
1752
+
1741
1753
  declare function highlight({ attribute, highlightedTagName, hit, cssClasses, }: HighlightOptions): string;
1742
1754
 
1755
+ declare type HighlightClassNames = HighlightClassNames_2;
1756
+
1743
1757
  declare type HighlightOptions = {
1744
1758
  attribute: string | string[];
1745
1759
  highlightedTagName?: string;
@@ -1749,6 +1763,16 @@ declare type HighlightOptions = {
1749
1763
  }>;
1750
1764
  };
1751
1765
 
1766
+ declare type HighlightProps<THit extends Hit<BaseHit>> = {
1767
+ hit: THit;
1768
+ attribute: keyof THit | string[];
1769
+ cssClasses?: HighlightProps_2['classNames'];
1770
+ } & PartialKeys<Omit<HighlightProps_2, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
1771
+
1772
+ declare type HighlightProps_2 = Omit<HighlightProps_3, 'classNames'> & {
1773
+ classNames?: Partial<HighlightClassNames>;
1774
+ };
1775
+
1752
1776
  declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
1753
1777
 
1754
1778
  declare type Hit<THit extends BaseHit = Record<string, any>> = {
@@ -1769,11 +1793,6 @@ declare type HitHighlightResult = {
1769
1793
  [attribute: string]: HitAttributeHighlightResult | HitAttributeHighlightResult[] | HitHighlightResult[] | HitHighlightResult;
1770
1794
  };
1771
1795
 
1772
- /**
1773
- * @deprecated use Hit[] directly instead
1774
- */
1775
- declare type Hits = Hit[];
1776
-
1777
1796
  declare const hits: HitsWidget;
1778
1797
 
1779
1798
  declare type HitsConnector<THit extends BaseHit = BaseHit> = Connector<HitsWidgetDescription<THit>, HitsConnectorParams<THit>>;
@@ -1872,8 +1891,13 @@ declare type HitsPerPageRenderState = {
1872
1891
  refine: (value: number) => void;
1873
1892
  /**
1874
1893
  * Indicates whether or not the search has results.
1894
+ * @deprecated Use `canRefine` instead.
1875
1895
  */
1876
1896
  hasNoResults: boolean;
1897
+ /**
1898
+ * Indicates if search state can be refined.
1899
+ */
1900
+ canRefine: boolean;
1877
1901
  };
1878
1902
 
1879
1903
  declare type HitsPerPageRenderStateItem = {
@@ -1942,7 +1966,7 @@ declare type HitsTemplates = Partial<{
1942
1966
  *
1943
1967
  * @default 'No Results'
1944
1968
  */
1945
- empty: Template;
1969
+ empty: Template<SearchResults>;
1946
1970
  /**
1947
1971
  * Template to use for each result. This template will receive an object containing a single record.
1948
1972
  *
@@ -1980,11 +2004,13 @@ declare type HitsWidgetParams = {
1980
2004
  cssClasses?: HitsCSSClasses;
1981
2005
  };
1982
2006
 
2007
+ declare type HoganHelpers<TKeys extends string = string> = Record<TKeys, (text: string, render: (value: string) => string) => string>;
2008
+
1983
2009
  declare type HTMLMarkerArguments = {
1984
2010
  __id: string;
1985
2011
  position: google.maps.LatLngLiteral;
1986
2012
  map: google.maps.Map;
1987
- template: string;
2013
+ template: ReturnType<typeof renderTemplate>;
1988
2014
  title?: string;
1989
2015
  className: string;
1990
2016
  anchor?: {
@@ -2163,9 +2189,7 @@ declare type InfiniteHitsTemplates = Partial<{
2163
2189
  /**
2164
2190
  * The template to use when there are no results.
2165
2191
  */
2166
- empty: Template<{
2167
- results: SearchResults;
2168
- }>;
2192
+ empty: Template<SearchResults>;
2169
2193
  /**
2170
2194
  * The template to use for the “Show previous” label.
2171
2195
  */
@@ -2401,6 +2425,10 @@ declare type InstantSearchModule = {
2401
2425
  reverseHighlight: typeof helpers.reverseHighlight;
2402
2426
  snippet: typeof helpers.snippet;
2403
2427
  reverseSnippet: typeof helpers.reverseSnippet;
2428
+ /**
2429
+ * @deprecated use createInsightsMiddleware
2430
+ * @link https://www.algolia.com/doc/api-reference/widgets/insights/js/
2431
+ */
2404
2432
  insights: typeof helpers.insights;
2405
2433
  };
2406
2434
 
@@ -2855,8 +2883,16 @@ declare type NumericMenuRenderState = {
2855
2883
  createURL: CreateURL<NumericMenuRenderStateItem['value']>;
2856
2884
  /**
2857
2885
  * `true` if the last search contains no result
2886
+ * @deprecated Use `canRefine` instead.
2858
2887
  */
2859
2888
  hasNoResults: boolean;
2889
+ /**
2890
+ * Indicates if search state can be refined.
2891
+ *
2892
+ * This is `true` if the last search contains no result and
2893
+ * "All" range is selected
2894
+ */
2895
+ canRefine: boolean;
2860
2896
  /**
2861
2897
  * Sets the selected value and trigger a new search
2862
2898
  */
@@ -3223,6 +3259,11 @@ declare type ParseURL<TRouteState> = (args: {
3223
3259
  location: Location;
3224
3260
  }) => TRouteState;
3225
3261
 
3262
+ /**
3263
+ * Make certain keys of an object optional.
3264
+ */
3265
+ declare type PartialKeys<TObj, TKeys extends keyof TObj> = Omit<TObj, TKeys> & Partial<Pick<TObj, TKeys>>;
3266
+
3226
3267
  declare type PlacesInstance = Places.PlacesInstance;
3227
3268
 
3228
3269
  declare type PlacesWidget = WidgetFactory<PlacesWidgetDescription, PlacesWidgetParams, PlacesWidgetParams>;
@@ -3721,6 +3762,8 @@ declare type RatingMenuRenderState = {
3721
3762
  refine: (value: string) => void;
3722
3763
  /**
3723
3764
  * `true` if the last search contains no result.
3765
+ *
3766
+ * @deprecated Use `canRefine` instead.
3724
3767
  */
3725
3768
  hasNoResults: boolean;
3726
3769
  /**
@@ -3735,9 +3778,15 @@ declare type RatingMenuTemplates = Partial<{
3735
3778
  */
3736
3779
  item: Template<{
3737
3780
  name: string;
3781
+ label: string;
3782
+ value: string;
3738
3783
  count: number;
3739
3784
  isRefined: boolean;
3740
3785
  url: string;
3786
+ stars: [boolean, boolean, boolean, boolean, boolean];
3787
+ cssClasses: RatingMenuCSSClasses;
3788
+ attribute?: string;
3789
+ isFromSearch?: boolean;
3741
3790
  }>;
3742
3791
  }>;
3743
3792
 
@@ -3940,6 +3989,10 @@ declare type RefinementListItemData = {
3940
3989
  * Object containing all the classes computed for the item.
3941
3990
  */
3942
3991
  cssClasses: RefinementListCSSClasses;
3992
+ /**
3993
+ * Whether the `items` prop contains facet values from the global search or from the search inside the items.
3994
+ */
3995
+ isFromSearch: boolean;
3943
3996
  };
3944
3997
 
3945
3998
  declare type RefinementListOwnCSSClasses = Partial<{
@@ -4005,7 +4058,9 @@ declare type RefinementListOwnTemplates = Partial<{
4005
4058
  /**
4006
4059
  * Template used for the show more text, provided with `isShowingMore` data property.
4007
4060
  */
4008
- showMoreText: Template;
4061
+ showMoreText: Template<{
4062
+ isShowingMore: boolean;
4063
+ }>;
4009
4064
  /**
4010
4065
  * Templates to use for search for facet values when there are no results.
4011
4066
  */
@@ -4240,7 +4295,7 @@ declare type RendererOptions<TWidgetParams> = {
4240
4295
  * The mutable list of hits. The may change depending
4241
4296
  * of the given transform items function.
4242
4297
  */
4243
- hits?: Hits;
4298
+ hits?: Hit[];
4244
4299
  /**
4245
4300
  * The current insights client, if any.
4246
4301
  */
@@ -4257,6 +4312,16 @@ declare type RenderState = {
4257
4312
 
4258
4313
  declare type RenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = TWidgetDescription extends RequiredKeys<WidgetDescription, 'renderState' | 'indexRenderState'> & WidgetParams ? RequiredRenderStateLifeCycle<TWidgetDescription> : Partial<RequiredRenderStateLifeCycle<TWidgetDescription>>;
4259
4314
 
4315
+ declare function renderTemplate({ templates, templateKey, compileOptions, helpers, data, bindEvent, sendEvent, }: {
4316
+ templates: Templates;
4317
+ templateKey: string;
4318
+ compileOptions?: HoganOptions;
4319
+ helpers?: HoganHelpers;
4320
+ data?: Record<string, any>;
4321
+ bindEvent?: BindEventForHits;
4322
+ sendEvent?: SendEventForHits;
4323
+ }): string | VNode< {}> | VNode< {}>[];
4324
+
4260
4325
  declare type RequiredKeys<TObject, TKeys extends keyof TObject> = Expand<Required<Pick<TObject, TKeys>> & Omit<TObject, TKeys>>;
4261
4326
 
4262
4327
  declare type RequiredRenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = {
@@ -4334,8 +4399,12 @@ declare type RequiredWidgetType<TWidgetDescription extends WidgetDescription> =
4334
4399
  $$widgetType: TWidgetDescription['$$widgetType'];
4335
4400
  };
4336
4401
 
4402
+ declare function ReverseHighlight<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: ReverseHighlightProps<THit>): h.JSX.Element;
4403
+
4337
4404
  declare function reverseHighlight({ attribute, highlightedTagName, hit, cssClasses, }: ReverseHighlightOptions): string;
4338
4405
 
4406
+ declare type ReverseHighlightClassNames = HighlightClassNames_2;
4407
+
4339
4408
  declare type ReverseHighlightOptions = {
4340
4409
  attribute: string | string[];
4341
4410
  highlightedTagName?: string;
@@ -4345,8 +4414,22 @@ declare type ReverseHighlightOptions = {
4345
4414
  }>;
4346
4415
  };
4347
4416
 
4417
+ declare type ReverseHighlightProps<THit extends Hit<BaseHit>> = {
4418
+ hit: THit;
4419
+ attribute: keyof THit | string[];
4420
+ cssClasses?: ReverseHighlightProps_2['classNames'];
4421
+ } & PartialKeys<Omit<ReverseHighlightProps_2, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
4422
+
4423
+ declare type ReverseHighlightProps_2 = Omit<HighlightProps_3, 'classNames'> & {
4424
+ classNames?: Partial<ReverseHighlightClassNames>;
4425
+ };
4426
+
4427
+ declare function ReverseSnippet<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: ReverseSnippetProps<THit>): h.JSX.Element;
4428
+
4348
4429
  declare function reverseSnippet({ attribute, highlightedTagName, hit, cssClasses, }: ReverseSnippetOptions): string;
4349
4430
 
4431
+ declare type ReverseSnippetClassNames = HighlightClassNames_2;
4432
+
4350
4433
  declare type ReverseSnippetOptions = {
4351
4434
  attribute: string | string[];
4352
4435
  highlightedTagName?: string;
@@ -4356,6 +4439,16 @@ declare type ReverseSnippetOptions = {
4356
4439
  }>;
4357
4440
  };
4358
4441
 
4442
+ declare type ReverseSnippetProps<THit extends Hit<BaseHit>> = {
4443
+ hit: THit;
4444
+ attribute: keyof THit | string[];
4445
+ cssClasses?: ReverseSnippetProps_2['classNames'];
4446
+ } & PartialKeys<Omit<ReverseSnippetProps_2, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
4447
+
4448
+ declare type ReverseSnippetProps_2 = Omit<HighlightProps_3, 'classNames'> & {
4449
+ classNames?: Partial<ReverseSnippetClassNames>;
4450
+ };
4451
+
4359
4452
  /**
4360
4453
  * The router is the part that saves and reads the object from the storage.
4361
4454
  * Usually this is the URL.
@@ -4408,6 +4501,8 @@ declare type ScopedResult = {
4408
4501
 
4409
4502
  declare const searchBox: SearchBoxWidget;
4410
4503
 
4504
+ declare type SearchBoxComponentCSSClasses = ComponentCSSClasses<SearchBoxCSSClasses>;
4505
+
4411
4506
  declare type SearchBoxConnector = Connector<SearchBoxWidgetDescription, SearchBoxConnectorParams>;
4412
4507
 
4413
4508
  declare type SearchBoxConnectorParams = {
@@ -4493,15 +4588,21 @@ declare type SearchBoxTemplates = Partial<{
4493
4588
  /**
4494
4589
  * Template used for displaying the submit button. Can accept a function or a Hogan string.
4495
4590
  */
4496
- submit: Template;
4591
+ submit: Template<{
4592
+ cssClasses: SearchBoxComponentCSSClasses;
4593
+ }>;
4497
4594
  /**
4498
4595
  * Template used for displaying the reset button. Can accept a function or a Hogan string.
4499
4596
  */
4500
- reset: Template;
4597
+ reset: Template<{
4598
+ cssClasses: SearchBoxComponentCSSClasses;
4599
+ }>;
4501
4600
  /**
4502
4601
  * Template used for displaying the loading indicator. Can accept a function or a Hogan string.
4503
4602
  */
4504
- loadingIndicator: Template;
4603
+ loadingIndicator: Template<{
4604
+ cssClasses: SearchBoxComponentCSSClasses;
4605
+ }>;
4505
4606
  }>;
4506
4607
 
4507
4608
  /**
@@ -4600,8 +4701,12 @@ declare function simpleStateMapping<TUiState extends UiState = UiState>(): State
4600
4701
 
4601
4702
  declare function singleIndexStateMapping<TUiState extends UiState = UiState>(indexName: keyof TUiState): StateMapping<TUiState, TUiState[typeof indexName]>;
4602
4703
 
4704
+ declare function Snippet<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: SnippetProps<THit>): h.JSX.Element;
4705
+
4603
4706
  declare function snippet({ attribute, highlightedTagName, hit, cssClasses, }: SnippetOptions): string;
4604
4707
 
4708
+ declare type SnippetClassNames = HighlightClassNames_2;
4709
+
4605
4710
  declare type SnippetOptions = {
4606
4711
  attribute: string | string[];
4607
4712
  highlightedTagName?: string;
@@ -4611,6 +4716,16 @@ declare type SnippetOptions = {
4611
4716
  };
4612
4717
  };
4613
4718
 
4719
+ declare type SnippetProps<THit extends Hit<BaseHit>> = {
4720
+ hit: THit;
4721
+ attribute: keyof THit | string[];
4722
+ cssClasses?: SnippetProps_2['classNames'];
4723
+ } & PartialKeys<Omit<SnippetProps_2, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
4724
+
4725
+ declare type SnippetProps_2 = Omit<HighlightProps_3, 'classNames'> & {
4726
+ classNames?: Partial<SnippetClassNames>;
4727
+ };
4728
+
4614
4729
  /**
4615
4730
  * Transforms the given items.
4616
4731
  */
@@ -4683,8 +4798,13 @@ declare type SortByRenderState = {
4683
4798
  refine: (value: string) => void;
4684
4799
  /**
4685
4800
  * `true` if the last search contains no result.
4801
+ * @deprecated Use `canRefine` instead.
4686
4802
  */
4687
4803
  hasNoResults: boolean;
4804
+ /**
4805
+ * `true` if we can refine.
4806
+ */
4807
+ canRefine: boolean;
4688
4808
  };
4689
4809
 
4690
4810
  declare type SortByWidget = WidgetFactory<SortByWidgetDescription & {
@@ -4858,13 +4978,9 @@ declare type StatsRenderState = {
4858
4978
 
4859
4979
  declare type StatsTemplates = Partial<{
4860
4980
  /**
4861
- * Text template, provided with `hasManyResults`, `hasNoResults`, `hasOneResult`, `hitsPerPage`, `nbHits`, `nbSortedHits`, `nbPages`, `areHitsSorted`, `page`, `processingTimeMS`, `query`.
4981
+ * Text template, provided with `hasManyResults`, `hasNoResults`, `hasOneResult`, `hasNoSortedResults`, `hasOneSortedResults`, `hasManySortedResults`, `hitsPerPage`, `nbHits`, `nbSortedHits`, `nbPages`, `areHitsSorted`, `page`, `processingTimeMS`, `query`.
4862
4982
  */
4863
- text: Template<{
4864
- hasManyResults: boolean;
4865
- hasNoResults: boolean;
4866
- hasOneResult: boolean;
4867
- } & StatsRenderState>;
4983
+ text: Template<TextTemplateProps & StatsRenderState>;
4868
4984
  }>;
4869
4985
 
4870
4986
  declare type StatsWidget = WidgetFactory<StatsWidgetDescription & {
@@ -4896,9 +5012,33 @@ declare type StatsWidgetParams = {
4896
5012
 
4897
5013
  declare type Status = 'initial' | 'askingPermission' | 'waiting' | 'recognizing' | 'finished' | 'error';
4898
5014
 
4899
- declare type Template<TTemplateData = void> = string | ((data: TTemplateData) => string);
5015
+ declare type Template<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string);
5016
+
5017
+ declare type TemplateParams = BindEventForHits & {
5018
+ html: typeof html;
5019
+ components: {
5020
+ Highlight: typeof Highlight;
5021
+ ReverseHighlight: typeof ReverseHighlight;
5022
+ Snippet: typeof Snippet;
5023
+ ReverseSnippet: typeof ReverseSnippet;
5024
+ };
5025
+ sendEvent?: SendEventForHits;
5026
+ };
4900
5027
 
4901
- declare type TemplateWithBindEvent<TTemplateData = void> = string | ((data: TTemplateData, bindEvent: BindEventForHits) => string);
5028
+ declare type Templates = {
5029
+ [key: string]: Template<any> | TemplateWithBindEvent<any> | undefined;
5030
+ };
5031
+
5032
+ declare type TemplateWithBindEvent<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string);
5033
+
5034
+ declare type TextTemplateProps = {
5035
+ hasManyResults: boolean;
5036
+ hasNoResults: boolean;
5037
+ hasOneResult: boolean;
5038
+ hasNoSortedResults: boolean;
5039
+ hasOneSortedResults: boolean;
5040
+ hasManySortedResults: boolean;
5041
+ };
4902
5042
 
4903
5043
  /**
4904
5044
  * The toggleRefinement widget lets the user either:
@@ -4999,7 +5139,9 @@ declare type ToggleRefinementTemplates = Partial<{
4999
5139
  /**
5000
5140
  * the text that describes the toggle action
5001
5141
  */
5002
- labelText: Template<ToggleRefinementValue>;
5142
+ labelText: Template<ToggleRefinementValue & {
5143
+ name: string;
5144
+ }>;
5003
5145
  }>;
5004
5146
 
5005
5147
  declare type ToggleRefinementValue = {