@react-aria/selection 3.16.2 → 3.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/import.mjs CHANGED
@@ -1,6 +1,7 @@
1
+ import {flushSync as $eCAIO$flushSync} from "react-dom";
1
2
  import {useRef as $eCAIO$useRef, useEffect as $eCAIO$useEffect, useMemo as $eCAIO$useMemo} from "react";
2
3
  import {getFocusableTreeWalker as $eCAIO$getFocusableTreeWalker, focusSafely as $eCAIO$focusSafely} from "@react-aria/focus";
3
- import {focusWithoutScrolling as $eCAIO$focusWithoutScrolling, useEvent as $eCAIO$useEvent, scrollIntoViewport as $eCAIO$scrollIntoViewport, scrollIntoView as $eCAIO$scrollIntoView, mergeProps as $eCAIO$mergeProps, isAppleDevice as $eCAIO$isAppleDevice, isMac as $eCAIO$isMac, isScrollable as $eCAIO$isScrollable} from "@react-aria/utils";
4
+ import {useRouter as $eCAIO$useRouter, focusWithoutScrolling as $eCAIO$focusWithoutScrolling, useEvent as $eCAIO$useEvent, scrollIntoViewport as $eCAIO$scrollIntoViewport, scrollIntoView as $eCAIO$scrollIntoView, mergeProps as $eCAIO$mergeProps, isAppleDevice as $eCAIO$isAppleDevice, isMac as $eCAIO$isMac, openLink as $eCAIO$openLink, isScrollable as $eCAIO$isScrollable} from "@react-aria/utils";
4
5
  import {getInteractionModality as $eCAIO$getInteractionModality, usePress as $eCAIO$usePress, useLongPress as $eCAIO$useLongPress} from "@react-aria/interactions";
5
6
  import {useLocale as $eCAIO$useLocale, useCollator as $eCAIO$useCollator} from "@react-aria/i18n";
6
7
 
@@ -28,6 +29,7 @@ import {useLocale as $eCAIO$useLocale, useCollator as $eCAIO$useCollator} from "
28
29
 
29
30
 
30
31
 
32
+
31
33
  /*
32
34
  * Copyright 2020 Adobe. All rights reserved.
33
35
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -66,7 +68,7 @@ function $feb5ffebff200149$export$16792effe837dba3(e) {
66
68
  * Controls how long to wait before clearing the typeahead buffer.
67
69
  */ const $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second
68
70
  function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
69
- let { keyboardDelegate: keyboardDelegate , selectionManager: selectionManager , onTypeSelect: onTypeSelect } = options;
71
+ let { keyboardDelegate: keyboardDelegate, selectionManager: selectionManager, onTypeSelect: onTypeSelect } = options;
70
72
  let state = (0, $eCAIO$useRef)({
71
73
  search: "",
72
74
  timeout: null
@@ -116,9 +118,10 @@ function $fb3050f43d946246$var$getStringForKey(key) {
116
118
 
117
119
 
118
120
  function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
119
- let { selectionManager: manager , keyboardDelegate: delegate , ref: ref , autoFocus: autoFocus = false , shouldFocusWrap: shouldFocusWrap = false , disallowEmptySelection: disallowEmptySelection = false , disallowSelectAll: disallowSelectAll = false , selectOnFocus: selectOnFocus = manager.selectionBehavior === "replace" , disallowTypeAhead: disallowTypeAhead = false , shouldUseVirtualFocus: shouldUseVirtualFocus , allowsTabNavigation: allowsTabNavigation = false , isVirtualized: isVirtualized , scrollRef: // If no scrollRef is provided, assume the collection ref is the scrollable region
120
- scrollRef = ref } = options;
121
- let { direction: direction } = (0, $eCAIO$useLocale)();
121
+ let { selectionManager: manager, keyboardDelegate: delegate, ref: ref, autoFocus: autoFocus = false, shouldFocusWrap: shouldFocusWrap = false, disallowEmptySelection: disallowEmptySelection = false, disallowSelectAll: disallowSelectAll = false, selectOnFocus: selectOnFocus = manager.selectionBehavior === "replace", disallowTypeAhead: disallowTypeAhead = false, shouldUseVirtualFocus: shouldUseVirtualFocus, allowsTabNavigation: allowsTabNavigation = false, isVirtualized: isVirtualized, scrollRef: // If no scrollRef is provided, assume the collection ref is the scrollable region
122
+ scrollRef = ref, linkBehavior: linkBehavior = "action" } = options;
123
+ let { direction: direction } = (0, $eCAIO$useLocale)();
124
+ let router = (0, $eCAIO$useRouter)();
122
125
  let onKeyDown = (e)=>{
123
126
  // Prevent option + tab from doing anything since it doesn't move focus to the cells, only buttons/checkboxes
124
127
  if (e.altKey && e.key === "Tab") e.preventDefault();
@@ -127,7 +130,17 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
127
130
  if (!ref.current.contains(e.target)) return;
128
131
  const navigateToKey = (key, childFocus)=>{
129
132
  if (key != null) {
133
+ if (manager.isLink(key) && linkBehavior === "selection" && selectOnFocus && !(0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) {
134
+ // Set focused key and re-render synchronously to bring item into view if needed.
135
+ (0, $eCAIO$flushSync)(()=>{
136
+ manager.setFocusedKey(key, childFocus);
137
+ });
138
+ let item = scrollRef.current.querySelector(`[data-key="${key}"]`);
139
+ router.open(item, e);
140
+ return;
141
+ }
130
142
  manager.setFocusedKey(key, childFocus);
143
+ if (manager.isLink(key) && linkBehavior === "override") return;
131
144
  if (e.shiftKey && manager.selectionMode === "multiple") manager.extendSelection(key);
132
145
  else if (selectOnFocus && !(0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) manager.replaceSelection(key);
133
146
  }
@@ -344,7 +357,7 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
344
357
  e.preventDefault();
345
358
  }
346
359
  };
347
- let { typeSelectProps: typeSelectProps } = (0, $fb3050f43d946246$export$e32c88dfddc6e1d8)({
360
+ let { typeSelectProps: typeSelectProps } = (0, $fb3050f43d946246$export$e32c88dfddc6e1d8)({
348
361
  keyboardDelegate: delegate,
349
362
  selectionManager: manager
350
363
  });
@@ -380,11 +393,20 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
380
393
 
381
394
 
382
395
  function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
383
- let { selectionManager: manager , key: key , ref: ref , shouldSelectOnPressUp: shouldSelectOnPressUp , shouldUseVirtualFocus: shouldUseVirtualFocus , focus: focus , isDisabled: isDisabled , onAction: onAction , allowsDifferentPressOrigin: allowsDifferentPressOrigin } = options;
396
+ let { selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = "action" } = options;
397
+ let router = (0, $eCAIO$useRouter)();
384
398
  let onSelect = (e)=>{
385
399
  if (e.pointerType === "keyboard" && (0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) manager.toggleSelection(key);
386
400
  else {
387
401
  if (manager.selectionMode === "none") return;
402
+ if (manager.isLink(key)) {
403
+ if (linkBehavior === "selection") {
404
+ router.open(ref.current, e);
405
+ // Always set selected keys back to what they were so that select and combobox close.
406
+ manager.setSelectedKeys(manager.selectedKeys);
407
+ return;
408
+ } else if (linkBehavior === "override" || linkBehavior === "none") return;
409
+ }
388
410
  if (manager.selectionMode === "single") {
389
411
  if (manager.isSelected(key) && !manager.disallowEmptySelection) manager.toggleSelection(key);
390
412
  else manager.replaceSelection(key);
@@ -429,15 +451,21 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
429
451
  // Clicking the checkbox enters selection mode, after which clicking anywhere on any row toggles selection for that row.
430
452
  // With highlight selection, onAction is secondary, and occurs on double click. Single click selects the row.
431
453
  // With touch, onAction occurs on single tap, and long press enters selection mode.
432
- let allowsSelection = !isDisabled && manager.canSelectItem(key);
433
- let allowsActions = onAction && !isDisabled;
434
- let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : manager.isEmpty);
454
+ let isLinkOverride = manager.isLink(key) && linkBehavior === "override";
455
+ let hasLinkAction = manager.isLink(key) && linkBehavior !== "selection" && linkBehavior !== "none";
456
+ let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride;
457
+ let allowsActions = (onAction || hasLinkAction) && !isDisabled;
458
+ let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : !allowsSelection || manager.isEmpty);
435
459
  let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === "replace";
436
460
  let hasAction = hasPrimaryAction || hasSecondaryAction;
437
461
  let modality = (0, $eCAIO$useRef)(null);
438
462
  let longPressEnabled = hasAction && allowsSelection;
439
463
  let longPressEnabledOnPressStart = (0, $eCAIO$useRef)(false);
440
464
  let hadPrimaryActionOnPressStart = (0, $eCAIO$useRef)(false);
465
+ let performAction = (e)=>{
466
+ if (onAction) onAction();
467
+ if (hasLinkAction) router.open(ref.current, e);
468
+ };
441
469
  // By default, selection occurs on pointer down. This can be strange if selecting an
442
470
  // item causes the UI to disappear immediately (e.g. menus).
443
471
  // If shouldSelectOnPressUp is true, we use onPressUp instead of onPressStart.
@@ -457,14 +485,14 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
457
485
  if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e)=>{
458
486
  if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== "mouse") {
459
487
  if (e.pointerType === "keyboard" && !$880e95eb8b93ba9a$var$isActionKey()) return;
460
- onAction();
461
- } else if (e.pointerType !== "keyboard") onSelect(e);
488
+ performAction(e);
489
+ } else if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
462
490
  };
463
491
  else {
464
- itemPressProps.onPressUp = (e)=>{
465
- if (e.pointerType !== "keyboard") onSelect(e);
492
+ itemPressProps.onPressUp = hasPrimaryAction ? null : (e)=>{
493
+ if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
466
494
  };
467
- itemPressProps.onPress = hasPrimaryAction ? ()=>onAction() : null;
495
+ itemPressProps.onPress = hasPrimaryAction ? performAction : null;
468
496
  }
469
497
  } else {
470
498
  itemPressProps.onPressStart = (e)=>{
@@ -474,33 +502,33 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
474
502
  // Select on mouse down unless there is a primary action which will occur on mouse up.
475
503
  // For keyboard, select on key down. If there is an action, the Space key selects on key down,
476
504
  // and the Enter key performs onAction on key up.
477
- if (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!onAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
505
+ if (allowsSelection && (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!allowsActions || $880e95eb8b93ba9a$var$isSelectionKey()))) onSelect(e);
478
506
  };
479
507
  itemPressProps.onPress = (e)=>{
480
508
  // Selection occurs on touch up. Primary actions always occur on pointer up.
481
509
  // Both primary and secondary actions occur on Enter key up. The only exception
482
510
  // is secondary actions, which occur on double click with a mouse.
483
511
  if (e.pointerType === "touch" || e.pointerType === "pen" || e.pointerType === "virtual" || e.pointerType === "keyboard" && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === "mouse" && hadPrimaryActionOnPressStart.current) {
484
- if (hasAction) onAction();
485
- else onSelect(e);
512
+ if (hasAction) performAction(e);
513
+ else if (allowsSelection) onSelect(e);
486
514
  }
487
515
  };
488
516
  }
489
517
  itemProps["data-key"] = key;
490
518
  itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
491
- let { pressProps: pressProps , isPressed: isPressed } = (0, $eCAIO$usePress)(itemPressProps);
519
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $eCAIO$usePress)(itemPressProps);
492
520
  // Double clicking with a mouse with selectionBehavior = 'replace' performs an action.
493
521
  let onDoubleClick = hasSecondaryAction ? (e)=>{
494
522
  if (modality.current === "mouse") {
495
523
  e.stopPropagation();
496
524
  e.preventDefault();
497
- onAction();
525
+ performAction(e);
498
526
  }
499
527
  } : undefined;
500
528
  // Long pressing an item with touch when selectionBehavior = 'replace' switches the selection behavior
501
529
  // to 'toggle'. This changes the single tap behavior from performing an action (i.e. navigating) to
502
530
  // selecting, and may toggle the appearance of a UI affordance like checkboxes on each item.
503
- let { longPressProps: longPressProps } = (0, $eCAIO$useLongPress)({
531
+ let { longPressProps: longPressProps } = (0, $eCAIO$useLongPress)({
504
532
  isDisabled: !longPressEnabled,
505
533
  onLongPress (e) {
506
534
  if (e.pointerType === "touch") {
@@ -516,10 +544,16 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
516
544
  let onDragStartCapture = (e)=>{
517
545
  if (modality.current === "touch" && longPressEnabledOnPressStart.current) e.preventDefault();
518
546
  };
547
+ // Prevent default on link clicks so that we control exactly
548
+ // when they open (to match selection behavior).
549
+ let onClick = manager.isLink(key) ? (e)=>{
550
+ if (!(0, $eCAIO$openLink).isOpening) e.preventDefault();
551
+ } : undefined;
519
552
  return {
520
553
  itemProps: (0, $eCAIO$mergeProps)(itemProps, allowsSelection || hasPrimaryAction ? pressProps : {}, longPressEnabled ? longPressProps : {}, {
521
554
  onDoubleClick: onDoubleClick,
522
- onDragStartCapture: onDragStartCapture
555
+ onDragStartCapture: onDragStartCapture,
556
+ onClick: onClick
523
557
  }),
524
558
  isPressed: isPressed,
525
559
  isSelected: manager.isSelected(key),
@@ -550,6 +584,7 @@ function $880e95eb8b93ba9a$var$isSelectionKey() {
550
584
  * OF ANY KIND, either express or implied. See the License for the specific language
551
585
  * governing permissions and limitations under the License.
552
586
  */
587
+
553
588
  /*
554
589
  * Copyright 2020 Adobe. All rights reserved.
555
590
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -712,6 +747,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
712
747
  let opts = args[0];
713
748
  this.collection = opts.collection;
714
749
  this.ref = opts.ref;
750
+ this.collator = opts.collator;
715
751
  this.disabledKeys = opts.disabledKeys || new Set();
716
752
  this.orientation = opts.orientation;
717
753
  this.direction = opts.direction;
@@ -735,9 +771,8 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
735
771
 
736
772
 
737
773
 
738
-
739
774
  function $982254629710d113$export$b95089534ab7c1fd(props) {
740
- let { selectionManager: selectionManager , collection: collection , disabledKeys: disabledKeys , ref: ref , keyboardDelegate: keyboardDelegate , autoFocus: autoFocus , shouldFocusWrap: shouldFocusWrap , isVirtualized: isVirtualized , disallowEmptySelection: disallowEmptySelection , selectOnFocus: selectOnFocus = selectionManager.selectionBehavior === "replace" , disallowTypeAhead: disallowTypeAhead , shouldUseVirtualFocus: shouldUseVirtualFocus , allowsTabNavigation: allowsTabNavigation } = props;
775
+ let { selectionManager: selectionManager, collection: collection, disabledKeys: disabledKeys, ref: ref, keyboardDelegate: keyboardDelegate } = props;
741
776
  // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
742
777
  // When virtualized, the layout object will be passed in as a prop and override this.
743
778
  let collator = (0, $eCAIO$useCollator)({
@@ -753,19 +788,11 @@ function $982254629710d113$export$b95089534ab7c1fd(props) {
753
788
  collator,
754
789
  disabledBehavior
755
790
  ]);
756
- let { collectionProps: collectionProps } = (0, $ae20dd8cbca75726$export$d6daf82dcd84e87c)({
791
+ let { collectionProps: collectionProps } = (0, $ae20dd8cbca75726$export$d6daf82dcd84e87c)({
792
+ ...props,
757
793
  ref: ref,
758
794
  selectionManager: selectionManager,
759
- keyboardDelegate: delegate,
760
- autoFocus: autoFocus,
761
- shouldFocusWrap: shouldFocusWrap,
762
- disallowEmptySelection: disallowEmptySelection,
763
- selectOnFocus: selectOnFocus,
764
- disallowTypeAhead: disallowTypeAhead,
765
- shouldUseVirtualFocus: shouldUseVirtualFocus,
766
- allowsTabNavigation: allowsTabNavigation,
767
- isVirtualized: isVirtualized,
768
- scrollRef: ref
795
+ keyboardDelegate: delegate
769
796
  });
770
797
  return {
771
798
  listProps: collectionProps
package/dist/main.js CHANGED
@@ -1,3 +1,4 @@
1
+ var $glPPV$reactdom = require("react-dom");
1
2
  var $glPPV$react = require("react");
2
3
  var $glPPV$reactariafocus = require("@react-aria/focus");
3
4
  var $glPPV$reactariautils = require("@react-aria/utils");
@@ -37,6 +38,7 @@ $parcel$export(module.exports, "useTypeSelect", () => $a1189052f36475e8$export$e
37
38
 
38
39
 
39
40
 
41
+
40
42
  /*
41
43
  * Copyright 2020 Adobe. All rights reserved.
42
44
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -75,7 +77,7 @@ function $ee0bdf4faa47f2a8$export$16792effe837dba3(e) {
75
77
  * Controls how long to wait before clearing the typeahead buffer.
76
78
  */ const $a1189052f36475e8$var$TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second
77
79
  function $a1189052f36475e8$export$e32c88dfddc6e1d8(options) {
78
- let { keyboardDelegate: keyboardDelegate , selectionManager: selectionManager , onTypeSelect: onTypeSelect } = options;
80
+ let { keyboardDelegate: keyboardDelegate, selectionManager: selectionManager, onTypeSelect: onTypeSelect } = options;
79
81
  let state = (0, $glPPV$react.useRef)({
80
82
  search: "",
81
83
  timeout: null
@@ -125,9 +127,10 @@ function $a1189052f36475e8$var$getStringForKey(key) {
125
127
 
126
128
 
127
129
  function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
128
- let { selectionManager: manager , keyboardDelegate: delegate , ref: ref , autoFocus: autoFocus = false , shouldFocusWrap: shouldFocusWrap = false , disallowEmptySelection: disallowEmptySelection = false , disallowSelectAll: disallowSelectAll = false , selectOnFocus: selectOnFocus = manager.selectionBehavior === "replace" , disallowTypeAhead: disallowTypeAhead = false , shouldUseVirtualFocus: shouldUseVirtualFocus , allowsTabNavigation: allowsTabNavigation = false , isVirtualized: isVirtualized , scrollRef: // If no scrollRef is provided, assume the collection ref is the scrollable region
129
- scrollRef = ref } = options;
130
- let { direction: direction } = (0, $glPPV$reactariai18n.useLocale)();
130
+ let { selectionManager: manager, keyboardDelegate: delegate, ref: ref, autoFocus: autoFocus = false, shouldFocusWrap: shouldFocusWrap = false, disallowEmptySelection: disallowEmptySelection = false, disallowSelectAll: disallowSelectAll = false, selectOnFocus: selectOnFocus = manager.selectionBehavior === "replace", disallowTypeAhead: disallowTypeAhead = false, shouldUseVirtualFocus: shouldUseVirtualFocus, allowsTabNavigation: allowsTabNavigation = false, isVirtualized: isVirtualized, scrollRef: // If no scrollRef is provided, assume the collection ref is the scrollable region
131
+ scrollRef = ref, linkBehavior: linkBehavior = "action" } = options;
132
+ let { direction: direction } = (0, $glPPV$reactariai18n.useLocale)();
133
+ let router = (0, $glPPV$reactariautils.useRouter)();
131
134
  let onKeyDown = (e)=>{
132
135
  // Prevent option + tab from doing anything since it doesn't move focus to the cells, only buttons/checkboxes
133
136
  if (e.altKey && e.key === "Tab") e.preventDefault();
@@ -136,7 +139,17 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
136
139
  if (!ref.current.contains(e.target)) return;
137
140
  const navigateToKey = (key, childFocus)=>{
138
141
  if (key != null) {
142
+ if (manager.isLink(key) && linkBehavior === "selection" && selectOnFocus && !(0, $ee0bdf4faa47f2a8$export$d3e3bd3e26688c04)(e)) {
143
+ // Set focused key and re-render synchronously to bring item into view if needed.
144
+ (0, $glPPV$reactdom.flushSync)(()=>{
145
+ manager.setFocusedKey(key, childFocus);
146
+ });
147
+ let item = scrollRef.current.querySelector(`[data-key="${key}"]`);
148
+ router.open(item, e);
149
+ return;
150
+ }
139
151
  manager.setFocusedKey(key, childFocus);
152
+ if (manager.isLink(key) && linkBehavior === "override") return;
140
153
  if (e.shiftKey && manager.selectionMode === "multiple") manager.extendSelection(key);
141
154
  else if (selectOnFocus && !(0, $ee0bdf4faa47f2a8$export$d3e3bd3e26688c04)(e)) manager.replaceSelection(key);
142
155
  }
@@ -353,7 +366,7 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
353
366
  e.preventDefault();
354
367
  }
355
368
  };
356
- let { typeSelectProps: typeSelectProps } = (0, $a1189052f36475e8$export$e32c88dfddc6e1d8)({
369
+ let { typeSelectProps: typeSelectProps } = (0, $a1189052f36475e8$export$e32c88dfddc6e1d8)({
357
370
  keyboardDelegate: delegate,
358
371
  selectionManager: manager
359
372
  });
@@ -389,11 +402,20 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
389
402
 
390
403
 
391
404
  function $433b1145b0781e10$export$ecf600387e221c37(options) {
392
- let { selectionManager: manager , key: key , ref: ref , shouldSelectOnPressUp: shouldSelectOnPressUp , shouldUseVirtualFocus: shouldUseVirtualFocus , focus: focus , isDisabled: isDisabled , onAction: onAction , allowsDifferentPressOrigin: allowsDifferentPressOrigin } = options;
405
+ let { selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = "action" } = options;
406
+ let router = (0, $glPPV$reactariautils.useRouter)();
393
407
  let onSelect = (e)=>{
394
408
  if (e.pointerType === "keyboard" && (0, $ee0bdf4faa47f2a8$export$d3e3bd3e26688c04)(e)) manager.toggleSelection(key);
395
409
  else {
396
410
  if (manager.selectionMode === "none") return;
411
+ if (manager.isLink(key)) {
412
+ if (linkBehavior === "selection") {
413
+ router.open(ref.current, e);
414
+ // Always set selected keys back to what they were so that select and combobox close.
415
+ manager.setSelectedKeys(manager.selectedKeys);
416
+ return;
417
+ } else if (linkBehavior === "override" || linkBehavior === "none") return;
418
+ }
397
419
  if (manager.selectionMode === "single") {
398
420
  if (manager.isSelected(key) && !manager.disallowEmptySelection) manager.toggleSelection(key);
399
421
  else manager.replaceSelection(key);
@@ -438,15 +460,21 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
438
460
  // Clicking the checkbox enters selection mode, after which clicking anywhere on any row toggles selection for that row.
439
461
  // With highlight selection, onAction is secondary, and occurs on double click. Single click selects the row.
440
462
  // With touch, onAction occurs on single tap, and long press enters selection mode.
441
- let allowsSelection = !isDisabled && manager.canSelectItem(key);
442
- let allowsActions = onAction && !isDisabled;
443
- let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : manager.isEmpty);
463
+ let isLinkOverride = manager.isLink(key) && linkBehavior === "override";
464
+ let hasLinkAction = manager.isLink(key) && linkBehavior !== "selection" && linkBehavior !== "none";
465
+ let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride;
466
+ let allowsActions = (onAction || hasLinkAction) && !isDisabled;
467
+ let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : !allowsSelection || manager.isEmpty);
444
468
  let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === "replace";
445
469
  let hasAction = hasPrimaryAction || hasSecondaryAction;
446
470
  let modality = (0, $glPPV$react.useRef)(null);
447
471
  let longPressEnabled = hasAction && allowsSelection;
448
472
  let longPressEnabledOnPressStart = (0, $glPPV$react.useRef)(false);
449
473
  let hadPrimaryActionOnPressStart = (0, $glPPV$react.useRef)(false);
474
+ let performAction = (e)=>{
475
+ if (onAction) onAction();
476
+ if (hasLinkAction) router.open(ref.current, e);
477
+ };
450
478
  // By default, selection occurs on pointer down. This can be strange if selecting an
451
479
  // item causes the UI to disappear immediately (e.g. menus).
452
480
  // If shouldSelectOnPressUp is true, we use onPressUp instead of onPressStart.
@@ -466,14 +494,14 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
466
494
  if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e)=>{
467
495
  if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== "mouse") {
468
496
  if (e.pointerType === "keyboard" && !$433b1145b0781e10$var$isActionKey()) return;
469
- onAction();
470
- } else if (e.pointerType !== "keyboard") onSelect(e);
497
+ performAction(e);
498
+ } else if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
471
499
  };
472
500
  else {
473
- itemPressProps.onPressUp = (e)=>{
474
- if (e.pointerType !== "keyboard") onSelect(e);
501
+ itemPressProps.onPressUp = hasPrimaryAction ? null : (e)=>{
502
+ if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
475
503
  };
476
- itemPressProps.onPress = hasPrimaryAction ? ()=>onAction() : null;
504
+ itemPressProps.onPress = hasPrimaryAction ? performAction : null;
477
505
  }
478
506
  } else {
479
507
  itemPressProps.onPressStart = (e)=>{
@@ -483,33 +511,33 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
483
511
  // Select on mouse down unless there is a primary action which will occur on mouse up.
484
512
  // For keyboard, select on key down. If there is an action, the Space key selects on key down,
485
513
  // and the Enter key performs onAction on key up.
486
- if (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!onAction || $433b1145b0781e10$var$isSelectionKey())) onSelect(e);
514
+ if (allowsSelection && (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!allowsActions || $433b1145b0781e10$var$isSelectionKey()))) onSelect(e);
487
515
  };
488
516
  itemPressProps.onPress = (e)=>{
489
517
  // Selection occurs on touch up. Primary actions always occur on pointer up.
490
518
  // Both primary and secondary actions occur on Enter key up. The only exception
491
519
  // is secondary actions, which occur on double click with a mouse.
492
520
  if (e.pointerType === "touch" || e.pointerType === "pen" || e.pointerType === "virtual" || e.pointerType === "keyboard" && hasAction && $433b1145b0781e10$var$isActionKey() || e.pointerType === "mouse" && hadPrimaryActionOnPressStart.current) {
493
- if (hasAction) onAction();
494
- else onSelect(e);
521
+ if (hasAction) performAction(e);
522
+ else if (allowsSelection) onSelect(e);
495
523
  }
496
524
  };
497
525
  }
498
526
  itemProps["data-key"] = key;
499
527
  itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
500
- let { pressProps: pressProps , isPressed: isPressed } = (0, $glPPV$reactariainteractions.usePress)(itemPressProps);
528
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $glPPV$reactariainteractions.usePress)(itemPressProps);
501
529
  // Double clicking with a mouse with selectionBehavior = 'replace' performs an action.
502
530
  let onDoubleClick = hasSecondaryAction ? (e)=>{
503
531
  if (modality.current === "mouse") {
504
532
  e.stopPropagation();
505
533
  e.preventDefault();
506
- onAction();
534
+ performAction(e);
507
535
  }
508
536
  } : undefined;
509
537
  // Long pressing an item with touch when selectionBehavior = 'replace' switches the selection behavior
510
538
  // to 'toggle'. This changes the single tap behavior from performing an action (i.e. navigating) to
511
539
  // selecting, and may toggle the appearance of a UI affordance like checkboxes on each item.
512
- let { longPressProps: longPressProps } = (0, $glPPV$reactariainteractions.useLongPress)({
540
+ let { longPressProps: longPressProps } = (0, $glPPV$reactariainteractions.useLongPress)({
513
541
  isDisabled: !longPressEnabled,
514
542
  onLongPress (e) {
515
543
  if (e.pointerType === "touch") {
@@ -525,10 +553,16 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
525
553
  let onDragStartCapture = (e)=>{
526
554
  if (modality.current === "touch" && longPressEnabledOnPressStart.current) e.preventDefault();
527
555
  };
556
+ // Prevent default on link clicks so that we control exactly
557
+ // when they open (to match selection behavior).
558
+ let onClick = manager.isLink(key) ? (e)=>{
559
+ if (!(0, $glPPV$reactariautils.openLink).isOpening) e.preventDefault();
560
+ } : undefined;
528
561
  return {
529
562
  itemProps: (0, $glPPV$reactariautils.mergeProps)(itemProps, allowsSelection || hasPrimaryAction ? pressProps : {}, longPressEnabled ? longPressProps : {}, {
530
563
  onDoubleClick: onDoubleClick,
531
- onDragStartCapture: onDragStartCapture
564
+ onDragStartCapture: onDragStartCapture,
565
+ onClick: onClick
532
566
  }),
533
567
  isPressed: isPressed,
534
568
  isSelected: manager.isSelected(key),
@@ -559,6 +593,7 @@ function $433b1145b0781e10$var$isSelectionKey() {
559
593
  * OF ANY KIND, either express or implied. See the License for the specific language
560
594
  * governing permissions and limitations under the License.
561
595
  */
596
+
562
597
  /*
563
598
  * Copyright 2020 Adobe. All rights reserved.
564
599
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -721,6 +756,7 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
721
756
  let opts = args[0];
722
757
  this.collection = opts.collection;
723
758
  this.ref = opts.ref;
759
+ this.collator = opts.collator;
724
760
  this.disabledKeys = opts.disabledKeys || new Set();
725
761
  this.orientation = opts.orientation;
726
762
  this.direction = opts.direction;
@@ -744,9 +780,8 @@ class $836f880b12dcae5c$export$a05409b8bb224a5a {
744
780
 
745
781
 
746
782
 
747
-
748
783
  function $bd230acee196f50c$export$b95089534ab7c1fd(props) {
749
- let { selectionManager: selectionManager , collection: collection , disabledKeys: disabledKeys , ref: ref , keyboardDelegate: keyboardDelegate , autoFocus: autoFocus , shouldFocusWrap: shouldFocusWrap , isVirtualized: isVirtualized , disallowEmptySelection: disallowEmptySelection , selectOnFocus: selectOnFocus = selectionManager.selectionBehavior === "replace" , disallowTypeAhead: disallowTypeAhead , shouldUseVirtualFocus: shouldUseVirtualFocus , allowsTabNavigation: allowsTabNavigation } = props;
784
+ let { selectionManager: selectionManager, collection: collection, disabledKeys: disabledKeys, ref: ref, keyboardDelegate: keyboardDelegate } = props;
750
785
  // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
751
786
  // When virtualized, the layout object will be passed in as a prop and override this.
752
787
  let collator = (0, $glPPV$reactariai18n.useCollator)({
@@ -762,19 +797,11 @@ function $bd230acee196f50c$export$b95089534ab7c1fd(props) {
762
797
  collator,
763
798
  disabledBehavior
764
799
  ]);
765
- let { collectionProps: collectionProps } = (0, $b6837c2f80a3c32f$export$d6daf82dcd84e87c)({
800
+ let { collectionProps: collectionProps } = (0, $b6837c2f80a3c32f$export$d6daf82dcd84e87c)({
801
+ ...props,
766
802
  ref: ref,
767
803
  selectionManager: selectionManager,
768
- keyboardDelegate: delegate,
769
- autoFocus: autoFocus,
770
- shouldFocusWrap: shouldFocusWrap,
771
- disallowEmptySelection: disallowEmptySelection,
772
- selectOnFocus: selectOnFocus,
773
- disallowTypeAhead: disallowTypeAhead,
774
- shouldUseVirtualFocus: shouldUseVirtualFocus,
775
- allowsTabNavigation: allowsTabNavigation,
776
- isVirtualized: isVirtualized,
777
- scrollRef: ref
804
+ keyboardDelegate: delegate
778
805
  });
779
806
  return {
780
807
  listProps: collectionProps