instantsearch.js 4.49.4 → 4.50.1
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/cjs/components/Pagination/Pagination.js +1 -1
- package/cjs/connectors/hits/connectHits.js +2 -1
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +3 -2
- package/cjs/lib/InstantSearch.js +3 -7
- package/cjs/lib/templating/prepareTemplateProps.js +1 -2
- package/cjs/lib/templating/renderTemplate.js +3 -0
- package/cjs/lib/utils/createSendEventForHits.js +6 -5
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/hits/hits.js +3 -4
- package/cjs/widgets/index/index.js +18 -1
- package/cjs/widgets/infinite-hits/infinite-hits.js +3 -4
- package/dist/instantsearch.development.d.ts +11 -3
- package/dist/instantsearch.development.js +89 -37
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +11 -3
- package/dist/instantsearch.production.min.d.ts +11 -3
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Answers/Answers.d.ts +3 -3
- package/es/components/Breadcrumb/Breadcrumb.d.ts +3 -3
- package/es/components/ClearRefinements/ClearRefinements.d.ts +3 -3
- package/es/components/CurrentRefinements/CurrentRefinements.d.ts +2 -2
- package/es/components/GeoSearchControls/GeoSearchButton.d.ts +1 -1
- package/es/components/GeoSearchControls/GeoSearchControls.d.ts +1 -1
- package/es/components/GeoSearchControls/GeoSearchToggle.d.ts +1 -1
- package/es/components/Highlight/Highlight.d.ts +2 -2
- package/es/components/Hits/Hits.d.ts +3 -3
- package/es/components/InfiniteHits/InfiniteHits.d.ts +3 -3
- package/es/components/MenuSelect/MenuSelect.d.ts +4 -4
- package/es/components/Pagination/Pagination.d.ts +3 -3
- package/es/components/Pagination/Pagination.js +1 -1
- package/es/components/Panel/Panel.d.ts +3 -3
- package/es/components/PoweredBy/PoweredBy.d.ts +2 -2
- package/es/components/QueryRuleCustomData/QueryRuleCustomData.d.ts +3 -3
- package/es/components/RangeInput/RangeInput.d.ts +3 -3
- package/es/components/RefinementList/RefinementList.d.ts +7 -7
- package/es/components/RefinementList/RefinementListItem.d.ts +1 -1
- package/es/components/RelevantSort/RelevantSort.d.ts +3 -3
- package/es/components/ReverseHighlight/ReverseHighlight.d.ts +2 -2
- package/es/components/ReverseSnippet/ReverseSnippet.d.ts +2 -2
- package/es/components/SearchBox/SearchBox.d.ts +5 -5
- package/es/components/Selector/Selector.d.ts +3 -3
- package/es/components/Slider/Rheostat.d.ts +6 -6
- package/es/components/Slider/Slider.d.ts +2 -2
- package/es/components/Snippet/Snippet.d.ts +2 -2
- package/es/components/Stats/Stats.d.ts +3 -3
- package/es/components/Template/Template.d.ts +1 -1
- package/es/components/ToggleRefinement/ToggleRefinement.d.ts +3 -3
- package/es/components/VoiceSearch/VoiceSearch.d.ts +3 -3
- package/es/connectors/answers/connectAnswers.d.ts +4 -4
- package/es/connectors/autocomplete/connectAutocomplete.d.ts +4 -4
- package/es/connectors/breadcrumb/connectBreadcrumb.d.ts +5 -5
- package/es/connectors/clear-refinements/connectClearRefinements.d.ts +4 -4
- package/es/connectors/configure/connectConfigure.d.ts +5 -5
- package/es/connectors/configure-related-items/connectConfigureRelatedItems.d.ts +5 -5
- package/es/connectors/current-refinements/connectCurrentRefinements.d.ts +6 -6
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +4 -4
- package/es/connectors/geo-search/connectGeoSearch.d.ts +6 -6
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.d.ts +5 -5
- package/es/connectors/hits/connectHits.d.ts +4 -4
- package/es/connectors/hits/connectHits.js +2 -1
- package/es/connectors/hits-per-page/connectHitsPerPage.d.ts +6 -6
- package/es/connectors/infinite-hits/connectInfiniteHits.d.ts +8 -8
- package/es/connectors/infinite-hits/connectInfiniteHits.js +3 -2
- package/es/connectors/menu/connectMenu.d.ts +5 -5
- package/es/connectors/numeric-menu/connectNumericMenu.d.ts +6 -6
- package/es/connectors/pagination/connectPagination.d.ts +4 -4
- package/es/connectors/powered-by/connectPoweredBy.d.ts +4 -4
- package/es/connectors/query-rules/connectQueryRules.d.ts +7 -7
- package/es/connectors/range/connectRange.d.ts +8 -8
- package/es/connectors/rating-menu/connectRatingMenu.d.ts +6 -6
- package/es/connectors/refinement-list/connectRefinementList.d.ts +5 -5
- package/es/connectors/relevant-sort/connectRelevantSort.d.ts +5 -5
- package/es/connectors/search-box/connectSearchBox.d.ts +4 -4
- package/es/connectors/sort-by/connectSortBy.d.ts +5 -5
- package/es/connectors/stats/connectStats.d.ts +4 -4
- package/es/connectors/toggle-refinement/connectToggleRefinement.d.ts +9 -9
- package/es/connectors/toggle-refinement/types.d.ts +5 -5
- package/es/connectors/voice-search/connectVoiceSearch.d.ts +4 -4
- package/es/helpers/components/Highlight.d.ts +1 -1
- package/es/helpers/components/ReverseHighlight.d.ts +1 -1
- package/es/helpers/components/ReverseSnippet.d.ts +1 -1
- package/es/helpers/components/Snippet.d.ts +1 -1
- package/es/helpers/highlight.d.ts +1 -1
- package/es/helpers/reverseHighlight.d.ts +1 -1
- package/es/helpers/reverseSnippet.d.ts +1 -1
- package/es/helpers/snippet.d.ts +1 -1
- package/es/index.d.ts +1 -1
- package/es/lib/InstantSearch.d.ts +3 -3
- package/es/lib/InstantSearch.js +3 -7
- package/es/lib/createHelpers.d.ts +1 -1
- package/es/lib/insights/listener.d.ts +1 -1
- package/es/lib/routers/history.d.ts +3 -3
- package/es/lib/suit.d.ts +2 -2
- package/es/lib/templating/prepareTemplateProps.d.ts +2 -2
- package/es/lib/templating/prepareTemplateProps.js +1 -2
- package/es/lib/templating/renderTemplate.js +3 -0
- package/es/lib/utils/checkIndexUiState.d.ts +1 -1
- package/es/lib/utils/createConcurrentSafePromise.d.ts +2 -2
- package/es/lib/utils/createSendEventForFacet.d.ts +4 -4
- package/es/lib/utils/createSendEventForHits.d.ts +8 -7
- package/es/lib/utils/createSendEventForHits.js +6 -5
- package/es/lib/utils/debounce.d.ts +2 -2
- package/es/lib/utils/defer.d.ts +2 -2
- package/es/lib/utils/documentation.d.ts +2 -2
- package/es/lib/utils/escapeFacetValue.d.ts +1 -1
- package/es/lib/utils/geo-search.d.ts +1 -1
- package/es/lib/utils/getRefinements.d.ts +6 -6
- package/es/lib/utils/logger.d.ts +2 -2
- package/es/lib/utils/range.d.ts +1 -1
- package/es/lib/utils/safelyRunOnBrowser.d.ts +2 -2
- package/es/lib/utils/toArray.d.ts +1 -1
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/lib/voiceSearchHelper/types.d.ts +5 -5
- package/es/middlewares/createInsightsMiddleware.d.ts +3 -3
- package/es/middlewares/createRouterMiddleware.d.ts +1 -1
- package/es/types/component.d.ts +1 -1
- package/es/types/connector.d.ts +4 -4
- package/es/types/insights.d.ts +5 -5
- package/es/types/middleware.d.ts +4 -4
- package/es/types/render-state.d.ts +5 -5
- package/es/types/results.d.ts +16 -16
- package/es/types/router.d.ts +2 -2
- package/es/types/templates.d.ts +14 -6
- package/es/types/ui-state.d.ts +4 -4
- package/es/types/utils.d.ts +6 -6
- package/es/types/widget-factory.d.ts +2 -2
- package/es/types/widget.d.ts +23 -23
- package/es/widgets/analytics/analytics.d.ts +4 -4
- package/es/widgets/answers/answers.d.ts +4 -4
- package/es/widgets/breadcrumb/breadcrumb.d.ts +4 -4
- package/es/widgets/clear-refinements/clear-refinements.d.ts +4 -4
- package/es/widgets/configure/configure.d.ts +2 -2
- package/es/widgets/configure-related-items/configure-related-items.d.ts +2 -2
- package/es/widgets/current-refinements/current-refinements.d.ts +3 -3
- package/es/widgets/dynamic-widgets/dynamic-widgets.d.ts +2 -2
- package/es/widgets/geo-search/createHTMLMarker.d.ts +1 -1
- package/es/widgets/geo-search/geo-search.d.ts +7 -7
- package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +6 -6
- package/es/widgets/hits/hits.d.ts +4 -4
- package/es/widgets/hits/hits.js +3 -4
- package/es/widgets/hits-per-page/hits-per-page.d.ts +3 -3
- package/es/widgets/index/index.d.ts +5 -5
- package/es/widgets/index/index.js +18 -1
- package/es/widgets/infinite-hits/infinite-hits.d.ts +4 -4
- package/es/widgets/infinite-hits/infinite-hits.js +3 -4
- package/es/widgets/menu/menu.d.ts +6 -6
- package/es/widgets/menu-select/menu-select.d.ts +4 -4
- package/es/widgets/numeric-menu/numeric-menu.d.ts +6 -6
- package/es/widgets/pagination/pagination.d.ts +4 -4
- package/es/widgets/panel/panel.d.ts +9 -9
- package/es/widgets/places/places.d.ts +6 -6
- package/es/widgets/powered-by/powered-by.d.ts +3 -3
- package/es/widgets/query-rule-context/query-rule-context.d.ts +2 -2
- package/es/widgets/query-rule-custom-data/query-rule-custom-data.d.ts +4 -4
- package/es/widgets/range-input/range-input.d.ts +4 -4
- package/es/widgets/range-slider/range-slider.d.ts +4 -4
- package/es/widgets/rating-menu/rating-menu.d.ts +6 -6
- package/es/widgets/refinement-list/refinement-list.d.ts +10 -10
- package/es/widgets/relevant-sort/relevant-sort.d.ts +4 -4
- package/es/widgets/search-box/search-box.d.ts +4 -4
- package/es/widgets/sort-by/sort-by.d.ts +4 -4
- package/es/widgets/stats/stats.d.ts +5 -5
- package/es/widgets/toggle-refinement/toggle-refinement.d.ts +4 -4
- package/es/widgets/voice-search/voice-search.d.ts +5 -5
- package/package.json +7 -5
|
@@ -13,7 +13,7 @@ var buildPayloads = function buildPayloads(_ref) {
|
|
|
13
13
|
widgetType = _ref.widgetType,
|
|
14
14
|
methodName = _ref.methodName,
|
|
15
15
|
args = _ref.args,
|
|
16
|
-
|
|
16
|
+
instantSearchInstance = _ref.instantSearchInstance;
|
|
17
17
|
// when there's only one argument, that means it's custom
|
|
18
18
|
if (args.length === 1 && _typeof(args[0]) === 'object') {
|
|
19
19
|
return [args[0]];
|
|
@@ -52,7 +52,7 @@ var buildPayloads = function buildPayloads(_ref) {
|
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
if (eventType === 'view') {
|
|
55
|
-
if (
|
|
55
|
+
if (instantSearchInstance.status !== 'idle') {
|
|
56
56
|
return [];
|
|
57
57
|
}
|
|
58
58
|
return hitsChunks.map(function (batch, i) {
|
|
@@ -122,7 +122,7 @@ export function createSendEventForHits(_ref2) {
|
|
|
122
122
|
index: index,
|
|
123
123
|
methodName: 'sendEvent',
|
|
124
124
|
args: args,
|
|
125
|
-
|
|
125
|
+
instantSearchInstance: instantSearchInstance
|
|
126
126
|
});
|
|
127
127
|
payloads.forEach(function (payload) {
|
|
128
128
|
return instantSearchInstance.sendEventToInsights(payload);
|
|
@@ -132,7 +132,8 @@ export function createSendEventForHits(_ref2) {
|
|
|
132
132
|
}
|
|
133
133
|
export function createBindEventForHits(_ref3) {
|
|
134
134
|
var index = _ref3.index,
|
|
135
|
-
widgetType = _ref3.widgetType
|
|
135
|
+
widgetType = _ref3.widgetType,
|
|
136
|
+
instantSearchInstance = _ref3.instantSearchInstance;
|
|
136
137
|
var bindEventForHits = function bindEventForHits() {
|
|
137
138
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
138
139
|
args[_key2] = arguments[_key2];
|
|
@@ -142,7 +143,7 @@ export function createBindEventForHits(_ref3) {
|
|
|
142
143
|
index: index,
|
|
143
144
|
methodName: 'bindEvent',
|
|
144
145
|
args: args,
|
|
145
|
-
|
|
146
|
+
instantSearchInstance: instantSearchInstance
|
|
146
147
|
});
|
|
147
148
|
return payloads.length ? "data-insights-event=".concat(serializePayload(payloads)) : '';
|
|
148
149
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Awaited } from '../../types';
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
type Func = (...args: any[]) => any;
|
|
3
|
+
export type DebouncedFunction<TFunction extends Func> = (this: ThisParameterType<TFunction>, ...args: Parameters<TFunction>) => Promise<Awaited<ReturnType<TFunction>>>;
|
|
4
4
|
export declare function debounce<TFunction extends Func>(func: TFunction, wait: number): DebouncedFunction<TFunction>;
|
|
5
5
|
export {};
|
package/es/lib/utils/defer.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
type WidgetParam = {
|
|
2
2
|
name: string;
|
|
3
3
|
connector?: boolean;
|
|
4
4
|
};
|
|
5
5
|
export declare function createDocumentationLink({ name, connector, }: WidgetParam): string;
|
|
6
|
-
|
|
6
|
+
type DocumentationMessageGenerator = (message?: string) => string;
|
|
7
7
|
export declare function createDocumentationMessageGenerator(...widgets: WidgetParam[]): DocumentationMessageGenerator;
|
|
8
8
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type FacetValue = string | number | boolean | undefined;
|
|
2
2
|
export declare function unescapeFacetValue<TFacetValue extends FacetValue>(value: TFacetValue): TFacetValue;
|
|
3
3
|
export declare function escapeFacetValue<TFacetValue extends FacetValue>(value: TFacetValue): TFacetValue;
|
|
4
4
|
export {};
|
|
@@ -2,7 +2,7 @@ export declare function aroundLatLngToPosition(value: string): {
|
|
|
2
2
|
lat: number;
|
|
3
3
|
lng: number;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export type LatLng = Array<[number, number, number, number]>;
|
|
6
6
|
export declare function insideBoundingBoxToBoundingBox(value: string | LatLng): {
|
|
7
7
|
northEast: {
|
|
8
8
|
lat: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SearchParameters, SearchResults } from 'algoliasearch-helper';
|
|
2
|
-
export
|
|
2
|
+
export type FacetRefinement = {
|
|
3
3
|
type: 'facet' | 'disjunctive' | 'hierarchical';
|
|
4
4
|
attribute: string;
|
|
5
5
|
name: string;
|
|
@@ -7,18 +7,18 @@ export declare type FacetRefinement = {
|
|
|
7
7
|
count?: number;
|
|
8
8
|
exhaustive?: boolean;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type TagRefinement = {
|
|
11
11
|
type: 'tag';
|
|
12
12
|
attribute: string;
|
|
13
13
|
name: string;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type QueryRefinement = {
|
|
16
16
|
type: 'query';
|
|
17
17
|
attribute: 'query';
|
|
18
18
|
query: string;
|
|
19
19
|
name: string;
|
|
20
20
|
};
|
|
21
|
-
export
|
|
21
|
+
export type NumericRefinement = {
|
|
22
22
|
type: 'numeric';
|
|
23
23
|
numericValue: number;
|
|
24
24
|
operator: '<' | '<=' | '=' | '!=' | '>=' | '>';
|
|
@@ -27,7 +27,7 @@ export declare type NumericRefinement = {
|
|
|
27
27
|
count?: number;
|
|
28
28
|
exhaustive?: boolean;
|
|
29
29
|
};
|
|
30
|
-
export
|
|
30
|
+
export type FacetExcludeRefinement = {
|
|
31
31
|
type: 'exclude';
|
|
32
32
|
exclude: boolean;
|
|
33
33
|
attribute: string;
|
|
@@ -35,5 +35,5 @@ export declare type FacetExcludeRefinement = {
|
|
|
35
35
|
count?: number;
|
|
36
36
|
exhaustive?: boolean;
|
|
37
37
|
};
|
|
38
|
-
export
|
|
38
|
+
export type Refinement = FacetRefinement | QueryRefinement | NumericRefinement | FacetExcludeRefinement | TagRefinement;
|
|
39
39
|
export declare function getRefinements(results: SearchResults | Record<string, never>, state: SearchParameters, includesQuery?: boolean): Refinement[];
|
package/es/lib/utils/logger.d.ts
CHANGED
package/es/lib/utils/range.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
type BrowserCallback<TReturn> = (params: {
|
|
2
2
|
window: typeof window;
|
|
3
3
|
}) => TReturn;
|
|
4
|
-
|
|
4
|
+
type SafelyRunOnBrowserOptions<TReturn> = {
|
|
5
5
|
/**
|
|
6
6
|
* Fallback to run on server environments.
|
|
7
7
|
*/
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.
|
|
1
|
+
declare const _default: "4.50.1";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.
|
|
1
|
+
export default '4.50.1';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type Status = 'initial' | 'askingPermission' | 'waiting' | 'recognizing' | 'finished' | 'error';
|
|
2
|
+
export type VoiceListeningState = {
|
|
3
3
|
status: Status;
|
|
4
4
|
transcript: string;
|
|
5
5
|
isSpeechFinal: boolean;
|
|
6
6
|
errorCode?: string;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type VoiceSearchHelperParams = {
|
|
9
9
|
searchAsYouSpeak: boolean;
|
|
10
10
|
language?: string;
|
|
11
11
|
onQueryChange: (query: string) => void;
|
|
12
12
|
onStateChange: () => void;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type VoiceSearchHelper = {
|
|
15
15
|
getState: () => VoiceListeningState;
|
|
16
16
|
isBrowserSupported: () => boolean;
|
|
17
17
|
isListening: () => boolean;
|
|
@@ -19,4 +19,4 @@ export declare type VoiceSearchHelper = {
|
|
|
19
19
|
stopListening: () => void;
|
|
20
20
|
dispose: () => void;
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export type CreateVoiceSearchHelper = (params: VoiceSearchHelperParams) => VoiceSearchHelper;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InsightsClient, InsightsClientMethod, InternalMiddleware, Hit } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type InsightsEvent = {
|
|
3
3
|
insightsMethod?: InsightsClientMethod;
|
|
4
4
|
payload: any;
|
|
5
5
|
widgetType: string;
|
|
@@ -7,7 +7,7 @@ export declare type InsightsEvent = {
|
|
|
7
7
|
hits?: Hit[];
|
|
8
8
|
attribute?: string;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type InsightsProps<TInsightsClient extends null | InsightsClient = InsightsClient | null> = {
|
|
11
11
|
insightsClient: TInsightsClient;
|
|
12
12
|
insightsInitParams?: {
|
|
13
13
|
userHasOptedOut?: boolean;
|
|
@@ -17,5 +17,5 @@ export declare type InsightsProps<TInsightsClient extends null | InsightsClient
|
|
|
17
17
|
};
|
|
18
18
|
onEvent?: (event: InsightsEvent, insightsClient: TInsightsClient) => void;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type CreateInsightsMiddleware = typeof createInsightsMiddleware;
|
|
21
21
|
export declare function createInsightsMiddleware<TInsightsClient extends null | InsightsClient>(props: InsightsProps<TInsightsClient>): InternalMiddleware;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Router, StateMapping, UiState, InternalMiddleware } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type RouterProps<TUiState extends UiState = UiState, TRouteState = TUiState> = {
|
|
3
3
|
router?: Router<TRouteState>;
|
|
4
4
|
stateMapping?: StateMapping<TUiState, TRouteState>;
|
|
5
5
|
};
|
package/es/types/component.d.ts
CHANGED
package/es/types/connector.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { UnknownWidgetParams, Widget, WidgetDescription } from './widget';
|
|
|
7
7
|
* The base renderer options. All render functions receive
|
|
8
8
|
* the options below plus the specific options per connector.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type RendererOptions<TWidgetParams> = {
|
|
11
11
|
/**
|
|
12
12
|
* The original widget params. Useful as you may
|
|
13
13
|
* need them while using the render function.
|
|
@@ -34,7 +34,7 @@ export declare type RendererOptions<TWidgetParams> = {
|
|
|
34
34
|
/**
|
|
35
35
|
* The render function.
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export type Renderer<TRenderState, TWidgetParams> = (
|
|
38
38
|
/**
|
|
39
39
|
* The base render options plus the specific options of the widget.
|
|
40
40
|
*/
|
|
@@ -46,12 +46,12 @@ isFirstRender: boolean) => void;
|
|
|
46
46
|
/**
|
|
47
47
|
* The called function when unmounting a widget.
|
|
48
48
|
*/
|
|
49
|
-
export
|
|
49
|
+
export type Unmounter = () => void;
|
|
50
50
|
/**
|
|
51
51
|
* The connector handles the business logic and exposes
|
|
52
52
|
* a simplified API to the rendering function.
|
|
53
53
|
*/
|
|
54
|
-
export
|
|
54
|
+
export type Connector<TWidgetDescription extends WidgetDescription, TConnectorParams extends UnknownWidgetParams> = <TWidgetParams extends UnknownWidgetParams>(
|
|
55
55
|
/**
|
|
56
56
|
* The render function.
|
|
57
57
|
*/
|
package/es/types/insights.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { InsightsMethodMap, InsightsClient as _InsightsClient } from 'search-insights';
|
|
2
2
|
export type { Init as InsightsInit, AddAlgoliaAgent as InsightsAddAlgoliaAgent, SetUserToken as InsightsSetUserToken, GetUserToken as InsightsGetUserToken, OnUserTokenChange as InsightsOnUserTokenChange, } from 'search-insights';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type InsightsClientMethod = keyof InsightsMethodMap;
|
|
4
|
+
export type InsightsClientPayload = {
|
|
5
5
|
eventName: string;
|
|
6
6
|
queryID: string;
|
|
7
7
|
index: string;
|
|
8
8
|
objectIDs: string[];
|
|
9
9
|
positions?: number[];
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type QueueItemMap = {
|
|
12
12
|
[MethodName in keyof InsightsMethodMap]: [
|
|
13
13
|
methodName: MethodName,
|
|
14
14
|
...args: InsightsMethodMap[MethodName]
|
|
15
15
|
];
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
export
|
|
17
|
+
type QueueItem = QueueItemMap[keyof QueueItemMap];
|
|
18
|
+
export type InsightsClient = _InsightsClient & {
|
|
19
19
|
queue?: QueueItem[];
|
|
20
20
|
};
|
package/es/types/middleware.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type InstantSearch from '../lib/InstantSearch';
|
|
2
2
|
import type { UiState } from './ui-state';
|
|
3
3
|
import type { AtLeastOne } from './utils';
|
|
4
|
-
export
|
|
4
|
+
export type MiddlewareDefinition<TUiState extends UiState = UiState> = {
|
|
5
5
|
onStateChange(options: {
|
|
6
6
|
uiState: TUiState;
|
|
7
7
|
}): void;
|
|
@@ -9,8 +9,8 @@ export declare type MiddlewareDefinition<TUiState extends UiState = UiState> = {
|
|
|
9
9
|
started(): void;
|
|
10
10
|
unsubscribe(): void;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type MiddlewareOptions = {
|
|
13
13
|
instantSearchInstance: InstantSearch;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
15
|
+
export type InternalMiddleware<TUiState extends UiState = UiState> = (options: MiddlewareOptions) => MiddlewareDefinition<TUiState>;
|
|
16
|
+
export type Middleware = (options: MiddlewareOptions) => AtLeastOne<MiddlewareDefinition>;
|
|
@@ -25,13 +25,13 @@ import type { ToggleRefinementWidgetDescription } from '../connectors/toggle-ref
|
|
|
25
25
|
import type { VoiceSearchWidgetDescription } from '../connectors/voice-search/connectVoiceSearch';
|
|
26
26
|
import type { AnalyticsWidgetDescription } from '../widgets/analytics/analytics';
|
|
27
27
|
import type { PlacesWidgetDescription } from '../widgets/places/places';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export
|
|
31
|
-
export
|
|
28
|
+
type ConnectorRenderStates = AnswersWidgetDescription['indexRenderState'] & AutocompleteWidgetDescription['indexRenderState'] & BreadcrumbWidgetDescription['indexRenderState'] & ClearRefinementsWidgetDescription['indexRenderState'] & ConfigureWidgetDescription['indexRenderState'] & CurrentRefinementsWidgetDescription['indexRenderState'] & GeoSearchWidgetDescription['indexRenderState'] & HierarchicalMenuWidgetDescription['indexRenderState'] & HitsWidgetDescription['indexRenderState'] & HitsPerPageWidgetDescription['indexRenderState'] & InfiniteHitsWidgetDescription['indexRenderState'] & MenuWidgetDescription['indexRenderState'] & NumericMenuWidgetDescription['indexRenderState'] & PaginationWidgetDescription['indexRenderState'] & PoweredByWidgetDescription['indexRenderState'] & QueryRulesWidgetDescription['indexRenderState'] & RangeWidgetDescription['indexRenderState'] & RatingMenuWidgetDescription['indexRenderState'] & RefinementListWidgetDescription['indexRenderState'] & RelevantSortWidgetDescription['indexRenderState'] & SearchBoxWidgetDescription['indexRenderState'] & SortByWidgetDescription['indexRenderState'] & StatsWidgetDescription['indexRenderState'] & ToggleRefinementWidgetDescription['indexRenderState'] & VoiceSearchWidgetDescription['indexRenderState'];
|
|
29
|
+
type WidgetRenderStates = AnalyticsWidgetDescription['indexRenderState'] & PlacesWidgetDescription['indexRenderState'];
|
|
30
|
+
export type IndexRenderState = Partial<ConnectorRenderStates & WidgetRenderStates>;
|
|
31
|
+
export type RenderState = {
|
|
32
32
|
[indexId: string]: IndexRenderState;
|
|
33
33
|
};
|
|
34
|
-
export
|
|
34
|
+
export type WidgetRenderState<TWidgetRenderState, TWidgetParams> = TWidgetRenderState & {
|
|
35
35
|
widgetParams: TWidgetParams;
|
|
36
36
|
};
|
|
37
37
|
export {};
|
package/es/types/results.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { PlainSearchParameters, SearchForFacetValues, SearchResults } from 'algoliasearch-helper';
|
|
2
|
-
export
|
|
2
|
+
export type HitAttributeHighlightResult = {
|
|
3
3
|
value: string;
|
|
4
4
|
matchLevel: 'none' | 'partial' | 'full';
|
|
5
5
|
matchedWords: string[];
|
|
6
6
|
fullyHighlighted?: boolean;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type HitHighlightResult = {
|
|
9
9
|
[attribute: string]: HitAttributeHighlightResult | HitAttributeHighlightResult[] | HitHighlightResult[] | HitHighlightResult;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
12
|
-
export
|
|
11
|
+
export type HitAttributeSnippetResult = Pick<HitAttributeHighlightResult, 'value' | 'matchLevel'>;
|
|
12
|
+
export type HitSnippetResult = {
|
|
13
13
|
[attribute: string]: HitAttributeSnippetResult[] | HitSnippetResult[] | HitAttributeSnippetResult | HitSnippetResult;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type GeoLoc = {
|
|
16
16
|
lat: number;
|
|
17
17
|
lng: number;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
|
|
20
20
|
objectID: string;
|
|
21
21
|
_highlightResult?: HitHighlightResult;
|
|
22
22
|
_snippetResult?: HitSnippetResult;
|
|
@@ -40,32 +40,32 @@ export declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
|
|
|
40
40
|
_distinctSeqID?: number;
|
|
41
41
|
_geoloc?: GeoLoc;
|
|
42
42
|
} & THit;
|
|
43
|
-
export
|
|
44
|
-
export
|
|
43
|
+
export type BaseHit = Record<string, unknown>;
|
|
44
|
+
export type Hit<THit extends BaseHit = Record<string, any>> = {
|
|
45
45
|
__position: number;
|
|
46
46
|
__queryID?: string;
|
|
47
47
|
} & AlgoliaHit<THit>;
|
|
48
48
|
/**
|
|
49
49
|
* @deprecated use Hit[] directly instead
|
|
50
50
|
*/
|
|
51
|
-
export
|
|
52
|
-
export
|
|
51
|
+
export type Hits = Hit[];
|
|
52
|
+
export type EscapedHits<THit = Hit> = THit[] & {
|
|
53
53
|
__escaped: boolean;
|
|
54
54
|
};
|
|
55
|
-
export
|
|
56
|
-
export
|
|
55
|
+
export type FacetHit = SearchForFacetValues.Hit;
|
|
56
|
+
export type FacetRefinement = {
|
|
57
57
|
value: string;
|
|
58
58
|
type: 'conjunctive' | 'disjunctive' | 'exclude';
|
|
59
59
|
};
|
|
60
|
-
export
|
|
60
|
+
export type NumericRefinement = {
|
|
61
61
|
value: number[];
|
|
62
62
|
type: 'numeric';
|
|
63
63
|
operator: string;
|
|
64
64
|
};
|
|
65
|
-
export
|
|
66
|
-
|
|
65
|
+
export type Refinement = FacetRefinement | NumericRefinement;
|
|
66
|
+
type InitialResult = {
|
|
67
67
|
state: PlainSearchParameters;
|
|
68
68
|
results: SearchResults['_rawResults'];
|
|
69
69
|
};
|
|
70
|
-
export
|
|
70
|
+
export type InitialResults = Record<string, InitialResult>;
|
|
71
71
|
export {};
|
package/es/types/router.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { UiState } from './ui-state';
|
|
|
3
3
|
* The router is the part that saves and reads the object from the storage.
|
|
4
4
|
* Usually this is the URL.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type Router<TRouteState = UiState> = {
|
|
7
7
|
/**
|
|
8
8
|
* onUpdate Sets an event listener that is triggered when the storage is updated.
|
|
9
9
|
* The function should accept a callback to trigger when the update happens.
|
|
@@ -37,7 +37,7 @@ export declare type Router<TRouteState = UiState> = {
|
|
|
37
37
|
* should be valid for any UiState:
|
|
38
38
|
* `UiState = routeToState(stateToRoute(UiState))`.
|
|
39
39
|
*/
|
|
40
|
-
export
|
|
40
|
+
export type StateMapping<TUiState = UiState, TRouteState = TUiState> = {
|
|
41
41
|
/**
|
|
42
42
|
* Transforms a UI state representation into a route object.
|
|
43
43
|
* It receives an object that contains the UI state of all the widgets in the page.
|
package/es/types/templates.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { VNode } from 'preact';
|
|
2
2
|
import type { Highlight, ReverseHighlight, ReverseSnippet, Snippet } from '../helpers/components';
|
|
3
3
|
import type { html } from 'htm/preact';
|
|
4
|
-
import type {
|
|
5
|
-
export
|
|
6
|
-
export
|
|
4
|
+
import type { BuiltInBindEventForHits, CustomBindEventForHits, SendEventForHits } from '../lib/utils';
|
|
5
|
+
export type Template<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string);
|
|
6
|
+
export type TemplateParams = {
|
|
7
7
|
html: typeof html;
|
|
8
8
|
components: {
|
|
9
9
|
Highlight: typeof Highlight;
|
|
@@ -13,8 +13,16 @@ export declare type TemplateParams = BindEventForHits & {
|
|
|
13
13
|
};
|
|
14
14
|
sendEvent?: SendEventForHits;
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
interface TemplateWithBindEventParams extends TemplateParams {
|
|
17
|
+
/** @deprecated use sendEvent instead */
|
|
18
|
+
(...args: Parameters<BuiltInBindEventForHits>): ReturnType<BuiltInBindEventForHits>;
|
|
19
|
+
/** @deprecated use sendEvent instead */
|
|
20
|
+
(...args: Parameters<CustomBindEventForHits>): ReturnType<CustomBindEventForHits>;
|
|
21
|
+
sendEvent: SendEventForHits;
|
|
22
|
+
}
|
|
23
|
+
export type TemplateWithBindEvent<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateWithBindEventParams) => VNode | VNode[] | string);
|
|
24
|
+
export type Templates = {
|
|
18
25
|
[key: string]: Template<any> | TemplateWithBindEvent<any> | undefined;
|
|
19
26
|
};
|
|
20
|
-
export
|
|
27
|
+
export type HoganHelpers<TKeys extends string = string> = Record<TKeys, (text: string, render: (value: string) => string) => string>;
|
|
28
|
+
export {};
|
package/es/types/ui-state.d.ts
CHANGED
|
@@ -16,10 +16,10 @@ import type { SortByWidgetDescription } from '../connectors/sort-by/connectSortB
|
|
|
16
16
|
import type { ToggleRefinementWidgetDescription } from '../connectors/toggle-refinement/connectToggleRefinement';
|
|
17
17
|
import type { VoiceSearchWidgetDescription } from '../connectors/voice-search/connectVoiceSearch';
|
|
18
18
|
import type { PlacesWidgetDescription } from '../widgets/places/places';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
export
|
|
19
|
+
type ConnectorUiStates = AutocompleteWidgetDescription['indexUiState'] & ConfigureWidgetDescription['indexUiState'] & GeoSearchWidgetDescription['indexUiState'] & HierarchicalMenuWidgetDescription['indexUiState'] & HitsPerPageWidgetDescription['indexUiState'] & InfiniteHitsWidgetDescription['indexUiState'] & MenuWidgetDescription['indexUiState'] & NumericMenuWidgetDescription['indexUiState'] & PaginationWidgetDescription['indexUiState'] & RangeWidgetDescription['indexUiState'] & RatingMenuWidgetDescription['indexUiState'] & RefinementListWidgetDescription['indexUiState'] & RelevantSortWidgetDescription['indexUiState'] & SearchBoxWidgetDescription['indexUiState'] & SortByWidgetDescription['indexUiState'] & ToggleRefinementWidgetDescription['indexUiState'] & VoiceSearchWidgetDescription['indexUiState'];
|
|
20
|
+
type WidgetUiStates = PlacesWidgetDescription['indexUiState'];
|
|
21
|
+
export type IndexUiState = Partial<ConnectorUiStates & WidgetUiStates>;
|
|
22
|
+
export type UiState = {
|
|
23
23
|
[indexId: string]: IndexUiState;
|
|
24
24
|
};
|
|
25
25
|
export {};
|
package/es/types/utils.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type HighlightedParts = {
|
|
2
2
|
value: string;
|
|
3
3
|
isHighlighted: boolean;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export type AtLeastOne<TTarget, TMapped = {
|
|
6
6
|
[Key in keyof TTarget]: Pick<TTarget, Key>;
|
|
7
7
|
}> = Partial<TTarget> & TMapped[keyof TMapped];
|
|
8
|
-
export
|
|
8
|
+
export type Expand<T> = T extends infer O ? {
|
|
9
9
|
[K in keyof O]: O[K];
|
|
10
10
|
} : never;
|
|
11
|
-
export
|
|
12
|
-
export
|
|
11
|
+
export type RequiredKeys<TObject, TKeys extends keyof TObject> = Expand<Required<Pick<TObject, TKeys>> & Omit<TObject, TKeys>>;
|
|
12
|
+
export type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T;
|
|
13
13
|
/**
|
|
14
14
|
* Make certain keys of an object optional.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type PartialKeys<TObj, TKeys extends keyof TObj> = Omit<TObj, TKeys> & Partial<Pick<TObj, TKeys>>;
|
|
@@ -2,13 +2,13 @@ import type { UnknownWidgetParams, Widget, WidgetDescription } from './widget';
|
|
|
2
2
|
/**
|
|
3
3
|
* The function that creates a new widget.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type WidgetFactory<TWidgetDescription extends WidgetDescription, TConnectorParams extends UnknownWidgetParams, TWidgetParams extends UnknownWidgetParams> = (
|
|
6
6
|
/**
|
|
7
7
|
* The params of the widget.
|
|
8
8
|
*/
|
|
9
9
|
widgetParams: TWidgetParams & TConnectorParams) => Widget<TWidgetDescription & {
|
|
10
10
|
widgetParams: TConnectorParams;
|
|
11
11
|
}>;
|
|
12
|
-
export
|
|
12
|
+
export type UnknownWidgetFactory = WidgetFactory<{
|
|
13
13
|
$$type: string;
|
|
14
14
|
}, any, any>;
|