instantsearch.js 4.45.1 → 4.46.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/CHANGELOG.md +21 -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/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
- package/cjs/helpers/components/Highlight.js +7 -7
- package/cjs/helpers/components/ReverseHighlight.js +7 -7
- package/cjs/helpers/components/ReverseSnippet.js +7 -7
- package/cjs/helpers/components/Snippet.js +7 -7
- package/cjs/lib/InstantSearch.js +33 -24
- package/cjs/lib/createHelpers.js +3 -1
- package/cjs/lib/formatNumber.js +10 -0
- package/cjs/lib/utils/capitalize.js +2 -5
- package/cjs/lib/utils/checkIndexUiState.js +3 -5
- package/cjs/lib/utils/checkRendering.js +4 -9
- package/cjs/lib/utils/clearRefinements.js +3 -9
- package/cjs/lib/utils/concatHighlightedParts.js +1 -1
- package/cjs/lib/utils/createSendEventForFacet.js +2 -4
- package/cjs/lib/utils/cx.js +10 -0
- package/cjs/lib/utils/defer.js +3 -6
- package/cjs/lib/utils/detect-insights-client.js +1 -1
- package/cjs/lib/utils/documentation.js +6 -9
- package/cjs/lib/utils/escape-highlight.js +4 -6
- package/cjs/lib/utils/escape-html.js +60 -0
- package/cjs/lib/utils/find.js +2 -5
- package/cjs/lib/utils/findIndex.js +2 -5
- package/cjs/lib/utils/getContainerNode.js +4 -9
- package/cjs/lib/utils/getHighlightFromSiblings.js +3 -5
- package/cjs/lib/utils/getHighlightedParts.js +1 -1
- package/cjs/lib/utils/getObjectType.js +2 -5
- package/cjs/lib/utils/getPropertyByPath.js +2 -5
- package/cjs/lib/utils/getRefinements.js +4 -6
- package/cjs/lib/utils/index.js +563 -432
- package/cjs/lib/utils/isDomElement.js +2 -5
- package/cjs/lib/utils/isEqual.js +2 -5
- package/cjs/lib/utils/isFacetRefined.js +1 -1
- package/cjs/lib/utils/isFiniteNumber.js +3 -5
- package/cjs/lib/utils/isIndexWidget.js +10 -0
- package/cjs/lib/utils/isPlainObject.js +2 -5
- package/cjs/lib/utils/isSpecialClick.js +2 -5
- package/cjs/lib/utils/logger.js +3 -5
- package/cjs/lib/utils/mergeSearchParameters.js +7 -10
- package/cjs/lib/utils/noop.js +2 -5
- package/cjs/lib/utils/prepareTemplateProps.js +4 -9
- package/cjs/lib/utils/range.js +2 -5
- package/cjs/lib/utils/renderTemplate.js +19 -7
- package/cjs/lib/utils/resolveSearchParameters.js +3 -6
- package/cjs/lib/utils/reverseHighlightedParts.js +3 -5
- package/cjs/lib/utils/setIndexHelperState.js +28 -0
- package/cjs/lib/utils/toArray.js +2 -5
- package/cjs/lib/utils/uniq.js +2 -5
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +23 -30
- package/cjs/middlewares/createMetadataMiddleware.js +1 -0
- package/cjs/middlewares/createRouterMiddleware.js +1 -0
- 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/index/index.js +8 -12
- 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 +153 -22
- package/dist/instantsearch.development.js +2842 -2112
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +153 -22
- package/dist/instantsearch.production.min.d.ts +153 -22
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/es/components/ClearRefinements/ClearRefinements.d.ts +1 -1
- package/es/components/GeoSearchControls/GeoSearchControls.d.ts +1 -1
- package/es/components/Hits/Hits.d.ts +2 -3
- 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/RefinementList/RefinementList.d.ts +1 -1
- package/es/components/Template/Template.d.ts +4 -3
- package/es/components/Template/Template.js +14 -4
- package/es/components/ToggleRefinement/ToggleRefinement.d.ts +1 -4
- package/es/components/ToggleRefinement/ToggleRefinement.js +0 -4
- package/es/connectors/toggle-refinement/connectToggleRefinement.d.ts +3 -2
- package/es/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
- package/es/helpers/components/Highlight.js +7 -5
- package/es/helpers/components/ReverseHighlight.js +7 -5
- package/es/helpers/components/ReverseSnippet.js +7 -5
- package/es/helpers/components/Snippet.js +7 -5
- package/es/lib/InstantSearch.d.ts +6 -1
- package/es/lib/InstantSearch.js +34 -21
- 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/capitalize.d.ts +1 -2
- package/es/lib/utils/capitalize.js +2 -4
- package/es/lib/utils/checkIndexUiState.js +1 -1
- package/es/lib/utils/checkRendering.d.ts +1 -2
- package/es/lib/utils/checkRendering.js +3 -6
- package/es/lib/utils/clearRefinements.d.ts +4 -8
- package/es/lib/utils/clearRefinements.js +3 -8
- package/es/lib/utils/concatHighlightedParts.d.ts +1 -1
- package/es/lib/utils/concatHighlightedParts.js +1 -1
- package/es/lib/utils/createSendEventForFacet.js +1 -1
- package/es/lib/utils/createSendEventForHits.d.ts +0 -3
- package/es/lib/utils/createSendEventForHits.js +0 -3
- package/es/lib/utils/cx.d.ts +1 -0
- package/es/lib/utils/cx.js +3 -0
- package/es/lib/utils/defer.d.ts +2 -2
- package/es/lib/utils/defer.js +2 -5
- package/es/lib/utils/detect-insights-client.d.ts +1 -1
- package/es/lib/utils/detect-insights-client.js +1 -1
- package/es/lib/utils/documentation.d.ts +2 -2
- package/es/lib/utils/documentation.js +4 -4
- package/es/lib/utils/escape-highlight.js +2 -2
- package/es/lib/utils/{escape.d.ts → escape-html.d.ts} +6 -2
- package/es/lib/utils/escape-html.js +51 -0
- package/es/lib/utils/escapeFacetValue.d.ts +1 -1
- package/es/lib/utils/find.d.ts +1 -2
- package/es/lib/utils/find.js +2 -4
- package/es/lib/utils/findIndex.d.ts +1 -2
- package/es/lib/utils/findIndex.js +2 -4
- package/es/lib/utils/getContainerNode.d.ts +1 -2
- package/es/lib/utils/getContainerNode.js +3 -5
- package/es/lib/utils/getHighlightFromSiblings.d.ts +1 -1
- package/es/lib/utils/getHighlightFromSiblings.js +2 -2
- package/es/lib/utils/getHighlightedParts.d.ts +1 -1
- package/es/lib/utils/getHighlightedParts.js +1 -1
- package/es/lib/utils/getObjectType.d.ts +1 -2
- package/es/lib/utils/getObjectType.js +2 -4
- package/es/lib/utils/getPropertyByPath.d.ts +1 -2
- package/es/lib/utils/getPropertyByPath.js +2 -4
- package/es/lib/utils/getRefinements.d.ts +1 -1
- package/es/lib/utils/getRefinements.js +2 -2
- package/es/lib/utils/index.d.ts +46 -45
- package/es/lib/utils/index.js +46 -45
- package/es/lib/utils/isDomElement.d.ts +1 -2
- package/es/lib/utils/isDomElement.js +2 -4
- package/es/lib/utils/isEqual.d.ts +1 -2
- package/es/lib/utils/isEqual.js +2 -4
- package/es/lib/utils/isFacetRefined.d.ts +1 -1
- package/es/lib/utils/isFacetRefined.js +1 -1
- package/es/lib/utils/isFiniteNumber.d.ts +1 -2
- package/es/lib/utils/isFiniteNumber.js +3 -4
- package/es/lib/utils/isIndexWidget.d.ts +3 -0
- package/es/lib/utils/isIndexWidget.js +3 -0
- package/es/lib/utils/isPlainObject.d.ts +1 -2
- package/es/lib/utils/isPlainObject.js +2 -4
- package/es/lib/utils/isSpecialClick.d.ts +1 -2
- package/es/lib/utils/isSpecialClick.js +2 -4
- package/es/lib/utils/logger.js +1 -1
- package/es/lib/utils/mergeSearchParameters.d.ts +1 -2
- package/es/lib/utils/mergeSearchParameters.js +4 -6
- package/es/lib/utils/noop.d.ts +1 -2
- package/es/lib/utils/noop.js +1 -3
- package/es/lib/utils/prepareTemplateProps.d.ts +2 -2
- package/es/lib/utils/prepareTemplateProps.js +3 -5
- package/es/lib/utils/range.d.ts +2 -2
- package/es/lib/utils/range.js +2 -4
- package/es/lib/utils/renderTemplate.d.ts +4 -4
- package/es/lib/utils/renderTemplate.js +17 -6
- package/es/lib/utils/resolveSearchParameters.d.ts +1 -2
- package/es/lib/utils/resolveSearchParameters.js +2 -4
- package/es/lib/utils/reverseHighlightedParts.d.ts +1 -1
- package/es/lib/utils/reverseHighlightedParts.js +2 -2
- package/es/lib/utils/setIndexHelperState.d.ts +3 -0
- package/es/lib/utils/setIndexHelperState.js +19 -0
- package/es/lib/utils/toArray.d.ts +3 -2
- package/es/lib/utils/toArray.js +2 -4
- package/es/lib/utils/uniq.d.ts +1 -2
- package/es/lib/utils/uniq.js +2 -4
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.js +23 -27
- package/es/middlewares/createMetadataMiddleware.js +1 -0
- package/es/middlewares/createRouterMiddleware.js +1 -0
- package/es/types/middleware.d.ts +1 -0
- 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/index/index.d.ts +0 -1
- package/es/widgets/index/index.js +5 -6
- 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 +8 -7
- package/cjs/lib/utils/convertNumericRefinementsToFilters.js +0 -31
- package/cjs/lib/utils/escape.js +0 -35
- package/cjs/lib/utils/unescape.js +0 -32
- package/es/lib/utils/convertNumericRefinementsToFilters.d.ts +0 -2
- package/es/lib/utils/convertNumericRefinementsToFilters.js +0 -24
- package/es/lib/utils/escape.js +0 -27
- package/es/lib/utils/unescape.d.ts +0 -9
- package/es/lib/utils/unescape.js +0 -25
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { h } from 'preact';
|
|
3
3
|
import type { BreadcrumbCSSClasses, BreadcrumbTemplates } from '../../widgets/breadcrumb/breadcrumb';
|
|
4
4
|
import type { ComponentCSSClasses } from '../../types';
|
|
5
|
-
import type { PreparedTemplateProps } from '../../lib/utils
|
|
5
|
+
import type { PreparedTemplateProps } from '../../lib/utils';
|
|
6
6
|
import type { BreadcrumbConnectorParamsItem } from '../../connectors/breadcrumb/connectBreadcrumb';
|
|
7
7
|
export declare type BreadcrumbComponentCSSClasses = ComponentCSSClasses<BreadcrumbCSSClasses>;
|
|
8
8
|
export declare type BreadcrumbComponentTemplates = Required<BreadcrumbTemplates>;
|
|
@@ -3,7 +3,7 @@ import { h } from 'preact';
|
|
|
3
3
|
import type { ClearRefinementsRenderState } from '../../connectors/clear-refinements/connectClearRefinements';
|
|
4
4
|
import type { ClearRefinementsCSSClasses, ClearRefinementsTemplates } from '../../widgets/clear-refinements/clear-refinements';
|
|
5
5
|
import type { ComponentCSSClasses } from '../../types';
|
|
6
|
-
import type { PreparedTemplateProps } from '../../lib/utils
|
|
6
|
+
import type { PreparedTemplateProps } from '../../lib/utils';
|
|
7
7
|
export declare type ClearRefinementsComponentCSSClasses = ComponentCSSClasses<ClearRefinementsCSSClasses>;
|
|
8
8
|
export declare type ClearRefinementsComponentTemplates = Required<ClearRefinementsTemplates>;
|
|
9
9
|
export declare type ClearRefinementsProps = {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { h } from 'preact';
|
|
3
3
|
import type { GeoSearchCSSClasses, GeoSearchTemplates } from '../../widgets/geo-search/geo-search';
|
|
4
4
|
import type { ComponentCSSClasses } from '../../types';
|
|
5
|
-
import type { PreparedTemplateProps } from '../../lib/utils
|
|
5
|
+
import type { PreparedTemplateProps } from '../../lib/utils';
|
|
6
6
|
declare type Props = {
|
|
7
7
|
cssClasses: ComponentCSSClasses<GeoSearchCSSClasses>;
|
|
8
8
|
enableRefine: boolean;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/** @jsx h */
|
|
2
2
|
import { h } from 'preact';
|
|
3
3
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
4
|
-
import type { BindEventForHits, SendEventForHits } from '../../lib/utils';
|
|
4
|
+
import type { BindEventForHits, SendEventForHits, PreparedTemplateProps } from '../../lib/utils';
|
|
5
5
|
import type { ComponentCSSClasses, Hit } from '../../types';
|
|
6
6
|
import type { HitsCSSClasses, HitsTemplates } from '../../widgets/hits/hits';
|
|
7
|
-
import type { PreparedTemplateProps } from '../../lib/utils/prepareTemplateProps';
|
|
8
7
|
export declare type HitsComponentCSSClasses = ComponentCSSClasses<HitsCSSClasses>;
|
|
9
8
|
export declare type HitsComponentTemplates = Required<HitsTemplates>;
|
|
10
9
|
export declare type HitsProps = {
|
|
@@ -15,5 +14,5 @@ export declare type HitsProps = {
|
|
|
15
14
|
cssClasses: HitsComponentCSSClasses;
|
|
16
15
|
templateProps: PreparedTemplateProps<HitsComponentTemplates>;
|
|
17
16
|
};
|
|
18
|
-
declare const Hits: ({ results, hits, bindEvent, cssClasses, templateProps, }: HitsProps) => h.JSX.Element;
|
|
17
|
+
declare const Hits: ({ results, hits, bindEvent, sendEvent, cssClasses, templateProps, }: HitsProps) => h.JSX.Element;
|
|
19
18
|
export default Hits;
|
|
@@ -15,6 +15,7 @@ var Hits = function Hits(_ref) {
|
|
|
15
15
|
var results = _ref.results,
|
|
16
16
|
hits = _ref.hits,
|
|
17
17
|
bindEvent = _ref.bindEvent,
|
|
18
|
+
sendEvent = _ref.sendEvent,
|
|
18
19
|
cssClasses = _ref.cssClasses,
|
|
19
20
|
templateProps = _ref.templateProps;
|
|
20
21
|
|
|
@@ -43,7 +44,8 @@ var Hits = function Hits(_ref) {
|
|
|
43
44
|
data: _objectSpread(_objectSpread({}, hit), {}, {
|
|
44
45
|
__hitIndex: index
|
|
45
46
|
}),
|
|
46
|
-
bindEvent: bindEvent
|
|
47
|
+
bindEvent: bindEvent,
|
|
48
|
+
sendEvent: sendEvent
|
|
47
49
|
}));
|
|
48
50
|
})));
|
|
49
51
|
};
|
|
@@ -22,5 +22,5 @@ export declare type InfiniteHitsProps = {
|
|
|
22
22
|
sendEvent: SendEventForHits;
|
|
23
23
|
bindEvent: BindEventForHits;
|
|
24
24
|
};
|
|
25
|
-
declare const InfiniteHits: ({ results, hits, bindEvent, hasShowPrevious, showPrevious, showMore, isFirstPage, isLastPage, cssClasses, templateProps, }: InfiniteHitsProps) => h.JSX.Element;
|
|
25
|
+
declare const InfiniteHits: ({ results, hits, bindEvent, sendEvent, hasShowPrevious, showPrevious, showMore, isFirstPage, isLastPage, cssClasses, templateProps, }: InfiniteHitsProps) => h.JSX.Element;
|
|
26
26
|
export default InfiniteHits;
|
|
@@ -15,6 +15,7 @@ var InfiniteHits = function InfiniteHits(_ref) {
|
|
|
15
15
|
var results = _ref.results,
|
|
16
16
|
hits = _ref.hits,
|
|
17
17
|
bindEvent = _ref.bindEvent,
|
|
18
|
+
sendEvent = _ref.sendEvent,
|
|
18
19
|
hasShowPrevious = _ref.hasShowPrevious,
|
|
19
20
|
showPrevious = _ref.showPrevious,
|
|
20
21
|
showMore = _ref.showMore,
|
|
@@ -56,7 +57,8 @@ var InfiniteHits = function InfiniteHits(_ref) {
|
|
|
56
57
|
data: _objectSpread(_objectSpread({}, hit), {}, {
|
|
57
58
|
__hitIndex: position
|
|
58
59
|
}),
|
|
59
|
-
bindEvent: bindEvent
|
|
60
|
+
bindEvent: bindEvent,
|
|
61
|
+
sendEvent: sendEvent
|
|
60
62
|
}));
|
|
61
63
|
})), h(Template, _extends({}, templateProps, {
|
|
62
64
|
templateKey: "showMoreText",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx h */
|
|
2
2
|
import type { JSX } from 'preact';
|
|
3
3
|
import { Component } from 'preact';
|
|
4
|
-
import type { PreparedTemplateProps } from '../../lib/utils
|
|
4
|
+
import type { PreparedTemplateProps } from '../../lib/utils';
|
|
5
5
|
import type { SearchBoxComponentCSSClasses, SearchBoxComponentTemplates } from '../SearchBox/SearchBox';
|
|
6
6
|
import type { HierarchicalMenuItem } from '../../connectors/hierarchical-menu/connectHierarchicalMenu';
|
|
7
7
|
import type { ComponentCSSClasses, CreateURL, Templates } from '../../types';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx h */
|
|
2
2
|
import type { JSX } from 'preact';
|
|
3
3
|
import { Component } from 'preact';
|
|
4
|
-
import type { PreparedTemplateProps } from '../../lib/utils
|
|
4
|
+
import type { BindEventForHits, SendEventForHits, PreparedTemplateProps } from '../../lib/utils';
|
|
5
5
|
import type { Templates } from '../../types';
|
|
6
6
|
declare const defaultProps: {
|
|
7
7
|
data: {};
|
|
@@ -10,12 +10,13 @@ declare const defaultProps: {
|
|
|
10
10
|
templates: {};
|
|
11
11
|
templatesConfig: {};
|
|
12
12
|
};
|
|
13
|
-
declare type TemplateProps = {
|
|
13
|
+
export declare type TemplateProps = {
|
|
14
14
|
data?: Record<string, any>;
|
|
15
15
|
rootProps?: Record<string, any>;
|
|
16
16
|
rootTagName?: keyof JSX.IntrinsicElements;
|
|
17
17
|
templateKey: string;
|
|
18
|
-
bindEvent?:
|
|
18
|
+
bindEvent?: BindEventForHits;
|
|
19
|
+
sendEvent?: SendEventForHits;
|
|
19
20
|
} & PreparedTemplateProps<Templates> & Readonly<typeof defaultProps>;
|
|
20
21
|
declare class Template extends Component<TemplateProps> {
|
|
21
22
|
static readonly defaultProps: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
-
|
|
3
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
6
|
|
|
7
7
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -26,7 +26,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
26
26
|
|
|
27
27
|
/** @jsx h */
|
|
28
28
|
import { h, Component } from 'preact';
|
|
29
|
-
import { renderTemplate, isEqual } from "../../lib/utils/index.js";
|
|
29
|
+
import { warning, renderTemplate, isEqual } from "../../lib/utils/index.js";
|
|
30
30
|
var defaultProps = {
|
|
31
31
|
data: {},
|
|
32
32
|
rootTagName: 'div',
|
|
@@ -55,6 +55,11 @@ var Template = /*#__PURE__*/function (_Component) {
|
|
|
55
55
|
}, {
|
|
56
56
|
key: "render",
|
|
57
57
|
value: function render() {
|
|
58
|
+
var _this = this;
|
|
59
|
+
|
|
60
|
+
process.env.NODE_ENV === 'development' ? warning(Object.keys(this.props.templates).every(function (key) {
|
|
61
|
+
return typeof _this.props.templates[key] === 'function';
|
|
62
|
+
}), "Hogan.js and string-based templates are deprecated and will not be supported in InstantSearch.js 5.x.\n\nYou can replace them with function-form templates and use either the provided `html` function or JSX templates.\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/#upgrade-templates") : void 0;
|
|
58
63
|
var RootTagName = this.props.rootTagName;
|
|
59
64
|
var useCustomCompileOptions = this.props.useCustomCompileOptions[this.props.templateKey];
|
|
60
65
|
var compileOptions = useCustomCompileOptions ? this.props.templatesConfig.compileOptions : {};
|
|
@@ -64,7 +69,8 @@ var Template = /*#__PURE__*/function (_Component) {
|
|
|
64
69
|
compileOptions: compileOptions,
|
|
65
70
|
helpers: this.props.templatesConfig.helpers,
|
|
66
71
|
data: this.props.data,
|
|
67
|
-
bindEvent: this.props.bindEvent
|
|
72
|
+
bindEvent: this.props.bindEvent,
|
|
73
|
+
sendEvent: this.props.sendEvent
|
|
68
74
|
});
|
|
69
75
|
|
|
70
76
|
if (content === null) {
|
|
@@ -73,6 +79,10 @@ var Template = /*#__PURE__*/function (_Component) {
|
|
|
73
79
|
return null;
|
|
74
80
|
}
|
|
75
81
|
|
|
82
|
+
if (_typeof(content) === 'object') {
|
|
83
|
+
return h(RootTagName, this.props.rootProps, content);
|
|
84
|
+
}
|
|
85
|
+
|
|
76
86
|
return h(RootTagName, _extends({}, this.props.rootProps, {
|
|
77
87
|
dangerouslySetInnerHTML: {
|
|
78
88
|
__html: content
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*/
|
|
4
1
|
/** @jsx h */
|
|
5
2
|
import { h } from 'preact';
|
|
6
3
|
import type { ToggleRefinementRenderState, ToggleRefinementValue } from '../../connectors/toggle-refinement/connectToggleRefinement';
|
|
7
|
-
import type { PreparedTemplateProps } from '../../lib/utils
|
|
4
|
+
import type { PreparedTemplateProps } from '../../lib/utils';
|
|
8
5
|
import type { ComponentCSSClasses } from '../../types';
|
|
9
6
|
import type { ToggleRefinementTemplates, ToggleRefinementCSSClasses } from '../../widgets/toggle-refinement/toggle-refinement';
|
|
10
7
|
export declare type ToggleRefinementComponentCSSClasses = ComponentCSSClasses<ToggleRefinementCSSClasses>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @jest-environment jsdom
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
3
|
/** @jsx h */
|
|
8
4
|
import { h } from 'preact';
|
|
9
5
|
import Template from "../Template/Template.js";
|
|
@@ -21,12 +21,13 @@ export declare type ToggleRefinementConnectorParams = {
|
|
|
21
21
|
* Value to filter on when toggled.
|
|
22
22
|
* @default "true"
|
|
23
23
|
*/
|
|
24
|
-
on?:
|
|
24
|
+
on?: FacetValue | FacetValue[];
|
|
25
25
|
/**
|
|
26
26
|
* Value to filter on when not toggled.
|
|
27
27
|
*/
|
|
28
|
-
off?:
|
|
28
|
+
off?: FacetValue | FacetValue[];
|
|
29
29
|
};
|
|
30
|
+
declare type FacetValue = string | boolean | number;
|
|
30
31
|
export declare type ToggleRefinementRenderState = {
|
|
31
32
|
/** The current toggle value */
|
|
32
33
|
value: {
|
|
@@ -80,7 +80,9 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
80
80
|
throw new Error(withUsage('The `attribute` option is required.'));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
var hasAnOffValue = userOff !== undefined;
|
|
83
|
+
var hasAnOffValue = userOff !== undefined; // even though facet values can be numbers and boolean,
|
|
84
|
+
// the helper methods only accept string in the type
|
|
85
|
+
|
|
84
86
|
var on = toArray(userOn).map(escapeFacetValue);
|
|
85
87
|
var off = hasAnOffValue ? toArray(userOff).map(escapeFacetValue) : undefined;
|
|
86
88
|
var sendEvent;
|
|
@@ -6,11 +6,13 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
6
6
|
|
|
7
7
|
/** @jsx h */
|
|
8
8
|
import { h } from 'preact';
|
|
9
|
-
import { Highlight as HighlightUiComponent } from "../../components/Highlight/Highlight.js";
|
|
10
|
-
|
|
11
|
-
import getPropertyByPath from "../../lib/utils/getPropertyByPath.js";
|
|
12
|
-
import unescape from "../../lib/utils/
|
|
9
|
+
import { Highlight as HighlightUiComponent } from "../../components/Highlight/Highlight.js"; // These utils are individually imported, as utils/renderTemplate imports helpers/components, importing lib/utils would create a circular dependency.
|
|
10
|
+
|
|
11
|
+
import { getPropertyByPath } from "../../lib/utils/getPropertyByPath.js";
|
|
12
|
+
import { unescape } from "../../lib/utils/escape-html.js";
|
|
13
|
+
import { toArray } from "../../lib/utils/toArray.js";
|
|
13
14
|
import { warning } from "../../lib/utils/logger.js";
|
|
15
|
+
import { getHighlightedParts } from "../../lib/utils/getHighlightedParts.js";
|
|
14
16
|
export function Highlight(_ref) {
|
|
15
17
|
var hit = _ref.hit,
|
|
16
18
|
attribute = _ref.attribute,
|
|
@@ -18,7 +20,7 @@ export function Highlight(_ref) {
|
|
|
18
20
|
props = _objectWithoutProperties(_ref, ["hit", "attribute", "cssClasses"]);
|
|
19
21
|
|
|
20
22
|
var property = getPropertyByPath(hit._highlightResult, attribute) || [];
|
|
21
|
-
var properties =
|
|
23
|
+
var properties = toArray(property);
|
|
22
24
|
process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable highlight for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
23
25
|
var parts = properties.map(function (_ref2) {
|
|
24
26
|
var value = _ref2.value;
|
|
@@ -12,11 +12,13 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
12
12
|
|
|
13
13
|
/** @jsx h */
|
|
14
14
|
import { h } from 'preact';
|
|
15
|
-
import { ReverseHighlight as ReverseHighlightUiComponent } from "../../components/ReverseHighlight/ReverseHighlight.js";
|
|
16
|
-
|
|
17
|
-
import getPropertyByPath from "../../lib/utils/getPropertyByPath.js";
|
|
18
|
-
import unescape from "../../lib/utils/
|
|
15
|
+
import { ReverseHighlight as ReverseHighlightUiComponent } from "../../components/ReverseHighlight/ReverseHighlight.js"; // These utils are individually imported, as utils/renderTemplate imports helpers/components, importing lib/utils would create a circular dependency.
|
|
16
|
+
|
|
17
|
+
import { getPropertyByPath } from "../../lib/utils/getPropertyByPath.js";
|
|
18
|
+
import { unescape } from "../../lib/utils/escape-html.js";
|
|
19
|
+
import { toArray } from "../../lib/utils/toArray.js";
|
|
19
20
|
import { warning } from "../../lib/utils/logger.js";
|
|
21
|
+
import { getHighlightedParts } from "../../lib/utils/getHighlightedParts.js";
|
|
20
22
|
export function ReverseHighlight(_ref) {
|
|
21
23
|
var hit = _ref.hit,
|
|
22
24
|
attribute = _ref.attribute,
|
|
@@ -24,7 +26,7 @@ export function ReverseHighlight(_ref) {
|
|
|
24
26
|
props = _objectWithoutProperties(_ref, ["hit", "attribute", "cssClasses"]);
|
|
25
27
|
|
|
26
28
|
var property = getPropertyByPath(hit._highlightResult, attribute) || [];
|
|
27
|
-
var properties =
|
|
29
|
+
var properties = toArray(property);
|
|
28
30
|
process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable highlight for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
29
31
|
var parts = properties.map(function (_ref2) {
|
|
30
32
|
var value = _ref2.value;
|
|
@@ -12,11 +12,13 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
12
12
|
|
|
13
13
|
/** @jsx h */
|
|
14
14
|
import { h } from 'preact';
|
|
15
|
-
import { ReverseSnippet as ReverseSnippetUiComponent } from "../../components/ReverseSnippet/ReverseSnippet.js";
|
|
16
|
-
|
|
17
|
-
import getPropertyByPath from "../../lib/utils/getPropertyByPath.js";
|
|
18
|
-
import unescape from "../../lib/utils/
|
|
15
|
+
import { ReverseSnippet as ReverseSnippetUiComponent } from "../../components/ReverseSnippet/ReverseSnippet.js"; // These utils are individually imported, as utils/renderTemplate imports helpers/components, importing lib/utils would create a circular dependency.
|
|
16
|
+
|
|
17
|
+
import { getPropertyByPath } from "../../lib/utils/getPropertyByPath.js";
|
|
18
|
+
import { unescape } from "../../lib/utils/escape-html.js";
|
|
19
|
+
import { toArray } from "../../lib/utils/toArray.js";
|
|
19
20
|
import { warning } from "../../lib/utils/logger.js";
|
|
21
|
+
import { getHighlightedParts } from "../../lib/utils/getHighlightedParts.js";
|
|
20
22
|
export function ReverseSnippet(_ref) {
|
|
21
23
|
var hit = _ref.hit,
|
|
22
24
|
attribute = _ref.attribute,
|
|
@@ -24,7 +26,7 @@ export function ReverseSnippet(_ref) {
|
|
|
24
26
|
props = _objectWithoutProperties(_ref, ["hit", "attribute", "cssClasses"]);
|
|
25
27
|
|
|
26
28
|
var property = getPropertyByPath(hit._snippetResult, attribute) || [];
|
|
27
|
-
var properties =
|
|
29
|
+
var properties = toArray(property);
|
|
28
30
|
process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
29
31
|
var parts = properties.map(function (_ref2) {
|
|
30
32
|
var value = _ref2.value;
|
|
@@ -6,11 +6,13 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
6
6
|
|
|
7
7
|
/** @jsx h */
|
|
8
8
|
import { h } from 'preact';
|
|
9
|
-
import { Snippet as SnippetUiComponent } from "../../components/Snippet/Snippet.js";
|
|
10
|
-
|
|
11
|
-
import getPropertyByPath from "../../lib/utils/getPropertyByPath.js";
|
|
12
|
-
import
|
|
9
|
+
import { Snippet as SnippetUiComponent } from "../../components/Snippet/Snippet.js"; // These utils are individually imported, as utils/renderTemplate imports helpers/components, importing lib/utils would create a circular dependency.
|
|
10
|
+
|
|
11
|
+
import { getPropertyByPath } from "../../lib/utils/getPropertyByPath.js";
|
|
12
|
+
import { toArray } from "../../lib/utils/toArray.js";
|
|
13
|
+
import { unescape } from "../../lib/utils/escape-html.js";
|
|
13
14
|
import { warning } from "../../lib/utils/logger.js";
|
|
15
|
+
import { getHighlightedParts } from "../../lib/utils/getHighlightedParts.js";
|
|
14
16
|
export function Snippet(_ref) {
|
|
15
17
|
var hit = _ref.hit,
|
|
16
18
|
attribute = _ref.attribute,
|
|
@@ -18,7 +20,7 @@ export function Snippet(_ref) {
|
|
|
18
20
|
props = _objectWithoutProperties(_ref, ["hit", "attribute", "cssClasses"]);
|
|
19
21
|
|
|
20
22
|
var property = getPropertyByPath(hit._snippetResult, attribute) || [];
|
|
21
|
-
var properties =
|
|
23
|
+
var properties = toArray(property);
|
|
22
24
|
process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
23
25
|
var parts = properties.map(function (_ref2) {
|
|
24
26
|
var value = _ref2.value;
|
|
@@ -177,7 +177,12 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
177
177
|
cancel(): void;
|
|
178
178
|
};
|
|
179
179
|
scheduleStalledRender(): void;
|
|
180
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Set the UI state and trigger a search.
|
|
182
|
+
* @param uiState The next UI state or a function computing it from the current state
|
|
183
|
+
* @param callOnStateChange private parameter used to know if the method is called from a state change
|
|
184
|
+
*/
|
|
185
|
+
setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState), callOnStateChange?: boolean): void;
|
|
181
186
|
getUiState(): TUiState;
|
|
182
187
|
onInternalStateChange: ((...args: any[]) => void) & {
|
|
183
188
|
wait(): Promise<void>;
|
package/es/lib/InstantSearch.js
CHANGED
|
@@ -28,10 +28,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
28
28
|
|
|
29
29
|
import algoliasearchHelper from 'algoliasearch-helper';
|
|
30
30
|
import EventEmitter from '@algolia/events';
|
|
31
|
-
import index
|
|
31
|
+
import index from "../widgets/index/index.js";
|
|
32
32
|
import version from "./version.js";
|
|
33
33
|
import createHelpers from "./createHelpers.js";
|
|
34
|
-
import { createDocumentationMessageGenerator, createDocumentationLink, defer, noop, warning,
|
|
34
|
+
import { createDocumentationMessageGenerator, createDocumentationLink, defer, noop, warning, setIndexHelperState } from "./utils/index.js";
|
|
35
35
|
import { createRouterMiddleware } from "../middlewares/createRouterMiddleware.js";
|
|
36
36
|
import { createMetadataMiddleware, isMetadataEnabled } from "../middlewares/createMetadataMiddleware.js";
|
|
37
37
|
var withUsage = createDocumentationMessageGenerator({
|
|
@@ -233,6 +233,7 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
233
233
|
var newMiddlewareList = middleware.map(function (fn) {
|
|
234
234
|
var newMiddleware = _objectSpread({
|
|
235
235
|
subscribe: noop,
|
|
236
|
+
started: noop,
|
|
236
237
|
unsubscribe: noop,
|
|
237
238
|
onStateChange: noop
|
|
238
239
|
}, fn({
|
|
@@ -251,6 +252,7 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
251
252
|
if (this.started) {
|
|
252
253
|
newMiddlewareList.forEach(function (m) {
|
|
253
254
|
m.subscribe();
|
|
255
|
+
m.started();
|
|
254
256
|
});
|
|
255
257
|
}
|
|
256
258
|
|
|
@@ -487,6 +489,10 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
487
489
|
// to init them directly after add
|
|
488
490
|
|
|
489
491
|
this.started = true;
|
|
492
|
+
this.middleware.forEach(function (_ref6) {
|
|
493
|
+
var instance = _ref6.instance;
|
|
494
|
+
instance.started();
|
|
495
|
+
});
|
|
490
496
|
}
|
|
491
497
|
/**
|
|
492
498
|
* Removes all widgets without triggering a search afterwards. This is an **EXPERIMENTAL** feature,
|
|
@@ -513,8 +519,8 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
513
519
|
this.mainHelper.removeAllListeners();
|
|
514
520
|
this.mainHelper = null;
|
|
515
521
|
this.helper = null;
|
|
516
|
-
this.middleware.forEach(function (
|
|
517
|
-
var instance =
|
|
522
|
+
this.middleware.forEach(function (_ref7) {
|
|
523
|
+
var instance = _ref7.instance;
|
|
518
524
|
instance.unsubscribe();
|
|
519
525
|
});
|
|
520
526
|
}
|
|
@@ -531,9 +537,19 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
531
537
|
}, this._stalledSearchDelay);
|
|
532
538
|
}
|
|
533
539
|
}
|
|
540
|
+
/**
|
|
541
|
+
* Set the UI state and trigger a search.
|
|
542
|
+
* @param uiState The next UI state or a function computing it from the current state
|
|
543
|
+
* @param callOnStateChange private parameter used to know if the method is called from a state change
|
|
544
|
+
*/
|
|
545
|
+
|
|
534
546
|
}, {
|
|
535
547
|
key: "setUiState",
|
|
536
548
|
value: function setUiState(uiState) {
|
|
549
|
+
var _this5 = this;
|
|
550
|
+
|
|
551
|
+
var callOnStateChange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
552
|
+
|
|
537
553
|
if (!this.mainHelper) {
|
|
538
554
|
throw new Error(withUsage('The `start` method needs to be called before `setUiState`.'));
|
|
539
555
|
} // We refresh the index UI state to update the local UI state that the
|
|
@@ -543,25 +559,22 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
543
559
|
this.mainIndex.refreshUiState();
|
|
544
560
|
var nextUiState = typeof uiState === 'function' ? uiState(this.mainIndex.getWidgetUiState({})) : uiState;
|
|
545
561
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
index: indexWidget,
|
|
552
|
-
indexUiState: nextIndexUiState
|
|
553
|
-
});
|
|
554
|
-
}
|
|
562
|
+
if (this.onStateChange && callOnStateChange) {
|
|
563
|
+
this.onStateChange({
|
|
564
|
+
uiState: nextUiState,
|
|
565
|
+
setUiState: function setUiState(finalUiState) {
|
|
566
|
+
setIndexHelperState(typeof finalUiState === 'function' ? finalUiState(nextUiState) : finalUiState, _this5.mainIndex);
|
|
555
567
|
|
|
556
|
-
|
|
557
|
-
uiState: nextIndexUiState
|
|
558
|
-
}));
|
|
559
|
-
indexWidget.getWidgets().filter(isIndexWidget).forEach(setIndexHelperState);
|
|
560
|
-
};
|
|
568
|
+
_this5.scheduleSearch();
|
|
561
569
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
570
|
+
_this5.onInternalStateChange();
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
} else {
|
|
574
|
+
setIndexHelperState(nextUiState, this.mainIndex);
|
|
575
|
+
this.scheduleSearch();
|
|
576
|
+
this.onInternalStateChange();
|
|
577
|
+
}
|
|
565
578
|
}
|
|
566
579
|
}, {
|
|
567
580
|
key: "getUiState",
|
package/es/lib/createHelpers.js
CHANGED
|
@@ -5,11 +5,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
7
|
import { highlight as _highlight, reverseHighlight as _reverseHighlight, snippet as _snippet, reverseSnippet as _reverseSnippet, insights as _insights } from "../helpers/index.js";
|
|
8
|
+
import { formatNumber as _formatNumber } from "./formatNumber.js";
|
|
8
9
|
export default function hoganHelpers(_ref) {
|
|
9
10
|
var numberLocale = _ref.numberLocale;
|
|
10
11
|
return {
|
|
11
12
|
formatNumber: function formatNumber(value, render) {
|
|
12
|
-
return Number(render(value))
|
|
13
|
+
return _formatNumber(Number(render(value)), numberLocale);
|
|
13
14
|
},
|
|
14
15
|
highlight: function highlight(options, render) {
|
|
15
16
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatNumber(value: number, numberLocale?: string): string;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare function capitalize(text: string): string;
|
|
2
|
-
export default capitalize;
|
|
1
|
+
export declare function capitalize(text: string): string;
|
|
@@ -18,7 +18,7 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
|
|
|
18
18
|
|
|
19
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
20
|
|
|
21
|
-
import capitalize from "./capitalize.js";
|
|
21
|
+
import { capitalize } from "./capitalize.js";
|
|
22
22
|
import { warning } from "./logger.js";
|
|
23
23
|
import { keys } from "./typedObject.js"; // Some connectors are responsible for multiple widgets so we need
|
|
24
24
|
// to map them.
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { Renderer } from '../../types/connector';
|
|
2
|
-
declare function checkRendering<TRenderOptions, TWidgetParams>(rendering: Renderer<TRenderOptions, TWidgetParams>, usage: string): void;
|
|
3
|
-
export default checkRendering;
|
|
2
|
+
export declare function checkRendering<TRenderOptions, TWidgetParams>(rendering: Renderer<TRenderOptions, TWidgetParams>, usage: string): void;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import getObjectType from "./getObjectType.js";
|
|
2
|
-
|
|
3
|
-
function checkRendering(rendering, usage) {
|
|
1
|
+
import { getObjectType } from "./getObjectType.js";
|
|
2
|
+
export function checkRendering(rendering, usage) {
|
|
4
3
|
if (rendering === undefined || typeof rendering !== 'function') {
|
|
5
4
|
throw new Error("The render function is not valid (received type ".concat(getObjectType(rendering), ").\n\n").concat(usage));
|
|
6
5
|
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default checkRendering;
|
|
6
|
+
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
|
|
1
|
+
import type { AlgoliaSearchHelper, SearchParameters } from 'algoliasearch-helper';
|
|
2
2
|
/**
|
|
3
3
|
* Clears the refinements of a SearchParameters object based on rules provided.
|
|
4
4
|
* The included attributes list is applied before the excluded attributes list. If the list
|
|
5
5
|
* is not provided, this list of all the currently refined attributes is used as included attributes.
|
|
6
|
-
* @
|
|
7
|
-
* @param {Helper} $0.helper instance of the Helper
|
|
8
|
-
* @param {string[]} [$0.attributesToClear = []] list of parameters to clear
|
|
9
|
-
* @returns {SearchParameters} search parameters with refinements cleared
|
|
6
|
+
* @returns search parameters with refinements cleared
|
|
10
7
|
*/
|
|
11
|
-
declare function clearRefinements({ helper, attributesToClear, }: {
|
|
8
|
+
export declare function clearRefinements({ helper, attributesToClear, }: {
|
|
12
9
|
helper: AlgoliaSearchHelper;
|
|
13
10
|
attributesToClear?: string[];
|
|
14
|
-
}):
|
|
15
|
-
export default clearRefinements;
|
|
11
|
+
}): SearchParameters;
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
* Clears the refinements of a SearchParameters object based on rules provided.
|
|
3
3
|
* The included attributes list is applied before the excluded attributes list. If the list
|
|
4
4
|
* is not provided, this list of all the currently refined attributes is used as included attributes.
|
|
5
|
-
* @
|
|
6
|
-
* @param {Helper} $0.helper instance of the Helper
|
|
7
|
-
* @param {string[]} [$0.attributesToClear = []] list of parameters to clear
|
|
8
|
-
* @returns {SearchParameters} search parameters with refinements cleared
|
|
5
|
+
* @returns search parameters with refinements cleared
|
|
9
6
|
*/
|
|
10
|
-
function clearRefinements(_ref) {
|
|
7
|
+
export function clearRefinements(_ref) {
|
|
11
8
|
var helper = _ref.helper,
|
|
12
9
|
_ref$attributesToClea = _ref.attributesToClear,
|
|
13
10
|
attributesToClear = _ref$attributesToClea === void 0 ? [] : _ref$attributesToClea;
|
|
@@ -37,6 +34,4 @@ function clearRefinements(_ref) {
|
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
return finalState;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default clearRefinements;
|
|
37
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { HighlightedParts } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export declare function concatHighlightedParts(parts: HighlightedParts[]): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TAG_REPLACEMENT } from "./escape-highlight.js";
|
|
2
|
-
export
|
|
2
|
+
export function concatHighlightedParts(parts) {
|
|
3
3
|
var highlightPreTag = TAG_REPLACEMENT.highlightPreTag,
|
|
4
4
|
highlightPostTag = TAG_REPLACEMENT.highlightPostTag;
|
|
5
5
|
return parts.map(function (part) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
|
-
import isFacetRefined from "./isFacetRefined.js";
|
|
3
|
+
import { isFacetRefined } from "./isFacetRefined.js";
|
|
4
4
|
export function createSendEventForFacet(_ref) {
|
|
5
5
|
var instantSearchInstance = _ref.instantSearchInstance,
|
|
6
6
|
helper = _ref.helper,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*/
|
|
4
1
|
import type { InstantSearch, Hit } from '../../types';
|
|
5
2
|
declare type BuiltInSendEventForHits = (eventType: string, hits: Hit | Hit[], eventName?: string) => void;
|
|
6
3
|
declare type CustomSendEventForHits = (customPayload: any) => void;
|