@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
@@ -0,0 +1,53 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+
6
+ $parcel$export(module.exports, "DOMLayoutDelegate", () => $2ac4508142683dcb$export$8f5ed9ff9f511381);
7
+ /*
8
+ * Copyright 2024 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */ class $2ac4508142683dcb$export$8f5ed9ff9f511381 {
18
+ getItemRect(key) {
19
+ let container = this.ref.current;
20
+ let item = key != null ? container.querySelector(`[data-key="${CSS.escape(key.toString())}"]`) : null;
21
+ if (!item) return null;
22
+ let containerRect = container.getBoundingClientRect();
23
+ let itemRect = item.getBoundingClientRect();
24
+ return {
25
+ x: itemRect.left - containerRect.left + container.scrollLeft,
26
+ y: itemRect.top - containerRect.top + container.scrollTop,
27
+ width: itemRect.width,
28
+ height: itemRect.height
29
+ };
30
+ }
31
+ getContentSize() {
32
+ let container = this.ref.current;
33
+ return {
34
+ width: container.scrollWidth,
35
+ height: container.scrollHeight
36
+ };
37
+ }
38
+ getVisibleRect() {
39
+ let container = this.ref.current;
40
+ return {
41
+ x: container.scrollLeft,
42
+ y: container.scrollTop,
43
+ width: container.offsetWidth,
44
+ height: container.offsetHeight
45
+ };
46
+ }
47
+ constructor(ref){
48
+ this.ref = ref;
49
+ }
50
+ }
51
+
52
+
53
+ //# sourceMappingURL=DOMLayoutDelegate.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAOX,YAAY,GAAQ,EAAe;QACjC,IAAI,YAAY,IAAI,CAAC,GAAG,CAAC,OAAO;QAChC,IAAI,OAAO,OAAO,OAAO,UAAU,aAAa,CAAC,CAAC,WAAW,EAAE,IAAI,MAAM,CAAC,IAAI,QAAQ,IAAI,EAAE,CAAC,IAAI;QACjG,IAAI,CAAC,MACH,OAAO;QAGT,IAAI,gBAAgB,UAAU,qBAAqB;QACnD,IAAI,WAAW,KAAK,qBAAqB;QAEzC,OAAO;YACL,GAAG,SAAS,IAAI,GAAG,cAAc,IAAI,GAAG,UAAU,UAAU;YAC5D,GAAG,SAAS,GAAG,GAAG,cAAc,GAAG,GAAG,UAAU,SAAS;YACzD,OAAO,SAAS,KAAK;YACrB,QAAQ,SAAS,MAAM;QACzB;IACF;IAEA,iBAAuB;QACrB,IAAI,YAAY,IAAI,CAAC,GAAG,CAAC,OAAO;QAChC,OAAO;YACL,OAAO,UAAU,WAAW;YAC5B,QAAQ,UAAU,YAAY;QAChC;IACF;IAEA,iBAAuB;QACrB,IAAI,YAAY,IAAI,CAAC,GAAG,CAAC,OAAO;QAChC,OAAO;YACL,GAAG,UAAU,UAAU;YACvB,GAAG,UAAU,SAAS;YACtB,OAAO,UAAU,WAAW;YAC5B,QAAQ,UAAU,YAAY;QAChC;IACF;IAtCA,YAAY,GAA2B,CAAE;QACvC,IAAI,CAAC,GAAG,GAAG;IACb;AAqCF","sources":["packages/@react-aria/selection/src/DOMLayoutDelegate.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {Key, LayoutDelegate, Rect, RefObject, Size} from '@react-types/shared';\n\nexport class DOMLayoutDelegate implements LayoutDelegate {\n private ref: RefObject<HTMLElement>;\n\n constructor(ref: RefObject<HTMLElement>) {\n this.ref = ref;\n }\n\n getItemRect(key: Key): Rect | null {\n let container = this.ref.current;\n let item = key != null ? container.querySelector(`[data-key=\"${CSS.escape(key.toString())}\"]`) : null;\n if (!item) {\n return null;\n }\n\n let containerRect = container.getBoundingClientRect();\n let itemRect = item.getBoundingClientRect();\n\n return {\n x: itemRect.left - containerRect.left + container.scrollLeft,\n y: itemRect.top - containerRect.top + container.scrollTop,\n width: itemRect.width,\n height: itemRect.height\n };\n }\n\n getContentSize(): Size {\n let container = this.ref.current;\n return {\n width: container.scrollWidth,\n height: container.scrollHeight\n };\n }\n\n getVisibleRect(): Rect {\n let container = this.ref.current;\n return {\n x: container.scrollLeft,\n y: container.scrollTop,\n width: container.offsetWidth,\n height: container.offsetHeight\n };\n }\n}\n"],"names":[],"version":3,"file":"DOMLayoutDelegate.main.js.map"}
@@ -0,0 +1,48 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ class $657e4dc4a6e88df0$export$8f5ed9ff9f511381 {
12
+ getItemRect(key) {
13
+ let container = this.ref.current;
14
+ let item = key != null ? container.querySelector(`[data-key="${CSS.escape(key.toString())}"]`) : null;
15
+ if (!item) return null;
16
+ let containerRect = container.getBoundingClientRect();
17
+ let itemRect = item.getBoundingClientRect();
18
+ return {
19
+ x: itemRect.left - containerRect.left + container.scrollLeft,
20
+ y: itemRect.top - containerRect.top + container.scrollTop,
21
+ width: itemRect.width,
22
+ height: itemRect.height
23
+ };
24
+ }
25
+ getContentSize() {
26
+ let container = this.ref.current;
27
+ return {
28
+ width: container.scrollWidth,
29
+ height: container.scrollHeight
30
+ };
31
+ }
32
+ getVisibleRect() {
33
+ let container = this.ref.current;
34
+ return {
35
+ x: container.scrollLeft,
36
+ y: container.scrollTop,
37
+ width: container.offsetWidth,
38
+ height: container.offsetHeight
39
+ };
40
+ }
41
+ constructor(ref){
42
+ this.ref = ref;
43
+ }
44
+ }
45
+
46
+
47
+ export {$657e4dc4a6e88df0$export$8f5ed9ff9f511381 as DOMLayoutDelegate};
48
+ //# sourceMappingURL=DOMLayoutDelegate.module.js.map
@@ -0,0 +1,48 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ class $657e4dc4a6e88df0$export$8f5ed9ff9f511381 {
12
+ getItemRect(key) {
13
+ let container = this.ref.current;
14
+ let item = key != null ? container.querySelector(`[data-key="${CSS.escape(key.toString())}"]`) : null;
15
+ if (!item) return null;
16
+ let containerRect = container.getBoundingClientRect();
17
+ let itemRect = item.getBoundingClientRect();
18
+ return {
19
+ x: itemRect.left - containerRect.left + container.scrollLeft,
20
+ y: itemRect.top - containerRect.top + container.scrollTop,
21
+ width: itemRect.width,
22
+ height: itemRect.height
23
+ };
24
+ }
25
+ getContentSize() {
26
+ let container = this.ref.current;
27
+ return {
28
+ width: container.scrollWidth,
29
+ height: container.scrollHeight
30
+ };
31
+ }
32
+ getVisibleRect() {
33
+ let container = this.ref.current;
34
+ return {
35
+ x: container.scrollLeft,
36
+ y: container.scrollTop,
37
+ width: container.offsetWidth,
38
+ height: container.offsetHeight
39
+ };
40
+ }
41
+ constructor(ref){
42
+ this.ref = ref;
43
+ }
44
+ }
45
+
46
+
47
+ export {$657e4dc4a6e88df0$export$8f5ed9ff9f511381 as DOMLayoutDelegate};
48
+ //# sourceMappingURL=DOMLayoutDelegate.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAOX,YAAY,GAAQ,EAAe;QACjC,IAAI,YAAY,IAAI,CAAC,GAAG,CAAC,OAAO;QAChC,IAAI,OAAO,OAAO,OAAO,UAAU,aAAa,CAAC,CAAC,WAAW,EAAE,IAAI,MAAM,CAAC,IAAI,QAAQ,IAAI,EAAE,CAAC,IAAI;QACjG,IAAI,CAAC,MACH,OAAO;QAGT,IAAI,gBAAgB,UAAU,qBAAqB;QACnD,IAAI,WAAW,KAAK,qBAAqB;QAEzC,OAAO;YACL,GAAG,SAAS,IAAI,GAAG,cAAc,IAAI,GAAG,UAAU,UAAU;YAC5D,GAAG,SAAS,GAAG,GAAG,cAAc,GAAG,GAAG,UAAU,SAAS;YACzD,OAAO,SAAS,KAAK;YACrB,QAAQ,SAAS,MAAM;QACzB;IACF;IAEA,iBAAuB;QACrB,IAAI,YAAY,IAAI,CAAC,GAAG,CAAC,OAAO;QAChC,OAAO;YACL,OAAO,UAAU,WAAW;YAC5B,QAAQ,UAAU,YAAY;QAChC;IACF;IAEA,iBAAuB;QACrB,IAAI,YAAY,IAAI,CAAC,GAAG,CAAC,OAAO;QAChC,OAAO;YACL,GAAG,UAAU,UAAU;YACvB,GAAG,UAAU,SAAS;YACtB,OAAO,UAAU,WAAW;YAC5B,QAAQ,UAAU,YAAY;QAChC;IACF;IAtCA,YAAY,GAA2B,CAAE;QACvC,IAAI,CAAC,GAAG,GAAG;IACb;AAqCF","sources":["packages/@react-aria/selection/src/DOMLayoutDelegate.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {Key, LayoutDelegate, Rect, RefObject, Size} from '@react-types/shared';\n\nexport class DOMLayoutDelegate implements LayoutDelegate {\n private ref: RefObject<HTMLElement>;\n\n constructor(ref: RefObject<HTMLElement>) {\n this.ref = ref;\n }\n\n getItemRect(key: Key): Rect | null {\n let container = this.ref.current;\n let item = key != null ? container.querySelector(`[data-key=\"${CSS.escape(key.toString())}\"]`) : null;\n if (!item) {\n return null;\n }\n\n let containerRect = container.getBoundingClientRect();\n let itemRect = item.getBoundingClientRect();\n\n return {\n x: itemRect.left - containerRect.left + container.scrollLeft,\n y: itemRect.top - containerRect.top + container.scrollTop,\n width: itemRect.width,\n height: itemRect.height\n };\n }\n\n getContentSize(): Size {\n let container = this.ref.current;\n return {\n width: container.scrollWidth,\n height: container.scrollHeight\n };\n }\n\n getVisibleRect(): Rect {\n let container = this.ref.current;\n return {\n x: container.scrollLeft,\n y: container.scrollTop,\n width: container.offsetWidth,\n height: container.offsetHeight\n };\n }\n}\n"],"names":[],"version":3,"file":"DOMLayoutDelegate.module.js.map"}
@@ -1,3 +1,4 @@
1
+ var $2ac4508142683dcb$exports = require("./DOMLayoutDelegate.main.js");
1
2
  var $doKEG$reactariautils = require("@react-aria/utils");
2
3
 
3
4
 
@@ -17,16 +18,17 @@ $parcel$export(module.exports, "ListKeyboardDelegate", () => $836f880b12dcae5c$e
17
18
  * OF ANY KIND, either express or implied. See the License for the specific language
18
19
  * governing permissions and limitations under the License.
19
20
  */
21
+
20
22
  class $836f880b12dcae5c$export$a05409b8bb224a5a {
21
23
  isDisabled(item) {
22
24
  var _item_props;
23
- return this.disabledBehavior === "all" && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
25
+ return this.disabledBehavior === 'all' && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
24
26
  }
25
27
  getNextKey(key) {
26
28
  key = this.collection.getKeyAfter(key);
27
29
  while(key != null){
28
30
  let item = this.collection.getItem(key);
29
- if (item.type === "item" && !this.isDisabled(item)) return key;
31
+ if (item.type === 'item' && !this.isDisabled(item)) return key;
30
32
  key = this.collection.getKeyAfter(key);
31
33
  }
32
34
  return null;
@@ -35,58 +37,58 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
35
37
  key = this.collection.getKeyBefore(key);
36
38
  while(key != null){
37
39
  let item = this.collection.getItem(key);
38
- if (item.type === "item" && !this.isDisabled(item)) return key;
40
+ if (item.type === 'item' && !this.isDisabled(item)) return key;
39
41
  key = this.collection.getKeyBefore(key);
40
42
  }
41
43
  return null;
42
44
  }
43
45
  findKey(key, nextKey, shouldSkip) {
44
- let item = this.getItem(key);
45
- if (!item) return null;
46
+ let itemRect = this.layoutDelegate.getItemRect(key);
47
+ if (!itemRect) return null;
46
48
  // Find the item above or below in the same column.
47
- let prevRect = item.getBoundingClientRect();
49
+ let prevRect = itemRect;
48
50
  do {
49
51
  key = nextKey(key);
50
- item = this.getItem(key);
51
- }while (item && shouldSkip(prevRect, item.getBoundingClientRect()));
52
+ itemRect = this.layoutDelegate.getItemRect(key);
53
+ }while (itemRect && shouldSkip(prevRect, itemRect));
52
54
  return key;
53
55
  }
54
56
  isSameRow(prevRect, itemRect) {
55
- return prevRect.top === itemRect.top || prevRect.left !== itemRect.left;
57
+ return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;
56
58
  }
57
59
  isSameColumn(prevRect, itemRect) {
58
- return prevRect.left === itemRect.left || prevRect.top !== itemRect.top;
60
+ return prevRect.x === itemRect.x || prevRect.y !== itemRect.y;
59
61
  }
60
62
  getKeyBelow(key) {
61
- if (this.layout === "grid" && this.orientation === "vertical") return this.findKey(key, (key)=>this.getNextKey(key), this.isSameRow);
63
+ if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getNextKey(key), this.isSameRow);
62
64
  else return this.getNextKey(key);
63
65
  }
64
66
  getKeyAbove(key) {
65
- if (this.layout === "grid" && this.orientation === "vertical") return this.findKey(key, (key)=>this.getPreviousKey(key), this.isSameRow);
67
+ if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getPreviousKey(key), this.isSameRow);
66
68
  else return this.getPreviousKey(key);
67
69
  }
68
70
  getNextColumn(key, right) {
69
71
  return right ? this.getPreviousKey(key) : this.getNextKey(key);
70
72
  }
71
73
  getKeyRightOf(key) {
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");
74
+ if (this.layout === 'grid') {
75
+ if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'rtl');
76
+ else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'rtl'), this.isSameColumn);
77
+ } else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'rtl');
76
78
  return null;
77
79
  }
78
80
  getKeyLeftOf(key) {
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");
81
+ if (this.layout === 'grid') {
82
+ if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'ltr');
83
+ else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'ltr'), this.isSameColumn);
84
+ } else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'ltr');
83
85
  return null;
84
86
  }
85
87
  getFirstKey() {
86
88
  let key = this.collection.getFirstKey();
87
89
  while(key != null){
88
90
  let item = this.collection.getItem(key);
89
- if ((item === null || item === void 0 ? void 0 : item.type) === "item" && !this.isDisabled(item)) return key;
91
+ if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return key;
90
92
  key = this.collection.getKeyAfter(key);
91
93
  }
92
94
  return null;
@@ -95,62 +97,47 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
95
97
  let key = this.collection.getLastKey();
96
98
  while(key != null){
97
99
  let item = this.collection.getItem(key);
98
- if (item.type === "item" && !this.isDisabled(item)) return key;
100
+ if (item.type === 'item' && !this.isDisabled(item)) return key;
99
101
  key = this.collection.getKeyBefore(key);
100
102
  }
101
103
  return null;
102
104
  }
103
- getItem(key) {
104
- return key !== null ? this.ref.current.querySelector(`[data-key="${CSS.escape(key.toString())}"]`) : null;
105
- }
106
105
  getKeyPageAbove(key) {
107
106
  let menu = this.ref.current;
108
- let item = this.getItem(key);
109
- if (!item) return null;
107
+ let itemRect = this.layoutDelegate.getItemRect(key);
108
+ if (!itemRect) return null;
110
109
  if (!(0, $doKEG$reactariautils.isScrollable)(menu)) return this.getFirstKey();
111
- let containerRect = menu.getBoundingClientRect();
112
- let itemRect = item.getBoundingClientRect();
113
- if (this.orientation === "horizontal") {
114
- let containerX = containerRect.x - menu.scrollLeft;
115
- let pageX = Math.max(0, itemRect.x - containerX + itemRect.width - containerRect.width);
116
- while(item && itemRect.x - containerX > pageX){
110
+ if (this.orientation === 'horizontal') {
111
+ let pageX = Math.max(0, itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width);
112
+ while(itemRect && itemRect.x > pageX){
117
113
  key = this.getKeyAbove(key);
118
- item = key == null ? null : this.getItem(key);
119
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
114
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
120
115
  }
121
116
  } else {
122
- let containerY = containerRect.y - menu.scrollTop;
123
- let pageY = Math.max(0, itemRect.y - containerY + itemRect.height - containerRect.height);
124
- while(item && itemRect.y - containerY > pageY){
117
+ let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);
118
+ while(itemRect && itemRect.y > pageY){
125
119
  key = this.getKeyAbove(key);
126
- item = key == null ? null : this.getItem(key);
127
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
120
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
128
121
  }
129
122
  }
130
123
  return key !== null && key !== void 0 ? key : this.getFirstKey();
131
124
  }
132
125
  getKeyPageBelow(key) {
133
126
  let menu = this.ref.current;
134
- let item = this.getItem(key);
135
- if (!item) return null;
127
+ let itemRect = this.layoutDelegate.getItemRect(key);
128
+ if (!itemRect) return null;
136
129
  if (!(0, $doKEG$reactariautils.isScrollable)(menu)) return this.getLastKey();
137
- let containerRect = menu.getBoundingClientRect();
138
- let itemRect = item.getBoundingClientRect();
139
- if (this.orientation === "horizontal") {
140
- let containerX = containerRect.x - menu.scrollLeft;
141
- let pageX = Math.min(menu.scrollWidth, itemRect.x - containerX - itemRect.width + containerRect.width);
142
- while(item && itemRect.x - containerX < pageX){
130
+ if (this.orientation === 'horizontal') {
131
+ let pageX = Math.min(this.layoutDelegate.getContentSize().width, itemRect.y - itemRect.width + this.layoutDelegate.getVisibleRect().width);
132
+ while(itemRect && itemRect.x < pageX){
143
133
  key = this.getKeyBelow(key);
144
- item = key == null ? null : this.getItem(key);
145
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
134
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
146
135
  }
147
136
  } else {
148
- let containerY = containerRect.y - menu.scrollTop;
149
- let pageY = Math.min(menu.scrollHeight, itemRect.y - containerY - itemRect.height + containerRect.height);
150
- while(item && itemRect.y - containerY < pageY){
137
+ let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height);
138
+ while(itemRect && itemRect.y < pageY){
151
139
  key = this.getKeyBelow(key);
152
- item = key == null ? null : this.getItem(key);
153
- itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
140
+ itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
154
141
  }
155
142
  }
156
143
  return key !== null && key !== void 0 ? key : this.getLastKey();
@@ -174,22 +161,24 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
174
161
  this.ref = opts.ref;
175
162
  this.collator = opts.collator;
176
163
  this.disabledKeys = opts.disabledKeys || new Set();
177
- this.disabledBehavior = opts.disabledBehavior || "all";
178
- this.orientation = opts.orientation;
164
+ this.disabledBehavior = opts.disabledBehavior || 'all';
165
+ this.orientation = opts.orientation || 'vertical';
179
166
  this.direction = opts.direction;
180
- this.layout = opts.layout || "stack";
167
+ this.layout = opts.layout || 'stack';
168
+ this.layoutDelegate = opts.layoutDelegate || new (0, $2ac4508142683dcb$exports.DOMLayoutDelegate)(opts.ref);
181
169
  } else {
182
170
  this.collection = args[0];
183
171
  this.disabledKeys = args[1];
184
172
  this.ref = args[2];
185
173
  this.collator = args[3];
186
- this.layout = "stack";
187
- this.orientation = "vertical";
188
- this.disabledBehavior = "all";
174
+ this.layout = 'stack';
175
+ this.orientation = 'vertical';
176
+ this.disabledBehavior = 'all';
177
+ this.layoutDelegate = new (0, $2ac4508142683dcb$exports.DOMLayoutDelegate)(this.ref);
189
178
  }
190
179
  // If this is a vertical stack, remove the left/right methods completely
191
180
  // so they aren't called by useDroppableCollection.
192
- if (this.layout === "stack" && this.orientation === "vertical") {
181
+ if (this.layout === 'stack' && this.orientation === 'vertical') {
193
182
  this.getKeyLeftOf = undefined;
194
183
  this.getKeyRightOf = undefined;
195
184
  }
@@ -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,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,CAAC,UAAU,CAAC,WAAW,CAAC;QACpC;QAEA,OAAO;IACT;IAEA,eAAe,GAAQ,EAAE;QACvB,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QACnC,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,CAAC,UAAU,CAAC,YAAY,CAAC;QACrC;QAEA,OAAO;IACT;IAEQ,QACN,GAAQ,EACR,OAA0B,EAC1B,UAA6D,EAC7D;QACA,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC;QACxB,IAAI,CAAC,MACH,OAAO;QAGT,mDAAmD;QACnD,IAAI,WAAW,KAAK,qBAAqB;QACzC,GAAG;YACD,MAAM,QAAQ;YACd,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,QA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AC,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.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAk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,SAAS,GAAG,KAAK,SAAS;YAC/B,IAAI,CAAC,MAAM,GAAG,KAAK,MAAM,IAAI;YAC7B,IAAI,CAAC,cAAc,GAAG,KAAK,cAAc,IAAI,IAAI,CAAA,GAAA,2CAAgB,EAAE,KAAK,GAAG;QAC7E,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;YACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA,GAAA,2CAAgB,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.main.js.map"}