@algolia/autocomplete-js 1.5.3 → 1.5.6
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/createAutocompleteDom.js +8 -2
- package/dist/esm/utils/setProperties.js +8 -1
- package/dist/umd/index.development.js +37 -6
- package/dist/umd/index.development.js.map +1 -1
- package/dist/umd/index.production.js +2 -2
- package/dist/umd/index.production.js.map +1 -1
- package/package.json +4 -4
|
@@ -131,16 +131,22 @@ export function createAutocompleteDom(_ref) {
|
|
|
131
131
|
textContent: placeholder
|
|
132
132
|
});
|
|
133
133
|
var detachedSearchButton = createDomElement('button', {
|
|
134
|
+
type: 'button',
|
|
134
135
|
class: classNames.detachedSearchButton,
|
|
135
|
-
onClick: function onClick(
|
|
136
|
-
event.preventDefault();
|
|
136
|
+
onClick: function onClick() {
|
|
137
137
|
setIsModalOpen(true);
|
|
138
138
|
},
|
|
139
139
|
children: [detachedSearchButtonIcon, detachedSearchButtonPlaceholder]
|
|
140
140
|
});
|
|
141
141
|
var detachedCancelButton = createDomElement('button', {
|
|
142
|
+
type: 'button',
|
|
142
143
|
class: classNames.detachedCancelButton,
|
|
143
144
|
textContent: translations.detachedCancelButtonText,
|
|
145
|
+
// Prevent `onTouchStart` from closing the panel
|
|
146
|
+
// since it should be initiated by `onClick` only
|
|
147
|
+
onTouchStart: function onTouchStart(event) {
|
|
148
|
+
event.stopPropagation();
|
|
149
|
+
},
|
|
144
150
|
onClick: function onClick() {
|
|
145
151
|
autocomplete.setIsOpen(false);
|
|
146
152
|
setIsModalOpen(false);
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Touch-specific event aliases
|
|
5
|
+
*
|
|
6
|
+
* See https://w3c.github.io/touch-events/#extensions-to-the-globaleventhandlers-mixin
|
|
7
|
+
*/
|
|
8
|
+
var TOUCH_EVENTS_ALIASES = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouchcancel'];
|
|
3
9
|
/*
|
|
4
10
|
* Taken from Preact
|
|
5
11
|
*
|
|
6
12
|
* See https://github.com/preactjs/preact/blob/6ab49d9020740127577bf4af66bf63f4af7f9fee/src/diff/props.js#L58-L151
|
|
7
13
|
*/
|
|
14
|
+
|
|
8
15
|
function setStyle(style, key, value) {
|
|
9
16
|
if (value === null) {
|
|
10
17
|
style[key] = '';
|
|
@@ -50,7 +57,7 @@ export function setProperty(dom, name, value) {
|
|
|
50
57
|
else if (name[0] === 'o' && name[1] === 'n') {
|
|
51
58
|
useCapture = name !== (name = name.replace(/Capture$/, ''));
|
|
52
59
|
nameLower = name.toLowerCase();
|
|
53
|
-
if (nameLower in dom) name = nameLower;
|
|
60
|
+
if (nameLower in dom || TOUCH_EVENTS_ALIASES.includes(nameLower)) name = nameLower;
|
|
54
61
|
name = name.slice(2);
|
|
55
62
|
if (!dom._listeners) dom._listeners = {};
|
|
56
63
|
dom._listeners[name] = value;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @algolia/autocomplete-js 1.5.
|
|
1
|
+
/*! @algolia/autocomplete-js 1.5.6 | 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) :
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
|
|
312
312
|
var noop = function noop() {};
|
|
313
313
|
|
|
314
|
-
var version = '1.5.
|
|
314
|
+
var version = '1.5.6';
|
|
315
315
|
|
|
316
316
|
var userAgents$1 = [{
|
|
317
317
|
segment: 'autocomplete-core',
|
|
@@ -584,6 +584,14 @@
|
|
|
584
584
|
});
|
|
585
585
|
}
|
|
586
586
|
|
|
587
|
+
var chromeRegex = /(crmo|crios|chrome)/i;
|
|
588
|
+
var edgeRegex = /edg(e|ios|a)?/i;
|
|
589
|
+
var samsungBrowserRegex = /samsungbrowser/i;
|
|
590
|
+
var chromiumRegex = /chromium/i;
|
|
591
|
+
function isChrome(userAgent) {
|
|
592
|
+
return Boolean(userAgent && userAgent.match(chromeRegex) && !userAgent.match(edgeRegex) && !userAgent.match(samsungBrowserRegex) && !userAgent.match(chromiumRegex));
|
|
593
|
+
}
|
|
594
|
+
|
|
587
595
|
// We don't have access to the autocomplete source when we call `onKeyDown`
|
|
588
596
|
// or `onClick` because those are native browser events.
|
|
589
597
|
// However, we can get the source from the suggestion index.
|
|
@@ -674,6 +682,11 @@
|
|
|
674
682
|
return parent === child || parent.contains(child);
|
|
675
683
|
}
|
|
676
684
|
|
|
685
|
+
var regex = /((gt|sm)-|galaxy nexus)|samsung[- ]/i;
|
|
686
|
+
function isSamsung(userAgent) {
|
|
687
|
+
return Boolean(userAgent && userAgent.match(regex));
|
|
688
|
+
}
|
|
689
|
+
|
|
677
690
|
function ownKeys$e(object, enumerableOnly) {
|
|
678
691
|
var keys = Object.keys(object);
|
|
679
692
|
|
|
@@ -1991,6 +2004,8 @@
|
|
|
1991
2004
|
};
|
|
1992
2005
|
|
|
1993
2006
|
var getInputProps = function getInputProps(providedProps) {
|
|
2007
|
+
var _props$environment$na;
|
|
2008
|
+
|
|
1994
2009
|
function onFocus(event) {
|
|
1995
2010
|
// We want to trigger a query when `openOnFocus` is true
|
|
1996
2011
|
// because the panel should open with the current query.
|
|
@@ -2016,6 +2031,9 @@
|
|
|
2016
2031
|
rest = _objectWithoutProperties$1(_ref2, _excluded4);
|
|
2017
2032
|
|
|
2018
2033
|
var activeItem = getActiveItem(store.getState());
|
|
2034
|
+
var userAgent = (_props$environment$na = props.environment.navigator) === null || _props$environment$na === void 0 ? void 0 : _props$environment$na.userAgent;
|
|
2035
|
+
var shouldFallbackKeyHint = isSamsung(userAgent) && isChrome(userAgent);
|
|
2036
|
+
var enterKeyHint = activeItem !== null && activeItem !== void 0 && activeItem.itemUrl && !shouldFallbackKeyHint ? 'go' : 'search';
|
|
2019
2037
|
return _objectSpread$6({
|
|
2020
2038
|
'aria-autocomplete': 'both',
|
|
2021
2039
|
'aria-activedescendant': store.getState().isOpen && store.getState().activeItemId !== null ? "".concat(props.id, "-item-").concat(store.getState().activeItemId) : undefined,
|
|
@@ -2026,7 +2044,7 @@
|
|
|
2026
2044
|
autoComplete: 'off',
|
|
2027
2045
|
autoCorrect: 'off',
|
|
2028
2046
|
autoCapitalize: 'off',
|
|
2029
|
-
enterKeyHint:
|
|
2047
|
+
enterKeyHint: enterKeyHint,
|
|
2030
2048
|
spellCheck: 'false',
|
|
2031
2049
|
autoFocus: props.autoFocus,
|
|
2032
2050
|
placeholder: props.placeholder,
|
|
@@ -2657,11 +2675,18 @@
|
|
|
2657
2675
|
|
|
2658
2676
|
/* eslint-disable */
|
|
2659
2677
|
|
|
2678
|
+
/**
|
|
2679
|
+
* Touch-specific event aliases
|
|
2680
|
+
*
|
|
2681
|
+
* See https://w3c.github.io/touch-events/#extensions-to-the-globaleventhandlers-mixin
|
|
2682
|
+
*/
|
|
2683
|
+
var TOUCH_EVENTS_ALIASES = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouchcancel'];
|
|
2660
2684
|
/*
|
|
2661
2685
|
* Taken from Preact
|
|
2662
2686
|
*
|
|
2663
2687
|
* See https://github.com/preactjs/preact/blob/6ab49d9020740127577bf4af66bf63f4af7f9fee/src/diff/props.js#L58-L151
|
|
2664
2688
|
*/
|
|
2689
|
+
|
|
2665
2690
|
function setStyle(style, key, value) {
|
|
2666
2691
|
if (value === null) {
|
|
2667
2692
|
style[key] = '';
|
|
@@ -2707,7 +2732,7 @@
|
|
|
2707
2732
|
else if (name[0] === 'o' && name[1] === 'n') {
|
|
2708
2733
|
useCapture = name !== (name = name.replace(/Capture$/, ''));
|
|
2709
2734
|
nameLower = name.toLowerCase();
|
|
2710
|
-
if (nameLower in dom) name = nameLower;
|
|
2735
|
+
if (nameLower in dom || TOUCH_EVENTS_ALIASES.includes(nameLower)) name = nameLower;
|
|
2711
2736
|
name = name.slice(2);
|
|
2712
2737
|
if (!dom._listeners) dom._listeners = {};
|
|
2713
2738
|
dom._listeners[name] = value;
|
|
@@ -2956,16 +2981,22 @@
|
|
|
2956
2981
|
textContent: placeholder
|
|
2957
2982
|
});
|
|
2958
2983
|
var detachedSearchButton = createDomElement('button', {
|
|
2984
|
+
type: 'button',
|
|
2959
2985
|
class: classNames.detachedSearchButton,
|
|
2960
|
-
onClick: function onClick(
|
|
2961
|
-
event.preventDefault();
|
|
2986
|
+
onClick: function onClick() {
|
|
2962
2987
|
setIsModalOpen(true);
|
|
2963
2988
|
},
|
|
2964
2989
|
children: [detachedSearchButtonIcon, detachedSearchButtonPlaceholder]
|
|
2965
2990
|
});
|
|
2966
2991
|
var detachedCancelButton = createDomElement('button', {
|
|
2992
|
+
type: 'button',
|
|
2967
2993
|
class: classNames.detachedCancelButton,
|
|
2968
2994
|
textContent: translations.detachedCancelButtonText,
|
|
2995
|
+
// Prevent `onTouchStart` from closing the panel
|
|
2996
|
+
// since it should be initiated by `onClick` only
|
|
2997
|
+
onTouchStart: function onTouchStart(event) {
|
|
2998
|
+
event.stopPropagation();
|
|
2999
|
+
},
|
|
2969
3000
|
onClick: function onClick() {
|
|
2970
3001
|
autocomplete.setIsOpen(false);
|
|
2971
3002
|
setIsModalOpen(false);
|