instantsearch.js 4.54.0 → 4.54.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 +35 -17
- package/cjs/components/Template/Template.js +6 -3
- package/cjs/helpers/highlight.js +5 -0
- package/cjs/helpers/reverseHighlight.js +5 -0
- package/cjs/helpers/reverseSnippet.js +5 -0
- package/cjs/helpers/snippet.js +5 -0
- package/cjs/lib/server.js +60 -0
- package/cjs/lib/utils/index.js +11 -0
- package/cjs/lib/utils/walkIndex.js +18 -0
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/pagination/pagination.js +51 -39
- package/cjs/widgets/panel/panel.js +0 -2
- package/dist/instantsearch.development.d.ts +27 -4
- package/dist/instantsearch.development.js +112 -63
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +27 -4
- package/dist/instantsearch.production.min.d.ts +27 -4
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Pagination/Pagination.js +34 -17
- package/es/components/Panel/Panel.d.ts +1 -1
- package/es/components/Template/Template.js +6 -3
- package/es/helpers/highlight.d.ts +3 -0
- package/es/helpers/highlight.js +5 -0
- package/es/helpers/reverseHighlight.d.ts +3 -0
- package/es/helpers/reverseHighlight.js +5 -0
- package/es/helpers/reverseSnippet.d.ts +3 -0
- package/es/helpers/reverseSnippet.js +5 -0
- package/es/helpers/snippet.d.ts +3 -0
- package/es/helpers/snippet.js +5 -0
- package/es/lib/server.d.ts +10 -0
- package/es/lib/server.js +53 -0
- package/es/lib/utils/index.d.ts +1 -0
- package/es/lib/utils/index.js +1 -0
- package/es/lib/utils/walkIndex.d.ts +5 -0
- package/es/lib/utils/walkIndex.js +12 -0
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/widgets/pagination/pagination.d.ts +12 -5
- package/es/widgets/pagination/pagination.js +51 -39
- package/es/widgets/panel/panel.js +0 -2
- package/package.json +5 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cx } from '@algolia/ui-components-shared';
|
|
2
2
|
import { h } from 'preact';
|
|
3
3
|
import { isSpecialClick } from "../../lib/utils/index.js";
|
|
4
|
+
import Template from "../Template/Template.js";
|
|
4
5
|
function Pagination(props) {
|
|
5
6
|
function createClickHandler(pageNumber) {
|
|
6
7
|
return function (event) {
|
|
@@ -21,7 +22,8 @@ function Pagination(props) {
|
|
|
21
22
|
ariaLabel: "First",
|
|
22
23
|
className: props.cssClasses.firstPageItem,
|
|
23
24
|
isDisabled: props.isFirstPage,
|
|
24
|
-
|
|
25
|
+
templates: props.templates,
|
|
26
|
+
templateKey: "first",
|
|
25
27
|
pageNumber: 0,
|
|
26
28
|
createURL: props.createURL,
|
|
27
29
|
cssClasses: props.cssClasses,
|
|
@@ -30,7 +32,8 @@ function Pagination(props) {
|
|
|
30
32
|
ariaLabel: "Previous",
|
|
31
33
|
className: props.cssClasses.previousPageItem,
|
|
32
34
|
isDisabled: props.isFirstPage,
|
|
33
|
-
|
|
35
|
+
templates: props.templates,
|
|
36
|
+
templateKey: "previous",
|
|
34
37
|
pageNumber: props.currentPage - 1,
|
|
35
38
|
createURL: props.createURL,
|
|
36
39
|
cssClasses: props.cssClasses,
|
|
@@ -41,7 +44,8 @@ function Pagination(props) {
|
|
|
41
44
|
ariaLabel: "Page ".concat(pageNumber + 1),
|
|
42
45
|
className: props.cssClasses.pageItem,
|
|
43
46
|
isSelected: pageNumber === props.currentPage,
|
|
44
|
-
|
|
47
|
+
templates: props.templates,
|
|
48
|
+
templateKey: "page",
|
|
45
49
|
pageNumber: pageNumber,
|
|
46
50
|
createURL: props.createURL,
|
|
47
51
|
cssClasses: props.cssClasses,
|
|
@@ -51,7 +55,8 @@ function Pagination(props) {
|
|
|
51
55
|
ariaLabel: "Next",
|
|
52
56
|
className: props.cssClasses.nextPageItem,
|
|
53
57
|
isDisabled: props.isLastPage,
|
|
54
|
-
|
|
58
|
+
templates: props.templates,
|
|
59
|
+
templateKey: "next",
|
|
55
60
|
pageNumber: props.currentPage + 1,
|
|
56
61
|
createURL: props.createURL,
|
|
57
62
|
cssClasses: props.cssClasses,
|
|
@@ -60,7 +65,8 @@ function Pagination(props) {
|
|
|
60
65
|
ariaLabel: "Last",
|
|
61
66
|
className: props.cssClasses.lastPageItem,
|
|
62
67
|
isDisabled: props.isLastPage,
|
|
63
|
-
|
|
68
|
+
templates: props.templates,
|
|
69
|
+
templateKey: "last",
|
|
64
70
|
pageNumber: props.nbPages - 1,
|
|
65
71
|
createURL: props.createURL,
|
|
66
72
|
cssClasses: props.cssClasses,
|
|
@@ -68,7 +74,8 @@ function Pagination(props) {
|
|
|
68
74
|
})));
|
|
69
75
|
}
|
|
70
76
|
function PaginationLink(_ref) {
|
|
71
|
-
var
|
|
77
|
+
var templates = _ref.templates,
|
|
78
|
+
templateKey = _ref.templateKey,
|
|
72
79
|
ariaLabel = _ref.ariaLabel,
|
|
73
80
|
pageNumber = _ref.pageNumber,
|
|
74
81
|
className = _ref.className,
|
|
@@ -81,18 +88,28 @@ function PaginationLink(_ref) {
|
|
|
81
88
|
createClickHandler = _ref.createClickHandler;
|
|
82
89
|
return h("li", {
|
|
83
90
|
className: cx(cssClasses.item, className, isDisabled && cssClasses.disabledItem, isSelected && cssClasses.selectedItem)
|
|
84
|
-
}, isDisabled ? h(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
}, isDisabled ? h(Template, {
|
|
92
|
+
rootTagName: "span",
|
|
93
|
+
rootProps: {
|
|
94
|
+
className: cssClasses.link
|
|
95
|
+
},
|
|
96
|
+
templateKey: templateKey,
|
|
97
|
+
templates: templates,
|
|
98
|
+
data: {
|
|
99
|
+
page: pageNumber + 1
|
|
88
100
|
}
|
|
89
|
-
}) : h(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
}) : h(Template, {
|
|
102
|
+
rootTagName: "a",
|
|
103
|
+
rootProps: {
|
|
104
|
+
className: cssClasses.link,
|
|
105
|
+
'aria-label': ariaLabel,
|
|
106
|
+
href: createURL(pageNumber),
|
|
107
|
+
onClick: createClickHandler(pageNumber)
|
|
108
|
+
},
|
|
109
|
+
templateKey: templateKey,
|
|
110
|
+
templates: templates,
|
|
111
|
+
data: {
|
|
112
|
+
page: pageNumber + 1
|
|
96
113
|
}
|
|
97
114
|
}));
|
|
98
115
|
}
|
|
@@ -3,7 +3,7 @@ import { h } from 'preact';
|
|
|
3
3
|
import type { ComponentCSSClasses, UnknownWidgetFactory } from '../../types';
|
|
4
4
|
import type { PanelCSSClasses, PanelSharedOptions, PanelTemplates } from '../../widgets/panel/panel';
|
|
5
5
|
export type PanelComponentCSSClasses = ComponentCSSClasses<Omit<PanelCSSClasses, 'collapseIcon'>>;
|
|
6
|
-
export type PanelComponentTemplates<TWidget extends UnknownWidgetFactory> =
|
|
6
|
+
export type PanelComponentTemplates<TWidget extends UnknownWidgetFactory> = PanelTemplates<TWidget>;
|
|
7
7
|
export type PanelProps<TWidget extends UnknownWidgetFactory> = {
|
|
8
8
|
hidden: boolean;
|
|
9
9
|
collapsible: boolean;
|
|
@@ -40,9 +40,12 @@ var Template = /*#__PURE__*/function (_Component) {
|
|
|
40
40
|
key: "render",
|
|
41
41
|
value: function render() {
|
|
42
42
|
var _this = this;
|
|
43
|
-
process.env.NODE_ENV === 'development'
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (process.env.NODE_ENV === 'development') {
|
|
44
|
+
var nonFunctionTemplates = Object.keys(this.props.templates).filter(function (key) {
|
|
45
|
+
return typeof _this.props.templates[key] !== 'function';
|
|
46
|
+
});
|
|
47
|
+
process.env.NODE_ENV === 'development' ? warning(nonFunctionTemplates.length === 0, "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\nString-based templates: ".concat(nonFunctionTemplates.join(', '), ".\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/#upgrade-templates")) : void 0;
|
|
48
|
+
}
|
|
46
49
|
var RootTagName = this.props.rootTagName;
|
|
47
50
|
var useCustomCompileOptions = this.props.useCustomCompileOptions[this.props.templateKey];
|
|
48
51
|
var compileOptions = useCustomCompileOptions ? this.props.templatesConfig.compileOptions : {};
|
|
@@ -7,4 +7,7 @@ export type HighlightOptions = {
|
|
|
7
7
|
highlighted: string;
|
|
8
8
|
}>;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use html tagged templates and the Highlight component instead
|
|
12
|
+
*/
|
|
10
13
|
export default function highlight({ attribute, highlightedTagName, hit, cssClasses, }: HighlightOptions): string;
|
package/es/helpers/highlight.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { component } from "../lib/suit.js";
|
|
2
2
|
import { getPropertyByPath, TAG_REPLACEMENT, warning } from "../lib/utils/index.js";
|
|
3
3
|
var suit = component('Highlight');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use html tagged templates and the Highlight component instead
|
|
7
|
+
*/
|
|
4
8
|
export default function highlight(_ref) {
|
|
5
9
|
var attribute = _ref.attribute,
|
|
6
10
|
_ref$highlightedTagNa = _ref.highlightedTagName,
|
|
@@ -8,6 +12,7 @@ export default function highlight(_ref) {
|
|
|
8
12
|
hit = _ref.hit,
|
|
9
13
|
_ref$cssClasses = _ref.cssClasses,
|
|
10
14
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
15
|
+
process.env.NODE_ENV === 'development' ? warning(false, "`instantsearch.highlight` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `Highlight` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") : void 0;
|
|
11
16
|
var highlightAttributeResult = getPropertyByPath(hit._highlightResult, attribute);
|
|
12
17
|
|
|
13
18
|
// @MAJOR fallback to attribute value if highlight is not found
|
|
@@ -7,4 +7,7 @@ export type ReverseHighlightOptions = {
|
|
|
7
7
|
highlighted: string;
|
|
8
8
|
}>;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use html tagged templates and the ReverseHighlight component instead
|
|
12
|
+
*/
|
|
10
13
|
export default function reverseHighlight({ attribute, highlightedTagName, hit, cssClasses, }: ReverseHighlightOptions): string;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { component } from "../lib/suit.js";
|
|
2
2
|
import { TAG_REPLACEMENT, getPropertyByPath, getHighlightedParts, reverseHighlightedParts, concatHighlightedParts, warning } from "../lib/utils/index.js";
|
|
3
3
|
var suit = component('ReverseHighlight');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use html tagged templates and the ReverseHighlight component instead
|
|
7
|
+
*/
|
|
4
8
|
export default function reverseHighlight(_ref) {
|
|
5
9
|
var attribute = _ref.attribute,
|
|
6
10
|
_ref$highlightedTagNa = _ref.highlightedTagName,
|
|
@@ -8,6 +12,7 @@ export default function reverseHighlight(_ref) {
|
|
|
8
12
|
hit = _ref.hit,
|
|
9
13
|
_ref$cssClasses = _ref.cssClasses,
|
|
10
14
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
15
|
+
process.env.NODE_ENV === 'development' ? warning(false, "`instantsearch.reverseHighlight` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `ReverseHighlight` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") : void 0;
|
|
11
16
|
var highlightAttributeResult = getPropertyByPath(hit._highlightResult, attribute);
|
|
12
17
|
|
|
13
18
|
// @MAJOR fallback to attribute value if highlight is not found
|
|
@@ -7,4 +7,7 @@ export type ReverseSnippetOptions = {
|
|
|
7
7
|
highlighted: string;
|
|
8
8
|
}>;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use html tagged templates and the ReverseSnippet component instead
|
|
12
|
+
*/
|
|
10
13
|
export default function reverseSnippet({ attribute, highlightedTagName, hit, cssClasses, }: ReverseSnippetOptions): string;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { component } from "../lib/suit.js";
|
|
2
2
|
import { TAG_REPLACEMENT, getPropertyByPath, getHighlightedParts, reverseHighlightedParts, concatHighlightedParts, warning } from "../lib/utils/index.js";
|
|
3
3
|
var suit = component('ReverseSnippet');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use html tagged templates and the ReverseSnippet component instead
|
|
7
|
+
*/
|
|
4
8
|
export default function reverseSnippet(_ref) {
|
|
5
9
|
var attribute = _ref.attribute,
|
|
6
10
|
_ref$highlightedTagNa = _ref.highlightedTagName,
|
|
@@ -8,6 +12,7 @@ export default function reverseSnippet(_ref) {
|
|
|
8
12
|
hit = _ref.hit,
|
|
9
13
|
_ref$cssClasses = _ref.cssClasses,
|
|
10
14
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
15
|
+
process.env.NODE_ENV === 'development' ? warning(false, "`instantsearch.reverseSnippet` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `ReverseSnippet` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") : void 0;
|
|
11
16
|
var snippetAttributeResult = getPropertyByPath(hit._snippetResult, attribute);
|
|
12
17
|
|
|
13
18
|
// @MAJOR fallback to attribute value if snippet is not found
|
package/es/helpers/snippet.d.ts
CHANGED
package/es/helpers/snippet.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { component } from "../lib/suit.js";
|
|
2
2
|
import { TAG_REPLACEMENT, getPropertyByPath, warning } from "../lib/utils/index.js";
|
|
3
3
|
var suit = component('Snippet');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use html tagged templates and the Snippet component instead
|
|
7
|
+
*/
|
|
4
8
|
export default function snippet(_ref) {
|
|
5
9
|
var attribute = _ref.attribute,
|
|
6
10
|
_ref$highlightedTagNa = _ref.highlightedTagName,
|
|
@@ -8,6 +12,7 @@ export default function snippet(_ref) {
|
|
|
8
12
|
hit = _ref.hit,
|
|
9
13
|
_ref$cssClasses = _ref.cssClasses,
|
|
10
14
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
15
|
+
process.env.NODE_ENV === 'development' ? warning(false, "`instantsearch.snippet` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `Snippet` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") : void 0;
|
|
11
16
|
var snippetAttributeResult = getPropertyByPath(hit._snippetResult, attribute);
|
|
12
17
|
|
|
13
18
|
// @MAJOR fallback to attribute value if snippet is not found
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IndexWidget, InitialResults, InstantSearch } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Waits for the results from the search instance to coordinate the next steps
|
|
4
|
+
* in `getServerState()`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function waitForResults(search: InstantSearch): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Walks the InstantSearch root index to construct the initial results.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getInitialResults(rootIndex: IndexWidget): InitialResults;
|
package/es/lib/server.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import { walkIndex } from "./utils/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* Waits for the results from the search instance to coordinate the next steps
|
|
10
|
+
* in `getServerState()`.
|
|
11
|
+
*/
|
|
12
|
+
export function waitForResults(search) {
|
|
13
|
+
var helper = search.mainHelper;
|
|
14
|
+
helper.searchOnlyWithDerivedHelpers();
|
|
15
|
+
return new Promise(function (resolve, reject) {
|
|
16
|
+
// All derived helpers resolve in the same tick so we're safe only relying
|
|
17
|
+
// on the first one.
|
|
18
|
+
helper.derivedHelpers[0].on('result', function () {
|
|
19
|
+
resolve();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// However, we listen to errors that can happen on any derived helper because
|
|
23
|
+
// any error is critical.
|
|
24
|
+
helper.on('error', function (error) {
|
|
25
|
+
reject(error);
|
|
26
|
+
});
|
|
27
|
+
search.on('error', function (error) {
|
|
28
|
+
reject(error);
|
|
29
|
+
});
|
|
30
|
+
helper.derivedHelpers.forEach(function (derivedHelper) {
|
|
31
|
+
return derivedHelper.on('error', function (error) {
|
|
32
|
+
reject(error);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Walks the InstantSearch root index to construct the initial results.
|
|
40
|
+
*/
|
|
41
|
+
export function getInitialResults(rootIndex) {
|
|
42
|
+
var initialResults = {};
|
|
43
|
+
walkIndex(rootIndex, function (widget) {
|
|
44
|
+
var searchResults = widget.getResults();
|
|
45
|
+
initialResults[widget.getIndexId()] = {
|
|
46
|
+
// We convert the Helper state to a plain object to pass parsable data
|
|
47
|
+
// structures from server to client.
|
|
48
|
+
state: _objectSpread({}, searchResults._state),
|
|
49
|
+
results: searchResults._rawResults
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
return initialResults;
|
|
53
|
+
}
|
package/es/lib/utils/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export * from './isFacetRefined';
|
|
|
33
33
|
export * from './isFiniteNumber';
|
|
34
34
|
export * from './isPlainObject';
|
|
35
35
|
export * from './isSpecialClick';
|
|
36
|
+
export * from './walkIndex';
|
|
36
37
|
export * from './logger';
|
|
37
38
|
export * from './mergeSearchParameters';
|
|
38
39
|
export * from './omit';
|
package/es/lib/utils/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export * from "./isFacetRefined.js";
|
|
|
33
33
|
export * from "./isFiniteNumber.js";
|
|
34
34
|
export * from "./isPlainObject.js";
|
|
35
35
|
export * from "./isSpecialClick.js";
|
|
36
|
+
export * from "./walkIndex.js";
|
|
36
37
|
export * from "./logger.js";
|
|
37
38
|
export * from "./mergeSearchParameters.js";
|
|
38
39
|
export * from "./omit.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isIndexWidget } from "./isIndexWidget.js";
|
|
2
|
+
/**
|
|
3
|
+
* Recurse over all child indices
|
|
4
|
+
*/
|
|
5
|
+
export function walkIndex(indexWidget, callback) {
|
|
6
|
+
callback(indexWidget);
|
|
7
|
+
indexWidget.getWidgets().forEach(function (widget) {
|
|
8
|
+
if (isIndexWidget(widget)) {
|
|
9
|
+
walkIndex(widget, callback);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.54.
|
|
1
|
+
declare const _default: "4.54.1";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.54.
|
|
1
|
+
export default '4.54.1';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import type { PaginationConnectorParams, PaginationWidgetDescription } from '../../connectors/pagination/connectPagination';
|
|
3
|
-
import type { WidgetFactory } from '../../types';
|
|
3
|
+
import type { Template, WidgetFactory } from '../../types';
|
|
4
4
|
export type PaginationCSSClasses = Partial<{
|
|
5
5
|
/**
|
|
6
6
|
* CSS classes added to the root element of the widget.
|
|
@@ -55,19 +55,26 @@ export type PaginationTemplates = Partial<{
|
|
|
55
55
|
/**
|
|
56
56
|
* Label for the Previous link.
|
|
57
57
|
*/
|
|
58
|
-
previous:
|
|
58
|
+
previous: Template;
|
|
59
59
|
/**
|
|
60
60
|
* Label for the Next link.
|
|
61
61
|
*/
|
|
62
|
-
next:
|
|
62
|
+
next: Template;
|
|
63
|
+
/**
|
|
64
|
+
* Label for the link of a certain page
|
|
65
|
+
* Page is one-based, so `page` will be `1` for the first page.
|
|
66
|
+
*/
|
|
67
|
+
page: Template<{
|
|
68
|
+
page: number;
|
|
69
|
+
}>;
|
|
63
70
|
/**
|
|
64
71
|
* Label for the First link.
|
|
65
72
|
*/
|
|
66
|
-
first:
|
|
73
|
+
first: Template;
|
|
67
74
|
/**
|
|
68
75
|
* Label for the Last link.
|
|
69
76
|
*/
|
|
70
|
-
last:
|
|
77
|
+
last: Template;
|
|
71
78
|
}>;
|
|
72
79
|
export type PaginationWidgetParams = {
|
|
73
80
|
/**
|
|
@@ -15,28 +15,40 @@ var withUsage = createDocumentationMessageGenerator({
|
|
|
15
15
|
name: 'pagination'
|
|
16
16
|
});
|
|
17
17
|
var defaultTemplates = {
|
|
18
|
-
previous:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
previous: function previous() {
|
|
19
|
+
return '‹';
|
|
20
|
+
},
|
|
21
|
+
next: function next() {
|
|
22
|
+
return '›';
|
|
23
|
+
},
|
|
24
|
+
page: function page(_ref) {
|
|
25
|
+
var _page = _ref.page;
|
|
26
|
+
return "".concat(_page);
|
|
27
|
+
},
|
|
28
|
+
first: function first() {
|
|
29
|
+
return '«';
|
|
30
|
+
},
|
|
31
|
+
last: function last() {
|
|
32
|
+
return '»';
|
|
33
|
+
}
|
|
22
34
|
};
|
|
23
|
-
var renderer = function renderer(
|
|
24
|
-
var containerNode =
|
|
25
|
-
cssClasses =
|
|
26
|
-
templates =
|
|
27
|
-
showFirst =
|
|
28
|
-
showLast =
|
|
29
|
-
showPrevious =
|
|
30
|
-
showNext =
|
|
31
|
-
scrollToNode =
|
|
32
|
-
return function (
|
|
33
|
-
var createURL =
|
|
34
|
-
currentRefinement =
|
|
35
|
-
nbPages =
|
|
36
|
-
pages =
|
|
37
|
-
isFirstPage =
|
|
38
|
-
isLastPage =
|
|
39
|
-
refine =
|
|
35
|
+
var renderer = function renderer(_ref2) {
|
|
36
|
+
var containerNode = _ref2.containerNode,
|
|
37
|
+
cssClasses = _ref2.cssClasses,
|
|
38
|
+
templates = _ref2.templates,
|
|
39
|
+
showFirst = _ref2.showFirst,
|
|
40
|
+
showLast = _ref2.showLast,
|
|
41
|
+
showPrevious = _ref2.showPrevious,
|
|
42
|
+
showNext = _ref2.showNext,
|
|
43
|
+
scrollToNode = _ref2.scrollToNode;
|
|
44
|
+
return function (_ref3, isFirstRendering) {
|
|
45
|
+
var createURL = _ref3.createURL,
|
|
46
|
+
currentRefinement = _ref3.currentRefinement,
|
|
47
|
+
nbPages = _ref3.nbPages,
|
|
48
|
+
pages = _ref3.pages,
|
|
49
|
+
isFirstPage = _ref3.isFirstPage,
|
|
50
|
+
isLastPage = _ref3.isLastPage,
|
|
51
|
+
refine = _ref3.refine;
|
|
40
52
|
if (isFirstRendering) return;
|
|
41
53
|
var setCurrentPage = function setCurrentPage(pageNumber) {
|
|
42
54
|
refine(pageNumber);
|
|
@@ -62,24 +74,24 @@ var renderer = function renderer(_ref) {
|
|
|
62
74
|
};
|
|
63
75
|
};
|
|
64
76
|
var pagination = function pagination(widgetParams) {
|
|
65
|
-
var
|
|
66
|
-
container =
|
|
67
|
-
|
|
68
|
-
userTemplates =
|
|
69
|
-
|
|
70
|
-
userCssClasses =
|
|
71
|
-
totalPages =
|
|
72
|
-
padding =
|
|
73
|
-
|
|
74
|
-
showFirst =
|
|
75
|
-
|
|
76
|
-
showLast =
|
|
77
|
-
|
|
78
|
-
showPrevious =
|
|
79
|
-
|
|
80
|
-
showNext =
|
|
81
|
-
|
|
82
|
-
userScrollTo =
|
|
77
|
+
var _ref4 = widgetParams || {},
|
|
78
|
+
container = _ref4.container,
|
|
79
|
+
_ref4$templates = _ref4.templates,
|
|
80
|
+
userTemplates = _ref4$templates === void 0 ? {} : _ref4$templates,
|
|
81
|
+
_ref4$cssClasses = _ref4.cssClasses,
|
|
82
|
+
userCssClasses = _ref4$cssClasses === void 0 ? {} : _ref4$cssClasses,
|
|
83
|
+
totalPages = _ref4.totalPages,
|
|
84
|
+
padding = _ref4.padding,
|
|
85
|
+
_ref4$showFirst = _ref4.showFirst,
|
|
86
|
+
showFirst = _ref4$showFirst === void 0 ? true : _ref4$showFirst,
|
|
87
|
+
_ref4$showLast = _ref4.showLast,
|
|
88
|
+
showLast = _ref4$showLast === void 0 ? true : _ref4$showLast,
|
|
89
|
+
_ref4$showPrevious = _ref4.showPrevious,
|
|
90
|
+
showPrevious = _ref4$showPrevious === void 0 ? true : _ref4$showPrevious,
|
|
91
|
+
_ref4$showNext = _ref4.showNext,
|
|
92
|
+
showNext = _ref4$showNext === void 0 ? true : _ref4$showNext,
|
|
93
|
+
_ref4$scrollTo = _ref4.scrollTo,
|
|
94
|
+
userScrollTo = _ref4$scrollTo === void 0 ? 'body' : _ref4$scrollTo;
|
|
83
95
|
if (!container) {
|
|
84
96
|
throw new Error(withUsage('The `container` option is required.'));
|
|
85
97
|
}
|
|
@@ -90,8 +90,6 @@ var panel = function panel(panelWidgetParams) {
|
|
|
90
90
|
}
|
|
91
91
|
var containerNode = getContainerNode(widgetParams.container);
|
|
92
92
|
var defaultTemplates = {
|
|
93
|
-
header: '',
|
|
94
|
-
footer: '',
|
|
95
93
|
collapseButtonText: function collapseButtonText(_ref4) {
|
|
96
94
|
var isCollapsed = _ref4.collapsed;
|
|
97
95
|
return "<svg\n class=\"".concat(cssClasses.collapseIcon, "\"\n style=\"width: 1em; height: 1em;\"\n viewBox=\"0 0 500 500\"\n >\n <path d=\"").concat(isCollapsed ? 'M100 250l300-150v300z' : 'M250 400l150-300H100z', "\" fill=\"currentColor\" />\n </svg>");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.54.
|
|
3
|
+
"version": "4.54.1",
|
|
4
4
|
"description": "InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia.",
|
|
5
5
|
"homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"version": "./scripts/version/update-version.js"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@instantsearch/mocks": "1.
|
|
59
|
-
"@instantsearch/tests": "1.
|
|
60
|
-
"@instantsearch/testutils": "1.0.
|
|
58
|
+
"@instantsearch/mocks": "1.11.0",
|
|
59
|
+
"@instantsearch/tests": "1.11.0",
|
|
60
|
+
"@instantsearch/testutils": "1.0.14",
|
|
61
61
|
"@storybook/html": "5.3.9",
|
|
62
62
|
"@types/scriptjs": "0.0.2",
|
|
63
63
|
"algoliasearch": "4.14.3",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"scriptjs": "2.5.9",
|
|
66
66
|
"webpack": "4.41.5"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "1f81b61cf0e78aeb7022d5e9eca0d49de727dc64"
|
|
69
69
|
}
|