@react-aria/grid 3.10.4 → 3.11.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/LICENSE +201 -0
- 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 +18 -17
- 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
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2019 Adobe
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -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,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,CAAC,GAAG,CAAC,KAAK,GAAG,CAAA;IACrG;IAEU,gBAAgB,OAAa,EAAE,IAAiC,EAAE;QAC1E,IAAI,MAAM,WAAW,OACjB,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,WAC7B,IAAI,CAAC,UAAU,CAAC,UAAU;QAE9B,MAAO,OAAO,KAAM;YAClB,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAU,CAAA,CAAC,QAAQ,KAAK,KAAI,GAC/C,OAAO;YAGT,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QACrC;IACF;IAEU,YAAY,OAAa,EAAE,IAAiC,EAAE;QACtE,IAAI,MAAM,WAAW,OACjB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,WAC5B,IAAI,CAAC,UAAU,CAAC,WAAW;QAE/B,MAAO,OAAO,KAAM;YAClB,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACnC,IAAI,CAAC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AAI,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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EA,OAAO;IACT;IAjYA,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,QAAQ,MAAM,IAAI,CAAC,QAAQ,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"}
|