@react-aria/grid 3.10.5 → 3.11.1
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/GridKeyboardDelegate.main.js +104 -43
- package/dist/GridKeyboardDelegate.main.js.map +1 -1
- package/dist/GridKeyboardDelegate.mjs +104 -43
- package/dist/GridKeyboardDelegate.module.js +104 -43
- package/dist/GridKeyboardDelegate.module.js.map +1 -1
- package/dist/ar-AE.main.js.map +1 -1
- package/dist/ar-AE.module.js.map +1 -1
- package/dist/bg-BG.main.js.map +1 -1
- package/dist/bg-BG.module.js.map +1 -1
- package/dist/cs-CZ.main.js.map +1 -1
- package/dist/cs-CZ.module.js.map +1 -1
- package/dist/da-DK.main.js.map +1 -1
- package/dist/da-DK.module.js.map +1 -1
- package/dist/de-DE.main.js.map +1 -1
- package/dist/de-DE.module.js.map +1 -1
- package/dist/el-GR.main.js.map +1 -1
- package/dist/el-GR.module.js.map +1 -1
- package/dist/en-US.main.js.map +1 -1
- package/dist/en-US.module.js.map +1 -1
- package/dist/es-ES.main.js.map +1 -1
- package/dist/es-ES.module.js.map +1 -1
- package/dist/et-EE.main.js.map +1 -1
- package/dist/et-EE.module.js.map +1 -1
- package/dist/fi-FI.main.js.map +1 -1
- package/dist/fi-FI.module.js.map +1 -1
- package/dist/fr-FR.main.js.map +1 -1
- package/dist/fr-FR.module.js.map +1 -1
- package/dist/he-IL.main.js.map +1 -1
- package/dist/he-IL.module.js.map +1 -1
- package/dist/hr-HR.main.js.map +1 -1
- package/dist/hr-HR.module.js.map +1 -1
- package/dist/hu-HU.main.js.map +1 -1
- package/dist/hu-HU.module.js.map +1 -1
- package/dist/it-IT.main.js.map +1 -1
- package/dist/it-IT.module.js.map +1 -1
- package/dist/ja-JP.main.js.map +1 -1
- package/dist/ja-JP.module.js.map +1 -1
- package/dist/ko-KR.main.js.map +1 -1
- package/dist/ko-KR.module.js.map +1 -1
- package/dist/lt-LT.main.js.map +1 -1
- package/dist/lt-LT.module.js.map +1 -1
- package/dist/lv-LV.main.js.map +1 -1
- package/dist/lv-LV.module.js.map +1 -1
- package/dist/nb-NO.main.js.map +1 -1
- package/dist/nb-NO.module.js.map +1 -1
- package/dist/nl-NL.main.js.map +1 -1
- package/dist/nl-NL.module.js.map +1 -1
- package/dist/pl-PL.main.js.map +1 -1
- package/dist/pl-PL.module.js.map +1 -1
- package/dist/pt-BR.main.js.map +1 -1
- package/dist/pt-BR.module.js.map +1 -1
- package/dist/pt-PT.main.js.map +1 -1
- package/dist/pt-PT.module.js.map +1 -1
- package/dist/ro-RO.main.js.map +1 -1
- package/dist/ro-RO.module.js.map +1 -1
- package/dist/ru-RU.main.js.map +1 -1
- package/dist/ru-RU.module.js.map +1 -1
- package/dist/sk-SK.main.js.map +1 -1
- package/dist/sk-SK.module.js.map +1 -1
- package/dist/sl-SI.main.js.map +1 -1
- package/dist/sl-SI.module.js.map +1 -1
- package/dist/sr-SP.main.js.map +1 -1
- package/dist/sr-SP.module.js.map +1 -1
- package/dist/sv-SE.main.js.map +1 -1
- package/dist/sv-SE.module.js.map +1 -1
- package/dist/tr-TR.main.js.map +1 -1
- package/dist/tr-TR.module.js.map +1 -1
- package/dist/types.d.ts +12 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.main.js.map +1 -1
- package/dist/uk-UA.module.js.map +1 -1
- package/dist/useGrid.main.js +1 -1
- package/dist/useGrid.main.js.map +1 -1
- package/dist/useGrid.mjs +1 -1
- package/dist/useGrid.module.js +1 -1
- package/dist/useGrid.module.js.map +1 -1
- package/dist/useGridCell.main.js +27 -20
- package/dist/useGridCell.main.js.map +1 -1
- package/dist/useGridCell.mjs +27 -20
- package/dist/useGridCell.module.js +27 -20
- package/dist/useGridCell.module.js.map +1 -1
- package/dist/useGridRow.main.js +4 -1
- package/dist/useGridRow.main.js.map +1 -1
- package/dist/useGridRow.mjs +4 -1
- package/dist/useGridRow.module.js +4 -1
- package/dist/useGridRow.module.js.map +1 -1
- package/dist/useGridSelectionAnnouncement.main.js.map +1 -1
- package/dist/useGridSelectionAnnouncement.module.js.map +1 -1
- package/dist/useHighlightSelectionDescription.main.js +1 -1
- package/dist/useHighlightSelectionDescription.main.js.map +1 -1
- package/dist/useHighlightSelectionDescription.mjs +1 -1
- package/dist/useHighlightSelectionDescription.module.js +1 -1
- package/dist/useHighlightSelectionDescription.module.js.map +1 -1
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.module.js.map +1 -1
- package/dist/zh-CN.main.js.map +1 -1
- package/dist/zh-CN.module.js.map +1 -1
- package/dist/zh-TW.main.js.map +1 -1
- package/dist/zh-TW.module.js.map +1 -1
- package/package.json +16 -16
- package/src/GridKeyboardDelegate.ts +120 -53
- package/src/useGrid.ts +1 -1
- package/src/useGridCell.ts +37 -33
- package/src/useGridRow.ts +2 -2
- package/src/useGridSelectionAnnouncement.ts +1 -1
- package/src/useHighlightSelectionDescription.ts +1 -1
- package/src/utils.ts +2 -2
|
@@ -34,149 +34,202 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
|
|
|
34
34
|
let key = fromKey != null ? this.collection.getKeyBefore(fromKey) : this.collection.getLastKey();
|
|
35
35
|
while(key != null){
|
|
36
36
|
let item = this.collection.getItem(key);
|
|
37
|
+
if (!item) return null;
|
|
37
38
|
if (!this.isDisabled(item) && (!pred || pred(item))) return key;
|
|
38
39
|
key = this.collection.getKeyBefore(key);
|
|
39
40
|
}
|
|
41
|
+
return null;
|
|
40
42
|
}
|
|
41
43
|
findNextKey(fromKey, pred) {
|
|
42
44
|
let key = fromKey != null ? this.collection.getKeyAfter(fromKey) : this.collection.getFirstKey();
|
|
43
45
|
while(key != null){
|
|
44
46
|
let item = this.collection.getItem(key);
|
|
47
|
+
if (!item) return null;
|
|
45
48
|
if (!this.isDisabled(item) && (!pred || pred(item))) return key;
|
|
46
49
|
key = this.collection.getKeyAfter(key);
|
|
50
|
+
if (key == null) return null;
|
|
47
51
|
}
|
|
52
|
+
return null;
|
|
48
53
|
}
|
|
49
|
-
getKeyBelow(
|
|
54
|
+
getKeyBelow(fromKey) {
|
|
55
|
+
let key = fromKey;
|
|
50
56
|
let startItem = this.collection.getItem(key);
|
|
51
|
-
if (!startItem) return;
|
|
57
|
+
if (!startItem) return null;
|
|
58
|
+
var _startItem_parentKey;
|
|
52
59
|
// If focus was on a cell, start searching from the parent row
|
|
53
|
-
if (this.isCell(startItem)) key = startItem.parentKey;
|
|
60
|
+
if (this.isCell(startItem)) key = (_startItem_parentKey = startItem.parentKey) !== null && _startItem_parentKey !== void 0 ? _startItem_parentKey : null;
|
|
61
|
+
if (key == null) return null;
|
|
54
62
|
// Find the next item
|
|
55
63
|
key = this.findNextKey(key, (item)=>item.type === 'item');
|
|
56
64
|
if (key != null) {
|
|
57
65
|
// If focus was on a cell, focus the cell with the same index in the next row.
|
|
58
66
|
if (this.isCell(startItem)) {
|
|
67
|
+
var _getNthItem;
|
|
59
68
|
let item = this.collection.getItem(key);
|
|
60
|
-
|
|
69
|
+
if (!item) return null;
|
|
70
|
+
var _startItem_index, _getNthItem_key;
|
|
71
|
+
return (_getNthItem_key = (_getNthItem = (0, $iKGCm$reactstatelycollections.getNthItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) !== null && _getNthItem_key !== void 0 ? _getNthItem_key : null;
|
|
61
72
|
}
|
|
62
73
|
// Otherwise, focus the next row
|
|
63
74
|
if (this.focusMode === 'row') return key;
|
|
64
75
|
}
|
|
76
|
+
return null;
|
|
65
77
|
}
|
|
66
|
-
getKeyAbove(
|
|
78
|
+
getKeyAbove(fromKey) {
|
|
79
|
+
let key = fromKey;
|
|
67
80
|
let startItem = this.collection.getItem(key);
|
|
68
|
-
if (!startItem) return;
|
|
81
|
+
if (!startItem) return null;
|
|
82
|
+
var _startItem_parentKey;
|
|
69
83
|
// If focus is on a cell, start searching from the parent row
|
|
70
|
-
if (this.isCell(startItem)) key = startItem.parentKey;
|
|
84
|
+
if (this.isCell(startItem)) key = (_startItem_parentKey = startItem.parentKey) !== null && _startItem_parentKey !== void 0 ? _startItem_parentKey : null;
|
|
85
|
+
if (key == null) return null;
|
|
71
86
|
// Find the previous item
|
|
72
87
|
key = this.findPreviousKey(key, (item)=>item.type === 'item');
|
|
73
88
|
if (key != null) {
|
|
74
89
|
// If focus was on a cell, focus the cell with the same index in the previous row.
|
|
75
90
|
if (this.isCell(startItem)) {
|
|
91
|
+
var _getNthItem;
|
|
76
92
|
let item = this.collection.getItem(key);
|
|
77
|
-
|
|
93
|
+
if (!item) return null;
|
|
94
|
+
var _startItem_index;
|
|
95
|
+
return ((_getNthItem = (0, $iKGCm$reactstatelycollections.getNthItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) || null;
|
|
78
96
|
}
|
|
79
97
|
// Otherwise, focus the previous row
|
|
80
98
|
if (this.focusMode === 'row') return key;
|
|
81
99
|
}
|
|
100
|
+
return null;
|
|
82
101
|
}
|
|
83
102
|
getKeyRightOf(key) {
|
|
84
103
|
let item = this.collection.getItem(key);
|
|
85
|
-
if (!item) return;
|
|
104
|
+
if (!item) return null;
|
|
86
105
|
// If focus is on a row, focus the first child cell.
|
|
87
106
|
if (this.isRow(item)) {
|
|
107
|
+
var _getLastItem, _getFirstItem;
|
|
88
108
|
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection);
|
|
89
|
-
|
|
109
|
+
var _ref;
|
|
110
|
+
return (_ref = this.direction === 'rtl' ? (_getLastItem = (0, $iKGCm$reactstatelycollections.getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key : (_getFirstItem = (0, $iKGCm$reactstatelycollections.getFirstItem)(children)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _ref !== void 0 ? _ref : null;
|
|
90
111
|
}
|
|
91
112
|
// If focus is on a cell, focus the next cell if any,
|
|
92
113
|
// otherwise focus the parent row.
|
|
93
|
-
if (this.isCell(item)) {
|
|
114
|
+
if (this.isCell(item) && item.parentKey != null) {
|
|
94
115
|
let parent = this.collection.getItem(item.parentKey);
|
|
116
|
+
if (!parent) return null;
|
|
95
117
|
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(parent, this.collection);
|
|
96
|
-
|
|
97
|
-
|
|
118
|
+
var _ref1;
|
|
119
|
+
let next = (_ref1 = this.direction === 'rtl' ? (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index - 1) : (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index + 1)) !== null && _ref1 !== void 0 ? _ref1 : null;
|
|
120
|
+
var _next_key;
|
|
121
|
+
if (next) return (_next_key = next.key) !== null && _next_key !== void 0 ? _next_key : null;
|
|
122
|
+
var _item_parentKey;
|
|
98
123
|
// focus row only if focusMode is set to row
|
|
99
|
-
if (this.focusMode === 'row') return item.parentKey;
|
|
100
|
-
|
|
124
|
+
if (this.focusMode === 'row') return (_item_parentKey = item.parentKey) !== null && _item_parentKey !== void 0 ? _item_parentKey : null;
|
|
125
|
+
var _ref2;
|
|
126
|
+
return (_ref2 = this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key)) !== null && _ref2 !== void 0 ? _ref2 : null;
|
|
101
127
|
}
|
|
128
|
+
return null;
|
|
102
129
|
}
|
|
103
130
|
getKeyLeftOf(key) {
|
|
104
131
|
let item = this.collection.getItem(key);
|
|
105
|
-
if (!item) return;
|
|
132
|
+
if (!item) return null;
|
|
106
133
|
// If focus is on a row, focus the last child cell.
|
|
107
134
|
if (this.isRow(item)) {
|
|
135
|
+
var _getFirstItem, _getLastItem;
|
|
108
136
|
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection);
|
|
109
|
-
|
|
137
|
+
var _ref;
|
|
138
|
+
return (_ref = this.direction === 'rtl' ? (_getFirstItem = (0, $iKGCm$reactstatelycollections.getFirstItem)(children)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key : (_getLastItem = (0, $iKGCm$reactstatelycollections.getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _ref !== void 0 ? _ref : null;
|
|
110
139
|
}
|
|
111
140
|
// If focus is on a cell, focus the previous cell if any,
|
|
112
141
|
// otherwise focus the parent row.
|
|
113
|
-
if (this.isCell(item)) {
|
|
142
|
+
if (this.isCell(item) && item.parentKey != null) {
|
|
114
143
|
let parent = this.collection.getItem(item.parentKey);
|
|
144
|
+
if (!parent) return null;
|
|
115
145
|
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(parent, this.collection);
|
|
116
|
-
|
|
117
|
-
|
|
146
|
+
var _ref1;
|
|
147
|
+
let prev = (_ref1 = this.direction === 'rtl' ? (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index + 1) : (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index - 1)) !== null && _ref1 !== void 0 ? _ref1 : null;
|
|
148
|
+
var _prev_key;
|
|
149
|
+
if (prev) return (_prev_key = prev.key) !== null && _prev_key !== void 0 ? _prev_key : null;
|
|
150
|
+
var _item_parentKey;
|
|
118
151
|
// focus row only if focusMode is set to row
|
|
119
|
-
if (this.focusMode === 'row') return item.parentKey;
|
|
120
|
-
|
|
152
|
+
if (this.focusMode === 'row') return (_item_parentKey = item.parentKey) !== null && _item_parentKey !== void 0 ? _item_parentKey : null;
|
|
153
|
+
var _ref2;
|
|
154
|
+
return (_ref2 = this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key)) !== null && _ref2 !== void 0 ? _ref2 : null;
|
|
121
155
|
}
|
|
156
|
+
return null;
|
|
122
157
|
}
|
|
123
|
-
getFirstKey(
|
|
158
|
+
getFirstKey(fromKey, global) {
|
|
159
|
+
let key = fromKey !== null && fromKey !== void 0 ? fromKey : null;
|
|
124
160
|
let item;
|
|
125
161
|
if (key != null) {
|
|
126
162
|
item = this.collection.getItem(key);
|
|
127
|
-
if (!item) return;
|
|
163
|
+
if (!item) return null;
|
|
128
164
|
// If global flag is not set, and a cell is currently focused,
|
|
129
165
|
// move focus to the first cell in the parent row.
|
|
130
|
-
if (this.isCell(item) && !global) {
|
|
166
|
+
if (this.isCell(item) && !global && item.parentKey != null) {
|
|
167
|
+
var _getFirstItem;
|
|
131
168
|
let parent = this.collection.getItem(item.parentKey);
|
|
132
|
-
|
|
169
|
+
if (!parent) return null;
|
|
170
|
+
var _getFirstItem_key;
|
|
171
|
+
return (_getFirstItem_key = (_getFirstItem = (0, $iKGCm$reactstatelycollections.getFirstItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(parent, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null;
|
|
133
172
|
}
|
|
134
173
|
}
|
|
135
174
|
// Find the first row
|
|
136
|
-
key = this.findNextKey(
|
|
175
|
+
key = this.findNextKey(undefined, (item)=>item.type === 'item');
|
|
137
176
|
// If global flag is set (or if focus mode is cell), focus the first cell in the first row.
|
|
138
|
-
if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') {
|
|
177
|
+
if (key != null && (item && this.isCell(item) && global || this.focusMode === 'cell')) {
|
|
178
|
+
var _getFirstItem1;
|
|
139
179
|
let item = this.collection.getItem(key);
|
|
140
|
-
|
|
180
|
+
if (!item) return null;
|
|
181
|
+
var _getFirstItem_key1;
|
|
182
|
+
key = (_getFirstItem_key1 = (_getFirstItem1 = (0, $iKGCm$reactstatelycollections.getFirstItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection))) === null || _getFirstItem1 === void 0 ? void 0 : _getFirstItem1.key) !== null && _getFirstItem_key1 !== void 0 ? _getFirstItem_key1 : null;
|
|
141
183
|
}
|
|
142
184
|
// Otherwise, focus the row itself.
|
|
143
185
|
return key;
|
|
144
186
|
}
|
|
145
|
-
getLastKey(
|
|
187
|
+
getLastKey(fromKey, global) {
|
|
188
|
+
let key = fromKey !== null && fromKey !== void 0 ? fromKey : null;
|
|
146
189
|
let item;
|
|
147
190
|
if (key != null) {
|
|
148
191
|
item = this.collection.getItem(key);
|
|
149
|
-
if (!item) return;
|
|
192
|
+
if (!item) return null;
|
|
150
193
|
// If global flag is not set, and a cell is currently focused,
|
|
151
194
|
// move focus to the last cell in the parent row.
|
|
152
|
-
if (this.isCell(item) && !global) {
|
|
195
|
+
if (this.isCell(item) && !global && item.parentKey != null) {
|
|
196
|
+
var _getLastItem;
|
|
153
197
|
let parent = this.collection.getItem(item.parentKey);
|
|
198
|
+
if (!parent) return null;
|
|
154
199
|
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(parent, this.collection);
|
|
155
|
-
|
|
200
|
+
var _getLastItem_key;
|
|
201
|
+
return (_getLastItem_key = (_getLastItem = (0, $iKGCm$reactstatelycollections.getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _getLastItem_key !== void 0 ? _getLastItem_key : null;
|
|
156
202
|
}
|
|
157
203
|
}
|
|
158
204
|
// Find the last row
|
|
159
|
-
key = this.findPreviousKey(
|
|
205
|
+
key = this.findPreviousKey(undefined, (item)=>item.type === 'item');
|
|
160
206
|
// If global flag is set (or if focus mode is cell), focus the last cell in the last row.
|
|
161
|
-
if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') {
|
|
207
|
+
if (key != null && (item && this.isCell(item) && global || this.focusMode === 'cell')) {
|
|
208
|
+
var _getLastItem1;
|
|
162
209
|
let item = this.collection.getItem(key);
|
|
210
|
+
if (!item) return null;
|
|
163
211
|
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection);
|
|
164
|
-
|
|
212
|
+
var _getLastItem_key1;
|
|
213
|
+
key = (_getLastItem_key1 = (_getLastItem1 = (0, $iKGCm$reactstatelycollections.getLastItem)(children)) === null || _getLastItem1 === void 0 ? void 0 : _getLastItem1.key) !== null && _getLastItem_key1 !== void 0 ? _getLastItem_key1 : null;
|
|
165
214
|
}
|
|
166
215
|
// Otherwise, focus the row itself.
|
|
167
216
|
return key;
|
|
168
217
|
}
|
|
169
|
-
getKeyPageAbove(
|
|
218
|
+
getKeyPageAbove(fromKey) {
|
|
219
|
+
let key = fromKey;
|
|
170
220
|
let itemRect = this.layoutDelegate.getItemRect(key);
|
|
171
221
|
if (!itemRect) return null;
|
|
172
222
|
let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);
|
|
173
|
-
while(itemRect && itemRect.y > pageY){
|
|
174
|
-
|
|
223
|
+
while(itemRect && itemRect.y > pageY && key != null){
|
|
224
|
+
var _this_getKeyAbove;
|
|
225
|
+
key = (_this_getKeyAbove = this.getKeyAbove(key)) !== null && _this_getKeyAbove !== void 0 ? _this_getKeyAbove : null;
|
|
226
|
+
if (key == null) break;
|
|
175
227
|
itemRect = this.layoutDelegate.getItemRect(key);
|
|
176
228
|
}
|
|
177
229
|
return key;
|
|
178
230
|
}
|
|
179
|
-
getKeyPageBelow(
|
|
231
|
+
getKeyPageBelow(fromKey) {
|
|
232
|
+
let key = fromKey;
|
|
180
233
|
let itemRect = this.layoutDelegate.getItemRect(key);
|
|
181
234
|
if (!itemRect) return null;
|
|
182
235
|
let pageHeight = this.layoutDelegate.getVisibleRect().height;
|
|
@@ -191,20 +244,27 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
|
|
|
191
244
|
return key;
|
|
192
245
|
}
|
|
193
246
|
getKeyForSearch(search, fromKey) {
|
|
247
|
+
let key = fromKey !== null && fromKey !== void 0 ? fromKey : null;
|
|
194
248
|
if (!this.collator) return null;
|
|
195
249
|
let collection = this.collection;
|
|
196
|
-
|
|
250
|
+
key = fromKey !== null && fromKey !== void 0 ? fromKey : this.getFirstKey();
|
|
251
|
+
if (key == null) return null;
|
|
197
252
|
// If the starting key is a cell, search from its parent row.
|
|
198
253
|
let startItem = collection.getItem(key);
|
|
199
|
-
if (startItem
|
|
254
|
+
if (!startItem) return null;
|
|
255
|
+
var _startItem_parentKey;
|
|
256
|
+
if (startItem.type === 'cell') key = (_startItem_parentKey = startItem.parentKey) !== null && _startItem_parentKey !== void 0 ? _startItem_parentKey : null;
|
|
200
257
|
let hasWrapped = false;
|
|
201
258
|
while(key != null){
|
|
202
259
|
let item = collection.getItem(key);
|
|
260
|
+
if (!item) return null;
|
|
203
261
|
// check row text value for match
|
|
204
262
|
if (item.textValue) {
|
|
205
263
|
let substring = item.textValue.slice(0, search.length);
|
|
206
264
|
if (this.collator.compare(substring, search) === 0) {
|
|
207
|
-
|
|
265
|
+
var _getFirstItem;
|
|
266
|
+
var _getFirstItem_key;
|
|
267
|
+
if (this.isRow(item) && this.focusMode === 'cell') return (_getFirstItem_key = (_getFirstItem = (0, $iKGCm$reactstatelycollections.getFirstItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null;
|
|
208
268
|
return item.key;
|
|
209
269
|
}
|
|
210
270
|
}
|
|
@@ -223,6 +283,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
|
|
|
223
283
|
this.disabledBehavior = options.disabledBehavior || 'all';
|
|
224
284
|
this.direction = options.direction;
|
|
225
285
|
this.collator = options.collator;
|
|
286
|
+
if (!options.layout && !options.ref) throw new Error('Either a layout or a ref must be specified.');
|
|
226
287
|
this.layoutDelegate = options.layoutDelegate || (options.layout ? new $3187c0e19200cb16$var$DeprecatedLayoutDelegate(options.layout) : new (0, $iKGCm$reactariaselection.DOMLayoutDelegate)(options.ref));
|
|
227
288
|
this.focusMode = options.focusMode || 'row';
|
|
228
289
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAoBM,MAAM;IAmBD,OAAO,IAAa,EAAE;QAC9B,OAAO,KAAK,IAA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oBAG/D,OAAO,KAAK,GAAG;gBACjB;YACF;YAEA,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAA,OAAQ,KAAK,IAAI,KAAK;YAElD,sDAAsD;YACtD,IAAI,OAAO,QAAQ,CAAC,YAAY;gBAC9B,MAAM,IAAI,CAAC,WAAW;gBACtB,aAAa;YACf;QACF;QAEA,OAAO;IACT;IA9TA,YAAY,OAAuC,CAAE;QACnD,IAAI,CAAC,UAAU,GAAG,QAAQ,UAAU;QACpC,IAAI,CAAC,YAAY,GAAG,QAAQ,YAAY;QACxC,IAAI,CAAC,gBAAgB,GAAG,QAAQ,gBAAgB,IAAI;QACpD,IAAI,CAAC,SAAS,GAAG,QAAQ,SAAS;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,QAAQ;QAChC,IAAI,CAAC,cAAc,GAAG,QAAQ,cAAc,IAAK,CAAA,QAAQ,MAAM,GAAG,IAAI,+CAAyB,QAAQ,MAAM,IAAI,IAAI,CAAA,GAAA,2CAAgB,EAAE,QAAQ,GAAG,CAAA;QAClJ,IAAI,CAAC,SAAS,GAAG,QAAQ,SAAS,IAAI;IACxC;AAuTF;AAiBA,MAAM;IAOJ,iBAAuB;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc;IACnC;IAEA,YAAY,GAAQ,EAAe;YAC1B;QAAP,OAAO,EAAA,6BAAA,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,kBAA1B,iDAAA,2BAAgC,IAAI,KAAI;IACjD;IAEA,iBAAuB;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW;IAC5C;IAdA,YAAY,MAAwB,CAAE;QACpC,IAAI,CAAC,MAAM,GAAG;IAChB;AAaF","sources":["packages/@react-aria/grid/src/GridKeyboardDelegate.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 {Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, RefObject, Size} from '@react-types/shared';\nimport {DOMLayoutDelegate} from '@react-aria/selection';\nimport {getChildNodes, getFirstItem, getLastItem, getNthItem} from '@react-stately/collections';\nimport {GridCollection} from '@react-types/grid';\n\nexport interface GridKeyboardDelegateOptions<C> {\n collection: C,\n disabledKeys: Set<Key>,\n disabledBehavior?: DisabledBehavior,\n ref?: RefObject<HTMLElement | null>,\n direction: Direction,\n collator?: Intl.Collator,\n layoutDelegate?: LayoutDelegate,\n /** @deprecated - Use layoutDelegate instead. */\n layout?: DeprecatedLayout,\n focusMode?: 'row' | 'cell'\n}\n\nexport class GridKeyboardDelegate<T, C extends GridCollection<T>> implements KeyboardDelegate {\n collection: C;\n protected disabledKeys: Set<Key>;\n protected disabledBehavior: DisabledBehavior;\n protected direction: Direction;\n protected collator: Intl.Collator;\n protected layoutDelegate: LayoutDelegate;\n protected focusMode;\n\n constructor(options: GridKeyboardDelegateOptions<C>) {\n this.collection = options.collection;\n this.disabledKeys = options.disabledKeys;\n this.disabledBehavior = options.disabledBehavior || 'all';\n this.direction = options.direction;\n this.collator = options.collator;\n this.layoutDelegate = options.layoutDelegate || (options.layout ? new DeprecatedLayoutDelegate(options.layout) : new DOMLayoutDelegate(options.ref));\n this.focusMode = options.focusMode || 'row';\n }\n\n protected isCell(node: Node<T>) {\n return node.type === 'cell';\n }\n\n protected isRow(node: Node<T>) {\n return node.type === 'row' || node.type === 'item';\n }\n\n private isDisabled(item: Node<unknown>) {\n return this.disabledBehavior === 'all' && (item.props?.isDisabled || this.disabledKeys.has(item.key));\n }\n\n protected findPreviousKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyBefore(fromKey)\n : this.collection.getLastKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\n }\n\n protected findNextKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyAfter(fromKey)\n : this.collection.getFirstKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n }\n\n getKeyBelow(key: Key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the next item\n key = this.findNextKey(key, (item => item.type === 'item'));\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the next row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n return getNthItem(getChildNodes(item, this.collection), startItem.index).key;\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n }\n\n getKeyAbove(key: Key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the previous item\n key = this.findPreviousKey(key, item => item.type === 'item');\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the previous row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n return getNthItem(getChildNodes(item, this.collection), startItem.index).key;\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n }\n\n getKeyRightOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return;\n }\n\n // If focus is on a row, focus the first child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return this.direction === 'rtl'\n ? getLastItem(children).key\n : getFirstItem(children).key;\n }\n\n // If focus is on a cell, focus the next cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item)) {\n let parent = this.collection.getItem(item.parentKey);\n let children = getChildNodes(parent, this.collection);\n let next = this.direction === 'rtl'\n ? getNthItem(children, item.index - 1)\n : getNthItem(children, item.index + 1);\n\n if (next) {\n return next.key;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey;\n }\n\n return this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key);\n }\n }\n\n getKeyLeftOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return;\n }\n\n // If focus is on a row, focus the last child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return this.direction === 'rtl'\n ? getFirstItem(children).key\n : getLastItem(children).key;\n }\n\n // If focus is on a cell, focus the previous cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item)) {\n let parent = this.collection.getItem(item.parentKey);\n let children = getChildNodes(parent, this.collection);\n let prev = this.direction === 'rtl'\n ? getNthItem(children, item.index + 1)\n : getNthItem(children, item.index - 1);\n\n if (prev) {\n return prev.key;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey;\n }\n\n return this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key);\n }\n }\n\n getFirstKey(key?: Key, global?: boolean) {\n let item: Node<T>;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the first cell in the parent row.\n if (this.isCell(item) && !global) {\n let parent = this.collection.getItem(item.parentKey);\n return getFirstItem(getChildNodes(parent, this.collection)).key;\n }\n }\n\n // Find the first row\n key = this.findNextKey(null, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the first cell in the first row.\n if ((key != null && item && this.isCell(item) && global) || this.focusMode === 'cell') {\n let item = this.collection.getItem(key);\n key = getFirstItem(getChildNodes(item, this.collection)).key;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getLastKey(key?: Key, global?: boolean) {\n let item: Node<T>;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the last cell in the parent row.\n if (this.isCell(item) && !global) {\n let parent = this.collection.getItem(item.parentKey);\n let children = getChildNodes(parent, this.collection);\n return getLastItem(children).key;\n }\n }\n\n // Find the last row\n key = this.findPreviousKey(null, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the last cell in the last row.\n if ((key != null && item && this.isCell(item) && global) || this.focusMode === 'cell') {\n let item = this.collection.getItem(key);\n let children = getChildNodes(item, this.collection);\n key = getLastItem(children).key;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getKeyPageAbove(key: Key) {\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\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 = this.layoutDelegate.getItemRect(key);\n }\n\n return key;\n }\n\n getKeyPageBelow(key: Key) {\n let itemRect = this.layoutDelegate.getItemRect(key);\n\n if (!itemRect) {\n return null;\n }\n\n let pageHeight = this.layoutDelegate.getVisibleRect().height;\n let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y + pageHeight);\n\n while (itemRect && (itemRect.y + itemRect.height) < pageY) {\n let nextKey = this.getKeyBelow(key);\n // If nextKey is undefined, we've reached the last row already\n if (nextKey == null) {\n break;\n }\n\n itemRect = this.layoutDelegate.getItemRect(nextKey);\n key = nextKey;\n }\n\n return key;\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\n // If the starting key is a cell, search from its parent row.\n let startItem = collection.getItem(key);\n if (startItem.type === 'cell') {\n key = startItem.parentKey;\n }\n\n let hasWrapped = false;\n while (key != null) {\n let item = collection.getItem(key);\n\n // check row text value for match\n if (item.textValue) {\n let substring = item.textValue.slice(0, search.length);\n if (this.collator.compare(substring, search) === 0) {\n if (this.isRow(item) && this.focusMode === 'cell') {\n return getFirstItem(getChildNodes(item, this.collection)).key;\n }\n\n return item.key;\n }\n }\n\n key = this.findNextKey(key, item => item.type === 'item');\n\n // Wrap around when reaching the end of the collection\n if (key == null && !hasWrapped) {\n key = this.getFirstKey();\n hasWrapped = true;\n }\n }\n\n return null;\n }\n}\n\n/* Backward compatibility for old Virtualizer Layout interface. */\ninterface DeprecatedLayout {\n getLayoutInfo(key: Key): DeprecatedLayoutInfo,\n getContentSize(): Size,\n virtualizer: DeprecatedVirtualizer\n}\n\ninterface DeprecatedLayoutInfo {\n rect: Rect\n}\n\ninterface DeprecatedVirtualizer {\n visibleRect: Rect\n}\n\nclass DeprecatedLayoutDelegate implements LayoutDelegate {\n layout: DeprecatedLayout;\n\n constructor(layout: DeprecatedLayout) {\n this.layout = layout;\n }\n\n getContentSize(): Size {\n return this.layout.getContentSize();\n }\n\n getItemRect(key: Key): Rect | null {\n return this.layout.getLayoutInfo(key)?.rect || null;\n }\n\n getVisibleRect(): Rect {\n return this.layout.virtualizer.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"GridKeyboardDelegate.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAoBM,MAAM;IAsBD,OAAO,IAAa,EAAE;QAC9B,OAAO,KAAK,IAAI,KAAK;IACvB;IAEU,MAAM,IAAa,EAAE;QAC7B,OAAO,KAAK,IAAI,KAAK,SAAS,KAAK,IAAI,KAAK;IAC9C;IAEQ,WAAW,IAAmB,EAAE;YACK;QAA3C,OAAO,IAAI,CAAC,gBAAgB,KAAK,SAAU,CAAA,EAAA,cAAA,KAAK,KAAK,cAAV,kCAAA,YAAY,UAAU,KAAI,IAAI,CAAC,YAAY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,GAAG,EACjC,MAAM,IAAI,MAAM;QAElB,IAAI,CAAC,cAAc,GAAG,QAAQ,cAAc,IAAK,CAAA,QAAQ,MAAM,GAAG,IAAI,+CAAyB,QAAQ,MAAM,IAAI,IAAI,CAAA,GAAA,2CAAgB,EAAE,QAAQ,GAAG,CAAC;QACnJ,IAAI,CAAC,SAAS,GAAG,QAAQ,SAAS,IAAI;IACxC;AAuXF;AAiBA,MAAM;IAOJ,iBAAuB;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc;IACnC;IAEA,YAAY,GAAQ,EAAe;YAC1B;QAAP,OAAO,EAAA,6BAAA,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,kBAA1B,iDAAA,2BAAgC,IAAI,KAAI;IACjD;IAEA,iBAAuB;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW;IAC5C;IAdA,YAAY,MAAwB,CAAE;QACpC,IAAI,CAAC,MAAM,GAAG;IAChB;AAaF","sources":["packages/@react-aria/grid/src/GridKeyboardDelegate.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 {Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, RefObject, Size} from '@react-types/shared';\nimport {DOMLayoutDelegate} from '@react-aria/selection';\nimport {getChildNodes, getFirstItem, getLastItem, getNthItem} from '@react-stately/collections';\nimport {GridCollection} from '@react-types/grid';\n\nexport interface GridKeyboardDelegateOptions<C> {\n collection: C,\n disabledKeys: Set<Key>,\n disabledBehavior?: DisabledBehavior,\n ref?: RefObject<HTMLElement | null>,\n direction: Direction,\n collator?: Intl.Collator,\n layoutDelegate?: LayoutDelegate,\n /** @deprecated - Use layoutDelegate instead. */\n layout?: DeprecatedLayout,\n focusMode?: 'row' | 'cell'\n}\n\nexport class GridKeyboardDelegate<T, C extends GridCollection<T>> implements KeyboardDelegate {\n collection: C;\n protected disabledKeys: Set<Key>;\n protected disabledBehavior: DisabledBehavior;\n protected direction: Direction;\n protected collator: Intl.Collator | undefined;\n protected layoutDelegate: LayoutDelegate;\n protected focusMode;\n\n constructor(options: GridKeyboardDelegateOptions<C>) {\n this.collection = options.collection;\n this.disabledKeys = options.disabledKeys;\n this.disabledBehavior = options.disabledBehavior || 'all';\n this.direction = options.direction;\n this.collator = options.collator;\n if (!options.layout && !options.ref) {\n throw new Error('Either a layout or a ref must be specified.');\n }\n this.layoutDelegate = options.layoutDelegate || (options.layout ? new DeprecatedLayoutDelegate(options.layout) : new DOMLayoutDelegate(options.ref!));\n this.focusMode = options.focusMode || 'row';\n }\n\n protected isCell(node: Node<T>) {\n return node.type === 'cell';\n }\n\n protected isRow(node: Node<T>) {\n return node.type === 'row' || node.type === 'item';\n }\n\n private isDisabled(item: Node<unknown>) {\n return this.disabledBehavior === 'all' && (item.props?.isDisabled || this.disabledKeys.has(item.key));\n }\n\n protected findPreviousKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyBefore(fromKey)\n : this.collection.getLastKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\n return null;\n }\n\n protected findNextKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyAfter(fromKey)\n : this.collection.getFirstKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n return null;\n }\n }\n return null;\n }\n\n getKeyBelow(fromKey: Key) {\n let key: Key | null = fromKey;\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return null;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey ?? null;\n }\n if (key == null) {\n return null;\n }\n\n // Find the next item\n key = this.findNextKey(key, (item => item.type === 'item'));\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the next row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n return getNthItem(getChildNodes(item, this.collection), startItem.index ?? 0)?.key ?? null;\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n return null;\n }\n\n getKeyAbove(fromKey: Key) {\n let key: Key | null = fromKey;\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return null;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey ?? null;\n }\n if (key == null) {\n return null;\n }\n\n // Find the previous item\n key = this.findPreviousKey(key, item => item.type === 'item');\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the previous row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n return getNthItem(getChildNodes(item, this.collection), startItem.index ?? 0)?.key || null;\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n return null;\n }\n\n getKeyRightOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If focus is on a row, focus the first child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return (this.direction === 'rtl'\n ? getLastItem(children)?.key\n : getFirstItem(children)?.key) ?? null;\n }\n\n // If focus is on a cell, focus the next cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item) && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n let next = (this.direction === 'rtl'\n ? getNthItem(children, item.index - 1)\n : getNthItem(children, item.index + 1)) ?? null;\n\n if (next) {\n return next.key ?? null;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey ?? null;\n }\n\n return (this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key)) ?? null;\n }\n return null;\n }\n\n getKeyLeftOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If focus is on a row, focus the last child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return (this.direction === 'rtl'\n ? getFirstItem(children)?.key\n : getLastItem(children)?.key) ?? null;\n }\n\n // If focus is on a cell, focus the previous cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item) && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n let prev = (this.direction === 'rtl'\n ? getNthItem(children, item.index + 1)\n : getNthItem(children, item.index - 1)) ?? null;\n\n if (prev) {\n return prev.key ?? null;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey ?? null;\n }\n\n return (this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key)) ?? null;\n }\n return null;\n }\n\n getFirstKey(fromKey?: Key, global?: boolean) {\n let key: Key | null = fromKey ?? null;\n let item: Node<T> | undefined | null;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the first cell in the parent row.\n if (this.isCell(item) && !global && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n return getFirstItem(getChildNodes(parent, this.collection))?.key ?? null;\n }\n }\n\n // Find the first row\n key = this.findNextKey(undefined, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the first cell in the first row.\n if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n key = getFirstItem(getChildNodes(item, this.collection))?.key ?? null;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getLastKey(fromKey?: Key, global?: boolean) {\n let key: Key | null = fromKey ?? null;\n let item: Node<T> | undefined | null;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the last cell in the parent row.\n if (this.isCell(item) && !global && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n return getLastItem(children)?.key ?? null;\n }\n }\n\n // Find the last row\n key = this.findPreviousKey(undefined, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the last cell in the last row.\n if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n let children = getChildNodes(item, this.collection);\n key = getLastItem(children)?.key ?? null;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getKeyPageAbove(fromKey: Key) {\n let key: Key | null = fromKey;\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);\n\n while (itemRect && itemRect.y > pageY && key != null) {\n key = this.getKeyAbove(key) ?? null;\n if (key == null) {\n break;\n }\n itemRect = this.layoutDelegate.getItemRect(key);\n }\n\n return key;\n }\n\n getKeyPageBelow(fromKey: Key) {\n let key: Key | null = fromKey;\n let itemRect = this.layoutDelegate.getItemRect(key);\n\n if (!itemRect) {\n return null;\n }\n\n let pageHeight = this.layoutDelegate.getVisibleRect().height;\n let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y + pageHeight);\n\n while (itemRect && (itemRect.y + itemRect.height) < pageY) {\n let nextKey = this.getKeyBelow(key);\n // If nextKey is undefined, we've reached the last row already\n if (nextKey == null) {\n break;\n }\n\n itemRect = this.layoutDelegate.getItemRect(nextKey);\n key = nextKey;\n }\n\n return key;\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n let key: Key | null = fromKey ?? null;\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n key = fromKey ?? this.getFirstKey();\n if (key == null) {\n return null;\n }\n\n // If the starting key is a cell, search from its parent row.\n let startItem = collection.getItem(key);\n if (!startItem) {\n return null;\n }\n if (startItem.type === 'cell') {\n key = startItem.parentKey ?? null;\n }\n\n let hasWrapped = false;\n while (key != null) {\n let item = collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // check row text value for match\n if (item.textValue) {\n let substring = item.textValue.slice(0, search.length);\n if (this.collator.compare(substring, search) === 0) {\n if (this.isRow(item) && this.focusMode === 'cell') {\n return getFirstItem(getChildNodes(item, this.collection))?.key ?? null;\n }\n\n return item.key;\n }\n }\n\n key = this.findNextKey(key, item => item.type === 'item');\n\n // Wrap around when reaching the end of the collection\n if (key == null && !hasWrapped) {\n key = this.getFirstKey();\n hasWrapped = true;\n }\n }\n\n return null;\n }\n}\n\n/* Backward compatibility for old Virtualizer Layout interface. */\ninterface DeprecatedLayout {\n getLayoutInfo(key: Key): DeprecatedLayoutInfo,\n getContentSize(): Size,\n virtualizer: DeprecatedVirtualizer\n}\n\ninterface DeprecatedLayoutInfo {\n rect: Rect\n}\n\ninterface DeprecatedVirtualizer {\n visibleRect: Rect\n}\n\nclass DeprecatedLayoutDelegate implements LayoutDelegate {\n layout: DeprecatedLayout;\n\n constructor(layout: DeprecatedLayout) {\n this.layout = layout;\n }\n\n getContentSize(): Size {\n return this.layout.getContentSize();\n }\n\n getItemRect(key: Key): Rect | null {\n return this.layout.getLayoutInfo(key)?.rect || null;\n }\n\n getVisibleRect(): Rect {\n return this.layout.virtualizer.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"GridKeyboardDelegate.main.js.map"}
|