@react-aria/grid 3.2.7-nightly.3249 → 3.2.7-nightly.3262

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/module.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {Rect as $cVkRF$Rect} from "@react-stately/virtualizer";
2
- import {announce as $cVkRF$announce} from "@react-aria/live-announcer";
3
2
  import {useId as $cVkRF$useId, filterDOMProps as $cVkRF$filterDOMProps, mergeProps as $cVkRF$mergeProps, useUpdateEffect as $cVkRF$useUpdateEffect, useDescription as $cVkRF$useDescription} from "@react-aria/utils";
4
3
  import {useMemo as $cVkRF$useMemo, useRef as $cVkRF$useRef} from "react";
5
- import {useMessageFormatter as $cVkRF$useMessageFormatter, useCollator as $cVkRF$useCollator, useLocale as $cVkRF$useLocale} from "@react-aria/i18n";
4
+ import {useCollator as $cVkRF$useCollator, useLocale as $cVkRF$useLocale, useMessageFormatter as $cVkRF$useMessageFormatter} from "@react-aria/i18n";
6
5
  import {useSelectableCollection as $cVkRF$useSelectableCollection, useSelectableItem as $cVkRF$useSelectableItem} from "@react-aria/selection";
6
+ import {announce as $cVkRF$announce} from "@react-aria/live-announcer";
7
7
  import {useInteractionModality as $cVkRF$useInteractionModality, isFocusVisible as $cVkRF$isFocusVisible} from "@react-aria/interactions";
8
8
  import {getFocusableTreeWalker as $cVkRF$getFocusableTreeWalker, focusSafely as $cVkRF$focusSafely} from "@react-aria/focus";
9
9
 
@@ -269,11 +269,15 @@ var $83c6e2eafa584c67$exports = {};
269
269
  $parcel$export($83c6e2eafa584c67$exports, "useGrid", () => $83c6e2eafa584c67$export$f6b86a04e5d66d90);
270
270
 
271
271
 
272
-
273
272
  const $1af922eb41e03c8f$export$e6235c0d09b995d0 = new WeakMap();
274
273
 
275
274
 
276
275
 
276
+
277
+ var $92599c3fd427b763$exports = {};
278
+
279
+ $parcel$export($92599c3fd427b763$exports, "useGridSelectionAnnouncement", () => $92599c3fd427b763$export$137e594ef3218a10);
280
+
277
281
  var $1dbe5ffd32adb38c$exports = {};
278
282
  var $682989befd4f478d$exports = {};
279
283
  $682989befd4f478d$exports = JSON.parse("{\"deselectedItem\":\"{item} غير المحدد\",\"longPressToSelect\":\"اضغط مطولًا للدخول إلى وضع التحديد.\",\"select\":\"تحديد\",\"selectedAll\":\"جميع العناصر المحددة.\",\"selectedCount\":\"{count, plural, =0 {لم يتم تحديد عناصر} one {# عنصر محدد} other {# عنصر محدد}}.\",\"selectedItem\":\"{item} المحدد\"}");
@@ -452,6 +456,72 @@ $1dbe5ffd32adb38c$exports = {
452
456
 
453
457
 
454
458
 
459
+ function $92599c3fd427b763$export$137e594ef3218a10(props, state) {
460
+ let { getRowText: getRowText = (key)=>{
461
+ var ref;
462
+ return (ref = state.collection.getItem(key)) === null || ref === void 0 ? void 0 : ref.textValue;
463
+ } } = props;
464
+ let formatMessage = $cVkRF$useMessageFormatter((/*@__PURE__*/$parcel$interopDefault($1dbe5ffd32adb38c$exports)));
465
+ // Many screen readers do not announce when items in a grid are selected/deselected.
466
+ // We do this using an ARIA live region.
467
+ let selection = state.selectionManager.rawSelection;
468
+ let lastSelection = $cVkRF$useRef(selection);
469
+ $cVkRF$useUpdateEffect(()=>{
470
+ var ref;
471
+ if (!state.selectionManager.isFocused) {
472
+ lastSelection.current = selection;
473
+ return;
474
+ }
475
+ let addedKeys = $92599c3fd427b763$var$diffSelection(selection, lastSelection.current);
476
+ let removedKeys = $92599c3fd427b763$var$diffSelection(lastSelection.current, selection);
477
+ // If adding or removing a single row from the selection, announce the name of that item.
478
+ let isReplace = state.selectionManager.selectionBehavior === 'replace';
479
+ let messages = [];
480
+ if (state.selectionManager.selectedKeys.size === 1 && isReplace) {
481
+ if (state.collection.getItem(state.selectionManager.selectedKeys.keys().next().value)) {
482
+ let currentSelectionText = getRowText(state.selectionManager.selectedKeys.keys().next().value);
483
+ if (currentSelectionText) messages.push(formatMessage('selectedItem', {
484
+ item: currentSelectionText
485
+ }));
486
+ }
487
+ } else if (addedKeys.size === 1 && removedKeys.size === 0) {
488
+ let addedText = getRowText(addedKeys.keys().next().value);
489
+ if (addedText) messages.push(formatMessage('selectedItem', {
490
+ item: addedText
491
+ }));
492
+ } else if (removedKeys.size === 1 && addedKeys.size === 0) {
493
+ if (state.collection.getItem(removedKeys.keys().next().value)) {
494
+ let removedText = getRowText(removedKeys.keys().next().value);
495
+ if (removedText) messages.push(formatMessage('deselectedItem', {
496
+ item: removedText
497
+ }));
498
+ }
499
+ }
500
+ // Announce how many items are selected, except when selecting the first item.
501
+ if (state.selectionManager.selectionMode === 'multiple') {
502
+ if (messages.length === 0 || selection === 'all' || selection.size > 1 || lastSelection.current === 'all' || ((ref = lastSelection.current) === null || ref === void 0 ? void 0 : ref.size) > 1) messages.push(selection === 'all' ? formatMessage('selectedAll') : formatMessage('selectedCount', {
503
+ count: selection.size
504
+ }));
505
+ }
506
+ if (messages.length > 0) $cVkRF$announce(messages.join(' '));
507
+ lastSelection.current = selection;
508
+ }, [
509
+ selection
510
+ ]);
511
+ }
512
+ function $92599c3fd427b763$var$diffSelection(a, b) {
513
+ let res = new Set();
514
+ if (a === 'all' || b === 'all') return res;
515
+ for (let key of a.keys())if (!b.has(key)) res.add(key);
516
+ return res;
517
+ }
518
+
519
+
520
+ var $5b9b5b5723db6ae1$exports = {};
521
+
522
+ $parcel$export($5b9b5b5723db6ae1$exports, "useHighlightSelectionDescription", () => $5b9b5b5723db6ae1$export$be42ebdab07ae4c2);
523
+
524
+
455
525
 
456
526
 
457
527
 
@@ -479,12 +549,8 @@ function $5b9b5b5723db6ae1$export$be42ebdab07ae4c2(props) {
479
549
 
480
550
 
481
551
 
482
- function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref1) {
483
- let { isVirtualized: isVirtualized , keyboardDelegate: keyboardDelegate , focusMode: focusMode , getRowText: getRowText = (key)=>{
484
- var ref;
485
- return (ref = state.collection.getItem(key)) === null || ref === void 0 ? void 0 : ref.textValue;
486
- } , scrollRef: scrollRef , onRowAction: onRowAction , onCellAction: onCellAction } = props;
487
- let formatMessage = $cVkRF$useMessageFormatter((/*@__PURE__*/$parcel$interopDefault($1dbe5ffd32adb38c$exports)));
552
+ function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref) {
553
+ let { isVirtualized: isVirtualized , keyboardDelegate: keyboardDelegate , focusMode: focusMode , scrollRef: scrollRef , getRowText: getRowText , onRowAction: onRowAction , onCellAction: onCellAction } = props;
488
554
  if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
489
555
  // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
490
556
  // When virtualized, the layout object will be passed in as a prop and override this.
@@ -496,7 +562,7 @@ function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref1) {
496
562
  let delegate = $cVkRF$useMemo(()=>keyboardDelegate || new $d1c300d9c497e402$export$de9feff04fda126e({
497
563
  collection: state.collection,
498
564
  disabledKeys: state.disabledKeys,
499
- ref: ref1,
565
+ ref: ref,
500
566
  direction: direction,
501
567
  collator: collator,
502
568
  focusMode: focusMode
@@ -505,13 +571,13 @@ function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref1) {
505
571
  keyboardDelegate,
506
572
  state.collection,
507
573
  state.disabledKeys,
508
- ref1,
574
+ ref,
509
575
  direction,
510
576
  collator,
511
577
  focusMode
512
578
  ]);
513
579
  let { collectionProps: collectionProps } = $cVkRF$useSelectableCollection({
514
- ref: ref1,
580
+ ref: ref,
515
581
  selectionManager: state.selectionManager,
516
582
  keyboardDelegate: delegate,
517
583
  isVirtualized: isVirtualized,
@@ -541,62 +607,13 @@ function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref1) {
541
607
  gridProps['aria-rowcount'] = state.collection.size;
542
608
  gridProps['aria-colcount'] = state.collection.columnCount;
543
609
  }
544
- // Many screen readers do not announce when items in a grid are selected/deselected.
545
- // We do this using an ARIA live region.
546
- let selection = state.selectionManager.rawSelection;
547
- let lastSelection = $cVkRF$useRef(selection);
548
- $cVkRF$useUpdateEffect(()=>{
549
- var ref;
550
- if (!state.selectionManager.isFocused) {
551
- lastSelection.current = selection;
552
- return;
553
- }
554
- let addedKeys = $83c6e2eafa584c67$var$diffSelection(selection, lastSelection.current);
555
- let removedKeys = $83c6e2eafa584c67$var$diffSelection(lastSelection.current, selection);
556
- // If adding or removing a single row from the selection, announce the name of that item.
557
- let isReplace = state.selectionManager.selectionBehavior === 'replace';
558
- let messages = [];
559
- if (state.selectionManager.selectedKeys.size === 1 && isReplace) {
560
- if (state.collection.getItem(state.selectionManager.selectedKeys.keys().next().value)) {
561
- let currentSelectionText = getRowText(state.selectionManager.selectedKeys.keys().next().value);
562
- if (currentSelectionText) messages.push(formatMessage('selectedItem', {
563
- item: currentSelectionText
564
- }));
565
- }
566
- } else if (addedKeys.size === 1 && removedKeys.size === 0) {
567
- let addedText = getRowText(addedKeys.keys().next().value);
568
- if (addedText) messages.push(formatMessage('selectedItem', {
569
- item: addedText
570
- }));
571
- } else if (removedKeys.size === 1 && addedKeys.size === 0) {
572
- if (state.collection.getItem(removedKeys.keys().next().value)) {
573
- let removedText = getRowText(removedKeys.keys().next().value);
574
- if (removedText) messages.push(formatMessage('deselectedItem', {
575
- item: removedText
576
- }));
577
- }
578
- }
579
- // Announce how many items are selected, except when selecting the first item.
580
- if (state.selectionManager.selectionMode === 'multiple') {
581
- if (messages.length === 0 || selection === 'all' || selection.size > 1 || lastSelection.current === 'all' || ((ref = lastSelection.current) === null || ref === void 0 ? void 0 : ref.size) > 1) messages.push(selection === 'all' ? formatMessage('selectedAll') : formatMessage('selectedCount', {
582
- count: selection.size
583
- }));
584
- }
585
- if (messages.length > 0) $cVkRF$announce(messages.join(' '));
586
- lastSelection.current = selection;
587
- }, [
588
- selection
589
- ]);
610
+ $92599c3fd427b763$export$137e594ef3218a10({
611
+ getRowText: getRowText
612
+ }, state);
590
613
  return {
591
614
  gridProps: gridProps
592
615
  };
593
616
  }
594
- function $83c6e2eafa584c67$var$diffSelection(a, b) {
595
- let res = new Set();
596
- if (a === 'all' || b === 'all') return res;
597
- for (let key of a.keys())if (!b.has(key)) res.add(key);
598
- return res;
599
- }
600
617
 
601
618
 
602
619
  var $e45487f8ba1cbdbf$exports = {};
@@ -819,5 +836,7 @@ function $7cb39d07f245a780$export$70e2eed1a92976ad(props, state) {
819
836
 
820
837
 
821
838
 
822
- export {$d1c300d9c497e402$export$de9feff04fda126e as GridKeyboardDelegate, $83c6e2eafa584c67$export$f6b86a04e5d66d90 as useGrid, $e45487f8ba1cbdbf$export$d3037f5d3f3e51bf as useGridRowGroup, $4159a7a9cbb0cc18$export$96357d5a73f686fa as useGridRow, $ab90dcbc1b5466d0$export$c7e10bfc0c59f67c as useGridCell, $7cb39d07f245a780$export$70e2eed1a92976ad as useGridSelectionCheckbox};
839
+
840
+
841
+ export {$d1c300d9c497e402$export$de9feff04fda126e as GridKeyboardDelegate, $83c6e2eafa584c67$export$f6b86a04e5d66d90 as useGrid, $e45487f8ba1cbdbf$export$d3037f5d3f3e51bf as useGridRowGroup, $4159a7a9cbb0cc18$export$96357d5a73f686fa as useGridRow, $ab90dcbc1b5466d0$export$c7e10bfc0c59f67c as useGridCell, $7cb39d07f245a780$export$70e2eed1a92976ad as useGridSelectionCheckbox, $5b9b5b5723db6ae1$export$be42ebdab07ae4c2 as useHighlightSelectionDescription, $92599c3fd427b763$export$137e594ef3218a10 as useGridSelectionAnnouncement};
823
842
  //# sourceMappingURL=module.js.map