@react-aria/selection 3.17.5 → 3.18.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 (42) hide show
  1. package/dist/ListKeyboardDelegate.main.js +200 -0
  2. package/dist/ListKeyboardDelegate.main.js.map +1 -0
  3. package/dist/ListKeyboardDelegate.mjs +195 -0
  4. package/dist/ListKeyboardDelegate.module.js +195 -0
  5. package/dist/ListKeyboardDelegate.module.js.map +1 -0
  6. package/dist/import.mjs +5 -794
  7. package/dist/main.js +10 -799
  8. package/dist/main.js.map +1 -1
  9. package/dist/module.js +5 -794
  10. package/dist/module.js.map +1 -1
  11. package/dist/types.d.ts +2 -1
  12. package/dist/types.d.ts.map +1 -1
  13. package/dist/useSelectableCollection.main.js +304 -0
  14. package/dist/useSelectableCollection.main.js.map +1 -0
  15. package/dist/useSelectableCollection.mjs +299 -0
  16. package/dist/useSelectableCollection.module.js +299 -0
  17. package/dist/useSelectableCollection.module.js.map +1 -0
  18. package/dist/useSelectableItem.main.js +213 -0
  19. package/dist/useSelectableItem.main.js.map +1 -0
  20. package/dist/useSelectableItem.mjs +208 -0
  21. package/dist/useSelectableItem.module.js +208 -0
  22. package/dist/useSelectableItem.module.js.map +1 -0
  23. package/dist/useSelectableList.main.js +61 -0
  24. package/dist/useSelectableList.main.js.map +1 -0
  25. package/dist/useSelectableList.mjs +56 -0
  26. package/dist/useSelectableList.module.js +56 -0
  27. package/dist/useSelectableList.module.js.map +1 -0
  28. package/dist/useTypeSelect.main.js +73 -0
  29. package/dist/useTypeSelect.main.js.map +1 -0
  30. package/dist/useTypeSelect.mjs +68 -0
  31. package/dist/useTypeSelect.module.js +68 -0
  32. package/dist/useTypeSelect.module.js.map +1 -0
  33. package/dist/utils.main.js +32 -0
  34. package/dist/utils.main.js.map +1 -0
  35. package/dist/utils.mjs +26 -0
  36. package/dist/utils.module.js +26 -0
  37. package/dist/utils.module.js.map +1 -0
  38. package/package.json +8 -8
  39. package/src/ListKeyboardDelegate.ts +15 -7
  40. package/src/useSelectableCollection.ts +5 -3
  41. package/src/useSelectableItem.ts +4 -2
  42. package/src/useSelectableList.ts +7 -1
@@ -0,0 +1,68 @@
1
+ import {useRef as $dAE4Y$useRef} from "react";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ /**
15
+ * Controls how long to wait before clearing the typeahead buffer.
16
+ */ const $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second
17
+ function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
18
+ let { keyboardDelegate: keyboardDelegate, selectionManager: selectionManager, onTypeSelect: onTypeSelect } = options;
19
+ let state = (0, $dAE4Y$useRef)({
20
+ search: "",
21
+ timeout: null
22
+ }).current;
23
+ let onKeyDown = (e)=>{
24
+ let character = $fb3050f43d946246$var$getStringForKey(e.key);
25
+ if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target)) return;
26
+ // Do not propagate the Spacebar event if it's meant to be part of the search.
27
+ // When we time out, the search term becomes empty, hence the check on length.
28
+ // Trimming is to account for the case of pressing the Spacebar more than once,
29
+ // which should cycle through the selection/deselection of the focused item.
30
+ if (character === " " && state.search.trim().length > 0) {
31
+ e.preventDefault();
32
+ if (!("continuePropagation" in e)) e.stopPropagation();
33
+ }
34
+ state.search += character;
35
+ // Use the delegate to find a key to focus.
36
+ // Prioritize items after the currently focused item, falling back to searching the whole list.
37
+ let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey);
38
+ // If no key found, search from the top.
39
+ if (key == null) key = keyboardDelegate.getKeyForSearch(state.search);
40
+ if (key != null) {
41
+ selectionManager.setFocusedKey(key);
42
+ if (onTypeSelect) onTypeSelect(key);
43
+ }
44
+ clearTimeout(state.timeout);
45
+ state.timeout = setTimeout(()=>{
46
+ state.search = "";
47
+ }, $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS);
48
+ };
49
+ return {
50
+ typeSelectProps: {
51
+ // Using a capturing listener to catch the keydown event before
52
+ // other hooks in order to handle the Spacebar event.
53
+ onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : null
54
+ }
55
+ };
56
+ }
57
+ function $fb3050f43d946246$var$getStringForKey(key) {
58
+ // If the key is of length 1, it is an ASCII value.
59
+ // Otherwise, if there are no ASCII characters in the key name,
60
+ // it is a Unicode character.
61
+ // See https://www.w3.org/TR/uievents-key/
62
+ if (key.length === 1 || !/^[A-Z]/i.test(key)) return key;
63
+ return "";
64
+ }
65
+
66
+
67
+ export {$fb3050f43d946246$export$e32c88dfddc6e1d8 as useTypeSelect};
68
+ //# sourceMappingURL=useTypeSelect.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAMD;;CAEC,GACD,MAAM,mDAA6B,MAAM,WAAW;AA2B7C,SAAS,0CAAc,OAA8B;IAC1D,IAAI,oBAAC,gBAAgB,oBAAE,gBAAgB,gBAAE,YAAY,EAAC,GAAG;IACzD,IAAI,QAAQ,CAAA,GAAA,aAAK,EAAE;QACjB,QAAQ;QACR,SAAS;IACX,GAAG,OAAO;IAEV,IAAI,YAAY,CAAC;QACf,IAAI,YAAY,sCAAgB,EAAE,GAAG;QACrC,IAAI,CAAC,aAAa,EAAE,OAAO,IAAI,EAAE,OAAO,IAAI,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAC5E;QAGF,8EAA8E;QAC9E,8EAA8E;QAC9E,+EAA+E;QAC/E,4EAA4E;QAC5E,IAAI,cAAc,OAAO,MAAM,MAAM,CAAC,IAAI,GAAG,MAAM,GAAG,GAAG;YACvD,EAAE,cAAc;YAChB,IAAI,CAAE,CAAA,yBAAyB,CAAA,GAC7B,EAAE,eAAe;QAErB;QAEA,MAAM,MAAM,IAAI;QAEhB,2CAA2C;QAC3C,+FAA+F;QAC/F,IAAI,MAAM,iBAAiB,eAAe,CAAC,MAAM,MAAM,EAAE,iBAAiB,UAAU;QAEpF,wCAAwC;QACxC,IAAI,OAAO,MACT,MAAM,iBAAiB,eAAe,CAAC,MAAM,MAAM;QAGrD,IAAI,OAAO,MAAM;YACf,iBAAiB,aAAa,CAAC;YAC/B,IAAI,cACF,aAAa;QAEjB;QAEA,aAAa,MAAM,OAAO;QAC1B,MAAM,OAAO,GAAG,WAAW;YACzB,MAAM,MAAM,GAAG;QACjB,GAAG;IACL;IAEA,OAAO;QACL,iBAAiB;YACf,+DAA+D;YAC/D,qDAAqD;YACrD,kBAAkB,iBAAiB,eAAe,GAAG,YAAY;QACnE;IACF;AACF;AAEA,SAAS,sCAAgB,GAAW;IAClC,mDAAmD;IACnD,+DAA+D;IAC/D,6BAA6B;IAC7B,0CAA0C;IAC1C,IAAI,IAAI,MAAM,KAAK,KAAK,CAAC,UAAU,IAAI,CAAC,MACtC,OAAO;IAGT,OAAO;AACT","sources":["packages/@react-aria/selection/src/useTypeSelect.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 {DOMAttributes, Key, KeyboardDelegate} from '@react-types/shared';\nimport {KeyboardEvent, useRef} from 'react';\nimport {MultipleSelectionManager} from '@react-stately/selection';\n\n/**\n * Controls how long to wait before clearing the typeahead buffer.\n */\nconst TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second\n\nexport interface AriaTypeSelectOptions {\n /**\n * A delegate that returns collection item keys with respect to visual layout.\n */\n keyboardDelegate: KeyboardDelegate,\n /**\n * An interface for reading and updating multiple selection state.\n */\n selectionManager: MultipleSelectionManager,\n /**\n * Called when an item is focused by typing.\n */\n onTypeSelect?: (key: Key) => void\n}\n\nexport interface TypeSelectAria {\n /**\n * Props to be spread on the owner of the options.\n */\n typeSelectProps: DOMAttributes\n}\n\n/**\n * Handles typeahead interactions with collections.\n */\nexport function useTypeSelect(options: AriaTypeSelectOptions): TypeSelectAria {\n let {keyboardDelegate, selectionManager, onTypeSelect} = options;\n let state = useRef({\n search: '',\n timeout: null\n }).current;\n\n let onKeyDown = (e: KeyboardEvent) => {\n let character = getStringForKey(e.key);\n if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target as HTMLElement)) {\n return;\n }\n\n // Do not propagate the Spacebar event if it's meant to be part of the search.\n // When we time out, the search term becomes empty, hence the check on length.\n // Trimming is to account for the case of pressing the Spacebar more than once,\n // which should cycle through the selection/deselection of the focused item.\n if (character === ' ' && state.search.trim().length > 0) {\n e.preventDefault();\n if (!('continuePropagation' in e)) {\n e.stopPropagation();\n }\n }\n\n state.search += character;\n\n // Use the delegate to find a key to focus.\n // Prioritize items after the currently focused item, falling back to searching the whole list.\n let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey);\n\n // If no key found, search from the top.\n if (key == null) {\n key = keyboardDelegate.getKeyForSearch(state.search);\n }\n\n if (key != null) {\n selectionManager.setFocusedKey(key);\n if (onTypeSelect) {\n onTypeSelect(key);\n }\n }\n\n clearTimeout(state.timeout);\n state.timeout = setTimeout(() => {\n state.search = '';\n }, TYPEAHEAD_DEBOUNCE_WAIT_MS);\n };\n\n return {\n typeSelectProps: {\n // Using a capturing listener to catch the keydown event before\n // other hooks in order to handle the Spacebar event.\n onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : null\n }\n };\n}\n\nfunction getStringForKey(key: string) {\n // If the key is of length 1, it is an ASCII value.\n // Otherwise, if there are no ASCII characters in the key name,\n // it is a Unicode character.\n // See https://www.w3.org/TR/uievents-key/\n if (key.length === 1 || !/^[A-Z]/i.test(key)) {\n return key;\n }\n\n return '';\n}\n"],"names":[],"version":3,"file":"useTypeSelect.module.js.map"}
@@ -0,0 +1,32 @@
1
+ var $gP8Dl$reactariautils = require("@react-aria/utils");
2
+
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "isNonContiguousSelectionModifier", () => $ee0bdf4faa47f2a8$export$d3e3bd3e26688c04);
9
+ $parcel$export(module.exports, "isCtrlKeyPressed", () => $ee0bdf4faa47f2a8$export$16792effe837dba3);
10
+ /*
11
+ * Copyright 2020 Adobe. All rights reserved.
12
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License. You may obtain a copy
14
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software distributed under
17
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
+ * OF ANY KIND, either express or implied. See the License for the specific language
19
+ * governing permissions and limitations under the License.
20
+ */
21
+ function $ee0bdf4faa47f2a8$export$d3e3bd3e26688c04(e) {
22
+ // Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.
23
+ // On Windows and Ubuntu, Alt + Space has a system wide meaning.
24
+ return (0, $gP8Dl$reactariautils.isAppleDevice)() ? e.altKey : e.ctrlKey;
25
+ }
26
+ function $ee0bdf4faa47f2a8$export$16792effe837dba3(e) {
27
+ if ((0, $gP8Dl$reactariautils.isMac)()) return e.metaKey;
28
+ return e.ctrlKey;
29
+ }
30
+
31
+
32
+ //# sourceMappingURL=utils.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;AAUM,SAAS,0CAAiC,CAAQ;IACvD,qFAAqF;IACrF,gEAAgE;IAChE,OAAO,CAAA,GAAA,mCAAY,MAAM,EAAE,MAAM,GAAG,EAAE,OAAO;AAC/C;AAEO,SAAS,0CAAiB,CAAQ;IACvC,IAAI,CAAA,GAAA,2BAAI,KACN,OAAO,EAAE,OAAO;IAGlB,OAAO,EAAE,OAAO;AAClB","sources":["packages/@react-aria/selection/src/utils.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 {isAppleDevice, isMac} from '@react-aria/utils';\n\ninterface Event {\n altKey: boolean,\n ctrlKey: boolean,\n metaKey: boolean\n}\n\nexport function isNonContiguousSelectionModifier(e: Event) {\n // Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.\n // On Windows and Ubuntu, Alt + Space has a system wide meaning.\n return isAppleDevice() ? e.altKey : e.ctrlKey;\n}\n\nexport function isCtrlKeyPressed(e: Event) {\n if (isMac()) {\n return e.metaKey;\n }\n\n return e.ctrlKey;\n}\n"],"names":[],"version":3,"file":"utils.main.js.map"}
package/dist/utils.mjs ADDED
@@ -0,0 +1,26 @@
1
+ import {isAppleDevice as $jUnAJ$isAppleDevice, isMac as $jUnAJ$isMac} from "@react-aria/utils";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $feb5ffebff200149$export$d3e3bd3e26688c04(e) {
15
+ // Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.
16
+ // On Windows and Ubuntu, Alt + Space has a system wide meaning.
17
+ return (0, $jUnAJ$isAppleDevice)() ? e.altKey : e.ctrlKey;
18
+ }
19
+ function $feb5ffebff200149$export$16792effe837dba3(e) {
20
+ if ((0, $jUnAJ$isMac)()) return e.metaKey;
21
+ return e.ctrlKey;
22
+ }
23
+
24
+
25
+ export {$feb5ffebff200149$export$d3e3bd3e26688c04 as isNonContiguousSelectionModifier, $feb5ffebff200149$export$16792effe837dba3 as isCtrlKeyPressed};
26
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1,26 @@
1
+ import {isAppleDevice as $jUnAJ$isAppleDevice, isMac as $jUnAJ$isMac} from "@react-aria/utils";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $feb5ffebff200149$export$d3e3bd3e26688c04(e) {
15
+ // Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.
16
+ // On Windows and Ubuntu, Alt + Space has a system wide meaning.
17
+ return (0, $jUnAJ$isAppleDevice)() ? e.altKey : e.ctrlKey;
18
+ }
19
+ function $feb5ffebff200149$export$16792effe837dba3(e) {
20
+ if ((0, $jUnAJ$isMac)()) return e.metaKey;
21
+ return e.ctrlKey;
22
+ }
23
+
24
+
25
+ export {$feb5ffebff200149$export$d3e3bd3e26688c04 as isNonContiguousSelectionModifier, $feb5ffebff200149$export$16792effe837dba3 as isCtrlKeyPressed};
26
+ //# sourceMappingURL=utils.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAUM,SAAS,0CAAiC,CAAQ;IACvD,qFAAqF;IACrF,gEAAgE;IAChE,OAAO,CAAA,GAAA,oBAAY,MAAM,EAAE,MAAM,GAAG,EAAE,OAAO;AAC/C;AAEO,SAAS,0CAAiB,CAAQ;IACvC,IAAI,CAAA,GAAA,YAAI,KACN,OAAO,EAAE,OAAO;IAGlB,OAAO,EAAE,OAAO;AAClB","sources":["packages/@react-aria/selection/src/utils.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 {isAppleDevice, isMac} from '@react-aria/utils';\n\ninterface Event {\n altKey: boolean,\n ctrlKey: boolean,\n metaKey: boolean\n}\n\nexport function isNonContiguousSelectionModifier(e: Event) {\n // Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.\n // On Windows and Ubuntu, Alt + Space has a system wide meaning.\n return isAppleDevice() ? e.altKey : e.ctrlKey;\n}\n\nexport function isCtrlKeyPressed(e: Event) {\n if (isMac()) {\n return e.metaKey;\n }\n\n return e.ctrlKey;\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/selection",
3
- "version": "3.17.5",
3
+ "version": "3.18.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,12 +22,12 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/focus": "^3.16.2",
26
- "@react-aria/i18n": "^3.10.2",
27
- "@react-aria/interactions": "^3.21.1",
28
- "@react-aria/utils": "^3.23.2",
29
- "@react-stately/selection": "^3.14.3",
30
- "@react-types/shared": "^3.22.1",
25
+ "@react-aria/focus": "^3.17.0",
26
+ "@react-aria/i18n": "^3.11.0",
27
+ "@react-aria/interactions": "^3.21.2",
28
+ "@react-aria/utils": "^3.24.0",
29
+ "@react-stately/selection": "^3.15.0",
30
+ "@react-types/shared": "^3.23.0",
31
31
  "@swc/helpers": "^0.5.0"
32
32
  },
33
33
  "peerDependencies": {
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "de9f84a22583fc741c29b341d14cd35ef4cca161"
40
+ "gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
41
41
  }
@@ -10,7 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {Collection, Direction, Key, KeyboardDelegate, Node, Orientation} from '@react-types/shared';
13
+ import {Collection, Direction, DisabledBehavior, Key, KeyboardDelegate, Node, Orientation} from '@react-types/shared';
14
14
  import {isScrollable} from '@react-aria/utils';
15
15
  import {RefObject} from 'react';
16
16
 
@@ -21,12 +21,14 @@ interface ListKeyboardDelegateOptions<T> {
21
21
  layout?: 'stack' | 'grid',
22
22
  orientation?: Orientation,
23
23
  direction?: Direction,
24
- disabledKeys?: Set<Key>
24
+ disabledKeys?: Set<Key>,
25
+ disabledBehavior?: DisabledBehavior
25
26
  }
26
27
 
27
28
  export class ListKeyboardDelegate<T> implements KeyboardDelegate {
28
29
  private collection: Collection<Node<T>>;
29
30
  private disabledKeys: Set<Key>;
31
+ private disabledBehavior: DisabledBehavior;
30
32
  private ref: RefObject<HTMLElement>;
31
33
  private collator: Intl.Collator | undefined;
32
34
  private layout: 'stack' | 'grid';
@@ -42,6 +44,7 @@ export class ListKeyboardDelegate<T> implements KeyboardDelegate {
42
44
  this.ref = opts.ref;
43
45
  this.collator = opts.collator;
44
46
  this.disabledKeys = opts.disabledKeys || new Set();
47
+ this.disabledBehavior = opts.disabledBehavior || 'all';
45
48
  this.orientation = opts.orientation;
46
49
  this.direction = opts.direction;
47
50
  this.layout = opts.layout || 'stack';
@@ -52,6 +55,7 @@ export class ListKeyboardDelegate<T> implements KeyboardDelegate {
52
55
  this.collator = args[3];
53
56
  this.layout = 'stack';
54
57
  this.orientation = 'vertical';
58
+ this.disabledBehavior = 'all';
55
59
  }
56
60
 
57
61
  // If this is a vertical stack, remove the left/right methods completely
@@ -62,11 +66,15 @@ export class ListKeyboardDelegate<T> implements KeyboardDelegate {
62
66
  }
63
67
  }
64
68
 
69
+ private isDisabled(item: Node<unknown>) {
70
+ return this.disabledBehavior === 'all' && (item.props?.isDisabled || this.disabledKeys.has(item.key));
71
+ }
72
+
65
73
  getNextKey(key: Key) {
66
74
  key = this.collection.getKeyAfter(key);
67
75
  while (key != null) {
68
76
  let item = this.collection.getItem(key);
69
- if (item.type === 'item' && !this.disabledKeys.has(key)) {
77
+ if (item.type === 'item' && !this.isDisabled(item)) {
70
78
  return key;
71
79
  }
72
80
 
@@ -80,7 +88,7 @@ export class ListKeyboardDelegate<T> implements KeyboardDelegate {
80
88
  key = this.collection.getKeyBefore(key);
81
89
  while (key != null) {
82
90
  let item = this.collection.getItem(key);
83
- if (item.type === 'item' && !this.disabledKeys.has(key)) {
91
+ if (item.type === 'item' && !this.isDisabled(item)) {
84
92
  return key;
85
93
  }
86
94
 
@@ -170,7 +178,7 @@ export class ListKeyboardDelegate<T> implements KeyboardDelegate {
170
178
  let key = this.collection.getFirstKey();
171
179
  while (key != null) {
172
180
  let item = this.collection.getItem(key);
173
- if (item?.type === 'item' && !this.disabledKeys.has(key)) {
181
+ if (item?.type === 'item' && !this.isDisabled(item)) {
174
182
  return key;
175
183
  }
176
184
 
@@ -184,7 +192,7 @@ export class ListKeyboardDelegate<T> implements KeyboardDelegate {
184
192
  let key = this.collection.getLastKey();
185
193
  while (key != null) {
186
194
  let item = this.collection.getItem(key);
187
- if (item.type === 'item' && !this.disabledKeys.has(key)) {
195
+ if (item.type === 'item' && !this.isDisabled(item)) {
188
196
  return key;
189
197
  }
190
198
 
@@ -195,7 +203,7 @@ export class ListKeyboardDelegate<T> implements KeyboardDelegate {
195
203
  }
196
204
 
197
205
  private getItem(key: Key): HTMLElement {
198
- return this.ref.current.querySelector(`[data-key="${CSS.escape(key.toString())}"]`);
206
+ return key !== null ? this.ref.current.querySelector(`[data-key="${CSS.escape(key.toString())}"]`) : null;
199
207
  }
200
208
 
201
209
  getKeyPageAbove(key: Key) {
@@ -141,7 +141,8 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions
141
141
  });
142
142
 
143
143
  let item = scrollRef.current.querySelector(`[data-key="${CSS.escape(key.toString())}"]`);
144
- router.open(item, e);
144
+ let itemProps = manager.getItemProps(key);
145
+ router.open(item, e, itemProps.href, itemProps.routerOptions);
145
146
 
146
147
  return;
147
148
  }
@@ -254,8 +255,9 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions
254
255
  }
255
256
  break;
256
257
  case 'Escape':
257
- e.preventDefault();
258
- if (!disallowEmptySelection) {
258
+ if (!disallowEmptySelection && manager.selectedKeys.size !== 0) {
259
+ e.stopPropagation();
260
+ e.preventDefault();
259
261
  manager.clearSelection();
260
262
  }
261
263
  break;
@@ -131,7 +131,8 @@ export function useSelectableItem(options: SelectableItemOptions): SelectableIte
131
131
 
132
132
  if (manager.isLink(key)) {
133
133
  if (linkBehavior === 'selection') {
134
- router.open(ref.current, e);
134
+ let itemProps = manager.getItemProps(key);
135
+ router.open(ref.current, e, itemProps.href, itemProps.routerOptions);
135
136
  // Always set selected keys back to what they were so that select and combobox close.
136
137
  manager.setSelectedKeys(manager.selectedKeys);
137
138
  return;
@@ -218,7 +219,8 @@ export function useSelectableItem(options: SelectableItemOptions): SelectableIte
218
219
  }
219
220
 
220
221
  if (hasLinkAction) {
221
- router.open(ref.current, e);
222
+ let itemProps = manager.getItemProps(key);
223
+ router.open(ref.current, e, itemProps.href, itemProps.routerOptions);
222
224
  }
223
225
  };
224
226
 
@@ -55,7 +55,13 @@ export function useSelectableList(props: AriaSelectableListOptions): SelectableL
55
55
  let collator = useCollator({usage: 'search', sensitivity: 'base'});
56
56
  let disabledBehavior = selectionManager.disabledBehavior;
57
57
  let delegate = useMemo(() => (
58
- keyboardDelegate || new ListKeyboardDelegate(collection, disabledBehavior === 'selection' ? new Set() : disabledKeys, ref, collator)
58
+ keyboardDelegate || new ListKeyboardDelegate({
59
+ collection,
60
+ disabledKeys,
61
+ disabledBehavior,
62
+ ref,
63
+ collator
64
+ })
59
65
  ), [keyboardDelegate, collection, disabledKeys, ref, collator, disabledBehavior]);
60
66
 
61
67
  let {collectionProps} = useSelectableCollection({