instantsearch.js 4.62.0 → 4.63.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/RefinementList/RefinementList.js +4 -4
- package/cjs/components/SearchBox/SearchBox.js +13 -7
- package/cjs/connectors/search-box/connectSearchBox.js +2 -2
- package/cjs/lib/routers/history.js +17 -4
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +16 -4
- package/dist/instantsearch.development.d.ts +11 -5
- package/dist/instantsearch.development.js +55 -24
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +11 -5
- package/dist/instantsearch.production.min.d.ts +11 -5
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/RefinementList/RefinementList.js +4 -4
- package/es/components/SearchBox/SearchBox.js +13 -7
- package/es/connectors/search-box/connectSearchBox.js +2 -2
- package/es/lib/routers/history.d.ts +10 -2
- package/es/lib/routers/history.js +18 -5
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.js +16 -4
- package/es/widgets/toggle-refinement/toggle-refinement.d.ts +2 -4
- package/package.json +10 -10
|
@@ -112,18 +112,18 @@ var RefinementList = /*#__PURE__*/function (_Component) {
|
|
|
112
112
|
// if one special key is down
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
var parent = originalEvent.target;
|
|
116
|
+
if (parent === null || parent.parentNode === null) {
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
|
-
if (isRefined &&
|
|
119
|
+
if (isRefined && parent.parentNode.querySelector('input[type="radio"]:checked')) {
|
|
119
120
|
// Prevent refinement for being reset if the user clicks on an already checked radio button
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
122
|
-
if (
|
|
123
|
+
if (parent.tagName === 'INPUT') {
|
|
123
124
|
_this.refine(facetValueToRefine);
|
|
124
125
|
return;
|
|
125
126
|
}
|
|
126
|
-
var parent = originalEvent.target;
|
|
127
127
|
while (parent !== originalEvent.currentTarget) {
|
|
128
128
|
if (parent.tagName === 'LABEL' && (parent.querySelector('input[type="checkbox"]') || parent.querySelector('input[type="radio"]'))) {
|
|
129
129
|
return;
|
|
@@ -51,13 +51,15 @@ var SearchBox = /*#__PURE__*/function (_Component) {
|
|
|
51
51
|
refine = _this$props.refine,
|
|
52
52
|
onChange = _this$props.onChange;
|
|
53
53
|
var query = event.target.value;
|
|
54
|
-
if (
|
|
55
|
-
|
|
54
|
+
if (event.type === 'compositionend' || !event.isComposing) {
|
|
55
|
+
if (searchAsYouType) {
|
|
56
|
+
refine(query);
|
|
57
|
+
}
|
|
58
|
+
_this.setState({
|
|
59
|
+
query: query
|
|
60
|
+
});
|
|
61
|
+
onChange(event);
|
|
56
62
|
}
|
|
57
|
-
_this.setState({
|
|
58
|
-
query: query
|
|
59
|
-
});
|
|
60
|
-
onChange(event);
|
|
61
63
|
});
|
|
62
64
|
_defineProperty(_assertThisInitialized(_this), "onSubmit", function (event) {
|
|
63
65
|
var _this$props2 = _this.props,
|
|
@@ -167,7 +169,11 @@ var SearchBox = /*#__PURE__*/function (_Component) {
|
|
|
167
169
|
,
|
|
168
170
|
spellCheck: "false",
|
|
169
171
|
maxLength: 512,
|
|
170
|
-
onInput: this.onInput
|
|
172
|
+
onInput: this.onInput
|
|
173
|
+
// see: https://github.com/preactjs/preact/issues/1978
|
|
174
|
+
// eslint-disable-next-line react/no-unknown-property
|
|
175
|
+
,
|
|
176
|
+
oncompositionend: this.onInput,
|
|
171
177
|
onBlur: this.onBlur,
|
|
172
178
|
onFocus: this.onFocus,
|
|
173
179
|
"aria-label": ariaLabel
|
|
@@ -64,7 +64,7 @@ var connectSearchBox = function connectSearchBox(renderFn) {
|
|
|
64
64
|
},
|
|
65
65
|
getWidgetRenderState: function getWidgetRenderState(_ref3) {
|
|
66
66
|
var helper = _ref3.helper,
|
|
67
|
-
|
|
67
|
+
instantSearchInstance = _ref3.instantSearchInstance,
|
|
68
68
|
state = _ref3.state;
|
|
69
69
|
if (!_refine) {
|
|
70
70
|
_refine = function _refine(query) {
|
|
@@ -81,7 +81,7 @@ var connectSearchBox = function connectSearchBox(renderFn) {
|
|
|
81
81
|
refine: _refine,
|
|
82
82
|
clear: _clear,
|
|
83
83
|
widgetParams: widgetParams,
|
|
84
|
-
isSearchStalled:
|
|
84
|
+
isSearchStalled: instantSearchInstance.status === 'stalled'
|
|
85
85
|
};
|
|
86
86
|
},
|
|
87
87
|
getWidgetUiState: function getWidgetUiState(uiState, _ref4) {
|
|
@@ -18,6 +18,13 @@ export type BrowserHistoryArgs<TRouteState> = {
|
|
|
18
18
|
start?: (onUpdate: () => void) => void;
|
|
19
19
|
dispose?: () => void;
|
|
20
20
|
push?: (url: string) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the URL should be cleaned up when the router is disposed.
|
|
23
|
+
* This can be useful when closing a modal containing InstantSearch, to
|
|
24
|
+
* remove active refinements from the URL.
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
cleanUrlOnDispose?: boolean;
|
|
21
28
|
};
|
|
22
29
|
declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
23
30
|
$$type: string;
|
|
@@ -68,11 +75,12 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
|
68
75
|
private _start?;
|
|
69
76
|
private _dispose?;
|
|
70
77
|
private _push?;
|
|
78
|
+
private _cleanUrlOnDispose;
|
|
71
79
|
/**
|
|
72
80
|
* Initializes a new storage provider that syncs the search state to the URL
|
|
73
81
|
* using web APIs (`window.location.pushState` and `onpopstate` event).
|
|
74
82
|
*/
|
|
75
|
-
constructor({ windowTitle, writeDelay, createURL, parseURL, getLocation, start, dispose, push, }: BrowserHistoryArgs<TRouteState>);
|
|
83
|
+
constructor({ windowTitle, writeDelay, createURL, parseURL, getLocation, start, dispose, push, cleanUrlOnDispose, }: BrowserHistoryArgs<TRouteState>);
|
|
76
84
|
/**
|
|
77
85
|
* Reads the URL and returns a syncable UI search state.
|
|
78
86
|
*/
|
|
@@ -101,5 +109,5 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
|
101
109
|
start(): void;
|
|
102
110
|
private shouldWrite;
|
|
103
111
|
}
|
|
104
|
-
export default function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, start, dispose, push, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
|
|
112
|
+
export default function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, start, dispose, push, cleanUrlOnDispose, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
|
|
105
113
|
export {};
|
|
@@ -6,7 +6,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
6
6
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
7
|
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); }
|
|
8
8
|
import qs from 'qs';
|
|
9
|
-
import { safelyRunOnBrowser, warning } from "../utils/index.js";
|
|
9
|
+
import { createDocumentationLink, safelyRunOnBrowser, warning } from "../utils/index.js";
|
|
10
10
|
var setWindowTitle = function setWindowTitle(title) {
|
|
11
11
|
if (title) {
|
|
12
12
|
// This function is only executed on browsers so we can disable this check.
|
|
@@ -29,7 +29,8 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
29
29
|
getLocation = _ref.getLocation,
|
|
30
30
|
start = _ref.start,
|
|
31
31
|
dispose = _ref.dispose,
|
|
32
|
-
push = _ref.push
|
|
32
|
+
push = _ref.push,
|
|
33
|
+
cleanUrlOnDispose = _ref.cleanUrlOnDispose;
|
|
33
34
|
_classCallCheck(this, BrowserHistory);
|
|
34
35
|
_defineProperty(this, "$$type", 'ais.browser');
|
|
35
36
|
/**
|
|
@@ -79,6 +80,7 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
79
80
|
_defineProperty(this, "_start", void 0);
|
|
80
81
|
_defineProperty(this, "_dispose", void 0);
|
|
81
82
|
_defineProperty(this, "_push", void 0);
|
|
83
|
+
_defineProperty(this, "_cleanUrlOnDispose", void 0);
|
|
82
84
|
this.windowTitle = windowTitle;
|
|
83
85
|
this.writeTimer = undefined;
|
|
84
86
|
this.writeDelay = writeDelay;
|
|
@@ -88,6 +90,13 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
88
90
|
this._start = start;
|
|
89
91
|
this._dispose = dispose;
|
|
90
92
|
this._push = push;
|
|
93
|
+
this._cleanUrlOnDispose = typeof cleanUrlOnDispose === 'undefined' ? true : cleanUrlOnDispose;
|
|
94
|
+
if (process.env.NODE_ENV === 'development' && typeof cleanUrlOnDispose === 'undefined') {
|
|
95
|
+
// eslint-disable-next-line no-console
|
|
96
|
+
console.info("Starting from the next major version, InstantSearch will not clean up the URL from active refinements when it is disposed.\n\nWe recommend setting `cleanUrlOnDispose` to false to adopt this change today.\nTo stay with the current behaviour and remove this warning, set the option to true.\n\nSee documentation: ".concat(createDocumentationLink({
|
|
97
|
+
name: 'history-router'
|
|
98
|
+
}), "#widget-param-cleanurlondispose"));
|
|
99
|
+
}
|
|
91
100
|
safelyRunOnBrowser(function (_ref2) {
|
|
92
101
|
var window = _ref2.window;
|
|
93
102
|
var title = _this.windowTitle && _this.windowTitle(_this.read());
|
|
@@ -215,7 +224,9 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
215
224
|
if (this.writeTimer) {
|
|
216
225
|
clearTimeout(this.writeTimer);
|
|
217
226
|
}
|
|
218
|
-
this.
|
|
227
|
+
if (this._cleanUrlOnDispose) {
|
|
228
|
+
this.write({});
|
|
229
|
+
}
|
|
219
230
|
}
|
|
220
231
|
}, {
|
|
221
232
|
key: "start",
|
|
@@ -304,7 +315,8 @@ export default function historyRouter() {
|
|
|
304
315
|
} : _ref7$getLocation,
|
|
305
316
|
start = _ref7.start,
|
|
306
317
|
dispose = _ref7.dispose,
|
|
307
|
-
push = _ref7.push
|
|
318
|
+
push = _ref7.push,
|
|
319
|
+
cleanUrlOnDispose = _ref7.cleanUrlOnDispose;
|
|
308
320
|
return new BrowserHistory({
|
|
309
321
|
createURL: createURL,
|
|
310
322
|
parseURL: parseURL,
|
|
@@ -313,6 +325,7 @@ export default function historyRouter() {
|
|
|
313
325
|
getLocation: getLocation,
|
|
314
326
|
start: start,
|
|
315
327
|
dispose: dispose,
|
|
316
|
-
push: push
|
|
328
|
+
push: push,
|
|
329
|
+
cleanUrlOnDispose: cleanUrlOnDispose
|
|
317
330
|
});
|
|
318
331
|
}
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.
|
|
1
|
+
declare const _default: "4.63.1";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.
|
|
1
|
+
export default '4.63.1';
|
|
@@ -16,7 +16,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
16
16
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
17
|
import { getInsightsAnonymousUserTokenInternal } from "../helpers/index.js";
|
|
18
18
|
import { warning, noop, getAppIdAndApiKey, find, safelyRunOnBrowser } from "../lib/utils/index.js";
|
|
19
|
-
var ALGOLIA_INSIGHTS_VERSION = '2.
|
|
19
|
+
var ALGOLIA_INSIGHTS_VERSION = '2.13.0';
|
|
20
20
|
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@".concat(ALGOLIA_INSIGHTS_VERSION, "/dist/search-insights.min.js");
|
|
21
21
|
export function createInsightsMiddleware() {
|
|
22
22
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -100,7 +100,7 @@ export function createInsightsMiddleware() {
|
|
|
100
100
|
// set it later on.
|
|
101
101
|
//
|
|
102
102
|
// Otherwise, the `init` call might override it with anonymous user token.
|
|
103
|
-
userTokenBeforeInit = userToken;
|
|
103
|
+
userTokenBeforeInit = normalizeUserToken(userToken);
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
// Only `init` if the `insightsInitParams` option is passed or
|
|
@@ -156,13 +156,14 @@ export function createInsightsMiddleware() {
|
|
|
156
156
|
}
|
|
157
157
|
var setUserTokenToSearch = function setUserTokenToSearch(userToken) {
|
|
158
158
|
var immediate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
159
|
-
|
|
159
|
+
var normalizedUserToken = normalizeUserToken(userToken);
|
|
160
|
+
if (!normalizedUserToken) {
|
|
160
161
|
return;
|
|
161
162
|
}
|
|
162
163
|
var existingToken = helper.state.userToken;
|
|
163
164
|
function applyToken() {
|
|
164
165
|
helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread(_objectSpread({}, helper.state), {}, {
|
|
165
|
-
userToken:
|
|
166
|
+
userToken: normalizedUserToken
|
|
166
167
|
}));
|
|
167
168
|
if (existingToken && existingToken !== userToken) {
|
|
168
169
|
instantSearchInstance.scheduleSearch();
|
|
@@ -259,4 +260,15 @@ function isModernInsightsClient(client) {
|
|
|
259
260
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
260
261
|
|
|
261
262
|
return v3 || v2_6 || v1_10;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* While `search-insights` supports both string and number user tokens,
|
|
267
|
+
* the Search API only accepts strings. This function normalizes the user token.
|
|
268
|
+
*/
|
|
269
|
+
function normalizeUserToken(userToken) {
|
|
270
|
+
if (!userToken) {
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
return typeof userToken === 'number' ? userToken.toString() : userToken;
|
|
262
274
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import type { ToggleRefinementConnectorParams, ToggleRefinementWidgetDescription,
|
|
2
|
+
import type { ToggleRefinementConnectorParams, ToggleRefinementWidgetDescription, ToggleRefinementRenderState } from '../../connectors/toggle-refinement/connectToggleRefinement';
|
|
3
3
|
import type { Template, WidgetFactory } from '../../types';
|
|
4
4
|
export type ToggleRefinementCSSClasses = Partial<{
|
|
5
5
|
/**
|
|
@@ -23,9 +23,7 @@ export type ToggleRefinementTemplates = Partial<{
|
|
|
23
23
|
/**
|
|
24
24
|
* the text that describes the toggle action
|
|
25
25
|
*/
|
|
26
|
-
labelText: Template<
|
|
27
|
-
name: string;
|
|
28
|
-
}>;
|
|
26
|
+
labelText: Template<ToggleRefinementRenderState['value']>;
|
|
29
27
|
}>;
|
|
30
28
|
export type ToggleRefinementWidgetParams = {
|
|
31
29
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.63.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",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"@types/google.maps": "^3.45.3",
|
|
34
34
|
"@types/hogan.js": "^3.0.0",
|
|
35
35
|
"@types/qs": "^6.5.3",
|
|
36
|
-
"algoliasearch-helper": "3.16.
|
|
36
|
+
"algoliasearch-helper": "3.16.1",
|
|
37
37
|
"hogan.js": "^3.0.2",
|
|
38
38
|
"htm": "^3.0.0",
|
|
39
39
|
"preact": "^10.10.0",
|
|
40
40
|
"qs": "^6.5.1 < 6.10",
|
|
41
|
-
"search-insights": "^2.
|
|
41
|
+
"search-insights": "^2.13.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"algoliasearch": ">= 3.1 < 6"
|
|
@@ -49,21 +49,21 @@
|
|
|
49
49
|
"build:cjs": "rm -rf cjs && BABEL_ENV=cjs babel --root-mode upward src --extensions '.js,.ts,.tsx' --out-dir cjs/ --ignore 'src/index.es.ts','**/__tests__','**/__mocks__' --quiet",
|
|
50
50
|
"build:es": "rm -rf es && BABEL_ENV=es babel --root-mode upward src --extensions '.js,.ts,.tsx' --out-dir es/ --ignore 'src/index.es.ts','**/__tests__','**/__mocks__' --quiet && BABEL_ENV=es babel --root-mode upward src/index.es.ts --out-file es/index.js --quiet && echo '{\"type\":\"module\",\"sideEffects\":false}' > es/package.json",
|
|
51
51
|
"build:types": "scripts/typescript/extract.js",
|
|
52
|
-
"storybook": "start-storybook --quiet --port 6006 --ci --static-dir .storybook/static",
|
|
53
|
-
"storybook:build": "build-storybook --quiet --output-dir ../../website/stories/js --static-dir .storybook/static",
|
|
52
|
+
"storybook": "NODE_OPTIONS=--openssl-legacy-provider start-storybook --quiet --port 6006 --ci --static-dir .storybook/static",
|
|
53
|
+
"storybook:build": "NODE_OPTIONS=--openssl-legacy-provider build-storybook --quiet --output-dir ../../website/stories/js --static-dir .storybook/static",
|
|
54
54
|
"test:exports": "node test/module/is-es-module.mjs && node test/module/is-cjs-module.cjs",
|
|
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.
|
|
58
|
+
"@instantsearch/mocks": "1.33.0",
|
|
59
|
+
"@instantsearch/tests": "1.33.0",
|
|
60
|
+
"@instantsearch/testutils": "1.22.0",
|
|
61
61
|
"@storybook/html": "5.3.9",
|
|
62
62
|
"@types/scriptjs": "0.0.2",
|
|
63
63
|
"algoliasearch": "4.14.3",
|
|
64
64
|
"places.js": "1.17.1",
|
|
65
65
|
"scriptjs": "2.5.9",
|
|
66
|
-
"webpack": "4.
|
|
66
|
+
"webpack": "4.47.0"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "4e99d1220b9c7872130f52bded4c1a84900bd0a3"
|
|
69
69
|
}
|