@react-aria/grid 3.14.7 → 3.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +9 -9
- package/dist/main.js +16 -16
- package/dist/main.js.map +1 -1
- package/dist/module.js +9 -9
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +16 -0
- package/package.json +15 -23
- package/src/index.ts +16 -16
- package/dist/GridKeyboardDelegate.main.js +0 -318
- package/dist/GridKeyboardDelegate.main.js.map +0 -1
- package/dist/GridKeyboardDelegate.mjs +0 -313
- package/dist/GridKeyboardDelegate.module.js +0 -313
- package/dist/GridKeyboardDelegate.module.js.map +0 -1
- package/dist/ar-AE.main.js +0 -15
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -17
- package/dist/ar-AE.module.js +0 -17
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -15
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -17
- package/dist/bg-BG.module.js +0 -17
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -15
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -17
- package/dist/cs-CZ.module.js +0 -17
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -15
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -17
- package/dist/da-DK.module.js +0 -17
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -15
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -17
- package/dist/de-DE.module.js +0 -17
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -15
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -17
- package/dist/el-GR.module.js +0 -17
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -15
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -17
- package/dist/en-US.module.js +0 -17
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -15
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -17
- package/dist/es-ES.module.js +0 -17
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -15
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -17
- package/dist/et-EE.module.js +0 -17
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -15
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -17
- package/dist/fi-FI.module.js +0 -17
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -15
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -17
- package/dist/fr-FR.module.js +0 -17
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -15
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -17
- package/dist/he-IL.module.js +0 -17
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -15
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -17
- package/dist/hr-HR.module.js +0 -17
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -15
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -17
- package/dist/hu-HU.module.js +0 -17
- package/dist/hu-HU.module.js.map +0 -1
- package/dist/intlStrings.main.js +0 -108
- package/dist/intlStrings.main.js.map +0 -1
- package/dist/intlStrings.mjs +0 -110
- package/dist/intlStrings.module.js +0 -110
- package/dist/intlStrings.module.js.map +0 -1
- package/dist/it-IT.main.js +0 -15
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -17
- package/dist/it-IT.module.js +0 -17
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -15
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -17
- package/dist/ja-JP.module.js +0 -17
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -15
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -17
- package/dist/ko-KR.module.js +0 -17
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -15
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -17
- package/dist/lt-LT.module.js +0 -17
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -15
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -17
- package/dist/lv-LV.module.js +0 -17
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -15
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -17
- package/dist/nb-NO.module.js +0 -17
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -15
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -17
- package/dist/nl-NL.module.js +0 -17
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -15
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -17
- package/dist/pl-PL.module.js +0 -17
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -15
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -17
- package/dist/pt-BR.module.js +0 -17
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -15
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -17
- package/dist/pt-PT.module.js +0 -17
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -15
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -17
- package/dist/ro-RO.module.js +0 -17
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -15
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -17
- package/dist/ru-RU.module.js +0 -17
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -15
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -17
- package/dist/sk-SK.module.js +0 -17
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -15
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -17
- package/dist/sl-SI.module.js +0 -17
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -15
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -17
- package/dist/sr-SP.module.js +0 -17
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -15
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -17
- package/dist/sv-SE.module.js +0 -17
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -15
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -17
- package/dist/tr-TR.module.js +0 -17
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -213
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -15
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -17
- package/dist/uk-UA.module.js +0 -17
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/useGrid.main.js +0 -135
- package/dist/useGrid.main.js.map +0 -1
- package/dist/useGrid.mjs +0 -130
- package/dist/useGrid.module.js +0 -130
- package/dist/useGrid.module.js.map +0 -1
- package/dist/useGridCell.main.js +0 -230
- package/dist/useGridCell.main.js.map +0 -1
- package/dist/useGridCell.mjs +0 -225
- package/dist/useGridCell.module.js +0 -225
- package/dist/useGridCell.module.js.map +0 -1
- package/dist/useGridRow.main.js +0 -56
- package/dist/useGridRow.main.js.map +0 -1
- package/dist/useGridRow.mjs +0 -51
- package/dist/useGridRow.module.js +0 -51
- package/dist/useGridRow.module.js.map +0 -1
- package/dist/useGridRowGroup.main.js +0 -26
- package/dist/useGridRowGroup.main.js.map +0 -1
- package/dist/useGridRowGroup.mjs +0 -21
- package/dist/useGridRowGroup.module.js +0 -21
- package/dist/useGridRowGroup.module.js.map +0 -1
- package/dist/useGridSelectionAnnouncement.main.js +0 -118
- package/dist/useGridSelectionAnnouncement.main.js.map +0 -1
- package/dist/useGridSelectionAnnouncement.mjs +0 -113
- package/dist/useGridSelectionAnnouncement.module.js +0 -113
- package/dist/useGridSelectionAnnouncement.module.js.map +0 -1
- package/dist/useGridSelectionCheckbox.main.js +0 -39
- package/dist/useGridSelectionCheckbox.main.js.map +0 -1
- package/dist/useGridSelectionCheckbox.mjs +0 -34
- package/dist/useGridSelectionCheckbox.module.js +0 -34
- package/dist/useGridSelectionCheckbox.module.js.map +0 -1
- package/dist/useHighlightSelectionDescription.main.js +0 -55
- package/dist/useHighlightSelectionDescription.main.js.map +0 -1
- package/dist/useHighlightSelectionDescription.mjs +0 -50
- package/dist/useHighlightSelectionDescription.module.js +0 -50
- package/dist/useHighlightSelectionDescription.module.js.map +0 -1
- package/dist/utils.main.js +0 -20
- package/dist/utils.main.js.map +0 -1
- package/dist/utils.mjs +0 -15
- package/dist/utils.module.js +0 -15
- package/dist/utils.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -15
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -17
- package/dist/zh-CN.module.js +0 -17
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -15
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -17
- package/dist/zh-TW.module.js +0 -17
- package/dist/zh-TW.module.js.map +0 -1
- package/src/GridKeyboardDelegate.ts +0 -484
- package/src/useGrid.ts +0 -186
- package/src/useGridCell.ts +0 -299
- package/src/useGridRow.ts +0 -84
- package/src/useGridRowGroup.ts +0 -29
- package/src/useGridSelectionAnnouncement.ts +0 -140
- package/src/useGridSelectionCheckbox.ts +0 -48
- package/src/useHighlightSelectionDescription.ts +0 -52
- package/src/utils.ts +0 -29
package/dist/useGrid.main.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
var $3187c0e19200cb16$exports = require("./GridKeyboardDelegate.main.js");
|
|
2
|
-
var $8ee34951196858d0$exports = require("./utils.main.js");
|
|
3
|
-
var $1eb174acfe8a0f16$exports = require("./useGridSelectionAnnouncement.main.js");
|
|
4
|
-
var $340f2fcd0ef9ce8d$exports = require("./useHighlightSelectionDescription.main.js");
|
|
5
|
-
var $lBaOG$reactariautils = require("@react-aria/utils");
|
|
6
|
-
var $lBaOG$react = require("react");
|
|
7
|
-
var $lBaOG$reactariai18n = require("@react-aria/i18n");
|
|
8
|
-
var $lBaOG$reactariafocus = require("@react-aria/focus");
|
|
9
|
-
var $lBaOG$reactariaselection = require("@react-aria/selection");
|
|
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, "useGrid", () => $11d770dfabe45077$export$f6b86a04e5d66d90);
|
|
17
|
-
/*
|
|
18
|
-
* Copyright 2020 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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref) {
|
|
37
|
-
let { isVirtualized: isVirtualized, disallowTypeAhead: disallowTypeAhead, keyboardDelegate: keyboardDelegate, focusMode: focusMode, scrollRef: scrollRef, getRowText: getRowText, onRowAction: onRowAction, onCellAction: onCellAction, escapeKeyBehavior: escapeKeyBehavior = 'clearSelection', shouldSelectOnPressUp: shouldSelectOnPressUp } = props;
|
|
38
|
-
let { selectionManager: manager } = state;
|
|
39
|
-
if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
40
|
-
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
41
|
-
// When virtualized, the layout object will be passed in as a prop and override this.
|
|
42
|
-
let collator = (0, $lBaOG$reactariai18n.useCollator)({
|
|
43
|
-
usage: 'search',
|
|
44
|
-
sensitivity: 'base'
|
|
45
|
-
});
|
|
46
|
-
let { direction: direction } = (0, $lBaOG$reactariai18n.useLocale)();
|
|
47
|
-
let disabledBehavior = state.selectionManager.disabledBehavior;
|
|
48
|
-
let delegate = (0, $lBaOG$react.useMemo)(()=>keyboardDelegate || new (0, $3187c0e19200cb16$exports.GridKeyboardDelegate)({
|
|
49
|
-
collection: state.collection,
|
|
50
|
-
disabledKeys: state.disabledKeys,
|
|
51
|
-
disabledBehavior: disabledBehavior,
|
|
52
|
-
ref: ref,
|
|
53
|
-
direction: direction,
|
|
54
|
-
collator: collator,
|
|
55
|
-
focusMode: focusMode
|
|
56
|
-
}), [
|
|
57
|
-
keyboardDelegate,
|
|
58
|
-
state.collection,
|
|
59
|
-
state.disabledKeys,
|
|
60
|
-
disabledBehavior,
|
|
61
|
-
ref,
|
|
62
|
-
direction,
|
|
63
|
-
collator,
|
|
64
|
-
focusMode
|
|
65
|
-
]);
|
|
66
|
-
let { collectionProps: collectionProps } = (0, $lBaOG$reactariaselection.useSelectableCollection)({
|
|
67
|
-
ref: ref,
|
|
68
|
-
selectionManager: manager,
|
|
69
|
-
keyboardDelegate: delegate,
|
|
70
|
-
isVirtualized: isVirtualized,
|
|
71
|
-
scrollRef: scrollRef,
|
|
72
|
-
disallowTypeAhead: disallowTypeAhead,
|
|
73
|
-
escapeKeyBehavior: escapeKeyBehavior
|
|
74
|
-
});
|
|
75
|
-
let id = (0, $lBaOG$reactariautils.useId)(props.id);
|
|
76
|
-
(0, $8ee34951196858d0$exports.gridMap).set(state, {
|
|
77
|
-
keyboardDelegate: delegate,
|
|
78
|
-
actions: {
|
|
79
|
-
onRowAction: onRowAction,
|
|
80
|
-
onCellAction: onCellAction
|
|
81
|
-
},
|
|
82
|
-
shouldSelectOnPressUp: shouldSelectOnPressUp
|
|
83
|
-
});
|
|
84
|
-
let descriptionProps = (0, $340f2fcd0ef9ce8d$exports.useHighlightSelectionDescription)({
|
|
85
|
-
selectionManager: manager,
|
|
86
|
-
hasItemActions: !!(onRowAction || onCellAction)
|
|
87
|
-
});
|
|
88
|
-
let domProps = (0, $lBaOG$reactariautils.filterDOMProps)(props, {
|
|
89
|
-
labelable: true
|
|
90
|
-
});
|
|
91
|
-
let onFocus = (0, $lBaOG$react.useCallback)((e)=>{
|
|
92
|
-
if (manager.isFocused) {
|
|
93
|
-
// If a focus event bubbled through a portal, reset focus state.
|
|
94
|
-
if (!(0, $lBaOG$reactariautils.nodeContains)(e.currentTarget, e.target)) manager.setFocused(false);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
// Focus events can bubble through portals. Ignore these events.
|
|
98
|
-
if (!(0, $lBaOG$reactariautils.nodeContains)(e.currentTarget, e.target)) return;
|
|
99
|
-
manager.setFocused(true);
|
|
100
|
-
}, [
|
|
101
|
-
manager
|
|
102
|
-
]);
|
|
103
|
-
// Continue to track collection focused state even if keyboard navigation is disabled
|
|
104
|
-
let navDisabledHandlers = (0, $lBaOG$react.useMemo)(()=>({
|
|
105
|
-
onBlur: collectionProps.onBlur,
|
|
106
|
-
onFocus: onFocus
|
|
107
|
-
}), [
|
|
108
|
-
onFocus,
|
|
109
|
-
collectionProps.onBlur
|
|
110
|
-
]);
|
|
111
|
-
let hasTabbableChild = (0, $lBaOG$reactariafocus.useHasTabbableChild)(ref, {
|
|
112
|
-
isDisabled: state.collection.size !== 0
|
|
113
|
-
});
|
|
114
|
-
let gridProps = (0, $lBaOG$reactariautils.mergeProps)(domProps, {
|
|
115
|
-
role: 'grid',
|
|
116
|
-
id: id,
|
|
117
|
-
'aria-multiselectable': manager.selectionMode === 'multiple' ? 'true' : undefined
|
|
118
|
-
}, state.isKeyboardNavigationDisabled ? navDisabledHandlers : collectionProps, // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.
|
|
119
|
-
state.collection.size === 0 && {
|
|
120
|
-
tabIndex: hasTabbableChild ? -1 : 0
|
|
121
|
-
} || undefined, descriptionProps);
|
|
122
|
-
if (isVirtualized) {
|
|
123
|
-
gridProps['aria-rowcount'] = state.collection.size;
|
|
124
|
-
gridProps['aria-colcount'] = state.collection.columnCount;
|
|
125
|
-
}
|
|
126
|
-
(0, $1eb174acfe8a0f16$exports.useGridSelectionAnnouncement)({
|
|
127
|
-
getRowText: getRowText
|
|
128
|
-
}, state);
|
|
129
|
-
return {
|
|
130
|
-
gridProps: gridProps
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
//# sourceMappingURL=useGrid.main.js.map
|
package/dist/useGrid.main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAuEM,SA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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 {AriaLabelingProps, DOMAttributes, DOMProps, Key, KeyboardDelegate, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, nodeContains, useId} from '@react-aria/utils';\nimport {GridCollection} from '@react-types/grid';\nimport {GridKeyboardDelegate} from './GridKeyboardDelegate';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {useCallback, useMemo} from 'react';\nimport {useCollator, useLocale} from '@react-aria/i18n';\nimport {useGridSelectionAnnouncement} from './useGridSelectionAnnouncement';\nimport {useHasTabbableChild} from '@react-aria/focus';\nimport {useHighlightSelectionDescription} from './useHighlightSelectionDescription';\nimport {useSelectableCollection} from '@react-aria/selection';\n\nexport interface GridProps extends DOMProps, AriaLabelingProps {\n /** Whether the grid uses virtual scrolling. */\n isVirtualized?: boolean,\n /**\n * Whether typeahead navigation is disabled.\n * @default false\n */\n disallowTypeAhead?: boolean,\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * Whether initial grid focus should be placed on the grid row or grid cell.\n * @default 'row'\n */\n focusMode?: 'row' | 'cell',\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 * The ref attached to the scrollable body. Used to provided automatic scrolling on item focus for non-virtualized grids.\n */\n scrollRef?: RefObject<HTMLElement | null>,\n /** Handler that is called when a user performs an action on the row. */\n onRowAction?: (key: Key) => void,\n /** Handler that is called when a user performs an action on the cell. */\n onCellAction?: (key: Key) => void,\n /**\n * Whether pressing the escape key should clear selection in the grid or not.\n *\n * Most experiences should not modify this option as it eliminates a keyboard user's ability to\n * easily clear selection. Only use if the escape key is being handled externally or should not\n * trigger selection clearing contextually.\n * @default 'clearSelection'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none',\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean\n}\n\nexport interface GridAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a grid component.\n * A grid displays data in one or more rows and columns and enables a user to navigate its contents via directional navigation keys.\n * @param props - Props for the grid.\n * @param state - State for the grid, as returned by `useGridState`.\n * @param ref - The ref attached to the grid element.\n */\nexport function useGrid<T>(props: GridProps, state: GridState<T, GridCollection<T>>, ref: RefObject<HTMLElement | null>): GridAria {\n let {\n isVirtualized,\n disallowTypeAhead,\n keyboardDelegate,\n focusMode,\n scrollRef,\n getRowText,\n onRowAction,\n onCellAction,\n escapeKeyBehavior = 'clearSelection',\n shouldSelectOnPressUp\n } = props;\n let {selectionManager: manager} = state;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let {direction} = useLocale();\n let disabledBehavior = state.selectionManager.disabledBehavior;\n let delegate = useMemo(() => keyboardDelegate || new GridKeyboardDelegate({\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n disabledBehavior,\n ref,\n direction,\n collator,\n focusMode\n }), [keyboardDelegate, state.collection, state.disabledKeys, disabledBehavior, ref, direction, collator, focusMode]);\n\n let {collectionProps} = useSelectableCollection({\n ref,\n selectionManager: manager,\n keyboardDelegate: delegate,\n isVirtualized,\n scrollRef,\n disallowTypeAhead,\n escapeKeyBehavior\n });\n\n let id = useId(props.id);\n gridMap.set(state, {keyboardDelegate: delegate, actions: {onRowAction, onCellAction}, shouldSelectOnPressUp});\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: manager,\n hasItemActions: !!(onRowAction || onCellAction)\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n let onFocus = useCallback((e) => {\n if (manager.isFocused) {\n // If a focus event bubbled through a portal, reset focus state.\n if (!nodeContains(e.currentTarget, e.target)) {\n manager.setFocused(false);\n }\n\n return;\n }\n\n // Focus events can bubble through portals. Ignore these events.\n if (!nodeContains(e.currentTarget, e.target)) {\n return;\n }\n\n manager.setFocused(true);\n }, [manager]);\n\n // Continue to track collection focused state even if keyboard navigation is disabled\n let navDisabledHandlers = useMemo(() => ({\n onBlur: collectionProps.onBlur,\n onFocus\n }), [onFocus, collectionProps.onBlur]);\n\n let hasTabbableChild = useHasTabbableChild(ref, {\n isDisabled: state.collection.size !== 0\n });\n\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable': manager.selectionMode === 'multiple' ? 'true' : undefined\n },\n state.isKeyboardNavigationDisabled ? navDisabledHandlers : collectionProps,\n // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.\n (state.collection.size === 0 && {tabIndex: hasTabbableChild ? -1 : 0}) || undefined,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = state.collection.columnCount;\n }\n\n useGridSelectionAnnouncement({getRowText}, state);\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useGrid.main.js.map"}
|
package/dist/useGrid.mjs
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import {GridKeyboardDelegate as $d1c300d9c497e402$export$de9feff04fda126e} from "./GridKeyboardDelegate.mjs";
|
|
2
|
-
import {gridMap as $1af922eb41e03c8f$export$e6235c0d09b995d0} from "./utils.mjs";
|
|
3
|
-
import {useGridSelectionAnnouncement as $92599c3fd427b763$export$137e594ef3218a10} from "./useGridSelectionAnnouncement.mjs";
|
|
4
|
-
import {useHighlightSelectionDescription as $5b9b5b5723db6ae1$export$be42ebdab07ae4c2} from "./useHighlightSelectionDescription.mjs";
|
|
5
|
-
import {useId as $eV0xE$useId, filterDOMProps as $eV0xE$filterDOMProps, nodeContains as $eV0xE$nodeContains, mergeProps as $eV0xE$mergeProps} from "@react-aria/utils";
|
|
6
|
-
import {useMemo as $eV0xE$useMemo, useCallback as $eV0xE$useCallback} from "react";
|
|
7
|
-
import {useCollator as $eV0xE$useCollator, useLocale as $eV0xE$useLocale} from "@react-aria/i18n";
|
|
8
|
-
import {useHasTabbableChild as $eV0xE$useHasTabbableChild} from "@react-aria/focus";
|
|
9
|
-
import {useSelectableCollection as $eV0xE$useSelectableCollection} from "@react-aria/selection";
|
|
10
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref) {
|
|
31
|
-
let { isVirtualized: isVirtualized, disallowTypeAhead: disallowTypeAhead, keyboardDelegate: keyboardDelegate, focusMode: focusMode, scrollRef: scrollRef, getRowText: getRowText, onRowAction: onRowAction, onCellAction: onCellAction, escapeKeyBehavior: escapeKeyBehavior = 'clearSelection', shouldSelectOnPressUp: shouldSelectOnPressUp } = props;
|
|
32
|
-
let { selectionManager: manager } = state;
|
|
33
|
-
if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
34
|
-
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
35
|
-
// When virtualized, the layout object will be passed in as a prop and override this.
|
|
36
|
-
let collator = (0, $eV0xE$useCollator)({
|
|
37
|
-
usage: 'search',
|
|
38
|
-
sensitivity: 'base'
|
|
39
|
-
});
|
|
40
|
-
let { direction: direction } = (0, $eV0xE$useLocale)();
|
|
41
|
-
let disabledBehavior = state.selectionManager.disabledBehavior;
|
|
42
|
-
let delegate = (0, $eV0xE$useMemo)(()=>keyboardDelegate || new (0, $d1c300d9c497e402$export$de9feff04fda126e)({
|
|
43
|
-
collection: state.collection,
|
|
44
|
-
disabledKeys: state.disabledKeys,
|
|
45
|
-
disabledBehavior: disabledBehavior,
|
|
46
|
-
ref: ref,
|
|
47
|
-
direction: direction,
|
|
48
|
-
collator: collator,
|
|
49
|
-
focusMode: focusMode
|
|
50
|
-
}), [
|
|
51
|
-
keyboardDelegate,
|
|
52
|
-
state.collection,
|
|
53
|
-
state.disabledKeys,
|
|
54
|
-
disabledBehavior,
|
|
55
|
-
ref,
|
|
56
|
-
direction,
|
|
57
|
-
collator,
|
|
58
|
-
focusMode
|
|
59
|
-
]);
|
|
60
|
-
let { collectionProps: collectionProps } = (0, $eV0xE$useSelectableCollection)({
|
|
61
|
-
ref: ref,
|
|
62
|
-
selectionManager: manager,
|
|
63
|
-
keyboardDelegate: delegate,
|
|
64
|
-
isVirtualized: isVirtualized,
|
|
65
|
-
scrollRef: scrollRef,
|
|
66
|
-
disallowTypeAhead: disallowTypeAhead,
|
|
67
|
-
escapeKeyBehavior: escapeKeyBehavior
|
|
68
|
-
});
|
|
69
|
-
let id = (0, $eV0xE$useId)(props.id);
|
|
70
|
-
(0, $1af922eb41e03c8f$export$e6235c0d09b995d0).set(state, {
|
|
71
|
-
keyboardDelegate: delegate,
|
|
72
|
-
actions: {
|
|
73
|
-
onRowAction: onRowAction,
|
|
74
|
-
onCellAction: onCellAction
|
|
75
|
-
},
|
|
76
|
-
shouldSelectOnPressUp: shouldSelectOnPressUp
|
|
77
|
-
});
|
|
78
|
-
let descriptionProps = (0, $5b9b5b5723db6ae1$export$be42ebdab07ae4c2)({
|
|
79
|
-
selectionManager: manager,
|
|
80
|
-
hasItemActions: !!(onRowAction || onCellAction)
|
|
81
|
-
});
|
|
82
|
-
let domProps = (0, $eV0xE$filterDOMProps)(props, {
|
|
83
|
-
labelable: true
|
|
84
|
-
});
|
|
85
|
-
let onFocus = (0, $eV0xE$useCallback)((e)=>{
|
|
86
|
-
if (manager.isFocused) {
|
|
87
|
-
// If a focus event bubbled through a portal, reset focus state.
|
|
88
|
-
if (!(0, $eV0xE$nodeContains)(e.currentTarget, e.target)) manager.setFocused(false);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
// Focus events can bubble through portals. Ignore these events.
|
|
92
|
-
if (!(0, $eV0xE$nodeContains)(e.currentTarget, e.target)) return;
|
|
93
|
-
manager.setFocused(true);
|
|
94
|
-
}, [
|
|
95
|
-
manager
|
|
96
|
-
]);
|
|
97
|
-
// Continue to track collection focused state even if keyboard navigation is disabled
|
|
98
|
-
let navDisabledHandlers = (0, $eV0xE$useMemo)(()=>({
|
|
99
|
-
onBlur: collectionProps.onBlur,
|
|
100
|
-
onFocus: onFocus
|
|
101
|
-
}), [
|
|
102
|
-
onFocus,
|
|
103
|
-
collectionProps.onBlur
|
|
104
|
-
]);
|
|
105
|
-
let hasTabbableChild = (0, $eV0xE$useHasTabbableChild)(ref, {
|
|
106
|
-
isDisabled: state.collection.size !== 0
|
|
107
|
-
});
|
|
108
|
-
let gridProps = (0, $eV0xE$mergeProps)(domProps, {
|
|
109
|
-
role: 'grid',
|
|
110
|
-
id: id,
|
|
111
|
-
'aria-multiselectable': manager.selectionMode === 'multiple' ? 'true' : undefined
|
|
112
|
-
}, state.isKeyboardNavigationDisabled ? navDisabledHandlers : collectionProps, // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.
|
|
113
|
-
state.collection.size === 0 && {
|
|
114
|
-
tabIndex: hasTabbableChild ? -1 : 0
|
|
115
|
-
} || undefined, descriptionProps);
|
|
116
|
-
if (isVirtualized) {
|
|
117
|
-
gridProps['aria-rowcount'] = state.collection.size;
|
|
118
|
-
gridProps['aria-colcount'] = state.collection.columnCount;
|
|
119
|
-
}
|
|
120
|
-
(0, $92599c3fd427b763$export$137e594ef3218a10)({
|
|
121
|
-
getRowText: getRowText
|
|
122
|
-
}, state);
|
|
123
|
-
return {
|
|
124
|
-
gridProps: gridProps
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
export {$83c6e2eafa584c67$export$f6b86a04e5d66d90 as useGrid};
|
|
130
|
-
//# sourceMappingURL=useGrid.module.js.map
|
package/dist/useGrid.module.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import {GridKeyboardDelegate as $d1c300d9c497e402$export$de9feff04fda126e} from "./GridKeyboardDelegate.module.js";
|
|
2
|
-
import {gridMap as $1af922eb41e03c8f$export$e6235c0d09b995d0} from "./utils.module.js";
|
|
3
|
-
import {useGridSelectionAnnouncement as $92599c3fd427b763$export$137e594ef3218a10} from "./useGridSelectionAnnouncement.module.js";
|
|
4
|
-
import {useHighlightSelectionDescription as $5b9b5b5723db6ae1$export$be42ebdab07ae4c2} from "./useHighlightSelectionDescription.module.js";
|
|
5
|
-
import {useId as $eV0xE$useId, filterDOMProps as $eV0xE$filterDOMProps, nodeContains as $eV0xE$nodeContains, mergeProps as $eV0xE$mergeProps} from "@react-aria/utils";
|
|
6
|
-
import {useMemo as $eV0xE$useMemo, useCallback as $eV0xE$useCallback} from "react";
|
|
7
|
-
import {useCollator as $eV0xE$useCollator, useLocale as $eV0xE$useLocale} from "@react-aria/i18n";
|
|
8
|
-
import {useHasTabbableChild as $eV0xE$useHasTabbableChild} from "@react-aria/focus";
|
|
9
|
-
import {useSelectableCollection as $eV0xE$useSelectableCollection} from "@react-aria/selection";
|
|
10
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref) {
|
|
31
|
-
let { isVirtualized: isVirtualized, disallowTypeAhead: disallowTypeAhead, keyboardDelegate: keyboardDelegate, focusMode: focusMode, scrollRef: scrollRef, getRowText: getRowText, onRowAction: onRowAction, onCellAction: onCellAction, escapeKeyBehavior: escapeKeyBehavior = 'clearSelection', shouldSelectOnPressUp: shouldSelectOnPressUp } = props;
|
|
32
|
-
let { selectionManager: manager } = state;
|
|
33
|
-
if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
34
|
-
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
35
|
-
// When virtualized, the layout object will be passed in as a prop and override this.
|
|
36
|
-
let collator = (0, $eV0xE$useCollator)({
|
|
37
|
-
usage: 'search',
|
|
38
|
-
sensitivity: 'base'
|
|
39
|
-
});
|
|
40
|
-
let { direction: direction } = (0, $eV0xE$useLocale)();
|
|
41
|
-
let disabledBehavior = state.selectionManager.disabledBehavior;
|
|
42
|
-
let delegate = (0, $eV0xE$useMemo)(()=>keyboardDelegate || new (0, $d1c300d9c497e402$export$de9feff04fda126e)({
|
|
43
|
-
collection: state.collection,
|
|
44
|
-
disabledKeys: state.disabledKeys,
|
|
45
|
-
disabledBehavior: disabledBehavior,
|
|
46
|
-
ref: ref,
|
|
47
|
-
direction: direction,
|
|
48
|
-
collator: collator,
|
|
49
|
-
focusMode: focusMode
|
|
50
|
-
}), [
|
|
51
|
-
keyboardDelegate,
|
|
52
|
-
state.collection,
|
|
53
|
-
state.disabledKeys,
|
|
54
|
-
disabledBehavior,
|
|
55
|
-
ref,
|
|
56
|
-
direction,
|
|
57
|
-
collator,
|
|
58
|
-
focusMode
|
|
59
|
-
]);
|
|
60
|
-
let { collectionProps: collectionProps } = (0, $eV0xE$useSelectableCollection)({
|
|
61
|
-
ref: ref,
|
|
62
|
-
selectionManager: manager,
|
|
63
|
-
keyboardDelegate: delegate,
|
|
64
|
-
isVirtualized: isVirtualized,
|
|
65
|
-
scrollRef: scrollRef,
|
|
66
|
-
disallowTypeAhead: disallowTypeAhead,
|
|
67
|
-
escapeKeyBehavior: escapeKeyBehavior
|
|
68
|
-
});
|
|
69
|
-
let id = (0, $eV0xE$useId)(props.id);
|
|
70
|
-
(0, $1af922eb41e03c8f$export$e6235c0d09b995d0).set(state, {
|
|
71
|
-
keyboardDelegate: delegate,
|
|
72
|
-
actions: {
|
|
73
|
-
onRowAction: onRowAction,
|
|
74
|
-
onCellAction: onCellAction
|
|
75
|
-
},
|
|
76
|
-
shouldSelectOnPressUp: shouldSelectOnPressUp
|
|
77
|
-
});
|
|
78
|
-
let descriptionProps = (0, $5b9b5b5723db6ae1$export$be42ebdab07ae4c2)({
|
|
79
|
-
selectionManager: manager,
|
|
80
|
-
hasItemActions: !!(onRowAction || onCellAction)
|
|
81
|
-
});
|
|
82
|
-
let domProps = (0, $eV0xE$filterDOMProps)(props, {
|
|
83
|
-
labelable: true
|
|
84
|
-
});
|
|
85
|
-
let onFocus = (0, $eV0xE$useCallback)((e)=>{
|
|
86
|
-
if (manager.isFocused) {
|
|
87
|
-
// If a focus event bubbled through a portal, reset focus state.
|
|
88
|
-
if (!(0, $eV0xE$nodeContains)(e.currentTarget, e.target)) manager.setFocused(false);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
// Focus events can bubble through portals. Ignore these events.
|
|
92
|
-
if (!(0, $eV0xE$nodeContains)(e.currentTarget, e.target)) return;
|
|
93
|
-
manager.setFocused(true);
|
|
94
|
-
}, [
|
|
95
|
-
manager
|
|
96
|
-
]);
|
|
97
|
-
// Continue to track collection focused state even if keyboard navigation is disabled
|
|
98
|
-
let navDisabledHandlers = (0, $eV0xE$useMemo)(()=>({
|
|
99
|
-
onBlur: collectionProps.onBlur,
|
|
100
|
-
onFocus: onFocus
|
|
101
|
-
}), [
|
|
102
|
-
onFocus,
|
|
103
|
-
collectionProps.onBlur
|
|
104
|
-
]);
|
|
105
|
-
let hasTabbableChild = (0, $eV0xE$useHasTabbableChild)(ref, {
|
|
106
|
-
isDisabled: state.collection.size !== 0
|
|
107
|
-
});
|
|
108
|
-
let gridProps = (0, $eV0xE$mergeProps)(domProps, {
|
|
109
|
-
role: 'grid',
|
|
110
|
-
id: id,
|
|
111
|
-
'aria-multiselectable': manager.selectionMode === 'multiple' ? 'true' : undefined
|
|
112
|
-
}, state.isKeyboardNavigationDisabled ? navDisabledHandlers : collectionProps, // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.
|
|
113
|
-
state.collection.size === 0 && {
|
|
114
|
-
tabIndex: hasTabbableChild ? -1 : 0
|
|
115
|
-
} || undefined, descriptionProps);
|
|
116
|
-
if (isVirtualized) {
|
|
117
|
-
gridProps['aria-rowcount'] = state.collection.size;
|
|
118
|
-
gridProps['aria-colcount'] = state.collection.columnCount;
|
|
119
|
-
}
|
|
120
|
-
(0, $92599c3fd427b763$export$137e594ef3218a10)({
|
|
121
|
-
getRowText: getRowText
|
|
122
|
-
}, state);
|
|
123
|
-
return {
|
|
124
|
-
gridProps: gridProps
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
export {$83c6e2eafa584c67$export$f6b86a04e5d66d90 as useGrid};
|
|
130
|
-
//# sourceMappingURL=useGrid.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAuEM,SAAS,0CAAW,KAAgB,EAAE,KAAsC,EAAE,GAAkC;IACrH,IAAI,iBACF,aAAa,qBACb,iBAAiB,oBACjB,gBAAgB,aAChB,SAAS,aACT,SAAS,cACT,UAAU,eACV,WAAW,gBACX,YAAY,qBACZ,oBAAoB,yCACpB,qBAAqB,EACtB,GAAG;IACJ,IAAI,EAAC,kBAAkB,OAAO,EAAC,GAAG;IAElC,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,WAAW,CAAA,GAAA,kBAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,mBAAmB,MAAM,gBAAgB,CAAC,gBAAgB;IAC9D,IAAI,WAAW,CAAA,GAAA,cAAM,EAAE,IAAM,oBAAoB,IAAI,CAAA,GAAA,yCAAmB,EAAE;YACxE,YAAY,MAAM,UAAU;YAC5B,cAAc,MAAM,YAAY;8BAChC;iBACA;uBACA;sBACA;uBACA;QACF,IAAI;QAAC;QAAkB,MAAM,UAAU;QAAE,MAAM,YAAY;QAAE;QAAkB;QAAK;QAAW;QAAU;KAAU;IAEnH,IAAI,mBAAC,eAAe,EAAC,GAAG,CAAA,GAAA,8BAAsB,EAAE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AAK;QAAC,UAAU,mBAAmB,KAAK;IAAC,KAAM,WAC1E;IAGF,IAAI,eAAe;QACjB,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,IAAI;QAClD,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,WAAW;IAC3D;IAEA,CAAA,GAAA,yCAA2B,EAAE;oBAAC;IAAU,GAAG;IAC3C,OAAO;mBACL;IACF;AACF","sources":["packages/@react-aria/grid/src/useGrid.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 {AriaLabelingProps, DOMAttributes, DOMProps, Key, KeyboardDelegate, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, nodeContains, useId} from '@react-aria/utils';\nimport {GridCollection} from '@react-types/grid';\nimport {GridKeyboardDelegate} from './GridKeyboardDelegate';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {useCallback, useMemo} from 'react';\nimport {useCollator, useLocale} from '@react-aria/i18n';\nimport {useGridSelectionAnnouncement} from './useGridSelectionAnnouncement';\nimport {useHasTabbableChild} from '@react-aria/focus';\nimport {useHighlightSelectionDescription} from './useHighlightSelectionDescription';\nimport {useSelectableCollection} from '@react-aria/selection';\n\nexport interface GridProps extends DOMProps, AriaLabelingProps {\n /** Whether the grid uses virtual scrolling. */\n isVirtualized?: boolean,\n /**\n * Whether typeahead navigation is disabled.\n * @default false\n */\n disallowTypeAhead?: boolean,\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * Whether initial grid focus should be placed on the grid row or grid cell.\n * @default 'row'\n */\n focusMode?: 'row' | 'cell',\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 * The ref attached to the scrollable body. Used to provided automatic scrolling on item focus for non-virtualized grids.\n */\n scrollRef?: RefObject<HTMLElement | null>,\n /** Handler that is called when a user performs an action on the row. */\n onRowAction?: (key: Key) => void,\n /** Handler that is called when a user performs an action on the cell. */\n onCellAction?: (key: Key) => void,\n /**\n * Whether pressing the escape key should clear selection in the grid or not.\n *\n * Most experiences should not modify this option as it eliminates a keyboard user's ability to\n * easily clear selection. Only use if the escape key is being handled externally or should not\n * trigger selection clearing contextually.\n * @default 'clearSelection'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none',\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean\n}\n\nexport interface GridAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a grid component.\n * A grid displays data in one or more rows and columns and enables a user to navigate its contents via directional navigation keys.\n * @param props - Props for the grid.\n * @param state - State for the grid, as returned by `useGridState`.\n * @param ref - The ref attached to the grid element.\n */\nexport function useGrid<T>(props: GridProps, state: GridState<T, GridCollection<T>>, ref: RefObject<HTMLElement | null>): GridAria {\n let {\n isVirtualized,\n disallowTypeAhead,\n keyboardDelegate,\n focusMode,\n scrollRef,\n getRowText,\n onRowAction,\n onCellAction,\n escapeKeyBehavior = 'clearSelection',\n shouldSelectOnPressUp\n } = props;\n let {selectionManager: manager} = state;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let {direction} = useLocale();\n let disabledBehavior = state.selectionManager.disabledBehavior;\n let delegate = useMemo(() => keyboardDelegate || new GridKeyboardDelegate({\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n disabledBehavior,\n ref,\n direction,\n collator,\n focusMode\n }), [keyboardDelegate, state.collection, state.disabledKeys, disabledBehavior, ref, direction, collator, focusMode]);\n\n let {collectionProps} = useSelectableCollection({\n ref,\n selectionManager: manager,\n keyboardDelegate: delegate,\n isVirtualized,\n scrollRef,\n disallowTypeAhead,\n escapeKeyBehavior\n });\n\n let id = useId(props.id);\n gridMap.set(state, {keyboardDelegate: delegate, actions: {onRowAction, onCellAction}, shouldSelectOnPressUp});\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: manager,\n hasItemActions: !!(onRowAction || onCellAction)\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n let onFocus = useCallback((e) => {\n if (manager.isFocused) {\n // If a focus event bubbled through a portal, reset focus state.\n if (!nodeContains(e.currentTarget, e.target)) {\n manager.setFocused(false);\n }\n\n return;\n }\n\n // Focus events can bubble through portals. Ignore these events.\n if (!nodeContains(e.currentTarget, e.target)) {\n return;\n }\n\n manager.setFocused(true);\n }, [manager]);\n\n // Continue to track collection focused state even if keyboard navigation is disabled\n let navDisabledHandlers = useMemo(() => ({\n onBlur: collectionProps.onBlur,\n onFocus\n }), [onFocus, collectionProps.onBlur]);\n\n let hasTabbableChild = useHasTabbableChild(ref, {\n isDisabled: state.collection.size !== 0\n });\n\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable': manager.selectionMode === 'multiple' ? 'true' : undefined\n },\n state.isKeyboardNavigationDisabled ? navDisabledHandlers : collectionProps,\n // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.\n (state.collection.size === 0 && {tabIndex: hasTabbableChild ? -1 : 0}) || undefined,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = state.collection.columnCount;\n }\n\n useGridSelectionAnnouncement({getRowText}, state);\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useGrid.module.js.map"}
|