@entur/dropdown 5.2.1-beta.0 → 5.3.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.
- 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 +53 -53
- package/dist/utils.d.ts +0 -5
- package/package.json +11 -11
package/dist/dropdown.esm.js
CHANGED
|
@@ -496,7 +496,7 @@ var DropdownDeprecatedToggleButton = function DropdownDeprecatedToggleButton() {
|
|
|
496
496
|
'eds-dropdown__toggle-button--open': isOpen
|
|
497
497
|
})
|
|
498
498
|
}), {
|
|
499
|
-
tabIndex:
|
|
499
|
+
tabIndex: -1,
|
|
500
500
|
type: "button"
|
|
501
501
|
}), React.createElement(DownArrowIcon, null));
|
|
502
502
|
};
|
|
@@ -1109,7 +1109,7 @@ var MultiSelectDeprecated = function MultiSelectDeprecated(_ref) {
|
|
|
1109
1109
|
}, React.createElement(BaseFormControl, {
|
|
1110
1110
|
label: label,
|
|
1111
1111
|
labelId: multiSelectId,
|
|
1112
|
-
labelProps: getLabelProps
|
|
1112
|
+
labelProps: getLabelProps,
|
|
1113
1113
|
feedback: feedback,
|
|
1114
1114
|
variant: variant,
|
|
1115
1115
|
isFilled: selectedItems.length > 0 || isOpen,
|
|
@@ -1264,19 +1264,28 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
1264
1264
|
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);
|
|
1265
1265
|
});
|
|
1266
1266
|
};
|
|
1267
|
-
var
|
|
1267
|
+
var ariaValuesSelectAll = function ariaValuesSelectAll() {
|
|
1268
1268
|
switch (selectAllCheckboxState == null ? void 0 : selectAllCheckboxState()) {
|
|
1269
1269
|
case 'indeterminate':
|
|
1270
1270
|
{
|
|
1271
|
-
return
|
|
1271
|
+
return {
|
|
1272
|
+
label: (selectAllItem == null ? void 0 : selectAllItem.label) + ", delvis valgt",
|
|
1273
|
+
selected: false
|
|
1274
|
+
};
|
|
1272
1275
|
}
|
|
1273
1276
|
case true:
|
|
1274
1277
|
{
|
|
1275
|
-
return
|
|
1278
|
+
return {
|
|
1279
|
+
label: (selectAllItem == null ? void 0 : selectAllItem.label) + ", " + ariaLabelChosenSingular,
|
|
1280
|
+
selected: true
|
|
1281
|
+
};
|
|
1276
1282
|
}
|
|
1277
1283
|
default:
|
|
1278
1284
|
{
|
|
1279
|
-
return
|
|
1285
|
+
return {
|
|
1286
|
+
label: "" + (selectAllItem == null ? void 0 : selectAllItem.label),
|
|
1287
|
+
selected: false
|
|
1288
|
+
};
|
|
1280
1289
|
}
|
|
1281
1290
|
}
|
|
1282
1291
|
};
|
|
@@ -1291,7 +1300,7 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
1291
1300
|
tabIndex: -1
|
|
1292
1301
|
}), React.createElement("span", {
|
|
1293
1302
|
className: "eds-dropdown__list__item__text",
|
|
1294
|
-
"aria-label":
|
|
1303
|
+
"aria-label": ariaValuesSelectAll().label
|
|
1295
1304
|
}, selectAllItem == null ? void 0 : selectAllItem.label));
|
|
1296
1305
|
};
|
|
1297
1306
|
var listItemContent = function listItemContent(item) {
|
|
@@ -1319,7 +1328,9 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
1319
1328
|
};
|
|
1320
1329
|
return (
|
|
1321
1330
|
// use popover from @entur/tooltip when that package upgrades to floating-ui
|
|
1322
|
-
React.createElement("ul", _extends({}, getMenuProps(
|
|
1331
|
+
React.createElement("ul", _extends({}, getMenuProps({
|
|
1332
|
+
'aria-multiselectable': isMultiselect
|
|
1333
|
+
}), {
|
|
1323
1334
|
className: "eds-dropdown__list",
|
|
1324
1335
|
style: _extends({
|
|
1325
1336
|
display: isOpen ? 'inline-block' : 'none'
|
|
@@ -1340,7 +1351,8 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
1340
1351
|
// here as items, it throws error when selectAllItem is a string.
|
|
1341
1352
|
// This does, however, not cause any functional issues.
|
|
1342
1353
|
item: item,
|
|
1343
|
-
index: index
|
|
1354
|
+
index: index,
|
|
1355
|
+
'aria-selected': itemIsSelectAll ? ariaValuesSelectAll().selected : isItemSelected(item)
|
|
1344
1356
|
})), itemIsSelectAll ? selectAllListItemContent() : listItemContent(item));
|
|
1345
1357
|
}), isNoMatches && React.createElement("li", {
|
|
1346
1358
|
key: "dropdown-list-no-match",
|
|
@@ -1622,17 +1634,6 @@ function getA11yRemovalMessage(options) {
|
|
|
1622
1634
|
if (removedItem.value === (selectAllItem == null ? void 0 : selectAllItem.value)) return 'Alle elementer i listen fjernet fra valgte.';
|
|
1623
1635
|
return itemToString(removedItem) + " fjernet fra valgte.";
|
|
1624
1636
|
}
|
|
1625
|
-
/**A VoiceOver click is always preformed in the center of the clicked element.
|
|
1626
|
-
This functions expolits that to check if the performed click likely is
|
|
1627
|
-
made by VoiceOver. */
|
|
1628
|
-
var isVoiceOverClick = function isVoiceOverClick(clickEvent) {
|
|
1629
|
-
var targetElementRect = clickEvent.currentTarget.getBoundingClientRect();
|
|
1630
|
-
var targetElementMiddleX = Math.floor(targetElementRect.x + targetElementRect.width / 2);
|
|
1631
|
-
var targetElementMiddleY = Math.floor(targetElementRect.y + targetElementRect.height / 2);
|
|
1632
|
-
var clickPositionX = clickEvent.clientX;
|
|
1633
|
-
var clickPositionY = clickEvent.clientY;
|
|
1634
|
-
return Math.abs(targetElementMiddleX - clickPositionX) <= 1 && Math.abs(targetElementMiddleY - clickPositionY) <= 1;
|
|
1635
|
-
};
|
|
1636
1637
|
/* end a11y utils */
|
|
1637
1638
|
|
|
1638
1639
|
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"];
|
|
@@ -1855,7 +1856,8 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1855
1856
|
"aria-hidden": "true",
|
|
1856
1857
|
onClick: function onClick() {
|
|
1857
1858
|
var _inputRef$current3;
|
|
1858
|
-
|
|
1859
|
+
(_inputRef$current3 = inputRef.current) == null ? void 0 : _inputRef$current3.focus();
|
|
1860
|
+
openMenu();
|
|
1859
1861
|
}
|
|
1860
1862
|
}, showSelectedItem ? selectedItem == null ? void 0 : selectedItem.label : ''), React.createElement("input", _extends({
|
|
1861
1863
|
className: classNames('eds-dropdown__input eds-form-control', {
|
|
@@ -1864,9 +1866,6 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1864
1866
|
disabled: readOnly || disabled,
|
|
1865
1867
|
placeholder: (_selectedItem$label = selectedItem == null ? void 0 : selectedItem.label) != null ? _selectedItem$label : placeholder
|
|
1866
1868
|
}, getInputProps({
|
|
1867
|
-
onClick: function onClick(e) {
|
|
1868
|
-
if (!isOpen && isVoiceOverClick(e)) openMenu();
|
|
1869
|
-
},
|
|
1870
1869
|
onBlur: function onBlur() {
|
|
1871
1870
|
if (selectedItem !== null) setShowSelectedItem(true);
|
|
1872
1871
|
},
|
|
@@ -1874,13 +1873,7 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
1874
1873
|
setShowSelectedItem(false);
|
|
1875
1874
|
},
|
|
1876
1875
|
onKeyDown: function onKeyDown(e) {
|
|
1877
|
-
if (selectOnTab && isOpen && e.key === 'Tab')
|
|
1878
|
-
var highlitedItem = listItems[highlightedIndex];
|
|
1879
|
-
if (highlitedItem) {
|
|
1880
|
-
// we don't want to clear selection with tab
|
|
1881
|
-
onChange == null ? void 0 : onChange(highlitedItem);
|
|
1882
|
-
}
|
|
1883
|
-
}
|
|
1876
|
+
if (selectOnTab && isOpen && e.key === 'Tab') onChange == null ? void 0 : onChange(listItems[highlightedIndex]);
|
|
1884
1877
|
},
|
|
1885
1878
|
ref: inputRef
|
|
1886
1879
|
})))), React.createElement(DropdownList, {
|
|
@@ -2257,9 +2250,6 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
2257
2250
|
}
|
|
2258
2251
|
}
|
|
2259
2252
|
}, getDropdownProps({
|
|
2260
|
-
onClick: function onClick(e) {
|
|
2261
|
-
if (!isOpen && isVoiceOverClick(e)) openMenu();
|
|
2262
|
-
},
|
|
2263
2253
|
preventKeyAction: isOpen,
|
|
2264
2254
|
ref: inputRef,
|
|
2265
2255
|
value: inputValue != null ? inputValue : EMPTY_INPUT
|
|
@@ -2319,6 +2309,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
2319
2309
|
var _useResolvedItems = useResolvedItems(initialItems),
|
|
2320
2310
|
normalizedItems = _useResolvedItems.items,
|
|
2321
2311
|
loading = _useResolvedItems.loading;
|
|
2312
|
+
var toggleButtonRef = useRef(null);
|
|
2322
2313
|
var isFilled = selectedItem !== null || placeholder !== undefined;
|
|
2323
2314
|
var _useSelect = useSelect({
|
|
2324
2315
|
items: normalizedItems,
|
|
@@ -2332,6 +2323,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
2332
2323
|
case useSelect.stateChangeTypes.ToggleButtonBlur:
|
|
2333
2324
|
if (!selectOnBlur) break;
|
|
2334
2325
|
case useSelect.stateChangeTypes.ToggleButtonKeyDownEnter: // eslint-disable-line no-fallthrough
|
|
2326
|
+
case useSelect.stateChangeTypes.ToggleButtonKeyDownSpaceButton:
|
|
2335
2327
|
case useSelect.stateChangeTypes.ItemClick:
|
|
2336
2328
|
{
|
|
2337
2329
|
if (newSelectedItem === undefined) return;
|
|
@@ -2363,7 +2355,9 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
2363
2355
|
loading: loading,
|
|
2364
2356
|
loadingText: loadingText,
|
|
2365
2357
|
onClear: function onClear() {
|
|
2358
|
+
var _toggleButtonRef$curr;
|
|
2366
2359
|
onChange == null ? void 0 : onChange(null);
|
|
2360
|
+
(_toggleButtonRef$curr = toggleButtonRef.current) == null ? void 0 : _toggleButtonRef$curr.focus();
|
|
2367
2361
|
},
|
|
2368
2362
|
disabled: readOnly || disabled,
|
|
2369
2363
|
selectedItems: [selectedItem]
|
|
@@ -2393,7 +2387,8 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
2393
2387
|
onChange == null ? void 0 : onChange(highlitedItem);
|
|
2394
2388
|
}
|
|
2395
2389
|
}
|
|
2396
|
-
}
|
|
2390
|
+
},
|
|
2391
|
+
ref: toggleButtonRef
|
|
2397
2392
|
})), (_ref3 = (_selectedItem$label = selectedItem == null ? void 0 : selectedItem.label) != null ? _selectedItem$label : React.createElement("div", {
|
|
2398
2393
|
className: classNames('eds-dropdown__selected-item__placeholder', {
|
|
2399
2394
|
'eds-dropdown__selected-item__placeholder--readonly': readOnly
|