@react-aria/selection 3.20.0 → 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 (34) hide show
  1. package/LICENSE +201 -0
  2. package/dist/DOMLayoutDelegate.main.js +9 -6
  3. package/dist/DOMLayoutDelegate.main.js.map +1 -1
  4. package/dist/DOMLayoutDelegate.mjs +9 -6
  5. package/dist/DOMLayoutDelegate.module.js +9 -6
  6. package/dist/DOMLayoutDelegate.module.js.map +1 -1
  7. package/dist/ListKeyboardDelegate.main.js +38 -30
  8. package/dist/ListKeyboardDelegate.main.js.map +1 -1
  9. package/dist/ListKeyboardDelegate.mjs +38 -30
  10. package/dist/ListKeyboardDelegate.module.js +38 -30
  11. package/dist/ListKeyboardDelegate.module.js.map +1 -1
  12. package/dist/types.d.ts +12 -12
  13. package/dist/types.d.ts.map +1 -1
  14. package/dist/useSelectableCollection.main.js +37 -25
  15. package/dist/useSelectableCollection.main.js.map +1 -1
  16. package/dist/useSelectableCollection.mjs +37 -25
  17. package/dist/useSelectableCollection.module.js +37 -25
  18. package/dist/useSelectableCollection.module.js.map +1 -1
  19. package/dist/useSelectableItem.main.js +5 -5
  20. package/dist/useSelectableItem.main.js.map +1 -1
  21. package/dist/useSelectableItem.mjs +5 -5
  22. package/dist/useSelectableItem.module.js +5 -5
  23. package/dist/useSelectableItem.module.js.map +1 -1
  24. package/dist/useTypeSelect.main.js +12 -10
  25. package/dist/useTypeSelect.main.js.map +1 -1
  26. package/dist/useTypeSelect.mjs +12 -10
  27. package/dist/useTypeSelect.module.js +12 -10
  28. package/dist/useTypeSelect.module.js.map +1 -1
  29. package/package.json +12 -11
  30. package/src/DOMLayoutDelegate.ts +11 -8
  31. package/src/ListKeyboardDelegate.ts +46 -34
  32. package/src/useSelectableCollection.ts +38 -32
  33. package/src/useSelectableItem.ts +7 -7
  34. package/src/useTypeSelect.ts +16 -14
@@ -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);
@@ -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;YACn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M,GAAG,KAAK,MAAM,IAAI;YAC7B,IAAI,CAAC,cAAc,GAAG,KAAK,cAAc,IAAI,IAAI,CAAA,GAAA,yCAAgB,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,yCAAgB,EAAE,IAAI,CAAC,GAAG;QACtD;QAEA,wEAAwE;QACxE,mDAAmD;QACnD,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,WAAW,KAAK,YAAY;YAC9D,IAAI,CAAC,YAAY,GAAG;YACpB,IAAI,CAAC,aAAa,GAAG;QACvB;IACF;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.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAkBM,MAAM;IA4CH,WAAW,IAAmB,EAAE;YACK;QAA3C,OAAO,IAAI,CAAC,gBAAgB,KAAK,SAAU,CAAA,EAAA,cAAA,KAAK,KAAK,cAAV,kCAAA,YAAY,UAAU,KAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,GAAG,CAAA;IACrG;IAEQ,oBAAoB,GAAe,EAAE,OAAiC,EAAc;QAC1F,IAAI,UAAU;QACd,MAAO,WAAW,KAAM;YACtB,IAAI,OAAO,IAAI,CAAC,UA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AG;YACnB,IAAI,CAAC,QAAQ,GAAG,KAAK,QAAQ;YAC7B,IAAI,CAAC,YAAY,GAAG,KAAK,YAAY,IAAI,IAAI;YAC7C,IAAI,CAAC,gBAAgB,GAAG,KAAK,gBAAgB,IAAI;YACjD,IAAI,CAAC,WAAW,GAAG,KAAK,WAAW,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,yCAAgB,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,yCAAgB,EAAE,IAAI,CAAC,GAAG;QACtD;QAEA,wEAAwE;QACxE,mDAAmD;QACnD,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,WAAW,KAAK,YAAY;YAC9D,IAAI,CAAC,YAAY,GAAG;YACpB,IAAI,CAAC,aAAa,GAAG;QACvB;IACF;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.module.js.map"}
package/dist/types.d.ts CHANGED
@@ -188,7 +188,7 @@ export interface SelectableItemAria extends SelectableItemStates {
188
188
  */
189
189
  export function useSelectableItem(options: SelectableItemOptions): SelectableItemAria;
190
190
  export class DOMLayoutDelegate implements LayoutDelegate {
191
- constructor(ref: RefObject<HTMLElement>);
191
+ constructor(ref: RefObject<HTMLElement | null>);
192
192
  getItemRect(key: Key): Rect | null;
193
193
  getContentSize(): Size;
194
194
  getVisibleRect(): Rect;
@@ -207,17 +207,17 @@ interface ListKeyboardDelegateOptions<T> {
207
207
  export class ListKeyboardDelegate<T> implements KeyboardDelegate {
208
208
  constructor(collection: Collection<Node<T>>, disabledKeys: Set<Key>, ref: RefObject<HTMLElement | null>, collator?: Intl.Collator);
209
209
  constructor(options: ListKeyboardDelegateOptions<T>);
210
- getNextKey(key: Key): Key;
211
- getPreviousKey(key: Key): Key;
212
- getKeyBelow(key: Key): Key;
213
- getKeyAbove(key: Key): Key;
214
- getKeyRightOf(key: Key): Key;
215
- getKeyLeftOf(key: Key): Key;
216
- getFirstKey(): Key;
217
- getLastKey(): Key;
218
- getKeyPageAbove(key: Key): Key;
219
- getKeyPageBelow(key: Key): Key;
220
- getKeyForSearch(search: string, fromKey?: Key): Key;
210
+ getNextKey(key: Key): Key | null;
211
+ getPreviousKey(key: Key): Key | null;
212
+ getKeyBelow(key: Key): Key | null;
213
+ getKeyAbove(key: Key): Key | null;
214
+ getKeyRightOf?(key: Key): Key | null;
215
+ getKeyLeftOf?(key: Key): Key | null;
216
+ getFirstKey(): Key | null;
217
+ getLastKey(): Key | null;
218
+ getKeyPageAbove(key: Key): Key | null;
219
+ getKeyPageBelow(key: Key): Key | null;
220
+ getKeyForSearch(search: string, fromKey?: Key): Key | null;
221
221
  }
222
222
  export interface AriaSelectableListOptions extends Omit<AriaSelectableCollectionOptions, 'keyboardDelegate'> {
223
223
  /**
@@ -1 +1 @@
1
- {"mappings":";;ACqBA;IACE;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IACnC;;OAEG;IACH,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;CAClC;AAED;IACE;;OAEG;IACH,eAAe,EAAE,aAAa,CAAA;CAC/B;AAED;;GAEG;AACH,8BAA8B,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAuD5E;AC9ED;IACE;;OAEG;IACH,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IACnC;;OAEG;IACH,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAC;IACnC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IACpC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAC;IAC1C;;;;;;OAMG;IACH,YAAY,CA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,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAmB9C;ACpQD,0CAA2C,SAAQ,IAAI,CAAC,+BAA+B,EAAE,kBAAkB,CAAC;IAC1G;;OAEG;IACH,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IACtC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;OAEG;IACH,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA;CACvB;AAED;IACE;;OAEG;IACH,SAAS,EAAE,aAAa,CAAA;CACzB;AAED;;GAEG;AACH,kCAAkC,KAAK,EAAE,yBAAyB,GAAG,kBAAkB,CAmCtF","sources":["packages/@react-aria/selection/src/packages/@react-aria/selection/src/utils.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useTypeSelect.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useSelectableCollection.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useSelectableItem.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/DOMLayoutDelegate.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/ListKeyboardDelegate.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useSelectableList.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/index.ts","packages/@react-aria/selection/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useSelectableCollection} from './useSelectableCollection';\nexport {useSelectableItem} from './useSelectableItem';\nexport {useSelectableList} from './useSelectableList';\nexport {ListKeyboardDelegate} from './ListKeyboardDelegate';\nexport {DOMLayoutDelegate} from './DOMLayoutDelegate';\nexport {useTypeSelect} from './useTypeSelect';\n\nexport type {AriaSelectableCollectionOptions, SelectableCollectionAria} from './useSelectableCollection';\nexport type {AriaSelectableListOptions, SelectableListAria} from './useSelectableList';\nexport type {SelectableItemOptions, SelectableItemStates, SelectableItemAria} from './useSelectableItem';\nexport type {AriaTypeSelectOptions, TypeSelectAria} from './useTypeSelect';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;ACqBA;IACE;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IACnC;;OAEG;IACH,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;CAClC;AAED;IACE;;OAEG;IACH,eAAe,EAAE,aAAa,CAAA;CAC/B;AAED;;GAEG;AACH,8BAA8B,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAyD5E;AChFD;IACE;;OAEG;IACH,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IACnC;;OAEG;IACH,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAC;IACnC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IACpC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;OAE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IAYpB,aAAa,CAAC,CAAC,GAAG,EAAE,GAAG;IAsBvB,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG;IAoBtB,WAAW;IAKX,UAAU;IAKV,eAAe,CAAC,GAAG,EAAE,GAAG;IA+BxB,eAAe,CAAC,GAAG,EAAE,GAAG;IA+BxB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAsB9C;AChRD,0CAA2C,SAAQ,IAAI,CAAC,+BAA+B,EAAE,kBAAkB,CAAC;IAC1G;;OAEG;IACH,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IACtC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;OAEG;IACH,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA;CACvB;AAED;IACE;;OAEG;IACH,SAAS,EAAE,aAAa,CAAA;CACzB;AAED;;GAEG;AACH,kCAAkC,KAAK,EAAE,yBAAyB,GAAG,kBAAkB,CAmCtF","sources":["packages/@react-aria/selection/src/packages/@react-aria/selection/src/utils.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useTypeSelect.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useSelectableCollection.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useSelectableItem.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/DOMLayoutDelegate.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/ListKeyboardDelegate.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useSelectableList.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/index.ts","packages/@react-aria/selection/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useSelectableCollection} from './useSelectableCollection';\nexport {useSelectableItem} from './useSelectableItem';\nexport {useSelectableList} from './useSelectableList';\nexport {ListKeyboardDelegate} from './ListKeyboardDelegate';\nexport {DOMLayoutDelegate} from './DOMLayoutDelegate';\nexport {useTypeSelect} from './useTypeSelect';\n\nexport type {AriaSelectableCollectionOptions, SelectableCollectionAria} from './useSelectableCollection';\nexport type {AriaSelectableListOptions, SelectableListAria} from './useSelectableList';\nexport type {SelectableItemOptions, SelectableItemStates, SelectableItemAria} from './useSelectableItem';\nexport type {AriaTypeSelectOptions, TypeSelectAria} from './useTypeSelect';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -37,21 +37,23 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
37
37
  let { direction: direction } = (0, $bT8Bh$reactariai18n.useLocale)();
38
38
  let router = (0, $bT8Bh$reactariautils.useRouter)();
39
39
  let onKeyDown = (e)=>{
40
+ var _ref_current;
40
41
  // Prevent option + tab from doing anything since it doesn't move focus to the cells, only buttons/checkboxes
41
42
  if (e.altKey && e.key === 'Tab') e.preventDefault();
42
43
  // Keyboard events bubble through portals. Don't handle keyboard events
43
44
  // for elements outside the collection (e.g. menus).
44
- if (!ref.current.contains(e.target)) return;
45
+ if (!((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.contains(e.target))) return;
45
46
  const navigateToKey = (key, childFocus)=>{
46
47
  if (key != null) {
47
48
  if (manager.isLink(key) && linkBehavior === 'selection' && selectOnFocus && !(0, $ee0bdf4faa47f2a8$exports.isNonContiguousSelectionModifier)(e)) {
49
+ var _scrollRef_current;
48
50
  // Set focused key and re-render synchronously to bring item into view if needed.
49
51
  (0, $bT8Bh$reactdom.flushSync)(()=>{
50
52
  manager.setFocusedKey(key, childFocus);
51
53
  });
52
- let item = scrollRef.current.querySelector(`[data-key="${CSS.escape(key.toString())}"]`);
54
+ let item = (_scrollRef_current = scrollRef.current) === null || _scrollRef_current === void 0 ? void 0 : _scrollRef_current.querySelector(`[data-key="${CSS.escape(key.toString())}"]`);
53
55
  let itemProps = manager.getItemProps(key);
54
- router.open(item, e, itemProps.href, itemProps.routerOptions);
56
+ if (item) router.open(item, e, itemProps.href, itemProps.routerOptions);
55
57
  return;
56
58
  }
57
59
  manager.setFocusedKey(key, childFocus);
@@ -86,7 +88,7 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
86
88
  case 'ArrowLeft':
87
89
  if (delegate.getKeyLeftOf) {
88
90
  var _delegate_getKeyLeftOf, _delegate_getFirstKey2, _delegate_getLastKey2;
89
- let nextKey = (_delegate_getKeyLeftOf = delegate.getKeyLeftOf) === null || _delegate_getKeyLeftOf === void 0 ? void 0 : _delegate_getKeyLeftOf.call(delegate, manager.focusedKey);
91
+ let nextKey = manager.focusedKey != null ? (_delegate_getKeyLeftOf = delegate.getKeyLeftOf) === null || _delegate_getKeyLeftOf === void 0 ? void 0 : _delegate_getKeyLeftOf.call(delegate, manager.focusedKey) : null;
90
92
  if (nextKey == null && shouldFocusWrap) nextKey = direction === 'rtl' ? (_delegate_getFirstKey2 = delegate.getFirstKey) === null || _delegate_getFirstKey2 === void 0 ? void 0 : _delegate_getFirstKey2.call(delegate, manager.focusedKey) : (_delegate_getLastKey2 = delegate.getLastKey) === null || _delegate_getLastKey2 === void 0 ? void 0 : _delegate_getLastKey2.call(delegate, manager.focusedKey);
91
93
  if (nextKey != null) {
92
94
  e.preventDefault();
@@ -97,7 +99,7 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
97
99
  case 'ArrowRight':
98
100
  if (delegate.getKeyRightOf) {
99
101
  var _delegate_getKeyRightOf, _delegate_getLastKey3, _delegate_getFirstKey3;
100
- let nextKey = (_delegate_getKeyRightOf = delegate.getKeyRightOf) === null || _delegate_getKeyRightOf === void 0 ? void 0 : _delegate_getKeyRightOf.call(delegate, manager.focusedKey);
102
+ let nextKey = manager.focusedKey != null ? (_delegate_getKeyRightOf = delegate.getKeyRightOf) === null || _delegate_getKeyRightOf === void 0 ? void 0 : _delegate_getKeyRightOf.call(delegate, manager.focusedKey) : null;
101
103
  if (nextKey == null && shouldFocusWrap) nextKey = direction === 'rtl' ? (_delegate_getLastKey3 = delegate.getLastKey) === null || _delegate_getLastKey3 === void 0 ? void 0 : _delegate_getLastKey3.call(delegate, manager.focusedKey) : (_delegate_getFirstKey3 = delegate.getFirstKey) === null || _delegate_getFirstKey3 === void 0 ? void 0 : _delegate_getFirstKey3.call(delegate, manager.focusedKey);
102
104
  if (nextKey != null) {
103
105
  e.preventDefault();
@@ -110,8 +112,10 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
110
112
  e.preventDefault();
111
113
  let firstKey = delegate.getFirstKey(manager.focusedKey, (0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e));
112
114
  manager.setFocusedKey(firstKey);
113
- if ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(firstKey);
114
- else if (selectOnFocus) manager.replaceSelection(firstKey);
115
+ if (firstKey != null) {
116
+ if ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(firstKey);
117
+ else if (selectOnFocus) manager.replaceSelection(firstKey);
118
+ }
115
119
  }
116
120
  break;
117
121
  case 'End':
@@ -119,12 +123,14 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
119
123
  e.preventDefault();
120
124
  let lastKey = delegate.getLastKey(manager.focusedKey, (0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e));
121
125
  manager.setFocusedKey(lastKey);
122
- if ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(lastKey);
123
- else if (selectOnFocus) manager.replaceSelection(lastKey);
126
+ if (lastKey != null) {
127
+ if ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(lastKey);
128
+ else if (selectOnFocus) manager.replaceSelection(lastKey);
129
+ }
124
130
  }
125
131
  break;
126
132
  case 'PageDown':
127
- if (delegate.getKeyPageBelow) {
133
+ if (delegate.getKeyPageBelow && manager.focusedKey != null) {
128
134
  let nextKey = delegate.getKeyPageBelow(manager.focusedKey);
129
135
  if (nextKey != null) {
130
136
  e.preventDefault();
@@ -133,7 +139,7 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
133
139
  }
134
140
  break;
135
141
  case 'PageUp':
136
- if (delegate.getKeyPageAbove) {
142
+ if (delegate.getKeyPageAbove && manager.focusedKey != null) {
137
143
  let nextKey = delegate.getKeyPageAbove(manager.focusedKey);
138
144
  if (nextKey != null) {
139
145
  e.preventDefault();
@@ -167,7 +173,7 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
167
173
  let walker = (0, $bT8Bh$reactariafocus.getFocusableTreeWalker)(ref.current, {
168
174
  tabbable: true
169
175
  });
170
- let next;
176
+ let next = undefined;
171
177
  let last;
172
178
  do {
173
179
  last = walker.lastChild();
@@ -185,10 +191,12 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
185
191
  top: 0,
186
192
  left: 0
187
193
  });
188
- (0, $bT8Bh$reactariautils.useEvent)(scrollRef, 'scroll', isVirtualized ? null : ()=>{
194
+ (0, $bT8Bh$reactariautils.useEvent)(scrollRef, 'scroll', isVirtualized ? undefined : ()=>{
195
+ var _scrollRef_current, _scrollRef_current1;
196
+ var _scrollRef_current_scrollTop, _scrollRef_current_scrollLeft;
189
197
  scrollPos.current = {
190
- top: scrollRef.current.scrollTop,
191
- left: scrollRef.current.scrollLeft
198
+ top: (_scrollRef_current_scrollTop = (_scrollRef_current = scrollRef.current) === null || _scrollRef_current === void 0 ? void 0 : _scrollRef_current.scrollTop) !== null && _scrollRef_current_scrollTop !== void 0 ? _scrollRef_current_scrollTop : 0,
199
+ left: (_scrollRef_current_scrollLeft = (_scrollRef_current1 = scrollRef.current) === null || _scrollRef_current1 === void 0 ? void 0 : _scrollRef_current1.scrollLeft) !== null && _scrollRef_current_scrollLeft !== void 0 ? _scrollRef_current_scrollLeft : 0
192
200
  };
193
201
  });
194
202
  let onFocus = (e)=>{
@@ -201,6 +209,7 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
201
209
  if (!e.currentTarget.contains(e.target)) return;
202
210
  manager.setFocused(true);
203
211
  if (manager.focusedKey == null) {
212
+ var _delegate_getLastKey, _delegate_getFirstKey;
204
213
  let navigateToFirstKey = (key)=>{
205
214
  if (key != null) {
206
215
  manager.setFocusedKey(key);
@@ -212,14 +221,14 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
212
221
  // and either focus the first or last item accordingly.
213
222
  let relatedTarget = e.relatedTarget;
214
223
  var _manager_lastSelectedKey, _manager_firstSelectedKey;
215
- if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToFirstKey((_manager_lastSelectedKey = manager.lastSelectedKey) !== null && _manager_lastSelectedKey !== void 0 ? _manager_lastSelectedKey : delegate.getLastKey());
216
- else navigateToFirstKey((_manager_firstSelectedKey = manager.firstSelectedKey) !== null && _manager_firstSelectedKey !== void 0 ? _manager_firstSelectedKey : delegate.getFirstKey());
217
- } else if (!isVirtualized) {
224
+ if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToFirstKey((_manager_lastSelectedKey = manager.lastSelectedKey) !== null && _manager_lastSelectedKey !== void 0 ? _manager_lastSelectedKey : (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate));
225
+ else navigateToFirstKey((_manager_firstSelectedKey = manager.firstSelectedKey) !== null && _manager_firstSelectedKey !== void 0 ? _manager_firstSelectedKey : (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate));
226
+ } else if (!isVirtualized && scrollRef.current) {
218
227
  // Restore the scroll position to what it was before.
219
228
  scrollRef.current.scrollTop = scrollPos.current.top;
220
229
  scrollRef.current.scrollLeft = scrollPos.current.left;
221
230
  }
222
- if (manager.focusedKey != null) {
231
+ if (manager.focusedKey != null && scrollRef.current) {
223
232
  // Refocus and scroll the focused item into view if it exists within the scrollable region.
224
233
  let element = scrollRef.current.querySelector(`[data-key="${CSS.escape(manager.focusedKey.toString())}"]`);
225
234
  if (element) {
@@ -239,10 +248,13 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
239
248
  const autoFocusRef = (0, $bT8Bh$react.useRef)(autoFocus);
240
249
  (0, $bT8Bh$react.useEffect)(()=>{
241
250
  if (autoFocusRef.current) {
251
+ var _delegate_getFirstKey, _delegate_getLastKey;
242
252
  let focusedKey = null;
253
+ var _delegate_getFirstKey1;
243
254
  // Check focus strategy to determine which item to focus
244
- if (autoFocus === 'first') focusedKey = delegate.getFirstKey();
245
- if (autoFocus === 'last') focusedKey = delegate.getLastKey();
255
+ if (autoFocus === 'first') focusedKey = (_delegate_getFirstKey1 = (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)) !== null && _delegate_getFirstKey1 !== void 0 ? _delegate_getFirstKey1 : null;
256
+ var _delegate_getLastKey1;
257
+ if (autoFocus === 'last') focusedKey = (_delegate_getLastKey1 = (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate)) !== null && _delegate_getLastKey1 !== void 0 ? _delegate_getLastKey1 : null;
246
258
  // If there are any selected keys, make the first one the new focus target
247
259
  let selectedKeys = manager.selectedKeys;
248
260
  if (selectedKeys.size) {
@@ -254,14 +266,14 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
254
266
  manager.setFocused(true);
255
267
  manager.setFocusedKey(focusedKey);
256
268
  // If no default focus key is selected, focus the collection itself.
257
- if (focusedKey == null && !shouldUseVirtualFocus) (0, $bT8Bh$reactariafocus.focusSafely)(ref.current);
269
+ if (focusedKey == null && !shouldUseVirtualFocus && ref.current) (0, $bT8Bh$reactariafocus.focusSafely)(ref.current);
258
270
  }
259
271
  // eslint-disable-next-line react-hooks/exhaustive-deps
260
272
  }, []);
261
273
  // Scroll the focused element into view when the focusedKey changes.
262
274
  let lastFocusedKey = (0, $bT8Bh$react.useRef)(manager.focusedKey);
263
275
  (0, $bT8Bh$react.useEffect)(()=>{
264
- if (manager.isFocused && manager.focusedKey != null && (manager.focusedKey !== lastFocusedKey.current || autoFocusRef.current) && (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
276
+ if (manager.isFocused && manager.focusedKey != null && (manager.focusedKey !== lastFocusedKey.current || autoFocusRef.current) && scrollRef.current && ref.current) {
265
277
  let modality = (0, $bT8Bh$reactariainteractions.getInteractionModality)();
266
278
  let element = ref.current.querySelector(`[data-key="${CSS.escape(manager.focusedKey.toString())}"]`);
267
279
  if (!element) // If item element wasn't found, return early (don't update autoFocusRef and lastFocusedKey).
@@ -276,7 +288,7 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
276
288
  }
277
289
  }
278
290
  // If the focused key becomes null (e.g. the last item is deleted), focus the whole collection.
279
- if (!shouldUseVirtualFocus && manager.isFocused && manager.focusedKey == null && lastFocusedKey.current != null) (0, $bT8Bh$reactariafocus.focusSafely)(ref.current);
291
+ if (!shouldUseVirtualFocus && manager.isFocused && manager.focusedKey == null && lastFocusedKey.current != null && ref.current) (0, $bT8Bh$reactariafocus.focusSafely)(ref.current);
280
292
  lastFocusedKey.current = manager.focusedKey;
281
293
  autoFocusRef.current = false;
282
294
  });
@@ -304,7 +316,7 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
304
316
  // This will be marshalled to either the first or last item depending on where focus came from.
305
317
  // If using virtual focus, don't set a tabIndex at all so that VoiceOver on iOS 14 doesn't try
306
318
  // to move real DOM focus to the element anyway.
307
- let tabIndex;
319
+ let tabIndex = undefined;
308
320
  if (!shouldUseVirtualFocus) tabIndex = manager.focusedKey == null ? 0 : -1;
309
321
  return {
310
322
  collectionProps: {