@react-aria/grid 3.0.0-beta.1 → 3.0.0-nightly-4980928d3-240906
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 +247 -0
- package/dist/GridKeyboardDelegate.main.js.map +1 -0
- package/dist/GridKeyboardDelegate.mjs +242 -0
- package/dist/GridKeyboardDelegate.module.js +242 -0
- package/dist/GridKeyboardDelegate.module.js.map +1 -0
- package/dist/ar-AE.main.js +15 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +17 -0
- package/dist/ar-AE.module.js +17 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +15 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +17 -0
- package/dist/bg-BG.module.js +17 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/cs-CZ.main.js +15 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +17 -0
- package/dist/cs-CZ.module.js +17 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +15 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +17 -0
- package/dist/da-DK.module.js +17 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +15 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +17 -0
- package/dist/de-DE.module.js +17 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +15 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +17 -0
- package/dist/el-GR.module.js +17 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +15 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +17 -0
- package/dist/en-US.module.js +17 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +15 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +17 -0
- package/dist/es-ES.module.js +17 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +15 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +17 -0
- package/dist/et-EE.module.js +17 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +15 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +17 -0
- package/dist/fi-FI.module.js +17 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +15 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +17 -0
- package/dist/fr-FR.module.js +17 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +15 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +17 -0
- package/dist/he-IL.module.js +17 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +15 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +17 -0
- package/dist/hr-HR.module.js +17 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +15 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +17 -0
- package/dist/hu-HU.module.js +17 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +31 -0
- 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.main.js +15 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +17 -0
- package/dist/it-IT.module.js +17 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +15 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +17 -0
- package/dist/ja-JP.module.js +17 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +15 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +17 -0
- package/dist/ko-KR.module.js +17 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +15 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +17 -0
- package/dist/lt-LT.module.js +17 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +15 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +17 -0
- package/dist/lv-LV.module.js +17 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.js +23 -823
- package/dist/main.js.map +1 -1
- package/dist/module.js +10 -773
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.main.js +15 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +17 -0
- package/dist/nb-NO.module.js +17 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +15 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +17 -0
- package/dist/nl-NL.module.js +17 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +15 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +17 -0
- package/dist/pl-PL.module.js +17 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +15 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +17 -0
- package/dist/pt-BR.module.js +17 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +15 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +17 -0
- package/dist/pt-PT.module.js +17 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +15 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +17 -0
- package/dist/ro-RO.module.js +17 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +15 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +17 -0
- package/dist/ru-RU.module.js +17 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +15 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +17 -0
- package/dist/sk-SK.module.js +17 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +15 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +17 -0
- package/dist/sl-SI.module.js +17 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +15 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +17 -0
- package/dist/sr-SP.module.js +17 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +15 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +17 -0
- package/dist/sv-SE.module.js +17 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +15 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +17 -0
- package/dist/tr-TR.module.js +17 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/types.d.ts +114 -36
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.main.js +15 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +17 -0
- package/dist/uk-UA.module.js +17 -0
- package/dist/uk-UA.module.js.map +1 -0
- 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 +39 -0
- package/dist/useGridSelectionCheckbox.main.js.map +1 -0
- package/dist/useGridSelectionCheckbox.mjs +34 -0
- package/dist/useGridSelectionCheckbox.module.js +34 -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.main.js +15 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +17 -0
- package/dist/zh-CN.module.js +17 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +15 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +17 -0
- package/dist/zh-TW.module.js +17 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +23 -15
- package/src/GridKeyboardDelegate.ts +93 -83
- package/src/index.ts +17 -5
- package/src/useGrid.ts +77 -78
- package/src/useGridCell.ts +96 -46
- package/src/useGridRow.ts +32 -21
- package/src/useGridRowGroup.ts +3 -3
- package/src/useGridSelectionAnnouncement.ts +115 -0
- package/src/useGridSelectionCheckbox.ts +48 -0
- package/src/useHighlightSelectionDescription.ts +52 -0
- package/src/utils.ts +13 -3
- package/LICENSE +0 -201
|
@@ -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;;;AAoCM,SAAS,0CAAsE,KAAsB,EAAE,KAAQ,EAAE,GAAuC;QAgBlI,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, RefObject} from '@react-types/shared';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\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 | null>): 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.module.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.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":"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","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"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import $4stjr$intlStringsmodulejs from "./intlStrings.mjs";
|
|
2
|
+
import {announce as $4stjr$announce} from "@react-aria/live-announcer";
|
|
3
|
+
import {useLocalizedStringFormatter as $4stjr$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
4
|
+
import {useRef as $4stjr$useRef} from "react";
|
|
5
|
+
import {useUpdateEffect as $4stjr$useUpdateEffect} from "@react-aria/utils";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function $parcel$interopDefault(a) {
|
|
9
|
+
return a && a.__esModule ? a.default : a;
|
|
10
|
+
}
|
|
11
|
+
/*
|
|
12
|
+
* Copyright 2022 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
|
+
function $92599c3fd427b763$export$137e594ef3218a10(props, state) {
|
|
27
|
+
let { getRowText: getRowText = (key)=>{
|
|
28
|
+
var _state_collection_getTextValue, _state_collection, _state_collection_getItem;
|
|
29
|
+
var _state_collection_getTextValue1;
|
|
30
|
+
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;
|
|
31
|
+
} } = props;
|
|
32
|
+
let stringFormatter = (0, $4stjr$useLocalizedStringFormatter)((0, ($parcel$interopDefault($4stjr$intlStringsmodulejs))), '@react-aria/grid');
|
|
33
|
+
// Many screen readers do not announce when items in a grid are selected/deselected.
|
|
34
|
+
// We do this using an ARIA live region.
|
|
35
|
+
let selection = state.selectionManager.rawSelection;
|
|
36
|
+
let lastSelection = (0, $4stjr$useRef)(selection);
|
|
37
|
+
(0, $4stjr$useUpdateEffect)(()=>{
|
|
38
|
+
var _lastSelection_current;
|
|
39
|
+
if (!state.selectionManager.isFocused) {
|
|
40
|
+
lastSelection.current = selection;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let addedKeys = $92599c3fd427b763$var$diffSelection(selection, lastSelection.current);
|
|
44
|
+
let removedKeys = $92599c3fd427b763$var$diffSelection(lastSelection.current, selection);
|
|
45
|
+
// If adding or removing a single row from the selection, announce the name of that item.
|
|
46
|
+
let isReplace = state.selectionManager.selectionBehavior === 'replace';
|
|
47
|
+
let messages = [];
|
|
48
|
+
if (state.selectionManager.selectedKeys.size === 1 && isReplace) {
|
|
49
|
+
if (state.collection.getItem(state.selectionManager.selectedKeys.keys().next().value)) {
|
|
50
|
+
let currentSelectionText = getRowText(state.selectionManager.selectedKeys.keys().next().value);
|
|
51
|
+
if (currentSelectionText) messages.push(stringFormatter.format('selectedItem', {
|
|
52
|
+
item: currentSelectionText
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
} else if (addedKeys.size === 1 && removedKeys.size === 0) {
|
|
56
|
+
let addedText = getRowText(addedKeys.keys().next().value);
|
|
57
|
+
if (addedText) messages.push(stringFormatter.format('selectedItem', {
|
|
58
|
+
item: addedText
|
|
59
|
+
}));
|
|
60
|
+
} else if (removedKeys.size === 1 && addedKeys.size === 0) {
|
|
61
|
+
if (state.collection.getItem(removedKeys.keys().next().value)) {
|
|
62
|
+
let removedText = getRowText(removedKeys.keys().next().value);
|
|
63
|
+
if (removedText) messages.push(stringFormatter.format('deselectedItem', {
|
|
64
|
+
item: removedText
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Announce how many items are selected, except when selecting the first item.
|
|
69
|
+
if (state.selectionManager.selectionMode === 'multiple') {
|
|
70
|
+
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', {
|
|
71
|
+
count: selection.size
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
if (messages.length > 0) (0, $4stjr$announce)(messages.join(' '));
|
|
75
|
+
lastSelection.current = selection;
|
|
76
|
+
}, [
|
|
77
|
+
selection
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
function $92599c3fd427b763$var$diffSelection(a, b) {
|
|
81
|
+
let res = new Set();
|
|
82
|
+
if (a === 'all' || b === 'all') return res;
|
|
83
|
+
for (let key of a.keys())if (!b.has(key)) res.add(key);
|
|
84
|
+
return res;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
export {$92599c3fd427b763$export$137e594ef3218a10 as useGridSelectionAnnouncement};
|
|
89
|
+
//# sourceMappingURL=useGridSelectionAnnouncement.module.js.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import $4stjr$intlStringsmodulejs from "./intlStrings.module.js";
|
|
2
|
+
import {announce as $4stjr$announce} from "@react-aria/live-announcer";
|
|
3
|
+
import {useLocalizedStringFormatter as $4stjr$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
4
|
+
import {useRef as $4stjr$useRef} from "react";
|
|
5
|
+
import {useUpdateEffect as $4stjr$useUpdateEffect} from "@react-aria/utils";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function $parcel$interopDefault(a) {
|
|
9
|
+
return a && a.__esModule ? a.default : a;
|
|
10
|
+
}
|
|
11
|
+
/*
|
|
12
|
+
* Copyright 2022 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
|
+
function $92599c3fd427b763$export$137e594ef3218a10(props, state) {
|
|
27
|
+
let { getRowText: getRowText = (key)=>{
|
|
28
|
+
var _state_collection_getTextValue, _state_collection, _state_collection_getItem;
|
|
29
|
+
var _state_collection_getTextValue1;
|
|
30
|
+
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;
|
|
31
|
+
} } = props;
|
|
32
|
+
let stringFormatter = (0, $4stjr$useLocalizedStringFormatter)((0, ($parcel$interopDefault($4stjr$intlStringsmodulejs))), '@react-aria/grid');
|
|
33
|
+
// Many screen readers do not announce when items in a grid are selected/deselected.
|
|
34
|
+
// We do this using an ARIA live region.
|
|
35
|
+
let selection = state.selectionManager.rawSelection;
|
|
36
|
+
let lastSelection = (0, $4stjr$useRef)(selection);
|
|
37
|
+
(0, $4stjr$useUpdateEffect)(()=>{
|
|
38
|
+
var _lastSelection_current;
|
|
39
|
+
if (!state.selectionManager.isFocused) {
|
|
40
|
+
lastSelection.current = selection;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let addedKeys = $92599c3fd427b763$var$diffSelection(selection, lastSelection.current);
|
|
44
|
+
let removedKeys = $92599c3fd427b763$var$diffSelection(lastSelection.current, selection);
|
|
45
|
+
// If adding or removing a single row from the selection, announce the name of that item.
|
|
46
|
+
let isReplace = state.selectionManager.selectionBehavior === 'replace';
|
|
47
|
+
let messages = [];
|
|
48
|
+
if (state.selectionManager.selectedKeys.size === 1 && isReplace) {
|
|
49
|
+
if (state.collection.getItem(state.selectionManager.selectedKeys.keys().next().value)) {
|
|
50
|
+
let currentSelectionText = getRowText(state.selectionManager.selectedKeys.keys().next().value);
|
|
51
|
+
if (currentSelectionText) messages.push(stringFormatter.format('selectedItem', {
|
|
52
|
+
item: currentSelectionText
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
} else if (addedKeys.size === 1 && removedKeys.size === 0) {
|
|
56
|
+
let addedText = getRowText(addedKeys.keys().next().value);
|
|
57
|
+
if (addedText) messages.push(stringFormatter.format('selectedItem', {
|
|
58
|
+
item: addedText
|
|
59
|
+
}));
|
|
60
|
+
} else if (removedKeys.size === 1 && addedKeys.size === 0) {
|
|
61
|
+
if (state.collection.getItem(removedKeys.keys().next().value)) {
|
|
62
|
+
let removedText = getRowText(removedKeys.keys().next().value);
|
|
63
|
+
if (removedText) messages.push(stringFormatter.format('deselectedItem', {
|
|
64
|
+
item: removedText
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Announce how many items are selected, except when selecting the first item.
|
|
69
|
+
if (state.selectionManager.selectionMode === 'multiple') {
|
|
70
|
+
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', {
|
|
71
|
+
count: selection.size
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
if (messages.length > 0) (0, $4stjr$announce)(messages.join(' '));
|
|
75
|
+
lastSelection.current = selection;
|
|
76
|
+
}, [
|
|
77
|
+
selection
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
function $92599c3fd427b763$var$diffSelection(a, b) {
|
|
81
|
+
let res = new Set();
|
|
82
|
+
if (a === 'all' || b === 'all') return res;
|
|
83
|
+
for (let key of a.keys())if (!b.has(key)) res.add(key);
|
|
84
|
+
return res;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
export {$92599c3fd427b763$export$137e594ef3218a10 as useGridSelectionAnnouncement};
|
|
89
|
+
//# sourceMappingURL=useGridSelectionAnnouncement.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"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","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.module.js.map"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var $085250522aa37816$exports = require("./intlStrings.main.js");
|
|
2
|
+
var $kbAeD$reactariautils = require("@react-aria/utils");
|
|
3
|
+
var $kbAeD$reactariai18n = require("@react-aria/i18n");
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$interopDefault(a) {
|
|
7
|
+
return a && a.__esModule ? a.default : a;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function $parcel$export(e, n, v, s) {
|
|
11
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
$parcel$export(module.exports, "useGridSelectionCheckbox", () => $d8385f73d3701365$export$70e2eed1a92976ad);
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function $d8385f73d3701365$export$70e2eed1a92976ad(props, state) {
|
|
19
|
+
let { key: key } = props;
|
|
20
|
+
let manager = state.selectionManager;
|
|
21
|
+
let checkboxId = (0, $kbAeD$reactariautils.useId)();
|
|
22
|
+
let isDisabled = !state.selectionManager.canSelectItem(key);
|
|
23
|
+
let isSelected = state.selectionManager.isSelected(key);
|
|
24
|
+
// Checkbox should always toggle selection, regardless of selectionBehavior.
|
|
25
|
+
let onChange = ()=>manager.toggleSelection(key);
|
|
26
|
+
const stringFormatter = (0, $kbAeD$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($085250522aa37816$exports))), '@react-aria/grid');
|
|
27
|
+
return {
|
|
28
|
+
checkboxProps: {
|
|
29
|
+
id: checkboxId,
|
|
30
|
+
'aria-label': stringFormatter.format('select'),
|
|
31
|
+
isSelected: isSelected,
|
|
32
|
+
isDisabled: isDisabled,
|
|
33
|
+
onChange: onChange
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=useGridSelectionCheckbox.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAyBO,SAAS,0CAAyD,KAAqC,EAAE,KAAsB;IACpI,IAAI,OAAC,GAAG,EAAC,GAAG;IAEZ,IAAI,UAAU,MAAM,gBAAgB;IACpC,IAAI,aAAa,CAAA,GAAA,2BAAI;IACrB,IAAI,aAAa,CAAC,MAAM,gBAAgB,CAAC,aAAa,CAAC;IACvD,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC;IAEnD,4EAA4E;IAC5E,IAAI,WAAW,IAAM,QAAQ,eAAe,CAAC;IAE7C,MAAM,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAElE,OAAO;QACL,eAAe;YACb,IAAI;YACJ,cAAc,gBAAgB,MAAM,CAAC;wBACrC;wBACA;sBACA;QACF;IACF;AACF","sources":["packages/@react-aria/grid/src/useGridSelectionCheckbox.ts"],"sourcesContent":["import {AriaCheckboxProps} from '@react-types/checkbox';\nimport {GridCollection} from '@react-types/grid';\nimport {GridState} from '@react-stately/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {Key} from '@react-types/shared';\nimport {useId} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaGridSelectionCheckboxProps {\n /** A unique key for the checkbox. */\n key: Key\n}\n\nexport interface GridSelectionCheckboxAria {\n /** Props for the row selection checkbox element. */\n checkboxProps: AriaCheckboxProps\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid.\n * @param props - Props for the selection checkbox.\n * @param state - State of the grid, as returned by `useGridState`.\n */\nexport function useGridSelectionCheckbox<T, C extends GridCollection<T>>(props: AriaGridSelectionCheckboxProps, state: GridState<T, C>): GridSelectionCheckboxAria {\n let {key} = props;\n\n let manager = state.selectionManager;\n let checkboxId = useId();\n let isDisabled = !state.selectionManager.canSelectItem(key);\n let isSelected = state.selectionManager.isSelected(key);\n\n // Checkbox should always toggle selection, regardless of selectionBehavior.\n let onChange = () => manager.toggleSelection(key);\n\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n return {\n checkboxProps: {\n id: checkboxId,\n 'aria-label': stringFormatter.format('select'),\n isSelected,\n isDisabled,\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridSelectionCheckbox.main.js.map"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import $fkdHx$intlStringsmodulejs from "./intlStrings.mjs";
|
|
2
|
+
import {useId as $fkdHx$useId} from "@react-aria/utils";
|
|
3
|
+
import {useLocalizedStringFormatter as $fkdHx$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$interopDefault(a) {
|
|
7
|
+
return a && a.__esModule ? a.default : a;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
function $7cb39d07f245a780$export$70e2eed1a92976ad(props, state) {
|
|
13
|
+
let { key: key } = props;
|
|
14
|
+
let manager = state.selectionManager;
|
|
15
|
+
let checkboxId = (0, $fkdHx$useId)();
|
|
16
|
+
let isDisabled = !state.selectionManager.canSelectItem(key);
|
|
17
|
+
let isSelected = state.selectionManager.isSelected(key);
|
|
18
|
+
// Checkbox should always toggle selection, regardless of selectionBehavior.
|
|
19
|
+
let onChange = ()=>manager.toggleSelection(key);
|
|
20
|
+
const stringFormatter = (0, $fkdHx$useLocalizedStringFormatter)((0, ($parcel$interopDefault($fkdHx$intlStringsmodulejs))), '@react-aria/grid');
|
|
21
|
+
return {
|
|
22
|
+
checkboxProps: {
|
|
23
|
+
id: checkboxId,
|
|
24
|
+
'aria-label': stringFormatter.format('select'),
|
|
25
|
+
isSelected: isSelected,
|
|
26
|
+
isDisabled: isDisabled,
|
|
27
|
+
onChange: onChange
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export {$7cb39d07f245a780$export$70e2eed1a92976ad as useGridSelectionCheckbox};
|
|
34
|
+
//# sourceMappingURL=useGridSelectionCheckbox.module.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import $fkdHx$intlStringsmodulejs from "./intlStrings.module.js";
|
|
2
|
+
import {useId as $fkdHx$useId} from "@react-aria/utils";
|
|
3
|
+
import {useLocalizedStringFormatter as $fkdHx$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$interopDefault(a) {
|
|
7
|
+
return a && a.__esModule ? a.default : a;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
function $7cb39d07f245a780$export$70e2eed1a92976ad(props, state) {
|
|
13
|
+
let { key: key } = props;
|
|
14
|
+
let manager = state.selectionManager;
|
|
15
|
+
let checkboxId = (0, $fkdHx$useId)();
|
|
16
|
+
let isDisabled = !state.selectionManager.canSelectItem(key);
|
|
17
|
+
let isSelected = state.selectionManager.isSelected(key);
|
|
18
|
+
// Checkbox should always toggle selection, regardless of selectionBehavior.
|
|
19
|
+
let onChange = ()=>manager.toggleSelection(key);
|
|
20
|
+
const stringFormatter = (0, $fkdHx$useLocalizedStringFormatter)((0, ($parcel$interopDefault($fkdHx$intlStringsmodulejs))), '@react-aria/grid');
|
|
21
|
+
return {
|
|
22
|
+
checkboxProps: {
|
|
23
|
+
id: checkboxId,
|
|
24
|
+
'aria-label': stringFormatter.format('select'),
|
|
25
|
+
isSelected: isSelected,
|
|
26
|
+
isDisabled: isDisabled,
|
|
27
|
+
onChange: onChange
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export {$7cb39d07f245a780$export$70e2eed1a92976ad as useGridSelectionCheckbox};
|
|
34
|
+
//# sourceMappingURL=useGridSelectionCheckbox.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAyBO,SAAS,0CAAyD,KAAqC,EAAE,KAAsB;IACpI,IAAI,OAAC,GAAG,EAAC,GAAG;IAEZ,IAAI,UAAU,MAAM,gBAAgB;IACpC,IAAI,aAAa,CAAA,GAAA,YAAI;IACrB,IAAI,aAAa,CAAC,MAAM,gBAAgB,CAAC,aAAa,CAAC;IACvD,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC;IAEnD,4EAA4E;IAC5E,IAAI,WAAW,IAAM,QAAQ,eAAe,CAAC;IAE7C,MAAM,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAElE,OAAO;QACL,eAAe;YACb,IAAI;YACJ,cAAc,gBAAgB,MAAM,CAAC;wBACrC;wBACA;sBACA;QACF;IACF;AACF","sources":["packages/@react-aria/grid/src/useGridSelectionCheckbox.ts"],"sourcesContent":["import {AriaCheckboxProps} from '@react-types/checkbox';\nimport {GridCollection} from '@react-types/grid';\nimport {GridState} from '@react-stately/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {Key} from '@react-types/shared';\nimport {useId} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaGridSelectionCheckboxProps {\n /** A unique key for the checkbox. */\n key: Key\n}\n\nexport interface GridSelectionCheckboxAria {\n /** Props for the row selection checkbox element. */\n checkboxProps: AriaCheckboxProps\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid.\n * @param props - Props for the selection checkbox.\n * @param state - State of the grid, as returned by `useGridState`.\n */\nexport function useGridSelectionCheckbox<T, C extends GridCollection<T>>(props: AriaGridSelectionCheckboxProps, state: GridState<T, C>): GridSelectionCheckboxAria {\n let {key} = props;\n\n let manager = state.selectionManager;\n let checkboxId = useId();\n let isDisabled = !state.selectionManager.canSelectItem(key);\n let isSelected = state.selectionManager.isSelected(key);\n\n // Checkbox should always toggle selection, regardless of selectionBehavior.\n let onChange = () => manager.toggleSelection(key);\n\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n return {\n checkboxProps: {\n id: checkboxId,\n 'aria-label': stringFormatter.format('select'),\n isSelected,\n isDisabled,\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridSelectionCheckbox.module.js.map"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var $085250522aa37816$exports = require("./intlStrings.main.js");
|
|
2
|
+
var $98baH$reactariautils = require("@react-aria/utils");
|
|
3
|
+
var $98baH$reactariainteractions = require("@react-aria/interactions");
|
|
4
|
+
var $98baH$reactariai18n = require("@react-aria/i18n");
|
|
5
|
+
var $98baH$react = require("react");
|
|
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, "useHighlightSelectionDescription", () => $340f2fcd0ef9ce8d$export$be42ebdab07ae4c2);
|
|
17
|
+
/*
|
|
18
|
+
* Copyright 2021 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 $340f2fcd0ef9ce8d$export$be42ebdab07ae4c2(props) {
|
|
33
|
+
let stringFormatter = (0, $98baH$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($085250522aa37816$exports))), '@react-aria/grid');
|
|
34
|
+
let modality = (0, $98baH$reactariainteractions.useInteractionModality)();
|
|
35
|
+
// null is the default if the user hasn't interacted with the table at all yet or the rest of the page
|
|
36
|
+
let shouldLongPress = (modality === 'pointer' || modality === 'virtual' || modality == null) && typeof window !== 'undefined' && 'ontouchstart' in window;
|
|
37
|
+
let interactionDescription = (0, $98baH$react.useMemo)(()=>{
|
|
38
|
+
let selectionMode = props.selectionManager.selectionMode;
|
|
39
|
+
let selectionBehavior = props.selectionManager.selectionBehavior;
|
|
40
|
+
let message = undefined;
|
|
41
|
+
if (shouldLongPress) message = stringFormatter.format('longPressToSelect');
|
|
42
|
+
return selectionBehavior === 'replace' && selectionMode !== 'none' && props.hasItemActions ? message : undefined;
|
|
43
|
+
}, [
|
|
44
|
+
props.selectionManager.selectionMode,
|
|
45
|
+
props.selectionManager.selectionBehavior,
|
|
46
|
+
props.hasItemActions,
|
|
47
|
+
stringFormatter,
|
|
48
|
+
shouldLongPress
|
|
49
|
+
]);
|
|
50
|
+
let descriptionProps = (0, $98baH$reactariautils.useDescription)(interactionDescription);
|
|
51
|
+
return descriptionProps;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=useHighlightSelectionDescription.main.js.map
|