@entur/dropdown 3.0.15 → 4.0.0-beta.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/CHANGELOG.md +7 -0
- package/dist/beta/SearchableDropdown.d.ts +20 -0
- package/dist/beta/index.d.ts +1 -0
- package/dist/dropdown.cjs.development.js +224 -22
- 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 +226 -25
- package/dist/dropdown.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/styles.css +170 -13
- package/package.json +2 -2
package/dist/dropdown.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mergeRefs, debounce, useRandomId, warnAboutMissingStyles } from '@entur/utils';
|
|
2
|
-
import React, { useState, useRef } from 'react';
|
|
3
|
-
import Downshift, { useSelect } from 'downshift';
|
|
2
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
3
|
+
import Downshift, { useSelect, useCombobox } from 'downshift';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { BaseFormControl, VariantProvider, FeedbackText } from '@entur/form';
|
|
6
6
|
import { CheckIcon, DownArrowIcon, CloseSmallIcon, CloseIcon } from '@entur/icons';
|
|
@@ -77,7 +77,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
77
77
|
return target;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
var _excluded$
|
|
80
|
+
var _excluded$9 = ["children", "onChange", "onInputValueChange", "highlightFirstItemOnOpen", "className", "style", "searchable"];
|
|
81
81
|
var DownshiftContext = /*#__PURE__*/React.createContext(null);
|
|
82
82
|
var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
83
83
|
var children = _ref.children,
|
|
@@ -95,7 +95,7 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
|
95
95
|
style = _ref.style,
|
|
96
96
|
_ref$searchable = _ref.searchable,
|
|
97
97
|
searchable = _ref$searchable === void 0 ? false : _ref$searchable,
|
|
98
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
98
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$9);
|
|
99
99
|
|
|
100
100
|
var handleStateChange = function handleStateChange(changes, stateAndHelpers) {
|
|
101
101
|
if (changes.type === Downshift.stateChangeTypes.controlledPropUpdatedSelectedItem) {
|
|
@@ -165,10 +165,10 @@ var useDownshift = function useDownshift() {
|
|
|
165
165
|
return context;
|
|
166
166
|
};
|
|
167
167
|
|
|
168
|
-
var _excluded$
|
|
168
|
+
var _excluded$8 = ["items"];
|
|
169
169
|
var DropdownList = function DropdownList(_ref) {
|
|
170
170
|
var items = _ref.items,
|
|
171
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
171
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
172
172
|
|
|
173
173
|
var _useDownshift = useDownshift(),
|
|
174
174
|
highlightedIndex = _useDownshift.highlightedIndex,
|
|
@@ -218,18 +218,18 @@ var DropdownToggleButton$1 = function DropdownToggleButton() {
|
|
|
218
218
|
}), React.createElement(DownArrowIcon, null));
|
|
219
219
|
};
|
|
220
220
|
|
|
221
|
-
var _excluded$
|
|
221
|
+
var _excluded$7 = ["className", "children"];
|
|
222
222
|
var DropdownLoadingDots = function DropdownLoadingDots(_ref) {
|
|
223
223
|
var className = _ref.className,
|
|
224
224
|
children = _ref.children,
|
|
225
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
225
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
226
226
|
|
|
227
227
|
return React.createElement("div", _extends({
|
|
228
228
|
className: classNames('eds-inline-spinner', className)
|
|
229
229
|
}, rest), React.createElement(LoadingDots, null), React.createElement(VisuallyHidden, null, children));
|
|
230
230
|
};
|
|
231
231
|
|
|
232
|
-
var _excluded$
|
|
232
|
+
var _excluded$6 = ["children", "className", "items", "loading", "loadingText", "placeholder", "style", "listStyle", "clearable", "label", "isFilled", "disableLabelAnimation"];
|
|
233
233
|
var BaseDropdown = function BaseDropdown(_ref) {
|
|
234
234
|
var children = _ref.children,
|
|
235
235
|
className = _ref.className,
|
|
@@ -245,7 +245,7 @@ var BaseDropdown = function BaseDropdown(_ref) {
|
|
|
245
245
|
_ref$isFilled = _ref.isFilled,
|
|
246
246
|
isFilled = _ref$isFilled === void 0 ? false : _ref$isFilled,
|
|
247
247
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
248
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
248
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
249
249
|
|
|
250
250
|
var _useDownshift = useDownshift(),
|
|
251
251
|
getLabelProps = _useDownshift.getLabelProps;
|
|
@@ -254,7 +254,7 @@ var BaseDropdown = function BaseDropdown(_ref) {
|
|
|
254
254
|
className: "eds-dropdown-wrapper",
|
|
255
255
|
style: style
|
|
256
256
|
}, React.createElement(BaseFormControl, _extends({
|
|
257
|
-
append: React.createElement(Appendix$
|
|
257
|
+
append: React.createElement(Appendix$2, {
|
|
258
258
|
clearable: clearable,
|
|
259
259
|
loading: loading,
|
|
260
260
|
loadingText: loadingText,
|
|
@@ -293,7 +293,7 @@ var ClearButton$1 = function ClearButton(_ref2) {
|
|
|
293
293
|
}));
|
|
294
294
|
};
|
|
295
295
|
|
|
296
|
-
var Appendix$
|
|
296
|
+
var Appendix$2 = function Appendix(_ref3) {
|
|
297
297
|
var clearable = _ref3.clearable,
|
|
298
298
|
loading = _ref3.loading,
|
|
299
299
|
loadingText = _ref3.loadingText,
|
|
@@ -310,7 +310,7 @@ var Appendix$1 = function Appendix(_ref3) {
|
|
|
310
310
|
return clearable ? React.createElement(React.Fragment, null, React.createElement(ClearButton$1, null), " ", React.createElement(DropdownToggleButton$1, null)) : React.createElement(DropdownToggleButton$1, null);
|
|
311
311
|
};
|
|
312
312
|
|
|
313
|
-
var _excluded$
|
|
313
|
+
var _excluded$5 = ["disabled", "placeholder", "selectOnTab", "openOnFocus", "listStyle", "items", "label", "disableLabelAnimation", "loading", "loadingText", "className", "clearable"];
|
|
314
314
|
var RegularDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
315
315
|
var disabled = _ref.disabled,
|
|
316
316
|
_ref$placeholder = _ref.placeholder,
|
|
@@ -327,7 +327,7 @@ var RegularDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
327
327
|
loadingText = _ref.loadingText,
|
|
328
328
|
className = _ref.className,
|
|
329
329
|
clearable = _ref.clearable,
|
|
330
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
330
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
331
331
|
|
|
332
332
|
var _useDownshift = useDownshift(),
|
|
333
333
|
getToggleButtonProps = _useDownshift.getToggleButtonProps,
|
|
@@ -392,7 +392,7 @@ var RegularDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
392
392
|
}), selectedItem ? selectedItem.label : placeholder));
|
|
393
393
|
});
|
|
394
394
|
|
|
395
|
-
var _excluded$
|
|
395
|
+
var _excluded$4 = ["disabled", "className", "items", "loading", "loadingText", "readOnly", "prepend", "selectOnTab", "openOnFocus", "listStyle", "clearable", "itemFilter", "label", "disableLabelAnimation", "placeholder"];
|
|
396
396
|
|
|
397
397
|
function LowerCaseFilterTest(item, input) {
|
|
398
398
|
if (!input) {
|
|
@@ -427,7 +427,7 @@ var SearchableDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
427
427
|
label = _ref.label,
|
|
428
428
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
429
429
|
placeholder = _ref.placeholder,
|
|
430
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
430
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
431
431
|
|
|
432
432
|
var _useDownshift = useDownshift(),
|
|
433
433
|
getInputProps = _useDownshift.getInputProps,
|
|
@@ -1373,7 +1373,7 @@ debounceTimeout) {
|
|
|
1373
1373
|
};
|
|
1374
1374
|
};
|
|
1375
1375
|
|
|
1376
|
-
var _excluded$
|
|
1376
|
+
var _excluded$3 = ["highlightFirstItemOnOpen", "debounceTimeout", "disabled", "feedback", "items", "label", "loadingText", "onChange", "placeholder", "prepend", "readOnly", "searchable", "selectOnTab", "openOnFocus", "variant", "value", "clearable", "className", "style", "listStyle", "itemFilter", "disableLabelAnimation"];
|
|
1377
1377
|
var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
1378
1378
|
var highlightFirstItemOnOpen = _ref.highlightFirstItemOnOpen,
|
|
1379
1379
|
debounceTimeout = _ref.debounceTimeout,
|
|
@@ -1401,7 +1401,7 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
1401
1401
|
listStyle = _ref.listStyle,
|
|
1402
1402
|
itemFilter = _ref.itemFilter,
|
|
1403
1403
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
1404
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
1404
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
1405
1405
|
|
|
1406
1406
|
var _useResolvedItems = useResolvedItems(items, debounceTimeout),
|
|
1407
1407
|
normalizedItems = _useResolvedItems.items,
|
|
@@ -1450,7 +1450,7 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
1450
1450
|
}, searchAbleProps))));
|
|
1451
1451
|
});
|
|
1452
1452
|
|
|
1453
|
-
var _excluded$
|
|
1453
|
+
var _excluded$2 = ["className", "disabled", "readOnly", "items", "loadingText", "prepend", "style", "label", "variant", "feedback", "disableLabelAnimation"];
|
|
1454
1454
|
var NativeDropdown = function NativeDropdown(_ref) {
|
|
1455
1455
|
var className = _ref.className,
|
|
1456
1456
|
_ref$disabled = _ref.disabled,
|
|
@@ -1465,7 +1465,7 @@ var NativeDropdown = function NativeDropdown(_ref) {
|
|
|
1465
1465
|
variant = _ref.variant,
|
|
1466
1466
|
feedback = _ref.feedback,
|
|
1467
1467
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
1468
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
1468
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
1469
1469
|
|
|
1470
1470
|
var _useResolvedItems = useResolvedItems(items),
|
|
1471
1471
|
normalizedItems = _useResolvedItems.items,
|
|
@@ -1507,7 +1507,7 @@ var NativeDropdown = function NativeDropdown(_ref) {
|
|
|
1507
1507
|
})));
|
|
1508
1508
|
};
|
|
1509
1509
|
|
|
1510
|
-
var _excluded = ["items", "itemsSelectedLabel", "label", "feedback", "variant", "disabled", "readOnly", "onChange", "className", "clearable", "loading", "loadingText", "openOnFocus", "style", "listStyle", "initialSelectedItems", "debounceTimeout"];
|
|
1510
|
+
var _excluded$1 = ["items", "itemsSelectedLabel", "label", "feedback", "variant", "disabled", "readOnly", "onChange", "className", "clearable", "loading", "loadingText", "openOnFocus", "style", "listStyle", "initialSelectedItems", "debounceTimeout"];
|
|
1511
1511
|
var MultiSelectContext = /*#__PURE__*/React.createContext(null);
|
|
1512
1512
|
|
|
1513
1513
|
var useMultiSelectContext = function useMultiSelectContext() {
|
|
@@ -1569,7 +1569,7 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
1569
1569
|
_ref$initialSelectedI = _ref.initialSelectedItems,
|
|
1570
1570
|
initialSelectedItems = _ref$initialSelectedI === void 0 ? [] : _ref$initialSelectedI,
|
|
1571
1571
|
debounceTimeout = _ref.debounceTimeout,
|
|
1572
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1572
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
1573
1573
|
|
|
1574
1574
|
var _useResolvedItems = useResolvedItems(input, debounceTimeout),
|
|
1575
1575
|
items = _useResolvedItems.items;
|
|
@@ -1645,7 +1645,7 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
1645
1645
|
isFilled: selectedItems.length > 0 || isOpen,
|
|
1646
1646
|
disabled: disabled,
|
|
1647
1647
|
readOnly: readOnly,
|
|
1648
|
-
append: React.createElement(Appendix, {
|
|
1648
|
+
append: React.createElement(Appendix$1, {
|
|
1649
1649
|
hasSelected: clearable && selectedItems.length > 0,
|
|
1650
1650
|
loading: loading,
|
|
1651
1651
|
loadingText: loadingText,
|
|
@@ -1718,7 +1718,7 @@ var ClearButton = function ClearButton(_ref3) {
|
|
|
1718
1718
|
}));
|
|
1719
1719
|
};
|
|
1720
1720
|
|
|
1721
|
-
var Appendix = function Appendix(_ref4) {
|
|
1721
|
+
var Appendix$1 = function Appendix(_ref4) {
|
|
1722
1722
|
var loading = _ref4.loading,
|
|
1723
1723
|
loadingText = _ref4.loadingText,
|
|
1724
1724
|
readOnly = _ref4.readOnly,
|
|
@@ -1775,7 +1775,208 @@ function SelectedItemsLabel(items) {
|
|
|
1775
1775
|
}).toString() : items.length + " elementer valgt";
|
|
1776
1776
|
}
|
|
1777
1777
|
|
|
1778
|
+
var _excluded = ["items", "selectedItem", "onChange", "label", "placeholder", "clearable", "openOnFocus", "className", "listStyle"];
|
|
1779
|
+
|
|
1780
|
+
function lowerCaseFilterTest(item, input) {
|
|
1781
|
+
if (!input) {
|
|
1782
|
+
return true;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
var sanitizeEscapeCharacters = input.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
1786
|
+
var inputRegex = new RegExp(sanitizeEscapeCharacters, 'i');
|
|
1787
|
+
return inputRegex.test(item.label);
|
|
1788
|
+
} // TODO Husk å @deprecate searchable-prop-en til Dropdown når denne komponenten skal ha official release
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
var SearchableDropdownBeta = function SearchableDropdownBeta(_ref) {
|
|
1792
|
+
var _selectedItem$label;
|
|
1793
|
+
|
|
1794
|
+
var items = _ref.items,
|
|
1795
|
+
value = _ref.selectedItem,
|
|
1796
|
+
onChange = _ref.onChange,
|
|
1797
|
+
_ref$label = _ref.label,
|
|
1798
|
+
label = _ref$label === void 0 ? '!MANGLER LABEL!' : _ref$label,
|
|
1799
|
+
placeholder = _ref.placeholder,
|
|
1800
|
+
_ref$clearable = _ref.clearable,
|
|
1801
|
+
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
1802
|
+
_ref$openOnFocus = _ref.openOnFocus,
|
|
1803
|
+
openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
|
|
1804
|
+
className = _ref.className,
|
|
1805
|
+
listStyle = _ref.listStyle,
|
|
1806
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1807
|
+
|
|
1808
|
+
var _React$useState = React.useState(items),
|
|
1809
|
+
filteredItems = _React$useState[0],
|
|
1810
|
+
setFilteredItems = _React$useState[1];
|
|
1811
|
+
|
|
1812
|
+
var _useState = useState(false),
|
|
1813
|
+
hideSelectedItem = _useState[0],
|
|
1814
|
+
setHideSelectedItem = _useState[1];
|
|
1815
|
+
|
|
1816
|
+
var inputRef = useRef(null);
|
|
1817
|
+
var stateReducer = React.useCallback(function (_, actionAndChanges) {
|
|
1818
|
+
var type = actionAndChanges.type,
|
|
1819
|
+
changes = actionAndChanges.changes;
|
|
1820
|
+
|
|
1821
|
+
switch (type) {
|
|
1822
|
+
case useCombobox.stateChangeTypes.ItemClick:
|
|
1823
|
+
case useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
1824
|
+
case useCombobox.stateChangeTypes.InputBlur:
|
|
1825
|
+
case useCombobox.stateChangeTypes.ControlledPropUpdatedSelectedItem:
|
|
1826
|
+
return _extends({}, changes, changes.selectedItem && {
|
|
1827
|
+
inputValue: ''
|
|
1828
|
+
});
|
|
1829
|
+
|
|
1830
|
+
default:
|
|
1831
|
+
return changes;
|
|
1832
|
+
}
|
|
1833
|
+
}, []);
|
|
1834
|
+
|
|
1835
|
+
var _useCombobox = useCombobox(_extends({
|
|
1836
|
+
onInputValueChange: function onInputValueChange(_ref2) {
|
|
1837
|
+
var inputValue = _ref2.inputValue;
|
|
1838
|
+
setFilteredItems(items.filter(function (item) {
|
|
1839
|
+
return lowerCaseFilterTest(item, inputValue);
|
|
1840
|
+
}));
|
|
1841
|
+
},
|
|
1842
|
+
items: filteredItems,
|
|
1843
|
+
itemToString: function itemToString(item) {
|
|
1844
|
+
if (item) return item.value;
|
|
1845
|
+
return '';
|
|
1846
|
+
},
|
|
1847
|
+
stateReducer: stateReducer,
|
|
1848
|
+
selectedItem: value,
|
|
1849
|
+
onSelectedItemChange: function onSelectedItemChange(_ref3) {
|
|
1850
|
+
var newSelectedItem = _ref3.selectedItem;
|
|
1851
|
+
return onChange(newSelectedItem);
|
|
1852
|
+
}
|
|
1853
|
+
}, rest)),
|
|
1854
|
+
isOpen = _useCombobox.isOpen,
|
|
1855
|
+
getToggleButtonProps = _useCombobox.getToggleButtonProps,
|
|
1856
|
+
getLabelProps = _useCombobox.getLabelProps,
|
|
1857
|
+
getMenuProps = _useCombobox.getMenuProps,
|
|
1858
|
+
getInputProps = _useCombobox.getInputProps,
|
|
1859
|
+
getComboboxProps = _useCombobox.getComboboxProps,
|
|
1860
|
+
highlightedIndex = _useCombobox.highlightedIndex,
|
|
1861
|
+
getItemProps = _useCombobox.getItemProps,
|
|
1862
|
+
selectedItem = _useCombobox.selectedItem,
|
|
1863
|
+
openMenu = _useCombobox.openMenu,
|
|
1864
|
+
inputValue = _useCombobox.inputValue,
|
|
1865
|
+
setInputValue = _useCombobox.setInputValue; // TODO Husk å generelt legge inn støtte for typeof value === string
|
|
1866
|
+
|
|
1867
|
+
|
|
1868
|
+
useEffect(function () {
|
|
1869
|
+
if (inputValue.toLowerCase() === (value == null ? void 0 : value.label.toLowerCase()) || inputValue.toLowerCase() === (value == null ? void 0 : value.value.toLowerCase())) setInputValue('');
|
|
1870
|
+
}, [value]);
|
|
1871
|
+
return React.createElement("div", {
|
|
1872
|
+
className: "eds-searchable-dropdown__wrapper"
|
|
1873
|
+
}, React.createElement(BaseFormControl, _extends({
|
|
1874
|
+
append: React.createElement(Appendix, {
|
|
1875
|
+
selectedItem: selectedItem,
|
|
1876
|
+
isOpen: isOpen,
|
|
1877
|
+
clearable: clearable,
|
|
1878
|
+
loading: false,
|
|
1879
|
+
loadingText: '',
|
|
1880
|
+
readOnly: false,
|
|
1881
|
+
onChange: onChange,
|
|
1882
|
+
getToggleButtonProps: getToggleButtonProps
|
|
1883
|
+
}),
|
|
1884
|
+
className: classNames('eds-searchable-dropdown', className),
|
|
1885
|
+
label: label,
|
|
1886
|
+
isFilled: selectedItem ? true : false,
|
|
1887
|
+
labelProps: getLabelProps()
|
|
1888
|
+
}, getComboboxProps(), rest), !hideSelectedItem && selectedItem && !inputValue && React.createElement("span", {
|
|
1889
|
+
className: "eds-searchable-dropdown__selected-item__wrapper"
|
|
1890
|
+
}, React.createElement("span", {
|
|
1891
|
+
className: "eds-searchable-dropdown__selected-item",
|
|
1892
|
+
onClick: function onClick() {
|
|
1893
|
+
var _inputRef$current;
|
|
1894
|
+
|
|
1895
|
+
return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
1896
|
+
}
|
|
1897
|
+
}, selectedItem.label)), React.createElement("input", _extends({
|
|
1898
|
+
placeholder: (_selectedItem$label = selectedItem == null ? void 0 : selectedItem.label) != null ? _selectedItem$label : placeholder,
|
|
1899
|
+
className: "eds-searchable-dropdown__input eds-form-control"
|
|
1900
|
+
}, getInputProps({
|
|
1901
|
+
onFocus: function onFocus() {
|
|
1902
|
+
if (!isOpen && openOnFocus) openMenu();
|
|
1903
|
+
setHideSelectedItem(true);
|
|
1904
|
+
},
|
|
1905
|
+
onBlur: function onBlur() {
|
|
1906
|
+
setHideSelectedItem(false);
|
|
1907
|
+
},
|
|
1908
|
+
ref: inputRef
|
|
1909
|
+
})))), React.createElement("ul", _extends({
|
|
1910
|
+
className: classNames('eds-searchable-dropdown__list', {
|
|
1911
|
+
'eds-searchable-dropdown__list--open': isOpen
|
|
1912
|
+
})
|
|
1913
|
+
}, getMenuProps(), {
|
|
1914
|
+
style: _extends({}, rest.style, listStyle)
|
|
1915
|
+
}), isOpen ? filteredItems.map(function (item, index) {
|
|
1916
|
+
return (// eslint-disable-next-line react/jsx-key
|
|
1917
|
+
React.createElement("li", _extends({
|
|
1918
|
+
className: classNames('eds-searchable-dropdown__list__item', {
|
|
1919
|
+
'eds-searchable-dropdown__list__item--highlighted': highlightedIndex === index,
|
|
1920
|
+
'eds-searchable-dropdown__list__item--selected': selectedItem === item
|
|
1921
|
+
})
|
|
1922
|
+
}, getItemProps({
|
|
1923
|
+
key: "" + index + item.value,
|
|
1924
|
+
item: item,
|
|
1925
|
+
index: index
|
|
1926
|
+
})), React.createElement("span", null, item.label), item.icons && React.createElement("span", null, item.icons.map(function (Icon, index) {
|
|
1927
|
+
return React.createElement(Icon, {
|
|
1928
|
+
key: index,
|
|
1929
|
+
inline: true,
|
|
1930
|
+
className: "eds-searchable-dropdown__list__item-icon"
|
|
1931
|
+
});
|
|
1932
|
+
})), selectedItem === item && React.createElement(CheckIcon, null))
|
|
1933
|
+
);
|
|
1934
|
+
}) : null));
|
|
1935
|
+
};
|
|
1936
|
+
|
|
1937
|
+
var Appendix = function Appendix(_ref4) {
|
|
1938
|
+
var clearable = _ref4.clearable,
|
|
1939
|
+
loading = _ref4.loading,
|
|
1940
|
+
loadingText = _ref4.loadingText,
|
|
1941
|
+
readOnly = _ref4.readOnly,
|
|
1942
|
+
getToggleButtonProps = _ref4.getToggleButtonProps,
|
|
1943
|
+
selectedItem = _ref4.selectedItem,
|
|
1944
|
+
isOpen = _ref4.isOpen,
|
|
1945
|
+
onChange = _ref4.onChange;
|
|
1946
|
+
|
|
1947
|
+
if (loading) {
|
|
1948
|
+
return React.createElement(DropdownLoadingDots, null, loadingText);
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
if (readOnly) {
|
|
1952
|
+
return null;
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
return React.createElement("div", {
|
|
1956
|
+
style: {
|
|
1957
|
+
display: 'flex',
|
|
1958
|
+
alignItems: 'center'
|
|
1959
|
+
}
|
|
1960
|
+
}, clearable && selectedItem && React.createElement(React.Fragment, null, React.createElement("button", {
|
|
1961
|
+
className: "eds-searchable-dropdown__clear-button",
|
|
1962
|
+
type: "button",
|
|
1963
|
+
tabIndex: -1,
|
|
1964
|
+
onClick: function onClick() {
|
|
1965
|
+
return onChange(null);
|
|
1966
|
+
}
|
|
1967
|
+
}, React.createElement(CloseSmallIcon, null)), React.createElement("div", {
|
|
1968
|
+
className: "eds-searchable-dropdown__divider"
|
|
1969
|
+
})), React.createElement("button", _extends({}, getToggleButtonProps({
|
|
1970
|
+
className: classNames('eds-searchable-dropdown__toggle-button', {
|
|
1971
|
+
'eds-searchable-dropdown__toggle-button--open': isOpen
|
|
1972
|
+
})
|
|
1973
|
+
}), {
|
|
1974
|
+
tabIndex: "-1",
|
|
1975
|
+
type: "button"
|
|
1976
|
+
}), React.createElement(DownArrowIcon, null)));
|
|
1977
|
+
};
|
|
1978
|
+
|
|
1778
1979
|
warnAboutMissingStyles('dropdown', 'form', 'a11y', 'chip');
|
|
1779
1980
|
|
|
1780
|
-
export { Dropdown, MultiSelect, NativeDropdown };
|
|
1981
|
+
export { Dropdown, MultiSelect, NativeDropdown, SearchableDropdownBeta };
|
|
1781
1982
|
//# sourceMappingURL=dropdown.esm.js.map
|