react-instantsearch 7.4.1 → 7.5.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/dist/cjs/ui/HierarchicalMenu.js +1 -1
- package/dist/cjs/ui/SearchBox.js +1 -0
- package/dist/cjs/widgets/RefinementList.js +6 -2
- package/dist/cjs/widgets/SearchBox.js +4 -2
- package/dist/es/ui/HierarchicalMenu.js +1 -1
- package/dist/es/ui/SearchBox.d.ts +2 -1
- package/dist/es/ui/SearchBox.js +1 -0
- package/dist/es/widgets/RefinementList.js +6 -2
- package/dist/es/widgets/SearchBox.js +4 -2
- package/dist/umd/ReactInstantSearch.js +42 -16
- package/dist/umd/ReactInstantSearch.js.map +1 -1
- package/dist/umd/ReactInstantSearch.min.js +1 -1
- package/dist/umd/ReactInstantSearch.min.js.map +1 -1
- package/package.json +4 -4
|
@@ -28,7 +28,7 @@ function HierarchicalList(_ref) {
|
|
|
28
28
|
}, items.map(function (item) {
|
|
29
29
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
30
30
|
key: item.value,
|
|
31
|
-
className: (0, _cx.cx)('ais-HierarchicalMenu-item', classNames.item, item.
|
|
31
|
+
className: (0, _cx.cx)('ais-HierarchicalMenu-item', classNames.item, item.isRefined && (0, _cx.cx)('ais-HierarchicalMenu-item--selected', classNames.selectedItem), item.data && item.data.length > 0 && (0, _cx.cx)('ais-HierarchicalMenu-item--parent', classNames.parentItem))
|
|
32
32
|
}, /*#__PURE__*/_react.default.createElement("a", {
|
|
33
33
|
className: (0, _cx.cx)('ais-HierarchicalMenu-link', classNames.link, item.isRefined && (0, _cx.cx)('ais-HierarchicalMenu-link--selected', classNames.selectedItemLink)),
|
|
34
34
|
href: createURL(item.value),
|
package/dist/cjs/ui/SearchBox.js
CHANGED
|
@@ -132,6 +132,7 @@ function SearchBox(_ref7) {
|
|
|
132
132
|
type: "search",
|
|
133
133
|
value: value,
|
|
134
134
|
onChange: onChange,
|
|
135
|
+
onCompositionEnd: onChange,
|
|
135
136
|
autoFocus: autoFocus
|
|
136
137
|
}), /*#__PURE__*/_react.default.createElement("button", {
|
|
137
138
|
className: (0, _cx.cx)('ais-SearchBox-submit', classNames.submit),
|
|
@@ -65,15 +65,19 @@ function RefinementList(_ref) {
|
|
|
65
65
|
setInputValue = _useState2[1];
|
|
66
66
|
var inputRef = (0, _react.useRef)(null);
|
|
67
67
|
function setQuery(newQuery) {
|
|
68
|
+
var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
68
69
|
setInputValue(newQuery);
|
|
69
|
-
|
|
70
|
+
if (compositionComplete) {
|
|
71
|
+
searchForItems(newQuery);
|
|
72
|
+
}
|
|
70
73
|
}
|
|
71
74
|
function onRefine(item) {
|
|
72
75
|
refine(item.value);
|
|
73
76
|
setQuery('');
|
|
74
77
|
}
|
|
75
78
|
function onChange(event) {
|
|
76
|
-
|
|
79
|
+
var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
|
|
80
|
+
setQuery(event.currentTarget.value, compositionComplete);
|
|
77
81
|
}
|
|
78
82
|
function onReset() {
|
|
79
83
|
setQuery('');
|
|
@@ -45,8 +45,9 @@ function SearchBox(_ref) {
|
|
|
45
45
|
setInputValue = _useState2[1];
|
|
46
46
|
var inputRef = (0, _react.useRef)(null);
|
|
47
47
|
function setQuery(newQuery) {
|
|
48
|
+
var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
48
49
|
setInputValue(newQuery);
|
|
49
|
-
if (searchAsYouType) {
|
|
50
|
+
if (searchAsYouType && compositionComplete) {
|
|
50
51
|
refine(newQuery);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -57,7 +58,8 @@ function SearchBox(_ref) {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
function onChange(event) {
|
|
60
|
-
|
|
61
|
+
var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
|
|
62
|
+
setQuery(event.currentTarget.value, compositionComplete);
|
|
61
63
|
}
|
|
62
64
|
function onSubmit(event) {
|
|
63
65
|
if (!searchAsYouType) {
|
|
@@ -21,7 +21,7 @@ function HierarchicalList(_ref) {
|
|
|
21
21
|
}, items.map(function (item) {
|
|
22
22
|
return /*#__PURE__*/React.createElement("li", {
|
|
23
23
|
key: item.value,
|
|
24
|
-
className: cx('ais-HierarchicalMenu-item', classNames.item, item.
|
|
24
|
+
className: cx('ais-HierarchicalMenu-item', classNames.item, item.isRefined && cx('ais-HierarchicalMenu-item--selected', classNames.selectedItem), item.data && item.data.length > 0 && cx('ais-HierarchicalMenu-item--parent', classNames.parentItem))
|
|
25
25
|
}, /*#__PURE__*/React.createElement("a", {
|
|
26
26
|
className: cx('ais-HierarchicalMenu-link', classNames.link, item.isRefined && cx('ais-HierarchicalMenu-link--selected', classNames.selectedItemLink)),
|
|
27
27
|
href: createURL(item.value),
|
|
@@ -50,7 +50,8 @@ export type SearchBoxTranslations = {
|
|
|
50
50
|
*/
|
|
51
51
|
resetButtonTitle: string;
|
|
52
52
|
};
|
|
53
|
-
export type SearchBoxProps = Omit<React.ComponentProps<'div'>, 'onSubmit' | 'onReset' | 'onChange'> & Pick<React.ComponentProps<'form'>, 'onSubmit'> & Required<Pick<React.ComponentProps<'form'>, 'onReset'>> & Pick<React.ComponentProps<'input'>, 'placeholder' | '
|
|
53
|
+
export type SearchBoxProps = Omit<React.ComponentProps<'div'>, 'onSubmit' | 'onReset' | 'onChange'> & Pick<React.ComponentProps<'form'>, 'onSubmit'> & Required<Pick<React.ComponentProps<'form'>, 'onReset'>> & Pick<React.ComponentProps<'input'>, 'placeholder' | 'autoFocus'> & {
|
|
54
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement> | React.CompositionEvent<HTMLInputElement>) => void;
|
|
54
55
|
formRef?: React.RefObject<HTMLFormElement>;
|
|
55
56
|
inputRef: React.RefObject<HTMLInputElement>;
|
|
56
57
|
isSearchStalled: boolean;
|
package/dist/es/ui/SearchBox.js
CHANGED
|
@@ -125,6 +125,7 @@ export function SearchBox(_ref7) {
|
|
|
125
125
|
type: "search",
|
|
126
126
|
value: value,
|
|
127
127
|
onChange: onChange,
|
|
128
|
+
onCompositionEnd: onChange,
|
|
128
129
|
autoFocus: autoFocus
|
|
129
130
|
}), /*#__PURE__*/React.createElement("button", {
|
|
130
131
|
className: cx('ais-SearchBox-submit', classNames.submit),
|
|
@@ -57,15 +57,19 @@ export function RefinementList(_ref) {
|
|
|
57
57
|
setInputValue = _useState2[1];
|
|
58
58
|
var inputRef = useRef(null);
|
|
59
59
|
function setQuery(newQuery) {
|
|
60
|
+
var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
60
61
|
setInputValue(newQuery);
|
|
61
|
-
|
|
62
|
+
if (compositionComplete) {
|
|
63
|
+
searchForItems(newQuery);
|
|
64
|
+
}
|
|
62
65
|
}
|
|
63
66
|
function onRefine(item) {
|
|
64
67
|
refine(item.value);
|
|
65
68
|
setQuery('');
|
|
66
69
|
}
|
|
67
70
|
function onChange(event) {
|
|
68
|
-
|
|
71
|
+
var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
|
|
72
|
+
setQuery(event.currentTarget.value, compositionComplete);
|
|
69
73
|
}
|
|
70
74
|
function onReset() {
|
|
71
75
|
setQuery('');
|
|
@@ -37,8 +37,9 @@ export function SearchBox(_ref) {
|
|
|
37
37
|
setInputValue = _useState2[1];
|
|
38
38
|
var inputRef = useRef(null);
|
|
39
39
|
function setQuery(newQuery) {
|
|
40
|
+
var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
40
41
|
setInputValue(newQuery);
|
|
41
|
-
if (searchAsYouType) {
|
|
42
|
+
if (searchAsYouType && compositionComplete) {
|
|
42
43
|
refine(newQuery);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -49,7 +50,8 @@ export function SearchBox(_ref) {
|
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
function onChange(event) {
|
|
52
|
-
|
|
53
|
+
var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
|
|
54
|
+
setQuery(event.currentTarget.value, compositionComplete);
|
|
53
55
|
}
|
|
54
56
|
function onSubmit(event) {
|
|
55
57
|
if (!searchAsYouType) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
var React__default = 'default' in React ? React['default'] : React;
|
|
9
9
|
|
|
10
|
-
var version = '7.
|
|
10
|
+
var version = '7.5.0';
|
|
11
11
|
|
|
12
12
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
13
13
|
//
|
|
@@ -4337,7 +4337,7 @@
|
|
|
4337
4337
|
|
|
4338
4338
|
var SearchResults_1 = SearchResults;
|
|
4339
4339
|
|
|
4340
|
-
var version$1 = '3.16.
|
|
4340
|
+
var version$1 = '3.16.1';
|
|
4341
4341
|
|
|
4342
4342
|
var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
|
|
4343
4343
|
|
|
@@ -10286,7 +10286,7 @@
|
|
|
10286
10286
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
10287
10287
|
return arr2;
|
|
10288
10288
|
}
|
|
10289
|
-
var ALGOLIA_INSIGHTS_VERSION = '2.
|
|
10289
|
+
var ALGOLIA_INSIGHTS_VERSION = '2.13.0';
|
|
10290
10290
|
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@".concat(ALGOLIA_INSIGHTS_VERSION, "/dist/search-insights.min.js");
|
|
10291
10291
|
function createInsightsMiddleware() {
|
|
10292
10292
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -10367,7 +10367,7 @@
|
|
|
10367
10367
|
// set it later on.
|
|
10368
10368
|
//
|
|
10369
10369
|
// Otherwise, the `init` call might override it with anonymous user token.
|
|
10370
|
-
userTokenBeforeInit = userToken;
|
|
10370
|
+
userTokenBeforeInit = normalizeUserToken(userToken);
|
|
10371
10371
|
});
|
|
10372
10372
|
|
|
10373
10373
|
// Only `init` if the `insightsInitParams` option is passed or
|
|
@@ -10423,13 +10423,14 @@
|
|
|
10423
10423
|
}
|
|
10424
10424
|
var setUserTokenToSearch = function setUserTokenToSearch(userToken) {
|
|
10425
10425
|
var immediate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
10426
|
-
|
|
10426
|
+
var normalizedUserToken = normalizeUserToken(userToken);
|
|
10427
|
+
if (!normalizedUserToken) {
|
|
10427
10428
|
return;
|
|
10428
10429
|
}
|
|
10429
10430
|
var existingToken = helper.state.userToken;
|
|
10430
10431
|
function applyToken() {
|
|
10431
10432
|
helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread$e(_objectSpread$e({}, helper.state), {}, {
|
|
10432
|
-
userToken:
|
|
10433
|
+
userToken: normalizedUserToken
|
|
10433
10434
|
}));
|
|
10434
10435
|
if (existingToken && existingToken !== userToken) {
|
|
10435
10436
|
instantSearchInstance.scheduleSearch();
|
|
@@ -10525,6 +10526,17 @@
|
|
|
10525
10526
|
return v3 || v2_6 || v1_10;
|
|
10526
10527
|
}
|
|
10527
10528
|
|
|
10529
|
+
/**
|
|
10530
|
+
* While `search-insights` supports both string and number user tokens,
|
|
10531
|
+
* the Search API only accepts strings. This function normalizes the user token.
|
|
10532
|
+
*/
|
|
10533
|
+
function normalizeUserToken(userToken) {
|
|
10534
|
+
if (!userToken) {
|
|
10535
|
+
return undefined;
|
|
10536
|
+
}
|
|
10537
|
+
return typeof userToken === 'number' ? userToken.toString() : userToken;
|
|
10538
|
+
}
|
|
10539
|
+
|
|
10528
10540
|
function extractWidgetPayload(widgets, instantSearchInstance, payload) {
|
|
10529
10541
|
var initOptions = createInitArgs(instantSearchInstance, instantSearchInstance.mainIndex, instantSearchInstance._initialUiState);
|
|
10530
10542
|
widgets.forEach(function (widget) {
|
|
@@ -11507,7 +11519,8 @@
|
|
|
11507
11519
|
getLocation = _ref.getLocation,
|
|
11508
11520
|
start = _ref.start,
|
|
11509
11521
|
dispose = _ref.dispose,
|
|
11510
|
-
push = _ref.push
|
|
11522
|
+
push = _ref.push,
|
|
11523
|
+
cleanUrlOnDispose = _ref.cleanUrlOnDispose;
|
|
11511
11524
|
_classCallCheck(this, BrowserHistory);
|
|
11512
11525
|
_defineProperty$f(this, "$$type", 'ais.browser');
|
|
11513
11526
|
/**
|
|
@@ -11557,6 +11570,7 @@
|
|
|
11557
11570
|
_defineProperty$f(this, "_start", void 0);
|
|
11558
11571
|
_defineProperty$f(this, "_dispose", void 0);
|
|
11559
11572
|
_defineProperty$f(this, "_push", void 0);
|
|
11573
|
+
_defineProperty$f(this, "_cleanUrlOnDispose", void 0);
|
|
11560
11574
|
this.windowTitle = windowTitle;
|
|
11561
11575
|
this.writeTimer = undefined;
|
|
11562
11576
|
this.writeDelay = writeDelay;
|
|
@@ -11566,6 +11580,7 @@
|
|
|
11566
11580
|
this._start = start;
|
|
11567
11581
|
this._dispose = dispose;
|
|
11568
11582
|
this._push = push;
|
|
11583
|
+
this._cleanUrlOnDispose = typeof cleanUrlOnDispose === 'undefined' ? true : cleanUrlOnDispose;
|
|
11569
11584
|
safelyRunOnBrowser(function (_ref2) {
|
|
11570
11585
|
var window = _ref2.window;
|
|
11571
11586
|
var title = _this.windowTitle && _this.windowTitle(_this.read());
|
|
@@ -11684,7 +11699,9 @@
|
|
|
11684
11699
|
if (this.writeTimer) {
|
|
11685
11700
|
clearTimeout(this.writeTimer);
|
|
11686
11701
|
}
|
|
11687
|
-
this.
|
|
11702
|
+
if (this._cleanUrlOnDispose) {
|
|
11703
|
+
this.write({});
|
|
11704
|
+
}
|
|
11688
11705
|
}
|
|
11689
11706
|
}, {
|
|
11690
11707
|
key: "start",
|
|
@@ -11773,7 +11790,8 @@
|
|
|
11773
11790
|
} : _ref7$getLocation,
|
|
11774
11791
|
start = _ref7.start,
|
|
11775
11792
|
dispose = _ref7.dispose,
|
|
11776
|
-
push = _ref7.push
|
|
11793
|
+
push = _ref7.push,
|
|
11794
|
+
cleanUrlOnDispose = _ref7.cleanUrlOnDispose;
|
|
11777
11795
|
return new BrowserHistory({
|
|
11778
11796
|
createURL: createURL,
|
|
11779
11797
|
parseURL: parseURL,
|
|
@@ -11782,7 +11800,8 @@
|
|
|
11782
11800
|
getLocation: getLocation,
|
|
11783
11801
|
start: start,
|
|
11784
11802
|
dispose: dispose,
|
|
11785
|
-
push: push
|
|
11803
|
+
push: push,
|
|
11804
|
+
cleanUrlOnDispose: cleanUrlOnDispose
|
|
11786
11805
|
});
|
|
11787
11806
|
}
|
|
11788
11807
|
|
|
@@ -12140,7 +12159,7 @@
|
|
|
12140
12159
|
};
|
|
12141
12160
|
}
|
|
12142
12161
|
|
|
12143
|
-
var version$3 = '4.
|
|
12162
|
+
var version$3 = '4.63.0';
|
|
12144
12163
|
|
|
12145
12164
|
function _typeof$o(obj) {
|
|
12146
12165
|
"@babel/helpers - typeof";
|
|
@@ -19135,7 +19154,7 @@
|
|
|
19135
19154
|
}, items.map(function (item) {
|
|
19136
19155
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
19137
19156
|
key: item.value,
|
|
19138
|
-
className: cx('ais-HierarchicalMenu-item', classNames.item, item.
|
|
19157
|
+
className: cx('ais-HierarchicalMenu-item', classNames.item, item.isRefined && cx('ais-HierarchicalMenu-item--selected', classNames.selectedItem), item.data && item.data.length > 0 && cx('ais-HierarchicalMenu-item--parent', classNames.parentItem))
|
|
19139
19158
|
}, /*#__PURE__*/React__default.createElement("a", {
|
|
19140
19159
|
className: cx('ais-HierarchicalMenu-link', classNames.link, item.isRefined && cx('ais-HierarchicalMenu-link--selected', classNames.selectedItemLink)),
|
|
19141
19160
|
href: createURL(item.value),
|
|
@@ -20135,6 +20154,7 @@
|
|
|
20135
20154
|
type: "search",
|
|
20136
20155
|
value: value,
|
|
20137
20156
|
onChange: onChange,
|
|
20157
|
+
onCompositionEnd: onChange,
|
|
20138
20158
|
autoFocus: autoFocus
|
|
20139
20159
|
}), /*#__PURE__*/React__default.createElement("button", {
|
|
20140
20160
|
className: cx('ais-SearchBox-submit', classNames.submit),
|
|
@@ -20199,15 +20219,19 @@
|
|
|
20199
20219
|
setInputValue = _useState2[1];
|
|
20200
20220
|
var inputRef = React.useRef(null);
|
|
20201
20221
|
function setQuery(newQuery) {
|
|
20222
|
+
var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
20202
20223
|
setInputValue(newQuery);
|
|
20203
|
-
|
|
20224
|
+
if (compositionComplete) {
|
|
20225
|
+
searchForItems(newQuery);
|
|
20226
|
+
}
|
|
20204
20227
|
}
|
|
20205
20228
|
function onRefine(item) {
|
|
20206
20229
|
refine(item.value);
|
|
20207
20230
|
setQuery('');
|
|
20208
20231
|
}
|
|
20209
20232
|
function onChange(event) {
|
|
20210
|
-
|
|
20233
|
+
var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
|
|
20234
|
+
setQuery(event.currentTarget.value, compositionComplete);
|
|
20211
20235
|
}
|
|
20212
20236
|
function onReset() {
|
|
20213
20237
|
setQuery('');
|
|
@@ -20278,8 +20302,9 @@
|
|
|
20278
20302
|
setInputValue = _useState2[1];
|
|
20279
20303
|
var inputRef = React.useRef(null);
|
|
20280
20304
|
function setQuery(newQuery) {
|
|
20305
|
+
var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
20281
20306
|
setInputValue(newQuery);
|
|
20282
|
-
if (searchAsYouType) {
|
|
20307
|
+
if (searchAsYouType && compositionComplete) {
|
|
20283
20308
|
refine(newQuery);
|
|
20284
20309
|
}
|
|
20285
20310
|
}
|
|
@@ -20290,7 +20315,8 @@
|
|
|
20290
20315
|
}
|
|
20291
20316
|
}
|
|
20292
20317
|
function onChange(event) {
|
|
20293
|
-
|
|
20318
|
+
var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
|
|
20319
|
+
setQuery(event.currentTarget.value, compositionComplete);
|
|
20294
20320
|
}
|
|
20295
20321
|
function onSubmit(event) {
|
|
20296
20322
|
if (!searchAsYouType) {
|