instantsearch.js 4.45.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.
- package/CHANGELOG.md +10 -0
- package/cjs/components/Hits/Hits.js +3 -1
- package/cjs/components/InfiniteHits/InfiniteHits.js +3 -1
- package/cjs/components/Template/Template.js +13 -3
- package/cjs/lib/createHelpers.js +3 -1
- package/cjs/lib/formatNumber.js +10 -0
- package/cjs/lib/utils/cx.js +10 -0
- package/cjs/lib/utils/index.js +10 -1
- package/cjs/lib/utils/renderTemplate.js +17 -2
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/answers/defaultTemplates.js +6 -2
- package/cjs/widgets/breadcrumb/defaultTemplates.js +6 -2
- package/cjs/widgets/clear-refinements/defaultTemplates.js +3 -1
- package/cjs/widgets/geo-search/createHTMLMarker.js +10 -4
- package/cjs/widgets/geo-search/defaultTemplates.js +18 -4
- package/cjs/widgets/hierarchical-menu/defaultTemplates.js +26 -2
- package/cjs/widgets/hits/defaultTemplates.js +3 -1
- package/cjs/widgets/infinite-hits/defaultTemplates.js +9 -3
- package/cjs/widgets/menu/defaultTemplates.js +26 -2
- package/cjs/widgets/menu-select/defaultTemplates.js +11 -2
- package/cjs/widgets/numeric-menu/defaultTemplates.js +20 -1
- package/cjs/widgets/range-input/range-input.js +6 -2
- package/cjs/widgets/rating-menu/defaultTemplates.js +57 -1
- package/cjs/widgets/refinement-list/defaultTemplates.js +38 -3
- package/cjs/widgets/relevant-sort/defaultTemplates.js +3 -1
- package/cjs/widgets/search-box/defaultTemplates.js +62 -3
- package/cjs/widgets/stats/stats.js +70 -22
- package/cjs/widgets/toggle-refinement/defaultTemplates.js +4 -1
- package/cjs/widgets/voice-search/defaultTemplates.js +81 -9
- package/dist/instantsearch.development.d.ts +142 -19
- package/dist/instantsearch.development.js +1232 -563
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +142 -19
- package/dist/instantsearch.production.min.d.ts +142 -19
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Hits/Hits.d.ts +1 -1
- package/es/components/Hits/Hits.js +3 -1
- package/es/components/InfiniteHits/InfiniteHits.d.ts +1 -1
- package/es/components/InfiniteHits/InfiniteHits.js +3 -1
- package/es/components/Template/Template.d.ts +4 -2
- package/es/components/Template/Template.js +14 -4
- package/es/lib/createHelpers.js +2 -1
- package/es/lib/formatNumber.d.ts +1 -0
- package/es/lib/formatNumber.js +3 -0
- package/es/lib/utils/cx.d.ts +1 -0
- package/es/lib/utils/cx.js +3 -0
- package/es/lib/utils/index.d.ts +1 -0
- package/es/lib/utils/index.js +2 -1
- package/es/lib/utils/renderTemplate.d.ts +4 -3
- package/es/lib/utils/renderTemplate.js +15 -2
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/types/templates.d.ts +16 -3
- package/es/widgets/answers/defaultTemplates.js +6 -2
- package/es/widgets/breadcrumb/defaultTemplates.js +6 -2
- package/es/widgets/clear-refinements/clear-refinements.d.ts +3 -1
- package/es/widgets/clear-refinements/defaultTemplates.js +3 -1
- package/es/widgets/geo-search/createHTMLMarker.d.ts +2 -1
- package/es/widgets/geo-search/createHTMLMarker.js +8 -1
- package/es/widgets/geo-search/defaultTemplates.d.ts +1 -0
- package/es/widgets/geo-search/defaultTemplates.js +17 -4
- package/es/widgets/hierarchical-menu/defaultTemplates.js +22 -2
- package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +2 -0
- package/es/widgets/hits/defaultTemplates.js +3 -1
- package/es/widgets/hits/hits.d.ts +2 -1
- package/es/widgets/infinite-hits/defaultTemplates.js +9 -3
- package/es/widgets/infinite-hits/infinite-hits.d.ts +1 -3
- package/es/widgets/menu/defaultTemplates.js +22 -2
- package/es/widgets/menu-select/defaultTemplates.js +9 -2
- package/es/widgets/numeric-menu/defaultTemplates.js +18 -1
- package/es/widgets/range-input/range-input.js +6 -2
- package/es/widgets/rating-menu/defaultTemplates.js +54 -1
- package/es/widgets/rating-menu/rating-menu.d.ts +6 -0
- package/es/widgets/refinement-list/defaultTemplates.js +34 -3
- package/es/widgets/refinement-list/refinement-list.d.ts +7 -1
- package/es/widgets/relevant-sort/defaultTemplates.js +3 -1
- package/es/widgets/search-box/defaultTemplates.js +61 -3
- package/es/widgets/search-box/search-box.d.ts +10 -3
- package/es/widgets/stats/stats.d.ts +10 -6
- package/es/widgets/stats/stats.js +69 -22
- package/es/widgets/toggle-refinement/defaultTemplates.js +4 -1
- package/es/widgets/toggle-refinement/toggle-refinement.d.ts +3 -1
- package/es/widgets/voice-search/defaultTemplates.js +81 -9
- package/package.json +6 -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;
|
|
@@ -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>> = {
|
|
@@ -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:
|
|
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
|
*/
|
|
@@ -3235,6 +3259,11 @@ declare type ParseURL<TRouteState> = (args: {
|
|
|
3235
3259
|
location: Location;
|
|
3236
3260
|
}) => TRouteState;
|
|
3237
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
|
+
|
|
3238
3267
|
declare type PlacesInstance = Places.PlacesInstance;
|
|
3239
3268
|
|
|
3240
3269
|
declare type PlacesWidget = WidgetFactory<PlacesWidgetDescription, PlacesWidgetParams, PlacesWidgetParams>;
|
|
@@ -3749,9 +3778,15 @@ declare type RatingMenuTemplates = Partial<{
|
|
|
3749
3778
|
*/
|
|
3750
3779
|
item: Template<{
|
|
3751
3780
|
name: string;
|
|
3781
|
+
label: string;
|
|
3782
|
+
value: string;
|
|
3752
3783
|
count: number;
|
|
3753
3784
|
isRefined: boolean;
|
|
3754
3785
|
url: string;
|
|
3786
|
+
stars: [boolean, boolean, boolean, boolean, boolean];
|
|
3787
|
+
cssClasses: RatingMenuCSSClasses;
|
|
3788
|
+
attribute?: string;
|
|
3789
|
+
isFromSearch?: boolean;
|
|
3755
3790
|
}>;
|
|
3756
3791
|
}>;
|
|
3757
3792
|
|
|
@@ -3954,6 +3989,10 @@ declare type RefinementListItemData = {
|
|
|
3954
3989
|
* Object containing all the classes computed for the item.
|
|
3955
3990
|
*/
|
|
3956
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;
|
|
3957
3996
|
};
|
|
3958
3997
|
|
|
3959
3998
|
declare type RefinementListOwnCSSClasses = Partial<{
|
|
@@ -4019,7 +4058,9 @@ declare type RefinementListOwnTemplates = Partial<{
|
|
|
4019
4058
|
/**
|
|
4020
4059
|
* Template used for the show more text, provided with `isShowingMore` data property.
|
|
4021
4060
|
*/
|
|
4022
|
-
showMoreText: Template
|
|
4061
|
+
showMoreText: Template<{
|
|
4062
|
+
isShowingMore: boolean;
|
|
4063
|
+
}>;
|
|
4023
4064
|
/**
|
|
4024
4065
|
* Templates to use for search for facet values when there are no results.
|
|
4025
4066
|
*/
|
|
@@ -4271,6 +4312,16 @@ declare type RenderState = {
|
|
|
4271
4312
|
|
|
4272
4313
|
declare type RenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = TWidgetDescription extends RequiredKeys<WidgetDescription, 'renderState' | 'indexRenderState'> & WidgetParams ? RequiredRenderStateLifeCycle<TWidgetDescription> : Partial<RequiredRenderStateLifeCycle<TWidgetDescription>>;
|
|
4273
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
|
+
|
|
4274
4325
|
declare type RequiredKeys<TObject, TKeys extends keyof TObject> = Expand<Required<Pick<TObject, TKeys>> & Omit<TObject, TKeys>>;
|
|
4275
4326
|
|
|
4276
4327
|
declare type RequiredRenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = {
|
|
@@ -4348,8 +4399,12 @@ declare type RequiredWidgetType<TWidgetDescription extends WidgetDescription> =
|
|
|
4348
4399
|
$$widgetType: TWidgetDescription['$$widgetType'];
|
|
4349
4400
|
};
|
|
4350
4401
|
|
|
4402
|
+
declare function ReverseHighlight<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: ReverseHighlightProps<THit>): h.JSX.Element;
|
|
4403
|
+
|
|
4351
4404
|
declare function reverseHighlight({ attribute, highlightedTagName, hit, cssClasses, }: ReverseHighlightOptions): string;
|
|
4352
4405
|
|
|
4406
|
+
declare type ReverseHighlightClassNames = HighlightClassNames_2;
|
|
4407
|
+
|
|
4353
4408
|
declare type ReverseHighlightOptions = {
|
|
4354
4409
|
attribute: string | string[];
|
|
4355
4410
|
highlightedTagName?: string;
|
|
@@ -4359,8 +4414,22 @@ declare type ReverseHighlightOptions = {
|
|
|
4359
4414
|
}>;
|
|
4360
4415
|
};
|
|
4361
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
|
+
|
|
4362
4429
|
declare function reverseSnippet({ attribute, highlightedTagName, hit, cssClasses, }: ReverseSnippetOptions): string;
|
|
4363
4430
|
|
|
4431
|
+
declare type ReverseSnippetClassNames = HighlightClassNames_2;
|
|
4432
|
+
|
|
4364
4433
|
declare type ReverseSnippetOptions = {
|
|
4365
4434
|
attribute: string | string[];
|
|
4366
4435
|
highlightedTagName?: string;
|
|
@@ -4370,6 +4439,16 @@ declare type ReverseSnippetOptions = {
|
|
|
4370
4439
|
}>;
|
|
4371
4440
|
};
|
|
4372
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
|
+
|
|
4373
4452
|
/**
|
|
4374
4453
|
* The router is the part that saves and reads the object from the storage.
|
|
4375
4454
|
* Usually this is the URL.
|
|
@@ -4422,6 +4501,8 @@ declare type ScopedResult = {
|
|
|
4422
4501
|
|
|
4423
4502
|
declare const searchBox: SearchBoxWidget;
|
|
4424
4503
|
|
|
4504
|
+
declare type SearchBoxComponentCSSClasses = ComponentCSSClasses<SearchBoxCSSClasses>;
|
|
4505
|
+
|
|
4425
4506
|
declare type SearchBoxConnector = Connector<SearchBoxWidgetDescription, SearchBoxConnectorParams>;
|
|
4426
4507
|
|
|
4427
4508
|
declare type SearchBoxConnectorParams = {
|
|
@@ -4507,15 +4588,21 @@ declare type SearchBoxTemplates = Partial<{
|
|
|
4507
4588
|
/**
|
|
4508
4589
|
* Template used for displaying the submit button. Can accept a function or a Hogan string.
|
|
4509
4590
|
*/
|
|
4510
|
-
submit: Template
|
|
4591
|
+
submit: Template<{
|
|
4592
|
+
cssClasses: SearchBoxComponentCSSClasses;
|
|
4593
|
+
}>;
|
|
4511
4594
|
/**
|
|
4512
4595
|
* Template used for displaying the reset button. Can accept a function or a Hogan string.
|
|
4513
4596
|
*/
|
|
4514
|
-
reset: Template
|
|
4597
|
+
reset: Template<{
|
|
4598
|
+
cssClasses: SearchBoxComponentCSSClasses;
|
|
4599
|
+
}>;
|
|
4515
4600
|
/**
|
|
4516
4601
|
* Template used for displaying the loading indicator. Can accept a function or a Hogan string.
|
|
4517
4602
|
*/
|
|
4518
|
-
loadingIndicator: Template
|
|
4603
|
+
loadingIndicator: Template<{
|
|
4604
|
+
cssClasses: SearchBoxComponentCSSClasses;
|
|
4605
|
+
}>;
|
|
4519
4606
|
}>;
|
|
4520
4607
|
|
|
4521
4608
|
/**
|
|
@@ -4614,8 +4701,12 @@ declare function simpleStateMapping<TUiState extends UiState = UiState>(): State
|
|
|
4614
4701
|
|
|
4615
4702
|
declare function singleIndexStateMapping<TUiState extends UiState = UiState>(indexName: keyof TUiState): StateMapping<TUiState, TUiState[typeof indexName]>;
|
|
4616
4703
|
|
|
4704
|
+
declare function Snippet<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: SnippetProps<THit>): h.JSX.Element;
|
|
4705
|
+
|
|
4617
4706
|
declare function snippet({ attribute, highlightedTagName, hit, cssClasses, }: SnippetOptions): string;
|
|
4618
4707
|
|
|
4708
|
+
declare type SnippetClassNames = HighlightClassNames_2;
|
|
4709
|
+
|
|
4619
4710
|
declare type SnippetOptions = {
|
|
4620
4711
|
attribute: string | string[];
|
|
4621
4712
|
highlightedTagName?: string;
|
|
@@ -4625,6 +4716,16 @@ declare type SnippetOptions = {
|
|
|
4625
4716
|
};
|
|
4626
4717
|
};
|
|
4627
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
|
+
|
|
4628
4729
|
/**
|
|
4629
4730
|
* Transforms the given items.
|
|
4630
4731
|
*/
|
|
@@ -4877,13 +4978,9 @@ declare type StatsRenderState = {
|
|
|
4877
4978
|
|
|
4878
4979
|
declare type StatsTemplates = Partial<{
|
|
4879
4980
|
/**
|
|
4880
|
-
* 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`.
|
|
4881
4982
|
*/
|
|
4882
|
-
text: Template<
|
|
4883
|
-
hasManyResults: boolean;
|
|
4884
|
-
hasNoResults: boolean;
|
|
4885
|
-
hasOneResult: boolean;
|
|
4886
|
-
} & StatsRenderState>;
|
|
4983
|
+
text: Template<TextTemplateProps & StatsRenderState>;
|
|
4887
4984
|
}>;
|
|
4888
4985
|
|
|
4889
4986
|
declare type StatsWidget = WidgetFactory<StatsWidgetDescription & {
|
|
@@ -4915,9 +5012,33 @@ declare type StatsWidgetParams = {
|
|
|
4915
5012
|
|
|
4916
5013
|
declare type Status = 'initial' | 'askingPermission' | 'waiting' | 'recognizing' | 'finished' | 'error';
|
|
4917
5014
|
|
|
4918
|
-
declare type Template<TTemplateData = void> = string | ((data: TTemplateData) => string);
|
|
5015
|
+
declare type Template<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string);
|
|
4919
5016
|
|
|
4920
|
-
declare type
|
|
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
|
+
};
|
|
5027
|
+
|
|
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
|
+
};
|
|
4921
5042
|
|
|
4922
5043
|
/**
|
|
4923
5044
|
* The toggleRefinement widget lets the user either:
|
|
@@ -5018,7 +5139,9 @@ declare type ToggleRefinementTemplates = Partial<{
|
|
|
5018
5139
|
/**
|
|
5019
5140
|
* the text that describes the toggle action
|
|
5020
5141
|
*/
|
|
5021
|
-
labelText: Template<ToggleRefinementValue
|
|
5142
|
+
labelText: Template<ToggleRefinementValue & {
|
|
5143
|
+
name: string;
|
|
5144
|
+
}>;
|
|
5022
5145
|
}>;
|
|
5023
5146
|
|
|
5024
5147
|
declare type ToggleRefinementValue = {
|
|
@@ -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;
|
|
@@ -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>> = {
|
|
@@ -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:
|
|
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
|
*/
|
|
@@ -3235,6 +3259,11 @@ declare type ParseURL<TRouteState> = (args: {
|
|
|
3235
3259
|
location: Location;
|
|
3236
3260
|
}) => TRouteState;
|
|
3237
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
|
+
|
|
3238
3267
|
declare type PlacesInstance = Places.PlacesInstance;
|
|
3239
3268
|
|
|
3240
3269
|
declare type PlacesWidget = WidgetFactory<PlacesWidgetDescription, PlacesWidgetParams, PlacesWidgetParams>;
|
|
@@ -3749,9 +3778,15 @@ declare type RatingMenuTemplates = Partial<{
|
|
|
3749
3778
|
*/
|
|
3750
3779
|
item: Template<{
|
|
3751
3780
|
name: string;
|
|
3781
|
+
label: string;
|
|
3782
|
+
value: string;
|
|
3752
3783
|
count: number;
|
|
3753
3784
|
isRefined: boolean;
|
|
3754
3785
|
url: string;
|
|
3786
|
+
stars: [boolean, boolean, boolean, boolean, boolean];
|
|
3787
|
+
cssClasses: RatingMenuCSSClasses;
|
|
3788
|
+
attribute?: string;
|
|
3789
|
+
isFromSearch?: boolean;
|
|
3755
3790
|
}>;
|
|
3756
3791
|
}>;
|
|
3757
3792
|
|
|
@@ -3954,6 +3989,10 @@ declare type RefinementListItemData = {
|
|
|
3954
3989
|
* Object containing all the classes computed for the item.
|
|
3955
3990
|
*/
|
|
3956
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;
|
|
3957
3996
|
};
|
|
3958
3997
|
|
|
3959
3998
|
declare type RefinementListOwnCSSClasses = Partial<{
|
|
@@ -4019,7 +4058,9 @@ declare type RefinementListOwnTemplates = Partial<{
|
|
|
4019
4058
|
/**
|
|
4020
4059
|
* Template used for the show more text, provided with `isShowingMore` data property.
|
|
4021
4060
|
*/
|
|
4022
|
-
showMoreText: Template
|
|
4061
|
+
showMoreText: Template<{
|
|
4062
|
+
isShowingMore: boolean;
|
|
4063
|
+
}>;
|
|
4023
4064
|
/**
|
|
4024
4065
|
* Templates to use for search for facet values when there are no results.
|
|
4025
4066
|
*/
|
|
@@ -4271,6 +4312,16 @@ declare type RenderState = {
|
|
|
4271
4312
|
|
|
4272
4313
|
declare type RenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = TWidgetDescription extends RequiredKeys<WidgetDescription, 'renderState' | 'indexRenderState'> & WidgetParams ? RequiredRenderStateLifeCycle<TWidgetDescription> : Partial<RequiredRenderStateLifeCycle<TWidgetDescription>>;
|
|
4273
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
|
+
|
|
4274
4325
|
declare type RequiredKeys<TObject, TKeys extends keyof TObject> = Expand<Required<Pick<TObject, TKeys>> & Omit<TObject, TKeys>>;
|
|
4275
4326
|
|
|
4276
4327
|
declare type RequiredRenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = {
|
|
@@ -4348,8 +4399,12 @@ declare type RequiredWidgetType<TWidgetDescription extends WidgetDescription> =
|
|
|
4348
4399
|
$$widgetType: TWidgetDescription['$$widgetType'];
|
|
4349
4400
|
};
|
|
4350
4401
|
|
|
4402
|
+
declare function ReverseHighlight<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: ReverseHighlightProps<THit>): h.JSX.Element;
|
|
4403
|
+
|
|
4351
4404
|
declare function reverseHighlight({ attribute, highlightedTagName, hit, cssClasses, }: ReverseHighlightOptions): string;
|
|
4352
4405
|
|
|
4406
|
+
declare type ReverseHighlightClassNames = HighlightClassNames_2;
|
|
4407
|
+
|
|
4353
4408
|
declare type ReverseHighlightOptions = {
|
|
4354
4409
|
attribute: string | string[];
|
|
4355
4410
|
highlightedTagName?: string;
|
|
@@ -4359,8 +4414,22 @@ declare type ReverseHighlightOptions = {
|
|
|
4359
4414
|
}>;
|
|
4360
4415
|
};
|
|
4361
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
|
+
|
|
4362
4429
|
declare function reverseSnippet({ attribute, highlightedTagName, hit, cssClasses, }: ReverseSnippetOptions): string;
|
|
4363
4430
|
|
|
4431
|
+
declare type ReverseSnippetClassNames = HighlightClassNames_2;
|
|
4432
|
+
|
|
4364
4433
|
declare type ReverseSnippetOptions = {
|
|
4365
4434
|
attribute: string | string[];
|
|
4366
4435
|
highlightedTagName?: string;
|
|
@@ -4370,6 +4439,16 @@ declare type ReverseSnippetOptions = {
|
|
|
4370
4439
|
}>;
|
|
4371
4440
|
};
|
|
4372
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
|
+
|
|
4373
4452
|
/**
|
|
4374
4453
|
* The router is the part that saves and reads the object from the storage.
|
|
4375
4454
|
* Usually this is the URL.
|
|
@@ -4422,6 +4501,8 @@ declare type ScopedResult = {
|
|
|
4422
4501
|
|
|
4423
4502
|
declare const searchBox: SearchBoxWidget;
|
|
4424
4503
|
|
|
4504
|
+
declare type SearchBoxComponentCSSClasses = ComponentCSSClasses<SearchBoxCSSClasses>;
|
|
4505
|
+
|
|
4425
4506
|
declare type SearchBoxConnector = Connector<SearchBoxWidgetDescription, SearchBoxConnectorParams>;
|
|
4426
4507
|
|
|
4427
4508
|
declare type SearchBoxConnectorParams = {
|
|
@@ -4507,15 +4588,21 @@ declare type SearchBoxTemplates = Partial<{
|
|
|
4507
4588
|
/**
|
|
4508
4589
|
* Template used for displaying the submit button. Can accept a function or a Hogan string.
|
|
4509
4590
|
*/
|
|
4510
|
-
submit: Template
|
|
4591
|
+
submit: Template<{
|
|
4592
|
+
cssClasses: SearchBoxComponentCSSClasses;
|
|
4593
|
+
}>;
|
|
4511
4594
|
/**
|
|
4512
4595
|
* Template used for displaying the reset button. Can accept a function or a Hogan string.
|
|
4513
4596
|
*/
|
|
4514
|
-
reset: Template
|
|
4597
|
+
reset: Template<{
|
|
4598
|
+
cssClasses: SearchBoxComponentCSSClasses;
|
|
4599
|
+
}>;
|
|
4515
4600
|
/**
|
|
4516
4601
|
* Template used for displaying the loading indicator. Can accept a function or a Hogan string.
|
|
4517
4602
|
*/
|
|
4518
|
-
loadingIndicator: Template
|
|
4603
|
+
loadingIndicator: Template<{
|
|
4604
|
+
cssClasses: SearchBoxComponentCSSClasses;
|
|
4605
|
+
}>;
|
|
4519
4606
|
}>;
|
|
4520
4607
|
|
|
4521
4608
|
/**
|
|
@@ -4614,8 +4701,12 @@ declare function simpleStateMapping<TUiState extends UiState = UiState>(): State
|
|
|
4614
4701
|
|
|
4615
4702
|
declare function singleIndexStateMapping<TUiState extends UiState = UiState>(indexName: keyof TUiState): StateMapping<TUiState, TUiState[typeof indexName]>;
|
|
4616
4703
|
|
|
4704
|
+
declare function Snippet<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: SnippetProps<THit>): h.JSX.Element;
|
|
4705
|
+
|
|
4617
4706
|
declare function snippet({ attribute, highlightedTagName, hit, cssClasses, }: SnippetOptions): string;
|
|
4618
4707
|
|
|
4708
|
+
declare type SnippetClassNames = HighlightClassNames_2;
|
|
4709
|
+
|
|
4619
4710
|
declare type SnippetOptions = {
|
|
4620
4711
|
attribute: string | string[];
|
|
4621
4712
|
highlightedTagName?: string;
|
|
@@ -4625,6 +4716,16 @@ declare type SnippetOptions = {
|
|
|
4625
4716
|
};
|
|
4626
4717
|
};
|
|
4627
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
|
+
|
|
4628
4729
|
/**
|
|
4629
4730
|
* Transforms the given items.
|
|
4630
4731
|
*/
|
|
@@ -4877,13 +4978,9 @@ declare type StatsRenderState = {
|
|
|
4877
4978
|
|
|
4878
4979
|
declare type StatsTemplates = Partial<{
|
|
4879
4980
|
/**
|
|
4880
|
-
* 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`.
|
|
4881
4982
|
*/
|
|
4882
|
-
text: Template<
|
|
4883
|
-
hasManyResults: boolean;
|
|
4884
|
-
hasNoResults: boolean;
|
|
4885
|
-
hasOneResult: boolean;
|
|
4886
|
-
} & StatsRenderState>;
|
|
4983
|
+
text: Template<TextTemplateProps & StatsRenderState>;
|
|
4887
4984
|
}>;
|
|
4888
4985
|
|
|
4889
4986
|
declare type StatsWidget = WidgetFactory<StatsWidgetDescription & {
|
|
@@ -4915,9 +5012,33 @@ declare type StatsWidgetParams = {
|
|
|
4915
5012
|
|
|
4916
5013
|
declare type Status = 'initial' | 'askingPermission' | 'waiting' | 'recognizing' | 'finished' | 'error';
|
|
4917
5014
|
|
|
4918
|
-
declare type Template<TTemplateData = void> = string | ((data: TTemplateData) => string);
|
|
5015
|
+
declare type Template<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string);
|
|
4919
5016
|
|
|
4920
|
-
declare type
|
|
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
|
+
};
|
|
5027
|
+
|
|
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
|
+
};
|
|
4921
5042
|
|
|
4922
5043
|
/**
|
|
4923
5044
|
* The toggleRefinement widget lets the user either:
|
|
@@ -5018,7 +5139,9 @@ declare type ToggleRefinementTemplates = Partial<{
|
|
|
5018
5139
|
/**
|
|
5019
5140
|
* the text that describes the toggle action
|
|
5020
5141
|
*/
|
|
5021
|
-
labelText: Template<ToggleRefinementValue
|
|
5142
|
+
labelText: Template<ToggleRefinementValue & {
|
|
5143
|
+
name: string;
|
|
5144
|
+
}>;
|
|
5022
5145
|
}>;
|
|
5023
5146
|
|
|
5024
5147
|
declare type ToggleRefinementValue = {
|