@entur/dropdown 5.2.1-beta.0 → 5.3.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/dist/dropdown.cjs.development.js +30 -35
- 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 +30 -35
- package/dist/dropdown.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/styles.css +105 -105
- package/dist/utils.d.ts +0 -5
- package/package.json +11 -11
|
@@ -500,7 +500,7 @@ var DropdownDeprecatedToggleButton = function DropdownDeprecatedToggleButton() {
|
|
|
500
500
|
'eds-dropdown__toggle-button--open': isOpen
|
|
501
501
|
})
|
|
502
502
|
}), {
|
|
503
|
-
tabIndex:
|
|
503
|
+
tabIndex: -1,
|
|
504
504
|
type: "button"
|
|
505
505
|
}), React.createElement(icons.DownArrowIcon, null));
|
|
506
506
|
};
|
|
@@ -1113,7 +1113,7 @@ var MultiSelectDeprecated = function MultiSelectDeprecated(_ref) {
|
|
|
1113
1113
|
}, React.createElement(form.BaseFormControl, {
|
|
1114
1114
|
label: label,
|
|
1115
1115
|
labelId: multiSelectId,
|
|
1116
|
-
labelProps: getLabelProps
|
|
1116
|
+
labelProps: getLabelProps,
|
|
1117
1117
|
feedback: feedback,
|
|
1118
1118
|
variant: variant,
|
|
1119
1119
|
isFilled: selectedItems.length > 0 || isOpen,
|
|
@@ -1268,19 +1268,28 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
1268
1268
|
return (selectedItem == null ? void 0 : selectedItem.value) === (item == null ? void 0 : item.value) && (selectedItem == null ? void 0 : selectedItem.label) === (item == null ? void 0 : item.label);
|
|
1269
1269
|
});
|
|
1270
1270
|
};
|
|
1271
|
-
var
|
|
1271
|
+
var ariaValuesSelectAll = function ariaValuesSelectAll() {
|
|
1272
1272
|
switch (selectAllCheckboxState == null ? void 0 : selectAllCheckboxState()) {
|
|
1273
1273
|
case 'indeterminate':
|
|
1274
1274
|
{
|
|
1275
|
-
return
|
|
1275
|
+
return {
|
|
1276
|
+
label: (selectAllItem == null ? void 0 : selectAllItem.label) + ", delvis valgt",
|
|
1277
|
+
selected: false
|
|
1278
|
+
};
|
|
1276
1279
|
}
|
|
1277
1280
|
case true:
|
|
1278
1281
|
{
|
|
1279
|
-
return
|
|
1282
|
+
return {
|
|
1283
|
+
label: (selectAllItem == null ? void 0 : selectAllItem.label) + ", " + ariaLabelChosenSingular,
|
|
1284
|
+
selected: true
|
|
1285
|
+
};
|
|
1280
1286
|
}
|
|
1281
1287
|
default:
|
|
1282
1288
|
{
|
|
1283
|
-
return
|
|
1289
|
+
return {
|
|
1290
|
+
label: "" + (selectAllItem == null ? void 0 : selectAllItem.label),
|
|
1291
|
+
selected: false
|
|
1292
|
+
};
|
|
1284
1293
|
}
|
|
1285
1294
|
}
|
|
1286
1295
|
};
|
|
@@ -1295,7 +1304,7 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
1295
1304
|
tabIndex: -1
|
|
1296
1305
|
}), React.createElement("span", {
|
|
1297
1306
|
className: "eds-dropdown__list__item__text",
|
|
1298
|
-
"aria-label":
|
|
1307
|
+
"aria-label": ariaValuesSelectAll().label
|
|
1299
1308
|
}, selectAllItem == null ? void 0 : selectAllItem.label));
|
|
1300
1309
|
};
|
|
1301
1310
|
var listItemContent = function listItemContent(item) {
|
|
@@ -1323,7 +1332,9 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
1323
1332
|
};
|
|
1324
1333
|
return (
|
|
1325
1334
|
// use popover from @entur/tooltip when that package upgrades to floating-ui
|
|
1326
|
-
React.createElement("ul", _extends({}, getMenuProps(
|
|
1335
|
+
React.createElement("ul", _extends({}, getMenuProps({
|
|
1336
|
+
'aria-multiselectable': isMultiselect
|
|
1337
|
+
}), {
|
|
1327
1338
|
className: "eds-dropdown__list",
|
|
1328
1339
|
style: _extends({
|
|
1329
1340
|
display: isOpen ? 'inline-block' : 'none'
|
|
@@ -1344,7 +1355,8 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
1344
1355
|
// here as items, it throws error when selectAllItem is a string.
|
|
1345
1356
|
// This does, however, not cause any functional issues.
|
|
1346
1357
|
item: item,
|
|
1347
|
-
index: index
|
|
1358
|
+
index: index,
|
|
1359
|
+
'aria-selected': itemIsSelectAll ? ariaValuesSelectAll().selected : isItemSelected(item)
|
|
1348
1360
|
})), itemIsSelectAll ? selectAllListItemContent() : listItemContent(item));
|
|
1349
1361
|
}), isNoMatches && React.createElement("li", {
|
|
1350
1362
|
key: "dropdown-list-no-match",
|
|
@@ -1626,17 +1638,6 @@ function getA11yRemovalMessage(options) {
|
|
|
1626
1638
|
if (removedItem.value === (selectAllItem == null ? void 0 : selectAllItem.value)) return 'Alle elementer i listen fjernet fra valgte.';
|
|
1627
1639
|
return itemToString(removedItem) + " fjernet fra valgte.";
|
|
1628
1640
|
}
|
|
1629
|
-
/**A VoiceOver click is always preformed in the center of the clicked element.
|
|
1630
|
-
This functions expolits that to check if the performed click likely is
|
|
1631
|
-
made by VoiceOver. */
|
|
1632
|
-
var isVoiceOverClick = function isVoiceOverClick(clickEvent) {
|
|
1633
|
-
var targetElementRect = clickEvent.currentTarget.getBoundingClientRect();
|
|
1634
|
-
var targetElementMiddleX = Math.floor(targetElementRect.x + targetElementRect.width / 2);
|
|
1635
|
-
var targetElementMiddleY = Math.floor(targetElementRect.y + targetElementRect.height / 2);
|
|
1636
|
-
var clickPositionX = clickEvent.clientX;
|
|
1637
|
-
var clickPositionY = clickEvent.clientY;
|
|
1638
|
-
return Math.abs(targetElementMiddleX - clickPositionX) <= 1 && Math.abs(targetElementMiddleY - clickPositionY) <= 1;
|
|
1639
|
-
};
|
|
1640
1641
|
/* end a11y utils */
|
|
1641
1642
|
|
|
1642
1643
|
var _excluded$3 = ["ariaLabelChosenSingular", "ariaLabelCloseList", "ariaLabelOpenList", "ariaLabelSelectedItem", "className", "clearable", "debounceTimeout", "disabled", "disableLabelAnimation", "feedback", "items", "itemFilter", "label", "labelClearSelectedItem", "listStyle", "loadingText", "noMatchesText", "onChange", "placeholder", "prepend", "readOnly", "selectedItem", "selectOnBlur", "selectOnTab", "style", "variant"];
|
|
@@ -1859,7 +1860,8 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1859
1860
|
"aria-hidden": "true",
|
|
1860
1861
|
onClick: function onClick() {
|
|
1861
1862
|
var _inputRef$current3;
|
|
1862
|
-
|
|
1863
|
+
(_inputRef$current3 = inputRef.current) == null ? void 0 : _inputRef$current3.focus();
|
|
1864
|
+
openMenu();
|
|
1863
1865
|
}
|
|
1864
1866
|
}, showSelectedItem ? selectedItem == null ? void 0 : selectedItem.label : ''), React.createElement("input", _extends({
|
|
1865
1867
|
className: classNames('eds-dropdown__input eds-form-control', {
|
|
@@ -1868,9 +1870,6 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1868
1870
|
disabled: readOnly || disabled,
|
|
1869
1871
|
placeholder: (_selectedItem$label = selectedItem == null ? void 0 : selectedItem.label) != null ? _selectedItem$label : placeholder
|
|
1870
1872
|
}, getInputProps({
|
|
1871
|
-
onClick: function onClick(e) {
|
|
1872
|
-
if (!isOpen && isVoiceOverClick(e)) openMenu();
|
|
1873
|
-
},
|
|
1874
1873
|
onBlur: function onBlur() {
|
|
1875
1874
|
if (selectedItem !== null) setShowSelectedItem(true);
|
|
1876
1875
|
},
|
|
@@ -1878,13 +1877,7 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1878
1877
|
setShowSelectedItem(false);
|
|
1879
1878
|
},
|
|
1880
1879
|
onKeyDown: function onKeyDown(e) {
|
|
1881
|
-
if (selectOnTab && isOpen && e.key === 'Tab')
|
|
1882
|
-
var highlitedItem = listItems[highlightedIndex];
|
|
1883
|
-
if (highlitedItem) {
|
|
1884
|
-
// we don't want to clear selection with tab
|
|
1885
|
-
onChange == null ? void 0 : onChange(highlitedItem);
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1880
|
+
if (selectOnTab && isOpen && e.key === 'Tab') onChange == null ? void 0 : onChange(listItems[highlightedIndex]);
|
|
1888
1881
|
},
|
|
1889
1882
|
ref: inputRef
|
|
1890
1883
|
})))), React.createElement(DropdownList, {
|
|
@@ -2261,9 +2254,6 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
2261
2254
|
}
|
|
2262
2255
|
}
|
|
2263
2256
|
}, getDropdownProps({
|
|
2264
|
-
onClick: function onClick(e) {
|
|
2265
|
-
if (!isOpen && isVoiceOverClick(e)) openMenu();
|
|
2266
|
-
},
|
|
2267
2257
|
preventKeyAction: isOpen,
|
|
2268
2258
|
ref: inputRef,
|
|
2269
2259
|
value: inputValue != null ? inputValue : EMPTY_INPUT
|
|
@@ -2323,6 +2313,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
2323
2313
|
var _useResolvedItems = useResolvedItems(initialItems),
|
|
2324
2314
|
normalizedItems = _useResolvedItems.items,
|
|
2325
2315
|
loading = _useResolvedItems.loading;
|
|
2316
|
+
var toggleButtonRef = React.useRef(null);
|
|
2326
2317
|
var isFilled = selectedItem !== null || placeholder !== undefined;
|
|
2327
2318
|
var _useSelect = Downshift.useSelect({
|
|
2328
2319
|
items: normalizedItems,
|
|
@@ -2336,6 +2327,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
2336
2327
|
case Downshift.useSelect.stateChangeTypes.ToggleButtonBlur:
|
|
2337
2328
|
if (!selectOnBlur) break;
|
|
2338
2329
|
case Downshift.useSelect.stateChangeTypes.ToggleButtonKeyDownEnter: // eslint-disable-line no-fallthrough
|
|
2330
|
+
case Downshift.useSelect.stateChangeTypes.ToggleButtonKeyDownSpaceButton:
|
|
2339
2331
|
case Downshift.useSelect.stateChangeTypes.ItemClick:
|
|
2340
2332
|
{
|
|
2341
2333
|
if (newSelectedItem === undefined) return;
|
|
@@ -2367,7 +2359,9 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
2367
2359
|
loading: loading,
|
|
2368
2360
|
loadingText: loadingText,
|
|
2369
2361
|
onClear: function onClear() {
|
|
2362
|
+
var _toggleButtonRef$curr;
|
|
2370
2363
|
onChange == null ? void 0 : onChange(null);
|
|
2364
|
+
(_toggleButtonRef$curr = toggleButtonRef.current) == null ? void 0 : _toggleButtonRef$curr.focus();
|
|
2371
2365
|
},
|
|
2372
2366
|
disabled: readOnly || disabled,
|
|
2373
2367
|
selectedItems: [selectedItem]
|
|
@@ -2397,7 +2391,8 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
2397
2391
|
onChange == null ? void 0 : onChange(highlitedItem);
|
|
2398
2392
|
}
|
|
2399
2393
|
}
|
|
2400
|
-
}
|
|
2394
|
+
},
|
|
2395
|
+
ref: toggleButtonRef
|
|
2401
2396
|
})), (_ref3 = (_selectedItem$label = selectedItem == null ? void 0 : selectedItem.label) != null ? _selectedItem$label : React.createElement("div", {
|
|
2402
2397
|
className: classNames('eds-dropdown__selected-item__placeholder', {
|
|
2403
2398
|
'eds-dropdown__selected-item__placeholder--readonly': readOnly
|