@entur/dropdown 5.1.2 → 5.2.0-beta.0

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.
@@ -780,6 +780,14 @@ var DropdownInputGroupDeprecated = function DropdownInputGroupDeprecated(_ref) {
780
780
  }, feedback)));
781
781
  };
782
782
 
783
+ // export type DropdownItemType<ValueType> =
784
+ // | { value?: ValueType; label: string; icons?: React.ComponentType<any>[] }
785
+ // | string;
786
+ // export type NormalizedDropdownItemType = {
787
+ // value: string | number | Record<any, any>;
788
+ // label: string;
789
+ // icons?: React.ComponentType<any>[];
790
+ // };
783
791
  var useNormalizedItems = function useNormalizedItems(items) {
784
792
  return React.useMemo(function () {
785
793
  return items.map(function (item) {
@@ -991,7 +999,7 @@ var useMultiSelectOldContext = function useMultiSelectOldContext() {
991
999
  return context;
992
1000
  };
993
1001
  function stateReducer(state,
994
- //StateChangeOptions<NormalizedDropdownItemType>,
1002
+ //StateChangeOptions<NormalizedDropdownItemDeprecatedType>,
995
1003
  actionAndChanges) {
996
1004
  var changes = actionAndChanges.changes,
997
1005
  type = actionAndChanges.type;
@@ -1334,6 +1342,9 @@ var DropdownList = function DropdownList(_ref) {
1334
1342
  })
1335
1343
  }, getItemProps({
1336
1344
  key: (item == null ? void 0 : item.label) + (item == null ? void 0 : item.value),
1345
+ // @ts-expect-error Since getItemProps expects the same item type
1346
+ // here as items, it throws error when selectAllItem is a string.
1347
+ // This does, however, not cause any functional issues.
1337
1348
  item: item,
1338
1349
  index: index
1339
1350
  })), itemIsSelectAll ? selectAllListItemContent() : listItemContent(item));
@@ -2209,7 +2220,7 @@ var MultiSelect = function MultiSelect(_ref) {
2209
2220
  disabled: disabled,
2210
2221
  getSelectedItemProps: getSelectedItemProps,
2211
2222
  index: index,
2212
- key: selectedItem == null ? void 0 : selectedItem.value,
2223
+ key: (selectedItem == null ? void 0 : selectedItem.label) + (typeof (selectedItem == null ? void 0 : selectedItem.value) === 'string' ? selectedItem.value : ''),
2213
2224
  readOnly: readOnly,
2214
2225
  removeSelectedItem: function removeSelectedItem() {
2215
2226
  var _inputRef$current6;