@entur/dropdown 5.0.18 → 5.0.20
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/dropdown.cjs.development.js +32 -25
- package/dist/dropdown.cjs.development.js.map +1 -1
- package/dist/dropdown.cjs.production.min.js +1 -1
- package/dist/dropdown.cjs.production.min.js.map +1 -1
- package/dist/dropdown.esm.js +32 -25
- package/dist/dropdown.esm.js.map +1 -1
- package/dist/styles.css +88 -87
- package/package.json +10 -10
package/dist/dropdown.esm.js
CHANGED
|
@@ -1406,13 +1406,6 @@ var FieldAppend$1 = function FieldAppend(_ref3) {
|
|
|
1406
1406
|
loadingText = _ref3$loadingText === void 0 ? 'Laster resultater …' : _ref3$loadingText,
|
|
1407
1407
|
onClear = _ref3.onClear,
|
|
1408
1408
|
selectedItems = _ref3.selectedItems;
|
|
1409
|
-
if (loading) {
|
|
1410
|
-
return React.createElement("div", {
|
|
1411
|
-
className: 'eds-dropdown__appendix__toggle-button--loading-dots'
|
|
1412
|
-
}, React.createElement(LoadingDots, {
|
|
1413
|
-
"aria-label": loadingText
|
|
1414
|
-
}));
|
|
1415
|
-
}
|
|
1416
1409
|
if (disabled) {
|
|
1417
1410
|
return null;
|
|
1418
1411
|
}
|
|
@@ -1424,14 +1417,18 @@ var FieldAppend$1 = function FieldAppend(_ref3) {
|
|
|
1424
1417
|
labelClearSelectedItems: labelClearSelectedItems
|
|
1425
1418
|
}), React.createElement("div", {
|
|
1426
1419
|
className: "eds-dropdown__appendix__divider"
|
|
1427
|
-
})), React.createElement(ToggleButton, {
|
|
1420
|
+
})), !loading ? React.createElement(ToggleButton, {
|
|
1428
1421
|
"aria-hidden": ariaHiddenToggleButton,
|
|
1429
1422
|
ariaLabelCloseList: ariaLabelCloseList,
|
|
1430
1423
|
ariaLabelOpenList: ariaLabelOpenList,
|
|
1431
1424
|
getToggleButtonProps: getToggleButtonProps,
|
|
1432
1425
|
isOpen: isOpen,
|
|
1433
1426
|
focusable: focusable
|
|
1434
|
-
})
|
|
1427
|
+
}) : React.createElement("div", {
|
|
1428
|
+
className: 'eds-dropdown__appendix__toggle-button--loading-dots'
|
|
1429
|
+
}, React.createElement(LoadingDots, {
|
|
1430
|
+
"aria-label": loadingText
|
|
1431
|
+
})));
|
|
1435
1432
|
};
|
|
1436
1433
|
var ClearableButton = function ClearableButton(_ref4) {
|
|
1437
1434
|
var onClear = _ref4.onClear,
|
|
@@ -1641,7 +1638,7 @@ var isVoiceOverClick = function isVoiceOverClick(clickEvent) {
|
|
|
1641
1638
|
|
|
1642
1639
|
var _excluded$3 = ["ariaLabelChosenSingular", "ariaLabelCloseList", "ariaLabelOpenList", "ariaLabelSelectedItem", "className", "clearable", "debounceTimeout", "disabled", "disableLabelAnimation", "feedback", "items", "itemFilter", "label", "labelClearSelectedItem", "listStyle", "loadingText", "noMatchesText", "onChange", "placeholder", "prepend", "readOnly", "selectedItem", "selectOnBlur", "selectOnTab", "style", "variant"];
|
|
1643
1640
|
var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
1644
|
-
var _selectedItem$label;
|
|
1641
|
+
var _document, _selectedItem$label;
|
|
1645
1642
|
var ariaLabelChosenSingular = _ref.ariaLabelChosenSingular,
|
|
1646
1643
|
ariaLabelCloseList = _ref.ariaLabelCloseList,
|
|
1647
1644
|
ariaLabelOpenList = _ref.ariaLabelOpenList,
|
|
@@ -1714,6 +1711,7 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1714
1711
|
inputValue: inputValue
|
|
1715
1712
|
});
|
|
1716
1713
|
}, [normalizedItems]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
1714
|
+
var inputHasFocus = typeof document !== 'undefined' ? (inputRef == null ? void 0 : inputRef.current) === ((_document = document) == null ? void 0 : _document.activeElement) : false;
|
|
1717
1715
|
var stateReducer = React.useCallback(function (_, _ref4) {
|
|
1718
1716
|
var type = _ref4.type,
|
|
1719
1717
|
changes = _ref4.changes;
|
|
@@ -1725,7 +1723,6 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1725
1723
|
case useCombobox.stateChangeTypes.ItemClick:
|
|
1726
1724
|
case useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
1727
1725
|
case useCombobox.stateChangeTypes.InputBlur:
|
|
1728
|
-
case useCombobox.stateChangeTypes.ControlledPropUpdatedSelectedItem:
|
|
1729
1726
|
{
|
|
1730
1727
|
updateListItems({
|
|
1731
1728
|
inputValue: EMPTY_INPUT
|
|
@@ -1734,6 +1731,14 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1734
1731
|
inputValue: EMPTY_INPUT
|
|
1735
1732
|
});
|
|
1736
1733
|
}
|
|
1734
|
+
case useCombobox.stateChangeTypes.ControlledPropUpdatedSelectedItem:
|
|
1735
|
+
if (!inputHasFocus) setShowSelectedItem(true);
|
|
1736
|
+
updateListItems({
|
|
1737
|
+
inputValue: EMPTY_INPUT
|
|
1738
|
+
});
|
|
1739
|
+
return _extends({}, changes, {
|
|
1740
|
+
inputValue: EMPTY_INPUT
|
|
1741
|
+
});
|
|
1737
1742
|
// remove leading whitespace, select element with spacebar on empty input, and filter list based on input
|
|
1738
1743
|
case useCombobox.stateChangeTypes.InputChange:
|
|
1739
1744
|
{
|
|
@@ -1804,11 +1809,24 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1804
1809
|
updateListItems({
|
|
1805
1810
|
inputValue: inputValue
|
|
1806
1811
|
});
|
|
1812
|
+
setShowSelectedItem(false);
|
|
1807
1813
|
};
|
|
1808
1814
|
return React.createElement("div", {
|
|
1809
1815
|
className: classNames('eds-dropdown__wrapper', className),
|
|
1810
1816
|
style: style
|
|
1811
1817
|
}, React.createElement(BaseFormControl, _extends({
|
|
1818
|
+
className: "eds-dropdown",
|
|
1819
|
+
disabled: disabled,
|
|
1820
|
+
disableLabelAnimation: disableLabelAnimation,
|
|
1821
|
+
feedback: feedback,
|
|
1822
|
+
isFilled: selectedItem !== null || inputValue !== EMPTY_INPUT,
|
|
1823
|
+
label: label,
|
|
1824
|
+
labelId: getLabelProps().id,
|
|
1825
|
+
labelProps: getLabelProps(),
|
|
1826
|
+
prepend: prepend,
|
|
1827
|
+
readOnly: readOnly,
|
|
1828
|
+
variant: variant
|
|
1829
|
+
}, rest, {
|
|
1812
1830
|
append: React.createElement(FieldAppend$1, {
|
|
1813
1831
|
ariaLabelCloseList: ariaLabelCloseList,
|
|
1814
1832
|
ariaLabelOpenList: ariaLabelOpenList,
|
|
@@ -1822,19 +1840,8 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1822
1840
|
loadingText: loadingText,
|
|
1823
1841
|
onClear: handleOnClear,
|
|
1824
1842
|
selectedItems: [selectedItem]
|
|
1825
|
-
})
|
|
1826
|
-
|
|
1827
|
-
disabled: disabled,
|
|
1828
|
-
disableLabelAnimation: disableLabelAnimation,
|
|
1829
|
-
feedback: feedback,
|
|
1830
|
-
isFilled: selectedItem !== null || inputValue !== EMPTY_INPUT,
|
|
1831
|
-
label: label,
|
|
1832
|
-
labelId: getLabelProps().id,
|
|
1833
|
-
labelProps: getLabelProps(),
|
|
1834
|
-
prepend: prepend,
|
|
1835
|
-
readOnly: readOnly,
|
|
1836
|
-
variant: variant
|
|
1837
|
-
}, rest), React.createElement("span", {
|
|
1843
|
+
})
|
|
1844
|
+
}), React.createElement("span", {
|
|
1838
1845
|
className: classNames('eds-dropdown--searchable__selected-item', {
|
|
1839
1846
|
'eds-dropdown--searchable__selected-item--hidden': !showSelectedItem
|
|
1840
1847
|
}),
|
|
@@ -1843,7 +1850,7 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1843
1850
|
var _inputRef$current2;
|
|
1844
1851
|
return (_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.focus();
|
|
1845
1852
|
}
|
|
1846
|
-
}, selectedItem == null ? void 0 : selectedItem.label), React.createElement("input", _extends({
|
|
1853
|
+
}, showSelectedItem ? selectedItem == null ? void 0 : selectedItem.label : ''), React.createElement("input", _extends({
|
|
1847
1854
|
className: classNames('eds-dropdown__input eds-form-control', {
|
|
1848
1855
|
'eds-dropdown__input--hidden': showSelectedItem
|
|
1849
1856
|
}),
|