@entur/dropdown 2.2.4 → 3.0.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 +24 -0
- package/dist/dropdown.cjs.development.js +91 -18
- 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 +92 -19
- package/dist/dropdown.esm.js.map +1 -1
- package/dist/styles.css +44 -10
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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.1](https://bitbucket.org/enturas/design-system/compare/@entur/dropdown@3.0.0...@entur/dropdown@3.0.1) (2022-04-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @entur/dropdown
|
|
9
|
+
|
|
10
|
+
# [3.0.0](https://bitbucket.org/enturas/design-system/compare/@entur/dropdown@2.3.0...@entur/dropdown@3.0.0) (2022-03-17)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **dropdown:** fix text truncate shortening words which don't need shortening ([4072480](https://bitbucket.org/enturas/design-system/commits/40724805af543369513d61c8d8d5b2461c48cc2f))
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- **dropdown:** improve usability of input field in searchable dropdown ([9f24e4b](https://bitbucket.org/enturas/design-system/commits/9f24e4b27b64b7f637914be6715a1ff4af7c0b77))
|
|
19
|
+
|
|
20
|
+
### BREAKING CHANGES
|
|
21
|
+
|
|
22
|
+
- **dropdown:** - Visuals and interaction method have changed
|
|
23
|
+
|
|
24
|
+
# [2.3.0](https://bitbucket.org/enturas/design-system/compare/@entur/dropdown@2.2.4...@entur/dropdown@2.3.0) (2022-03-14)
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
- **dropdown:** add ref forwarding to dropdown and searchable dropdown ([af4cae7](https://bitbucket.org/enturas/design-system/commits/af4cae7bb5fe83c5d1c2f58462c3ba6e77f2e1b8))
|
|
29
|
+
|
|
6
30
|
## [2.2.4](https://bitbucket.org/enturas/design-system/compare/@entur/dropdown@2.2.3...@entur/dropdown@2.2.4) (2022-03-01)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package @entur/dropdown
|
|
@@ -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) {
|
|
@@ -321,7 +359,7 @@ var Appendix$1 = function Appendix(_ref3) {
|
|
|
321
359
|
};
|
|
322
360
|
|
|
323
361
|
var _excluded$4 = ["disabled", "placeholder", "selectOnTab", "openOnFocus", "listStyle", "items", "label", "disableLabelAnimation", "loading", "loadingText", "className", "clearable"];
|
|
324
|
-
var RegularDropdown = function
|
|
362
|
+
var RegularDropdown = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
|
325
363
|
var disabled = _ref.disabled,
|
|
326
364
|
_ref$placeholder = _ref.placeholder,
|
|
327
365
|
placeholder = _ref$placeholder === void 0 ? 'Vennligst velg' : _ref$placeholder,
|
|
@@ -397,8 +435,10 @@ var RegularDropdown = function RegularDropdown(_ref) {
|
|
|
397
435
|
!isOpen && openMenu();
|
|
398
436
|
}
|
|
399
437
|
}
|
|
400
|
-
}, rest))
|
|
401
|
-
|
|
438
|
+
}, rest)), {
|
|
439
|
+
ref: ref
|
|
440
|
+
}), selectedItem ? selectedItem.label : placeholder));
|
|
441
|
+
});
|
|
402
442
|
|
|
403
443
|
var _excluded$3 = ["disabled", "className", "items", "loading", "loadingText", "readOnly", "prepend", "selectOnTab", "openOnFocus", "listStyle", "clearable", "itemFilter", "label", "disableLabelAnimation", "placeholder"];
|
|
404
444
|
|
|
@@ -412,7 +452,7 @@ function LowerCaseFilterTest(item, input) {
|
|
|
412
452
|
return inputRegex.test(item.label);
|
|
413
453
|
}
|
|
414
454
|
|
|
415
|
-
var SearchableDropdown = function
|
|
455
|
+
var SearchableDropdown = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
|
416
456
|
var _ref$disabled = _ref.disabled,
|
|
417
457
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
418
458
|
className = _ref.className,
|
|
@@ -443,8 +483,14 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
443
483
|
selectHighlightedItem = _useDownshift.selectHighlightedItem,
|
|
444
484
|
isOpen = _useDownshift.isOpen,
|
|
445
485
|
openMenu = _useDownshift.openMenu,
|
|
486
|
+
closeMenu = _useDownshift.closeMenu,
|
|
446
487
|
selectedItem = _useDownshift.selectedItem;
|
|
447
488
|
|
|
489
|
+
var _useState = React.useState(false),
|
|
490
|
+
hideSelectedItem = _useState[0],
|
|
491
|
+
setHideSelectedItem = _useState[1];
|
|
492
|
+
|
|
493
|
+
var inputRef = React.useRef(null);
|
|
448
494
|
var filteredItems = React__default["default"].useMemo(function () {
|
|
449
495
|
return items.filter(function (item) {
|
|
450
496
|
return itemFilter(item, inputValue);
|
|
@@ -463,24 +509,50 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
463
509
|
label: label,
|
|
464
510
|
isFilled: selectedItem ? true : false,
|
|
465
511
|
disableLabelAnimation: disableLabelAnimation
|
|
466
|
-
}, selectedItem && !inputValue && React__default["default"].createElement("span", {
|
|
467
|
-
className: "eds-dropdown__searchable-selected-
|
|
468
|
-
},
|
|
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({
|
|
469
522
|
disabled: disabled,
|
|
470
523
|
readOnly: readOnly,
|
|
471
524
|
className: 'eds-form-control eds-dropdown__input',
|
|
472
525
|
onKeyDown: function onKeyDown(e) {
|
|
473
|
-
if (selectOnTab && e.key === 'Tab')
|
|
474
|
-
selectHighlightedItem();
|
|
475
|
-
}
|
|
526
|
+
if (selectOnTab && e.key === 'Tab') selectHighlightedItem();
|
|
476
527
|
},
|
|
477
528
|
onFocus: function onFocus() {
|
|
478
|
-
if (openOnFocus)
|
|
479
|
-
|
|
480
|
-
}
|
|
529
|
+
if (!isOpen && openOnFocus) openMenu();
|
|
530
|
+
setHideSelectedItem(true);
|
|
481
531
|
},
|
|
482
|
-
placeholder: selectedItem ?
|
|
483
|
-
}, rest))
|
|
532
|
+
placeholder: selectedItem ? selectedItem.label : placeholder
|
|
533
|
+
}, rest)), {
|
|
534
|
+
onBlur: function onBlur() {
|
|
535
|
+
setHideSelectedItem(false);
|
|
536
|
+
closeMenu();
|
|
537
|
+
},
|
|
538
|
+
ref: mergeRefs(ref, inputRef)
|
|
539
|
+
})));
|
|
540
|
+
});
|
|
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
|
+
};
|
|
484
556
|
};
|
|
485
557
|
|
|
486
558
|
var DropdownInputGroup = function DropdownInputGroup(_ref) {
|
|
@@ -1366,7 +1438,7 @@ debounceTimeout) {
|
|
|
1366
1438
|
};
|
|
1367
1439
|
|
|
1368
1440
|
var _excluded$2 = ["highlightFirstItemOnOpen", "debounceTimeout", "disabled", "feedback", "items", "label", "loadingText", "onChange", "placeholder", "prepend", "readOnly", "searchable", "selectOnTab", "openOnFocus", "variant", "value", "clearable", "className", "style", "listStyle", "itemFilter", "disableLabelAnimation"];
|
|
1369
|
-
var Dropdown = function
|
|
1441
|
+
var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
|
1370
1442
|
var highlightFirstItemOnOpen = _ref.highlightFirstItemOnOpen,
|
|
1371
1443
|
debounceTimeout = _ref.debounceTimeout,
|
|
1372
1444
|
disabled = _ref.disabled,
|
|
@@ -1437,9 +1509,10 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
1437
1509
|
openOnFocus: openOnFocus,
|
|
1438
1510
|
listStyle: listStyle,
|
|
1439
1511
|
clearable: clearable,
|
|
1440
|
-
disableLabelAnimation: disableLabelAnimation
|
|
1512
|
+
disableLabelAnimation: disableLabelAnimation,
|
|
1513
|
+
ref: ref
|
|
1441
1514
|
}, searchAbleProps))));
|
|
1442
|
-
};
|
|
1515
|
+
});
|
|
1443
1516
|
|
|
1444
1517
|
var _excluded$1 = ["className", "disabled", "readOnly", "items", "loadingText", "prepend", "style", "label", "variant", "feedback", "disableLabelAnimation"];
|
|
1445
1518
|
var NativeDropdown = function NativeDropdown(_ref) {
|