@react-aria/selection 3.18.0 → 3.19.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.
Files changed (43) hide show
  1. package/dist/DOMLayoutDelegate.main.js +53 -0
  2. package/dist/DOMLayoutDelegate.main.js.map +1 -0
  3. package/dist/DOMLayoutDelegate.mjs +48 -0
  4. package/dist/DOMLayoutDelegate.module.js +48 -0
  5. package/dist/DOMLayoutDelegate.module.js.map +1 -0
  6. package/dist/ListKeyboardDelegate.main.js +51 -62
  7. package/dist/ListKeyboardDelegate.main.js.map +1 -1
  8. package/dist/ListKeyboardDelegate.mjs +52 -63
  9. package/dist/ListKeyboardDelegate.module.js +51 -62
  10. package/dist/ListKeyboardDelegate.module.js.map +1 -1
  11. package/dist/import.mjs +3 -1
  12. package/dist/main.js +3 -0
  13. package/dist/main.js.map +1 -1
  14. package/dist/module.js +3 -1
  15. package/dist/module.js.map +1 -1
  16. package/dist/types.d.ts +19 -7
  17. package/dist/types.d.ts.map +1 -1
  18. package/dist/useSelectableCollection.main.js +46 -44
  19. package/dist/useSelectableCollection.main.js.map +1 -1
  20. package/dist/useSelectableCollection.mjs +47 -45
  21. package/dist/useSelectableCollection.module.js +46 -44
  22. package/dist/useSelectableCollection.module.js.map +1 -1
  23. package/dist/useSelectableItem.main.js +25 -25
  24. package/dist/useSelectableItem.main.js.map +1 -1
  25. package/dist/useSelectableItem.mjs +26 -26
  26. package/dist/useSelectableItem.module.js +25 -25
  27. package/dist/useSelectableItem.module.js.map +1 -1
  28. package/dist/useSelectableList.main.js +6 -4
  29. package/dist/useSelectableList.main.js.map +1 -1
  30. package/dist/useSelectableList.mjs +7 -5
  31. package/dist/useSelectableList.module.js +6 -4
  32. package/dist/useSelectableList.module.js.map +1 -1
  33. package/dist/useTypeSelect.main.js +5 -5
  34. package/dist/useTypeSelect.mjs +6 -6
  35. package/dist/useTypeSelect.module.js +5 -5
  36. package/dist/utils.mjs +1 -1
  37. package/package.json +10 -10
  38. package/src/DOMLayoutDelegate.ts +57 -0
  39. package/src/ListKeyboardDelegate.ts +37 -49
  40. package/src/index.ts +1 -0
  41. package/src/useSelectableCollection.ts +26 -15
  42. package/src/useSelectableItem.ts +3 -3
  43. package/src/useSelectableList.ts +12 -4
@@ -1,3 +1,4 @@
1
+ import {DOMLayoutDelegate as $657e4dc4a6e88df0$export$8f5ed9ff9f511381} from "./DOMLayoutDelegate.mjs";
1
2
  import {isScrollable as $eak97$isScrollable} from "@react-aria/utils";
2
3
 
3
4
  /*
@@ -11,16 +12,17 @@ import {isScrollable as $eak97$isScrollable} from "@react-aria/utils";
11
12
  * OF ANY KIND, either express or implied. See the License for the specific language
12
13
  * governing permissions and limitations under the License.
13
14
  */
15
+
14
16
  class $2a25aae57d74318e$export$a05409b8bb224a5a {
15
17
  isDisabled(item) {
16
18
  var _item_props;
17
- return this.disabledBehavior === "all" && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
19
+ return this.disabledBehavior === 'all' && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
18
20
  }
19
21
  getNextKey(key) {
20
22
  key = this.collection.getKeyAfter(key);
21
23
  while(key != null){
22
24
  let item = this.collection.getItem(key);
23
- if (item.type === "item" && !this.isDisabled(item)) return key;
25
+ if (item.type === 'item' && !this.isDisabled(item)) return key;
24
26
  key = this.collection.getKeyAfter(key);
25
27
  }
26
28
  return null;
@@ -29,58 +31,58 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
29
31
  key = this.collection.getKeyBefore(key);
30
32
  while(key != null){
31
33
  let item = this.collection.getItem(key);
32
- if (item.type === "item" && !this.isDisabled(item)) return key;
34
+ if (item.type === 'item' && !this.isDisabled(item)) return key;
33
35
  key = this.collection.getKeyBefore(key);
34
36
  }
35
37
  return null;
36
38
  }
37
39
  findKey(key, nextKey, shouldSkip) {
38
- let item = this.getItem(key);
39
- if (!item) return null;
40
+ let itemRect = this.layoutDelegate.getItemRect(key);
41
+ if (!itemRect) return null;
40
42
  // Find the item above or below in the same column.
41
- let prevRect = item.getBoundingClientRect();
43
+ let prevRect = itemRect;
42
44
  do {
43
45
  key = nextKey(key);
44
- item = this.getItem(key);
45
- }while (item && shouldSkip(prevRect, item.getBoundingClientRect()));
46
+ itemRect = this.layoutDelegate.getItemRect(key);
47
+ }while (itemRect && shouldSkip(prevRect, itemRect));
46
48
  return key;
47
49
  }
48
50
  isSameRow(prevRect, itemRect) {
49
- return prevRect.top === itemRect.top || prevRect.left !== itemRect.left;
51
+ return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;
50
52
  }
51
53
  isSameColumn(prevRect, itemRect) {
52
- return prevRect.left === itemRect.left || prevRect.top !== itemRect.top;
54
+ return prevRect.x === itemRect.x || prevRect.y !== itemRect.y;
53
55
  }
54
56
  getKeyBelow(key) {
55
- if (this.layout === "grid" && this.orientation === "vertical") return this.findKey(key, (key)=>this.getNextKey(key), this.isSameRow);
57
+ if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getNextKey(key), this.isSameRow);
56
58
  else return this.getNextKey(key);
57
59
  }
58
60
  getKeyAbove(key) {
59
- if (this.layout === "grid" && this.orientation === "vertical") return this.findKey(key, (key)=>this.getPreviousKey(key), this.isSameRow);
61
+ if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getPreviousKey(key), this.isSameRow);
60
62
  else return this.getPreviousKey(key);
61
63
  }
62
64
  getNextColumn(key, right) {
63
65
  return right ? this.getPreviousKey(key) : this.getNextKey(key);
64
66
  }
65
67
  getKeyRightOf(key) {
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");
68
+ if (this.layout === 'grid') {
69
+ if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'rtl');
70
+ else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'rtl'), this.isSameColumn);
71
+ } else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'rtl');
70
72
  return null;
71
73
  }
72
74
  getKeyLeftOf(key) {
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");
75
+ if (this.layout === 'grid') {
76
+ if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'ltr');
77
+ else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'ltr'), this.isSameColumn);
78
+ } else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'ltr');
77
79
  return null;
78
80
  }
79
81
  getFirstKey() {
80
82
  let key = this.collection.getFirstKey();
81
83
  while(key != null){
82
84
  let item = this.collection.getItem(key);
83
- if ((item === null || item === void 0 ? void 0 : item.type) === "item" && !this.isDisabled(item)) return key;
85
+ if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return key;
84
86
  key = this.collection.getKeyAfter(key);
85
87
  }
86
88
  return null;
@@ -89,62 +91,47 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
89
91
  let key = this.collection.getLastKey();
90
92
  while(key != null){
91
93
  let item = this.collection.getItem(key);
92
- if (item.type === "item" && !this.isDisabled(item)) return key;
94
+ if (item.type === 'item' && !this.isDisabled(item)) return key;
93
95
  key = this.collection.getKeyBefore(key);
94
96
  }
95
97
  return null;
96
98
  }
97
- getItem(key) {
98
- return key !== null ? this.ref.current.querySelector(`[data-key="${CSS.escape(key.toString())}"]`) : null;
99
- }
100
99
  getKeyPageAbove(key) {
101
100
  let menu = this.ref.current;
102
- let item = this.getItem(key);
103
- if (!item) return null;
101
+ let itemRect = this.layoutDelegate.getItemRect(key);
102
+ if (!itemRect) return null;
104
103
  if (!(0, $eak97$isScrollable)(menu)) return this.getFirstKey();
105
- let containerRect = menu.getBoundingClientRect();
106
- let itemRect = item.getBoundingClientRect();
107
- if (this.orientation === "horizontal") {
108
- let containerX = containerRect.x - menu.scrollLeft;
109
- let pageX = Math.max(0, itemRect.x - containerX + itemRect.width - containerRect.width);
110
- while(item && itemRect.x - containerX > pageX){
104
+ if (this.orientation === 'horizontal') {
105
+ let pageX = Math.max(0, itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width);
106
+ while(itemRect && itemRect.x > pageX){
111
107
  key = this.getKeyAbove(key);
112
- item = key == null ? null : this.getItem(key);
113
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
108
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
114
109
  }
115
110
  } else {
116
- let containerY = containerRect.y - menu.scrollTop;
117
- let pageY = Math.max(0, itemRect.y - containerY + itemRect.height - containerRect.height);
118
- while(item && itemRect.y - containerY > pageY){
111
+ let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);
112
+ while(itemRect && itemRect.y > pageY){
119
113
  key = this.getKeyAbove(key);
120
- item = key == null ? null : this.getItem(key);
121
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
114
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
122
115
  }
123
116
  }
124
117
  return key !== null && key !== void 0 ? key : this.getFirstKey();
125
118
  }
126
119
  getKeyPageBelow(key) {
127
120
  let menu = this.ref.current;
128
- let item = this.getItem(key);
129
- if (!item) return null;
121
+ let itemRect = this.layoutDelegate.getItemRect(key);
122
+ if (!itemRect) return null;
130
123
  if (!(0, $eak97$isScrollable)(menu)) return this.getLastKey();
131
- let containerRect = menu.getBoundingClientRect();
132
- let itemRect = item.getBoundingClientRect();
133
- if (this.orientation === "horizontal") {
134
- let containerX = containerRect.x - menu.scrollLeft;
135
- let pageX = Math.min(menu.scrollWidth, itemRect.x - containerX - itemRect.width + containerRect.width);
136
- while(item && itemRect.x - containerX < pageX){
124
+ if (this.orientation === 'horizontal') {
125
+ let pageX = Math.min(this.layoutDelegate.getContentSize().width, itemRect.y - itemRect.width + this.layoutDelegate.getVisibleRect().width);
126
+ while(itemRect && itemRect.x < pageX){
137
127
  key = this.getKeyBelow(key);
138
- item = key == null ? null : this.getItem(key);
139
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
128
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
140
129
  }
141
130
  } else {
142
- let containerY = containerRect.y - menu.scrollTop;
143
- let pageY = Math.min(menu.scrollHeight, itemRect.y - containerY - itemRect.height + containerRect.height);
144
- while(item && itemRect.y - containerY < pageY){
131
+ let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height);
132
+ while(itemRect && itemRect.y < pageY){
145
133
  key = this.getKeyBelow(key);
146
- item = key == null ? null : this.getItem(key);
147
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
134
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
148
135
  }
149
136
  }
150
137
  return key !== null && key !== void 0 ? key : this.getLastKey();
@@ -168,22 +155,24 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
168
155
  this.ref = opts.ref;
169
156
  this.collator = opts.collator;
170
157
  this.disabledKeys = opts.disabledKeys || new Set();
171
- this.disabledBehavior = opts.disabledBehavior || "all";
172
- this.orientation = opts.orientation;
158
+ this.disabledBehavior = opts.disabledBehavior || 'all';
159
+ this.orientation = opts.orientation || 'vertical';
173
160
  this.direction = opts.direction;
174
- this.layout = opts.layout || "stack";
161
+ this.layout = opts.layout || 'stack';
162
+ this.layoutDelegate = opts.layoutDelegate || new (0, $657e4dc4a6e88df0$export$8f5ed9ff9f511381)(opts.ref);
175
163
  } else {
176
164
  this.collection = args[0];
177
165
  this.disabledKeys = args[1];
178
166
  this.ref = args[2];
179
167
  this.collator = args[3];
180
- this.layout = "stack";
181
- this.orientation = "vertical";
182
- this.disabledBehavior = "all";
168
+ this.layout = 'stack';
169
+ this.orientation = 'vertical';
170
+ this.disabledBehavior = 'all';
171
+ this.layoutDelegate = new (0, $657e4dc4a6e88df0$export$8f5ed9ff9f511381)(this.ref);
183
172
  }
184
173
  // If this is a vertical stack, remove the left/right methods completely
185
174
  // so they aren't called by useDroppableCollection.
186
- if (this.layout === "stack" && this.orientation === "vertical") {
175
+ if (this.layout === 'stack' && this.orientation === 'vertical') {
187
176
  this.getKeyLeftOf = undefined;
188
177
  this.getKeyRightOf = undefined;
189
178
  }
@@ -192,4 +181,4 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
192
181
 
193
182
 
194
183
  export {$2a25aae57d74318e$export$a05409b8bb224a5a as ListKeyboardDelegate};
195
- //# sourceMappingURL=ListKeyboardDelegate.mjs.map
184
+ //# sourceMappingURL=ListKeyboardDelegate.module.js.map
@@ -1,3 +1,4 @@
1
+ import {DOMLayoutDelegate as $657e4dc4a6e88df0$export$8f5ed9ff9f511381} from "./DOMLayoutDelegate.module.js";
1
2
  import {isScrollable as $eak97$isScrollable} from "@react-aria/utils";
2
3
 
3
4
  /*
@@ -11,16 +12,17 @@ import {isScrollable as $eak97$isScrollable} from "@react-aria/utils";
11
12
  * OF ANY KIND, either express or implied. See the License for the specific language
12
13
  * governing permissions and limitations under the License.
13
14
  */
15
+
14
16
  class $2a25aae57d74318e$export$a05409b8bb224a5a {
15
17
  isDisabled(item) {
16
18
  var _item_props;
17
- return this.disabledBehavior === "all" && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
19
+ return this.disabledBehavior === 'all' && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
18
20
  }
19
21
  getNextKey(key) {
20
22
  key = this.collection.getKeyAfter(key);
21
23
  while(key != null){
22
24
  let item = this.collection.getItem(key);
23
- if (item.type === "item" && !this.isDisabled(item)) return key;
25
+ if (item.type === 'item' && !this.isDisabled(item)) return key;
24
26
  key = this.collection.getKeyAfter(key);
25
27
  }
26
28
  return null;
@@ -29,58 +31,58 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
29
31
  key = this.collection.getKeyBefore(key);
30
32
  while(key != null){
31
33
  let item = this.collection.getItem(key);
32
- if (item.type === "item" && !this.isDisabled(item)) return key;
34
+ if (item.type === 'item' && !this.isDisabled(item)) return key;
33
35
  key = this.collection.getKeyBefore(key);
34
36
  }
35
37
  return null;
36
38
  }
37
39
  findKey(key, nextKey, shouldSkip) {
38
- let item = this.getItem(key);
39
- if (!item) return null;
40
+ let itemRect = this.layoutDelegate.getItemRect(key);
41
+ if (!itemRect) return null;
40
42
  // Find the item above or below in the same column.
41
- let prevRect = item.getBoundingClientRect();
43
+ let prevRect = itemRect;
42
44
  do {
43
45
  key = nextKey(key);
44
- item = this.getItem(key);
45
- }while (item && shouldSkip(prevRect, item.getBoundingClientRect()));
46
+ itemRect = this.layoutDelegate.getItemRect(key);
47
+ }while (itemRect && shouldSkip(prevRect, itemRect));
46
48
  return key;
47
49
  }
48
50
  isSameRow(prevRect, itemRect) {
49
- return prevRect.top === itemRect.top || prevRect.left !== itemRect.left;
51
+ return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;
50
52
  }
51
53
  isSameColumn(prevRect, itemRect) {
52
- return prevRect.left === itemRect.left || prevRect.top !== itemRect.top;
54
+ return prevRect.x === itemRect.x || prevRect.y !== itemRect.y;
53
55
  }
54
56
  getKeyBelow(key) {
55
- if (this.layout === "grid" && this.orientation === "vertical") return this.findKey(key, (key)=>this.getNextKey(key), this.isSameRow);
57
+ if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getNextKey(key), this.isSameRow);
56
58
  else return this.getNextKey(key);
57
59
  }
58
60
  getKeyAbove(key) {
59
- if (this.layout === "grid" && this.orientation === "vertical") return this.findKey(key, (key)=>this.getPreviousKey(key), this.isSameRow);
61
+ if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getPreviousKey(key), this.isSameRow);
60
62
  else return this.getPreviousKey(key);
61
63
  }
62
64
  getNextColumn(key, right) {
63
65
  return right ? this.getPreviousKey(key) : this.getNextKey(key);
64
66
  }
65
67
  getKeyRightOf(key) {
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");
68
+ if (this.layout === 'grid') {
69
+ if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'rtl');
70
+ else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'rtl'), this.isSameColumn);
71
+ } else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'rtl');
70
72
  return null;
71
73
  }
72
74
  getKeyLeftOf(key) {
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");
75
+ if (this.layout === 'grid') {
76
+ if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'ltr');
77
+ else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'ltr'), this.isSameColumn);
78
+ } else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'ltr');
77
79
  return null;
78
80
  }
79
81
  getFirstKey() {
80
82
  let key = this.collection.getFirstKey();
81
83
  while(key != null){
82
84
  let item = this.collection.getItem(key);
83
- if ((item === null || item === void 0 ? void 0 : item.type) === "item" && !this.isDisabled(item)) return key;
85
+ if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return key;
84
86
  key = this.collection.getKeyAfter(key);
85
87
  }
86
88
  return null;
@@ -89,62 +91,47 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
89
91
  let key = this.collection.getLastKey();
90
92
  while(key != null){
91
93
  let item = this.collection.getItem(key);
92
- if (item.type === "item" && !this.isDisabled(item)) return key;
94
+ if (item.type === 'item' && !this.isDisabled(item)) return key;
93
95
  key = this.collection.getKeyBefore(key);
94
96
  }
95
97
  return null;
96
98
  }
97
- getItem(key) {
98
- return key !== null ? this.ref.current.querySelector(`[data-key="${CSS.escape(key.toString())}"]`) : null;
99
- }
100
99
  getKeyPageAbove(key) {
101
100
  let menu = this.ref.current;
102
- let item = this.getItem(key);
103
- if (!item) return null;
101
+ let itemRect = this.layoutDelegate.getItemRect(key);
102
+ if (!itemRect) return null;
104
103
  if (!(0, $eak97$isScrollable)(menu)) return this.getFirstKey();
105
- let containerRect = menu.getBoundingClientRect();
106
- let itemRect = item.getBoundingClientRect();
107
- if (this.orientation === "horizontal") {
108
- let containerX = containerRect.x - menu.scrollLeft;
109
- let pageX = Math.max(0, itemRect.x - containerX + itemRect.width - containerRect.width);
110
- while(item && itemRect.x - containerX > pageX){
104
+ if (this.orientation === 'horizontal') {
105
+ let pageX = Math.max(0, itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width);
106
+ while(itemRect && itemRect.x > pageX){
111
107
  key = this.getKeyAbove(key);
112
- item = key == null ? null : this.getItem(key);
113
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
108
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
114
109
  }
115
110
  } else {
116
- let containerY = containerRect.y - menu.scrollTop;
117
- let pageY = Math.max(0, itemRect.y - containerY + itemRect.height - containerRect.height);
118
- while(item && itemRect.y - containerY > pageY){
111
+ let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);
112
+ while(itemRect && itemRect.y > pageY){
119
113
  key = this.getKeyAbove(key);
120
- item = key == null ? null : this.getItem(key);
121
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
114
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
122
115
  }
123
116
  }
124
117
  return key !== null && key !== void 0 ? key : this.getFirstKey();
125
118
  }
126
119
  getKeyPageBelow(key) {
127
120
  let menu = this.ref.current;
128
- let item = this.getItem(key);
129
- if (!item) return null;
121
+ let itemRect = this.layoutDelegate.getItemRect(key);
122
+ if (!itemRect) return null;
130
123
  if (!(0, $eak97$isScrollable)(menu)) return this.getLastKey();
131
- let containerRect = menu.getBoundingClientRect();
132
- let itemRect = item.getBoundingClientRect();
133
- if (this.orientation === "horizontal") {
134
- let containerX = containerRect.x - menu.scrollLeft;
135
- let pageX = Math.min(menu.scrollWidth, itemRect.x - containerX - itemRect.width + containerRect.width);
136
- while(item && itemRect.x - containerX < pageX){
124
+ if (this.orientation === 'horizontal') {
125
+ let pageX = Math.min(this.layoutDelegate.getContentSize().width, itemRect.y - itemRect.width + this.layoutDelegate.getVisibleRect().width);
126
+ while(itemRect && itemRect.x < pageX){
137
127
  key = this.getKeyBelow(key);
138
- item = key == null ? null : this.getItem(key);
139
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
128
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
140
129
  }
141
130
  } else {
142
- let containerY = containerRect.y - menu.scrollTop;
143
- let pageY = Math.min(menu.scrollHeight, itemRect.y - containerY - itemRect.height + containerRect.height);
144
- while(item && itemRect.y - containerY < pageY){
131
+ let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height);
132
+ while(itemRect && itemRect.y < pageY){
145
133
  key = this.getKeyBelow(key);
146
- item = key == null ? null : this.getItem(key);
147
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
134
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
148
135
  }
149
136
  }
150
137
  return key !== null && key !== void 0 ? key : this.getLastKey();
@@ -168,22 +155,24 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
168
155
  this.ref = opts.ref;
169
156
  this.collator = opts.collator;
170
157
  this.disabledKeys = opts.disabledKeys || new Set();
171
- this.disabledBehavior = opts.disabledBehavior || "all";
172
- this.orientation = opts.orientation;
158
+ this.disabledBehavior = opts.disabledBehavior || 'all';
159
+ this.orientation = opts.orientation || 'vertical';
173
160
  this.direction = opts.direction;
174
- this.layout = opts.layout || "stack";
161
+ this.layout = opts.layout || 'stack';
162
+ this.layoutDelegate = opts.layoutDelegate || new (0, $657e4dc4a6e88df0$export$8f5ed9ff9f511381)(opts.ref);
175
163
  } else {
176
164
  this.collection = args[0];
177
165
  this.disabledKeys = args[1];
178
166
  this.ref = args[2];
179
167
  this.collator = args[3];
180
- this.layout = "stack";
181
- this.orientation = "vertical";
182
- this.disabledBehavior = "all";
168
+ this.layout = 'stack';
169
+ this.orientation = 'vertical';
170
+ this.disabledBehavior = 'all';
171
+ this.layoutDelegate = new (0, $657e4dc4a6e88df0$export$8f5ed9ff9f511381)(this.ref);
183
172
  }
184
173
  // If this is a vertical stack, remove the left/right methods completely
185
174
  // so they aren't called by useDroppableCollection.
186
- if (this.layout === "stack" && this.orientation === "vertical") {
175
+ if (this.layout === 'stack' && this.orientation === 'vertical') {
187
176
  this.getKeyLeftOf = undefined;
188
177
  this.getKeyRightOf = undefined;
189
178
  }
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAiBM,MAAM;IAyCH,WAAW,IAAmB,EAAE;YACK;QAA3C,OAAO,IAAI,CAAC,gBAAgB,KAAK,SAAU,CAAA,EAAA,cAAA,KAAK,KAAK,cAAV,kCAAA,YAAY,UAAU,KAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,GAAG,CAAA;IACrG;IAEA,WAAW,GAAQ,EAAE;QACnB,MAAM,IAAI,CAAC,UAAU,CAAC,WA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;YACjC,IAAI,CAAC,GAAG,GAAG,KAAK,GAAG;YACnB,IAAI,CAAC,QAAQ,GAAG,KAAK,QAAQ;YAC7B,IAAI,CAAC,YAAY,GAAG,KAAK,YAAY,IAAI,IAAI;YAC7C,IAAI,CAAC,gBAAgB,GAAG,KAAK,gBAAgB,IAAI;YACjD,IAAI,CAAC,WAAW,GAAG,KAAK,WAAW;YACnC,IAAI,CAAC,SAAS,GAAG,KAAK,SAAS;YAC/B,IAAI,CAAC,MAAM,GAAG,KAAK,MAAM,IAAI;QAC/B,OAAO;YACL,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE;YACzB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE;YAC3B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE;YACvB,IAAI,CAAC,MAAM,GAAG;YACd,IAAI,CAAC,WAAW,GAAG;YACnB,IAAI,CAAC,gBAAgB,GAAG;QAC1B;QAEA,wEAAwE;QACxE,mDAAmD;QACnD,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,WAAW,KAAK,YAAY;YAC9D,IAAI,CAAC,YAAY,GAAG;YACpB,IAAI,CAAC,aAAa,GAAG;QACvB;IACF;AAyOF","sources":["packages/@react-aria/selection/src/ListKeyboardDelegate.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Direction, DisabledBehavior, Key, KeyboardDelegate, Node, Orientation} from '@react-types/shared';\nimport {isScrollable} from '@react-aria/utils';\nimport {RefObject} from 'react';\n\ninterface ListKeyboardDelegateOptions<T> {\n collection: Collection<Node<T>>,\n ref: RefObject<HTMLElement>,\n collator?: Intl.Collator,\n layout?: 'stack' | 'grid',\n orientation?: Orientation,\n direction?: Direction,\n disabledKeys?: Set<Key>,\n disabledBehavior?: DisabledBehavior\n}\n\nexport class ListKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<Node<T>>;\n private disabledKeys: Set<Key>;\n private disabledBehavior: DisabledBehavior;\n private ref: RefObject<HTMLElement>;\n private collator: Intl.Collator | undefined;\n private layout: 'stack' | 'grid';\n private orientation?: Orientation;\n private direction?: Direction;\n\n constructor(collection: Collection<Node<T>>, disabledKeys: Set<Key>, ref: RefObject<HTMLElement>, collator?: Intl.Collator);\n constructor(options: ListKeyboardDelegateOptions<T>);\n constructor(...args: any[]) {\n if (args.length === 1) {\n let opts = args[0] as ListKeyboardDelegateOptions<T>;\n this.collection = opts.collection;\n this.ref = opts.ref;\n this.collator = opts.collator;\n this.disabledKeys = opts.disabledKeys || new Set();\n this.disabledBehavior = opts.disabledBehavior || 'all';\n this.orientation = opts.orientation;\n this.direction = opts.direction;\n this.layout = opts.layout || 'stack';\n } else {\n this.collection = args[0];\n this.disabledKeys = args[1];\n this.ref = args[2];\n this.collator = args[3];\n this.layout = 'stack';\n this.orientation = 'vertical';\n this.disabledBehavior = 'all';\n }\n\n // If this is a vertical stack, remove the left/right methods completely\n // so they aren't called by useDroppableCollection.\n if (this.layout === 'stack' && this.orientation === 'vertical') {\n this.getKeyLeftOf = undefined;\n this.getKeyRightOf = undefined;\n }\n }\n\n private isDisabled(item: Node<unknown>) {\n return this.disabledBehavior === 'all' && (item.props?.isDisabled || this.disabledKeys.has(item.key));\n }\n\n getNextKey(key: Key) {\n key = this.collection.getKeyAfter(key);\n while (key != null) {\n let item = this.collection.getItem(key);\n if (item.type === 'item' && !this.isDisabled(item)) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return null;\n }\n\n getPreviousKey(key: Key) {\n key = this.collection.getKeyBefore(key);\n while (key != null) {\n let item = this.collection.getItem(key);\n if (item.type === 'item' && !this.isDisabled(item)) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\n\n return null;\n }\n\n private findKey(\n key: Key,\n nextKey: (key: Key) => Key,\n shouldSkip: (prevRect: DOMRect, itemRect: DOMRect) => boolean\n ) {\n let item = this.getItem(key);\n if (!item) {\n return null;\n }\n\n // Find the item above or below in the same column.\n let prevRect = item.getBoundingClientRect();\n do {\n key = nextKey(key);\n item = this.getItem(key);\n } while (item && shouldSkip(prevRect, item.getBoundingClientRect()));\n\n return key;\n }\n\n private isSameRow(prevRect: DOMRect, itemRect: DOMRect) {\n return prevRect.top === itemRect.top || prevRect.left !== itemRect.left;\n }\n\n private isSameColumn(prevRect: DOMRect, itemRect: DOMRect) {\n return prevRect.left === itemRect.left || prevRect.top !== itemRect.top;\n }\n\n getKeyBelow(key: Key) {\n if (this.layout === 'grid' && this.orientation === 'vertical') {\n return this.findKey(key, (key) => this.getNextKey(key), this.isSameRow);\n } else {\n return this.getNextKey(key);\n }\n }\n\n getKeyAbove(key: Key) {\n if (this.layout === 'grid' && this.orientation === 'vertical') {\n return this.findKey(key, (key) => this.getPreviousKey(key), this.isSameRow);\n } else {\n return this.getPreviousKey(key);\n }\n }\n\n private getNextColumn(key: Key, right: boolean) {\n return right ? this.getPreviousKey(key) : this.getNextKey(key);\n }\n\n getKeyRightOf(key: Key) {\n if (this.layout === 'grid') {\n if (this.orientation === 'vertical') {\n return this.getNextColumn(key, this.direction === 'rtl');\n } else {\n return this.findKey(key, (key) => this.getNextColumn(key, this.direction === 'rtl'), this.isSameColumn);\n }\n } else if (this.orientation === 'horizontal') {\n return this.getNextColumn(key, this.direction === 'rtl');\n }\n\n return null;\n }\n\n getKeyLeftOf(key: Key) {\n if (this.layout === 'grid') {\n if (this.orientation === 'vertical') {\n return this.getNextColumn(key, this.direction === 'ltr');\n } else {\n return this.findKey(key, (key) => this.getNextColumn(key, this.direction === 'ltr'), this.isSameColumn);\n }\n } else if (this.orientation === 'horizontal') {\n return this.getNextColumn(key, this.direction === 'ltr');\n }\n\n return null;\n }\n\n getFirstKey() {\n let key = this.collection.getFirstKey();\n while (key != null) {\n let item = this.collection.getItem(key);\n if (item?.type === 'item' && !this.isDisabled(item)) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return null;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n while (key != null) {\n let item = this.collection.getItem(key);\n if (item.type === 'item' && !this.isDisabled(item)) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\n\n return null;\n }\n\n private getItem(key: Key): HTMLElement {\n return key !== null ? this.ref.current.querySelector(`[data-key=\"${CSS.escape(key.toString())}\"]`) : null;\n }\n\n getKeyPageAbove(key: Key) {\n let menu = this.ref.current;\n let item = this.getItem(key);\n if (!item) {\n return null;\n }\n\n if (!isScrollable(menu)) {\n return this.getFirstKey();\n }\n\n let containerRect = menu.getBoundingClientRect();\n let itemRect = item.getBoundingClientRect();\n if (this.orientation === 'horizontal') {\n let containerX = containerRect.x - menu.scrollLeft;\n let pageX = Math.max(0, (itemRect.x - containerX) + itemRect.width - containerRect.width);\n\n while (item && (itemRect.x - containerX) > pageX) {\n key = this.getKeyAbove(key);\n item = key == null ? null : this.getItem(key);\n itemRect = item?.getBoundingClientRect();\n }\n } else {\n let containerY = containerRect.y - menu.scrollTop;\n let pageY = Math.max(0, (itemRect.y - containerY) + itemRect.height - containerRect.height);\n\n while (item && (itemRect.y - containerY) > pageY) {\n key = this.getKeyAbove(key);\n item = key == null ? null : this.getItem(key);\n itemRect = item?.getBoundingClientRect();\n }\n }\n\n return key ?? this.getFirstKey();\n }\n\n getKeyPageBelow(key: Key) {\n let menu = this.ref.current;\n let item = this.getItem(key);\n if (!item) {\n return null;\n }\n\n if (!isScrollable(menu)) {\n return this.getLastKey();\n }\n\n let containerRect = menu.getBoundingClientRect();\n let itemRect = item.getBoundingClientRect();\n if (this.orientation === 'horizontal') {\n let containerX = containerRect.x - menu.scrollLeft;\n let pageX = Math.min(menu.scrollWidth, (itemRect.x - containerX) - itemRect.width + containerRect.width);\n\n while (item && (itemRect.x - containerX) < pageX) {\n key = this.getKeyBelow(key);\n item = key == null ? null : this.getItem(key);\n itemRect = item?.getBoundingClientRect();\n }\n } else {\n let containerY = containerRect.y - menu.scrollTop;\n let pageY = Math.min(menu.scrollHeight, (itemRect.y - containerY) - itemRect.height + containerRect.height);\n\n while (item && (itemRect.y - containerY) < pageY) {\n key = this.getKeyBelow(key);\n item = key == null ? null : this.getItem(key);\n itemRect = item?.getBoundingClientRect();\n }\n }\n\n return key ?? this.getLastKey();\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey || this.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n let substring = item.textValue.slice(0, search.length);\n if (item.textValue && this.collator.compare(substring, search) === 0) {\n return key;\n }\n\n key = this.getKeyBelow(key);\n }\n\n return null;\n }\n}\n"],"names":[],"version":3,"file":"ListKeyboardDelegate.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAkBM,MAAM;IA4CH,WAAW,IAAmB,EAAE;YACK;QAA3C,OAAO,IAAI,CAAC,gBAAgB,KAAK,SAAU,CAAA,EAAA,cAAA,KAAK,KAAK,cAAV,kCAAA,YAAY,UAAU,KAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,GAAG,CAAA;IACrG;IAEA,WAAW,GAAQ,EAAE;QACnB,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QAClC,MAAO,OAAO,KAAM;YAClB,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACnC,IAAI,KAAK,IAAI,KAAK,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,OAC3C,OAAO;YAGT,MAAM,IAAI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AgB,GAAG;YACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA,GAAA,yCAAgB,EAAE,IAAI,CAAC,GAAG;QACtD;QAEA,wEAAwE;QACxE,mDAAmD;QACnD,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,WAAW,KAAK,YAAY;YAC9D,IAAI,CAAC,YAAY,GAAG;YACpB,IAAI,CAAC,aAAa,GAAG;QACvB;IACF;AAyNF","sources":["packages/@react-aria/selection/src/ListKeyboardDelegate.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Orientation, Rect, RefObject} from '@react-types/shared';\nimport {DOMLayoutDelegate} from './DOMLayoutDelegate';\nimport {isScrollable} from '@react-aria/utils';\n\ninterface ListKeyboardDelegateOptions<T> {\n collection: Collection<Node<T>>,\n ref: RefObject<HTMLElement | null>,\n collator?: Intl.Collator,\n layout?: 'stack' | 'grid',\n orientation?: Orientation,\n direction?: Direction,\n disabledKeys?: Set<Key>,\n disabledBehavior?: DisabledBehavior,\n layoutDelegate?: LayoutDelegate\n}\n\nexport class ListKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<Node<T>>;\n private disabledKeys: Set<Key>;\n private disabledBehavior: DisabledBehavior;\n private ref: RefObject<HTMLElement | null>;\n private collator: Intl.Collator | undefined;\n private layout: 'stack' | 'grid';\n private orientation?: Orientation;\n private direction?: Direction;\n private layoutDelegate: LayoutDelegate;\n\n constructor(collection: Collection<Node<T>>, disabledKeys: Set<Key>, ref: RefObject<HTMLElement | null>, collator?: Intl.Collator);\n constructor(options: ListKeyboardDelegateOptions<T>);\n constructor(...args: any[]) {\n if (args.length === 1) {\n let opts = args[0] as ListKeyboardDelegateOptions<T>;\n this.collection = opts.collection;\n this.ref = opts.ref;\n this.collator = opts.collator;\n this.disabledKeys = opts.disabledKeys || new Set();\n this.disabledBehavior = opts.disabledBehavior || 'all';\n this.orientation = opts.orientation || 'vertical';\n this.direction = opts.direction;\n this.layout = opts.layout || 'stack';\n this.layoutDelegate = opts.layoutDelegate || new DOMLayoutDelegate(opts.ref);\n } else {\n this.collection = args[0];\n this.disabledKeys = args[1];\n this.ref = args[2];\n this.collator = args[3];\n this.layout = 'stack';\n this.orientation = 'vertical';\n this.disabledBehavior = 'all';\n this.layoutDelegate = new DOMLayoutDelegate(this.ref);\n }\n\n // If this is a vertical stack, remove the left/right methods completely\n // so they aren't called by useDroppableCollection.\n if (this.layout === 'stack' && this.orientation === 'vertical') {\n this.getKeyLeftOf = undefined;\n this.getKeyRightOf = undefined;\n }\n }\n\n private isDisabled(item: Node<unknown>) {\n return this.disabledBehavior === 'all' && (item.props?.isDisabled || this.disabledKeys.has(item.key));\n }\n\n getNextKey(key: Key) {\n key = this.collection.getKeyAfter(key);\n while (key != null) {\n let item = this.collection.getItem(key);\n if (item.type === 'item' && !this.isDisabled(item)) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return null;\n }\n\n getPreviousKey(key: Key) {\n key = this.collection.getKeyBefore(key);\n while (key != null) {\n let item = this.collection.getItem(key);\n if (item.type === 'item' && !this.isDisabled(item)) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\n\n return null;\n }\n\n private findKey(\n key: Key,\n nextKey: (key: Key) => Key,\n shouldSkip: (prevRect: Rect, itemRect: Rect) => boolean\n ) {\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n // Find the item above or below in the same column.\n let prevRect = itemRect;\n do {\n key = nextKey(key);\n itemRect = this.layoutDelegate.getItemRect(key);\n } while (itemRect && shouldSkip(prevRect, itemRect));\n\n return key;\n }\n\n private isSameRow(prevRect: Rect, itemRect: Rect) {\n return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;\n }\n\n private isSameColumn(prevRect: Rect, itemRect: Rect) {\n return prevRect.x === itemRect.x || prevRect.y !== itemRect.y;\n }\n\n getKeyBelow(key: Key) {\n if (this.layout === 'grid' && this.orientation === 'vertical') {\n return this.findKey(key, (key) => this.getNextKey(key), this.isSameRow);\n } else {\n return this.getNextKey(key);\n }\n }\n\n getKeyAbove(key: Key) {\n if (this.layout === 'grid' && this.orientation === 'vertical') {\n return this.findKey(key, (key) => this.getPreviousKey(key), this.isSameRow);\n } else {\n return this.getPreviousKey(key);\n }\n }\n\n private getNextColumn(key: Key, right: boolean) {\n return right ? this.getPreviousKey(key) : this.getNextKey(key);\n }\n\n getKeyRightOf(key: Key) {\n if (this.layout === 'grid') {\n if (this.orientation === 'vertical') {\n return this.getNextColumn(key, this.direction === 'rtl');\n } else {\n return this.findKey(key, (key) => this.getNextColumn(key, this.direction === 'rtl'), this.isSameColumn);\n }\n } else if (this.orientation === 'horizontal') {\n return this.getNextColumn(key, this.direction === 'rtl');\n }\n\n return null;\n }\n\n getKeyLeftOf(key: Key) {\n if (this.layout === 'grid') {\n if (this.orientation === 'vertical') {\n return this.getNextColumn(key, this.direction === 'ltr');\n } else {\n return this.findKey(key, (key) => this.getNextColumn(key, this.direction === 'ltr'), this.isSameColumn);\n }\n } else if (this.orientation === 'horizontal') {\n return this.getNextColumn(key, this.direction === 'ltr');\n }\n\n return null;\n }\n\n getFirstKey() {\n let key = this.collection.getFirstKey();\n while (key != null) {\n let item = this.collection.getItem(key);\n if (item?.type === 'item' && !this.isDisabled(item)) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return null;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n while (key != null) {\n let item = this.collection.getItem(key);\n if (item.type === 'item' && !this.isDisabled(item)) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\n\n return null;\n }\n\n getKeyPageAbove(key: Key) {\n let menu = this.ref.current;\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n if (!isScrollable(menu)) {\n return this.getFirstKey();\n }\n\n if (this.orientation === 'horizontal') {\n let pageX = Math.max(0, itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width);\n\n while (itemRect && itemRect.x > pageX) {\n key = this.getKeyAbove(key);\n itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);\n }\n } else {\n let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);\n\n while (itemRect && itemRect.y > pageY) {\n key = this.getKeyAbove(key);\n itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);\n }\n }\n\n return key ?? this.getFirstKey();\n }\n\n getKeyPageBelow(key: Key) {\n let menu = this.ref.current;\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n if (!isScrollable(menu)) {\n return this.getLastKey();\n }\n\n if (this.orientation === 'horizontal') {\n let pageX = Math.min(this.layoutDelegate.getContentSize().width, itemRect.y - itemRect.width + this.layoutDelegate.getVisibleRect().width);\n\n while (itemRect && itemRect.x < pageX) {\n key = this.getKeyBelow(key);\n itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);\n }\n } else {\n let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height);\n\n while (itemRect && itemRect.y < pageY) {\n key = this.getKeyBelow(key);\n itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);\n }\n }\n\n return key ?? this.getLastKey();\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey || this.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n let substring = item.textValue.slice(0, search.length);\n if (item.textValue && this.collator.compare(substring, search) === 0) {\n return key;\n }\n\n key = this.getKeyBelow(key);\n }\n\n return null;\n }\n}\n"],"names":[],"version":3,"file":"ListKeyboardDelegate.module.js.map"}
package/dist/import.mjs CHANGED
@@ -2,6 +2,7 @@ import {useSelectableCollection as $ae20dd8cbca75726$export$d6daf82dcd84e87c} fr
2
2
  import {useSelectableItem as $880e95eb8b93ba9a$export$ecf600387e221c37} from "./useSelectableItem.mjs";
3
3
  import {useSelectableList as $982254629710d113$export$b95089534ab7c1fd} from "./useSelectableList.mjs";
4
4
  import {ListKeyboardDelegate as $2a25aae57d74318e$export$a05409b8bb224a5a} from "./ListKeyboardDelegate.mjs";
5
+ import {DOMLayoutDelegate as $657e4dc4a6e88df0$export$8f5ed9ff9f511381} from "./DOMLayoutDelegate.mjs";
5
6
  import {useTypeSelect as $fb3050f43d946246$export$e32c88dfddc6e1d8} from "./useTypeSelect.mjs";
6
7
 
7
8
  /*
@@ -21,5 +22,6 @@ import {useTypeSelect as $fb3050f43d946246$export$e32c88dfddc6e1d8} from "./useT
21
22
 
22
23
 
23
24
 
24
- export {$ae20dd8cbca75726$export$d6daf82dcd84e87c as useSelectableCollection, $880e95eb8b93ba9a$export$ecf600387e221c37 as useSelectableItem, $982254629710d113$export$b95089534ab7c1fd as useSelectableList, $2a25aae57d74318e$export$a05409b8bb224a5a as ListKeyboardDelegate, $fb3050f43d946246$export$e32c88dfddc6e1d8 as useTypeSelect};
25
+
26
+ export {$ae20dd8cbca75726$export$d6daf82dcd84e87c as useSelectableCollection, $880e95eb8b93ba9a$export$ecf600387e221c37 as useSelectableItem, $982254629710d113$export$b95089534ab7c1fd as useSelectableList, $2a25aae57d74318e$export$a05409b8bb224a5a as ListKeyboardDelegate, $657e4dc4a6e88df0$export$8f5ed9ff9f511381 as DOMLayoutDelegate, $fb3050f43d946246$export$e32c88dfddc6e1d8 as useTypeSelect};
25
27
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -2,6 +2,7 @@ var $b6837c2f80a3c32f$exports = require("./useSelectableCollection.main.js");
2
2
  var $433b1145b0781e10$exports = require("./useSelectableItem.main.js");
3
3
  var $bd230acee196f50c$exports = require("./useSelectableList.main.js");
4
4
  var $836f880b12dcae5c$exports = require("./ListKeyboardDelegate.main.js");
5
+ var $2ac4508142683dcb$exports = require("./DOMLayoutDelegate.main.js");
5
6
  var $a1189052f36475e8$exports = require("./useTypeSelect.main.js");
6
7
 
7
8
 
@@ -13,6 +14,7 @@ $parcel$export(module.exports, "useSelectableCollection", () => $b6837c2f80a3c32
13
14
  $parcel$export(module.exports, "useSelectableItem", () => $433b1145b0781e10$exports.useSelectableItem);
14
15
  $parcel$export(module.exports, "useSelectableList", () => $bd230acee196f50c$exports.useSelectableList);
15
16
  $parcel$export(module.exports, "ListKeyboardDelegate", () => $836f880b12dcae5c$exports.ListKeyboardDelegate);
17
+ $parcel$export(module.exports, "DOMLayoutDelegate", () => $2ac4508142683dcb$exports.DOMLayoutDelegate);
16
18
  $parcel$export(module.exports, "useTypeSelect", () => $a1189052f36475e8$exports.useTypeSelect);
17
19
  /*
18
20
  * Copyright 2020 Adobe. All rights reserved.
@@ -31,4 +33,5 @@ $parcel$export(module.exports, "useTypeSelect", () => $a1189052f36475e8$exports.
31
33
 
32
34
 
33
35
 
36
+
34
37
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/selection/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useSelectableCollection} from './useSelectableCollection';\nexport {useSelectableItem} from './useSelectableItem';\nexport {useSelectableList} from './useSelectableList';\nexport {ListKeyboardDelegate} from './ListKeyboardDelegate';\nexport {useTypeSelect} from './useTypeSelect';\n\nexport type {AriaSelectableCollectionOptions, SelectableCollectionAria} from './useSelectableCollection';\nexport type {AriaSelectableListOptions, SelectableListAria} from './useSelectableList';\nexport type {SelectableItemOptions, SelectableItemStates, SelectableItemAria} from './useSelectableItem';\nexport type {AriaTypeSelectOptions, TypeSelectAria} from './useTypeSelect';\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/selection/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useSelectableCollection} from './useSelectableCollection';\nexport {useSelectableItem} from './useSelectableItem';\nexport {useSelectableList} from './useSelectableList';\nexport {ListKeyboardDelegate} from './ListKeyboardDelegate';\nexport {DOMLayoutDelegate} from './DOMLayoutDelegate';\nexport {useTypeSelect} from './useTypeSelect';\n\nexport type {AriaSelectableCollectionOptions, SelectableCollectionAria} from './useSelectableCollection';\nexport type {AriaSelectableListOptions, SelectableListAria} from './useSelectableList';\nexport type {SelectableItemOptions, SelectableItemStates, SelectableItemAria} from './useSelectableItem';\nexport type {AriaTypeSelectOptions, TypeSelectAria} from './useTypeSelect';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -2,6 +2,7 @@ import {useSelectableCollection as $ae20dd8cbca75726$export$d6daf82dcd84e87c} fr
2
2
  import {useSelectableItem as $880e95eb8b93ba9a$export$ecf600387e221c37} from "./useSelectableItem.module.js";
3
3
  import {useSelectableList as $982254629710d113$export$b95089534ab7c1fd} from "./useSelectableList.module.js";
4
4
  import {ListKeyboardDelegate as $2a25aae57d74318e$export$a05409b8bb224a5a} from "./ListKeyboardDelegate.module.js";
5
+ import {DOMLayoutDelegate as $657e4dc4a6e88df0$export$8f5ed9ff9f511381} from "./DOMLayoutDelegate.module.js";
5
6
  import {useTypeSelect as $fb3050f43d946246$export$e32c88dfddc6e1d8} from "./useTypeSelect.module.js";
6
7
 
7
8
  /*
@@ -21,5 +22,6 @@ import {useTypeSelect as $fb3050f43d946246$export$e32c88dfddc6e1d8} from "./useT
21
22
 
22
23
 
23
24
 
24
- export {$ae20dd8cbca75726$export$d6daf82dcd84e87c as useSelectableCollection, $880e95eb8b93ba9a$export$ecf600387e221c37 as useSelectableItem, $982254629710d113$export$b95089534ab7c1fd as useSelectableList, $2a25aae57d74318e$export$a05409b8bb224a5a as ListKeyboardDelegate, $fb3050f43d946246$export$e32c88dfddc6e1d8 as useTypeSelect};
25
+
26
+ export {$ae20dd8cbca75726$export$d6daf82dcd84e87c as useSelectableCollection, $880e95eb8b93ba9a$export$ecf600387e221c37 as useSelectableItem, $982254629710d113$export$b95089534ab7c1fd as useSelectableList, $2a25aae57d74318e$export$a05409b8bb224a5a as ListKeyboardDelegate, $657e4dc4a6e88df0$export$8f5ed9ff9f511381 as DOMLayoutDelegate, $fb3050f43d946246$export$e32c88dfddc6e1d8 as useTypeSelect};
25
27
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/selection/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useSelectableCollection} from './useSelectableCollection';\nexport {useSelectableItem} from './useSelectableItem';\nexport {useSelectableList} from './useSelectableList';\nexport {ListKeyboardDelegate} from './ListKeyboardDelegate';\nexport {useTypeSelect} from './useTypeSelect';\n\nexport type {AriaSelectableCollectionOptions, SelectableCollectionAria} from './useSelectableCollection';\nexport type {AriaSelectableListOptions, SelectableListAria} from './useSelectableList';\nexport type {SelectableItemOptions, SelectableItemStates, SelectableItemAria} from './useSelectableItem';\nexport type {AriaTypeSelectOptions, TypeSelectAria} from './useTypeSelect';\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/selection/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useSelectableCollection} from './useSelectableCollection';\nexport {useSelectableItem} from './useSelectableItem';\nexport {useSelectableList} from './useSelectableList';\nexport {ListKeyboardDelegate} from './ListKeyboardDelegate';\nexport {DOMLayoutDelegate} from './DOMLayoutDelegate';\nexport {useTypeSelect} from './useTypeSelect';\n\nexport type {AriaSelectableCollectionOptions, SelectableCollectionAria} from './useSelectableCollection';\nexport type {AriaSelectableListOptions, SelectableListAria} from './useSelectableList';\nexport type {SelectableItemOptions, SelectableItemStates, SelectableItemAria} from './useSelectableItem';\nexport type {AriaTypeSelectOptions, TypeSelectAria} from './useTypeSelect';\n"],"names":[],"version":3,"file":"module.js.map"}