@react-aria/selection 3.18.0 → 3.18.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/ListKeyboardDelegate.main.js +23 -23
- package/dist/ListKeyboardDelegate.mjs +24 -24
- package/dist/ListKeyboardDelegate.module.js +23 -23
- package/dist/useSelectableCollection.main.js +30 -30
- package/dist/useSelectableCollection.mjs +31 -31
- package/dist/useSelectableCollection.module.js +30 -30
- package/dist/useSelectableItem.main.js +25 -25
- package/dist/useSelectableItem.mjs +26 -26
- package/dist/useSelectableItem.module.js +25 -25
- package/dist/useSelectableList.main.js +2 -2
- package/dist/useSelectableList.mjs +3 -3
- package/dist/useSelectableList.module.js +2 -2
- package/dist/useTypeSelect.main.js +5 -5
- package/dist/useTypeSelect.mjs +6 -6
- package/dist/useTypeSelect.module.js +5 -5
- package/dist/utils.mjs +1 -1
- package/package.json +8 -8
|
@@ -20,13 +20,13 @@ $parcel$export(module.exports, "ListKeyboardDelegate", () => $836f880b12dcae5c$e
|
|
|
20
20
|
class $836f880b12dcae5c$export$a05409b8bb224a5a {
|
|
21
21
|
isDisabled(item) {
|
|
22
22
|
var _item_props;
|
|
23
|
-
return this.disabledBehavior ===
|
|
23
|
+
return this.disabledBehavior === 'all' && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
|
|
24
24
|
}
|
|
25
25
|
getNextKey(key) {
|
|
26
26
|
key = this.collection.getKeyAfter(key);
|
|
27
27
|
while(key != null){
|
|
28
28
|
let item = this.collection.getItem(key);
|
|
29
|
-
if (item.type ===
|
|
29
|
+
if (item.type === 'item' && !this.isDisabled(item)) return key;
|
|
30
30
|
key = this.collection.getKeyAfter(key);
|
|
31
31
|
}
|
|
32
32
|
return null;
|
|
@@ -35,7 +35,7 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
|
|
|
35
35
|
key = this.collection.getKeyBefore(key);
|
|
36
36
|
while(key != null){
|
|
37
37
|
let item = this.collection.getItem(key);
|
|
38
|
-
if (item.type ===
|
|
38
|
+
if (item.type === 'item' && !this.isDisabled(item)) return key;
|
|
39
39
|
key = this.collection.getKeyBefore(key);
|
|
40
40
|
}
|
|
41
41
|
return null;
|
|
@@ -58,35 +58,35 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
|
|
|
58
58
|
return prevRect.left === itemRect.left || prevRect.top !== itemRect.top;
|
|
59
59
|
}
|
|
60
60
|
getKeyBelow(key) {
|
|
61
|
-
if (this.layout ===
|
|
61
|
+
if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getNextKey(key), this.isSameRow);
|
|
62
62
|
else return this.getNextKey(key);
|
|
63
63
|
}
|
|
64
64
|
getKeyAbove(key) {
|
|
65
|
-
if (this.layout ===
|
|
65
|
+
if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getPreviousKey(key), this.isSameRow);
|
|
66
66
|
else return this.getPreviousKey(key);
|
|
67
67
|
}
|
|
68
68
|
getNextColumn(key, right) {
|
|
69
69
|
return right ? this.getPreviousKey(key) : this.getNextKey(key);
|
|
70
70
|
}
|
|
71
71
|
getKeyRightOf(key) {
|
|
72
|
-
if (this.layout ===
|
|
73
|
-
if (this.orientation ===
|
|
74
|
-
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction ===
|
|
75
|
-
} else if (this.orientation ===
|
|
72
|
+
if (this.layout === 'grid') {
|
|
73
|
+
if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'rtl');
|
|
74
|
+
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'rtl'), this.isSameColumn);
|
|
75
|
+
} else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'rtl');
|
|
76
76
|
return null;
|
|
77
77
|
}
|
|
78
78
|
getKeyLeftOf(key) {
|
|
79
|
-
if (this.layout ===
|
|
80
|
-
if (this.orientation ===
|
|
81
|
-
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction ===
|
|
82
|
-
} else if (this.orientation ===
|
|
79
|
+
if (this.layout === 'grid') {
|
|
80
|
+
if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'ltr');
|
|
81
|
+
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'ltr'), this.isSameColumn);
|
|
82
|
+
} else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'ltr');
|
|
83
83
|
return null;
|
|
84
84
|
}
|
|
85
85
|
getFirstKey() {
|
|
86
86
|
let key = this.collection.getFirstKey();
|
|
87
87
|
while(key != null){
|
|
88
88
|
let item = this.collection.getItem(key);
|
|
89
|
-
if ((item === null || item === void 0 ? void 0 : item.type) ===
|
|
89
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return key;
|
|
90
90
|
key = this.collection.getKeyAfter(key);
|
|
91
91
|
}
|
|
92
92
|
return null;
|
|
@@ -95,7 +95,7 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
|
|
|
95
95
|
let key = this.collection.getLastKey();
|
|
96
96
|
while(key != null){
|
|
97
97
|
let item = this.collection.getItem(key);
|
|
98
|
-
if (item.type ===
|
|
98
|
+
if (item.type === 'item' && !this.isDisabled(item)) return key;
|
|
99
99
|
key = this.collection.getKeyBefore(key);
|
|
100
100
|
}
|
|
101
101
|
return null;
|
|
@@ -110,7 +110,7 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
|
|
|
110
110
|
if (!(0, $doKEG$reactariautils.isScrollable)(menu)) return this.getFirstKey();
|
|
111
111
|
let containerRect = menu.getBoundingClientRect();
|
|
112
112
|
let itemRect = item.getBoundingClientRect();
|
|
113
|
-
if (this.orientation ===
|
|
113
|
+
if (this.orientation === 'horizontal') {
|
|
114
114
|
let containerX = containerRect.x - menu.scrollLeft;
|
|
115
115
|
let pageX = Math.max(0, itemRect.x - containerX + itemRect.width - containerRect.width);
|
|
116
116
|
while(item && itemRect.x - containerX > pageX){
|
|
@@ -136,7 +136,7 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
|
|
|
136
136
|
if (!(0, $doKEG$reactariautils.isScrollable)(menu)) return this.getLastKey();
|
|
137
137
|
let containerRect = menu.getBoundingClientRect();
|
|
138
138
|
let itemRect = item.getBoundingClientRect();
|
|
139
|
-
if (this.orientation ===
|
|
139
|
+
if (this.orientation === 'horizontal') {
|
|
140
140
|
let containerX = containerRect.x - menu.scrollLeft;
|
|
141
141
|
let pageX = Math.min(menu.scrollWidth, itemRect.x - containerX - itemRect.width + containerRect.width);
|
|
142
142
|
while(item && itemRect.x - containerX < pageX){
|
|
@@ -174,22 +174,22 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
|
|
|
174
174
|
this.ref = opts.ref;
|
|
175
175
|
this.collator = opts.collator;
|
|
176
176
|
this.disabledKeys = opts.disabledKeys || new Set();
|
|
177
|
-
this.disabledBehavior = opts.disabledBehavior ||
|
|
177
|
+
this.disabledBehavior = opts.disabledBehavior || 'all';
|
|
178
178
|
this.orientation = opts.orientation;
|
|
179
179
|
this.direction = opts.direction;
|
|
180
|
-
this.layout = opts.layout ||
|
|
180
|
+
this.layout = opts.layout || 'stack';
|
|
181
181
|
} else {
|
|
182
182
|
this.collection = args[0];
|
|
183
183
|
this.disabledKeys = args[1];
|
|
184
184
|
this.ref = args[2];
|
|
185
185
|
this.collator = args[3];
|
|
186
|
-
this.layout =
|
|
187
|
-
this.orientation =
|
|
188
|
-
this.disabledBehavior =
|
|
186
|
+
this.layout = 'stack';
|
|
187
|
+
this.orientation = 'vertical';
|
|
188
|
+
this.disabledBehavior = 'all';
|
|
189
189
|
}
|
|
190
190
|
// If this is a vertical stack, remove the left/right methods completely
|
|
191
191
|
// so they aren't called by useDroppableCollection.
|
|
192
|
-
if (this.layout ===
|
|
192
|
+
if (this.layout === 'stack' && this.orientation === 'vertical') {
|
|
193
193
|
this.getKeyLeftOf = undefined;
|
|
194
194
|
this.getKeyRightOf = undefined;
|
|
195
195
|
}
|
|
@@ -14,13 +14,13 @@ import {isScrollable as $eak97$isScrollable} from "@react-aria/utils";
|
|
|
14
14
|
class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
15
15
|
isDisabled(item) {
|
|
16
16
|
var _item_props;
|
|
17
|
-
return this.disabledBehavior ===
|
|
17
|
+
return this.disabledBehavior === 'all' && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
|
|
18
18
|
}
|
|
19
19
|
getNextKey(key) {
|
|
20
20
|
key = this.collection.getKeyAfter(key);
|
|
21
21
|
while(key != null){
|
|
22
22
|
let item = this.collection.getItem(key);
|
|
23
|
-
if (item.type ===
|
|
23
|
+
if (item.type === 'item' && !this.isDisabled(item)) return key;
|
|
24
24
|
key = this.collection.getKeyAfter(key);
|
|
25
25
|
}
|
|
26
26
|
return null;
|
|
@@ -29,7 +29,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
29
29
|
key = this.collection.getKeyBefore(key);
|
|
30
30
|
while(key != null){
|
|
31
31
|
let item = this.collection.getItem(key);
|
|
32
|
-
if (item.type ===
|
|
32
|
+
if (item.type === 'item' && !this.isDisabled(item)) return key;
|
|
33
33
|
key = this.collection.getKeyBefore(key);
|
|
34
34
|
}
|
|
35
35
|
return null;
|
|
@@ -52,35 +52,35 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
52
52
|
return prevRect.left === itemRect.left || prevRect.top !== itemRect.top;
|
|
53
53
|
}
|
|
54
54
|
getKeyBelow(key) {
|
|
55
|
-
if (this.layout ===
|
|
55
|
+
if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getNextKey(key), this.isSameRow);
|
|
56
56
|
else return this.getNextKey(key);
|
|
57
57
|
}
|
|
58
58
|
getKeyAbove(key) {
|
|
59
|
-
if (this.layout ===
|
|
59
|
+
if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getPreviousKey(key), this.isSameRow);
|
|
60
60
|
else return this.getPreviousKey(key);
|
|
61
61
|
}
|
|
62
62
|
getNextColumn(key, right) {
|
|
63
63
|
return right ? this.getPreviousKey(key) : this.getNextKey(key);
|
|
64
64
|
}
|
|
65
65
|
getKeyRightOf(key) {
|
|
66
|
-
if (this.layout ===
|
|
67
|
-
if (this.orientation ===
|
|
68
|
-
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction ===
|
|
69
|
-
} else if (this.orientation ===
|
|
66
|
+
if (this.layout === 'grid') {
|
|
67
|
+
if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'rtl');
|
|
68
|
+
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'rtl'), this.isSameColumn);
|
|
69
|
+
} else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'rtl');
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
72
|
getKeyLeftOf(key) {
|
|
73
|
-
if (this.layout ===
|
|
74
|
-
if (this.orientation ===
|
|
75
|
-
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction ===
|
|
76
|
-
} else if (this.orientation ===
|
|
73
|
+
if (this.layout === 'grid') {
|
|
74
|
+
if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'ltr');
|
|
75
|
+
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'ltr'), this.isSameColumn);
|
|
76
|
+
} else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'ltr');
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
79
|
getFirstKey() {
|
|
80
80
|
let key = this.collection.getFirstKey();
|
|
81
81
|
while(key != null){
|
|
82
82
|
let item = this.collection.getItem(key);
|
|
83
|
-
if ((item === null || item === void 0 ? void 0 : item.type) ===
|
|
83
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return key;
|
|
84
84
|
key = this.collection.getKeyAfter(key);
|
|
85
85
|
}
|
|
86
86
|
return null;
|
|
@@ -89,7 +89,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
89
89
|
let key = this.collection.getLastKey();
|
|
90
90
|
while(key != null){
|
|
91
91
|
let item = this.collection.getItem(key);
|
|
92
|
-
if (item.type ===
|
|
92
|
+
if (item.type === 'item' && !this.isDisabled(item)) return key;
|
|
93
93
|
key = this.collection.getKeyBefore(key);
|
|
94
94
|
}
|
|
95
95
|
return null;
|
|
@@ -104,7 +104,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
104
104
|
if (!(0, $eak97$isScrollable)(menu)) return this.getFirstKey();
|
|
105
105
|
let containerRect = menu.getBoundingClientRect();
|
|
106
106
|
let itemRect = item.getBoundingClientRect();
|
|
107
|
-
if (this.orientation ===
|
|
107
|
+
if (this.orientation === 'horizontal') {
|
|
108
108
|
let containerX = containerRect.x - menu.scrollLeft;
|
|
109
109
|
let pageX = Math.max(0, itemRect.x - containerX + itemRect.width - containerRect.width);
|
|
110
110
|
while(item && itemRect.x - containerX > pageX){
|
|
@@ -130,7 +130,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
130
130
|
if (!(0, $eak97$isScrollable)(menu)) return this.getLastKey();
|
|
131
131
|
let containerRect = menu.getBoundingClientRect();
|
|
132
132
|
let itemRect = item.getBoundingClientRect();
|
|
133
|
-
if (this.orientation ===
|
|
133
|
+
if (this.orientation === 'horizontal') {
|
|
134
134
|
let containerX = containerRect.x - menu.scrollLeft;
|
|
135
135
|
let pageX = Math.min(menu.scrollWidth, itemRect.x - containerX - itemRect.width + containerRect.width);
|
|
136
136
|
while(item && itemRect.x - containerX < pageX){
|
|
@@ -168,22 +168,22 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
168
168
|
this.ref = opts.ref;
|
|
169
169
|
this.collator = opts.collator;
|
|
170
170
|
this.disabledKeys = opts.disabledKeys || new Set();
|
|
171
|
-
this.disabledBehavior = opts.disabledBehavior ||
|
|
171
|
+
this.disabledBehavior = opts.disabledBehavior || 'all';
|
|
172
172
|
this.orientation = opts.orientation;
|
|
173
173
|
this.direction = opts.direction;
|
|
174
|
-
this.layout = opts.layout ||
|
|
174
|
+
this.layout = opts.layout || 'stack';
|
|
175
175
|
} else {
|
|
176
176
|
this.collection = args[0];
|
|
177
177
|
this.disabledKeys = args[1];
|
|
178
178
|
this.ref = args[2];
|
|
179
179
|
this.collator = args[3];
|
|
180
|
-
this.layout =
|
|
181
|
-
this.orientation =
|
|
182
|
-
this.disabledBehavior =
|
|
180
|
+
this.layout = 'stack';
|
|
181
|
+
this.orientation = 'vertical';
|
|
182
|
+
this.disabledBehavior = 'all';
|
|
183
183
|
}
|
|
184
184
|
// If this is a vertical stack, remove the left/right methods completely
|
|
185
185
|
// so they aren't called by useDroppableCollection.
|
|
186
|
-
if (this.layout ===
|
|
186
|
+
if (this.layout === 'stack' && this.orientation === 'vertical') {
|
|
187
187
|
this.getKeyLeftOf = undefined;
|
|
188
188
|
this.getKeyRightOf = undefined;
|
|
189
189
|
}
|
|
@@ -192,4 +192,4 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
192
192
|
|
|
193
193
|
|
|
194
194
|
export {$2a25aae57d74318e$export$a05409b8bb224a5a as ListKeyboardDelegate};
|
|
195
|
-
//# sourceMappingURL=ListKeyboardDelegate.
|
|
195
|
+
//# sourceMappingURL=ListKeyboardDelegate.module.js.map
|
|
@@ -14,13 +14,13 @@ import {isScrollable as $eak97$isScrollable} from "@react-aria/utils";
|
|
|
14
14
|
class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
15
15
|
isDisabled(item) {
|
|
16
16
|
var _item_props;
|
|
17
|
-
return this.disabledBehavior ===
|
|
17
|
+
return this.disabledBehavior === 'all' && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
|
|
18
18
|
}
|
|
19
19
|
getNextKey(key) {
|
|
20
20
|
key = this.collection.getKeyAfter(key);
|
|
21
21
|
while(key != null){
|
|
22
22
|
let item = this.collection.getItem(key);
|
|
23
|
-
if (item.type ===
|
|
23
|
+
if (item.type === 'item' && !this.isDisabled(item)) return key;
|
|
24
24
|
key = this.collection.getKeyAfter(key);
|
|
25
25
|
}
|
|
26
26
|
return null;
|
|
@@ -29,7 +29,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
29
29
|
key = this.collection.getKeyBefore(key);
|
|
30
30
|
while(key != null){
|
|
31
31
|
let item = this.collection.getItem(key);
|
|
32
|
-
if (item.type ===
|
|
32
|
+
if (item.type === 'item' && !this.isDisabled(item)) return key;
|
|
33
33
|
key = this.collection.getKeyBefore(key);
|
|
34
34
|
}
|
|
35
35
|
return null;
|
|
@@ -52,35 +52,35 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
52
52
|
return prevRect.left === itemRect.left || prevRect.top !== itemRect.top;
|
|
53
53
|
}
|
|
54
54
|
getKeyBelow(key) {
|
|
55
|
-
if (this.layout ===
|
|
55
|
+
if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getNextKey(key), this.isSameRow);
|
|
56
56
|
else return this.getNextKey(key);
|
|
57
57
|
}
|
|
58
58
|
getKeyAbove(key) {
|
|
59
|
-
if (this.layout ===
|
|
59
|
+
if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getPreviousKey(key), this.isSameRow);
|
|
60
60
|
else return this.getPreviousKey(key);
|
|
61
61
|
}
|
|
62
62
|
getNextColumn(key, right) {
|
|
63
63
|
return right ? this.getPreviousKey(key) : this.getNextKey(key);
|
|
64
64
|
}
|
|
65
65
|
getKeyRightOf(key) {
|
|
66
|
-
if (this.layout ===
|
|
67
|
-
if (this.orientation ===
|
|
68
|
-
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction ===
|
|
69
|
-
} else if (this.orientation ===
|
|
66
|
+
if (this.layout === 'grid') {
|
|
67
|
+
if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'rtl');
|
|
68
|
+
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'rtl'), this.isSameColumn);
|
|
69
|
+
} else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'rtl');
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
72
|
getKeyLeftOf(key) {
|
|
73
|
-
if (this.layout ===
|
|
74
|
-
if (this.orientation ===
|
|
75
|
-
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction ===
|
|
76
|
-
} else if (this.orientation ===
|
|
73
|
+
if (this.layout === 'grid') {
|
|
74
|
+
if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'ltr');
|
|
75
|
+
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'ltr'), this.isSameColumn);
|
|
76
|
+
} else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'ltr');
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
79
|
getFirstKey() {
|
|
80
80
|
let key = this.collection.getFirstKey();
|
|
81
81
|
while(key != null){
|
|
82
82
|
let item = this.collection.getItem(key);
|
|
83
|
-
if ((item === null || item === void 0 ? void 0 : item.type) ===
|
|
83
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return key;
|
|
84
84
|
key = this.collection.getKeyAfter(key);
|
|
85
85
|
}
|
|
86
86
|
return null;
|
|
@@ -89,7 +89,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
89
89
|
let key = this.collection.getLastKey();
|
|
90
90
|
while(key != null){
|
|
91
91
|
let item = this.collection.getItem(key);
|
|
92
|
-
if (item.type ===
|
|
92
|
+
if (item.type === 'item' && !this.isDisabled(item)) return key;
|
|
93
93
|
key = this.collection.getKeyBefore(key);
|
|
94
94
|
}
|
|
95
95
|
return null;
|
|
@@ -104,7 +104,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
104
104
|
if (!(0, $eak97$isScrollable)(menu)) return this.getFirstKey();
|
|
105
105
|
let containerRect = menu.getBoundingClientRect();
|
|
106
106
|
let itemRect = item.getBoundingClientRect();
|
|
107
|
-
if (this.orientation ===
|
|
107
|
+
if (this.orientation === 'horizontal') {
|
|
108
108
|
let containerX = containerRect.x - menu.scrollLeft;
|
|
109
109
|
let pageX = Math.max(0, itemRect.x - containerX + itemRect.width - containerRect.width);
|
|
110
110
|
while(item && itemRect.x - containerX > pageX){
|
|
@@ -130,7 +130,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
130
130
|
if (!(0, $eak97$isScrollable)(menu)) return this.getLastKey();
|
|
131
131
|
let containerRect = menu.getBoundingClientRect();
|
|
132
132
|
let itemRect = item.getBoundingClientRect();
|
|
133
|
-
if (this.orientation ===
|
|
133
|
+
if (this.orientation === 'horizontal') {
|
|
134
134
|
let containerX = containerRect.x - menu.scrollLeft;
|
|
135
135
|
let pageX = Math.min(menu.scrollWidth, itemRect.x - containerX - itemRect.width + containerRect.width);
|
|
136
136
|
while(item && itemRect.x - containerX < pageX){
|
|
@@ -168,22 +168,22 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
168
168
|
this.ref = opts.ref;
|
|
169
169
|
this.collator = opts.collator;
|
|
170
170
|
this.disabledKeys = opts.disabledKeys || new Set();
|
|
171
|
-
this.disabledBehavior = opts.disabledBehavior ||
|
|
171
|
+
this.disabledBehavior = opts.disabledBehavior || 'all';
|
|
172
172
|
this.orientation = opts.orientation;
|
|
173
173
|
this.direction = opts.direction;
|
|
174
|
-
this.layout = opts.layout ||
|
|
174
|
+
this.layout = opts.layout || 'stack';
|
|
175
175
|
} else {
|
|
176
176
|
this.collection = args[0];
|
|
177
177
|
this.disabledKeys = args[1];
|
|
178
178
|
this.ref = args[2];
|
|
179
179
|
this.collator = args[3];
|
|
180
|
-
this.layout =
|
|
181
|
-
this.orientation =
|
|
182
|
-
this.disabledBehavior =
|
|
180
|
+
this.layout = 'stack';
|
|
181
|
+
this.orientation = 'vertical';
|
|
182
|
+
this.disabledBehavior = 'all';
|
|
183
183
|
}
|
|
184
184
|
// If this is a vertical stack, remove the left/right methods completely
|
|
185
185
|
// so they aren't called by useDroppableCollection.
|
|
186
|
-
if (this.layout ===
|
|
186
|
+
if (this.layout === 'stack' && this.orientation === 'vertical') {
|
|
187
187
|
this.getKeyLeftOf = undefined;
|
|
188
188
|
this.getKeyRightOf = undefined;
|
|
189
189
|
}
|
|
@@ -32,19 +32,19 @@ $parcel$export(module.exports, "useSelectableCollection", () => $b6837c2f80a3c32
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
|
|
35
|
-
let { selectionManager: manager, keyboardDelegate: delegate, ref: ref, autoFocus: autoFocus = false, shouldFocusWrap: shouldFocusWrap = false, disallowEmptySelection: disallowEmptySelection = false, disallowSelectAll: disallowSelectAll = false, selectOnFocus: selectOnFocus = manager.selectionBehavior ===
|
|
36
|
-
scrollRef = ref, linkBehavior: linkBehavior =
|
|
35
|
+
let { selectionManager: manager, keyboardDelegate: delegate, ref: ref, autoFocus: autoFocus = false, shouldFocusWrap: shouldFocusWrap = false, disallowEmptySelection: disallowEmptySelection = false, disallowSelectAll: disallowSelectAll = false, selectOnFocus: selectOnFocus = manager.selectionBehavior === 'replace', disallowTypeAhead: disallowTypeAhead = false, shouldUseVirtualFocus: shouldUseVirtualFocus, allowsTabNavigation: allowsTabNavigation = false, isVirtualized: isVirtualized, scrollRef: // If no scrollRef is provided, assume the collection ref is the scrollable region
|
|
36
|
+
scrollRef = ref, linkBehavior: linkBehavior = 'action' } = options;
|
|
37
37
|
let { direction: direction } = (0, $bT8Bh$reactariai18n.useLocale)();
|
|
38
38
|
let router = (0, $bT8Bh$reactariautils.useRouter)();
|
|
39
39
|
let onKeyDown = (e)=>{
|
|
40
40
|
// Prevent option + tab from doing anything since it doesn't move focus to the cells, only buttons/checkboxes
|
|
41
|
-
if (e.altKey && e.key ===
|
|
41
|
+
if (e.altKey && e.key === 'Tab') e.preventDefault();
|
|
42
42
|
// Keyboard events bubble through portals. Don't handle keyboard events
|
|
43
43
|
// for elements outside the collection (e.g. menus).
|
|
44
44
|
if (!ref.current.contains(e.target)) return;
|
|
45
45
|
const navigateToKey = (key, childFocus)=>{
|
|
46
46
|
if (key != null) {
|
|
47
|
-
if (manager.isLink(key) && linkBehavior ===
|
|
47
|
+
if (manager.isLink(key) && linkBehavior === 'selection' && selectOnFocus && !(0, $ee0bdf4faa47f2a8$exports.isNonContiguousSelectionModifier)(e)) {
|
|
48
48
|
// Set focused key and re-render synchronously to bring item into view if needed.
|
|
49
49
|
(0, $bT8Bh$reactdom.flushSync)(()=>{
|
|
50
50
|
manager.setFocusedKey(key, childFocus);
|
|
@@ -55,13 +55,13 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
manager.setFocusedKey(key, childFocus);
|
|
58
|
-
if (manager.isLink(key) && linkBehavior ===
|
|
59
|
-
if (e.shiftKey && manager.selectionMode ===
|
|
58
|
+
if (manager.isLink(key) && linkBehavior === 'override') return;
|
|
59
|
+
if (e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(key);
|
|
60
60
|
else if (selectOnFocus && !(0, $ee0bdf4faa47f2a8$exports.isNonContiguousSelectionModifier)(e)) manager.replaceSelection(key);
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
switch(e.key){
|
|
64
|
-
case
|
|
64
|
+
case 'ArrowDown':
|
|
65
65
|
if (delegate.getKeyBelow) {
|
|
66
66
|
var _delegate_getFirstKey, _delegate_getFirstKey1;
|
|
67
67
|
e.preventDefault();
|
|
@@ -70,7 +70,7 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
|
|
|
70
70
|
navigateToKey(nextKey);
|
|
71
71
|
}
|
|
72
72
|
break;
|
|
73
|
-
case
|
|
73
|
+
case 'ArrowUp':
|
|
74
74
|
if (delegate.getKeyAbove) {
|
|
75
75
|
var _delegate_getLastKey, _delegate_getLastKey1;
|
|
76
76
|
e.preventDefault();
|
|
@@ -79,70 +79,70 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
|
|
|
79
79
|
navigateToKey(nextKey);
|
|
80
80
|
}
|
|
81
81
|
break;
|
|
82
|
-
case
|
|
82
|
+
case 'ArrowLeft':
|
|
83
83
|
if (delegate.getKeyLeftOf) {
|
|
84
84
|
var _delegate_getFirstKey2, _delegate_getLastKey2;
|
|
85
85
|
e.preventDefault();
|
|
86
86
|
let nextKey = delegate.getKeyLeftOf(manager.focusedKey);
|
|
87
|
-
if (nextKey == null && shouldFocusWrap) nextKey = direction ===
|
|
88
|
-
navigateToKey(nextKey, direction ===
|
|
87
|
+
if (nextKey == null && shouldFocusWrap) nextKey = direction === 'rtl' ? (_delegate_getFirstKey2 = delegate.getFirstKey) === null || _delegate_getFirstKey2 === void 0 ? void 0 : _delegate_getFirstKey2.call(delegate, manager.focusedKey) : (_delegate_getLastKey2 = delegate.getLastKey) === null || _delegate_getLastKey2 === void 0 ? void 0 : _delegate_getLastKey2.call(delegate, manager.focusedKey);
|
|
88
|
+
navigateToKey(nextKey, direction === 'rtl' ? 'first' : 'last');
|
|
89
89
|
}
|
|
90
90
|
break;
|
|
91
|
-
case
|
|
91
|
+
case 'ArrowRight':
|
|
92
92
|
if (delegate.getKeyRightOf) {
|
|
93
93
|
var _delegate_getLastKey3, _delegate_getFirstKey3;
|
|
94
94
|
e.preventDefault();
|
|
95
95
|
let nextKey = delegate.getKeyRightOf(manager.focusedKey);
|
|
96
|
-
if (nextKey == null && shouldFocusWrap) nextKey = direction ===
|
|
97
|
-
navigateToKey(nextKey, direction ===
|
|
96
|
+
if (nextKey == null && shouldFocusWrap) nextKey = direction === 'rtl' ? (_delegate_getLastKey3 = delegate.getLastKey) === null || _delegate_getLastKey3 === void 0 ? void 0 : _delegate_getLastKey3.call(delegate, manager.focusedKey) : (_delegate_getFirstKey3 = delegate.getFirstKey) === null || _delegate_getFirstKey3 === void 0 ? void 0 : _delegate_getFirstKey3.call(delegate, manager.focusedKey);
|
|
97
|
+
navigateToKey(nextKey, direction === 'rtl' ? 'last' : 'first');
|
|
98
98
|
}
|
|
99
99
|
break;
|
|
100
|
-
case
|
|
100
|
+
case 'Home':
|
|
101
101
|
if (delegate.getFirstKey) {
|
|
102
102
|
e.preventDefault();
|
|
103
103
|
let firstKey = delegate.getFirstKey(manager.focusedKey, (0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e));
|
|
104
104
|
manager.setFocusedKey(firstKey);
|
|
105
|
-
if ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) && e.shiftKey && manager.selectionMode ===
|
|
105
|
+
if ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(firstKey);
|
|
106
106
|
else if (selectOnFocus) manager.replaceSelection(firstKey);
|
|
107
107
|
}
|
|
108
108
|
break;
|
|
109
|
-
case
|
|
109
|
+
case 'End':
|
|
110
110
|
if (delegate.getLastKey) {
|
|
111
111
|
e.preventDefault();
|
|
112
112
|
let lastKey = delegate.getLastKey(manager.focusedKey, (0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e));
|
|
113
113
|
manager.setFocusedKey(lastKey);
|
|
114
|
-
if ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) && e.shiftKey && manager.selectionMode ===
|
|
114
|
+
if ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(lastKey);
|
|
115
115
|
else if (selectOnFocus) manager.replaceSelection(lastKey);
|
|
116
116
|
}
|
|
117
117
|
break;
|
|
118
|
-
case
|
|
118
|
+
case 'PageDown':
|
|
119
119
|
if (delegate.getKeyPageBelow) {
|
|
120
120
|
e.preventDefault();
|
|
121
121
|
let nextKey = delegate.getKeyPageBelow(manager.focusedKey);
|
|
122
122
|
navigateToKey(nextKey);
|
|
123
123
|
}
|
|
124
124
|
break;
|
|
125
|
-
case
|
|
125
|
+
case 'PageUp':
|
|
126
126
|
if (delegate.getKeyPageAbove) {
|
|
127
127
|
e.preventDefault();
|
|
128
128
|
let nextKey = delegate.getKeyPageAbove(manager.focusedKey);
|
|
129
129
|
navigateToKey(nextKey);
|
|
130
130
|
}
|
|
131
131
|
break;
|
|
132
|
-
case
|
|
133
|
-
if ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) && manager.selectionMode ===
|
|
132
|
+
case 'a':
|
|
133
|
+
if ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) && manager.selectionMode === 'multiple' && disallowSelectAll !== true) {
|
|
134
134
|
e.preventDefault();
|
|
135
135
|
manager.selectAll();
|
|
136
136
|
}
|
|
137
137
|
break;
|
|
138
|
-
case
|
|
138
|
+
case 'Escape':
|
|
139
139
|
if (!disallowEmptySelection && manager.selectedKeys.size !== 0) {
|
|
140
140
|
e.stopPropagation();
|
|
141
141
|
e.preventDefault();
|
|
142
142
|
manager.clearSelection();
|
|
143
143
|
}
|
|
144
144
|
break;
|
|
145
|
-
case
|
|
145
|
+
case 'Tab':
|
|
146
146
|
if (!allowsTabNavigation) {
|
|
147
147
|
// There may be elements that are "tabbable" inside a collection (e.g. in a grid cell).
|
|
148
148
|
// However, collections should be treated as a single tab stop, with arrow key navigation internally.
|
|
@@ -172,7 +172,7 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
|
|
|
172
172
|
top: 0,
|
|
173
173
|
left: 0
|
|
174
174
|
});
|
|
175
|
-
(0, $bT8Bh$reactariautils.useEvent)(scrollRef,
|
|
175
|
+
(0, $bT8Bh$reactariautils.useEvent)(scrollRef, 'scroll', isVirtualized ? null : ()=>{
|
|
176
176
|
scrollPos.current = {
|
|
177
177
|
top: scrollRef.current.scrollTop,
|
|
178
178
|
left: scrollRef.current.scrollLeft
|
|
@@ -213,7 +213,7 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
|
|
|
213
213
|
// This prevents a flash of focus on the first/last element in the collection, or the collection itself.
|
|
214
214
|
if (!element.contains(document.activeElement)) (0, $bT8Bh$reactariautils.focusWithoutScrolling)(element);
|
|
215
215
|
let modality = (0, $bT8Bh$reactariainteractions.getInteractionModality)();
|
|
216
|
-
if (modality ===
|
|
216
|
+
if (modality === 'keyboard') (0, $bT8Bh$reactariautils.scrollIntoViewport)(element, {
|
|
217
217
|
containingElement: ref.current
|
|
218
218
|
});
|
|
219
219
|
}
|
|
@@ -228,8 +228,8 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
|
|
|
228
228
|
if (autoFocusRef.current) {
|
|
229
229
|
let focusedKey = null;
|
|
230
230
|
// Check focus strategy to determine which item to focus
|
|
231
|
-
if (autoFocus ===
|
|
232
|
-
if (autoFocus ===
|
|
231
|
+
if (autoFocus === 'first') focusedKey = delegate.getFirstKey();
|
|
232
|
+
if (autoFocus === 'last') focusedKey = delegate.getLastKey();
|
|
233
233
|
// If there are any selected keys, make the first one the new focus target
|
|
234
234
|
let selectedKeys = manager.selectedKeys;
|
|
235
235
|
if (selectedKeys.size) {
|
|
@@ -252,10 +252,10 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
|
|
|
252
252
|
let modality = (0, $bT8Bh$reactariainteractions.getInteractionModality)();
|
|
253
253
|
if (manager.isFocused && manager.focusedKey != null && (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
254
254
|
let element = scrollRef.current.querySelector(`[data-key="${CSS.escape(manager.focusedKey.toString())}"]`);
|
|
255
|
-
if (element && (modality ===
|
|
255
|
+
if (element && (modality === 'keyboard' || autoFocusRef.current)) {
|
|
256
256
|
if (!isVirtualized) (0, $bT8Bh$reactariautils.scrollIntoView)(scrollRef.current, element);
|
|
257
257
|
// Avoid scroll in iOS VO, since it may cause overlay to close (i.e. RAC submenu)
|
|
258
|
-
if (modality !==
|
|
258
|
+
if (modality !== 'virtual') (0, $bT8Bh$reactariautils.scrollIntoViewport)(element, {
|
|
259
259
|
containingElement: ref.current
|
|
260
260
|
});
|
|
261
261
|
}
|