@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/main.js CHANGED
@@ -1,9 +1,9 @@
1
1
  var $2oePb$reactstatelyvirtualizer = require("@react-stately/virtualizer");
2
- var $2oePb$reactarialiveannouncer = require("@react-aria/live-announcer");
3
2
  var $2oePb$reactariautils = require("@react-aria/utils");
4
3
  var $2oePb$react = require("react");
5
4
  var $2oePb$reactariai18n = require("@react-aria/i18n");
6
5
  var $2oePb$reactariaselection = require("@react-aria/selection");
6
+ var $2oePb$reactarialiveannouncer = require("@react-aria/live-announcer");
7
7
  var $2oePb$reactariainteractions = require("@react-aria/interactions");
8
8
  var $2oePb$reactariafocus = require("@react-aria/focus");
9
9
 
@@ -285,11 +285,15 @@ var $11d770dfabe45077$exports = {};
285
285
  $parcel$export($11d770dfabe45077$exports, "useGrid", () => $11d770dfabe45077$export$f6b86a04e5d66d90);
286
286
 
287
287
 
288
-
289
288
  const $8ee34951196858d0$export$e6235c0d09b995d0 = new WeakMap();
290
289
 
291
290
 
292
291
 
292
+
293
+ var $1eb174acfe8a0f16$exports = {};
294
+
295
+ $parcel$export($1eb174acfe8a0f16$exports, "useGridSelectionAnnouncement", () => $1eb174acfe8a0f16$export$137e594ef3218a10);
296
+
293
297
  var $cba28e4266d77056$exports = {};
294
298
  var $6f42661ae0214332$exports = {};
295
299
  $6f42661ae0214332$exports = JSON.parse("{\"deselectedItem\":\"{item} غير المحدد\",\"longPressToSelect\":\"اضغط مطولًا للدخول إلى وضع التحديد.\",\"select\":\"تحديد\",\"selectedAll\":\"جميع العناصر المحددة.\",\"selectedCount\":\"{count, plural, =0 {لم يتم تحديد عناصر} one {# عنصر محدد} other {# عنصر محدد}}.\",\"selectedItem\":\"{item} المحدد\"}");
@@ -468,6 +472,72 @@ $cba28e4266d77056$exports = {
468
472
 
469
473
 
470
474
 
475
+ function $1eb174acfe8a0f16$export$137e594ef3218a10(props, state) {
476
+ let { getRowText: getRowText = (key)=>{
477
+ var ref;
478
+ return (ref = state.collection.getItem(key)) === null || ref === void 0 ? void 0 : ref.textValue;
479
+ } } = props;
480
+ let formatMessage = $2oePb$reactariai18n.useMessageFormatter((/*@__PURE__*/$parcel$interopDefault($cba28e4266d77056$exports)));
481
+ // Many screen readers do not announce when items in a grid are selected/deselected.
482
+ // We do this using an ARIA live region.
483
+ let selection = state.selectionManager.rawSelection;
484
+ let lastSelection = $2oePb$react.useRef(selection);
485
+ $2oePb$reactariautils.useUpdateEffect(()=>{
486
+ var ref;
487
+ if (!state.selectionManager.isFocused) {
488
+ lastSelection.current = selection;
489
+ return;
490
+ }
491
+ let addedKeys = $1eb174acfe8a0f16$var$diffSelection(selection, lastSelection.current);
492
+ let removedKeys = $1eb174acfe8a0f16$var$diffSelection(lastSelection.current, selection);
493
+ // If adding or removing a single row from the selection, announce the name of that item.
494
+ let isReplace = state.selectionManager.selectionBehavior === 'replace';
495
+ let messages = [];
496
+ if (state.selectionManager.selectedKeys.size === 1 && isReplace) {
497
+ if (state.collection.getItem(state.selectionManager.selectedKeys.keys().next().value)) {
498
+ let currentSelectionText = getRowText(state.selectionManager.selectedKeys.keys().next().value);
499
+ if (currentSelectionText) messages.push(formatMessage('selectedItem', {
500
+ item: currentSelectionText
501
+ }));
502
+ }
503
+ } else if (addedKeys.size === 1 && removedKeys.size === 0) {
504
+ let addedText = getRowText(addedKeys.keys().next().value);
505
+ if (addedText) messages.push(formatMessage('selectedItem', {
506
+ item: addedText
507
+ }));
508
+ } else if (removedKeys.size === 1 && addedKeys.size === 0) {
509
+ if (state.collection.getItem(removedKeys.keys().next().value)) {
510
+ let removedText = getRowText(removedKeys.keys().next().value);
511
+ if (removedText) messages.push(formatMessage('deselectedItem', {
512
+ item: removedText
513
+ }));
514
+ }
515
+ }
516
+ // Announce how many items are selected, except when selecting the first item.
517
+ if (state.selectionManager.selectionMode === 'multiple') {
518
+ 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', {
519
+ count: selection.size
520
+ }));
521
+ }
522
+ if (messages.length > 0) $2oePb$reactarialiveannouncer.announce(messages.join(' '));
523
+ lastSelection.current = selection;
524
+ }, [
525
+ selection
526
+ ]);
527
+ }
528
+ function $1eb174acfe8a0f16$var$diffSelection(a, b) {
529
+ let res = new Set();
530
+ if (a === 'all' || b === 'all') return res;
531
+ for (let key of a.keys())if (!b.has(key)) res.add(key);
532
+ return res;
533
+ }
534
+
535
+
536
+ var $340f2fcd0ef9ce8d$exports = {};
537
+
538
+ $parcel$export($340f2fcd0ef9ce8d$exports, "useHighlightSelectionDescription", () => $340f2fcd0ef9ce8d$export$be42ebdab07ae4c2);
539
+
540
+
471
541
 
472
542
 
473
543
 
@@ -495,12 +565,8 @@ function $340f2fcd0ef9ce8d$export$be42ebdab07ae4c2(props) {
495
565
 
496
566
 
497
567
 
498
- function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref1) {
499
- let { isVirtualized: isVirtualized , keyboardDelegate: keyboardDelegate , focusMode: focusMode , getRowText: getRowText = (key)=>{
500
- var ref;
501
- return (ref = state.collection.getItem(key)) === null || ref === void 0 ? void 0 : ref.textValue;
502
- } , scrollRef: scrollRef , onRowAction: onRowAction , onCellAction: onCellAction } = props;
503
- let formatMessage = $2oePb$reactariai18n.useMessageFormatter((/*@__PURE__*/$parcel$interopDefault($cba28e4266d77056$exports)));
568
+ function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref) {
569
+ let { isVirtualized: isVirtualized , keyboardDelegate: keyboardDelegate , focusMode: focusMode , scrollRef: scrollRef , getRowText: getRowText , onRowAction: onRowAction , onCellAction: onCellAction } = props;
504
570
  if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
505
571
  // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
506
572
  // When virtualized, the layout object will be passed in as a prop and override this.
@@ -512,7 +578,7 @@ function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref1) {
512
578
  let delegate = $2oePb$react.useMemo(()=>keyboardDelegate || new $3187c0e19200cb16$export$de9feff04fda126e({
513
579
  collection: state.collection,
514
580
  disabledKeys: state.disabledKeys,
515
- ref: ref1,
581
+ ref: ref,
516
582
  direction: direction,
517
583
  collator: collator,
518
584
  focusMode: focusMode
@@ -521,13 +587,13 @@ function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref1) {
521
587
  keyboardDelegate,
522
588
  state.collection,
523
589
  state.disabledKeys,
524
- ref1,
590
+ ref,
525
591
  direction,
526
592
  collator,
527
593
  focusMode
528
594
  ]);
529
595
  let { collectionProps: collectionProps } = $2oePb$reactariaselection.useSelectableCollection({
530
- ref: ref1,
596
+ ref: ref,
531
597
  selectionManager: state.selectionManager,
532
598
  keyboardDelegate: delegate,
533
599
  isVirtualized: isVirtualized,
@@ -557,62 +623,13 @@ function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref1) {
557
623
  gridProps['aria-rowcount'] = state.collection.size;
558
624
  gridProps['aria-colcount'] = state.collection.columnCount;
559
625
  }
560
- // Many screen readers do not announce when items in a grid are selected/deselected.
561
- // We do this using an ARIA live region.
562
- let selection = state.selectionManager.rawSelection;
563
- let lastSelection = $2oePb$react.useRef(selection);
564
- $2oePb$reactariautils.useUpdateEffect(()=>{
565
- var ref;
566
- if (!state.selectionManager.isFocused) {
567
- lastSelection.current = selection;
568
- return;
569
- }
570
- let addedKeys = $11d770dfabe45077$var$diffSelection(selection, lastSelection.current);
571
- let removedKeys = $11d770dfabe45077$var$diffSelection(lastSelection.current, selection);
572
- // If adding or removing a single row from the selection, announce the name of that item.
573
- let isReplace = state.selectionManager.selectionBehavior === 'replace';
574
- let messages = [];
575
- if (state.selectionManager.selectedKeys.size === 1 && isReplace) {
576
- if (state.collection.getItem(state.selectionManager.selectedKeys.keys().next().value)) {
577
- let currentSelectionText = getRowText(state.selectionManager.selectedKeys.keys().next().value);
578
- if (currentSelectionText) messages.push(formatMessage('selectedItem', {
579
- item: currentSelectionText
580
- }));
581
- }
582
- } else if (addedKeys.size === 1 && removedKeys.size === 0) {
583
- let addedText = getRowText(addedKeys.keys().next().value);
584
- if (addedText) messages.push(formatMessage('selectedItem', {
585
- item: addedText
586
- }));
587
- } else if (removedKeys.size === 1 && addedKeys.size === 0) {
588
- if (state.collection.getItem(removedKeys.keys().next().value)) {
589
- let removedText = getRowText(removedKeys.keys().next().value);
590
- if (removedText) messages.push(formatMessage('deselectedItem', {
591
- item: removedText
592
- }));
593
- }
594
- }
595
- // Announce how many items are selected, except when selecting the first item.
596
- if (state.selectionManager.selectionMode === 'multiple') {
597
- 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', {
598
- count: selection.size
599
- }));
600
- }
601
- if (messages.length > 0) $2oePb$reactarialiveannouncer.announce(messages.join(' '));
602
- lastSelection.current = selection;
603
- }, [
604
- selection
605
- ]);
626
+ $1eb174acfe8a0f16$export$137e594ef3218a10({
627
+ getRowText: getRowText
628
+ }, state);
606
629
  return {
607
630
  gridProps: gridProps
608
631
  };
609
632
  }
610
- function $11d770dfabe45077$var$diffSelection(a, b) {
611
- let res = new Set();
612
- if (a === 'all' || b === 'all') return res;
613
- for (let key of a.keys())if (!b.has(key)) res.add(key);
614
- return res;
615
- }
616
633
 
617
634
 
618
635
  var $c7def85a57100898$exports = {};
@@ -833,12 +850,16 @@ function $d8385f73d3701365$export$70e2eed1a92976ad(props, state) {
833
850
  }
834
851
 
835
852
 
853
+
854
+
836
855
  $parcel$exportWildcard(module.exports, $3187c0e19200cb16$exports);
837
856
  $parcel$exportWildcard(module.exports, $11d770dfabe45077$exports);
838
857
  $parcel$exportWildcard(module.exports, $c7def85a57100898$exports);
839
858
  $parcel$exportWildcard(module.exports, $eed398987c639831$exports);
840
859
  $parcel$exportWildcard(module.exports, $cf2021be63b01ef4$exports);
841
860
  $parcel$exportWildcard(module.exports, $d8385f73d3701365$exports);
861
+ $parcel$exportWildcard(module.exports, $340f2fcd0ef9ce8d$exports);
862
+ $parcel$exportWildcard(module.exports, $1eb174acfe8a0f16$exports);
842
863
 
843
864
 
844
865
  //# sourceMappingURL=main.js.map