@react-aria/selection 3.27.2 → 3.28.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.
- package/dist/import.mjs +7 -7
- package/dist/main.js +12 -12
- package/dist/main.js.map +1 -1
- package/dist/module.js +7 -7
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +10 -0
- package/package.json +15 -17
- package/src/index.ts +10 -10
- package/dist/DOMLayoutDelegate.main.js +0 -59
- package/dist/DOMLayoutDelegate.main.js.map +0 -1
- package/dist/DOMLayoutDelegate.mjs +0 -54
- package/dist/DOMLayoutDelegate.module.js +0 -54
- package/dist/DOMLayoutDelegate.module.js.map +0 -1
- package/dist/ListKeyboardDelegate.main.js +0 -197
- package/dist/ListKeyboardDelegate.main.js.map +0 -1
- package/dist/ListKeyboardDelegate.mjs +0 -192
- package/dist/ListKeyboardDelegate.module.js +0 -192
- package/dist/ListKeyboardDelegate.module.js.map +0 -1
- package/dist/types.d.ts +0 -258
- package/dist/types.d.ts.map +0 -1
- package/dist/useSelectableCollection.main.js +0 -404
- package/dist/useSelectableCollection.main.js.map +0 -1
- package/dist/useSelectableCollection.mjs +0 -399
- package/dist/useSelectableCollection.module.js +0 -399
- package/dist/useSelectableCollection.module.js.map +0 -1
- package/dist/useSelectableItem.main.js +0 -263
- package/dist/useSelectableItem.main.js.map +0 -1
- package/dist/useSelectableItem.mjs +0 -258
- package/dist/useSelectableItem.module.js +0 -258
- package/dist/useSelectableItem.module.js.map +0 -1
- package/dist/useSelectableList.main.js +0 -63
- package/dist/useSelectableList.main.js.map +0 -1
- package/dist/useSelectableList.mjs +0 -58
- package/dist/useSelectableList.module.js +0 -58
- package/dist/useSelectableList.module.js.map +0 -1
- package/dist/useTypeSelect.main.js +0 -77
- package/dist/useTypeSelect.main.js.map +0 -1
- package/dist/useTypeSelect.mjs +0 -72
- package/dist/useTypeSelect.module.js +0 -72
- package/dist/useTypeSelect.module.js.map +0 -1
- package/dist/utils.main.js +0 -46
- package/dist/utils.main.js.map +0 -1
- package/dist/utils.mjs +0 -38
- package/dist/utils.module.js +0 -38
- package/dist/utils.module.js.map +0 -1
- package/src/DOMLayoutDelegate.ts +0 -61
- package/src/ListKeyboardDelegate.ts +0 -291
- package/src/useSelectableCollection.ts +0 -594
- package/src/useSelectableItem.ts +0 -422
- package/src/useSelectableList.ts +0 -85
- package/src/useTypeSelect.ts +0 -117
- package/src/utils.ts +0 -47
|
@@ -1 +0,0 @@
|
|
|
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,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,OAC5C,OAAO;YAGT,UAAU,QAAQ;QACpB;QAEA,OAAO;IACT;IAEA,WAAW,GAAQ,EAAc;QAC/B,IAAI,UAAsB;QAC1B,UAAU,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QACtC,OAAO,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAA,MAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;IAC9E;IAEA,eAAe,GAAQ,EAAc;QACnC,IAAI,UAAsB;QAC1B,UAAU,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QACvC,OAAO,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAA,MAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;IA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AAE;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, expandedKeys?: Set<Key>);\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): Key | null {\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): Key | null {\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): Key | null {\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): Key | null {\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): Key | null {\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): Key | null {\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(): Key | null {\n let key = this.collection.getFirstKey();\n return this.findNextNonDisabled(key, key => this.collection.getKeyAfter(key));\n }\n\n getLastKey(): Key | null {\n let key = this.collection.getLastKey();\n return this.findNextNonDisabled(key, key => this.collection.getKeyBefore(key));\n }\n\n getKeyPageAbove(key: Key): Key | null {\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): Key | null {\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): Key | null {\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"}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import {DOMLayoutDelegate as $657e4dc4a6e88df0$export$8f5ed9ff9f511381} from "./DOMLayoutDelegate.mjs";
|
|
2
|
-
import {isScrollable as $eak97$isScrollable} from "@react-aria/utils";
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
-
* governing permissions and limitations under the License.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
17
|
-
isDisabled(item) {
|
|
18
|
-
var _item_props;
|
|
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
|
-
}
|
|
21
|
-
findNextNonDisabled(key, getNext) {
|
|
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);
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
getNextKey(key) {
|
|
31
|
-
let nextKey = key;
|
|
32
|
-
nextKey = this.collection.getKeyAfter(nextKey);
|
|
33
|
-
return this.findNextNonDisabled(nextKey, (key)=>this.collection.getKeyAfter(key));
|
|
34
|
-
}
|
|
35
|
-
getPreviousKey(key) {
|
|
36
|
-
let nextKey = key;
|
|
37
|
-
nextKey = this.collection.getKeyBefore(nextKey);
|
|
38
|
-
return this.findNextNonDisabled(nextKey, (key)=>this.collection.getKeyBefore(key));
|
|
39
|
-
}
|
|
40
|
-
findKey(key, nextKey, shouldSkip) {
|
|
41
|
-
let tempKey = key;
|
|
42
|
-
let itemRect = this.layoutDelegate.getItemRect(tempKey);
|
|
43
|
-
if (!itemRect || tempKey == null) return null;
|
|
44
|
-
// Find the item above or below in the same column.
|
|
45
|
-
let prevRect = itemRect;
|
|
46
|
-
do {
|
|
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;
|
|
52
|
-
}
|
|
53
|
-
isSameRow(prevRect, itemRect) {
|
|
54
|
-
return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;
|
|
55
|
-
}
|
|
56
|
-
isSameColumn(prevRect, itemRect) {
|
|
57
|
-
return prevRect.x === itemRect.x || prevRect.y !== itemRect.y;
|
|
58
|
-
}
|
|
59
|
-
getKeyBelow(key) {
|
|
60
|
-
if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getNextKey(key), this.isSameRow);
|
|
61
|
-
else return this.getNextKey(key);
|
|
62
|
-
}
|
|
63
|
-
getKeyAbove(key) {
|
|
64
|
-
if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getPreviousKey(key), this.isSameRow);
|
|
65
|
-
else return this.getPreviousKey(key);
|
|
66
|
-
}
|
|
67
|
-
getNextColumn(key, right) {
|
|
68
|
-
return right ? this.getPreviousKey(key) : this.getNextKey(key);
|
|
69
|
-
}
|
|
70
|
-
getKeyRightOf(key) {
|
|
71
|
-
// This is a temporary solution for CardView until we refactor useSelectableCollection.
|
|
72
|
-
// https://github.com/orgs/adobe/projects/19/views/32?pane=issue&itemId=77825042
|
|
73
|
-
let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyRightOf' : 'getKeyLeftOf';
|
|
74
|
-
if (this.layoutDelegate[layoutDelegateMethod]) {
|
|
75
|
-
key = this.layoutDelegate[layoutDelegateMethod](key);
|
|
76
|
-
return this.findNextNonDisabled(key, (key)=>this.layoutDelegate[layoutDelegateMethod](key));
|
|
77
|
-
}
|
|
78
|
-
if (this.layout === 'grid') {
|
|
79
|
-
if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'rtl');
|
|
80
|
-
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'rtl'), this.isSameColumn);
|
|
81
|
-
} else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'rtl');
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
getKeyLeftOf(key) {
|
|
85
|
-
let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyLeftOf' : 'getKeyRightOf';
|
|
86
|
-
if (this.layoutDelegate[layoutDelegateMethod]) {
|
|
87
|
-
key = this.layoutDelegate[layoutDelegateMethod](key);
|
|
88
|
-
return this.findNextNonDisabled(key, (key)=>this.layoutDelegate[layoutDelegateMethod](key));
|
|
89
|
-
}
|
|
90
|
-
if (this.layout === 'grid') {
|
|
91
|
-
if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'ltr');
|
|
92
|
-
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'ltr'), this.isSameColumn);
|
|
93
|
-
} else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'ltr');
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
getFirstKey() {
|
|
97
|
-
let key = this.collection.getFirstKey();
|
|
98
|
-
return this.findNextNonDisabled(key, (key)=>this.collection.getKeyAfter(key));
|
|
99
|
-
}
|
|
100
|
-
getLastKey() {
|
|
101
|
-
let key = this.collection.getLastKey();
|
|
102
|
-
return this.findNextNonDisabled(key, (key)=>this.collection.getKeyBefore(key));
|
|
103
|
-
}
|
|
104
|
-
getKeyPageAbove(key) {
|
|
105
|
-
let menu = this.ref.current;
|
|
106
|
-
let itemRect = this.layoutDelegate.getItemRect(key);
|
|
107
|
-
if (!itemRect) return null;
|
|
108
|
-
if (menu && !(0, $eak97$isScrollable)(menu)) return this.getFirstKey();
|
|
109
|
-
let nextKey = key;
|
|
110
|
-
if (this.orientation === 'horizontal') {
|
|
111
|
-
let pageX = Math.max(0, itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width);
|
|
112
|
-
while(itemRect && itemRect.x > pageX && nextKey != null){
|
|
113
|
-
nextKey = this.getKeyAbove(nextKey);
|
|
114
|
-
itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
|
|
115
|
-
}
|
|
116
|
-
} else {
|
|
117
|
-
let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);
|
|
118
|
-
while(itemRect && itemRect.y > pageY && nextKey != null){
|
|
119
|
-
nextKey = this.getKeyAbove(nextKey);
|
|
120
|
-
itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return nextKey !== null && nextKey !== void 0 ? nextKey : this.getFirstKey();
|
|
124
|
-
}
|
|
125
|
-
getKeyPageBelow(key) {
|
|
126
|
-
let menu = this.ref.current;
|
|
127
|
-
let itemRect = this.layoutDelegate.getItemRect(key);
|
|
128
|
-
if (!itemRect) return null;
|
|
129
|
-
if (menu && !(0, $eak97$isScrollable)(menu)) return this.getLastKey();
|
|
130
|
-
let nextKey = key;
|
|
131
|
-
if (this.orientation === 'horizontal') {
|
|
132
|
-
let pageX = Math.min(this.layoutDelegate.getContentSize().width, itemRect.y - itemRect.width + this.layoutDelegate.getVisibleRect().width);
|
|
133
|
-
while(itemRect && itemRect.x < pageX && nextKey != null){
|
|
134
|
-
nextKey = this.getKeyBelow(nextKey);
|
|
135
|
-
itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height);
|
|
139
|
-
while(itemRect && itemRect.y < pageY && nextKey != null){
|
|
140
|
-
nextKey = this.getKeyBelow(nextKey);
|
|
141
|
-
itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return nextKey !== null && nextKey !== void 0 ? nextKey : this.getLastKey();
|
|
145
|
-
}
|
|
146
|
-
getKeyForSearch(search, fromKey) {
|
|
147
|
-
if (!this.collator) return null;
|
|
148
|
-
let collection = this.collection;
|
|
149
|
-
let key = fromKey || this.getFirstKey();
|
|
150
|
-
while(key != null){
|
|
151
|
-
let item = collection.getItem(key);
|
|
152
|
-
if (!item) return null;
|
|
153
|
-
let substring = item.textValue.slice(0, search.length);
|
|
154
|
-
if (item.textValue && this.collator.compare(substring, search) === 0) return key;
|
|
155
|
-
key = this.getNextKey(key);
|
|
156
|
-
}
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
constructor(...args){
|
|
160
|
-
if (args.length === 1) {
|
|
161
|
-
let opts = args[0];
|
|
162
|
-
this.collection = opts.collection;
|
|
163
|
-
this.ref = opts.ref;
|
|
164
|
-
this.collator = opts.collator;
|
|
165
|
-
this.disabledKeys = opts.disabledKeys || new Set();
|
|
166
|
-
this.disabledBehavior = opts.disabledBehavior || 'all';
|
|
167
|
-
this.orientation = opts.orientation || 'vertical';
|
|
168
|
-
this.direction = opts.direction;
|
|
169
|
-
this.layout = opts.layout || 'stack';
|
|
170
|
-
this.layoutDelegate = opts.layoutDelegate || new (0, $657e4dc4a6e88df0$export$8f5ed9ff9f511381)(opts.ref);
|
|
171
|
-
} else {
|
|
172
|
-
this.collection = args[0];
|
|
173
|
-
this.disabledKeys = args[1];
|
|
174
|
-
this.ref = args[2];
|
|
175
|
-
this.collator = args[3];
|
|
176
|
-
this.layout = 'stack';
|
|
177
|
-
this.orientation = 'vertical';
|
|
178
|
-
this.disabledBehavior = 'all';
|
|
179
|
-
this.layoutDelegate = new (0, $657e4dc4a6e88df0$export$8f5ed9ff9f511381)(this.ref);
|
|
180
|
-
}
|
|
181
|
-
// If this is a vertical stack, remove the left/right methods completely
|
|
182
|
-
// so they aren't called by useDroppableCollection.
|
|
183
|
-
if (this.layout === 'stack' && this.orientation === 'vertical') {
|
|
184
|
-
this.getKeyLeftOf = undefined;
|
|
185
|
-
this.getKeyRightOf = undefined;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
export {$2a25aae57d74318e$export$a05409b8bb224a5a as ListKeyboardDelegate};
|
|
192
|
-
//# sourceMappingURL=ListKeyboardDelegate.module.js.map
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import {DOMLayoutDelegate as $657e4dc4a6e88df0$export$8f5ed9ff9f511381} from "./DOMLayoutDelegate.module.js";
|
|
2
|
-
import {isScrollable as $eak97$isScrollable} from "@react-aria/utils";
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
-
* governing permissions and limitations under the License.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
17
|
-
isDisabled(item) {
|
|
18
|
-
var _item_props;
|
|
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
|
-
}
|
|
21
|
-
findNextNonDisabled(key, getNext) {
|
|
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);
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
getNextKey(key) {
|
|
31
|
-
let nextKey = key;
|
|
32
|
-
nextKey = this.collection.getKeyAfter(nextKey);
|
|
33
|
-
return this.findNextNonDisabled(nextKey, (key)=>this.collection.getKeyAfter(key));
|
|
34
|
-
}
|
|
35
|
-
getPreviousKey(key) {
|
|
36
|
-
let nextKey = key;
|
|
37
|
-
nextKey = this.collection.getKeyBefore(nextKey);
|
|
38
|
-
return this.findNextNonDisabled(nextKey, (key)=>this.collection.getKeyBefore(key));
|
|
39
|
-
}
|
|
40
|
-
findKey(key, nextKey, shouldSkip) {
|
|
41
|
-
let tempKey = key;
|
|
42
|
-
let itemRect = this.layoutDelegate.getItemRect(tempKey);
|
|
43
|
-
if (!itemRect || tempKey == null) return null;
|
|
44
|
-
// Find the item above or below in the same column.
|
|
45
|
-
let prevRect = itemRect;
|
|
46
|
-
do {
|
|
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;
|
|
52
|
-
}
|
|
53
|
-
isSameRow(prevRect, itemRect) {
|
|
54
|
-
return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;
|
|
55
|
-
}
|
|
56
|
-
isSameColumn(prevRect, itemRect) {
|
|
57
|
-
return prevRect.x === itemRect.x || prevRect.y !== itemRect.y;
|
|
58
|
-
}
|
|
59
|
-
getKeyBelow(key) {
|
|
60
|
-
if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getNextKey(key), this.isSameRow);
|
|
61
|
-
else return this.getNextKey(key);
|
|
62
|
-
}
|
|
63
|
-
getKeyAbove(key) {
|
|
64
|
-
if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getPreviousKey(key), this.isSameRow);
|
|
65
|
-
else return this.getPreviousKey(key);
|
|
66
|
-
}
|
|
67
|
-
getNextColumn(key, right) {
|
|
68
|
-
return right ? this.getPreviousKey(key) : this.getNextKey(key);
|
|
69
|
-
}
|
|
70
|
-
getKeyRightOf(key) {
|
|
71
|
-
// This is a temporary solution for CardView until we refactor useSelectableCollection.
|
|
72
|
-
// https://github.com/orgs/adobe/projects/19/views/32?pane=issue&itemId=77825042
|
|
73
|
-
let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyRightOf' : 'getKeyLeftOf';
|
|
74
|
-
if (this.layoutDelegate[layoutDelegateMethod]) {
|
|
75
|
-
key = this.layoutDelegate[layoutDelegateMethod](key);
|
|
76
|
-
return this.findNextNonDisabled(key, (key)=>this.layoutDelegate[layoutDelegateMethod](key));
|
|
77
|
-
}
|
|
78
|
-
if (this.layout === 'grid') {
|
|
79
|
-
if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'rtl');
|
|
80
|
-
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'rtl'), this.isSameColumn);
|
|
81
|
-
} else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'rtl');
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
getKeyLeftOf(key) {
|
|
85
|
-
let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyLeftOf' : 'getKeyRightOf';
|
|
86
|
-
if (this.layoutDelegate[layoutDelegateMethod]) {
|
|
87
|
-
key = this.layoutDelegate[layoutDelegateMethod](key);
|
|
88
|
-
return this.findNextNonDisabled(key, (key)=>this.layoutDelegate[layoutDelegateMethod](key));
|
|
89
|
-
}
|
|
90
|
-
if (this.layout === 'grid') {
|
|
91
|
-
if (this.orientation === 'vertical') return this.getNextColumn(key, this.direction === 'ltr');
|
|
92
|
-
else return this.findKey(key, (key)=>this.getNextColumn(key, this.direction === 'ltr'), this.isSameColumn);
|
|
93
|
-
} else if (this.orientation === 'horizontal') return this.getNextColumn(key, this.direction === 'ltr');
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
getFirstKey() {
|
|
97
|
-
let key = this.collection.getFirstKey();
|
|
98
|
-
return this.findNextNonDisabled(key, (key)=>this.collection.getKeyAfter(key));
|
|
99
|
-
}
|
|
100
|
-
getLastKey() {
|
|
101
|
-
let key = this.collection.getLastKey();
|
|
102
|
-
return this.findNextNonDisabled(key, (key)=>this.collection.getKeyBefore(key));
|
|
103
|
-
}
|
|
104
|
-
getKeyPageAbove(key) {
|
|
105
|
-
let menu = this.ref.current;
|
|
106
|
-
let itemRect = this.layoutDelegate.getItemRect(key);
|
|
107
|
-
if (!itemRect) return null;
|
|
108
|
-
if (menu && !(0, $eak97$isScrollable)(menu)) return this.getFirstKey();
|
|
109
|
-
let nextKey = key;
|
|
110
|
-
if (this.orientation === 'horizontal') {
|
|
111
|
-
let pageX = Math.max(0, itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width);
|
|
112
|
-
while(itemRect && itemRect.x > pageX && nextKey != null){
|
|
113
|
-
nextKey = this.getKeyAbove(nextKey);
|
|
114
|
-
itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
|
|
115
|
-
}
|
|
116
|
-
} else {
|
|
117
|
-
let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);
|
|
118
|
-
while(itemRect && itemRect.y > pageY && nextKey != null){
|
|
119
|
-
nextKey = this.getKeyAbove(nextKey);
|
|
120
|
-
itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return nextKey !== null && nextKey !== void 0 ? nextKey : this.getFirstKey();
|
|
124
|
-
}
|
|
125
|
-
getKeyPageBelow(key) {
|
|
126
|
-
let menu = this.ref.current;
|
|
127
|
-
let itemRect = this.layoutDelegate.getItemRect(key);
|
|
128
|
-
if (!itemRect) return null;
|
|
129
|
-
if (menu && !(0, $eak97$isScrollable)(menu)) return this.getLastKey();
|
|
130
|
-
let nextKey = key;
|
|
131
|
-
if (this.orientation === 'horizontal') {
|
|
132
|
-
let pageX = Math.min(this.layoutDelegate.getContentSize().width, itemRect.y - itemRect.width + this.layoutDelegate.getVisibleRect().width);
|
|
133
|
-
while(itemRect && itemRect.x < pageX && nextKey != null){
|
|
134
|
-
nextKey = this.getKeyBelow(nextKey);
|
|
135
|
-
itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height);
|
|
139
|
-
while(itemRect && itemRect.y < pageY && nextKey != null){
|
|
140
|
-
nextKey = this.getKeyBelow(nextKey);
|
|
141
|
-
itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return nextKey !== null && nextKey !== void 0 ? nextKey : this.getLastKey();
|
|
145
|
-
}
|
|
146
|
-
getKeyForSearch(search, fromKey) {
|
|
147
|
-
if (!this.collator) return null;
|
|
148
|
-
let collection = this.collection;
|
|
149
|
-
let key = fromKey || this.getFirstKey();
|
|
150
|
-
while(key != null){
|
|
151
|
-
let item = collection.getItem(key);
|
|
152
|
-
if (!item) return null;
|
|
153
|
-
let substring = item.textValue.slice(0, search.length);
|
|
154
|
-
if (item.textValue && this.collator.compare(substring, search) === 0) return key;
|
|
155
|
-
key = this.getNextKey(key);
|
|
156
|
-
}
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
constructor(...args){
|
|
160
|
-
if (args.length === 1) {
|
|
161
|
-
let opts = args[0];
|
|
162
|
-
this.collection = opts.collection;
|
|
163
|
-
this.ref = opts.ref;
|
|
164
|
-
this.collator = opts.collator;
|
|
165
|
-
this.disabledKeys = opts.disabledKeys || new Set();
|
|
166
|
-
this.disabledBehavior = opts.disabledBehavior || 'all';
|
|
167
|
-
this.orientation = opts.orientation || 'vertical';
|
|
168
|
-
this.direction = opts.direction;
|
|
169
|
-
this.layout = opts.layout || 'stack';
|
|
170
|
-
this.layoutDelegate = opts.layoutDelegate || new (0, $657e4dc4a6e88df0$export$8f5ed9ff9f511381)(opts.ref);
|
|
171
|
-
} else {
|
|
172
|
-
this.collection = args[0];
|
|
173
|
-
this.disabledKeys = args[1];
|
|
174
|
-
this.ref = args[2];
|
|
175
|
-
this.collator = args[3];
|
|
176
|
-
this.layout = 'stack';
|
|
177
|
-
this.orientation = 'vertical';
|
|
178
|
-
this.disabledBehavior = 'all';
|
|
179
|
-
this.layoutDelegate = new (0, $657e4dc4a6e88df0$export$8f5ed9ff9f511381)(this.ref);
|
|
180
|
-
}
|
|
181
|
-
// If this is a vertical stack, remove the left/right methods completely
|
|
182
|
-
// so they aren't called by useDroppableCollection.
|
|
183
|
-
if (this.layout === 'stack' && this.orientation === 'vertical') {
|
|
184
|
-
this.getKeyLeftOf = undefined;
|
|
185
|
-
this.getKeyRightOf = undefined;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
export {$2a25aae57d74318e$export$a05409b8bb224a5a as ListKeyboardDelegate};
|
|
192
|
-
//# sourceMappingURL=ListKeyboardDelegate.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,GA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O,IAAI,CAAC,EAAE;YAClB,IAAI,CAAC,UAAU,GAAG,KAAK,UAAU;YACjC,IAAI,CAAC,GAAG,GAAG,KAAK,GAAG;YACnB,IAAI,CAAC,QAAQ,GAAG,KAAK,QAAQ;YAC7B,IAAI,CAAC,YAAY,GAAG,KAAK,YAAY,IAAI,IAAI;YAC7C,IAAI,CAAC,gBAAgB,GAAG,KAAK,gBAAgB,IAAI;YACjD,IAAI,CAAC,WAAW,GAAG,KAAK,WAAW,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, expandedKeys?: Set<Key>);\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): Key | null {\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): Key | null {\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): Key | null {\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): Key | null {\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): Key | null {\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): Key | null {\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(): Key | null {\n let key = this.collection.getFirstKey();\n return this.findNextNonDisabled(key, key => this.collection.getKeyAfter(key));\n }\n\n getLastKey(): Key | null {\n let key = this.collection.getLastKey();\n return this.findNextNonDisabled(key, key => this.collection.getKeyBefore(key));\n }\n\n getKeyPageAbove(key: Key): Key | null {\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): Key | null {\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): Key | null {\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"}
|