@algolia/autocomplete-js 1.11.0 → 1.11.1
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/render.js
CHANGED
|
@@ -101,13 +101,12 @@ export function renderPanel(render, _ref2) {
|
|
|
101
101
|
}, propGetters.getListProps(_objectSpread({
|
|
102
102
|
state: state,
|
|
103
103
|
props: autocomplete.getListProps({
|
|
104
|
-
|
|
104
|
+
source: source
|
|
105
105
|
})
|
|
106
106
|
}, autocompleteScopeApi))), items.map(function (item) {
|
|
107
107
|
var itemProps = autocomplete.getItemProps({
|
|
108
108
|
item: item,
|
|
109
|
-
source: source
|
|
110
|
-
sourceIndex: sourceIndex
|
|
109
|
+
source: source
|
|
111
110
|
});
|
|
112
111
|
return renderer.createElement("li", _extends({
|
|
113
112
|
key: itemProps.id,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @algolia/autocomplete-js 1.11.
|
|
1
|
+
/*! @algolia/autocomplete-js 1.11.1 | 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) :
|
|
@@ -347,7 +347,7 @@
|
|
|
347
347
|
return undefined;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
var version = '1.11.
|
|
350
|
+
var version = '1.11.1';
|
|
351
351
|
|
|
352
352
|
var userAgents$1 = [{
|
|
353
353
|
segment: 'autocomplete-core',
|
|
@@ -1370,6 +1370,17 @@
|
|
|
1370
1370
|
};
|
|
1371
1371
|
}
|
|
1372
1372
|
|
|
1373
|
+
/**
|
|
1374
|
+
* Returns a full element id for an autocomplete element.
|
|
1375
|
+
*
|
|
1376
|
+
* @param autocompleteInstanceId The id of the autocomplete instance
|
|
1377
|
+
* @param elementId The specific element id
|
|
1378
|
+
* @param source The source of the element, when it needs to be scoped
|
|
1379
|
+
*/
|
|
1380
|
+
function getAutocompleteElementId(autocompleteInstanceId, elementId, source) {
|
|
1381
|
+
return [autocompleteInstanceId, source === null || source === void 0 ? void 0 : source.sourceId, elementId].filter(Boolean).join('-').replace(/\s/g, '');
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1373
1384
|
function isOrContainsNode(parent, child) {
|
|
1374
1385
|
return parent === child || parent.contains(child);
|
|
1375
1386
|
}
|
|
@@ -2358,7 +2369,8 @@
|
|
|
2358
2369
|
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
2359
2370
|
// eslint-disable-next-line no-inner-declarations
|
|
2360
2371
|
var triggerScrollIntoView = function triggerScrollIntoView() {
|
|
2361
|
-
var
|
|
2372
|
+
var highlightedItem = getActiveItem(store.getState());
|
|
2373
|
+
var nodeItem = props.environment.document.getElementById(getAutocompleteElementId(props.id, "item-".concat(store.getState().activeItemId), highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.source));
|
|
2362
2374
|
if (nodeItem) {
|
|
2363
2375
|
if (nodeItem.scrollIntoViewIfNeeded) {
|
|
2364
2376
|
nodeItem.scrollIntoViewIfNeeded(false);
|
|
@@ -2545,9 +2557,8 @@
|
|
|
2545
2557
|
_excluded2 = ["inputElement", "formElement", "panelElement"],
|
|
2546
2558
|
_excluded3 = ["inputElement"],
|
|
2547
2559
|
_excluded4 = ["inputElement", "maxLength"],
|
|
2548
|
-
_excluded5 = ["
|
|
2549
|
-
_excluded6 = ["
|
|
2550
|
-
_excluded7 = ["item", "source", "sourceIndex"];
|
|
2560
|
+
_excluded5 = ["source"],
|
|
2561
|
+
_excluded6 = ["item", "source"];
|
|
2551
2562
|
function ownKeys$6(object, enumerableOnly) {
|
|
2552
2563
|
var keys = Object.keys(object);
|
|
2553
2564
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -2692,8 +2703,11 @@
|
|
|
2692
2703
|
role: 'combobox',
|
|
2693
2704
|
'aria-expanded': store.getState().isOpen,
|
|
2694
2705
|
'aria-haspopup': 'listbox',
|
|
2695
|
-
'aria-owns': store.getState().isOpen ?
|
|
2696
|
-
|
|
2706
|
+
'aria-owns': store.getState().isOpen ? store.getState().collections.map(function (_ref2) {
|
|
2707
|
+
var source = _ref2.source;
|
|
2708
|
+
return getAutocompleteElementId(props.id, 'list', source);
|
|
2709
|
+
}).join(' ') : undefined,
|
|
2710
|
+
'aria-labelledby': getAutocompleteElementId(props.id, 'label')
|
|
2697
2711
|
}, rest);
|
|
2698
2712
|
};
|
|
2699
2713
|
var getFormProps = function getFormProps(providedProps) {
|
|
@@ -2743,22 +2757,25 @@
|
|
|
2743
2757
|
}
|
|
2744
2758
|
store.dispatch('focus', null);
|
|
2745
2759
|
}
|
|
2746
|
-
var
|
|
2747
|
-
|
|
2748
|
-
var
|
|
2749
|
-
maxLength =
|
|
2750
|
-
rest = _objectWithoutProperties$1(
|
|
2760
|
+
var _ref3 = providedProps || {};
|
|
2761
|
+
_ref3.inputElement;
|
|
2762
|
+
var _ref3$maxLength = _ref3.maxLength,
|
|
2763
|
+
maxLength = _ref3$maxLength === void 0 ? 512 : _ref3$maxLength,
|
|
2764
|
+
rest = _objectWithoutProperties$1(_ref3, _excluded4);
|
|
2751
2765
|
var activeItem = getActiveItem(store.getState());
|
|
2752
2766
|
var userAgent = ((_props$environment$na = props.environment.navigator) === null || _props$environment$na === void 0 ? void 0 : _props$environment$na.userAgent) || '';
|
|
2753
2767
|
var shouldFallbackKeyHint = isSamsung(userAgent);
|
|
2754
2768
|
var enterKeyHint = props.enterKeyHint || (activeItem !== null && activeItem !== void 0 && activeItem.itemUrl && !shouldFallbackKeyHint ? 'go' : 'search');
|
|
2755
2769
|
return _objectSpread$6({
|
|
2756
2770
|
'aria-autocomplete': 'both',
|
|
2757
|
-
'aria-activedescendant': store.getState().isOpen && store.getState().activeItemId !== null ?
|
|
2758
|
-
'aria-controls': store.getState().isOpen ?
|
|
2759
|
-
|
|
2771
|
+
'aria-activedescendant': store.getState().isOpen && store.getState().activeItemId !== null ? getAutocompleteElementId(props.id, "item-".concat(store.getState().activeItemId), activeItem === null || activeItem === void 0 ? void 0 : activeItem.source) : undefined,
|
|
2772
|
+
'aria-controls': store.getState().isOpen ? store.getState().collections.map(function (_ref4) {
|
|
2773
|
+
var source = _ref4.source;
|
|
2774
|
+
return getAutocompleteElementId(props.id, 'list', source);
|
|
2775
|
+
}).join(' ') : undefined,
|
|
2776
|
+
'aria-labelledby': getAutocompleteElementId(props.id, 'label'),
|
|
2760
2777
|
value: store.getState().completion || store.getState().query,
|
|
2761
|
-
id:
|
|
2778
|
+
id: getAutocompleteElementId(props.id, 'input'),
|
|
2762
2779
|
autoComplete: 'off',
|
|
2763
2780
|
autoCorrect: 'off',
|
|
2764
2781
|
autoCapitalize: 'off',
|
|
@@ -2804,26 +2821,20 @@
|
|
|
2804
2821
|
}
|
|
2805
2822
|
}, rest);
|
|
2806
2823
|
};
|
|
2807
|
-
var
|
|
2808
|
-
return typeof sourceId !== 'undefined' ? "".concat(instanceId, "-").concat(sourceId) : instanceId;
|
|
2809
|
-
};
|
|
2810
|
-
var getLabelProps = function getLabelProps(providedProps) {
|
|
2811
|
-
var _ref3 = providedProps || {},
|
|
2812
|
-
sourceIndex = _ref3.sourceIndex,
|
|
2813
|
-
rest = _objectWithoutProperties$1(_ref3, _excluded5);
|
|
2824
|
+
var getLabelProps = function getLabelProps(rest) {
|
|
2814
2825
|
return _objectSpread$6({
|
|
2815
|
-
htmlFor:
|
|
2816
|
-
id:
|
|
2826
|
+
htmlFor: getAutocompleteElementId(props.id, 'input'),
|
|
2827
|
+
id: getAutocompleteElementId(props.id, 'label')
|
|
2817
2828
|
}, rest);
|
|
2818
2829
|
};
|
|
2819
2830
|
var getListProps = function getListProps(providedProps) {
|
|
2820
|
-
var
|
|
2821
|
-
|
|
2822
|
-
rest = _objectWithoutProperties$1(
|
|
2831
|
+
var _ref5 = providedProps || {},
|
|
2832
|
+
source = _ref5.source,
|
|
2833
|
+
rest = _objectWithoutProperties$1(_ref5, _excluded5);
|
|
2823
2834
|
return _objectSpread$6({
|
|
2824
2835
|
role: 'listbox',
|
|
2825
|
-
'aria-labelledby':
|
|
2826
|
-
id:
|
|
2836
|
+
'aria-labelledby': getAutocompleteElementId(props.id, 'label'),
|
|
2837
|
+
id: getAutocompleteElementId(props.id, 'list', source)
|
|
2827
2838
|
}, rest);
|
|
2828
2839
|
};
|
|
2829
2840
|
var getPanelProps = function getPanelProps(rest) {
|
|
@@ -2842,10 +2853,9 @@
|
|
|
2842
2853
|
var getItemProps = function getItemProps(providedProps) {
|
|
2843
2854
|
var item = providedProps.item,
|
|
2844
2855
|
source = providedProps.source,
|
|
2845
|
-
|
|
2846
|
-
rest = _objectWithoutProperties$1(providedProps, _excluded7);
|
|
2856
|
+
rest = _objectWithoutProperties$1(providedProps, _excluded6);
|
|
2847
2857
|
return _objectSpread$6({
|
|
2848
|
-
id:
|
|
2858
|
+
id: getAutocompleteElementId(props.id, "item-".concat(item.__autocomplete_id), source),
|
|
2849
2859
|
role: 'option',
|
|
2850
2860
|
'aria-selected': store.getState().activeItemId === item.__autocomplete_id,
|
|
2851
2861
|
onMouseMove: function onMouseMove(event) {
|
|
@@ -4705,13 +4715,12 @@
|
|
|
4705
4715
|
}, propGetters.getListProps(_objectSpread2({
|
|
4706
4716
|
state: state,
|
|
4707
4717
|
props: autocomplete.getListProps({
|
|
4708
|
-
|
|
4718
|
+
source: source
|
|
4709
4719
|
})
|
|
4710
4720
|
}, autocompleteScopeApi))), items.map(function (item) {
|
|
4711
4721
|
var itemProps = autocomplete.getItemProps({
|
|
4712
4722
|
item: item,
|
|
4713
|
-
source: source
|
|
4714
|
-
sourceIndex: sourceIndex
|
|
4723
|
+
source: source
|
|
4715
4724
|
});
|
|
4716
4725
|
return renderer.createElement("li", _extends({
|
|
4717
4726
|
key: itemProps.id,
|