@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.
- package/dist/components/DropdownList.d.ts +2 -1
- package/dist/dropdown.cjs.development.js +16 -9
- 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 +16 -9
- package/dist/dropdown.esm.js.map +1 -1
- package/dist/styles.css +78 -78
- package/package.json +8 -8
|
@@ -21,6 +21,7 @@ type DropdownListProps<ValueType> = {
|
|
|
21
21
|
selectAllItem?: NormalizedDropdownItemType<string>;
|
|
22
22
|
selectedItems: NormalizedDropdownItemType<ValueType>[];
|
|
23
23
|
style?: React.CSSProperties;
|
|
24
|
+
readOnly?: boolean;
|
|
24
25
|
};
|
|
25
|
-
export declare const DropdownList: <ValueType extends unknown>({ ariaLabelChosenSingular, ariaLabelSelectedItem, getItemProps, getMenuProps, isOpen, highlightedIndex, listItems, floatingStyles, setListRef, loading, loadingText, noMatchesText, selectAllCheckboxState, selectAllItem, selectedItems, ...rest }: DropdownListProps<ValueType>) => React.JSX.Element;
|
|
26
|
+
export declare const DropdownList: <ValueType extends unknown>({ ariaLabelChosenSingular, ariaLabelSelectedItem, getItemProps, getMenuProps, isOpen, highlightedIndex, listItems, floatingStyles, setListRef, loading, loadingText, noMatchesText, selectAllCheckboxState, selectAllItem, selectedItems, readOnly, ...rest }: DropdownListProps<ValueType>) => React.JSX.Element;
|
|
26
27
|
export {};
|
|
@@ -361,7 +361,7 @@ function _regeneratorRuntime() {
|
|
|
361
361
|
}, e;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
var _excluded$5 = ["ariaLabelChosenSingular", "ariaLabelSelectedItem", "getItemProps", "getMenuProps", "isOpen", "highlightedIndex", "listItems", "floatingStyles", "setListRef", "loading", "loadingText", "noMatchesText", "selectAllCheckboxState", "selectAllItem", "selectedItems"];
|
|
364
|
+
var _excluded$5 = ["ariaLabelChosenSingular", "ariaLabelSelectedItem", "getItemProps", "getMenuProps", "isOpen", "highlightedIndex", "listItems", "floatingStyles", "setListRef", "loading", "loadingText", "noMatchesText", "selectAllCheckboxState", "selectAllItem", "selectedItems", "readOnly"];
|
|
365
365
|
var DropdownList = function DropdownList(_ref) {
|
|
366
366
|
var _listItems$;
|
|
367
367
|
var _ref$ariaLabelChosenS = _ref.ariaLabelChosenSingular,
|
|
@@ -384,6 +384,8 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
384
384
|
selectAllCheckboxState = _ref.selectAllCheckboxState,
|
|
385
385
|
selectAllItem = _ref.selectAllItem,
|
|
386
386
|
selectedItems = _ref.selectedItems,
|
|
387
|
+
_ref$readOnly = _ref.readOnly,
|
|
388
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
387
389
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
388
390
|
var isMultiselect = selectAllItem !== undefined;
|
|
389
391
|
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));
|
|
@@ -458,10 +460,10 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
458
460
|
ref: setListRef,
|
|
459
461
|
className: 'eds-dropdown__list',
|
|
460
462
|
style: _extends({}, floatingStyles, {
|
|
461
|
-
display: isOpen ? undefined : 'none'
|
|
463
|
+
display: isOpen && !readOnly ? undefined : 'none'
|
|
462
464
|
}, rest.style)
|
|
463
465
|
})), function () {
|
|
464
|
-
if (!isOpen) {
|
|
466
|
+
if (!isOpen || readOnly) {
|
|
465
467
|
return null;
|
|
466
468
|
}
|
|
467
469
|
if (loading) {
|
|
@@ -1145,7 +1147,8 @@ var SearchableDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
1145
1147
|
loading: loading != null ? loading : resolvedItemsLoading,
|
|
1146
1148
|
loadingText: loadingText,
|
|
1147
1149
|
noMatchesText: noMatchesText,
|
|
1148
|
-
selectedItems: selectedItem !== null ? [selectedItem] : []
|
|
1150
|
+
selectedItems: selectedItem !== null ? [selectedItem] : [],
|
|
1151
|
+
readOnly: readOnly
|
|
1149
1152
|
})
|
|
1150
1153
|
}, rest, {
|
|
1151
1154
|
// Append is not supported as of now
|
|
@@ -1154,8 +1157,8 @@ var SearchableDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
1154
1157
|
className: classNames('eds-dropdown--searchable__selected-item', {
|
|
1155
1158
|
'eds-dropdown--searchable__selected-item--hidden': !showSelectedItem
|
|
1156
1159
|
}),
|
|
1157
|
-
|
|
1158
|
-
|
|
1160
|
+
onClick: readOnly ? undefined : (_getInputProps2 = getInputProps()) == null ? void 0 : _getInputProps2.onClick,
|
|
1161
|
+
tabIndex: readOnly ? 0 : -1
|
|
1159
1162
|
}, showSelectedItem ? selectedItem == null ? void 0 : selectedItem.label : ''), React.createElement("input", _extends({
|
|
1160
1163
|
className: classNames('eds-dropdown__input eds-form-control', {
|
|
1161
1164
|
'eds-dropdown__input--hidden': showSelectedItem
|
|
@@ -1176,7 +1179,9 @@ var SearchableDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
1176
1179
|
if (selectedItem !== null) setShowSelectedItem(true);
|
|
1177
1180
|
},
|
|
1178
1181
|
onFocus: function onFocus() {
|
|
1179
|
-
|
|
1182
|
+
if (!readOnly) {
|
|
1183
|
+
setShowSelectedItem(false);
|
|
1184
|
+
}
|
|
1180
1185
|
},
|
|
1181
1186
|
disabled: disabled,
|
|
1182
1187
|
readOnly: readOnly,
|
|
@@ -1514,7 +1519,8 @@ var MultiSelect = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
1514
1519
|
noMatchesText: noMatchesText,
|
|
1515
1520
|
selectAllCheckboxState: selectAllCheckboxState,
|
|
1516
1521
|
selectAllItem: selectAll,
|
|
1517
|
-
selectedItems: selectedItems
|
|
1522
|
+
selectedItems: selectedItems,
|
|
1523
|
+
readOnly: readOnly
|
|
1518
1524
|
})
|
|
1519
1525
|
}, rest), React.createElement("div", {
|
|
1520
1526
|
className: classNames('eds-dropdown--multiselect__selected-items-and-input', {
|
|
@@ -1756,7 +1762,8 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
1756
1762
|
setListRef: refs.setFloating,
|
|
1757
1763
|
loading: loading != null ? loading : resolvedItemsLoading,
|
|
1758
1764
|
loadingText: loadingText,
|
|
1759
|
-
selectedItems: selectedItem !== null ? [selectedItem] : []
|
|
1765
|
+
selectedItems: selectedItem !== null ? [selectedItem] : [],
|
|
1766
|
+
readOnly: readOnly
|
|
1760
1767
|
})
|
|
1761
1768
|
}, rest, {
|
|
1762
1769
|
// Append is not supported as of now
|