@react-aria/selection 3.20.1 → 3.21.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 (33) hide show
  1. package/dist/DOMLayoutDelegate.main.js +9 -6
  2. package/dist/DOMLayoutDelegate.main.js.map +1 -1
  3. package/dist/DOMLayoutDelegate.mjs +9 -6
  4. package/dist/DOMLayoutDelegate.module.js +9 -6
  5. package/dist/DOMLayoutDelegate.module.js.map +1 -1
  6. package/dist/ListKeyboardDelegate.main.js +38 -30
  7. package/dist/ListKeyboardDelegate.main.js.map +1 -1
  8. package/dist/ListKeyboardDelegate.mjs +38 -30
  9. package/dist/ListKeyboardDelegate.module.js +38 -30
  10. package/dist/ListKeyboardDelegate.module.js.map +1 -1
  11. package/dist/types.d.ts +12 -12
  12. package/dist/types.d.ts.map +1 -1
  13. package/dist/useSelectableCollection.main.js +37 -25
  14. package/dist/useSelectableCollection.main.js.map +1 -1
  15. package/dist/useSelectableCollection.mjs +37 -25
  16. package/dist/useSelectableCollection.module.js +37 -25
  17. package/dist/useSelectableCollection.module.js.map +1 -1
  18. package/dist/useSelectableItem.main.js +5 -5
  19. package/dist/useSelectableItem.main.js.map +1 -1
  20. package/dist/useSelectableItem.mjs +5 -5
  21. package/dist/useSelectableItem.module.js +5 -5
  22. package/dist/useSelectableItem.module.js.map +1 -1
  23. package/dist/useTypeSelect.main.js +12 -10
  24. package/dist/useTypeSelect.main.js.map +1 -1
  25. package/dist/useTypeSelect.mjs +12 -10
  26. package/dist/useTypeSelect.module.js +12 -10
  27. package/dist/useTypeSelect.module.js.map +1 -1
  28. package/package.json +10 -10
  29. package/src/DOMLayoutDelegate.ts +11 -8
  30. package/src/ListKeyboardDelegate.ts +46 -34
  31. package/src/useSelectableCollection.ts +38 -32
  32. package/src/useSelectableItem.ts +7 -7
  33. package/src/useTypeSelect.ts +16 -14
@@ -17,6 +17,7 @@ $parcel$export(module.exports, "DOMLayoutDelegate", () => $2ac4508142683dcb$expo
17
17
  */ class $2ac4508142683dcb$export$8f5ed9ff9f511381 {
18
18
  getItemRect(key) {
19
19
  let container = this.ref.current;
20
+ if (!container) return null;
20
21
  let item = key != null ? container.querySelector(`[data-key="${CSS.escape(key.toString())}"]`) : null;
21
22
  if (!item) return null;
22
23
  let containerRect = container.getBoundingClientRect();
@@ -30,18 +31,20 @@ $parcel$export(module.exports, "DOMLayoutDelegate", () => $2ac4508142683dcb$expo
30
31
  }
31
32
  getContentSize() {
32
33
  let container = this.ref.current;
34
+ var _container_scrollWidth, _container_scrollHeight;
33
35
  return {
34
- width: container.scrollWidth,
35
- height: container.scrollHeight
36
+ width: (_container_scrollWidth = container === null || container === void 0 ? void 0 : container.scrollWidth) !== null && _container_scrollWidth !== void 0 ? _container_scrollWidth : 0,
37
+ height: (_container_scrollHeight = container === null || container === void 0 ? void 0 : container.scrollHeight) !== null && _container_scrollHeight !== void 0 ? _container_scrollHeight : 0
36
38
  };
37
39
  }
38
40
  getVisibleRect() {
39
41
  let container = this.ref.current;
42
+ var _container_scrollLeft, _container_scrollTop, _container_offsetWidth, _container_offsetHeight;
40
43
  return {
41
- x: container.scrollLeft,
42
- y: container.scrollTop,
43
- width: container.offsetWidth,
44
- height: container.offsetHeight
44
+ x: (_container_scrollLeft = container === null || container === void 0 ? void 0 : container.scrollLeft) !== null && _container_scrollLeft !== void 0 ? _container_scrollLeft : 0,
45
+ y: (_container_scrollTop = container === null || container === void 0 ? void 0 : container.scrollTop) !== null && _container_scrollTop !== void 0 ? _container_scrollTop : 0,
46
+ width: (_container_offsetWidth = container === null || container === void 0 ? void 0 : container.offsetWidth) !== null && _container_offsetWidth !== void 0 ? _container_offsetWidth : 0,
47
+ height: (_container_offsetHeight = container === null || container === void 0 ? void 0 : container.offsetHeight) !== null && _container_offsetHeight !== void 0 ? _container_offsetHeight : 0
45
48
  };
46
49
  }
47
50
  constructor(ref){
@@ -1 +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"}
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAOX,YAAY,GAAQ,EAAe;QACjC,IAAI,YAAY,IAAI,CAAC,GAAG,CAAC,OAAO;QAChC,IAAI,CAAC,WACH,OAAO;QAET,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;YAEvB,wBACC;QAFV,OAAO;YACL,OAAO,CAAA,yBAAA,sBAAA,gCAAA,UAAW,WAAW,cAAtB,oCAAA,yBAA0B;YACjC,QAAQ,CAAA,0BAAA,sBAAA,gCAAA,UAAW,YAAY,cAAvB,qCAAA,0BAA2B;QACrC;IACF;IAEA,iBAAuB;QACrB,IAAI,YAAY,IAAI,CAAC,GAAG,CAAC,OAAO;YAE3B,uBACA,sBACI,wBACC;QAJV,OAAO;YACL,GAAG,CAAA,wBAAA,sBAAA,gCAAA,UAAW,UAAU,cAArB,mCAAA,wBAAyB;YAC5B,GAAG,CAAA,uBAAA,sBAAA,gCAAA,UAAW,SAAS,cAApB,kCAAA,uBAAwB;YAC3B,OAAO,CAAA,yBAAA,sBAAA,gCAAA,UAAW,WAAW,cAAtB,oCAAA,yBAA0B;YACjC,QAAQ,CAAA,0BAAA,sBAAA,gCAAA,UAAW,YAAY,cAAvB,qCAAA,0BAA2B;QACrC;IACF;IAzCA,YAAY,GAAkC,CAAE;QAC9C,IAAI,CAAC,GAAG,GAAG;IACb;AAwCF","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 | null>;\n\n constructor(ref: RefObject<HTMLElement | null>) {\n this.ref = ref;\n }\n\n getItemRect(key: Key): Rect | null {\n let container = this.ref.current;\n if (!container) {\n return null;\n }\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 ?? 0,\n height: container?.scrollHeight ?? 0\n };\n }\n\n getVisibleRect(): Rect {\n let container = this.ref.current;\n return {\n x: container?.scrollLeft ?? 0,\n y: container?.scrollTop ?? 0,\n width: container?.offsetWidth ?? 0,\n height: container?.offsetHeight ?? 0\n };\n }\n}\n"],"names":[],"version":3,"file":"DOMLayoutDelegate.main.js.map"}
@@ -11,6 +11,7 @@
11
11
  */ class $657e4dc4a6e88df0$export$8f5ed9ff9f511381 {
12
12
  getItemRect(key) {
13
13
  let container = this.ref.current;
14
+ if (!container) return null;
14
15
  let item = key != null ? container.querySelector(`[data-key="${CSS.escape(key.toString())}"]`) : null;
15
16
  if (!item) return null;
16
17
  let containerRect = container.getBoundingClientRect();
@@ -24,18 +25,20 @@
24
25
  }
25
26
  getContentSize() {
26
27
  let container = this.ref.current;
28
+ var _container_scrollWidth, _container_scrollHeight;
27
29
  return {
28
- width: container.scrollWidth,
29
- height: container.scrollHeight
30
+ width: (_container_scrollWidth = container === null || container === void 0 ? void 0 : container.scrollWidth) !== null && _container_scrollWidth !== void 0 ? _container_scrollWidth : 0,
31
+ height: (_container_scrollHeight = container === null || container === void 0 ? void 0 : container.scrollHeight) !== null && _container_scrollHeight !== void 0 ? _container_scrollHeight : 0
30
32
  };
31
33
  }
32
34
  getVisibleRect() {
33
35
  let container = this.ref.current;
36
+ var _container_scrollLeft, _container_scrollTop, _container_offsetWidth, _container_offsetHeight;
34
37
  return {
35
- x: container.scrollLeft,
36
- y: container.scrollTop,
37
- width: container.offsetWidth,
38
- height: container.offsetHeight
38
+ x: (_container_scrollLeft = container === null || container === void 0 ? void 0 : container.scrollLeft) !== null && _container_scrollLeft !== void 0 ? _container_scrollLeft : 0,
39
+ y: (_container_scrollTop = container === null || container === void 0 ? void 0 : container.scrollTop) !== null && _container_scrollTop !== void 0 ? _container_scrollTop : 0,
40
+ width: (_container_offsetWidth = container === null || container === void 0 ? void 0 : container.offsetWidth) !== null && _container_offsetWidth !== void 0 ? _container_offsetWidth : 0,
41
+ height: (_container_offsetHeight = container === null || container === void 0 ? void 0 : container.offsetHeight) !== null && _container_offsetHeight !== void 0 ? _container_offsetHeight : 0
39
42
  };
40
43
  }
41
44
  constructor(ref){
@@ -11,6 +11,7 @@
11
11
  */ class $657e4dc4a6e88df0$export$8f5ed9ff9f511381 {
12
12
  getItemRect(key) {
13
13
  let container = this.ref.current;
14
+ if (!container) return null;
14
15
  let item = key != null ? container.querySelector(`[data-key="${CSS.escape(key.toString())}"]`) : null;
15
16
  if (!item) return null;
16
17
  let containerRect = container.getBoundingClientRect();
@@ -24,18 +25,20 @@
24
25
  }
25
26
  getContentSize() {
26
27
  let container = this.ref.current;
28
+ var _container_scrollWidth, _container_scrollHeight;
27
29
  return {
28
- width: container.scrollWidth,
29
- height: container.scrollHeight
30
+ width: (_container_scrollWidth = container === null || container === void 0 ? void 0 : container.scrollWidth) !== null && _container_scrollWidth !== void 0 ? _container_scrollWidth : 0,
31
+ height: (_container_scrollHeight = container === null || container === void 0 ? void 0 : container.scrollHeight) !== null && _container_scrollHeight !== void 0 ? _container_scrollHeight : 0
30
32
  };
31
33
  }
32
34
  getVisibleRect() {
33
35
  let container = this.ref.current;
36
+ var _container_scrollLeft, _container_scrollTop, _container_offsetWidth, _container_offsetHeight;
34
37
  return {
35
- x: container.scrollLeft,
36
- y: container.scrollTop,
37
- width: container.offsetWidth,
38
- height: container.offsetHeight
38
+ x: (_container_scrollLeft = container === null || container === void 0 ? void 0 : container.scrollLeft) !== null && _container_scrollLeft !== void 0 ? _container_scrollLeft : 0,
39
+ y: (_container_scrollTop = container === null || container === void 0 ? void 0 : container.scrollTop) !== null && _container_scrollTop !== void 0 ? _container_scrollTop : 0,
40
+ width: (_container_offsetWidth = container === null || container === void 0 ? void 0 : container.offsetWidth) !== null && _container_offsetWidth !== void 0 ? _container_offsetWidth : 0,
41
+ height: (_container_offsetHeight = container === null || container === void 0 ? void 0 : container.offsetHeight) !== null && _container_offsetHeight !== void 0 ? _container_offsetHeight : 0
39
42
  };
40
43
  }
41
44
  constructor(ref){
@@ -1 +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
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAOX,YAAY,GAAQ,EAAe;QACjC,IAAI,YAAY,IAAI,CAAC,GAAG,CAAC,OAAO;QAChC,IAAI,CAAC,WACH,OAAO;QAET,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;YAEvB,wBACC;QAFV,OAAO;YACL,OAAO,CAAA,yBAAA,sBAAA,gCAAA,UAAW,WAAW,cAAtB,oCAAA,yBAA0B;YACjC,QAAQ,CAAA,0BAAA,sBAAA,gCAAA,UAAW,YAAY,cAAvB,qCAAA,0BAA2B;QACrC;IACF;IAEA,iBAAuB;QACrB,IAAI,YAAY,IAAI,CAAC,GAAG,CAAC,OAAO;YAE3B,uBACA,sBACI,wBACC;QAJV,OAAO;YACL,GAAG,CAAA,wBAAA,sBAAA,gCAAA,UAAW,UAAU,cAArB,mCAAA,wBAAyB;YAC5B,GAAG,CAAA,uBAAA,sBAAA,gCAAA,UAAW,SAAS,cAApB,kCAAA,uBAAwB;YAC3B,OAAO,CAAA,yBAAA,sBAAA,gCAAA,UAAW,WAAW,cAAtB,oCAAA,yBAA0B;YACjC,QAAQ,CAAA,0BAAA,sBAAA,gCAAA,UAAW,YAAY,cAAvB,qCAAA,0BAA2B;QACrC;IACF;IAzCA,YAAY,GAAkC,CAAE;QAC9C,IAAI,CAAC,GAAG,GAAG;IACb;AAwCF","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 | null>;\n\n constructor(ref: RefObject<HTMLElement | null>) {\n this.ref = ref;\n }\n\n getItemRect(key: Key): Rect | null {\n let container = this.ref.current;\n if (!container) {\n return null;\n }\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 ?? 0,\n height: container?.scrollHeight ?? 0\n };\n }\n\n getVisibleRect(): Rect {\n let container = this.ref.current;\n return {\n x: container?.scrollLeft ?? 0,\n y: container?.scrollTop ?? 0,\n width: container?.offsetWidth ?? 0,\n height: container?.offsetHeight ?? 0\n };\n }\n}\n"],"names":[],"version":3,"file":"DOMLayoutDelegate.module.js.map"}
@@ -25,31 +25,36 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
25
25
  return this.disabledBehavior === 'all' && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
26
26
  }
27
27
  findNextNonDisabled(key, getNext) {
28
- while(key != null){
29
- let item = this.collection.getItem(key);
30
- if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return key;
31
- key = getNext(key);
28
+ let nextKey = key;
29
+ while(nextKey != null){
30
+ let item = this.collection.getItem(nextKey);
31
+ if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return nextKey;
32
+ nextKey = getNext(nextKey);
32
33
  }
33
34
  return null;
34
35
  }
35
36
  getNextKey(key) {
36
- key = this.collection.getKeyAfter(key);
37
- return this.findNextNonDisabled(key, (key)=>this.collection.getKeyAfter(key));
37
+ let nextKey = key;
38
+ nextKey = this.collection.getKeyAfter(nextKey);
39
+ return this.findNextNonDisabled(nextKey, (key)=>this.collection.getKeyAfter(key));
38
40
  }
39
41
  getPreviousKey(key) {
40
- key = this.collection.getKeyBefore(key);
41
- return this.findNextNonDisabled(key, (key)=>this.collection.getKeyBefore(key));
42
+ let nextKey = key;
43
+ nextKey = this.collection.getKeyBefore(nextKey);
44
+ return this.findNextNonDisabled(nextKey, (key)=>this.collection.getKeyBefore(key));
42
45
  }
43
46
  findKey(key, nextKey, shouldSkip) {
44
- let itemRect = this.layoutDelegate.getItemRect(key);
45
- if (!itemRect) return null;
47
+ let tempKey = key;
48
+ let itemRect = this.layoutDelegate.getItemRect(tempKey);
49
+ if (!itemRect || tempKey == null) return null;
46
50
  // Find the item above or below in the same column.
47
51
  let prevRect = itemRect;
48
52
  do {
49
- key = nextKey(key);
50
- itemRect = this.layoutDelegate.getItemRect(key);
51
- }while (itemRect && shouldSkip(prevRect, itemRect));
52
- return key;
53
+ tempKey = nextKey(tempKey);
54
+ if (tempKey == null) break;
55
+ itemRect = this.layoutDelegate.getItemRect(tempKey);
56
+ }while (itemRect && shouldSkip(prevRect, itemRect) && tempKey != null);
57
+ return tempKey;
53
58
  }
54
59
  isSameRow(prevRect, itemRect) {
55
60
  return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;
@@ -106,41 +111,43 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
106
111
  let menu = this.ref.current;
107
112
  let itemRect = this.layoutDelegate.getItemRect(key);
108
113
  if (!itemRect) return null;
109
- if (!(0, $doKEG$reactariautils.isScrollable)(menu)) return this.getFirstKey();
114
+ if (menu && !(0, $doKEG$reactariautils.isScrollable)(menu)) return this.getFirstKey();
115
+ let nextKey = key;
110
116
  if (this.orientation === 'horizontal') {
111
117
  let pageX = Math.max(0, itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width);
112
- while(itemRect && itemRect.x > pageX){
113
- key = this.getKeyAbove(key);
114
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
118
+ while(itemRect && itemRect.x > pageX && nextKey != null){
119
+ nextKey = this.getKeyAbove(nextKey);
120
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
115
121
  }
116
122
  } else {
117
123
  let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);
118
- while(itemRect && itemRect.y > pageY){
119
- key = this.getKeyAbove(key);
120
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
124
+ while(itemRect && itemRect.y > pageY && nextKey != null){
125
+ nextKey = this.getKeyAbove(nextKey);
126
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
121
127
  }
122
128
  }
123
- return key !== null && key !== void 0 ? key : this.getFirstKey();
129
+ return nextKey !== null && nextKey !== void 0 ? nextKey : this.getFirstKey();
124
130
  }
125
131
  getKeyPageBelow(key) {
126
132
  let menu = this.ref.current;
127
133
  let itemRect = this.layoutDelegate.getItemRect(key);
128
134
  if (!itemRect) return null;
129
- if (!(0, $doKEG$reactariautils.isScrollable)(menu)) return this.getLastKey();
135
+ if (menu && !(0, $doKEG$reactariautils.isScrollable)(menu)) return this.getLastKey();
136
+ let nextKey = key;
130
137
  if (this.orientation === 'horizontal') {
131
138
  let pageX = Math.min(this.layoutDelegate.getContentSize().width, itemRect.y - itemRect.width + this.layoutDelegate.getVisibleRect().width);
132
- while(itemRect && itemRect.x < pageX){
133
- key = this.getKeyBelow(key);
134
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
139
+ while(itemRect && itemRect.x < pageX && nextKey != null){
140
+ nextKey = this.getKeyBelow(nextKey);
141
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
135
142
  }
136
143
  } else {
137
144
  let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height);
138
- while(itemRect && itemRect.y < pageY){
139
- key = this.getKeyBelow(key);
140
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
145
+ while(itemRect && itemRect.y < pageY && nextKey != null){
146
+ nextKey = this.getKeyBelow(nextKey);
147
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
141
148
  }
142
149
  }
143
- return key !== null && key !== void 0 ? key : this.getLastKey();
150
+ return nextKey !== null && nextKey !== void 0 ? nextKey : this.getLastKey();
144
151
  }
145
152
  getKeyForSearch(search, fromKey) {
146
153
  if (!this.collator) return null;
@@ -148,6 +155,7 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
148
155
  let key = fromKey || this.getFirstKey();
149
156
  while(key != null){
150
157
  let item = collection.getItem(key);
158
+ if (!item) return null;
151
159
  let substring = item.textValue.slice(0, search.length);
152
160
  if (item.textValue && this.collator.compare(substring, search) === 0) return key;
153
161
  key = this.getNextKey(key);
@@ -1 +1 @@
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;IAEQ,oBAAoB,GAAQ,EAAE,OAAiC,EAAc;QACnF,MAAO,OAAO,KAAM;YAClB,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACnC,IAAI,CAAA,iBAAA,2BAAA,KAAM,IAAI,MAAK,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,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AAA,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;AAgNF","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 private findNextNonDisabled(key: Key, getNext: (key: Key) => Key | null): Key | null {\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 = getNext(key);\n }\n\n return null;\n }\n\n getNextKey(key: Key) {\n key = this.collection.getKeyAfter(key);\n return this.findNextNonDisabled(key, key => this.collection.getKeyAfter(key));\n }\n\n getPreviousKey(key: Key) {\n key = this.collection.getKeyBefore(key);\n return this.findNextNonDisabled(key, key => this.collection.getKeyBefore(key));\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 // This is a temporary solution for CardView until we refactor useSelectableCollection.\n // https://github.com/orgs/adobe/projects/19/views/32?pane=issue&itemId=77825042\n let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyRightOf' : 'getKeyLeftOf';\n if (this.layoutDelegate[layoutDelegateMethod]) {\n key = this.layoutDelegate[layoutDelegateMethod](key);\n return this.findNextNonDisabled(key, key => this.layoutDelegate[layoutDelegateMethod](key));\n }\n\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 let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyLeftOf' : 'getKeyRightOf';\n if (this.layoutDelegate[layoutDelegateMethod]) {\n key = this.layoutDelegate[layoutDelegateMethod](key);\n return this.findNextNonDisabled(key, key => this.layoutDelegate[layoutDelegateMethod](key));\n }\n\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 return this.findNextNonDisabled(key, key => this.collection.getKeyAfter(key));\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n return this.findNextNonDisabled(key, key => this.collection.getKeyBefore(key));\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.getNextKey(key);\n }\n\n return null;\n }\n}\n"],"names":[],"version":3,"file":"ListKeyboardDelegate.main.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;IAEQ,oBAAoB,GAAe,EAAE,OAAiC,EAAc;QAC1F,IAAI,UAAU;QACd,MAAO,WAAW,KAAM;YACtB,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACnC,IAAI,CAAA,iBAAA,2BAAA,KAAM,IAAI,MAAK,UAA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AG,KAAK,YAAY,IAAI,IAAI;YAC7C,IAAI,CAAC,gBAAgB,GAAG,KAAK,gBAAgB,IAAI;YACjD,IAAI,CAAC,WAAW,GAAG,KAAK,WAAW,IAAI;YACvC,IAAI,CAAC,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;AA4NF","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 private findNextNonDisabled(key: Key | null, getNext: (key: Key) => Key | null): Key | null {\n let nextKey = key;\n while (nextKey != null) {\n let item = this.collection.getItem(nextKey);\n if (item?.type === 'item' && !this.isDisabled(item)) {\n return nextKey;\n }\n\n nextKey = getNext(nextKey);\n }\n\n return null;\n }\n\n getNextKey(key: Key) {\n let nextKey: Key | null = key;\n nextKey = this.collection.getKeyAfter(nextKey);\n return this.findNextNonDisabled(nextKey, key => this.collection.getKeyAfter(key));\n }\n\n getPreviousKey(key: Key) {\n let nextKey: Key | null = key;\n nextKey = this.collection.getKeyBefore(nextKey);\n return this.findNextNonDisabled(nextKey, key => this.collection.getKeyBefore(key));\n }\n\n private findKey(\n key: Key,\n nextKey: (key: Key) => Key | null,\n shouldSkip: (prevRect: Rect, itemRect: Rect) => boolean\n ) {\n let tempKey: Key | null = key;\n let itemRect = this.layoutDelegate.getItemRect(tempKey);\n if (!itemRect || tempKey == null) {\n return null;\n }\n\n // Find the item above or below in the same column.\n let prevRect = itemRect;\n do {\n tempKey = nextKey(tempKey);\n if (tempKey == null) {\n break;\n }\n itemRect = this.layoutDelegate.getItemRect(tempKey);\n } while (itemRect && shouldSkip(prevRect, itemRect) && tempKey != null);\n\n return tempKey;\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 // This is a temporary solution for CardView until we refactor useSelectableCollection.\n // https://github.com/orgs/adobe/projects/19/views/32?pane=issue&itemId=77825042\n let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyRightOf' : 'getKeyLeftOf';\n if (this.layoutDelegate[layoutDelegateMethod]) {\n key = this.layoutDelegate[layoutDelegateMethod](key);\n return this.findNextNonDisabled(key, key => this.layoutDelegate[layoutDelegateMethod](key));\n }\n\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 let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyLeftOf' : 'getKeyRightOf';\n if (this.layoutDelegate[layoutDelegateMethod]) {\n key = this.layoutDelegate[layoutDelegateMethod](key);\n return this.findNextNonDisabled(key, key => this.layoutDelegate[layoutDelegateMethod](key));\n }\n\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 return this.findNextNonDisabled(key, key => this.collection.getKeyAfter(key));\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n return this.findNextNonDisabled(key, key => this.collection.getKeyBefore(key));\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 (menu && !isScrollable(menu)) {\n return this.getFirstKey();\n }\n\n let nextKey: Key | null = key;\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 && nextKey != null) {\n nextKey = this.getKeyAbove(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\n }\n } else {\n let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);\n\n while (itemRect && itemRect.y > pageY && nextKey != null) {\n nextKey = this.getKeyAbove(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\n }\n }\n\n return nextKey ?? 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 (menu && !isScrollable(menu)) {\n return this.getLastKey();\n }\n\n let nextKey: Key | null = key;\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 && nextKey != null) {\n nextKey = this.getKeyBelow(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\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 && nextKey != null) {\n nextKey = this.getKeyBelow(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\n }\n }\n\n return nextKey ?? 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 if (!item) {\n return null;\n }\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.getNextKey(key);\n }\n\n return null;\n }\n}\n"],"names":[],"version":3,"file":"ListKeyboardDelegate.main.js.map"}
@@ -19,31 +19,36 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
19
19
  return this.disabledBehavior === 'all' && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
20
20
  }
21
21
  findNextNonDisabled(key, getNext) {
22
- while(key != null){
23
- let item = this.collection.getItem(key);
24
- if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return key;
25
- key = getNext(key);
22
+ let nextKey = key;
23
+ while(nextKey != null){
24
+ let item = this.collection.getItem(nextKey);
25
+ if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return nextKey;
26
+ nextKey = getNext(nextKey);
26
27
  }
27
28
  return null;
28
29
  }
29
30
  getNextKey(key) {
30
- key = this.collection.getKeyAfter(key);
31
- return this.findNextNonDisabled(key, (key)=>this.collection.getKeyAfter(key));
31
+ let nextKey = key;
32
+ nextKey = this.collection.getKeyAfter(nextKey);
33
+ return this.findNextNonDisabled(nextKey, (key)=>this.collection.getKeyAfter(key));
32
34
  }
33
35
  getPreviousKey(key) {
34
- key = this.collection.getKeyBefore(key);
35
- return this.findNextNonDisabled(key, (key)=>this.collection.getKeyBefore(key));
36
+ let nextKey = key;
37
+ nextKey = this.collection.getKeyBefore(nextKey);
38
+ return this.findNextNonDisabled(nextKey, (key)=>this.collection.getKeyBefore(key));
36
39
  }
37
40
  findKey(key, nextKey, shouldSkip) {
38
- let itemRect = this.layoutDelegate.getItemRect(key);
39
- if (!itemRect) return null;
41
+ let tempKey = key;
42
+ let itemRect = this.layoutDelegate.getItemRect(tempKey);
43
+ if (!itemRect || tempKey == null) return null;
40
44
  // Find the item above or below in the same column.
41
45
  let prevRect = itemRect;
42
46
  do {
43
- key = nextKey(key);
44
- itemRect = this.layoutDelegate.getItemRect(key);
45
- }while (itemRect && shouldSkip(prevRect, itemRect));
46
- return key;
47
+ tempKey = nextKey(tempKey);
48
+ if (tempKey == null) break;
49
+ itemRect = this.layoutDelegate.getItemRect(tempKey);
50
+ }while (itemRect && shouldSkip(prevRect, itemRect) && tempKey != null);
51
+ return tempKey;
47
52
  }
48
53
  isSameRow(prevRect, itemRect) {
49
54
  return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;
@@ -100,41 +105,43 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
100
105
  let menu = this.ref.current;
101
106
  let itemRect = this.layoutDelegate.getItemRect(key);
102
107
  if (!itemRect) return null;
103
- if (!(0, $eak97$isScrollable)(menu)) return this.getFirstKey();
108
+ if (menu && !(0, $eak97$isScrollable)(menu)) return this.getFirstKey();
109
+ let nextKey = key;
104
110
  if (this.orientation === 'horizontal') {
105
111
  let pageX = Math.max(0, itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width);
106
- while(itemRect && itemRect.x > pageX){
107
- key = this.getKeyAbove(key);
108
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
112
+ while(itemRect && itemRect.x > pageX && nextKey != null){
113
+ nextKey = this.getKeyAbove(nextKey);
114
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
109
115
  }
110
116
  } else {
111
117
  let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);
112
- while(itemRect && itemRect.y > pageY){
113
- key = this.getKeyAbove(key);
114
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
118
+ while(itemRect && itemRect.y > pageY && nextKey != null){
119
+ nextKey = this.getKeyAbove(nextKey);
120
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
115
121
  }
116
122
  }
117
- return key !== null && key !== void 0 ? key : this.getFirstKey();
123
+ return nextKey !== null && nextKey !== void 0 ? nextKey : this.getFirstKey();
118
124
  }
119
125
  getKeyPageBelow(key) {
120
126
  let menu = this.ref.current;
121
127
  let itemRect = this.layoutDelegate.getItemRect(key);
122
128
  if (!itemRect) return null;
123
- if (!(0, $eak97$isScrollable)(menu)) return this.getLastKey();
129
+ if (menu && !(0, $eak97$isScrollable)(menu)) return this.getLastKey();
130
+ let nextKey = key;
124
131
  if (this.orientation === 'horizontal') {
125
132
  let pageX = Math.min(this.layoutDelegate.getContentSize().width, itemRect.y - itemRect.width + this.layoutDelegate.getVisibleRect().width);
126
- while(itemRect && itemRect.x < pageX){
127
- key = this.getKeyBelow(key);
128
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
133
+ while(itemRect && itemRect.x < pageX && nextKey != null){
134
+ nextKey = this.getKeyBelow(nextKey);
135
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
129
136
  }
130
137
  } else {
131
138
  let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height);
132
- while(itemRect && itemRect.y < pageY){
133
- key = this.getKeyBelow(key);
134
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
139
+ while(itemRect && itemRect.y < pageY && nextKey != null){
140
+ nextKey = this.getKeyBelow(nextKey);
141
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
135
142
  }
136
143
  }
137
- return key !== null && key !== void 0 ? key : this.getLastKey();
144
+ return nextKey !== null && nextKey !== void 0 ? nextKey : this.getLastKey();
138
145
  }
139
146
  getKeyForSearch(search, fromKey) {
140
147
  if (!this.collator) return null;
@@ -142,6 +149,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
142
149
  let key = fromKey || this.getFirstKey();
143
150
  while(key != null){
144
151
  let item = collection.getItem(key);
152
+ if (!item) return null;
145
153
  let substring = item.textValue.slice(0, search.length);
146
154
  if (item.textValue && this.collator.compare(substring, search) === 0) return key;
147
155
  key = this.getNextKey(key);
@@ -19,31 +19,36 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
19
19
  return this.disabledBehavior === 'all' && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
20
20
  }
21
21
  findNextNonDisabled(key, getNext) {
22
- while(key != null){
23
- let item = this.collection.getItem(key);
24
- if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return key;
25
- key = getNext(key);
22
+ let nextKey = key;
23
+ while(nextKey != null){
24
+ let item = this.collection.getItem(nextKey);
25
+ if ((item === null || item === void 0 ? void 0 : item.type) === 'item' && !this.isDisabled(item)) return nextKey;
26
+ nextKey = getNext(nextKey);
26
27
  }
27
28
  return null;
28
29
  }
29
30
  getNextKey(key) {
30
- key = this.collection.getKeyAfter(key);
31
- return this.findNextNonDisabled(key, (key)=>this.collection.getKeyAfter(key));
31
+ let nextKey = key;
32
+ nextKey = this.collection.getKeyAfter(nextKey);
33
+ return this.findNextNonDisabled(nextKey, (key)=>this.collection.getKeyAfter(key));
32
34
  }
33
35
  getPreviousKey(key) {
34
- key = this.collection.getKeyBefore(key);
35
- return this.findNextNonDisabled(key, (key)=>this.collection.getKeyBefore(key));
36
+ let nextKey = key;
37
+ nextKey = this.collection.getKeyBefore(nextKey);
38
+ return this.findNextNonDisabled(nextKey, (key)=>this.collection.getKeyBefore(key));
36
39
  }
37
40
  findKey(key, nextKey, shouldSkip) {
38
- let itemRect = this.layoutDelegate.getItemRect(key);
39
- if (!itemRect) return null;
41
+ let tempKey = key;
42
+ let itemRect = this.layoutDelegate.getItemRect(tempKey);
43
+ if (!itemRect || tempKey == null) return null;
40
44
  // Find the item above or below in the same column.
41
45
  let prevRect = itemRect;
42
46
  do {
43
- key = nextKey(key);
44
- itemRect = this.layoutDelegate.getItemRect(key);
45
- }while (itemRect && shouldSkip(prevRect, itemRect));
46
- return key;
47
+ tempKey = nextKey(tempKey);
48
+ if (tempKey == null) break;
49
+ itemRect = this.layoutDelegate.getItemRect(tempKey);
50
+ }while (itemRect && shouldSkip(prevRect, itemRect) && tempKey != null);
51
+ return tempKey;
47
52
  }
48
53
  isSameRow(prevRect, itemRect) {
49
54
  return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;
@@ -100,41 +105,43 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
100
105
  let menu = this.ref.current;
101
106
  let itemRect = this.layoutDelegate.getItemRect(key);
102
107
  if (!itemRect) return null;
103
- if (!(0, $eak97$isScrollable)(menu)) return this.getFirstKey();
108
+ if (menu && !(0, $eak97$isScrollable)(menu)) return this.getFirstKey();
109
+ let nextKey = key;
104
110
  if (this.orientation === 'horizontal') {
105
111
  let pageX = Math.max(0, itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width);
106
- while(itemRect && itemRect.x > pageX){
107
- key = this.getKeyAbove(key);
108
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
112
+ while(itemRect && itemRect.x > pageX && nextKey != null){
113
+ nextKey = this.getKeyAbove(nextKey);
114
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
109
115
  }
110
116
  } else {
111
117
  let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);
112
- while(itemRect && itemRect.y > pageY){
113
- key = this.getKeyAbove(key);
114
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
118
+ while(itemRect && itemRect.y > pageY && nextKey != null){
119
+ nextKey = this.getKeyAbove(nextKey);
120
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
115
121
  }
116
122
  }
117
- return key !== null && key !== void 0 ? key : this.getFirstKey();
123
+ return nextKey !== null && nextKey !== void 0 ? nextKey : this.getFirstKey();
118
124
  }
119
125
  getKeyPageBelow(key) {
120
126
  let menu = this.ref.current;
121
127
  let itemRect = this.layoutDelegate.getItemRect(key);
122
128
  if (!itemRect) return null;
123
- if (!(0, $eak97$isScrollable)(menu)) return this.getLastKey();
129
+ if (menu && !(0, $eak97$isScrollable)(menu)) return this.getLastKey();
130
+ let nextKey = key;
124
131
  if (this.orientation === 'horizontal') {
125
132
  let pageX = Math.min(this.layoutDelegate.getContentSize().width, itemRect.y - itemRect.width + this.layoutDelegate.getVisibleRect().width);
126
- while(itemRect && itemRect.x < pageX){
127
- key = this.getKeyBelow(key);
128
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
133
+ while(itemRect && itemRect.x < pageX && nextKey != null){
134
+ nextKey = this.getKeyBelow(nextKey);
135
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
129
136
  }
130
137
  } else {
131
138
  let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height);
132
- while(itemRect && itemRect.y < pageY){
133
- key = this.getKeyBelow(key);
134
- itemRect = key == null ? null : this.layoutDelegate.getItemRect(key);
139
+ while(itemRect && itemRect.y < pageY && nextKey != null){
140
+ nextKey = this.getKeyBelow(nextKey);
141
+ itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
135
142
  }
136
143
  }
137
- return key !== null && key !== void 0 ? key : this.getLastKey();
144
+ return nextKey !== null && nextKey !== void 0 ? nextKey : this.getLastKey();
138
145
  }
139
146
  getKeyForSearch(search, fromKey) {
140
147
  if (!this.collator) return null;
@@ -142,6 +149,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
142
149
  let key = fromKey || this.getFirstKey();
143
150
  while(key != null){
144
151
  let item = collection.getItem(key);
152
+ if (!item) return null;
145
153
  let substring = item.textValue.slice(0, search.length);
146
154
  if (item.textValue && this.collator.compare(substring, search) === 0) return key;
147
155
  key = this.getNextKey(key);