@entur/dropdown 7.2.1 → 7.2.2

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.
@@ -357,7 +357,7 @@ function _regeneratorRuntime() {
357
357
  }, e;
358
358
  }
359
359
 
360
- var _excluded$5 = ["ariaLabelChosenSingular", "ariaLabelSelectedItem", "getItemProps", "getMenuProps", "isOpen", "highlightedIndex", "listItems", "floatingStyles", "setListRef", "loading", "loadingText", "noMatchesText", "selectAllCheckboxState", "selectAllItem", "selectedItems"];
360
+ var _excluded$5 = ["ariaLabelChosenSingular", "ariaLabelSelectedItem", "getItemProps", "getMenuProps", "isOpen", "highlightedIndex", "listItems", "floatingStyles", "setListRef", "loading", "loadingText", "noMatchesText", "selectAllCheckboxState", "selectAllItem", "selectedItems", "readOnly"];
361
361
  var DropdownList = function DropdownList(_ref) {
362
362
  var _listItems$;
363
363
  var _ref$ariaLabelChosenS = _ref.ariaLabelChosenSingular,
@@ -380,6 +380,8 @@ var DropdownList = function DropdownList(_ref) {
380
380
  selectAllCheckboxState = _ref.selectAllCheckboxState,
381
381
  selectAllItem = _ref.selectAllItem,
382
382
  selectedItems = _ref.selectedItems,
383
+ _ref$readOnly = _ref.readOnly,
384
+ readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
383
385
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
384
386
  var isMultiselect = selectAllItem !== undefined;
385
387
  var isNoMatches = !loading && (listItems.length === 0 || (listItems == null ? void 0 : listItems.length) === 1 && (listItems == null || (_listItems$ = listItems[0]) == null ? void 0 : _listItems$.value) === (selectAllItem == null ? void 0 : selectAllItem.value));
@@ -454,10 +456,10 @@ var DropdownList = function DropdownList(_ref) {
454
456
  ref: setListRef,
455
457
  className: 'eds-dropdown__list',
456
458
  style: _extends({}, floatingStyles, {
457
- display: isOpen ? undefined : 'none'
459
+ display: isOpen && !readOnly ? undefined : 'none'
458
460
  }, rest.style)
459
461
  })), function () {
460
- if (!isOpen) {
462
+ if (!isOpen || readOnly) {
461
463
  return null;
462
464
  }
463
465
  if (loading) {
@@ -1141,7 +1143,8 @@ var SearchableDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1141
1143
  loading: loading != null ? loading : resolvedItemsLoading,
1142
1144
  loadingText: loadingText,
1143
1145
  noMatchesText: noMatchesText,
1144
- selectedItems: selectedItem !== null ? [selectedItem] : []
1146
+ selectedItems: selectedItem !== null ? [selectedItem] : [],
1147
+ readOnly: readOnly
1145
1148
  })
1146
1149
  }, rest, {
1147
1150
  // Append is not supported as of now
@@ -1150,8 +1153,8 @@ var SearchableDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1150
1153
  className: classNames('eds-dropdown--searchable__selected-item', {
1151
1154
  'eds-dropdown--searchable__selected-item--hidden': !showSelectedItem
1152
1155
  }),
1153
- "aria-hidden": "true",
1154
- onClick: (_getInputProps2 = getInputProps()) == null ? void 0 : _getInputProps2.onClick
1156
+ onClick: readOnly ? undefined : (_getInputProps2 = getInputProps()) == null ? void 0 : _getInputProps2.onClick,
1157
+ tabIndex: readOnly ? 0 : -1
1155
1158
  }, showSelectedItem ? selectedItem == null ? void 0 : selectedItem.label : ''), React.createElement("input", _extends({
1156
1159
  className: classNames('eds-dropdown__input eds-form-control', {
1157
1160
  'eds-dropdown__input--hidden': showSelectedItem
@@ -1172,7 +1175,9 @@ var SearchableDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1172
1175
  if (selectedItem !== null) setShowSelectedItem(true);
1173
1176
  },
1174
1177
  onFocus: function onFocus() {
1175
- setShowSelectedItem(false);
1178
+ if (!readOnly) {
1179
+ setShowSelectedItem(false);
1180
+ }
1176
1181
  },
1177
1182
  disabled: disabled,
1178
1183
  readOnly: readOnly,
@@ -1510,7 +1515,8 @@ var MultiSelect = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1510
1515
  noMatchesText: noMatchesText,
1511
1516
  selectAllCheckboxState: selectAllCheckboxState,
1512
1517
  selectAllItem: selectAll,
1513
- selectedItems: selectedItems
1518
+ selectedItems: selectedItems,
1519
+ readOnly: readOnly
1514
1520
  })
1515
1521
  }, rest), React.createElement("div", {
1516
1522
  className: classNames('eds-dropdown--multiselect__selected-items-and-input', {
@@ -1752,7 +1758,8 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1752
1758
  setListRef: refs.setFloating,
1753
1759
  loading: loading != null ? loading : resolvedItemsLoading,
1754
1760
  loadingText: loadingText,
1755
- selectedItems: selectedItem !== null ? [selectedItem] : []
1761
+ selectedItems: selectedItem !== null ? [selectedItem] : [],
1762
+ readOnly: readOnly
1756
1763
  })
1757
1764
  }, rest, {
1758
1765
  // Append is not supported as of now