@algolia/autocomplete-core 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.
@@ -16,7 +16,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
16
16
 
17
17
  import { onInput } from './onInput';
18
18
  import { onKeyDown as _onKeyDown } from './onKeyDown';
19
- import { getActiveItem, isOrContainsNode } from './utils';
19
+ import { getActiveItem, isOrContainsNode, isSamsung } from './utils';
20
20
  export function getPropGetters(_ref) {
21
21
  var props = _ref.props,
22
22
  refresh = _ref.refresh,
@@ -125,6 +125,8 @@ export function getPropGetters(_ref) {
125
125
  };
126
126
 
127
127
  var getInputProps = function getInputProps(providedProps) {
128
+ var _props$environment$na;
129
+
128
130
  function onFocus(event) {
129
131
  // We want to trigger a query when `openOnFocus` is true
130
132
  // because the panel should open with the current query.
@@ -150,6 +152,9 @@ export function getPropGetters(_ref) {
150
152
  rest = _objectWithoutProperties(_ref2, _excluded4);
151
153
 
152
154
  var activeItem = getActiveItem(store.getState());
155
+ var userAgent = (_props$environment$na = props.environment.navigator) === null || _props$environment$na === void 0 ? void 0 : _props$environment$na.userAgent;
156
+ var shouldFallbackKeyHint = isSamsung(userAgent);
157
+ var enterKeyHint = activeItem !== null && activeItem !== void 0 && activeItem.itemUrl && !shouldFallbackKeyHint ? 'go' : 'search';
153
158
  return _objectSpread({
154
159
  'aria-autocomplete': 'both',
155
160
  'aria-activedescendant': store.getState().isOpen && store.getState().activeItemId !== null ? "".concat(props.id, "-item-").concat(store.getState().activeItemId) : undefined,
@@ -160,7 +165,7 @@ export function getPropGetters(_ref) {
160
165
  autoComplete: 'off',
161
166
  autoCorrect: 'off',
162
167
  autoCapitalize: 'off',
163
- enterKeyHint: activeItem !== null && activeItem !== void 0 && activeItem.itemUrl ? 'go' : 'search',
168
+ enterKeyHint: enterKeyHint,
164
169
  spellCheck: 'false',
165
170
  autoFocus: props.autoFocus,
166
171
  placeholder: props.placeholder,
@@ -5,4 +5,5 @@ export * from './getNextActiveItemId';
5
5
  export * from './getNormalizedSources';
6
6
  export * from './getActiveItem';
7
7
  export * from './isOrContainsNode';
8
+ export * from './isSamsung';
8
9
  export * from './mapToAlgoliaResponse';
@@ -5,4 +5,5 @@ export * from './getNextActiveItemId';
5
5
  export * from './getNormalizedSources';
6
6
  export * from './getActiveItem';
7
7
  export * from './isOrContainsNode';
8
+ export * from './isSamsung';
8
9
  export * from './mapToAlgoliaResponse';
@@ -0,0 +1 @@
1
+ export declare function isSamsung(userAgent: string): boolean;
@@ -0,0 +1,4 @@
1
+ var regex = /((gt|sm)-|galaxy nexus)|samsung[- ]/i;
2
+ export function isSamsung(userAgent) {
3
+ return Boolean(userAgent && userAgent.match(regex));
4
+ }
@@ -1,4 +1,4 @@
1
- /*! @algolia/autocomplete-core 1.5.4 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
1
+ /*! @algolia/autocomplete-core 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) :
@@ -264,7 +264,7 @@
264
264
 
265
265
  var noop = function noop() {};
266
266
 
267
- var version = '1.5.4';
267
+ var version = '1.5.7';
268
268
 
269
269
  var userAgents = [{
270
270
  segment: 'autocomplete-core',
@@ -577,6 +577,11 @@
577
577
  return parent === child || parent.contains(child);
578
578
  }
579
579
 
580
+ var regex = /((gt|sm)-|galaxy nexus)|samsung[- ]/i;
581
+ function isSamsung(userAgent) {
582
+ return Boolean(userAgent && userAgent.match(regex));
583
+ }
584
+
580
585
  function mapToAlgoliaResponse(rawResults) {
581
586
  var results = rawResults.map(function (result) {
582
587
  var _hits;
@@ -1340,6 +1345,8 @@
1340
1345
  };
1341
1346
 
1342
1347
  var getInputProps = function getInputProps(providedProps) {
1348
+ var _props$environment$na;
1349
+
1343
1350
  function onFocus(event) {
1344
1351
  // We want to trigger a query when `openOnFocus` is true
1345
1352
  // because the panel should open with the current query.
@@ -1365,6 +1372,9 @@
1365
1372
  rest = _objectWithoutProperties(_ref2, _excluded4);
1366
1373
 
1367
1374
  var activeItem = getActiveItem(store.getState());
1375
+ var userAgent = (_props$environment$na = props.environment.navigator) === null || _props$environment$na === void 0 ? void 0 : _props$environment$na.userAgent;
1376
+ var shouldFallbackKeyHint = isSamsung(userAgent);
1377
+ var enterKeyHint = activeItem !== null && activeItem !== void 0 && activeItem.itemUrl && !shouldFallbackKeyHint ? 'go' : 'search';
1368
1378
  return _objectSpread2({
1369
1379
  'aria-autocomplete': 'both',
1370
1380
  'aria-activedescendant': store.getState().isOpen && store.getState().activeItemId !== null ? "".concat(props.id, "-item-").concat(store.getState().activeItemId) : undefined,
@@ -1375,7 +1385,7 @@
1375
1385
  autoComplete: 'off',
1376
1386
  autoCorrect: 'off',
1377
1387
  autoCapitalize: 'off',
1378
- enterKeyHint: activeItem !== null && activeItem !== void 0 && activeItem.itemUrl ? 'go' : 'search',
1388
+ enterKeyHint: enterKeyHint,
1379
1389
  spellCheck: 'false',
1380
1390
  autoFocus: props.autoFocus,
1381
1391
  placeholder: props.placeholder,