@entur/dropdown 2.3.0 → 3.0.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/CHANGELOG.md +22 -0
- package/dist/dropdown.cjs.development.js +79 -11
- 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 +80 -12
- package/dist/dropdown.esm.js.map +1 -1
- package/dist/styles.css +100 -66
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.0.2](https://bitbucket.org/enturas/design-system/compare/@entur/dropdown@3.0.1...@entur/dropdown@3.0.2) (2022-04-20)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @entur/dropdown
|
|
9
|
+
|
|
10
|
+
## [3.0.1](https://bitbucket.org/enturas/design-system/compare/@entur/dropdown@3.0.0...@entur/dropdown@3.0.1) (2022-04-19)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @entur/dropdown
|
|
13
|
+
|
|
14
|
+
# [3.0.0](https://bitbucket.org/enturas/design-system/compare/@entur/dropdown@2.3.0...@entur/dropdown@3.0.0) (2022-03-17)
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
- **dropdown:** fix text truncate shortening words which don't need shortening ([4072480](https://bitbucket.org/enturas/design-system/commits/40724805af543369513d61c8d8d5b2461c48cc2f))
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
- **dropdown:** improve usability of input field in searchable dropdown ([9f24e4b](https://bitbucket.org/enturas/design-system/commits/9f24e4b27b64b7f637914be6715a1ff4af7c0b77))
|
|
23
|
+
|
|
24
|
+
### BREAKING CHANGES
|
|
25
|
+
|
|
26
|
+
- **dropdown:** - Visuals and interaction method have changed
|
|
27
|
+
|
|
6
28
|
# [2.3.0](https://bitbucket.org/enturas/design-system/compare/@entur/dropdown@2.2.4...@entur/dropdown@2.3.0) (2022-03-14)
|
|
7
29
|
|
|
8
30
|
### Features
|
|
@@ -87,6 +87,44 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
87
87
|
return target;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
91
|
+
if (!o) return;
|
|
92
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
93
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
94
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
95
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
96
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function _arrayLikeToArray(arr, len) {
|
|
100
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
101
|
+
|
|
102
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
103
|
+
|
|
104
|
+
return arr2;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
108
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
109
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
110
|
+
|
|
111
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
112
|
+
if (it) o = it;
|
|
113
|
+
var i = 0;
|
|
114
|
+
return function () {
|
|
115
|
+
if (i >= o.length) return {
|
|
116
|
+
done: true
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
done: false,
|
|
120
|
+
value: o[i++]
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
126
|
+
}
|
|
127
|
+
|
|
90
128
|
var _excluded$8 = ["children", "onChange", "onInputValueChange", "highlightFirstItemOnOpen", "className", "style", "searchable"];
|
|
91
129
|
var DownshiftContext = /*#__PURE__*/React__default["default"].createContext(null);
|
|
92
130
|
var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
@@ -445,8 +483,14 @@ var SearchableDropdown = /*#__PURE__*/React__default["default"].forwardRef(funct
|
|
|
445
483
|
selectHighlightedItem = _useDownshift.selectHighlightedItem,
|
|
446
484
|
isOpen = _useDownshift.isOpen,
|
|
447
485
|
openMenu = _useDownshift.openMenu,
|
|
486
|
+
closeMenu = _useDownshift.closeMenu,
|
|
448
487
|
selectedItem = _useDownshift.selectedItem;
|
|
449
488
|
|
|
489
|
+
var _useState = React.useState(false),
|
|
490
|
+
hideSelectedItem = _useState[0],
|
|
491
|
+
setHideSelectedItem = _useState[1];
|
|
492
|
+
|
|
493
|
+
var inputRef = React.useRef(null);
|
|
450
494
|
var filteredItems = React__default["default"].useMemo(function () {
|
|
451
495
|
return items.filter(function (item) {
|
|
452
496
|
return itemFilter(item, inputValue);
|
|
@@ -465,28 +509,52 @@ var SearchableDropdown = /*#__PURE__*/React__default["default"].forwardRef(funct
|
|
|
465
509
|
label: label,
|
|
466
510
|
isFilled: selectedItem ? true : false,
|
|
467
511
|
disableLabelAnimation: disableLabelAnimation
|
|
468
|
-
}, selectedItem && !inputValue && React__default["default"].createElement("span", {
|
|
469
|
-
className: "eds-dropdown__searchable-selected-
|
|
470
|
-
},
|
|
512
|
+
}, !hideSelectedItem && selectedItem && !inputValue && React__default["default"].createElement("span", {
|
|
513
|
+
className: "eds-dropdown__searchable-selected-item__wrapper"
|
|
514
|
+
}, React__default["default"].createElement("span", {
|
|
515
|
+
className: "eds-dropdown__searchable-selected-item",
|
|
516
|
+
onClick: function onClick() {
|
|
517
|
+
var _inputRef$current;
|
|
518
|
+
|
|
519
|
+
return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
520
|
+
}
|
|
521
|
+
}, selectedItem.label)), React__default["default"].createElement("input", _extends({}, getInputProps(_extends({
|
|
471
522
|
disabled: disabled,
|
|
472
523
|
readOnly: readOnly,
|
|
473
524
|
className: 'eds-form-control eds-dropdown__input',
|
|
474
525
|
onKeyDown: function onKeyDown(e) {
|
|
475
|
-
if (selectOnTab && e.key === 'Tab')
|
|
476
|
-
selectHighlightedItem();
|
|
477
|
-
}
|
|
526
|
+
if (selectOnTab && e.key === 'Tab') selectHighlightedItem();
|
|
478
527
|
},
|
|
479
528
|
onFocus: function onFocus() {
|
|
480
|
-
if (openOnFocus)
|
|
481
|
-
|
|
482
|
-
}
|
|
529
|
+
if (!isOpen && openOnFocus) openMenu();
|
|
530
|
+
setHideSelectedItem(true);
|
|
483
531
|
},
|
|
484
|
-
placeholder: selectedItem ?
|
|
532
|
+
placeholder: selectedItem ? selectedItem.label : placeholder
|
|
485
533
|
}, rest)), {
|
|
486
|
-
|
|
534
|
+
onBlur: function onBlur() {
|
|
535
|
+
setHideSelectedItem(false);
|
|
536
|
+
closeMenu();
|
|
537
|
+
},
|
|
538
|
+
ref: mergeRefs(ref, inputRef)
|
|
487
539
|
})));
|
|
488
540
|
});
|
|
489
541
|
|
|
542
|
+
var mergeRefs = function mergeRefs() {
|
|
543
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
544
|
+
refs[_key] = arguments[_key];
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
return function (node) {
|
|
548
|
+
for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
|
|
549
|
+
var ref = _step.value;
|
|
550
|
+
|
|
551
|
+
if (typeof ref === 'function') {
|
|
552
|
+
ref(node);
|
|
553
|
+
} else if (ref) ref.current = node;
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
};
|
|
557
|
+
|
|
490
558
|
var DropdownInputGroup = function DropdownInputGroup(_ref) {
|
|
491
559
|
var children = _ref.children,
|
|
492
560
|
feedback = _ref.feedback,
|