@algolia/autocomplete-js 1.19.10 → 1.19.11
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/esm/autocomplete.js
CHANGED
|
@@ -36,6 +36,19 @@ export function autocomplete(options) {
|
|
|
36
36
|
var isDetached = reactive(function () {
|
|
37
37
|
return props.value.core.environment.matchMedia(props.value.renderer.detachedMediaQuery).matches;
|
|
38
38
|
});
|
|
39
|
+
function warnAboutOpenOnFocusInDetachedMode() {
|
|
40
|
+
var _props$value$core$ope;
|
|
41
|
+
// `openOnFocus` isn't resolved to its default at this layer yet (that
|
|
42
|
+
// happens inside `autocomplete-core`'s `createAutocomplete`), so we
|
|
43
|
+
// mirror its documented default (`false`) explicitly here rather than
|
|
44
|
+
// relying on falsiness, or reaching for `getDefaultProps` from
|
|
45
|
+
// `autocomplete-core` — that function has side effects (it generates
|
|
46
|
+
// an autocomplete id, builds the full `getSources` pipeline) that make
|
|
47
|
+
// it unsuitable for just reading one resolved option.
|
|
48
|
+
var openOnFocus = (_props$value$core$ope = props.value.core.openOnFocus) !== null && _props$value$core$ope !== void 0 ? _props$value$core$ope : false;
|
|
49
|
+
process.env.NODE_ENV !== 'production' ? warn(!(isDetached.value && !openOnFocus), "`openOnFocus: false` can lead to unexpected behavior in detached mode. We recommend using `openOnFocus: true` when detached mode is enabled.\n\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-openonfocus") : void 0;
|
|
50
|
+
}
|
|
51
|
+
warnAboutOpenOnFocusInDetachedMode();
|
|
39
52
|
var autocomplete = reactive(function () {
|
|
40
53
|
return createAutocomplete(_objectSpread(_objectSpread({}, props.value.core), {}, {
|
|
41
54
|
onStateChange: function onStateChange(params) {
|
|
@@ -218,6 +231,7 @@ export function autocomplete(options) {
|
|
|
218
231
|
var previousIsDetached = isDetached.value;
|
|
219
232
|
isDetached.value = props.value.core.environment.matchMedia(props.value.renderer.detachedMediaQuery).matches;
|
|
220
233
|
if (previousIsDetached !== isDetached.value) {
|
|
234
|
+
warnAboutOpenOnFocusInDetachedMode();
|
|
221
235
|
update({});
|
|
222
236
|
} else {
|
|
223
237
|
requestAnimationFrame(setPanelPosition);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @algolia/autocomplete-js 1.19.
|
|
1
|
+
/*! @algolia/autocomplete-js 1.19.11 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
return undefined;
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
var version = '1.19.
|
|
330
|
+
var version = '1.19.11';
|
|
331
331
|
|
|
332
332
|
var userAgents$1 = [{
|
|
333
333
|
segment: 'autocomplete-core',
|
|
@@ -2518,9 +2518,11 @@
|
|
|
2518
2518
|
// result in an unsolicited UI behavior.
|
|
2519
2519
|
store.pendingRequests.cancelAll();
|
|
2520
2520
|
} else if (event.key === 'Enter') {
|
|
2521
|
+
var activeItem = store.getState().activeItemId !== null ? getActiveItem(store.getState()) : null;
|
|
2522
|
+
|
|
2521
2523
|
// No active item, so we let the browser handle the native `onSubmit` form
|
|
2522
2524
|
// event.
|
|
2523
|
-
if (
|
|
2525
|
+
if (!activeItem || store.getState().collections.every(function (collection) {
|
|
2524
2526
|
return collection.items.length === 0;
|
|
2525
2527
|
})) {
|
|
2526
2528
|
var waitForSubmit = getPluginSubmitPromise(props.plugins, store.pendingRequests);
|
|
@@ -2539,11 +2541,10 @@
|
|
|
2539
2541
|
// This prevents the `onSubmit` event to be sent because an item is
|
|
2540
2542
|
// highlighted.
|
|
2541
2543
|
event.preventDefault();
|
|
2542
|
-
var
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
source = _ref2.source;
|
|
2544
|
+
var item = activeItem.item,
|
|
2545
|
+
itemInputValue = activeItem.itemInputValue,
|
|
2546
|
+
itemUrl = activeItem.itemUrl,
|
|
2547
|
+
source = activeItem.source;
|
|
2547
2548
|
if (event.metaKey || event.ctrlKey) {
|
|
2548
2549
|
if (itemUrl !== undefined) {
|
|
2549
2550
|
source.onSelect(_objectSpread$7({
|
|
@@ -3193,9 +3194,13 @@
|
|
|
3193
3194
|
}
|
|
3194
3195
|
case 'setCollections':
|
|
3195
3196
|
{
|
|
3196
|
-
|
|
3197
|
+
var newItemsCount = getItemsCount({
|
|
3197
3198
|
collections: action.payload
|
|
3198
3199
|
});
|
|
3200
|
+
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
3201
|
+
collections: action.payload,
|
|
3202
|
+
activeItemId: state.activeItemId !== null && state.activeItemId >= newItemsCount ? action.props.defaultActiveItemId : state.activeItemId
|
|
3203
|
+
});
|
|
3199
3204
|
}
|
|
3200
3205
|
case 'setIsOpen':
|
|
3201
3206
|
{
|
|
@@ -4911,6 +4916,19 @@
|
|
|
4911
4916
|
var isDetached = reactive(function () {
|
|
4912
4917
|
return props.value.core.environment.matchMedia(props.value.renderer.detachedMediaQuery).matches;
|
|
4913
4918
|
});
|
|
4919
|
+
function warnAboutOpenOnFocusInDetachedMode() {
|
|
4920
|
+
var _props$value$core$ope;
|
|
4921
|
+
// `openOnFocus` isn't resolved to its default at this layer yet (that
|
|
4922
|
+
// happens inside `autocomplete-core`'s `createAutocomplete`), so we
|
|
4923
|
+
// mirror its documented default (`false`) explicitly here rather than
|
|
4924
|
+
// relying on falsiness, or reaching for `getDefaultProps` from
|
|
4925
|
+
// `autocomplete-core` — that function has side effects (it generates
|
|
4926
|
+
// an autocomplete id, builds the full `getSources` pipeline) that make
|
|
4927
|
+
// it unsuitable for just reading one resolved option.
|
|
4928
|
+
var openOnFocus = (_props$value$core$ope = props.value.core.openOnFocus) !== null && _props$value$core$ope !== void 0 ? _props$value$core$ope : false;
|
|
4929
|
+
"development" !== 'production' ? warn(!(isDetached.value && !openOnFocus), "`openOnFocus: false` can lead to unexpected behavior in detached mode. We recommend using `openOnFocus: true` when detached mode is enabled.\n\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-openonfocus") : void 0;
|
|
4930
|
+
}
|
|
4931
|
+
warnAboutOpenOnFocusInDetachedMode();
|
|
4914
4932
|
var autocomplete = reactive(function () {
|
|
4915
4933
|
return createAutocomplete(_objectSpread2(_objectSpread2({}, props.value.core), {}, {
|
|
4916
4934
|
onStateChange: function onStateChange(params) {
|
|
@@ -5093,6 +5111,7 @@
|
|
|
5093
5111
|
var previousIsDetached = isDetached.value;
|
|
5094
5112
|
isDetached.value = props.value.core.environment.matchMedia(props.value.renderer.detachedMediaQuery).matches;
|
|
5095
5113
|
if (previousIsDetached !== isDetached.value) {
|
|
5114
|
+
warnAboutOpenOnFocusInDetachedMode();
|
|
5096
5115
|
update({});
|
|
5097
5116
|
} else {
|
|
5098
5117
|
requestAnimationFrame(setPanelPosition);
|