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
|
@@ -15,5 +15,5 @@ export declare type HitsProps = {
|
|
|
15
15
|
cssClasses: HitsComponentCSSClasses;
|
|
16
16
|
templateProps: PreparedTemplateProps<HitsComponentTemplates>;
|
|
17
17
|
};
|
|
18
|
-
declare const Hits: ({ results, hits, bindEvent, cssClasses, templateProps, }: HitsProps) => h.JSX.Element;
|
|
18
|
+
declare const Hits: ({ results, hits, bindEvent, sendEvent, cssClasses, templateProps, }: HitsProps) => h.JSX.Element;
|
|
19
19
|
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,6 +1,7 @@
|
|
|
1
1
|
/** @jsx h */
|
|
2
2
|
import type { JSX } from 'preact';
|
|
3
3
|
import { Component } from 'preact';
|
|
4
|
+
import type { BindEventForHits, SendEventForHits } from '../../lib/utils';
|
|
4
5
|
import type { PreparedTemplateProps } from '../../lib/utils/prepareTemplateProps';
|
|
5
6
|
import type { Templates } from '../../types';
|
|
6
7
|
declare const defaultProps: {
|
|
@@ -10,12 +11,13 @@ declare const defaultProps: {
|
|
|
10
11
|
templates: {};
|
|
11
12
|
templatesConfig: {};
|
|
12
13
|
};
|
|
13
|
-
declare type TemplateProps = {
|
|
14
|
+
export declare type TemplateProps = {
|
|
14
15
|
data?: Record<string, any>;
|
|
15
16
|
rootProps?: Record<string, any>;
|
|
16
17
|
rootTagName?: keyof JSX.IntrinsicElements;
|
|
17
18
|
templateKey: string;
|
|
18
|
-
bindEvent?:
|
|
19
|
+
bindEvent?: BindEventForHits;
|
|
20
|
+
sendEvent?: SendEventForHits;
|
|
19
21
|
} & PreparedTemplateProps<Templates> & Readonly<typeof defaultProps>;
|
|
20
22
|
declare class Template extends Component<TemplateProps> {
|
|
21
23
|
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
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cx(cssClasses?: string | string[] | undefined): string;
|
package/es/lib/utils/index.d.ts
CHANGED
package/es/lib/utils/index.js
CHANGED
|
@@ -44,4 +44,5 @@ export { createConcurrentSafePromise } from "./createConcurrentSafePromise.js";
|
|
|
44
44
|
export { debounce } from "./debounce.js";
|
|
45
45
|
export { serializePayload, deserializePayload } from "./serializer.js";
|
|
46
46
|
export { getWidgetAttribute } from "./getWidgetAttribute.js";
|
|
47
|
-
export { safelyRunOnBrowser } from "./safelyRunOnBrowser.js";
|
|
47
|
+
export { safelyRunOnBrowser } from "./safelyRunOnBrowser.js";
|
|
48
|
+
export { cx } from "./cx.js";
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { HoganOptions } from 'hogan.js';
|
|
2
2
|
import type { Templates, HoganHelpers } from '../../types';
|
|
3
|
-
import type { BindEventForHits } from './createSendEventForHits';
|
|
4
|
-
declare function renderTemplate({ templates, templateKey, compileOptions, helpers, data, bindEvent, }: {
|
|
3
|
+
import type { BindEventForHits, SendEventForHits } from './createSendEventForHits';
|
|
4
|
+
declare function renderTemplate({ templates, templateKey, compileOptions, helpers, data, bindEvent, sendEvent, }: {
|
|
5
5
|
templates: Templates;
|
|
6
6
|
templateKey: string;
|
|
7
7
|
compileOptions?: HoganOptions;
|
|
8
8
|
helpers?: HoganHelpers;
|
|
9
9
|
data?: Record<string, any>;
|
|
10
10
|
bindEvent?: BindEventForHits;
|
|
11
|
-
|
|
11
|
+
sendEvent?: SendEventForHits;
|
|
12
|
+
}): string | import("preact").VNode<{}> | import("preact").VNode<{}>[];
|
|
12
13
|
export default renderTemplate;
|
|
@@ -7,6 +7,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
7
7
|
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; }
|
|
8
8
|
|
|
9
9
|
import hogan from 'hogan.js';
|
|
10
|
+
import { Highlight, ReverseHighlight, ReverseSnippet, Snippet } from "../../helpers/components/index.js";
|
|
11
|
+
import { html } from 'htm/preact';
|
|
10
12
|
|
|
11
13
|
// We add all our template helper methods to the template as lambdas. Note
|
|
12
14
|
// that lambdas in Mustache are supposed to accept a second argument of
|
|
@@ -37,7 +39,8 @@ function renderTemplate(_ref) {
|
|
|
37
39
|
compileOptions = _ref.compileOptions,
|
|
38
40
|
helpers = _ref.helpers,
|
|
39
41
|
data = _ref.data,
|
|
40
|
-
bindEvent = _ref.bindEvent
|
|
42
|
+
bindEvent = _ref.bindEvent,
|
|
43
|
+
sendEvent = _ref.sendEvent;
|
|
41
44
|
var template = templates[templateKey];
|
|
42
45
|
|
|
43
46
|
if (typeof template !== 'string' && typeof template !== 'function') {
|
|
@@ -45,7 +48,17 @@ function renderTemplate(_ref) {
|
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
if (typeof template === 'function') {
|
|
48
|
-
|
|
51
|
+
// @MAJOR no longer pass bindEvent when string templates are removed
|
|
52
|
+
var params = bindEvent || {};
|
|
53
|
+
params.html = html;
|
|
54
|
+
params.sendEvent = sendEvent;
|
|
55
|
+
params.components = {
|
|
56
|
+
Highlight: Highlight,
|
|
57
|
+
ReverseHighlight: ReverseHighlight,
|
|
58
|
+
Snippet: Snippet,
|
|
59
|
+
ReverseSnippet: ReverseSnippet
|
|
60
|
+
};
|
|
61
|
+
return template(data, params);
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
var transformedHelpers = transformHelpersToHogan(helpers, compileOptions, data);
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.
|
|
1
|
+
declare const _default: "4.46.0";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.
|
|
1
|
+
export default '4.46.0';
|
package/es/types/templates.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { VNode } from 'preact';
|
|
2
|
+
import type { Highlight, ReverseHighlight, ReverseSnippet, Snippet } from '../helpers/components';
|
|
3
|
+
import type { html } from 'htm/preact';
|
|
4
|
+
import type { BindEventForHits, SendEventForHits } from '../lib/utils';
|
|
5
|
+
export declare type Template<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string);
|
|
6
|
+
export declare type TemplateParams = BindEventForHits & {
|
|
7
|
+
html: typeof html;
|
|
8
|
+
components: {
|
|
9
|
+
Highlight: typeof Highlight;
|
|
10
|
+
ReverseHighlight: typeof ReverseHighlight;
|
|
11
|
+
Snippet: typeof Snippet;
|
|
12
|
+
ReverseSnippet: typeof ReverseSnippet;
|
|
13
|
+
};
|
|
14
|
+
sendEvent?: SendEventForHits;
|
|
15
|
+
};
|
|
16
|
+
export declare type TemplateWithBindEvent<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string);
|
|
4
17
|
export declare type Templates = {
|
|
5
18
|
[key: string]: Template<any> | TemplateWithBindEvent<any> | undefined;
|
|
6
19
|
};
|
|
@@ -19,7 +19,9 @@ export declare type ClearRefinementsTemplates = Partial<{
|
|
|
19
19
|
/**
|
|
20
20
|
* Template for the content of the button
|
|
21
21
|
*/
|
|
22
|
-
resetLabel: Template
|
|
22
|
+
resetLabel: Template<{
|
|
23
|
+
hasRefinements: boolean;
|
|
24
|
+
}>;
|
|
23
25
|
}>;
|
|
24
26
|
export declare type ClearRefinementsWidgetParams = {
|
|
25
27
|
/**
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="google.maps" />
|
|
2
|
+
import type { renderTemplate } from '../../lib/utils';
|
|
2
3
|
export declare type HTMLMarkerArguments = {
|
|
3
4
|
__id: string;
|
|
4
5
|
position: google.maps.LatLngLiteral;
|
|
5
6
|
map: google.maps.Map;
|
|
6
|
-
template:
|
|
7
|
+
template: ReturnType<typeof renderTemplate>;
|
|
7
8
|
title?: string;
|
|
8
9
|
className: string;
|
|
9
10
|
anchor?: {
|
|
@@ -23,6 +23,8 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
23
23
|
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; }
|
|
24
24
|
|
|
25
25
|
/* global google EventListener */
|
|
26
|
+
import { render } from 'preact';
|
|
27
|
+
|
|
26
28
|
var createHTMLMarker = function createHTMLMarker(googleReference) {
|
|
27
29
|
var HTMLMarker = /*#__PURE__*/function (_googleReference$maps) {
|
|
28
30
|
_inherits(HTMLMarker, _googleReference$maps);
|
|
@@ -66,7 +68,12 @@ var createHTMLMarker = function createHTMLMarker(googleReference) {
|
|
|
66
68
|
_this.element = document.createElement('div');
|
|
67
69
|
_this.element.className = className;
|
|
68
70
|
_this.element.style.position = 'absolute';
|
|
69
|
-
|
|
71
|
+
|
|
72
|
+
if (_typeof(template) === 'object') {
|
|
73
|
+
render(template, _this.element);
|
|
74
|
+
} else {
|
|
75
|
+
_this.element.innerHTML = template;
|
|
76
|
+
}
|
|
70
77
|
|
|
71
78
|
_this.setMap(map);
|
|
72
79
|
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
/** @jsx h */
|
|
2
|
+
import { h } from 'preact';
|
|
3
|
+
|
|
4
|
+
var _ref = h("p", null, "Your custom HTML Marker");
|
|
5
|
+
|
|
1
6
|
var defaultTemplates = {
|
|
2
|
-
HTMLMarker:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
HTMLMarker: function HTMLMarker() {
|
|
8
|
+
return _ref;
|
|
9
|
+
},
|
|
10
|
+
reset: function reset() {
|
|
11
|
+
return 'Clear the map refinement';
|
|
12
|
+
},
|
|
13
|
+
toggle: function toggle() {
|
|
14
|
+
return 'Search as I move the map';
|
|
15
|
+
},
|
|
16
|
+
redo: function redo() {
|
|
17
|
+
return 'Redo search here';
|
|
18
|
+
}
|
|
6
19
|
};
|
|
7
20
|
export default defaultTemplates;
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
+
/** @jsx h */
|
|
2
|
+
import { h } from 'preact';
|
|
3
|
+
import { formatNumber } from "../../lib/formatNumber.js";
|
|
4
|
+
import { cx } from "../../lib/utils/index.js";
|
|
1
5
|
var defaultTemplates = {
|
|
2
|
-
item:
|
|
3
|
-
|
|
6
|
+
item: function item(_ref) {
|
|
7
|
+
var url = _ref.url,
|
|
8
|
+
label = _ref.label,
|
|
9
|
+
count = _ref.count,
|
|
10
|
+
cssClasses = _ref.cssClasses;
|
|
11
|
+
return h("a", {
|
|
12
|
+
className: cx(cssClasses.link),
|
|
13
|
+
href: url
|
|
14
|
+
}, h("span", {
|
|
15
|
+
className: cx(cssClasses.label)
|
|
16
|
+
}, label), h("span", {
|
|
17
|
+
className: cx(cssClasses.count)
|
|
18
|
+
}, formatNumber(count)));
|
|
19
|
+
},
|
|
20
|
+
showMoreText: function showMoreText(_ref2) {
|
|
21
|
+
var isShowingMore = _ref2.isShowingMore;
|
|
22
|
+
return isShowingMore ? 'Show less' : 'Show more';
|
|
23
|
+
}
|
|
4
24
|
};
|
|
5
25
|
export default defaultTemplates;
|
|
@@ -10,6 +10,8 @@ declare type HierarchicalMenuTemplates = Partial<{
|
|
|
10
10
|
count: number;
|
|
11
11
|
isRefined: boolean;
|
|
12
12
|
url: string;
|
|
13
|
+
label: string;
|
|
14
|
+
cssClasses: HierarchicalMenuCSSClasses;
|
|
13
15
|
}>;
|
|
14
16
|
/**
|
|
15
17
|
* Template used for the show more text, provided with `isShowingMore` data property.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @jsx h */
|
|
2
2
|
import type { HitsConnectorParams, HitsWidgetDescription } from '../../connectors/hits/connectHits';
|
|
3
3
|
import type { Template, TemplateWithBindEvent, Hit, WidgetFactory } from '../../types';
|
|
4
|
+
import type { SearchResults } from 'algoliasearch-helper';
|
|
4
5
|
export declare type HitsCSSClasses = Partial<{
|
|
5
6
|
/**
|
|
6
7
|
* CSS class to add to the wrapping element.
|
|
@@ -25,7 +26,7 @@ export declare type HitsTemplates = Partial<{
|
|
|
25
26
|
*
|
|
26
27
|
* @default 'No Results'
|
|
27
28
|
*/
|
|
28
|
-
empty: Template
|
|
29
|
+
empty: Template<SearchResults>;
|
|
29
30
|
/**
|
|
30
31
|
* Template to use for each result. This template will receive an object containing a single record.
|
|
31
32
|
*
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
var defaultTemplates = {
|
|
2
|
-
empty:
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
empty: function empty() {
|
|
3
|
+
return 'No results';
|
|
4
|
+
},
|
|
5
|
+
showPreviousText: function showPreviousText() {
|
|
6
|
+
return 'Show previous results';
|
|
7
|
+
},
|
|
8
|
+
showMoreText: function showMoreText() {
|
|
9
|
+
return 'Show more results';
|
|
10
|
+
},
|
|
5
11
|
item: function item(data) {
|
|
6
12
|
return JSON.stringify(data, null, 2);
|
|
7
13
|
}
|
|
@@ -40,9 +40,7 @@ export declare type InfiniteHitsTemplates = Partial<{
|
|
|
40
40
|
/**
|
|
41
41
|
* The template to use when there are no results.
|
|
42
42
|
*/
|
|
43
|
-
empty: Template<
|
|
44
|
-
results: SearchResults;
|
|
45
|
-
}>;
|
|
43
|
+
empty: Template<SearchResults>;
|
|
46
44
|
/**
|
|
47
45
|
* The template to use for the “Show previous” label.
|
|
48
46
|
*/
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
+
/** @jsx h */
|
|
2
|
+
import { h } from 'preact';
|
|
3
|
+
import { formatNumber } from "../../lib/formatNumber.js";
|
|
4
|
+
import { cx } from "../../lib/utils/index.js";
|
|
1
5
|
var defaultTemplates = {
|
|
2
|
-
item:
|
|
3
|
-
|
|
6
|
+
item: function item(_ref) {
|
|
7
|
+
var cssClasses = _ref.cssClasses,
|
|
8
|
+
url = _ref.url,
|
|
9
|
+
label = _ref.label,
|
|
10
|
+
count = _ref.count;
|
|
11
|
+
return h("a", {
|
|
12
|
+
className: cx(cssClasses.link),
|
|
13
|
+
href: url
|
|
14
|
+
}, h("span", {
|
|
15
|
+
className: cx(cssClasses.label)
|
|
16
|
+
}, label), h("span", {
|
|
17
|
+
className: cx(cssClasses.count)
|
|
18
|
+
}, formatNumber(count)));
|
|
19
|
+
},
|
|
20
|
+
showMoreText: function showMoreText(_ref2) {
|
|
21
|
+
var isShowingMore = _ref2.isShowingMore;
|
|
22
|
+
return isShowingMore ? 'Show less' : 'Show more';
|
|
23
|
+
}
|
|
4
24
|
};
|
|
5
25
|
export default defaultTemplates;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { formatNumber } from "../../lib/formatNumber.js";
|
|
1
2
|
var defaultTemplates = {
|
|
2
|
-
item:
|
|
3
|
-
|
|
3
|
+
item: function item(_ref) {
|
|
4
|
+
var label = _ref.label,
|
|
5
|
+
count = _ref.count;
|
|
6
|
+
return "".concat(label, " (").concat(formatNumber(count), ")");
|
|
7
|
+
},
|
|
8
|
+
defaultOption: function defaultOption() {
|
|
9
|
+
return 'See all';
|
|
10
|
+
}
|
|
4
11
|
};
|
|
5
12
|
export default defaultTemplates;
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
+
/** @jsx h */
|
|
2
|
+
import { h } from 'preact';
|
|
1
3
|
var defaultTemplates = {
|
|
2
|
-
item:
|
|
4
|
+
item: function item(_ref) {
|
|
5
|
+
var cssClasses = _ref.cssClasses,
|
|
6
|
+
attribute = _ref.attribute,
|
|
7
|
+
label = _ref.label,
|
|
8
|
+
isRefined = _ref.isRefined;
|
|
9
|
+
return h("label", {
|
|
10
|
+
className: cssClasses.label
|
|
11
|
+
}, h("input", {
|
|
12
|
+
type: "radio",
|
|
13
|
+
className: cssClasses.radio,
|
|
14
|
+
name: attribute,
|
|
15
|
+
defaultChecked: isRefined
|
|
16
|
+
}), h("span", {
|
|
17
|
+
className: cssClasses.labelText
|
|
18
|
+
}, label));
|
|
19
|
+
}
|
|
3
20
|
};
|
|
4
21
|
export default defaultTemplates;
|
|
@@ -28,8 +28,12 @@ var withUsage = createDocumentationMessageGenerator({
|
|
|
28
28
|
});
|
|
29
29
|
var suit = component('RangeInput');
|
|
30
30
|
var defaultTemplates = {
|
|
31
|
-
separatorText:
|
|
32
|
-
|
|
31
|
+
separatorText: function separatorText() {
|
|
32
|
+
return 'to';
|
|
33
|
+
},
|
|
34
|
+
submitText: function submitText() {
|
|
35
|
+
return 'Go';
|
|
36
|
+
}
|
|
33
37
|
};
|
|
34
38
|
|
|
35
39
|
var renderer = function renderer(_ref) {
|
|
@@ -1,4 +1,57 @@
|
|
|
1
|
+
/** @jsx h */
|
|
2
|
+
import { h } from 'preact';
|
|
3
|
+
import { formatNumber } from "../../lib/formatNumber.js";
|
|
4
|
+
import { cx } from "../../lib/utils/index.js";
|
|
5
|
+
|
|
6
|
+
function ItemWrapper(_ref) {
|
|
7
|
+
var children = _ref.children,
|
|
8
|
+
count = _ref.count,
|
|
9
|
+
value = _ref.value,
|
|
10
|
+
url = _ref.url,
|
|
11
|
+
cssClasses = _ref.cssClasses;
|
|
12
|
+
|
|
13
|
+
if (count) {
|
|
14
|
+
return h("a", {
|
|
15
|
+
className: cx(cssClasses.link),
|
|
16
|
+
"aria-label": "".concat(value, " & up"),
|
|
17
|
+
href: url
|
|
18
|
+
}, children);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return h("div", {
|
|
22
|
+
className: cx(cssClasses.link),
|
|
23
|
+
"aria-label": "".concat(value, " & up"),
|
|
24
|
+
disabled: true
|
|
25
|
+
}, children);
|
|
26
|
+
}
|
|
27
|
+
|
|
1
28
|
var defaultTemplates = {
|
|
2
|
-
item:
|
|
29
|
+
item: function item(_ref2) {
|
|
30
|
+
var count = _ref2.count,
|
|
31
|
+
value = _ref2.value,
|
|
32
|
+
url = _ref2.url,
|
|
33
|
+
stars = _ref2.stars,
|
|
34
|
+
cssClasses = _ref2.cssClasses;
|
|
35
|
+
return h(ItemWrapper, {
|
|
36
|
+
count: count,
|
|
37
|
+
value: value,
|
|
38
|
+
url: url,
|
|
39
|
+
cssClasses: cssClasses
|
|
40
|
+
}, stars.map(function (isFull, index) {
|
|
41
|
+
return h("svg", {
|
|
42
|
+
key: index,
|
|
43
|
+
className: cx([cx(cssClasses.starIcon), cx(isFull ? cssClasses.fullStarIcon : cssClasses.emptyStarIcon)]),
|
|
44
|
+
"aria-hidden": "true",
|
|
45
|
+
width: "24",
|
|
46
|
+
height: "24"
|
|
47
|
+
}, h("use", {
|
|
48
|
+
xlinkHref: isFull ? '#ais-RatingMenu-starSymbol' : '#ais-RatingMenu-starEmptySymbol'
|
|
49
|
+
}));
|
|
50
|
+
}), h("span", {
|
|
51
|
+
className: cx(cssClasses.label)
|
|
52
|
+
}, "& Up"), count && h("span", {
|
|
53
|
+
className: cx(cssClasses.count)
|
|
54
|
+
}, formatNumber(count)));
|
|
55
|
+
}
|
|
3
56
|
};
|
|
4
57
|
export default defaultTemplates;
|
|
@@ -7,9 +7,15 @@ export declare type RatingMenuTemplates = Partial<{
|
|
|
7
7
|
*/
|
|
8
8
|
item: Template<{
|
|
9
9
|
name: string;
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
10
12
|
count: number;
|
|
11
13
|
isRefined: boolean;
|
|
12
14
|
url: string;
|
|
15
|
+
stars: [boolean, boolean, boolean, boolean, boolean];
|
|
16
|
+
cssClasses: RatingMenuCSSClasses;
|
|
17
|
+
attribute?: string;
|
|
18
|
+
isFromSearch?: boolean;
|
|
13
19
|
}>;
|
|
14
20
|
}>;
|
|
15
21
|
export declare type RatingMenuCSSClasses = Partial<{
|