@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.
- package/dist/GridKeyboardDelegate.main.js +252 -0
- package/dist/GridKeyboardDelegate.main.js.map +1 -0
- package/dist/GridKeyboardDelegate.mjs +247 -0
- package/dist/GridKeyboardDelegate.module.js +247 -0
- package/dist/GridKeyboardDelegate.module.js.map +1 -0
- package/dist/ar-AE.mjs +1 -1
- package/dist/bg-BG.mjs +1 -1
- package/dist/cs-CZ.mjs +1 -1
- package/dist/da-DK.mjs +1 -1
- package/dist/de-DE.mjs +1 -1
- package/dist/el-GR.mjs +1 -1
- package/dist/en-US.mjs +1 -1
- package/dist/es-ES.mjs +1 -1
- package/dist/et-EE.mjs +1 -1
- package/dist/fi-FI.mjs +1 -1
- package/dist/fr-FR.mjs +1 -1
- package/dist/he-IL.mjs +1 -1
- package/dist/hr-HR.mjs +1 -1
- package/dist/hu-HU.mjs +1 -1
- package/dist/import.mjs +8 -884
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.mjs +1 -1
- package/dist/ja-JP.mjs +1 -1
- package/dist/ko-KR.mjs +1 -1
- package/dist/lt-LT.mjs +1 -1
- package/dist/lv-LV.mjs +1 -1
- package/dist/main.js +16 -892
- package/dist/main.js.map +1 -1
- package/dist/module.js +8 -884
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.mjs +1 -1
- package/dist/nl-NL.mjs +1 -1
- package/dist/pl-PL.mjs +1 -1
- package/dist/pt-BR.mjs +1 -1
- package/dist/pt-PT.mjs +1 -1
- package/dist/ro-RO.mjs +1 -1
- package/dist/ru-RU.mjs +1 -1
- package/dist/sk-SK.mjs +1 -1
- package/dist/sl-SI.mjs +1 -1
- package/dist/sr-SP.mjs +1 -1
- package/dist/sv-SE.mjs +1 -1
- package/dist/tr-TR.mjs +1 -1
- package/dist/uk-UA.mjs +1 -1
- package/dist/useGrid.main.js +132 -0
- package/dist/useGrid.main.js.map +1 -0
- package/dist/useGrid.mjs +127 -0
- package/dist/useGrid.module.js +127 -0
- package/dist/useGrid.module.js.map +1 -0
- package/dist/useGridCell.main.js +220 -0
- package/dist/useGridCell.main.js.map +1 -0
- package/dist/useGridCell.mjs +215 -0
- package/dist/useGridCell.module.js +215 -0
- package/dist/useGridCell.module.js.map +1 -0
- package/dist/useGridRow.main.js +53 -0
- package/dist/useGridRow.main.js.map +1 -0
- package/dist/useGridRow.mjs +48 -0
- package/dist/useGridRow.module.js +48 -0
- package/dist/useGridRow.module.js.map +1 -0
- package/dist/useGridRowGroup.main.js +26 -0
- package/dist/useGridRowGroup.main.js.map +1 -0
- package/dist/useGridRowGroup.mjs +21 -0
- package/dist/useGridRowGroup.module.js +21 -0
- package/dist/useGridRowGroup.module.js.map +1 -0
- package/dist/useGridSelectionAnnouncement.main.js +94 -0
- package/dist/useGridSelectionAnnouncement.main.js.map +1 -0
- package/dist/useGridSelectionAnnouncement.mjs +89 -0
- package/dist/useGridSelectionAnnouncement.module.js +89 -0
- package/dist/useGridSelectionAnnouncement.module.js.map +1 -0
- package/dist/useGridSelectionCheckbox.main.js +38 -0
- package/dist/useGridSelectionCheckbox.main.js.map +1 -0
- package/dist/useGridSelectionCheckbox.mjs +33 -0
- package/dist/useGridSelectionCheckbox.module.js +33 -0
- package/dist/useGridSelectionCheckbox.module.js.map +1 -0
- package/dist/useHighlightSelectionDescription.main.js +55 -0
- package/dist/useHighlightSelectionDescription.main.js.map +1 -0
- package/dist/useHighlightSelectionDescription.mjs +50 -0
- package/dist/useHighlightSelectionDescription.module.js +50 -0
- package/dist/useHighlightSelectionDescription.module.js.map +1 -0
- package/dist/utils.main.js +20 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +15 -0
- package/dist/utils.module.js +15 -0
- package/dist/utils.module.js.map +1 -0
- package/dist/zh-CN.mjs +1 -1
- package/dist/zh-TW.mjs +1 -1
- package/package.json +15 -15
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {gridMap as $1af922eb41e03c8f$export$e6235c0d09b995d0} from "./utils.module.js";
|
|
2
|
+
import {getFocusableTreeWalker as $j4Qbl$getFocusableTreeWalker, focusSafely as $j4Qbl$focusSafely} from "@react-aria/focus";
|
|
3
|
+
import {scrollIntoViewport as $j4Qbl$scrollIntoViewport, getScrollParent as $j4Qbl$getScrollParent, mergeProps as $j4Qbl$mergeProps} from "@react-aria/utils";
|
|
4
|
+
import {isFocusVisible as $j4Qbl$isFocusVisible} from "@react-aria/interactions";
|
|
5
|
+
import {useRef as $j4Qbl$useRef} from "react";
|
|
6
|
+
import {useLocale as $j4Qbl$useLocale} from "@react-aria/i18n";
|
|
7
|
+
import {useSelectableItem as $j4Qbl$useSelectableItem} from "@react-aria/selection";
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
11
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
* governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function $ab90dcbc1b5466d0$export$c7e10bfc0c59f67c(props, state, ref) {
|
|
27
|
+
let { node: node, isVirtualized: isVirtualized, focusMode: focusMode = "child", shouldSelectOnPressUp: shouldSelectOnPressUp, onAction: onAction } = props;
|
|
28
|
+
let { direction: direction } = (0, $j4Qbl$useLocale)();
|
|
29
|
+
let { keyboardDelegate: keyboardDelegate, actions: { onCellAction: onCellAction } } = (0, $1af922eb41e03c8f$export$e6235c0d09b995d0).get(state);
|
|
30
|
+
// We need to track the key of the item at the time it was last focused so that we force
|
|
31
|
+
// focus to go to the item when the DOM node is reused for a different item in a virtualizer.
|
|
32
|
+
let keyWhenFocused = (0, $j4Qbl$useRef)(null);
|
|
33
|
+
// Handles focusing the cell. If there is a focusable child,
|
|
34
|
+
// it is focused, otherwise the cell itself is focused.
|
|
35
|
+
let focus = ()=>{
|
|
36
|
+
let treeWalker = (0, $j4Qbl$getFocusableTreeWalker)(ref.current);
|
|
37
|
+
if (focusMode === "child") {
|
|
38
|
+
// If focus is already on a focusable child within the cell, early return so we don't shift focus
|
|
39
|
+
if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) return;
|
|
40
|
+
let focusable = state.selectionManager.childFocusStrategy === "last" ? $ab90dcbc1b5466d0$var$last(treeWalker) : treeWalker.firstChild();
|
|
41
|
+
if (focusable) {
|
|
42
|
+
(0, $j4Qbl$focusSafely)(focusable);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (keyWhenFocused.current != null && node.key !== keyWhenFocused.current || !ref.current.contains(document.activeElement)) (0, $j4Qbl$focusSafely)(ref.current);
|
|
47
|
+
};
|
|
48
|
+
let { itemProps: itemProps, isPressed: isPressed } = (0, $j4Qbl$useSelectableItem)({
|
|
49
|
+
selectionManager: state.selectionManager,
|
|
50
|
+
key: node.key,
|
|
51
|
+
ref: ref,
|
|
52
|
+
isVirtualized: isVirtualized,
|
|
53
|
+
focus: focus,
|
|
54
|
+
shouldSelectOnPressUp: shouldSelectOnPressUp,
|
|
55
|
+
onAction: onCellAction ? ()=>onCellAction(node.key) : onAction,
|
|
56
|
+
isDisabled: state.collection.size === 0
|
|
57
|
+
});
|
|
58
|
+
let onKeyDownCapture = (e)=>{
|
|
59
|
+
if (!e.currentTarget.contains(e.target) || state.isKeyboardNavigationDisabled) return;
|
|
60
|
+
let walker = (0, $j4Qbl$getFocusableTreeWalker)(ref.current);
|
|
61
|
+
walker.currentNode = document.activeElement;
|
|
62
|
+
switch(e.key){
|
|
63
|
+
case "ArrowLeft":
|
|
64
|
+
{
|
|
65
|
+
// Find the next focusable element within the cell.
|
|
66
|
+
let focusable = direction === "rtl" ? walker.nextNode() : walker.previousNode();
|
|
67
|
+
// Don't focus the cell itself if focusMode is "child"
|
|
68
|
+
if (focusMode === "child" && focusable === ref.current) focusable = null;
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
if (focusable) {
|
|
72
|
+
(0, $j4Qbl$focusSafely)(focusable);
|
|
73
|
+
(0, $j4Qbl$scrollIntoViewport)(focusable, {
|
|
74
|
+
containingElement: (0, $j4Qbl$getScrollParent)(ref.current)
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
// If there is no next focusable child, then move to the next cell to the left of this one.
|
|
78
|
+
// This will be handled by useSelectableCollection. However, if there is no cell to the left
|
|
79
|
+
// of this one, only one column, and the grid doesn't focus rows, then the next key will be the
|
|
80
|
+
// same as this one. In that case we need to handle focusing either the cell or the first/last
|
|
81
|
+
// child, depending on the focus mode.
|
|
82
|
+
let prev = keyboardDelegate.getKeyLeftOf(node.key);
|
|
83
|
+
if (prev !== node.key) {
|
|
84
|
+
// We prevent the capturing event from reaching children of the cell, e.g. pickers.
|
|
85
|
+
// We want arrow keys to navigate to the next cell instead. We need to re-dispatch
|
|
86
|
+
// the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
|
|
87
|
+
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (focusMode === "cell" && direction === "rtl") {
|
|
91
|
+
(0, $j4Qbl$focusSafely)(ref.current);
|
|
92
|
+
(0, $j4Qbl$scrollIntoViewport)(ref.current, {
|
|
93
|
+
containingElement: (0, $j4Qbl$getScrollParent)(ref.current)
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
walker.currentNode = ref.current;
|
|
97
|
+
focusable = direction === "rtl" ? walker.firstChild() : $ab90dcbc1b5466d0$var$last(walker);
|
|
98
|
+
if (focusable) {
|
|
99
|
+
(0, $j4Qbl$focusSafely)(focusable);
|
|
100
|
+
(0, $j4Qbl$scrollIntoViewport)(focusable, {
|
|
101
|
+
containingElement: (0, $j4Qbl$getScrollParent)(ref.current)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case "ArrowRight":
|
|
109
|
+
{
|
|
110
|
+
let focusable = direction === "rtl" ? walker.previousNode() : walker.nextNode();
|
|
111
|
+
if (focusMode === "child" && focusable === ref.current) focusable = null;
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
e.stopPropagation();
|
|
114
|
+
if (focusable) {
|
|
115
|
+
(0, $j4Qbl$focusSafely)(focusable);
|
|
116
|
+
(0, $j4Qbl$scrollIntoViewport)(focusable, {
|
|
117
|
+
containingElement: (0, $j4Qbl$getScrollParent)(ref.current)
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
let next = keyboardDelegate.getKeyRightOf(node.key);
|
|
121
|
+
if (next !== node.key) {
|
|
122
|
+
// We prevent the capturing event from reaching children of the cell, e.g. pickers.
|
|
123
|
+
// We want arrow keys to navigate to the next cell instead. We need to re-dispatch
|
|
124
|
+
// the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
|
|
125
|
+
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
if (focusMode === "cell" && direction === "ltr") {
|
|
129
|
+
(0, $j4Qbl$focusSafely)(ref.current);
|
|
130
|
+
(0, $j4Qbl$scrollIntoViewport)(ref.current, {
|
|
131
|
+
containingElement: (0, $j4Qbl$getScrollParent)(ref.current)
|
|
132
|
+
});
|
|
133
|
+
} else {
|
|
134
|
+
walker.currentNode = ref.current;
|
|
135
|
+
focusable = direction === "rtl" ? $ab90dcbc1b5466d0$var$last(walker) : walker.firstChild();
|
|
136
|
+
if (focusable) {
|
|
137
|
+
(0, $j4Qbl$focusSafely)(focusable);
|
|
138
|
+
(0, $j4Qbl$scrollIntoViewport)(focusable, {
|
|
139
|
+
containingElement: (0, $j4Qbl$getScrollParent)(ref.current)
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case "ArrowUp":
|
|
147
|
+
case "ArrowDown":
|
|
148
|
+
// Prevent this event from reaching cell children, e.g. menu buttons. We want arrow keys to navigate
|
|
149
|
+
// to the cell above/below instead. We need to re-dispatch the event from a higher parent so it still
|
|
150
|
+
// bubbles and gets handled by useSelectableCollection.
|
|
151
|
+
if (!e.altKey && ref.current.contains(e.target)) {
|
|
152
|
+
e.stopPropagation();
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
// Grid cells can have focusable elements inside them. In this case, focus should
|
|
160
|
+
// be marshalled to that element rather than focusing the cell itself.
|
|
161
|
+
let onFocus = (e)=>{
|
|
162
|
+
keyWhenFocused.current = node.key;
|
|
163
|
+
if (e.target !== ref.current) {
|
|
164
|
+
// useSelectableItem only handles setting the focused key when
|
|
165
|
+
// the focused element is the gridcell itself. We also want to
|
|
166
|
+
// set the focused key when a child element receives focus.
|
|
167
|
+
// If focus is currently visible (e.g. the user is navigating with the keyboard),
|
|
168
|
+
// then skip this. We want to restore focus to the previously focused row/cell
|
|
169
|
+
// in that case since the table should act like a single tab stop.
|
|
170
|
+
if (!(0, $j4Qbl$isFocusVisible)()) state.selectionManager.setFocusedKey(node.key);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// If the cell itself is focused, wait a frame so that focus finishes propagatating
|
|
174
|
+
// up to the tree, and move focus to a focusable child if possible.
|
|
175
|
+
requestAnimationFrame(()=>{
|
|
176
|
+
if (focusMode === "child" && document.activeElement === ref.current) focus();
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
let gridCellProps = (0, $j4Qbl$mergeProps)(itemProps, {
|
|
180
|
+
role: "gridcell",
|
|
181
|
+
onKeyDownCapture: onKeyDownCapture,
|
|
182
|
+
onFocus: onFocus
|
|
183
|
+
});
|
|
184
|
+
var _node_colIndex;
|
|
185
|
+
if (isVirtualized) gridCellProps["aria-colindex"] = ((_node_colIndex = node.colIndex) !== null && _node_colIndex !== void 0 ? _node_colIndex : node.index) + 1; // aria-colindex is 1-based
|
|
186
|
+
// When pressing with a pointer and cell selection is not enabled, usePress will be applied to the
|
|
187
|
+
// row rather than the cell. However, when the row is draggable, usePress cannot preventDefault
|
|
188
|
+
// on pointer down, so the browser will try to focus the cell which has a tabIndex applied.
|
|
189
|
+
// To avoid this, remove the tabIndex from the cell briefly on pointer down.
|
|
190
|
+
if (shouldSelectOnPressUp && gridCellProps.tabIndex != null && gridCellProps.onPointerDown == null) gridCellProps.onPointerDown = (e)=>{
|
|
191
|
+
let el = e.currentTarget;
|
|
192
|
+
let tabindex = el.getAttribute("tabindex");
|
|
193
|
+
el.removeAttribute("tabindex");
|
|
194
|
+
requestAnimationFrame(()=>{
|
|
195
|
+
el.setAttribute("tabindex", tabindex);
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
return {
|
|
199
|
+
gridCellProps: gridCellProps,
|
|
200
|
+
isPressed: isPressed
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function $ab90dcbc1b5466d0$var$last(walker) {
|
|
204
|
+
let next;
|
|
205
|
+
let last;
|
|
206
|
+
do {
|
|
207
|
+
last = walker.lastChild();
|
|
208
|
+
if (last) next = last;
|
|
209
|
+
}while (last);
|
|
210
|
+
return next;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
export {$ab90dcbc1b5466d0$export$c7e10bfc0c59f67c as useGridCell};
|
|
215
|
+
//# sourceMappingURL=useGridCell.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AA0CM,SAAS,0CAA4C,KAAoB,EAAE,KAAsB,EAAE,GAAgC;IACxI,IAAI,QACF,IAAI,iBACJ,aAAa,aACb,YAAY,gCACZ,qBAAqB,YACrB,QAAQ,EACT,GAAG;IAEJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,oBAAC,gBAAgB,EAAE,SAAS,gBAAC,YAAY,EAAC,EAAC,GAAG,CAAA,GAAA,yCAAM,EAAE,GAAG,CAAC;IAE9D,wFAAwF;IACxF,6FAA6F;IAC7F,IAAI,iBAAiB,CAAA,GAAA,aAAK,EAAE;IAE5B,4DAA4D;IAC5D,uDAAuD;IACvD,IAAI,QAAQ;QACV,IAAI,aAAa,CAAA,GAAA,6BAAqB,EAAE,IAAI,OAAO;QACnD,IAAI,cAAc,SAAS;YACzB,iGAAiG;YACjG,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,KAAK,IAAI,OAAO,KAAK,SAAS,aAAa,EACxF;YAGF,IAAI,YAAY,MAAM,gBAAgB,CAAC,kBAAkB,KAAK,SAC1D,2BAAK,cACL,WAAW,UAAU;YACzB,IAAI,WAAW;gBACb,CAAA,GAAA,kBAAU,EAAE;gBACZ;YACF;QACF;QAEA,IACE,AAAC,eAAe,OAAO,IAAI,QAAQ,KAAK,GAAG,KAAK,eAAe,OAAO,IACtE,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,a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AAA,iBAAA,KAAK,QAAQ,cAAb,4BAAA,iBAAiB,KAAK,KAAK,AAAD,IAAK,GAAG,2BAA2B;IAGjG,kGAAkG;IAClG,+FAA+F;IAC/F,2FAA2F;IAC3F,4EAA4E;IAC5E,IAAI,yBAAyB,cAAc,QAAQ,IAAI,QAAQ,cAAc,aAAa,IAAI,MAC5F,cAAc,aAAa,GAAG,CAAC;QAC7B,IAAI,KAAK,EAAE,aAAa;QACxB,IAAI,WAAW,GAAG,YAAY,CAAC;QAC/B,GAAG,eAAe,CAAC;QACnB,sBAAsB;YACpB,GAAG,YAAY,CAAC,YAAY;QAC9B;IACF;IAGF,OAAO;uBACL;mBACA;IACF;AACF;AAEA,SAAS,2BAAK,MAAkB;IAC9B,IAAI;IACJ,IAAI;IACJ,GAAG;QACD,OAAO,OAAO,SAAS;QACvB,IAAI,MACF,OAAO;IAEX,QAAS,MAAM;IACf,OAAO;AACT","sources":["packages/@react-aria/grid/src/useGridCell.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 {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';\nimport {getScrollParent, mergeProps, scrollIntoViewport} from '@react-aria/utils';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {isFocusVisible} from '@react-aria/interactions';\nimport {KeyboardEvent as ReactKeyboardEvent, RefObject, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSelectableItem} from '@react-aria/selection';\n\nexport interface GridCellProps {\n /** An object representing the grid cell. Contains all the relevant information that makes up the grid cell. */\n node: GridNode<unknown>,\n /** Whether the grid cell is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether the cell or its first focusable child element should be focused when the grid cell is focused. */\n focusMode?: 'child' | 'cell',\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the cell.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface GridCellAria {\n /** Props for the grid cell element. */\n gridCellProps: DOMAttributes,\n /** Whether the cell is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a cell in a grid.\n * @param props - Props for the cell.\n * @param state - State of the parent grid, as returned by `useGridState`.\n */\nexport function useGridCell<T, C extends GridCollection<T>>(props: GridCellProps, state: GridState<T, C>, ref: RefObject<FocusableElement>): GridCellAria {\n let {\n node,\n isVirtualized,\n focusMode = 'child',\n shouldSelectOnPressUp,\n onAction\n } = props;\n\n let {direction} = useLocale();\n let {keyboardDelegate, actions: {onCellAction}} = gridMap.get(state);\n\n // We need to track the key of the item at the time it was last focused so that we force\n // focus to go to the item when the DOM node is reused for a different item in a virtualizer.\n let keyWhenFocused = useRef(null);\n\n // Handles focusing the cell. If there is a focusable child,\n // it is focused, otherwise the cell itself is focused.\n let focus = () => {\n let treeWalker = getFocusableTreeWalker(ref.current);\n if (focusMode === 'child') {\n // If focus is already on a focusable child within the cell, early return so we don't shift focus\n if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) {\n return;\n }\n\n let focusable = state.selectionManager.childFocusStrategy === 'last'\n ? last(treeWalker)\n : treeWalker.firstChild() as FocusableElement;\n if (focusable) {\n focusSafely(focusable);\n return;\n }\n }\n\n if (\n (keyWhenFocused.current != null && node.key !== keyWhenFocused.current) ||\n !ref.current.contains(document.activeElement)\n ) {\n focusSafely(ref.current);\n }\n };\n\n let {itemProps, isPressed} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n focus,\n shouldSelectOnPressUp,\n onAction: onCellAction ? () => onCellAction(node.key) : onAction,\n isDisabled: state.collection.size === 0\n });\n\n let onKeyDownCapture = (e: ReactKeyboardEvent) => {\n if (!e.currentTarget.contains(e.target as Element) || state.isKeyboardNavigationDisabled) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = document.activeElement;\n\n switch (e.key) {\n case 'ArrowLeft': {\n // Find the next focusable element within the cell.\n let focusable = direction === 'rtl'\n ? walker.nextNode() as FocusableElement\n : walker.previousNode() as FocusableElement;\n\n // Don't focus the cell itself if focusMode is \"child\"\n if (focusMode === 'child' && focusable === ref.current) {\n focusable = null;\n }\n\n e.preventDefault();\n e.stopPropagation();\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n // If there is no next focusable child, then move to the next cell to the left of this one.\n // This will be handled by useSelectableCollection. However, if there is no cell to the left\n // of this one, only one column, and the grid doesn't focus rows, then the next key will be the\n // same as this one. In that case we need to handle focusing either the cell or the first/last\n // child, depending on the focus mode.\n let prev = keyboardDelegate.getKeyLeftOf(node.key);\n if (prev !== node.key) {\n // We prevent the capturing event from reaching children of the cell, e.g. pickers.\n // We want arrow keys to navigate to the next cell instead. We need to re-dispatch \n // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n break;\n }\n\n if (focusMode === 'cell' && direction === 'rtl') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n focusable = direction === 'rtl'\n ? walker.firstChild() as FocusableElement\n : last(walker);\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n let focusable = direction === 'rtl'\n ? walker.previousNode() as FocusableElement\n : walker.nextNode() as FocusableElement;\n\n if (focusMode === 'child' && focusable === ref.current) {\n focusable = null;\n }\n\n e.preventDefault();\n e.stopPropagation();\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n let next = keyboardDelegate.getKeyRightOf(node.key);\n if (next !== node.key) {\n // We prevent the capturing event from reaching children of the cell, e.g. pickers.\n // We want arrow keys to navigate to the next cell instead. We need to re-dispatch \n // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n break;\n }\n\n if (focusMode === 'cell' && direction === 'ltr') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n focusable = direction === 'rtl'\n ? last(walker)\n : walker.firstChild() as FocusableElement;\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching cell children, e.g. menu buttons. We want arrow keys to navigate\n // to the cell above/below instead. We need to re-dispatch the event from a higher parent so it still\n // bubbles and gets handled by useSelectableCollection.\n if (!e.altKey && ref.current.contains(e.target as Element)) {\n e.stopPropagation();\n e.preventDefault();\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n }\n break;\n }\n };\n\n // Grid cells can have focusable elements inside them. In this case, focus should\n // be marshalled to that element rather than focusing the cell itself.\n let onFocus = (e) => {\n keyWhenFocused.current = node.key;\n if (e.target !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the gridcell itself. We also want to\n // set the focused key when a child element receives focus.\n // If focus is currently visible (e.g. the user is navigating with the keyboard),\n // then skip this. We want to restore focus to the previously focused row/cell\n // in that case since the table should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n\n // If the cell itself is focused, wait a frame so that focus finishes propagatating\n // up to the tree, and move focus to a focusable child if possible.\n requestAnimationFrame(() => {\n if (focusMode === 'child' && document.activeElement === ref.current) {\n focus();\n }\n });\n };\n\n let gridCellProps: DOMAttributes = mergeProps(itemProps, {\n role: 'gridcell',\n onKeyDownCapture,\n onFocus\n });\n\n if (isVirtualized) {\n gridCellProps['aria-colindex'] = (node.colIndex ?? node.index) + 1; // aria-colindex is 1-based\n }\n\n // When pressing with a pointer and cell selection is not enabled, usePress will be applied to the\n // row rather than the cell. However, when the row is draggable, usePress cannot preventDefault\n // on pointer down, so the browser will try to focus the cell which has a tabIndex applied.\n // To avoid this, remove the tabIndex from the cell briefly on pointer down.\n if (shouldSelectOnPressUp && gridCellProps.tabIndex != null && gridCellProps.onPointerDown == null) {\n gridCellProps.onPointerDown = (e) => {\n let el = e.currentTarget;\n let tabindex = el.getAttribute('tabindex');\n el.removeAttribute('tabindex');\n requestAnimationFrame(() => {\n el.setAttribute('tabindex', tabindex);\n });\n };\n }\n\n return {\n gridCellProps,\n isPressed\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n"],"names":[],"version":3,"file":"useGridCell.module.js.map"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var $8ee34951196858d0$exports = require("./utils.main.js");
|
|
2
|
+
var $apCYc$reactariautils = require("@react-aria/utils");
|
|
3
|
+
var $apCYc$reactariaselection = require("@react-aria/selection");
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$export(e, n, v, s) {
|
|
7
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
$parcel$export(module.exports, "useGridRow", () => $eed398987c639831$export$96357d5a73f686fa);
|
|
11
|
+
/*
|
|
12
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
+
* governing permissions and limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
function $eed398987c639831$export$96357d5a73f686fa(props, state, ref) {
|
|
25
|
+
var _node_props, _node_props1;
|
|
26
|
+
let { node: node, isVirtualized: isVirtualized, shouldSelectOnPressUp: shouldSelectOnPressUp, onAction: onAction } = props;
|
|
27
|
+
let { actions: actions } = (0, $8ee34951196858d0$exports.gridMap).get(state);
|
|
28
|
+
let onRowAction = actions.onRowAction ? ()=>actions.onRowAction(node.key) : onAction;
|
|
29
|
+
let { itemProps: itemProps, ...states } = (0, $apCYc$reactariaselection.useSelectableItem)({
|
|
30
|
+
selectionManager: state.selectionManager,
|
|
31
|
+
key: node.key,
|
|
32
|
+
ref: ref,
|
|
33
|
+
isVirtualized: isVirtualized,
|
|
34
|
+
shouldSelectOnPressUp: shouldSelectOnPressUp,
|
|
35
|
+
onAction: onRowAction || (node === null || node === void 0 ? void 0 : (_node_props = node.props) === null || _node_props === void 0 ? void 0 : _node_props.onAction) ? (0, $apCYc$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,
|
|
36
|
+
isDisabled: state.collection.size === 0
|
|
37
|
+
});
|
|
38
|
+
let isSelected = state.selectionManager.isSelected(node.key);
|
|
39
|
+
let rowProps = {
|
|
40
|
+
role: "row",
|
|
41
|
+
"aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined,
|
|
42
|
+
"aria-disabled": states.isDisabled || undefined,
|
|
43
|
+
...itemProps
|
|
44
|
+
};
|
|
45
|
+
if (isVirtualized) rowProps["aria-rowindex"] = node.index + 1; // aria-rowindex is 1 based
|
|
46
|
+
return {
|
|
47
|
+
rowProps: rowProps,
|
|
48
|
+
...states
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=useGridRow.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAqCM,SAAS,0CAAsE,KAAsB,EAAE,KAAQ,EAAE,GAAgC;QAgB3H,aAA8B;IAfzD,IAAI,QACF,IAAI,iBACJ,aAAa,yBACb,qBAAqB,YACrB,QAAQ,EACT,GAAG;IAEJ,IAAI,WAAC,OAAO,EAAC,GAAG,CAAA,GAAA,iCAAM,EAAE,GAAG,CAAC;IAC5B,IAAI,cAAc,QAAQ,WAAW,GAAG,IAAM,QAAQ,WAAW,CAAC,KAAK,GAAG,IAAI;IAC9E,IAAI,aAAC,SAAS,EAAE,GAAG,QAAO,GAAG,CAAA,GAAA,2CAAgB,EAAE;QAC7C,kBAAkB,MAAM,gBAAgB;QACxC,KAAK,KAAK,GAAG;aACb;uBACA;+BACA;QACA,UAAU,gBAAe,iBAAA,4BAAA,cAAA,KAAM,KAAK,cAAX,kCAAA,YAAa,QAAQ,IAAG,CAAA,GAAA,2BAAI,EAAE,iBAAA,4BAAA,eAAA,KAAM,KAAK,cAAX,mCAAA,aAAa,QAAQ,EAAE,eAAe;QAC7F,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC,KAAK,GAAG;IAE3D,IAAI,WAA0B;QAC5B,MAAM;QACN,iBAAiB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAAS,aAAa;QAChF,iBAAiB,OAAO,UAAU,IAAI;QACtC,GAAG,SAAS;IACd;IAEA,IAAI,eACF,QAAQ,CAAC,gBAAgB,GAAG,KAAK,KAAK,GAAG,GAAG,2BAA2B;IAGzE,OAAO;kBACL;QACA,GAAG,MAAM;IACX;AACF","sources":["packages/@react-aria/grid/src/useGridRow.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 {chain} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {RefObject} from 'react';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface GridRowProps<T> {\n /** An object representing the grid row. Contains all the relevant information that makes up the grid row. */\n node: GridNode<T>,\n /** Whether the grid row is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the row.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface GridRowAria extends SelectableItemStates {\n /** Props for the grid row element. */\n rowProps: DOMAttributes,\n /** Whether the row is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid.\n * @param props - Props for the row.\n * @param state - State of the parent grid, as returned by `useGridState`.\n */\nexport function useGridRow<T, C extends GridCollection<T>, S extends GridState<T, C>>(props: GridRowProps<T>, state: S, ref: RefObject<FocusableElement>): GridRowAria {\n let {\n node,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction\n } = props;\n\n let {actions} = gridMap.get(state);\n let onRowAction = actions.onRowAction ? () => actions.onRowAction(node.key) : onAction;\n let {itemProps, ...states} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction: onRowAction || node?.props?.onAction ? chain(node?.props?.onAction, onRowAction) : undefined,\n isDisabled: state.collection.size === 0\n });\n\n let isSelected = state.selectionManager.isSelected(node.key);\n\n let rowProps: DOMAttributes = {\n role: 'row',\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined,\n 'aria-disabled': states.isDisabled || undefined,\n ...itemProps\n };\n\n if (isVirtualized) {\n rowProps['aria-rowindex'] = node.index + 1; // aria-rowindex is 1 based\n }\n\n return {\n rowProps,\n ...states\n };\n}\n"],"names":[],"version":3,"file":"useGridRow.main.js.map"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {gridMap as $1af922eb41e03c8f$export$e6235c0d09b995d0} from "./utils.mjs";
|
|
2
|
+
import {chain as $kA5if$chain} from "@react-aria/utils";
|
|
3
|
+
import {useSelectableItem as $kA5if$useSelectableItem} from "@react-aria/selection";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function $4159a7a9cbb0cc18$export$96357d5a73f686fa(props, state, ref) {
|
|
19
|
+
var _node_props, _node_props1;
|
|
20
|
+
let { node: node, isVirtualized: isVirtualized, shouldSelectOnPressUp: shouldSelectOnPressUp, onAction: onAction } = props;
|
|
21
|
+
let { actions: actions } = (0, $1af922eb41e03c8f$export$e6235c0d09b995d0).get(state);
|
|
22
|
+
let onRowAction = actions.onRowAction ? ()=>actions.onRowAction(node.key) : onAction;
|
|
23
|
+
let { itemProps: itemProps, ...states } = (0, $kA5if$useSelectableItem)({
|
|
24
|
+
selectionManager: state.selectionManager,
|
|
25
|
+
key: node.key,
|
|
26
|
+
ref: ref,
|
|
27
|
+
isVirtualized: isVirtualized,
|
|
28
|
+
shouldSelectOnPressUp: shouldSelectOnPressUp,
|
|
29
|
+
onAction: onRowAction || (node === null || node === void 0 ? void 0 : (_node_props = node.props) === null || _node_props === void 0 ? void 0 : _node_props.onAction) ? (0, $kA5if$chain)(node === null || node === void 0 ? void 0 : (_node_props1 = node.props) === null || _node_props1 === void 0 ? void 0 : _node_props1.onAction, onRowAction) : undefined,
|
|
30
|
+
isDisabled: state.collection.size === 0
|
|
31
|
+
});
|
|
32
|
+
let isSelected = state.selectionManager.isSelected(node.key);
|
|
33
|
+
let rowProps = {
|
|
34
|
+
role: "row",
|
|
35
|
+
"aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined,
|
|
36
|
+
"aria-disabled": states.isDisabled || undefined,
|
|
37
|
+
...itemProps
|
|
38
|
+
};
|
|
39
|
+
if (isVirtualized) rowProps["aria-rowindex"] = node.index + 1; // aria-rowindex is 1 based
|
|
40
|
+
return {
|
|
41
|
+
rowProps: rowProps,
|
|
42
|
+
...states
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
export {$4159a7a9cbb0cc18$export$96357d5a73f686fa as useGridRow};
|
|
48
|
+
//# sourceMappingURL=useGridRow.mjs.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {gridMap as $1af922eb41e03c8f$export$e6235c0d09b995d0} from "./utils.module.js";
|
|
2
|
+
import {chain as $kA5if$chain} from "@react-aria/utils";
|
|
3
|
+
import {useSelectableItem as $kA5if$useSelectableItem} from "@react-aria/selection";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function $4159a7a9cbb0cc18$export$96357d5a73f686fa(props, state, ref) {
|
|
19
|
+
var _node_props, _node_props1;
|
|
20
|
+
let { node: node, isVirtualized: isVirtualized, shouldSelectOnPressUp: shouldSelectOnPressUp, onAction: onAction } = props;
|
|
21
|
+
let { actions: actions } = (0, $1af922eb41e03c8f$export$e6235c0d09b995d0).get(state);
|
|
22
|
+
let onRowAction = actions.onRowAction ? ()=>actions.onRowAction(node.key) : onAction;
|
|
23
|
+
let { itemProps: itemProps, ...states } = (0, $kA5if$useSelectableItem)({
|
|
24
|
+
selectionManager: state.selectionManager,
|
|
25
|
+
key: node.key,
|
|
26
|
+
ref: ref,
|
|
27
|
+
isVirtualized: isVirtualized,
|
|
28
|
+
shouldSelectOnPressUp: shouldSelectOnPressUp,
|
|
29
|
+
onAction: onRowAction || (node === null || node === void 0 ? void 0 : (_node_props = node.props) === null || _node_props === void 0 ? void 0 : _node_props.onAction) ? (0, $kA5if$chain)(node === null || node === void 0 ? void 0 : (_node_props1 = node.props) === null || _node_props1 === void 0 ? void 0 : _node_props1.onAction, onRowAction) : undefined,
|
|
30
|
+
isDisabled: state.collection.size === 0
|
|
31
|
+
});
|
|
32
|
+
let isSelected = state.selectionManager.isSelected(node.key);
|
|
33
|
+
let rowProps = {
|
|
34
|
+
role: "row",
|
|
35
|
+
"aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined,
|
|
36
|
+
"aria-disabled": states.isDisabled || undefined,
|
|
37
|
+
...itemProps
|
|
38
|
+
};
|
|
39
|
+
if (isVirtualized) rowProps["aria-rowindex"] = node.index + 1; // aria-rowindex is 1 based
|
|
40
|
+
return {
|
|
41
|
+
rowProps: rowProps,
|
|
42
|
+
...states
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
export {$4159a7a9cbb0cc18$export$96357d5a73f686fa as useGridRow};
|
|
48
|
+
//# sourceMappingURL=useGridRow.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAqCM,SAAS,0CAAsE,KAAsB,EAAE,KAAQ,EAAE,GAAgC;QAgB3H,aAA8B;IAfzD,IAAI,QACF,IAAI,iBACJ,aAAa,yBACb,qBAAqB,YACrB,QAAQ,EACT,GAAG;IAEJ,IAAI,WAAC,OAAO,EAAC,GAAG,CAAA,GAAA,yCAAM,EAAE,GAAG,CAAC;IAC5B,IAAI,cAAc,QAAQ,WAAW,GAAG,IAAM,QAAQ,WAAW,CAAC,KAAK,GAAG,IAAI;IAC9E,IAAI,aAAC,SAAS,EAAE,GAAG,QAAO,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAC7C,kBAAkB,MAAM,gBAAgB;QACxC,KAAK,KAAK,GAAG;aACb;uBACA;+BACA;QACA,UAAU,gBAAe,iBAAA,4BAAA,cAAA,KAAM,KAAK,cAAX,kCAAA,YAAa,QAAQ,IAAG,CAAA,GAAA,YAAI,EAAE,iBAAA,4BAAA,eAAA,KAAM,KAAK,cAAX,mCAAA,aAAa,QAAQ,EAAE,eAAe;QAC7F,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC,KAAK,GAAG;IAE3D,IAAI,WAA0B;QAC5B,MAAM;QACN,iBAAiB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAAS,aAAa;QAChF,iBAAiB,OAAO,UAAU,IAAI;QACtC,GAAG,SAAS;IACd;IAEA,IAAI,eACF,QAAQ,CAAC,gBAAgB,GAAG,KAAK,KAAK,GAAG,GAAG,2BAA2B;IAGzE,OAAO;kBACL;QACA,GAAG,MAAM;IACX;AACF","sources":["packages/@react-aria/grid/src/useGridRow.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 {chain} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {RefObject} from 'react';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface GridRowProps<T> {\n /** An object representing the grid row. Contains all the relevant information that makes up the grid row. */\n node: GridNode<T>,\n /** Whether the grid row is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the row.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface GridRowAria extends SelectableItemStates {\n /** Props for the grid row element. */\n rowProps: DOMAttributes,\n /** Whether the row is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid.\n * @param props - Props for the row.\n * @param state - State of the parent grid, as returned by `useGridState`.\n */\nexport function useGridRow<T, C extends GridCollection<T>, S extends GridState<T, C>>(props: GridRowProps<T>, state: S, ref: RefObject<FocusableElement>): GridRowAria {\n let {\n node,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction\n } = props;\n\n let {actions} = gridMap.get(state);\n let onRowAction = actions.onRowAction ? () => actions.onRowAction(node.key) : onAction;\n let {itemProps, ...states} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction: onRowAction || node?.props?.onAction ? chain(node?.props?.onAction, onRowAction) : undefined,\n isDisabled: state.collection.size === 0\n });\n\n let isSelected = state.selectionManager.isSelected(node.key);\n\n let rowProps: DOMAttributes = {\n role: 'row',\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined,\n 'aria-disabled': states.isDisabled || undefined,\n ...itemProps\n };\n\n if (isVirtualized) {\n rowProps['aria-rowindex'] = node.index + 1; // aria-rowindex is 1 based\n }\n\n return {\n rowProps,\n ...states\n };\n}\n"],"names":[],"version":3,"file":"useGridRow.module.js.map"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
function $parcel$export(e, n, v, s) {
|
|
3
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
$parcel$export(module.exports, "useGridRowGroup", () => $c7def85a57100898$export$d3037f5d3f3e51bf);
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/ function $c7def85a57100898$export$d3037f5d3f3e51bf() {
|
|
18
|
+
return {
|
|
19
|
+
rowGroupProps: {
|
|
20
|
+
role: "rowgroup"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=useGridRowGroup.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAYM,SAAS;IACd,OAAO;QACL,eAAe;YACb,MAAM;QACR;IACF;AACF","sources":["packages/@react-aria/grid/src/useGridRowGroup.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 {DOMAttributes} from '@react-types/shared';\n\nexport interface GridRowGroupAria {\n /** Props for the row group element. */\n rowGroupProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a row group in a grid.\n */\nexport function useGridRowGroup(): GridRowGroupAria {\n return {\n rowGroupProps: {\n role: 'rowgroup'\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridRowGroup.main.js.map"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/ function $e45487f8ba1cbdbf$export$d3037f5d3f3e51bf() {
|
|
12
|
+
return {
|
|
13
|
+
rowGroupProps: {
|
|
14
|
+
role: "rowgroup"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export {$e45487f8ba1cbdbf$export$d3037f5d3f3e51bf as useGridRowGroup};
|
|
21
|
+
//# sourceMappingURL=useGridRowGroup.mjs.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/ function $e45487f8ba1cbdbf$export$d3037f5d3f3e51bf() {
|
|
12
|
+
return {
|
|
13
|
+
rowGroupProps: {
|
|
14
|
+
role: "rowgroup"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export {$e45487f8ba1cbdbf$export$d3037f5d3f3e51bf as useGridRowGroup};
|
|
21
|
+
//# sourceMappingURL=useGridRowGroup.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAYM,SAAS;IACd,OAAO;QACL,eAAe;YACb,MAAM;QACR;IACF;AACF","sources":["packages/@react-aria/grid/src/useGridRowGroup.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 {DOMAttributes} from '@react-types/shared';\n\nexport interface GridRowGroupAria {\n /** Props for the row group element. */\n rowGroupProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a row group in a grid.\n */\nexport function useGridRowGroup(): GridRowGroupAria {\n return {\n rowGroupProps: {\n role: 'rowgroup'\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridRowGroup.module.js.map"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
var $085250522aa37816$exports = require("./intlStrings.main.js");
|
|
2
|
+
var $iMOYA$reactarialiveannouncer = require("@react-aria/live-announcer");
|
|
3
|
+
var $iMOYA$reactariai18n = require("@react-aria/i18n");
|
|
4
|
+
var $iMOYA$react = require("react");
|
|
5
|
+
var $iMOYA$reactariautils = require("@react-aria/utils");
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function $parcel$interopDefault(a) {
|
|
9
|
+
return a && a.__esModule ? a.default : a;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function $parcel$export(e, n, v, s) {
|
|
13
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
$parcel$export(module.exports, "useGridSelectionAnnouncement", () => $1eb174acfe8a0f16$export$137e594ef3218a10);
|
|
17
|
+
/*
|
|
18
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
function $1eb174acfe8a0f16$export$137e594ef3218a10(props, state) {
|
|
33
|
+
let { getRowText: getRowText = (key)=>{
|
|
34
|
+
var _state_collection_getTextValue, _state_collection, _state_collection_getItem;
|
|
35
|
+
var _state_collection_getTextValue1;
|
|
36
|
+
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;
|
|
37
|
+
} } = props;
|
|
38
|
+
let stringFormatter = (0, $iMOYA$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($085250522aa37816$exports))), "@react-aria/grid");
|
|
39
|
+
// Many screen readers do not announce when items in a grid are selected/deselected.
|
|
40
|
+
// We do this using an ARIA live region.
|
|
41
|
+
let selection = state.selectionManager.rawSelection;
|
|
42
|
+
let lastSelection = (0, $iMOYA$react.useRef)(selection);
|
|
43
|
+
(0, $iMOYA$reactariautils.useUpdateEffect)(()=>{
|
|
44
|
+
var _lastSelection_current;
|
|
45
|
+
if (!state.selectionManager.isFocused) {
|
|
46
|
+
lastSelection.current = selection;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let addedKeys = $1eb174acfe8a0f16$var$diffSelection(selection, lastSelection.current);
|
|
50
|
+
let removedKeys = $1eb174acfe8a0f16$var$diffSelection(lastSelection.current, selection);
|
|
51
|
+
// If adding or removing a single row from the selection, announce the name of that item.
|
|
52
|
+
let isReplace = state.selectionManager.selectionBehavior === "replace";
|
|
53
|
+
let messages = [];
|
|
54
|
+
if (state.selectionManager.selectedKeys.size === 1 && isReplace) {
|
|
55
|
+
if (state.collection.getItem(state.selectionManager.selectedKeys.keys().next().value)) {
|
|
56
|
+
let currentSelectionText = getRowText(state.selectionManager.selectedKeys.keys().next().value);
|
|
57
|
+
if (currentSelectionText) messages.push(stringFormatter.format("selectedItem", {
|
|
58
|
+
item: currentSelectionText
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
} else if (addedKeys.size === 1 && removedKeys.size === 0) {
|
|
62
|
+
let addedText = getRowText(addedKeys.keys().next().value);
|
|
63
|
+
if (addedText) messages.push(stringFormatter.format("selectedItem", {
|
|
64
|
+
item: addedText
|
|
65
|
+
}));
|
|
66
|
+
} else if (removedKeys.size === 1 && addedKeys.size === 0) {
|
|
67
|
+
if (state.collection.getItem(removedKeys.keys().next().value)) {
|
|
68
|
+
let removedText = getRowText(removedKeys.keys().next().value);
|
|
69
|
+
if (removedText) messages.push(stringFormatter.format("deselectedItem", {
|
|
70
|
+
item: removedText
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Announce how many items are selected, except when selecting the first item.
|
|
75
|
+
if (state.selectionManager.selectionMode === "multiple") {
|
|
76
|
+
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", {
|
|
77
|
+
count: selection.size
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
if (messages.length > 0) (0, $iMOYA$reactarialiveannouncer.announce)(messages.join(" "));
|
|
81
|
+
lastSelection.current = selection;
|
|
82
|
+
}, [
|
|
83
|
+
selection
|
|
84
|
+
]);
|
|
85
|
+
}
|
|
86
|
+
function $1eb174acfe8a0f16$var$diffSelection(a, b) {
|
|
87
|
+
let res = new Set();
|
|
88
|
+
if (a === "all" || b === "all") return res;
|
|
89
|
+
for (let key of a.keys())if (!b.has(key)) res.add(key);
|
|
90
|
+
return res;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=useGridSelectionAnnouncement.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BM,SAAS,0CAAgC,KAAqC,EAAE,KAA4B;IACjH,IAAI,cACF,aAAa,CAAC;YAAQ,gCAAA,mBAAwC;YAAxC;eAAA,CAAA,mCAAA,iCAAA,CAAA,oBAAA,MAAM,UAAU,EAAC,YAAY,cAA7B,qDAAA,oCAAA,mBAAgC,kBAAhC,6CAAA,mCAAwC,4BAAA,MAAM,UAAU,CAAC,OAAO,CAAC,kBAAzB,gDAAA,0BAA+B,SAAS;IAAD,GACtG,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,oFAAoF;IACpF,wCAAwC;IACxC,IAAI,YAAY,MAAM,gBAAgB,CAAC,YAAY;IACnD,IAAI,gBAAgB,CAAA,GAAA,mBAAK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,MAAM,gBAAgB,CAAC,aAAa,KAAK,YAC3C;YAAA,IAAI,SAAS,MAAM,KAAK,KAAK,cAAc,SAAS,UAAU,IAAI,GAAG,KAAK,cAAc,OAAO,KAAK,SAAS,EAAA,yBAAA,cAAc,OAAO,cAArB,6CAAA,uBAAuB,IAAI,IAAG,GACzI,SAAS,IAAI,CAAC,cAAc,QACxB,gBAAgB,MAAM,CAAC,iBACvB,gBAAgB,MAAM,CAAC,iBAAiB;gBAAC,OAAO,UAAU,IAAI;YAAA;QAEpE;QAGF,IAAI,SAAS,MAAM,GAAG,GACpB,CAAA,GAAA,sCAAO,EAAE,SAAS,IAAI,CAAC;QAGzB,cAAc,OAAO,GAAG;IAC1B,GAAG;QAAC;KAAU;AAChB;AAEA,SAAS,oCAAc,CAAY,EAAE,CAAY;IAC/C,IAAI,MAAM,IAAI;IACd,IAAI,MAAM,SAAS,MAAM,OACvB,OAAO;IAGT,KAAK,IAAI,OAAO,EAAE,IAAI,GACpB,IAAI,CAAC,EAAE,GAAG,CAAC,MACT,IAAI,GAAG,CAAC;IAIZ,OAAO;AACT","sources":["packages/@react-aria/grid/src/useGridSelectionAnnouncement.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {announce} from '@react-aria/live-announcer';\nimport {Collection, Key, Node, Selection} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {SelectionManager} from '@react-stately/selection';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useRef} from 'react';\nimport {useUpdateEffect} from '@react-aria/utils';\n\nexport interface GridSelectionAnnouncementProps {\n /**\n * A function that returns the text that should be announced by assistive technology when a row is added or removed from selection.\n * @default (key) => state.collection.getItem(key)?.textValue\n */\n getRowText?: (key: Key) => string\n}\n\ninterface GridSelectionState<T> {\n /** A collection of items in the grid. */\n collection: Collection<Node<T>>,\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>,\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager\n}\n\nexport function useGridSelectionAnnouncement<T>(props: GridSelectionAnnouncementProps, state: GridSelectionState<T>) {\n let {\n getRowText = (key) => state.collection.getTextValue?.(key) ?? state.collection.getItem(key)?.textValue\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n // Many screen readers do not announce when items in a grid are selected/deselected.\n // We do this using an ARIA live region.\n let selection = state.selectionManager.rawSelection;\n let lastSelection = useRef(selection);\n useUpdateEffect(() => {\n if (!state.selectionManager.isFocused) {\n lastSelection.current = selection;\n\n return;\n }\n\n let addedKeys = diffSelection(selection, lastSelection.current);\n let removedKeys = diffSelection(lastSelection.current, selection);\n\n // If adding or removing a single row from the selection, announce the name of that item.\n let isReplace = state.selectionManager.selectionBehavior === 'replace';\n let messages = [];\n\n if ((state.selectionManager.selectedKeys.size === 1 && isReplace)) {\n if (state.collection.getItem(state.selectionManager.selectedKeys.keys().next().value)) {\n let currentSelectionText = getRowText(state.selectionManager.selectedKeys.keys().next().value);\n if (currentSelectionText) {\n messages.push(stringFormatter.format('selectedItem', {item: currentSelectionText}));\n }\n }\n } else if (addedKeys.size === 1 && removedKeys.size === 0) {\n let addedText = getRowText(addedKeys.keys().next().value);\n if (addedText) {\n messages.push(stringFormatter.format('selectedItem', {item: addedText}));\n }\n } else if (removedKeys.size === 1 && addedKeys.size === 0) {\n if (state.collection.getItem(removedKeys.keys().next().value)) {\n let removedText = getRowText(removedKeys.keys().next().value);\n if (removedText) {\n messages.push(stringFormatter.format('deselectedItem', {item: removedText}));\n }\n }\n }\n\n // Announce how many items are selected, except when selecting the first item.\n if (state.selectionManager.selectionMode === 'multiple') {\n if (messages.length === 0 || selection === 'all' || selection.size > 1 || lastSelection.current === 'all' || lastSelection.current?.size > 1) {\n messages.push(selection === 'all'\n ? stringFormatter.format('selectedAll')\n : stringFormatter.format('selectedCount', {count: selection.size})\n );\n }\n }\n\n if (messages.length > 0) {\n announce(messages.join(' '));\n }\n\n lastSelection.current = selection;\n }, [selection]);\n}\n\nfunction diffSelection(a: Selection, b: Selection): Set<Key> {\n let res = new Set<Key>();\n if (a === 'all' || b === 'all') {\n return res;\n }\n\n for (let key of a.keys()) {\n if (!b.has(key)) {\n res.add(key);\n }\n }\n\n return res;\n}\n"],"names":[],"version":3,"file":"useGridSelectionAnnouncement.main.js.map"}
|