@algolia/autocomplete-js 1.5.4 → 1.5.7

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.
@@ -142,8 +142,12 @@ export function createAutocompleteDom(_ref) {
142
142
  type: 'button',
143
143
  class: classNames.detachedCancelButton,
144
144
  textContent: translations.detachedCancelButtonText,
145
- onClick: function onClick(event) {
145
+ // Prevent `onTouchStart` from closing the panel
146
+ // since it should be initiated by `onClick` only
147
+ onTouchStart: function onTouchStart(event) {
146
148
  event.stopPropagation();
149
+ },
150
+ onClick: function onClick() {
147
151
  autocomplete.setIsOpen(false);
148
152
  setIsModalOpen(false);
149
153
  }
@@ -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.4 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
1
+ /*! @algolia/autocomplete-js 1.5.7 | 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.4';
314
+ var version = '1.5.7';
315
315
 
316
316
  var userAgents$1 = [{
317
317
  segment: 'autocomplete-core',
@@ -674,6 +674,11 @@
674
674
  return parent === child || parent.contains(child);
675
675
  }
676
676
 
677
+ var regex = /((gt|sm)-|galaxy nexus)|samsung[- ]/i;
678
+ function isSamsung(userAgent) {
679
+ return Boolean(userAgent && userAgent.match(regex));
680
+ }
681
+
677
682
  function ownKeys$e(object, enumerableOnly) {
678
683
  var keys = Object.keys(object);
679
684
 
@@ -1991,6 +1996,8 @@
1991
1996
  };
1992
1997
 
1993
1998
  var getInputProps = function getInputProps(providedProps) {
1999
+ var _props$environment$na;
2000
+
1994
2001
  function onFocus(event) {
1995
2002
  // We want to trigger a query when `openOnFocus` is true
1996
2003
  // because the panel should open with the current query.
@@ -2016,6 +2023,9 @@
2016
2023
  rest = _objectWithoutProperties$1(_ref2, _excluded4);
2017
2024
 
2018
2025
  var activeItem = getActiveItem(store.getState());
2026
+ var userAgent = (_props$environment$na = props.environment.navigator) === null || _props$environment$na === void 0 ? void 0 : _props$environment$na.userAgent;
2027
+ var shouldFallbackKeyHint = isSamsung(userAgent);
2028
+ var enterKeyHint = activeItem !== null && activeItem !== void 0 && activeItem.itemUrl && !shouldFallbackKeyHint ? 'go' : 'search';
2019
2029
  return _objectSpread$6({
2020
2030
  'aria-autocomplete': 'both',
2021
2031
  'aria-activedescendant': store.getState().isOpen && store.getState().activeItemId !== null ? "".concat(props.id, "-item-").concat(store.getState().activeItemId) : undefined,
@@ -2026,7 +2036,7 @@
2026
2036
  autoComplete: 'off',
2027
2037
  autoCorrect: 'off',
2028
2038
  autoCapitalize: 'off',
2029
- enterKeyHint: activeItem !== null && activeItem !== void 0 && activeItem.itemUrl ? 'go' : 'search',
2039
+ enterKeyHint: enterKeyHint,
2030
2040
  spellCheck: 'false',
2031
2041
  autoFocus: props.autoFocus,
2032
2042
  placeholder: props.placeholder,
@@ -2657,11 +2667,18 @@
2657
2667
 
2658
2668
  /* eslint-disable */
2659
2669
 
2670
+ /**
2671
+ * Touch-specific event aliases
2672
+ *
2673
+ * See https://w3c.github.io/touch-events/#extensions-to-the-globaleventhandlers-mixin
2674
+ */
2675
+ var TOUCH_EVENTS_ALIASES = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouchcancel'];
2660
2676
  /*
2661
2677
  * Taken from Preact
2662
2678
  *
2663
2679
  * See https://github.com/preactjs/preact/blob/6ab49d9020740127577bf4af66bf63f4af7f9fee/src/diff/props.js#L58-L151
2664
2680
  */
2681
+
2665
2682
  function setStyle(style, key, value) {
2666
2683
  if (value === null) {
2667
2684
  style[key] = '';
@@ -2707,7 +2724,7 @@
2707
2724
  else if (name[0] === 'o' && name[1] === 'n') {
2708
2725
  useCapture = name !== (name = name.replace(/Capture$/, ''));
2709
2726
  nameLower = name.toLowerCase();
2710
- if (nameLower in dom) name = nameLower;
2727
+ if (nameLower in dom || TOUCH_EVENTS_ALIASES.includes(nameLower)) name = nameLower;
2711
2728
  name = name.slice(2);
2712
2729
  if (!dom._listeners) dom._listeners = {};
2713
2730
  dom._listeners[name] = value;
@@ -2967,8 +2984,12 @@
2967
2984
  type: 'button',
2968
2985
  class: classNames.detachedCancelButton,
2969
2986
  textContent: translations.detachedCancelButtonText,
2970
- onClick: function onClick(event) {
2987
+ // Prevent `onTouchStart` from closing the panel
2988
+ // since it should be initiated by `onClick` only
2989
+ onTouchStart: function onTouchStart(event) {
2971
2990
  event.stopPropagation();
2991
+ },
2992
+ onClick: function onClick() {
2972
2993
  autocomplete.setIsOpen(false);
2973
2994
  setIsModalOpen(false);
2974
2995
  }