downshift 9.0.1 → 9.0.3
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/downshift.cjs.js +9 -5
- package/dist/downshift.esm.js +9 -5
- package/dist/downshift.native.cjs.js +9 -5
- package/dist/downshift.nativeweb.cjs.js +9 -5
- package/dist/downshift.umd.js +9 -5
- package/dist/downshift.umd.js.map +1 -1
- package/dist/downshift.umd.min.js +1 -1
- package/dist/downshift.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/preact/dist/downshift.cjs.js +9 -5
- package/preact/dist/downshift.esm.js +9 -5
- package/preact/dist/downshift.umd.js +9 -5
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +1 -1
- package/preact/dist/downshift.umd.min.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "downshift",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.3",
|
|
4
4
|
"description": "🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.",
|
|
5
5
|
"main": "dist/downshift.cjs.js",
|
|
6
6
|
"react-native": "dist/downshift.native.cjs.js",
|
|
@@ -1760,6 +1760,7 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1760
1760
|
var items = props.items,
|
|
1761
1761
|
initialHighlightedIndex = props.initialHighlightedIndex,
|
|
1762
1762
|
defaultHighlightedIndex = props.defaultHighlightedIndex,
|
|
1763
|
+
isItemDisabled = props.isItemDisabled,
|
|
1763
1764
|
itemToKey = props.itemToKey;
|
|
1764
1765
|
var selectedItem = state.selectedItem,
|
|
1765
1766
|
highlightedIndex = state.highlightedIndex;
|
|
@@ -1768,10 +1769,10 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1768
1769
|
}
|
|
1769
1770
|
|
|
1770
1771
|
// initialHighlightedIndex will give value to highlightedIndex on initial state only.
|
|
1771
|
-
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex) {
|
|
1772
|
+
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex && !isItemDisabled(items[initialHighlightedIndex])) {
|
|
1772
1773
|
return initialHighlightedIndex;
|
|
1773
1774
|
}
|
|
1774
|
-
if (defaultHighlightedIndex !== undefined) {
|
|
1775
|
+
if (defaultHighlightedIndex !== undefined && !isItemDisabled(items[defaultHighlightedIndex])) {
|
|
1775
1776
|
return defaultHighlightedIndex;
|
|
1776
1777
|
}
|
|
1777
1778
|
if (selectedItem) {
|
|
@@ -1779,10 +1780,13 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1779
1780
|
return itemToKey(selectedItem) === itemToKey(item);
|
|
1780
1781
|
});
|
|
1781
1782
|
}
|
|
1782
|
-
if (offset
|
|
1783
|
-
return -1;
|
|
1783
|
+
if (offset < 0 && !isItemDisabled(items[items.length - 1])) {
|
|
1784
|
+
return items.length - 1;
|
|
1785
|
+
}
|
|
1786
|
+
if (offset > 0 && !isItemDisabled(items[0])) {
|
|
1787
|
+
return 0;
|
|
1784
1788
|
}
|
|
1785
|
-
return
|
|
1789
|
+
return -1;
|
|
1786
1790
|
}
|
|
1787
1791
|
/**
|
|
1788
1792
|
* Tracks mouse and touch events, such as mouseDown, touchMove and touchEnd.
|
|
@@ -1748,6 +1748,7 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1748
1748
|
var items = props.items,
|
|
1749
1749
|
initialHighlightedIndex = props.initialHighlightedIndex,
|
|
1750
1750
|
defaultHighlightedIndex = props.defaultHighlightedIndex,
|
|
1751
|
+
isItemDisabled = props.isItemDisabled,
|
|
1751
1752
|
itemToKey = props.itemToKey;
|
|
1752
1753
|
var selectedItem = state.selectedItem,
|
|
1753
1754
|
highlightedIndex = state.highlightedIndex;
|
|
@@ -1756,10 +1757,10 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1756
1757
|
}
|
|
1757
1758
|
|
|
1758
1759
|
// initialHighlightedIndex will give value to highlightedIndex on initial state only.
|
|
1759
|
-
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex) {
|
|
1760
|
+
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex && !isItemDisabled(items[initialHighlightedIndex])) {
|
|
1760
1761
|
return initialHighlightedIndex;
|
|
1761
1762
|
}
|
|
1762
|
-
if (defaultHighlightedIndex !== undefined) {
|
|
1763
|
+
if (defaultHighlightedIndex !== undefined && !isItemDisabled(items[defaultHighlightedIndex])) {
|
|
1763
1764
|
return defaultHighlightedIndex;
|
|
1764
1765
|
}
|
|
1765
1766
|
if (selectedItem) {
|
|
@@ -1767,10 +1768,13 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1767
1768
|
return itemToKey(selectedItem) === itemToKey(item);
|
|
1768
1769
|
});
|
|
1769
1770
|
}
|
|
1770
|
-
if (offset
|
|
1771
|
-
return -1;
|
|
1771
|
+
if (offset < 0 && !isItemDisabled(items[items.length - 1])) {
|
|
1772
|
+
return items.length - 1;
|
|
1773
|
+
}
|
|
1774
|
+
if (offset > 0 && !isItemDisabled(items[0])) {
|
|
1775
|
+
return 0;
|
|
1772
1776
|
}
|
|
1773
|
-
return
|
|
1777
|
+
return -1;
|
|
1774
1778
|
}
|
|
1775
1779
|
/**
|
|
1776
1780
|
* Tracks mouse and touch events, such as mouseDown, touchMove and touchEnd.
|
|
@@ -2024,6 +2024,7 @@
|
|
|
2024
2024
|
var items = props.items,
|
|
2025
2025
|
initialHighlightedIndex = props.initialHighlightedIndex,
|
|
2026
2026
|
defaultHighlightedIndex = props.defaultHighlightedIndex,
|
|
2027
|
+
isItemDisabled = props.isItemDisabled,
|
|
2027
2028
|
itemToKey = props.itemToKey;
|
|
2028
2029
|
var selectedItem = state.selectedItem,
|
|
2029
2030
|
highlightedIndex = state.highlightedIndex;
|
|
@@ -2032,10 +2033,10 @@
|
|
|
2032
2033
|
}
|
|
2033
2034
|
|
|
2034
2035
|
// initialHighlightedIndex will give value to highlightedIndex on initial state only.
|
|
2035
|
-
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex) {
|
|
2036
|
+
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex && !isItemDisabled(items[initialHighlightedIndex])) {
|
|
2036
2037
|
return initialHighlightedIndex;
|
|
2037
2038
|
}
|
|
2038
|
-
if (defaultHighlightedIndex !== undefined) {
|
|
2039
|
+
if (defaultHighlightedIndex !== undefined && !isItemDisabled(items[defaultHighlightedIndex])) {
|
|
2039
2040
|
return defaultHighlightedIndex;
|
|
2040
2041
|
}
|
|
2041
2042
|
if (selectedItem) {
|
|
@@ -2043,10 +2044,13 @@
|
|
|
2043
2044
|
return itemToKey(selectedItem) === itemToKey(item);
|
|
2044
2045
|
});
|
|
2045
2046
|
}
|
|
2046
|
-
if (offset
|
|
2047
|
-
return -1;
|
|
2047
|
+
if (offset < 0 && !isItemDisabled(items[items.length - 1])) {
|
|
2048
|
+
return items.length - 1;
|
|
2049
|
+
}
|
|
2050
|
+
if (offset > 0 && !isItemDisabled(items[0])) {
|
|
2051
|
+
return 0;
|
|
2048
2052
|
}
|
|
2049
|
-
return
|
|
2053
|
+
return -1;
|
|
2050
2054
|
}
|
|
2051
2055
|
/**
|
|
2052
2056
|
* Tracks mouse and touch events, such as mouseDown, touchMove and touchEnd.
|