@react-aria/grid 3.14.5 → 3.14.6
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/types.d.ts.map +1 -1
- package/dist/useGridSelectionAnnouncement.main.js +14 -4
- package/dist/useGridSelectionAnnouncement.main.js.map +1 -1
- package/dist/useGridSelectionAnnouncement.mjs +14 -4
- package/dist/useGridSelectionAnnouncement.module.js +14 -4
- package/dist/useGridSelectionAnnouncement.module.js.map +1 -1
- package/package.json +9 -9
- package/src/useGridSelectionAnnouncement.ts +15 -5
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAiBA,6CAA6C,CAAC;IAC5C,UAAU,EAAE,CAAC,CAAC;IACd,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,GAAG,CAAC,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAC;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC;IACzB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gDAAgD;IAChD,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;CAC3B;AAED,kCAAkC,CAAC,EAAE,CAAC,SAAS,eAAe,CAAC,CAAC,CAAE,YAAW,gBAAgB;IAC3F,UAAU,EAAE,CAAC,CAAC;IACd,SAAS,CAAC,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC7C,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC;IAC/B,SAAS,CAAC,QAAQ,EAAE,KAAK,QAAQ,GAAG,SAAS,CAAC;IAC9C,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IACzC,SAAS,CAAC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C,GAAG,yBAAyB,CAsBjK","sources":["packages/@react-aria/grid/src/packages/@react-aria/grid/src/GridKeyboardDelegate.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/utils.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGridSelectionAnnouncement.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useHighlightSelectionDescription.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGrid.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGridRowGroup.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGridRow.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGridCell.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGridSelectionCheckbox.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/index.ts","packages/@react-aria/grid/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,"/*\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\nexport {GridKeyboardDelegate} from './GridKeyboardDelegate';\nexport {useGrid} from './useGrid';\nexport {useGridRowGroup} from './useGridRowGroup';\nexport {useGridRow} from './useGridRow';\nexport {useGridCell} from './useGridCell';\nexport {useGridSelectionCheckbox} from './useGridSelectionCheckbox';\nexport {useHighlightSelectionDescription} from './useHighlightSelectionDescription';\nexport {useGridSelectionAnnouncement} from './useGridSelectionAnnouncement';\n\nexport type {GridProps, GridAria} from './useGrid';\nexport type {GridCellAria, GridCellProps} from './useGridCell';\nexport type {GridRowGroupAria} from './useGridRowGroup';\nexport type {GridRowProps, GridRowAria} from './useGridRow';\nexport type {GridKeyboardDelegateOptions} from './GridKeyboardDelegate';\nexport type {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria} from './useGridSelectionCheckbox';\nexport type {HighlightSelectionDescriptionProps} from './useHighlightSelectionDescription';\nexport type {GridSelectionAnnouncementProps} from './useGridSelectionAnnouncement';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var $085250522aa37816$exports = require("./intlStrings.main.js");
|
|
2
2
|
var $iMOYA$reactarialiveannouncer = require("@react-aria/live-announcer");
|
|
3
|
-
var $iMOYA$reactariautils = require("@react-aria/utils");
|
|
4
|
-
var $iMOYA$reactariai18n = require("@react-aria/i18n");
|
|
5
3
|
var $iMOYA$react = require("react");
|
|
4
|
+
var $iMOYA$reactariai18n = require("@react-aria/i18n");
|
|
5
|
+
var $iMOYA$reactariautils = require("@react-aria/utils");
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
function $parcel$interopDefault(a) {
|
|
@@ -40,7 +40,7 @@ function $1eb174acfe8a0f16$export$137e594ef3218a10(props, state) {
|
|
|
40
40
|
// We do this using an ARIA live region.
|
|
41
41
|
let selection = state.selectionManager.rawSelection;
|
|
42
42
|
let lastSelection = (0, $iMOYA$react.useRef)(selection);
|
|
43
|
-
let announceSelectionChange = (0, $iMOYA$
|
|
43
|
+
let announceSelectionChange = (0, $iMOYA$react.useCallback)(()=>{
|
|
44
44
|
var _lastSelection_current;
|
|
45
45
|
if (!state.selectionManager.isFocused || selection === lastSelection.current) {
|
|
46
46
|
lastSelection.current = selection;
|
|
@@ -84,7 +84,17 @@ function $1eb174acfe8a0f16$export$137e594ef3218a10(props, state) {
|
|
|
84
84
|
}
|
|
85
85
|
if (messages.length > 0) (0, $iMOYA$reactarialiveannouncer.announce)(messages.join(' '));
|
|
86
86
|
lastSelection.current = selection;
|
|
87
|
-
}
|
|
87
|
+
}, [
|
|
88
|
+
selection,
|
|
89
|
+
state.selectionManager.selectedKeys,
|
|
90
|
+
state.selectionManager.isFocused,
|
|
91
|
+
state.selectionManager.selectionBehavior,
|
|
92
|
+
state.selectionManager.selectionMode,
|
|
93
|
+
state.collection,
|
|
94
|
+
getRowText,
|
|
95
|
+
stringFormatter
|
|
96
|
+
]);
|
|
97
|
+
// useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end
|
|
88
98
|
(0, $iMOYA$reactariautils.useUpdateEffect)(()=>{
|
|
89
99
|
if (state.selectionManager.isFocused) announceSelectionChange();
|
|
90
100
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BM,SAAS,0CAAgC,KAAqC,EAAE,KAA4B;IACjH,IAAI,cACF,aAAa,CAAC;YAAQ,gCAAA,mBAAwC;YAAxC;eAAA,CAAA,mCAAA,iCAAA,CAAA,oBAAA,MAAM,UAAU,EAAC,YAAY,cAA7B,qDAAA,oCAAA,mBAAgC,kBAAhC,6CAAA,mCAAwC,4BAAA,MAAM,UAAU,CAAC,OAAO,CAAC,kBAAzB,gDAAA,0BAA+B,SAAS;OACvG,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,oFAAoF;IACpF,wCAAwC;IACxC,IAAI,YAAY,MAAM,gBAAgB,CAAC,YAAY;IACnD,IAAI,gBAAgB,CAAA,GAAA,mBAAK,EAAE;IAC3B,IAAI,0BAA0B,CAAA,GAAA,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BM,SAAS,0CAAgC,KAAqC,EAAE,KAA4B;IACjH,IAAI,cACF,aAAa,CAAC;YAAQ,gCAAA,mBAAwC;YAAxC;eAAA,CAAA,mCAAA,iCAAA,CAAA,oBAAA,MAAM,UAAU,EAAC,YAAY,cAA7B,qDAAA,oCAAA,mBAAgC,kBAAhC,6CAAA,mCAAwC,4BAAA,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MAAM,SAAS,MAAM,OACvB,OAAO;IAGT,KAAK,IAAI,OAAO,EAAE,IAAI,GACpB,IAAI,CAAC,EAAE,GAAG,CAAC,MACT,IAAI,GAAG,CAAC;IAIZ,OAAO;AACT","sources":["packages/@react-aria/grid/src/useGridSelectionAnnouncement.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {announce} from '@react-aria/live-announcer';\nimport {Collection, Key, Node, Selection} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {SelectionManager} from '@react-stately/selection';\nimport {useCallback, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\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>): void {\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 let announceSelectionChange = useCallback(() => {\n if (!state.selectionManager.isFocused || selection === lastSelection.current) {\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: string[] = [];\n\n if ((state.selectionManager.selectedKeys.size === 1 && isReplace)) {\n let firstKey = state.selectionManager.selectedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let currentSelectionText = getRowText(firstKey);\n if (currentSelectionText) {\n messages.push(stringFormatter.format('selectedItem', {item: currentSelectionText}));\n }\n }\n } else if (addedKeys.size === 1 && removedKeys.size === 0) {\n let firstKey = addedKeys.keys().next().value;\n if (firstKey != null) {\n let addedText = getRowText(firstKey);\n if (addedText) {\n messages.push(stringFormatter.format('selectedItem', {item: addedText}));\n }\n }\n } else if (removedKeys.size === 1 && addedKeys.size === 0) {\n let firstKey = removedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let removedText = getRowText(firstKey);\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 }, [\n selection,\n state.selectionManager.selectedKeys,\n state.selectionManager.isFocused,\n state.selectionManager.selectionBehavior,\n state.selectionManager.selectionMode,\n state.collection,\n getRowText,\n stringFormatter\n ]);\n\n // useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end\n useUpdateEffect(() => {\n if (state.selectionManager.isFocused) {\n announceSelectionChange();\n } else {\n // Wait a frame in case the collection is about to become focused (e.g. on mouse down).\n let raf = requestAnimationFrame(announceSelectionChange);\n return () => cancelAnimationFrame(raf);\n }\n }, [selection, state.selectionManager.isFocused]);\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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import $4stjr$intlStringsmodulejs from "./intlStrings.mjs";
|
|
2
2
|
import {announce as $4stjr$announce} from "@react-aria/live-announcer";
|
|
3
|
-
import {
|
|
3
|
+
import {useRef as $4stjr$useRef, useCallback as $4stjr$useCallback} from "react";
|
|
4
4
|
import {useLocalizedStringFormatter as $4stjr$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
5
|
-
import {
|
|
5
|
+
import {useUpdateEffect as $4stjr$useUpdateEffect} from "@react-aria/utils";
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
function $parcel$interopDefault(a) {
|
|
@@ -34,7 +34,7 @@ function $92599c3fd427b763$export$137e594ef3218a10(props, state) {
|
|
|
34
34
|
// We do this using an ARIA live region.
|
|
35
35
|
let selection = state.selectionManager.rawSelection;
|
|
36
36
|
let lastSelection = (0, $4stjr$useRef)(selection);
|
|
37
|
-
let announceSelectionChange = (0, $4stjr$
|
|
37
|
+
let announceSelectionChange = (0, $4stjr$useCallback)(()=>{
|
|
38
38
|
var _lastSelection_current;
|
|
39
39
|
if (!state.selectionManager.isFocused || selection === lastSelection.current) {
|
|
40
40
|
lastSelection.current = selection;
|
|
@@ -78,7 +78,17 @@ function $92599c3fd427b763$export$137e594ef3218a10(props, state) {
|
|
|
78
78
|
}
|
|
79
79
|
if (messages.length > 0) (0, $4stjr$announce)(messages.join(' '));
|
|
80
80
|
lastSelection.current = selection;
|
|
81
|
-
}
|
|
81
|
+
}, [
|
|
82
|
+
selection,
|
|
83
|
+
state.selectionManager.selectedKeys,
|
|
84
|
+
state.selectionManager.isFocused,
|
|
85
|
+
state.selectionManager.selectionBehavior,
|
|
86
|
+
state.selectionManager.selectionMode,
|
|
87
|
+
state.collection,
|
|
88
|
+
getRowText,
|
|
89
|
+
stringFormatter
|
|
90
|
+
]);
|
|
91
|
+
// useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end
|
|
82
92
|
(0, $4stjr$useUpdateEffect)(()=>{
|
|
83
93
|
if (state.selectionManager.isFocused) announceSelectionChange();
|
|
84
94
|
else {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import $4stjr$intlStringsmodulejs from "./intlStrings.module.js";
|
|
2
2
|
import {announce as $4stjr$announce} from "@react-aria/live-announcer";
|
|
3
|
-
import {
|
|
3
|
+
import {useRef as $4stjr$useRef, useCallback as $4stjr$useCallback} from "react";
|
|
4
4
|
import {useLocalizedStringFormatter as $4stjr$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
5
|
-
import {
|
|
5
|
+
import {useUpdateEffect as $4stjr$useUpdateEffect} from "@react-aria/utils";
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
function $parcel$interopDefault(a) {
|
|
@@ -34,7 +34,7 @@ function $92599c3fd427b763$export$137e594ef3218a10(props, state) {
|
|
|
34
34
|
// We do this using an ARIA live region.
|
|
35
35
|
let selection = state.selectionManager.rawSelection;
|
|
36
36
|
let lastSelection = (0, $4stjr$useRef)(selection);
|
|
37
|
-
let announceSelectionChange = (0, $4stjr$
|
|
37
|
+
let announceSelectionChange = (0, $4stjr$useCallback)(()=>{
|
|
38
38
|
var _lastSelection_current;
|
|
39
39
|
if (!state.selectionManager.isFocused || selection === lastSelection.current) {
|
|
40
40
|
lastSelection.current = selection;
|
|
@@ -78,7 +78,17 @@ function $92599c3fd427b763$export$137e594ef3218a10(props, state) {
|
|
|
78
78
|
}
|
|
79
79
|
if (messages.length > 0) (0, $4stjr$announce)(messages.join(' '));
|
|
80
80
|
lastSelection.current = selection;
|
|
81
|
-
}
|
|
81
|
+
}, [
|
|
82
|
+
selection,
|
|
83
|
+
state.selectionManager.selectedKeys,
|
|
84
|
+
state.selectionManager.isFocused,
|
|
85
|
+
state.selectionManager.selectionBehavior,
|
|
86
|
+
state.selectionManager.selectionMode,
|
|
87
|
+
state.collection,
|
|
88
|
+
getRowText,
|
|
89
|
+
stringFormatter
|
|
90
|
+
]);
|
|
91
|
+
// useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end
|
|
82
92
|
(0, $4stjr$useUpdateEffect)(()=>{
|
|
83
93
|
if (state.selectionManager.isFocused) announceSelectionChange();
|
|
84
94
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BM,SAAS,0CAAgC,KAAqC,EAAE,KAA4B;IACjH,IAAI,cACF,aAAa,CAAC;YAAQ,gCAAA,mBAAwC;YAAxC;eAAA,CAAA,mCAAA,iCAAA,CAAA,oBAAA,MAAM,UAAU,EAAC,YAAY,cAA7B,qDAAA,oCAAA,mBAAgC,kBAAhC,6CAAA,mCAAwC,4BAAA,MAAM,UAAU,CAAC,OAAO,CAAC,kBAAzB,gDAAA,0BAA+B,SAAS;OACvG,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAEhE,oFAAoF;IACpF,wCAAwC;IACxC,IAAI,YAAY,MAAM,gBAAgB,CAAC,YAAY;IACnD,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAE;IAC3B,IAAI,0BAA0B,CAAA,GAAA,
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BM,SAAS,0CAAgC,KAAqC,EAAE,KAA4B;IACjH,IAAI,cACF,aAAa,CAAC;YAAQ,gCAAA,mBAAwC;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GAAG;QAAC;QAAW,MAAM,gBAAgB,CAAC,SAAS;KAAC;AAClD;AAEA,SAAS,oCAAc,CAAY,EAAE,CAAY;IAC/C,IAAI,MAAM,IAAI;IACd,IAAI,MAAM,SAAS,MAAM,OACvB,OAAO;IAGT,KAAK,IAAI,OAAO,EAAE,IAAI,GACpB,IAAI,CAAC,EAAE,GAAG,CAAC,MACT,IAAI,GAAG,CAAC;IAIZ,OAAO;AACT","sources":["packages/@react-aria/grid/src/useGridSelectionAnnouncement.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {announce} from '@react-aria/live-announcer';\nimport {Collection, Key, Node, Selection} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {SelectionManager} from '@react-stately/selection';\nimport {useCallback, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\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>): void {\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 let announceSelectionChange = useCallback(() => {\n if (!state.selectionManager.isFocused || selection === lastSelection.current) {\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: string[] = [];\n\n if ((state.selectionManager.selectedKeys.size === 1 && isReplace)) {\n let firstKey = state.selectionManager.selectedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let currentSelectionText = getRowText(firstKey);\n if (currentSelectionText) {\n messages.push(stringFormatter.format('selectedItem', {item: currentSelectionText}));\n }\n }\n } else if (addedKeys.size === 1 && removedKeys.size === 0) {\n let firstKey = addedKeys.keys().next().value;\n if (firstKey != null) {\n let addedText = getRowText(firstKey);\n if (addedText) {\n messages.push(stringFormatter.format('selectedItem', {item: addedText}));\n }\n }\n } else if (removedKeys.size === 1 && addedKeys.size === 0) {\n let firstKey = removedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let removedText = getRowText(firstKey);\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 }, [\n selection,\n state.selectionManager.selectedKeys,\n state.selectionManager.isFocused,\n state.selectionManager.selectionBehavior,\n state.selectionManager.selectionMode,\n state.collection,\n getRowText,\n stringFormatter\n ]);\n\n // useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end\n useUpdateEffect(() => {\n if (state.selectionManager.isFocused) {\n announceSelectionChange();\n } else {\n // Wait a frame in case the collection is about to become focused (e.g. on mouse down).\n let raf = requestAnimationFrame(announceSelectionChange);\n return () => cancelAnimationFrame(raf);\n }\n }, [selection, state.selectionManager.isFocused]);\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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/grid",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.6",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"url": "https://github.com/adobe/react-spectrum"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@react-aria/focus": "^3.21.
|
|
30
|
-
"@react-aria/i18n": "^3.12.
|
|
31
|
-
"@react-aria/interactions": "^3.
|
|
29
|
+
"@react-aria/focus": "^3.21.3",
|
|
30
|
+
"@react-aria/i18n": "^3.12.14",
|
|
31
|
+
"@react-aria/interactions": "^3.26.0",
|
|
32
32
|
"@react-aria/live-announcer": "^3.4.4",
|
|
33
|
-
"@react-aria/selection": "^3.
|
|
34
|
-
"@react-aria/utils": "^3.
|
|
33
|
+
"@react-aria/selection": "^3.27.0",
|
|
34
|
+
"@react-aria/utils": "^3.32.0",
|
|
35
35
|
"@react-stately/collections": "^3.12.8",
|
|
36
|
-
"@react-stately/grid": "^3.11.
|
|
37
|
-
"@react-stately/selection": "^3.20.
|
|
36
|
+
"@react-stately/grid": "^3.11.7",
|
|
37
|
+
"@react-stately/selection": "^3.20.7",
|
|
38
38
|
"@react-types/checkbox": "^3.10.2",
|
|
39
39
|
"@react-types/grid": "^3.3.6",
|
|
40
40
|
"@react-types/shared": "^3.32.1",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "4d838da5bfe36abb35aed166995a9ef63825370f"
|
|
51
51
|
}
|
|
@@ -15,9 +15,9 @@ import {Collection, Key, Node, Selection} from '@react-types/shared';
|
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
import intlMessages from '../intl/*.json';
|
|
17
17
|
import {SelectionManager} from '@react-stately/selection';
|
|
18
|
-
import {
|
|
18
|
+
import {useCallback, useRef} from 'react';
|
|
19
19
|
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
20
|
-
import {
|
|
20
|
+
import {useUpdateEffect} from '@react-aria/utils';
|
|
21
21
|
|
|
22
22
|
export interface GridSelectionAnnouncementProps {
|
|
23
23
|
/**
|
|
@@ -46,7 +46,7 @@ export function useGridSelectionAnnouncement<T>(props: GridSelectionAnnouncement
|
|
|
46
46
|
// We do this using an ARIA live region.
|
|
47
47
|
let selection = state.selectionManager.rawSelection;
|
|
48
48
|
let lastSelection = useRef(selection);
|
|
49
|
-
let announceSelectionChange =
|
|
49
|
+
let announceSelectionChange = useCallback(() => {
|
|
50
50
|
if (!state.selectionManager.isFocused || selection === lastSelection.current) {
|
|
51
51
|
lastSelection.current = selection;
|
|
52
52
|
|
|
@@ -101,8 +101,18 @@ export function useGridSelectionAnnouncement<T>(props: GridSelectionAnnouncement
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
lastSelection.current = selection;
|
|
104
|
-
}
|
|
105
|
-
|
|
104
|
+
}, [
|
|
105
|
+
selection,
|
|
106
|
+
state.selectionManager.selectedKeys,
|
|
107
|
+
state.selectionManager.isFocused,
|
|
108
|
+
state.selectionManager.selectionBehavior,
|
|
109
|
+
state.selectionManager.selectionMode,
|
|
110
|
+
state.collection,
|
|
111
|
+
getRowText,
|
|
112
|
+
stringFormatter
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
// useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end
|
|
106
116
|
useUpdateEffect(() => {
|
|
107
117
|
if (state.selectionManager.isFocused) {
|
|
108
118
|
announceSelectionChange();
|