@react-aria/grid 3.8.9-nightly.4555 → 3.8.9-nightly.4560

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/GridKeyboardDelegate.main.js +252 -0
  2. package/dist/GridKeyboardDelegate.main.js.map +1 -0
  3. package/dist/GridKeyboardDelegate.mjs +247 -0
  4. package/dist/GridKeyboardDelegate.module.js +247 -0
  5. package/dist/GridKeyboardDelegate.module.js.map +1 -0
  6. package/dist/ar-AE.mjs +1 -1
  7. package/dist/bg-BG.mjs +1 -1
  8. package/dist/cs-CZ.mjs +1 -1
  9. package/dist/da-DK.mjs +1 -1
  10. package/dist/de-DE.mjs +1 -1
  11. package/dist/el-GR.mjs +1 -1
  12. package/dist/en-US.mjs +1 -1
  13. package/dist/es-ES.mjs +1 -1
  14. package/dist/et-EE.mjs +1 -1
  15. package/dist/fi-FI.mjs +1 -1
  16. package/dist/fr-FR.mjs +1 -1
  17. package/dist/he-IL.mjs +1 -1
  18. package/dist/hr-HR.mjs +1 -1
  19. package/dist/hu-HU.mjs +1 -1
  20. package/dist/import.mjs +8 -884
  21. package/dist/intlStrings.main.js +108 -0
  22. package/dist/intlStrings.main.js.map +1 -0
  23. package/dist/intlStrings.mjs +110 -0
  24. package/dist/intlStrings.module.js +110 -0
  25. package/dist/intlStrings.module.js.map +1 -0
  26. package/dist/it-IT.mjs +1 -1
  27. package/dist/ja-JP.mjs +1 -1
  28. package/dist/ko-KR.mjs +1 -1
  29. package/dist/lt-LT.mjs +1 -1
  30. package/dist/lv-LV.mjs +1 -1
  31. package/dist/main.js +16 -892
  32. package/dist/main.js.map +1 -1
  33. package/dist/module.js +8 -884
  34. package/dist/module.js.map +1 -1
  35. package/dist/nb-NO.mjs +1 -1
  36. package/dist/nl-NL.mjs +1 -1
  37. package/dist/pl-PL.mjs +1 -1
  38. package/dist/pt-BR.mjs +1 -1
  39. package/dist/pt-PT.mjs +1 -1
  40. package/dist/ro-RO.mjs +1 -1
  41. package/dist/ru-RU.mjs +1 -1
  42. package/dist/sk-SK.mjs +1 -1
  43. package/dist/sl-SI.mjs +1 -1
  44. package/dist/sr-SP.mjs +1 -1
  45. package/dist/sv-SE.mjs +1 -1
  46. package/dist/tr-TR.mjs +1 -1
  47. package/dist/uk-UA.mjs +1 -1
  48. package/dist/useGrid.main.js +132 -0
  49. package/dist/useGrid.main.js.map +1 -0
  50. package/dist/useGrid.mjs +127 -0
  51. package/dist/useGrid.module.js +127 -0
  52. package/dist/useGrid.module.js.map +1 -0
  53. package/dist/useGridCell.main.js +220 -0
  54. package/dist/useGridCell.main.js.map +1 -0
  55. package/dist/useGridCell.mjs +215 -0
  56. package/dist/useGridCell.module.js +215 -0
  57. package/dist/useGridCell.module.js.map +1 -0
  58. package/dist/useGridRow.main.js +53 -0
  59. package/dist/useGridRow.main.js.map +1 -0
  60. package/dist/useGridRow.mjs +48 -0
  61. package/dist/useGridRow.module.js +48 -0
  62. package/dist/useGridRow.module.js.map +1 -0
  63. package/dist/useGridRowGroup.main.js +26 -0
  64. package/dist/useGridRowGroup.main.js.map +1 -0
  65. package/dist/useGridRowGroup.mjs +21 -0
  66. package/dist/useGridRowGroup.module.js +21 -0
  67. package/dist/useGridRowGroup.module.js.map +1 -0
  68. package/dist/useGridSelectionAnnouncement.main.js +94 -0
  69. package/dist/useGridSelectionAnnouncement.main.js.map +1 -0
  70. package/dist/useGridSelectionAnnouncement.mjs +89 -0
  71. package/dist/useGridSelectionAnnouncement.module.js +89 -0
  72. package/dist/useGridSelectionAnnouncement.module.js.map +1 -0
  73. package/dist/useGridSelectionCheckbox.main.js +38 -0
  74. package/dist/useGridSelectionCheckbox.main.js.map +1 -0
  75. package/dist/useGridSelectionCheckbox.mjs +33 -0
  76. package/dist/useGridSelectionCheckbox.module.js +33 -0
  77. package/dist/useGridSelectionCheckbox.module.js.map +1 -0
  78. package/dist/useHighlightSelectionDescription.main.js +55 -0
  79. package/dist/useHighlightSelectionDescription.main.js.map +1 -0
  80. package/dist/useHighlightSelectionDescription.mjs +50 -0
  81. package/dist/useHighlightSelectionDescription.module.js +50 -0
  82. package/dist/useHighlightSelectionDescription.module.js.map +1 -0
  83. package/dist/utils.main.js +20 -0
  84. package/dist/utils.main.js.map +1 -0
  85. package/dist/utils.mjs +15 -0
  86. package/dist/utils.module.js +15 -0
  87. package/dist/utils.module.js.map +1 -0
  88. package/dist/zh-CN.mjs +1 -1
  89. package/dist/zh-TW.mjs +1 -1
  90. package/package.json +15 -15
package/dist/main.js CHANGED
@@ -1,316 +1,25 @@
1
- var $6f42661ae0214332$exports = require("./ar-AE.main.js");
2
- var $3e5d289b19f0fad9$exports = require("./bg-BG.main.js");
3
- var $786c35956e916979$exports = require("./cs-CZ.main.js");
4
- var $7166f564b8fa3e8a$exports = require("./da-DK.main.js");
5
- var $12fc5e32bb482de0$exports = require("./de-DE.main.js");
6
- var $84b67ad15c785b2c$exports = require("./el-GR.main.js");
7
- var $86f7e6ba2423a35d$exports = require("./en-US.main.js");
8
- var $67f524d2f2545d56$exports = require("./es-ES.main.js");
9
- var $d8df13f1dbf6e0c4$exports = require("./et-EE.main.js");
10
- var $e2b4dfe2d4d55739$exports = require("./fi-FI.main.js");
11
- var $c06d6698d30993e7$exports = require("./fr-FR.main.js");
12
- var $e775713aa5566057$exports = require("./he-IL.main.js");
13
- var $a972cfeb69a51f5b$exports = require("./hr-HR.main.js");
14
- var $a471da6bb87e6cd1$exports = require("./hu-HU.main.js");
15
- var $47879155027d6c95$exports = require("./it-IT.main.js");
16
- var $9cd8dc003c2209e6$exports = require("./ja-JP.main.js");
17
- var $a490b9448c5f2ded$exports = require("./ko-KR.main.js");
18
- var $99f69e0597841328$exports = require("./lt-LT.main.js");
19
- var $28ac5b31e47d46d4$exports = require("./lv-LV.main.js");
20
- var $d0ae97c9412add8b$exports = require("./nb-NO.main.js");
21
- var $7e5335510891b8c3$exports = require("./nl-NL.main.js");
22
- var $455cb5ebd5f6c27d$exports = require("./pl-PL.main.js");
23
- var $55020c522ee676a2$exports = require("./pt-BR.main.js");
24
- var $cc691e0f35e41c7f$exports = require("./pt-PT.main.js");
25
- var $712b70af9d7e11e9$exports = require("./ro-RO.main.js");
26
- var $c483d9d6d4bcff75$exports = require("./ru-RU.main.js");
27
- var $35bc9f18e7cf9157$exports = require("./sk-SK.main.js");
28
- var $e933d1373d8e91e0$exports = require("./sl-SI.main.js");
29
- var $77463d6521c72512$exports = require("./sr-SP.main.js");
30
- var $6380ab044222ca52$exports = require("./sv-SE.main.js");
31
- var $9cb854f23a6ff322$exports = require("./tr-TR.main.js");
32
- var $912862d79e063c74$exports = require("./uk-UA.main.js");
33
- var $91bb887772fd7ad4$exports = require("./zh-CN.main.js");
34
- var $a33ce76c4b030d83$exports = require("./zh-TW.main.js");
35
- var $2oePb$reactstatelycollections = require("@react-stately/collections");
36
- var $2oePb$reactstatelyvirtualizer = require("@react-stately/virtualizer");
37
- var $2oePb$reactariautils = require("@react-aria/utils");
38
- var $2oePb$react = require("react");
39
- var $2oePb$reactariai18n = require("@react-aria/i18n");
40
- var $2oePb$reactariafocus = require("@react-aria/focus");
41
- var $2oePb$reactariaselection = require("@react-aria/selection");
42
- var $2oePb$reactarialiveannouncer = require("@react-aria/live-announcer");
43
- var $2oePb$reactariainteractions = require("@react-aria/interactions");
1
+ var $3187c0e19200cb16$exports = require("./GridKeyboardDelegate.main.js");
2
+ var $11d770dfabe45077$exports = require("./useGrid.main.js");
3
+ var $c7def85a57100898$exports = require("./useGridRowGroup.main.js");
4
+ var $eed398987c639831$exports = require("./useGridRow.main.js");
5
+ var $cf2021be63b01ef4$exports = require("./useGridCell.main.js");
6
+ var $d8385f73d3701365$exports = require("./useGridSelectionCheckbox.main.js");
7
+ var $340f2fcd0ef9ce8d$exports = require("./useHighlightSelectionDescription.main.js");
8
+ var $1eb174acfe8a0f16$exports = require("./useGridSelectionAnnouncement.main.js");
44
9
 
45
10
 
46
11
  function $parcel$export(e, n, v, s) {
47
12
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
48
13
  }
49
14
 
50
- function $parcel$interopDefault(a) {
51
- return a && a.__esModule ? a.default : a;
52
- }
53
-
54
- $parcel$export(module.exports, "GridKeyboardDelegate", () => $3187c0e19200cb16$export$de9feff04fda126e);
55
- $parcel$export(module.exports, "useGrid", () => $11d770dfabe45077$export$f6b86a04e5d66d90);
56
- $parcel$export(module.exports, "useGridRowGroup", () => $c7def85a57100898$export$d3037f5d3f3e51bf);
57
- $parcel$export(module.exports, "useGridRow", () => $eed398987c639831$export$96357d5a73f686fa);
58
- $parcel$export(module.exports, "useGridCell", () => $cf2021be63b01ef4$export$c7e10bfc0c59f67c);
59
- $parcel$export(module.exports, "useGridSelectionCheckbox", () => $d8385f73d3701365$export$70e2eed1a92976ad);
60
- $parcel$export(module.exports, "useHighlightSelectionDescription", () => $340f2fcd0ef9ce8d$export$be42ebdab07ae4c2);
61
- $parcel$export(module.exports, "useGridSelectionAnnouncement", () => $1eb174acfe8a0f16$export$137e594ef3218a10);
62
- /*
63
- * Copyright 2020 Adobe. All rights reserved.
64
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
65
- * you may not use this file except in compliance with the License. You may obtain a copy
66
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
67
- *
68
- * Unless required by applicable law or agreed to in writing, software distributed under
69
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
70
- * OF ANY KIND, either express or implied. See the License for the specific language
71
- * governing permissions and limitations under the License.
72
- */ /*
73
- * Copyright 2020 Adobe. All rights reserved.
74
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
75
- * you may not use this file except in compliance with the License. You may obtain a copy
76
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
77
- *
78
- * Unless required by applicable law or agreed to in writing, software distributed under
79
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
80
- * OF ANY KIND, either express or implied. See the License for the specific language
81
- * governing permissions and limitations under the License.
82
- */
83
-
84
- class $3187c0e19200cb16$export$de9feff04fda126e {
85
- isCell(node) {
86
- return node.type === "cell";
87
- }
88
- isRow(node) {
89
- return node.type === "row" || node.type === "item";
90
- }
91
- isDisabled(item) {
92
- var _item_props;
93
- return this.disabledBehavior === "all" && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
94
- }
95
- findPreviousKey(fromKey, pred) {
96
- let key = fromKey != null ? this.collection.getKeyBefore(fromKey) : this.collection.getLastKey();
97
- while(key != null){
98
- let item = this.collection.getItem(key);
99
- if (!this.isDisabled(item) && (!pred || pred(item))) return key;
100
- key = this.collection.getKeyBefore(key);
101
- }
102
- }
103
- findNextKey(fromKey, pred) {
104
- let key = fromKey != null ? this.collection.getKeyAfter(fromKey) : this.collection.getFirstKey();
105
- while(key != null){
106
- let item = this.collection.getItem(key);
107
- if (!this.isDisabled(item) && (!pred || pred(item))) return key;
108
- key = this.collection.getKeyAfter(key);
109
- }
110
- }
111
- getKeyBelow(key) {
112
- let startItem = this.collection.getItem(key);
113
- if (!startItem) return;
114
- // If focus was on a cell, start searching from the parent row
115
- if (this.isCell(startItem)) key = startItem.parentKey;
116
- // Find the next item
117
- key = this.findNextKey(key);
118
- if (key != null) {
119
- // If focus was on a cell, focus the cell with the same index in the next row.
120
- if (this.isCell(startItem)) {
121
- let item = this.collection.getItem(key);
122
- return (0, $2oePb$reactstatelycollections.getNthItem)((0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection), startItem.index).key;
123
- }
124
- // Otherwise, focus the next row
125
- if (this.focusMode === "row") return key;
126
- }
127
- }
128
- getKeyAbove(key) {
129
- let startItem = this.collection.getItem(key);
130
- if (!startItem) return;
131
- // If focus is on a cell, start searching from the parent row
132
- if (this.isCell(startItem)) key = startItem.parentKey;
133
- // Find the previous item
134
- key = this.findPreviousKey(key);
135
- if (key != null) {
136
- // If focus was on a cell, focus the cell with the same index in the previous row.
137
- if (this.isCell(startItem)) {
138
- let item = this.collection.getItem(key);
139
- return (0, $2oePb$reactstatelycollections.getNthItem)((0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection), startItem.index).key;
140
- }
141
- // Otherwise, focus the previous row
142
- if (this.focusMode === "row") return key;
143
- }
144
- }
145
- getKeyRightOf(key) {
146
- let item = this.collection.getItem(key);
147
- if (!item) return;
148
- // If focus is on a row, focus the first child cell.
149
- if (this.isRow(item)) {
150
- let children = (0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection);
151
- return this.direction === "rtl" ? (0, $2oePb$reactstatelycollections.getLastItem)(children).key : (0, $2oePb$reactstatelycollections.getFirstItem)(children).key;
152
- }
153
- // If focus is on a cell, focus the next cell if any,
154
- // otherwise focus the parent row.
155
- if (this.isCell(item)) {
156
- let parent = this.collection.getItem(item.parentKey);
157
- let children = (0, $2oePb$reactstatelycollections.getChildNodes)(parent, this.collection);
158
- let next = this.direction === "rtl" ? (0, $2oePb$reactstatelycollections.getNthItem)(children, item.index - 1) : (0, $2oePb$reactstatelycollections.getNthItem)(children, item.index + 1);
159
- if (next) return next.key;
160
- // focus row only if focusMode is set to row
161
- if (this.focusMode === "row") return item.parentKey;
162
- return this.direction === "rtl" ? this.getFirstKey(key) : this.getLastKey(key);
163
- }
164
- }
165
- getKeyLeftOf(key) {
166
- let item = this.collection.getItem(key);
167
- if (!item) return;
168
- // If focus is on a row, focus the last child cell.
169
- if (this.isRow(item)) {
170
- let children = (0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection);
171
- return this.direction === "rtl" ? (0, $2oePb$reactstatelycollections.getFirstItem)(children).key : (0, $2oePb$reactstatelycollections.getLastItem)(children).key;
172
- }
173
- // If focus is on a cell, focus the previous cell if any,
174
- // otherwise focus the parent row.
175
- if (this.isCell(item)) {
176
- let parent = this.collection.getItem(item.parentKey);
177
- let children = (0, $2oePb$reactstatelycollections.getChildNodes)(parent, this.collection);
178
- let prev = this.direction === "rtl" ? (0, $2oePb$reactstatelycollections.getNthItem)(children, item.index + 1) : (0, $2oePb$reactstatelycollections.getNthItem)(children, item.index - 1);
179
- if (prev) return prev.key;
180
- // focus row only if focusMode is set to row
181
- if (this.focusMode === "row") return item.parentKey;
182
- return this.direction === "rtl" ? this.getLastKey(key) : this.getFirstKey(key);
183
- }
184
- }
185
- getFirstKey(key, global) {
186
- let item;
187
- if (key != null) {
188
- item = this.collection.getItem(key);
189
- if (!item) return;
190
- // If global flag is not set, and a cell is currently focused,
191
- // move focus to the first cell in the parent row.
192
- if (this.isCell(item) && !global) {
193
- let parent = this.collection.getItem(item.parentKey);
194
- return (0, $2oePb$reactstatelycollections.getFirstItem)((0, $2oePb$reactstatelycollections.getChildNodes)(parent, this.collection)).key;
195
- }
196
- }
197
- // Find the first row
198
- key = this.findNextKey();
199
- // If global flag is set (or if focus mode is cell), focus the first cell in the first row.
200
- if (key != null && item && this.isCell(item) && global || this.focusMode === "cell") {
201
- let item = this.collection.getItem(key);
202
- key = (0, $2oePb$reactstatelycollections.getFirstItem)((0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection)).key;
203
- }
204
- // Otherwise, focus the row itself.
205
- return key;
206
- }
207
- getLastKey(key, global) {
208
- let item;
209
- if (key != null) {
210
- item = this.collection.getItem(key);
211
- if (!item) return;
212
- // If global flag is not set, and a cell is currently focused,
213
- // move focus to the last cell in the parent row.
214
- if (this.isCell(item) && !global) {
215
- let parent = this.collection.getItem(item.parentKey);
216
- let children = (0, $2oePb$reactstatelycollections.getChildNodes)(parent, this.collection);
217
- return (0, $2oePb$reactstatelycollections.getLastItem)(children).key;
218
- }
219
- }
220
- // Find the last row
221
- key = this.findPreviousKey();
222
- // If global flag is set (or if focus mode is cell), focus the last cell in the last row.
223
- if (key != null && item && this.isCell(item) && global || this.focusMode === "cell") {
224
- let item = this.collection.getItem(key);
225
- let children = (0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection);
226
- key = (0, $2oePb$reactstatelycollections.getLastItem)(children).key;
227
- }
228
- // Otherwise, focus the row itself.
229
- return key;
230
- }
231
- getItem(key) {
232
- return this.ref.current.querySelector(`[data-key="${CSS.escape(key.toString())}"]`);
233
- }
234
- getItemRect(key) {
235
- var _this_layout_getLayoutInfo;
236
- if (this.layout) return (_this_layout_getLayoutInfo = this.layout.getLayoutInfo(key)) === null || _this_layout_getLayoutInfo === void 0 ? void 0 : _this_layout_getLayoutInfo.rect;
237
- let item = this.getItem(key);
238
- if (item) return new (0, $2oePb$reactstatelyvirtualizer.Rect)(item.offsetLeft, item.offsetTop, item.offsetWidth, item.offsetHeight);
239
- }
240
- getPageHeight() {
241
- var _this_layout_virtualizer, _this_ref_current, _this_ref;
242
- if (this.layout) return (_this_layout_virtualizer = this.layout.virtualizer) === null || _this_layout_virtualizer === void 0 ? void 0 : _this_layout_virtualizer.visibleRect.height;
243
- return (_this_ref = this.ref) === null || _this_ref === void 0 ? void 0 : (_this_ref_current = _this_ref.current) === null || _this_ref_current === void 0 ? void 0 : _this_ref_current.offsetHeight;
244
- }
245
- getContentHeight() {
246
- var _this_ref_current, _this_ref;
247
- if (this.layout) return this.layout.getContentSize().height;
248
- return (_this_ref = this.ref) === null || _this_ref === void 0 ? void 0 : (_this_ref_current = _this_ref.current) === null || _this_ref_current === void 0 ? void 0 : _this_ref_current.scrollHeight;
249
- }
250
- getKeyPageAbove(key) {
251
- let itemRect = this.getItemRect(key);
252
- if (!itemRect) return null;
253
- let pageY = Math.max(0, itemRect.maxY - this.getPageHeight());
254
- while(itemRect && itemRect.y > pageY){
255
- key = this.getKeyAbove(key);
256
- itemRect = this.getItemRect(key);
257
- }
258
- return key;
259
- }
260
- getKeyPageBelow(key) {
261
- let itemRect = this.getItemRect(key);
262
- if (!itemRect) return null;
263
- let pageHeight = this.getPageHeight();
264
- let pageY = Math.min(this.getContentHeight(), itemRect.y + pageHeight);
265
- while(itemRect && itemRect.maxY < pageY){
266
- let nextKey = this.getKeyBelow(key);
267
- itemRect = this.getItemRect(nextKey);
268
- // Guard against case where maxY of the last key is barely less than pageY due to rounding
269
- // and thus it attempts to set key to null
270
- if (nextKey != null) key = nextKey;
271
- }
272
- return key;
273
- }
274
- getKeyForSearch(search, fromKey) {
275
- if (!this.collator) return null;
276
- let collection = this.collection;
277
- let key = fromKey !== null && fromKey !== void 0 ? fromKey : this.getFirstKey();
278
- // If the starting key is a cell, search from its parent row.
279
- let startItem = collection.getItem(key);
280
- if (startItem.type === "cell") key = startItem.parentKey;
281
- let hasWrapped = false;
282
- while(key != null){
283
- let item = collection.getItem(key);
284
- // check row text value for match
285
- if (item.textValue) {
286
- let substring = item.textValue.slice(0, search.length);
287
- if (this.collator.compare(substring, search) === 0) {
288
- if (this.isRow(item) && this.focusMode === "cell") return (0, $2oePb$reactstatelycollections.getFirstItem)((0, $2oePb$reactstatelycollections.getChildNodes)(item, this.collection)).key;
289
- return item.key;
290
- }
291
- }
292
- key = this.findNextKey(key);
293
- // Wrap around when reaching the end of the collection
294
- if (key == null && !hasWrapped) {
295
- key = this.getFirstKey();
296
- hasWrapped = true;
297
- }
298
- }
299
- return null;
300
- }
301
- constructor(options){
302
- this.collection = options.collection;
303
- this.disabledKeys = options.disabledKeys;
304
- this.disabledBehavior = options.disabledBehavior || "all";
305
- this.ref = options.ref;
306
- this.direction = options.direction;
307
- this.collator = options.collator;
308
- this.layout = options.layout;
309
- this.focusMode = options.focusMode || "row";
310
- }
311
- }
312
-
313
-
15
+ $parcel$export(module.exports, "GridKeyboardDelegate", () => $3187c0e19200cb16$exports.GridKeyboardDelegate);
16
+ $parcel$export(module.exports, "useGrid", () => $11d770dfabe45077$exports.useGrid);
17
+ $parcel$export(module.exports, "useGridRowGroup", () => $c7def85a57100898$exports.useGridRowGroup);
18
+ $parcel$export(module.exports, "useGridRow", () => $eed398987c639831$exports.useGridRow);
19
+ $parcel$export(module.exports, "useGridCell", () => $cf2021be63b01ef4$exports.useGridCell);
20
+ $parcel$export(module.exports, "useGridSelectionCheckbox", () => $d8385f73d3701365$exports.useGridSelectionCheckbox);
21
+ $parcel$export(module.exports, "useHighlightSelectionDescription", () => $340f2fcd0ef9ce8d$exports.useHighlightSelectionDescription);
22
+ $parcel$export(module.exports, "useGridSelectionAnnouncement", () => $1eb174acfe8a0f16$exports.useGridSelectionAnnouncement);
314
23
  /*
315
24
  * Copyright 2020 Adobe. All rights reserved.
316
25
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -323,596 +32,11 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
323
32
  * governing permissions and limitations under the License.
324
33
  */
325
34
 
326
- /*
327
- * Copyright 2020 Adobe. All rights reserved.
328
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
329
- * you may not use this file except in compliance with the License. You may obtain a copy
330
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
331
- *
332
- * Unless required by applicable law or agreed to in writing, software distributed under
333
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
334
- * OF ANY KIND, either express or implied. See the License for the specific language
335
- * governing permissions and limitations under the License.
336
- */ const $8ee34951196858d0$export$e6235c0d09b995d0 = new WeakMap();
337
-
338
-
339
-
340
-
341
- /*
342
- * Copyright 2022 Adobe. All rights reserved.
343
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
344
- * you may not use this file except in compliance with the License. You may obtain a copy
345
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
346
- *
347
- * Unless required by applicable law or agreed to in writing, software distributed under
348
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
349
- * OF ANY KIND, either express or implied. See the License for the specific language
350
- * governing permissions and limitations under the License.
351
- */
352
- var $085250522aa37816$exports = {};
353
-
354
-
355
-
356
-
357
-
358
-
359
-
360
-
361
-
362
-
363
-
364
-
365
-
366
-
367
-
368
-
369
-
370
-
371
-
372
-
373
-
374
-
375
-
376
-
377
-
378
-
379
-
380
-
381
-
382
-
383
-
384
-
385
-
386
-
387
- $085250522aa37816$exports = {
388
- "ar-AE": $6f42661ae0214332$exports,
389
- "bg-BG": $3e5d289b19f0fad9$exports,
390
- "cs-CZ": $786c35956e916979$exports,
391
- "da-DK": $7166f564b8fa3e8a$exports,
392
- "de-DE": $12fc5e32bb482de0$exports,
393
- "el-GR": $84b67ad15c785b2c$exports,
394
- "en-US": $86f7e6ba2423a35d$exports,
395
- "es-ES": $67f524d2f2545d56$exports,
396
- "et-EE": $d8df13f1dbf6e0c4$exports,
397
- "fi-FI": $e2b4dfe2d4d55739$exports,
398
- "fr-FR": $c06d6698d30993e7$exports,
399
- "he-IL": $e775713aa5566057$exports,
400
- "hr-HR": $a972cfeb69a51f5b$exports,
401
- "hu-HU": $a471da6bb87e6cd1$exports,
402
- "it-IT": $47879155027d6c95$exports,
403
- "ja-JP": $9cd8dc003c2209e6$exports,
404
- "ko-KR": $a490b9448c5f2ded$exports,
405
- "lt-LT": $99f69e0597841328$exports,
406
- "lv-LV": $28ac5b31e47d46d4$exports,
407
- "nb-NO": $d0ae97c9412add8b$exports,
408
- "nl-NL": $7e5335510891b8c3$exports,
409
- "pl-PL": $455cb5ebd5f6c27d$exports,
410
- "pt-BR": $55020c522ee676a2$exports,
411
- "pt-PT": $cc691e0f35e41c7f$exports,
412
- "ro-RO": $712b70af9d7e11e9$exports,
413
- "ru-RU": $c483d9d6d4bcff75$exports,
414
- "sk-SK": $35bc9f18e7cf9157$exports,
415
- "sl-SI": $e933d1373d8e91e0$exports,
416
- "sr-SP": $77463d6521c72512$exports,
417
- "sv-SE": $6380ab044222ca52$exports,
418
- "tr-TR": $9cb854f23a6ff322$exports,
419
- "uk-UA": $912862d79e063c74$exports,
420
- "zh-CN": $91bb887772fd7ad4$exports,
421
- "zh-TW": $a33ce76c4b030d83$exports
422
- };
423
35
 
424
36
 
425
37
 
426
38
 
427
39
 
428
- function $1eb174acfe8a0f16$export$137e594ef3218a10(props, state) {
429
- let { getRowText: getRowText = (key)=>{
430
- var _state_collection_getTextValue, _state_collection, _state_collection_getItem;
431
- var _state_collection_getTextValue1;
432
- return (_state_collection_getTextValue1 = (_state_collection_getTextValue = (_state_collection = state.collection).getTextValue) === null || _state_collection_getTextValue === void 0 ? void 0 : _state_collection_getTextValue.call(_state_collection, key)) !== null && _state_collection_getTextValue1 !== void 0 ? _state_collection_getTextValue1 : (_state_collection_getItem = state.collection.getItem(key)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.textValue;
433
- } } = props;
434
- let stringFormatter = (0, $2oePb$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($085250522aa37816$exports))), "@react-aria/grid");
435
- // Many screen readers do not announce when items in a grid are selected/deselected.
436
- // We do this using an ARIA live region.
437
- let selection = state.selectionManager.rawSelection;
438
- let lastSelection = (0, $2oePb$react.useRef)(selection);
439
- (0, $2oePb$reactariautils.useUpdateEffect)(()=>{
440
- var _lastSelection_current;
441
- if (!state.selectionManager.isFocused) {
442
- lastSelection.current = selection;
443
- return;
444
- }
445
- let addedKeys = $1eb174acfe8a0f16$var$diffSelection(selection, lastSelection.current);
446
- let removedKeys = $1eb174acfe8a0f16$var$diffSelection(lastSelection.current, selection);
447
- // If adding or removing a single row from the selection, announce the name of that item.
448
- let isReplace = state.selectionManager.selectionBehavior === "replace";
449
- let messages = [];
450
- if (state.selectionManager.selectedKeys.size === 1 && isReplace) {
451
- if (state.collection.getItem(state.selectionManager.selectedKeys.keys().next().value)) {
452
- let currentSelectionText = getRowText(state.selectionManager.selectedKeys.keys().next().value);
453
- if (currentSelectionText) messages.push(stringFormatter.format("selectedItem", {
454
- item: currentSelectionText
455
- }));
456
- }
457
- } else if (addedKeys.size === 1 && removedKeys.size === 0) {
458
- let addedText = getRowText(addedKeys.keys().next().value);
459
- if (addedText) messages.push(stringFormatter.format("selectedItem", {
460
- item: addedText
461
- }));
462
- } else if (removedKeys.size === 1 && addedKeys.size === 0) {
463
- if (state.collection.getItem(removedKeys.keys().next().value)) {
464
- let removedText = getRowText(removedKeys.keys().next().value);
465
- if (removedText) messages.push(stringFormatter.format("deselectedItem", {
466
- item: removedText
467
- }));
468
- }
469
- }
470
- // Announce how many items are selected, except when selecting the first item.
471
- if (state.selectionManager.selectionMode === "multiple") {
472
- if (messages.length === 0 || selection === "all" || selection.size > 1 || lastSelection.current === "all" || ((_lastSelection_current = lastSelection.current) === null || _lastSelection_current === void 0 ? void 0 : _lastSelection_current.size) > 1) messages.push(selection === "all" ? stringFormatter.format("selectedAll") : stringFormatter.format("selectedCount", {
473
- count: selection.size
474
- }));
475
- }
476
- if (messages.length > 0) (0, $2oePb$reactarialiveannouncer.announce)(messages.join(" "));
477
- lastSelection.current = selection;
478
- }, [
479
- selection
480
- ]);
481
- }
482
- function $1eb174acfe8a0f16$var$diffSelection(a, b) {
483
- let res = new Set();
484
- if (a === "all" || b === "all") return res;
485
- for (let key of a.keys())if (!b.has(key)) res.add(key);
486
- return res;
487
- }
488
-
489
-
490
-
491
- /*
492
- * Copyright 2021 Adobe. All rights reserved.
493
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
494
- * you may not use this file except in compliance with the License. You may obtain a copy
495
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
496
- *
497
- * Unless required by applicable law or agreed to in writing, software distributed under
498
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
499
- * OF ANY KIND, either express or implied. See the License for the specific language
500
- * governing permissions and limitations under the License.
501
- */
502
-
503
-
504
-
505
-
506
- function $340f2fcd0ef9ce8d$export$be42ebdab07ae4c2(props) {
507
- let stringFormatter = (0, $2oePb$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($085250522aa37816$exports))), "@react-aria/grid");
508
- let modality = (0, $2oePb$reactariainteractions.useInteractionModality)();
509
- // null is the default if the user hasn't interacted with the table at all yet or the rest of the page
510
- let shouldLongPress = (modality === "pointer" || modality === "virtual" || modality == null) && typeof window !== "undefined" && "ontouchstart" in window;
511
- let interactionDescription = (0, $2oePb$react.useMemo)(()=>{
512
- let selectionMode = props.selectionManager.selectionMode;
513
- let selectionBehavior = props.selectionManager.selectionBehavior;
514
- let message = undefined;
515
- if (shouldLongPress) message = stringFormatter.format("longPressToSelect");
516
- return selectionBehavior === "replace" && selectionMode !== "none" && props.hasItemActions ? message : undefined;
517
- }, [
518
- props.selectionManager.selectionMode,
519
- props.selectionManager.selectionBehavior,
520
- props.hasItemActions,
521
- stringFormatter,
522
- shouldLongPress
523
- ]);
524
- let descriptionProps = (0, $2oePb$reactariautils.useDescription)(interactionDescription);
525
- return descriptionProps;
526
- }
527
-
528
-
529
-
530
- function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref) {
531
- let { isVirtualized: isVirtualized, keyboardDelegate: keyboardDelegate, focusMode: focusMode, scrollRef: scrollRef, getRowText: getRowText, onRowAction: onRowAction, onCellAction: onCellAction } = props;
532
- let { selectionManager: manager } = state;
533
- if (!props["aria-label"] && !props["aria-labelledby"]) console.warn("An aria-label or aria-labelledby prop is required for accessibility.");
534
- // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
535
- // When virtualized, the layout object will be passed in as a prop and override this.
536
- let collator = (0, $2oePb$reactariai18n.useCollator)({
537
- usage: "search",
538
- sensitivity: "base"
539
- });
540
- let { direction: direction } = (0, $2oePb$reactariai18n.useLocale)();
541
- let disabledBehavior = state.selectionManager.disabledBehavior;
542
- let delegate = (0, $2oePb$react.useMemo)(()=>keyboardDelegate || new (0, $3187c0e19200cb16$export$de9feff04fda126e)({
543
- collection: state.collection,
544
- disabledKeys: state.disabledKeys,
545
- disabledBehavior: disabledBehavior,
546
- ref: ref,
547
- direction: direction,
548
- collator: collator,
549
- focusMode: focusMode
550
- }), [
551
- keyboardDelegate,
552
- state.collection,
553
- state.disabledKeys,
554
- disabledBehavior,
555
- ref,
556
- direction,
557
- collator,
558
- focusMode
559
- ]);
560
- let { collectionProps: collectionProps } = (0, $2oePb$reactariaselection.useSelectableCollection)({
561
- ref: ref,
562
- selectionManager: manager,
563
- keyboardDelegate: delegate,
564
- isVirtualized: isVirtualized,
565
- scrollRef: scrollRef
566
- });
567
- let id = (0, $2oePb$reactariautils.useId)(props.id);
568
- (0, $8ee34951196858d0$export$e6235c0d09b995d0).set(state, {
569
- keyboardDelegate: delegate,
570
- actions: {
571
- onRowAction: onRowAction,
572
- onCellAction: onCellAction
573
- }
574
- });
575
- let descriptionProps = (0, $340f2fcd0ef9ce8d$export$be42ebdab07ae4c2)({
576
- selectionManager: manager,
577
- hasItemActions: !!(onRowAction || onCellAction)
578
- });
579
- let domProps = (0, $2oePb$reactariautils.filterDOMProps)(props, {
580
- labelable: true
581
- });
582
- let onFocus = (0, $2oePb$react.useCallback)((e)=>{
583
- if (manager.isFocused) {
584
- // If a focus event bubbled through a portal, reset focus state.
585
- if (!e.currentTarget.contains(e.target)) manager.setFocused(false);
586
- return;
587
- }
588
- // Focus events can bubble through portals. Ignore these events.
589
- if (!e.currentTarget.contains(e.target)) return;
590
- manager.setFocused(true);
591
- }, [
592
- manager
593
- ]);
594
- // Continue to track collection focused state even if keyboard navigation is disabled
595
- let navDisabledHandlers = (0, $2oePb$react.useMemo)(()=>({
596
- onBlur: collectionProps.onBlur,
597
- onFocus: onFocus
598
- }), [
599
- onFocus,
600
- collectionProps.onBlur
601
- ]);
602
- let hasTabbableChild = (0, $2oePb$reactariafocus.useHasTabbableChild)(ref, {
603
- isDisabled: state.collection.size !== 0
604
- });
605
- let gridProps = (0, $2oePb$reactariautils.mergeProps)(domProps, {
606
- role: "grid",
607
- id: id,
608
- "aria-multiselectable": manager.selectionMode === "multiple" ? "true" : undefined
609
- }, state.isKeyboardNavigationDisabled ? navDisabledHandlers : collectionProps, // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.
610
- state.collection.size === 0 && {
611
- tabIndex: hasTabbableChild ? -1 : 0
612
- }, descriptionProps);
613
- if (isVirtualized) {
614
- gridProps["aria-rowcount"] = state.collection.size;
615
- gridProps["aria-colcount"] = state.collection.columnCount;
616
- }
617
- (0, $1eb174acfe8a0f16$export$137e594ef3218a10)({
618
- getRowText: getRowText
619
- }, state);
620
- return {
621
- gridProps: gridProps
622
- };
623
- }
624
-
625
-
626
- /*
627
- * Copyright 2020 Adobe. All rights reserved.
628
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
629
- * you may not use this file except in compliance with the License. You may obtain a copy
630
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
631
- *
632
- * Unless required by applicable law or agreed to in writing, software distributed under
633
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
634
- * OF ANY KIND, either express or implied. See the License for the specific language
635
- * governing permissions and limitations under the License.
636
- */ function $c7def85a57100898$export$d3037f5d3f3e51bf() {
637
- return {
638
- rowGroupProps: {
639
- role: "rowgroup"
640
- }
641
- };
642
- }
643
-
644
-
645
- /*
646
- * Copyright 2020 Adobe. All rights reserved.
647
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
648
- * you may not use this file except in compliance with the License. You may obtain a copy
649
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
650
- *
651
- * Unless required by applicable law or agreed to in writing, software distributed under
652
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
653
- * OF ANY KIND, either express or implied. See the License for the specific language
654
- * governing permissions and limitations under the License.
655
- */
656
-
657
-
658
- function $eed398987c639831$export$96357d5a73f686fa(props, state, ref) {
659
- var _node_props, _node_props1;
660
- let { node: node, isVirtualized: isVirtualized, shouldSelectOnPressUp: shouldSelectOnPressUp, onAction: onAction } = props;
661
- let { actions: actions } = (0, $8ee34951196858d0$export$e6235c0d09b995d0).get(state);
662
- let onRowAction = actions.onRowAction ? ()=>actions.onRowAction(node.key) : onAction;
663
- let { itemProps: itemProps, ...states } = (0, $2oePb$reactariaselection.useSelectableItem)({
664
- selectionManager: state.selectionManager,
665
- key: node.key,
666
- ref: ref,
667
- isVirtualized: isVirtualized,
668
- shouldSelectOnPressUp: shouldSelectOnPressUp,
669
- onAction: onRowAction || (node === null || node === void 0 ? void 0 : (_node_props = node.props) === null || _node_props === void 0 ? void 0 : _node_props.onAction) ? (0, $2oePb$reactariautils.chain)(node === null || node === void 0 ? void 0 : (_node_props1 = node.props) === null || _node_props1 === void 0 ? void 0 : _node_props1.onAction, onRowAction) : undefined,
670
- isDisabled: state.collection.size === 0
671
- });
672
- let isSelected = state.selectionManager.isSelected(node.key);
673
- let rowProps = {
674
- role: "row",
675
- "aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined,
676
- "aria-disabled": states.isDisabled || undefined,
677
- ...itemProps
678
- };
679
- if (isVirtualized) rowProps["aria-rowindex"] = node.index + 1; // aria-rowindex is 1 based
680
- return {
681
- rowProps: rowProps,
682
- ...states
683
- };
684
- }
685
-
686
-
687
- /*
688
- * Copyright 2020 Adobe. All rights reserved.
689
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
690
- * you may not use this file except in compliance with the License. You may obtain a copy
691
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
692
- *
693
- * Unless required by applicable law or agreed to in writing, software distributed under
694
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
695
- * OF ANY KIND, either express or implied. See the License for the specific language
696
- * governing permissions and limitations under the License.
697
- */
698
-
699
-
700
-
701
-
702
-
703
-
704
- function $cf2021be63b01ef4$export$c7e10bfc0c59f67c(props, state, ref) {
705
- let { node: node, isVirtualized: isVirtualized, focusMode: focusMode = "child", shouldSelectOnPressUp: shouldSelectOnPressUp, onAction: onAction } = props;
706
- let { direction: direction } = (0, $2oePb$reactariai18n.useLocale)();
707
- let { keyboardDelegate: keyboardDelegate, actions: { onCellAction: onCellAction } } = (0, $8ee34951196858d0$export$e6235c0d09b995d0).get(state);
708
- // We need to track the key of the item at the time it was last focused so that we force
709
- // focus to go to the item when the DOM node is reused for a different item in a virtualizer.
710
- let keyWhenFocused = (0, $2oePb$react.useRef)(null);
711
- // Handles focusing the cell. If there is a focusable child,
712
- // it is focused, otherwise the cell itself is focused.
713
- let focus = ()=>{
714
- let treeWalker = (0, $2oePb$reactariafocus.getFocusableTreeWalker)(ref.current);
715
- if (focusMode === "child") {
716
- // If focus is already on a focusable child within the cell, early return so we don't shift focus
717
- if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) return;
718
- let focusable = state.selectionManager.childFocusStrategy === "last" ? $cf2021be63b01ef4$var$last(treeWalker) : treeWalker.firstChild();
719
- if (focusable) {
720
- (0, $2oePb$reactariafocus.focusSafely)(focusable);
721
- return;
722
- }
723
- }
724
- if (keyWhenFocused.current != null && node.key !== keyWhenFocused.current || !ref.current.contains(document.activeElement)) (0, $2oePb$reactariafocus.focusSafely)(ref.current);
725
- };
726
- let { itemProps: itemProps, isPressed: isPressed } = (0, $2oePb$reactariaselection.useSelectableItem)({
727
- selectionManager: state.selectionManager,
728
- key: node.key,
729
- ref: ref,
730
- isVirtualized: isVirtualized,
731
- focus: focus,
732
- shouldSelectOnPressUp: shouldSelectOnPressUp,
733
- onAction: onCellAction ? ()=>onCellAction(node.key) : onAction,
734
- isDisabled: state.collection.size === 0
735
- });
736
- let onKeyDownCapture = (e)=>{
737
- if (!e.currentTarget.contains(e.target) || state.isKeyboardNavigationDisabled) return;
738
- let walker = (0, $2oePb$reactariafocus.getFocusableTreeWalker)(ref.current);
739
- walker.currentNode = document.activeElement;
740
- switch(e.key){
741
- case "ArrowLeft":
742
- {
743
- // Find the next focusable element within the cell.
744
- let focusable = direction === "rtl" ? walker.nextNode() : walker.previousNode();
745
- // Don't focus the cell itself if focusMode is "child"
746
- if (focusMode === "child" && focusable === ref.current) focusable = null;
747
- e.preventDefault();
748
- e.stopPropagation();
749
- if (focusable) {
750
- (0, $2oePb$reactariafocus.focusSafely)(focusable);
751
- (0, $2oePb$reactariautils.scrollIntoViewport)(focusable, {
752
- containingElement: (0, $2oePb$reactariautils.getScrollParent)(ref.current)
753
- });
754
- } else {
755
- // If there is no next focusable child, then move to the next cell to the left of this one.
756
- // This will be handled by useSelectableCollection. However, if there is no cell to the left
757
- // of this one, only one column, and the grid doesn't focus rows, then the next key will be the
758
- // same as this one. In that case we need to handle focusing either the cell or the first/last
759
- // child, depending on the focus mode.
760
- let prev = keyboardDelegate.getKeyLeftOf(node.key);
761
- if (prev !== node.key) {
762
- // We prevent the capturing event from reaching children of the cell, e.g. pickers.
763
- // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
764
- // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
765
- ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
766
- break;
767
- }
768
- if (focusMode === "cell" && direction === "rtl") {
769
- (0, $2oePb$reactariafocus.focusSafely)(ref.current);
770
- (0, $2oePb$reactariautils.scrollIntoViewport)(ref.current, {
771
- containingElement: (0, $2oePb$reactariautils.getScrollParent)(ref.current)
772
- });
773
- } else {
774
- walker.currentNode = ref.current;
775
- focusable = direction === "rtl" ? walker.firstChild() : $cf2021be63b01ef4$var$last(walker);
776
- if (focusable) {
777
- (0, $2oePb$reactariafocus.focusSafely)(focusable);
778
- (0, $2oePb$reactariautils.scrollIntoViewport)(focusable, {
779
- containingElement: (0, $2oePb$reactariautils.getScrollParent)(ref.current)
780
- });
781
- }
782
- }
783
- }
784
- break;
785
- }
786
- case "ArrowRight":
787
- {
788
- let focusable = direction === "rtl" ? walker.previousNode() : walker.nextNode();
789
- if (focusMode === "child" && focusable === ref.current) focusable = null;
790
- e.preventDefault();
791
- e.stopPropagation();
792
- if (focusable) {
793
- (0, $2oePb$reactariafocus.focusSafely)(focusable);
794
- (0, $2oePb$reactariautils.scrollIntoViewport)(focusable, {
795
- containingElement: (0, $2oePb$reactariautils.getScrollParent)(ref.current)
796
- });
797
- } else {
798
- let next = keyboardDelegate.getKeyRightOf(node.key);
799
- if (next !== node.key) {
800
- // We prevent the capturing event from reaching children of the cell, e.g. pickers.
801
- // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
802
- // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
803
- ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
804
- break;
805
- }
806
- if (focusMode === "cell" && direction === "ltr") {
807
- (0, $2oePb$reactariafocus.focusSafely)(ref.current);
808
- (0, $2oePb$reactariautils.scrollIntoViewport)(ref.current, {
809
- containingElement: (0, $2oePb$reactariautils.getScrollParent)(ref.current)
810
- });
811
- } else {
812
- walker.currentNode = ref.current;
813
- focusable = direction === "rtl" ? $cf2021be63b01ef4$var$last(walker) : walker.firstChild();
814
- if (focusable) {
815
- (0, $2oePb$reactariafocus.focusSafely)(focusable);
816
- (0, $2oePb$reactariautils.scrollIntoViewport)(focusable, {
817
- containingElement: (0, $2oePb$reactariautils.getScrollParent)(ref.current)
818
- });
819
- }
820
- }
821
- }
822
- break;
823
- }
824
- case "ArrowUp":
825
- case "ArrowDown":
826
- // Prevent this event from reaching cell children, e.g. menu buttons. We want arrow keys to navigate
827
- // to the cell above/below instead. We need to re-dispatch the event from a higher parent so it still
828
- // bubbles and gets handled by useSelectableCollection.
829
- if (!e.altKey && ref.current.contains(e.target)) {
830
- e.stopPropagation();
831
- e.preventDefault();
832
- ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
833
- }
834
- break;
835
- }
836
- };
837
- // Grid cells can have focusable elements inside them. In this case, focus should
838
- // be marshalled to that element rather than focusing the cell itself.
839
- let onFocus = (e)=>{
840
- keyWhenFocused.current = node.key;
841
- if (e.target !== ref.current) {
842
- // useSelectableItem only handles setting the focused key when
843
- // the focused element is the gridcell itself. We also want to
844
- // set the focused key when a child element receives focus.
845
- // If focus is currently visible (e.g. the user is navigating with the keyboard),
846
- // then skip this. We want to restore focus to the previously focused row/cell
847
- // in that case since the table should act like a single tab stop.
848
- if (!(0, $2oePb$reactariainteractions.isFocusVisible)()) state.selectionManager.setFocusedKey(node.key);
849
- return;
850
- }
851
- // If the cell itself is focused, wait a frame so that focus finishes propagatating
852
- // up to the tree, and move focus to a focusable child if possible.
853
- requestAnimationFrame(()=>{
854
- if (focusMode === "child" && document.activeElement === ref.current) focus();
855
- });
856
- };
857
- let gridCellProps = (0, $2oePb$reactariautils.mergeProps)(itemProps, {
858
- role: "gridcell",
859
- onKeyDownCapture: onKeyDownCapture,
860
- onFocus: onFocus
861
- });
862
- var _node_colIndex;
863
- if (isVirtualized) gridCellProps["aria-colindex"] = ((_node_colIndex = node.colIndex) !== null && _node_colIndex !== void 0 ? _node_colIndex : node.index) + 1; // aria-colindex is 1-based
864
- // When pressing with a pointer and cell selection is not enabled, usePress will be applied to the
865
- // row rather than the cell. However, when the row is draggable, usePress cannot preventDefault
866
- // on pointer down, so the browser will try to focus the cell which has a tabIndex applied.
867
- // To avoid this, remove the tabIndex from the cell briefly on pointer down.
868
- if (shouldSelectOnPressUp && gridCellProps.tabIndex != null && gridCellProps.onPointerDown == null) gridCellProps.onPointerDown = (e)=>{
869
- let el = e.currentTarget;
870
- let tabindex = el.getAttribute("tabindex");
871
- el.removeAttribute("tabindex");
872
- requestAnimationFrame(()=>{
873
- el.setAttribute("tabindex", tabindex);
874
- });
875
- };
876
- return {
877
- gridCellProps: gridCellProps,
878
- isPressed: isPressed
879
- };
880
- }
881
- function $cf2021be63b01ef4$var$last(walker) {
882
- let next;
883
- let last;
884
- do {
885
- last = walker.lastChild();
886
- if (last) next = last;
887
- }while (last);
888
- return next;
889
- }
890
-
891
-
892
-
893
-
894
-
895
- function $d8385f73d3701365$export$70e2eed1a92976ad(props, state) {
896
- let { key: key } = props;
897
- let manager = state.selectionManager;
898
- let checkboxId = (0, $2oePb$reactariautils.useId)();
899
- let isDisabled = !state.selectionManager.canSelectItem(key);
900
- let isSelected = state.selectionManager.isSelected(key);
901
- let onChange = ()=>manager.select(key);
902
- const stringFormatter = (0, $2oePb$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($085250522aa37816$exports))), "@react-aria/grid");
903
- return {
904
- checkboxProps: {
905
- id: checkboxId,
906
- "aria-label": stringFormatter.format("select"),
907
- isSelected: isSelected,
908
- isDisabled: isDisabled,
909
- onChange: onChange
910
- }
911
- };
912
- }
913
-
914
-
915
-
916
40
 
917
41
 
918
42