@react-aria/selection 3.18.0 → 3.19.0

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.
Files changed (43) hide show
  1. package/dist/DOMLayoutDelegate.main.js +53 -0
  2. package/dist/DOMLayoutDelegate.main.js.map +1 -0
  3. package/dist/DOMLayoutDelegate.mjs +48 -0
  4. package/dist/DOMLayoutDelegate.module.js +48 -0
  5. package/dist/DOMLayoutDelegate.module.js.map +1 -0
  6. package/dist/ListKeyboardDelegate.main.js +51 -62
  7. package/dist/ListKeyboardDelegate.main.js.map +1 -1
  8. package/dist/ListKeyboardDelegate.mjs +52 -63
  9. package/dist/ListKeyboardDelegate.module.js +51 -62
  10. package/dist/ListKeyboardDelegate.module.js.map +1 -1
  11. package/dist/import.mjs +3 -1
  12. package/dist/main.js +3 -0
  13. package/dist/main.js.map +1 -1
  14. package/dist/module.js +3 -1
  15. package/dist/module.js.map +1 -1
  16. package/dist/types.d.ts +19 -7
  17. package/dist/types.d.ts.map +1 -1
  18. package/dist/useSelectableCollection.main.js +46 -44
  19. package/dist/useSelectableCollection.main.js.map +1 -1
  20. package/dist/useSelectableCollection.mjs +47 -45
  21. package/dist/useSelectableCollection.module.js +46 -44
  22. package/dist/useSelectableCollection.module.js.map +1 -1
  23. package/dist/useSelectableItem.main.js +25 -25
  24. package/dist/useSelectableItem.main.js.map +1 -1
  25. package/dist/useSelectableItem.mjs +26 -26
  26. package/dist/useSelectableItem.module.js +25 -25
  27. package/dist/useSelectableItem.module.js.map +1 -1
  28. package/dist/useSelectableList.main.js +6 -4
  29. package/dist/useSelectableList.main.js.map +1 -1
  30. package/dist/useSelectableList.mjs +7 -5
  31. package/dist/useSelectableList.module.js +6 -4
  32. package/dist/useSelectableList.module.js.map +1 -1
  33. package/dist/useTypeSelect.main.js +5 -5
  34. package/dist/useTypeSelect.mjs +6 -6
  35. package/dist/useTypeSelect.module.js +5 -5
  36. package/dist/utils.mjs +1 -1
  37. package/package.json +10 -10
  38. package/src/DOMLayoutDelegate.ts +57 -0
  39. package/src/ListKeyboardDelegate.ts +37 -49
  40. package/src/index.ts +1 -0
  41. package/src/useSelectableCollection.ts +26 -15
  42. package/src/useSelectableItem.ts +3 -3
  43. package/src/useSelectableList.ts +12 -4
@@ -26,26 +26,26 @@ $parcel$export(module.exports, "useSelectableItem", () => $433b1145b0781e10$expo
26
26
 
27
27
 
28
28
  function $433b1145b0781e10$export$ecf600387e221c37(options) {
29
- let { selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = "action" } = options;
29
+ let { selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = 'action' } = options;
30
30
  let router = (0, $i4XHw$reactariautils.useRouter)();
31
31
  let onSelect = (e)=>{
32
- if (e.pointerType === "keyboard" && (0, $ee0bdf4faa47f2a8$exports.isNonContiguousSelectionModifier)(e)) manager.toggleSelection(key);
32
+ if (e.pointerType === 'keyboard' && (0, $ee0bdf4faa47f2a8$exports.isNonContiguousSelectionModifier)(e)) manager.toggleSelection(key);
33
33
  else {
34
- if (manager.selectionMode === "none") return;
34
+ if (manager.selectionMode === 'none') return;
35
35
  if (manager.isLink(key)) {
36
- if (linkBehavior === "selection") {
36
+ if (linkBehavior === 'selection') {
37
37
  let itemProps = manager.getItemProps(key);
38
38
  router.open(ref.current, e, itemProps.href, itemProps.routerOptions);
39
39
  // Always set selected keys back to what they were so that select and combobox close.
40
40
  manager.setSelectedKeys(manager.selectedKeys);
41
41
  return;
42
- } else if (linkBehavior === "override" || linkBehavior === "none") return;
42
+ } else if (linkBehavior === 'override' || linkBehavior === 'none') return;
43
43
  }
44
- if (manager.selectionMode === "single") {
44
+ if (manager.selectionMode === 'single') {
45
45
  if (manager.isSelected(key) && !manager.disallowEmptySelection) manager.toggleSelection(key);
46
46
  else manager.replaceSelection(key);
47
47
  } else if (e && e.shiftKey) manager.extendSelection(key);
48
- else if (manager.selectionBehavior === "toggle" || e && ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) || e.pointerType === "touch" || e.pointerType === "virtual")) // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys
48
+ else if (manager.selectionBehavior === 'toggle' || e && ((0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e) || e.pointerType === 'touch' || e.pointerType === 'virtual')) // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys
49
49
  manager.toggleSelection(key);
50
50
  else manager.replaceSelection(key);
51
51
  }
@@ -85,12 +85,12 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
85
85
  // Clicking the checkbox enters selection mode, after which clicking anywhere on any row toggles selection for that row.
86
86
  // With highlight selection, onAction is secondary, and occurs on double click. Single click selects the row.
87
87
  // With touch, onAction occurs on single tap, and long press enters selection mode.
88
- let isLinkOverride = manager.isLink(key) && linkBehavior === "override";
89
- let hasLinkAction = manager.isLink(key) && linkBehavior !== "selection" && linkBehavior !== "none";
88
+ let isLinkOverride = manager.isLink(key) && linkBehavior === 'override';
89
+ let hasLinkAction = manager.isLink(key) && linkBehavior !== 'selection' && linkBehavior !== 'none';
90
90
  let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride;
91
91
  let allowsActions = (onAction || hasLinkAction) && !isDisabled;
92
- let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : !allowsSelection || manager.isEmpty);
93
- let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === "replace";
92
+ let hasPrimaryAction = allowsActions && (manager.selectionBehavior === 'replace' ? !allowsSelection : !allowsSelection || manager.isEmpty);
93
+ let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === 'replace';
94
94
  let hasAction = hasPrimaryAction || hasSecondaryAction;
95
95
  let modality = (0, $i4XHw$react.useRef)(null);
96
96
  let longPressEnabled = hasAction && allowsSelection;
@@ -115,19 +115,19 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
115
115
  itemPressProps.onPressStart = (e)=>{
116
116
  modality.current = e.pointerType;
117
117
  longPressEnabledOnPressStart.current = longPressEnabled;
118
- if (e.pointerType === "keyboard" && (!hasAction || $433b1145b0781e10$var$isSelectionKey())) onSelect(e);
118
+ if (e.pointerType === 'keyboard' && (!hasAction || $433b1145b0781e10$var$isSelectionKey())) onSelect(e);
119
119
  };
120
120
  // If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.)
121
121
  // Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row)
122
122
  if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e)=>{
123
- if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== "mouse") {
124
- if (e.pointerType === "keyboard" && !$433b1145b0781e10$var$isActionKey()) return;
123
+ if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== 'mouse') {
124
+ if (e.pointerType === 'keyboard' && !$433b1145b0781e10$var$isActionKey()) return;
125
125
  performAction(e);
126
- } else if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
126
+ } else if (e.pointerType !== 'keyboard' && allowsSelection) onSelect(e);
127
127
  };
128
128
  else {
129
129
  itemPressProps.onPressUp = hasPrimaryAction ? null : (e)=>{
130
- if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
130
+ if (e.pointerType !== 'keyboard' && allowsSelection) onSelect(e);
131
131
  };
132
132
  itemPressProps.onPress = hasPrimaryAction ? performAction : null;
133
133
  }
@@ -139,24 +139,24 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
139
139
  // Select on mouse down unless there is a primary action which will occur on mouse up.
140
140
  // For keyboard, select on key down. If there is an action, the Space key selects on key down,
141
141
  // and the Enter key performs onAction on key up.
142
- if (allowsSelection && (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!allowsActions || $433b1145b0781e10$var$isSelectionKey()))) onSelect(e);
142
+ if (allowsSelection && (e.pointerType === 'mouse' && !hasPrimaryAction || e.pointerType === 'keyboard' && (!allowsActions || $433b1145b0781e10$var$isSelectionKey()))) onSelect(e);
143
143
  };
144
144
  itemPressProps.onPress = (e)=>{
145
145
  // Selection occurs on touch up. Primary actions always occur on pointer up.
146
146
  // Both primary and secondary actions occur on Enter key up. The only exception
147
147
  // is secondary actions, which occur on double click with a mouse.
148
- if (e.pointerType === "touch" || e.pointerType === "pen" || e.pointerType === "virtual" || e.pointerType === "keyboard" && hasAction && $433b1145b0781e10$var$isActionKey() || e.pointerType === "mouse" && hadPrimaryActionOnPressStart.current) {
148
+ if (e.pointerType === 'touch' || e.pointerType === 'pen' || e.pointerType === 'virtual' || e.pointerType === 'keyboard' && hasAction && $433b1145b0781e10$var$isActionKey() || e.pointerType === 'mouse' && hadPrimaryActionOnPressStart.current) {
149
149
  if (hasAction) performAction(e);
150
150
  else if (allowsSelection) onSelect(e);
151
151
  }
152
152
  };
153
153
  }
154
- itemProps["data-key"] = key;
154
+ itemProps['data-key'] = key;
155
155
  itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
156
156
  let { pressProps: pressProps, isPressed: isPressed } = (0, $i4XHw$reactariainteractions.usePress)(itemPressProps);
157
157
  // Double clicking with a mouse with selectionBehavior = 'replace' performs an action.
158
158
  let onDoubleClick = hasSecondaryAction ? (e)=>{
159
- if (modality.current === "mouse") {
159
+ if (modality.current === 'mouse') {
160
160
  e.stopPropagation();
161
161
  e.preventDefault();
162
162
  performAction(e);
@@ -168,9 +168,9 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
168
168
  let { longPressProps: longPressProps } = (0, $i4XHw$reactariainteractions.useLongPress)({
169
169
  isDisabled: !longPressEnabled,
170
170
  onLongPress (e) {
171
- if (e.pointerType === "touch") {
171
+ if (e.pointerType === 'touch') {
172
172
  onSelect(e);
173
- manager.setSelectionBehavior("toggle");
173
+ manager.setSelectionBehavior('toggle');
174
174
  }
175
175
  }
176
176
  });
@@ -179,7 +179,7 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
179
179
  // Use a capturing listener to ensure this runs before useDrag, regardless of
180
180
  // the order the props get merged.
181
181
  let onDragStartCapture = (e)=>{
182
- if (modality.current === "touch" && longPressEnabledOnPressStart.current) e.preventDefault();
182
+ if (modality.current === 'touch' && longPressEnabledOnPressStart.current) e.preventDefault();
183
183
  };
184
184
  // Prevent default on link clicks so that we control exactly
185
185
  // when they open (to match selection behavior).
@@ -202,11 +202,11 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
202
202
  }
203
203
  function $433b1145b0781e10$var$isActionKey() {
204
204
  let event = window.event;
205
- return (event === null || event === void 0 ? void 0 : event.key) === "Enter";
205
+ return (event === null || event === void 0 ? void 0 : event.key) === 'Enter';
206
206
  }
207
207
  function $433b1145b0781e10$var$isSelectionKey() {
208
208
  let event = window.event;
209
- return (event === null || event === void 0 ? void 0 : event.key) === " " || (event === null || event === void 0 ? void 0 : event.code) === "Space";
209
+ return (event === null || event === void 0 ? void 0 : event.key) === ' ' || (event === null || event === void 0 ? void 0 : event.code) === 'Space';
210
210
  }
211
211
 
212
212
 
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAkGM,SAAS,0CAAkB,OAA8B;IAC9D,IAAI,EACF,kBAAkB,OAAO,OACzB,GAAG,OACH,GAAG,yBACH,qBAAqB,yBACrB,qBAAqB,SACrB,KAAK,cACL,UAAU,YACV,QAAQ,8BACR,0BAA0B,gBAC1B,eAAe,UAChB,GAAG;IACJ,IAAI,SAAS,CAAA,GAAA,+BAAQ;IAErB,IAAI,WAAW,CAAC;Q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AS;IACP,IAAI,QAAQ,OAAO,KAAK;IACxB,OAAO,CAAA,kBAAA,4BAAA,MAAO,GAAG,MAAK;AACxB;AAEA,SAAS;IACP,IAAI,QAAQ,OAAO,KAAK;IACxB,OAAO,CAAA,kBAAA,4BAAA,MAAO,GAAG,MAAK,OAAO,CAAA,kBAAA,4BAAA,MAAO,IAAI,MAAK;AAC/C","sources":["packages/@react-aria/selection/src/useSelectableItem.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, FocusableElement, Key, LongPressEvent, PressEvent} from '@react-types/shared';\nimport {focusSafely} from '@react-aria/focus';\nimport {isCtrlKeyPressed, isNonContiguousSelectionModifier} from './utils';\nimport {mergeProps, openLink, useRouter} from '@react-aria/utils';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {PressProps, useLongPress, usePress} from '@react-aria/interactions';\nimport {RefObject, useEffect, useRef} from 'react';\n\nexport interface SelectableItemOptions {\n /**\n * An interface for reading and updating multiple selection state.\n */\n selectionManager: MultipleSelectionManager,\n /**\n * A unique key for the item.\n */\n key: Key,\n /**\n * Ref to the item.\n */\n ref: RefObject<FocusableElement>,\n /**\n * By default, selection occurs on pointer down. This can be strange if selecting an\n * item causes the UI to disappear immediately (e.g. menus).\n */\n shouldSelectOnPressUp?: boolean,\n /**\n * Whether selection requires the pointer/mouse down and up events to occur on the same target or triggers selection on\n * the target of the pointer/mouse up event.\n */\n allowsDifferentPressOrigin?: boolean,\n /**\n * Whether the option is contained in a virtual scroller.\n */\n isVirtualized?: boolean,\n /**\n * Function to focus the item.\n */\n focus?: () => void,\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean,\n /** Whether the item is disabled. */\n isDisabled?: boolean,\n /**\n * Handler that is called when a user performs an action on the item. The exact user event depends on\n * the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: () => void,\n /**\n * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n * - 'none': links are disabled for both selection and actions (e.g. handled elsewhere).\n * @default 'action'\n */\n linkBehavior?: 'action' | 'selection' | 'override' | 'none'\n}\n\nexport interface SelectableItemStates {\n /** Whether the item is currently in a pressed state. */\n isPressed: boolean,\n /** Whether the item is currently selected. */\n isSelected: boolean,\n /** Whether the item is currently focused. */\n isFocused: boolean,\n /**\n * Whether the item is non-interactive, i.e. both selection and actions are disabled and the item may\n * not be focused. Dependent on `disabledKeys` and `disabledBehavior`.\n */\n isDisabled: boolean,\n /**\n * Whether the item may be selected, dependent on `selectionMode`, `disabledKeys`, and `disabledBehavior`.\n */\n allowsSelection: boolean,\n /**\n * Whether the item has an action, dependent on `onAction`, `disabledKeys`,\n * and `disabledBehavior`. It may also change depending on the current selection state\n * of the list (e.g. when selection is primary). This can be used to enable or disable hover\n * styles or other visual indications of interactivity.\n */\n hasAction: boolean\n}\n\nexport interface SelectableItemAria extends SelectableItemStates {\n /**\n * Props to be spread on the item root node.\n */\n itemProps: DOMAttributes\n}\n\n/**\n * Handles interactions with an item in a selectable collection.\n */\nexport function useSelectableItem(options: SelectableItemOptions): SelectableItemAria {\n let {\n selectionManager: manager,\n key,\n ref,\n shouldSelectOnPressUp,\n shouldUseVirtualFocus,\n focus,\n isDisabled,\n onAction,\n allowsDifferentPressOrigin,\n linkBehavior = 'action'\n } = options;\n let router = useRouter();\n\n let onSelect = (e: PressEvent | LongPressEvent | PointerEvent) => {\n if (e.pointerType === 'keyboard' && isNonContiguousSelectionModifier(e)) {\n manager.toggleSelection(key);\n } else {\n if (manager.selectionMode === 'none') {\n return;\n }\n\n if (manager.isLink(key)) {\n if (linkBehavior === 'selection') {\n let itemProps = manager.getItemProps(key);\n router.open(ref.current, e, itemProps.href, itemProps.routerOptions);\n // Always set selected keys back to what they were so that select and combobox close.\n manager.setSelectedKeys(manager.selectedKeys);\n return;\n } else if (linkBehavior === 'override' || linkBehavior === 'none') {\n return;\n }\n }\n\n if (manager.selectionMode === 'single') {\n if (manager.isSelected(key) && !manager.disallowEmptySelection) {\n manager.toggleSelection(key);\n } else {\n manager.replaceSelection(key);\n }\n } else if (e && e.shiftKey) {\n manager.extendSelection(key);\n } else if (manager.selectionBehavior === 'toggle' || (e && (isCtrlKeyPressed(e) || e.pointerType === 'touch' || e.pointerType === 'virtual'))) {\n // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys\n manager.toggleSelection(key);\n } else {\n manager.replaceSelection(key);\n }\n }\n };\n\n // Focus the associated DOM node when this item becomes the focusedKey\n useEffect(() => {\n let isFocused = key === manager.focusedKey;\n if (isFocused && manager.isFocused && !shouldUseVirtualFocus) {\n if (focus) {\n focus();\n } else if (document.activeElement !== ref.current) {\n focusSafely(ref.current);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [ref, key, manager.focusedKey, manager.childFocusStrategy, manager.isFocused, shouldUseVirtualFocus]);\n\n isDisabled = isDisabled || manager.isDisabled(key);\n // Set tabIndex to 0 if the element is focused, or -1 otherwise so that only the last focused\n // item is tabbable. If using virtual focus, don't set a tabIndex at all so that VoiceOver\n // on iOS 14 doesn't try to move real DOM focus to the item anyway.\n let itemProps: SelectableItemAria['itemProps'] = {};\n if (!shouldUseVirtualFocus && !isDisabled) {\n itemProps = {\n tabIndex: key === manager.focusedKey ? 0 : -1,\n onFocus(e) {\n if (e.target === ref.current) {\n manager.setFocusedKey(key);\n }\n }\n };\n } else if (isDisabled) {\n itemProps.onMouseDown = (e) => {\n // Prevent focus going to the body when clicking on a disabled item.\n e.preventDefault();\n };\n }\n\n // With checkbox selection, onAction (i.e. navigation) becomes primary, and occurs on a single click of the row.\n // Clicking the checkbox enters selection mode, after which clicking anywhere on any row toggles selection for that row.\n // With highlight selection, onAction is secondary, and occurs on double click. Single click selects the row.\n // With touch, onAction occurs on single tap, and long press enters selection mode.\n let isLinkOverride = manager.isLink(key) && linkBehavior === 'override';\n let hasLinkAction = manager.isLink(key) && linkBehavior !== 'selection' && linkBehavior !== 'none';\n let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride;\n let allowsActions = (onAction || hasLinkAction) && !isDisabled;\n let hasPrimaryAction = allowsActions && (\n manager.selectionBehavior === 'replace'\n ? !allowsSelection\n : !allowsSelection || manager.isEmpty\n );\n let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === 'replace';\n let hasAction = hasPrimaryAction || hasSecondaryAction;\n let modality = useRef(null);\n\n let longPressEnabled = hasAction && allowsSelection;\n let longPressEnabledOnPressStart = useRef(false);\n let hadPrimaryActionOnPressStart = useRef(false);\n\n let performAction = (e) => {\n if (onAction) {\n onAction();\n }\n\n if (hasLinkAction) {\n let itemProps = manager.getItemProps(key);\n router.open(ref.current, e, itemProps.href, itemProps.routerOptions);\n }\n };\n\n // By default, selection occurs on pointer down. This can be strange if selecting an\n // item causes the UI to disappear immediately (e.g. menus).\n // If shouldSelectOnPressUp is true, we use onPressUp instead of onPressStart.\n // onPress requires a pointer down event on the same element as pointer up. For menus,\n // we want to be able to have the pointer down on the trigger that opens the menu and\n // the pointer up on the menu item rather than requiring a separate press.\n // For keyboard events, selection still occurs on key down.\n let itemPressProps: PressProps = {};\n if (shouldSelectOnPressUp) {\n itemPressProps.onPressStart = (e) => {\n modality.current = e.pointerType;\n longPressEnabledOnPressStart.current = longPressEnabled;\n if (e.pointerType === 'keyboard' && (!hasAction || isSelectionKey())) {\n onSelect(e);\n }\n };\n\n // If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.)\n // Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row)\n if (!allowsDifferentPressOrigin) {\n itemPressProps.onPress = (e) => {\n if (hasPrimaryAction || (hasSecondaryAction && e.pointerType !== 'mouse')) {\n if (e.pointerType === 'keyboard' && !isActionKey()) {\n return;\n }\n\n performAction(e);\n } else if (e.pointerType !== 'keyboard' && allowsSelection) {\n onSelect(e);\n }\n };\n } else {\n itemPressProps.onPressUp = hasPrimaryAction ? null : (e) => {\n if (e.pointerType !== 'keyboard' && allowsSelection) {\n onSelect(e);\n }\n };\n\n itemPressProps.onPress = hasPrimaryAction ? performAction : null;\n }\n } else {\n itemPressProps.onPressStart = (e) => {\n modality.current = e.pointerType;\n longPressEnabledOnPressStart.current = longPressEnabled;\n hadPrimaryActionOnPressStart.current = hasPrimaryAction;\n\n // Select on mouse down unless there is a primary action which will occur on mouse up.\n // For keyboard, select on key down. If there is an action, the Space key selects on key down,\n // and the Enter key performs onAction on key up.\n if (\n allowsSelection && (\n (e.pointerType === 'mouse' && !hasPrimaryAction) ||\n (e.pointerType === 'keyboard' && (!allowsActions || isSelectionKey()))\n )\n ) {\n onSelect(e);\n }\n };\n\n itemPressProps.onPress = (e) => {\n // Selection occurs on touch up. Primary actions always occur on pointer up.\n // Both primary and secondary actions occur on Enter key up. The only exception\n // is secondary actions, which occur on double click with a mouse.\n if (\n e.pointerType === 'touch' ||\n e.pointerType === 'pen' ||\n e.pointerType === 'virtual' ||\n (e.pointerType === 'keyboard' && hasAction && isActionKey()) ||\n (e.pointerType === 'mouse' && hadPrimaryActionOnPressStart.current)\n ) {\n if (hasAction) {\n performAction(e);\n } else if (allowsSelection) {\n onSelect(e);\n }\n }\n };\n }\n\n itemProps['data-key'] = key;\n itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;\n let {pressProps, isPressed} = usePress(itemPressProps);\n\n // Double clicking with a mouse with selectionBehavior = 'replace' performs an action.\n let onDoubleClick = hasSecondaryAction ? (e) => {\n if (modality.current === 'mouse') {\n e.stopPropagation();\n e.preventDefault();\n performAction(e);\n }\n } : undefined;\n\n // Long pressing an item with touch when selectionBehavior = 'replace' switches the selection behavior\n // to 'toggle'. This changes the single tap behavior from performing an action (i.e. navigating) to\n // selecting, and may toggle the appearance of a UI affordance like checkboxes on each item.\n let {longPressProps} = useLongPress({\n isDisabled: !longPressEnabled,\n onLongPress(e) {\n if (e.pointerType === 'touch') {\n onSelect(e);\n manager.setSelectionBehavior('toggle');\n }\n }\n });\n\n // Prevent native drag and drop on long press if we also select on long press.\n // Once the user is in selection mode, they can long press again to drag.\n // Use a capturing listener to ensure this runs before useDrag, regardless of\n // the order the props get merged.\n let onDragStartCapture = e => {\n if (modality.current === 'touch' && longPressEnabledOnPressStart.current) {\n e.preventDefault();\n }\n };\n\n // Prevent default on link clicks so that we control exactly\n // when they open (to match selection behavior).\n let onClick = manager.isLink(key) ? e => {\n if (!(openLink as any).isOpening) {\n e.preventDefault();\n }\n } : undefined;\n\n return {\n itemProps: mergeProps(\n itemProps,\n allowsSelection || hasPrimaryAction ? pressProps : {},\n longPressEnabled ? longPressProps : {},\n {onDoubleClick, onDragStartCapture, onClick}\n ),\n isPressed,\n isSelected: manager.isSelected(key),\n isFocused: manager.isFocused && manager.focusedKey === key,\n isDisabled,\n allowsSelection,\n hasAction\n };\n}\n\nfunction isActionKey() {\n let event = window.event as KeyboardEvent;\n return event?.key === 'Enter';\n}\n\nfunction isSelectionKey() {\n let event = window.event as KeyboardEvent;\n return event?.key === ' ' || event?.code === 'Space';\n}\n"],"names":[],"version":3,"file":"useSelectableItem.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAkGM,SAAS,0CAAkB,OAA8B;IAC9D,IAAI,EACF,kBAAkB,OAAO,OACzB,GAAG,OACH,GAAG,yBACH,qBAAqB,yBACrB,qBAAqB,SACrB,KAAK,cACL,UAAU,YACV,QAAQ,8BACR,0BAA0B,gBA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C/B,WAAW,QAAQ,SAAS,IAAI,QAAQ,UAAU,KAAK;oBACvD;yBACA;mBACA;IACF;AACF;AAEA,SAAS;IACP,IAAI,QAAQ,OAAO,KAAK;IACxB,OAAO,CAAA,kBAAA,4BAAA,MAAO,GAAG,MAAK;AACxB;AAEA,SAAS;IACP,IAAI,QAAQ,OAAO,KAAK;IACxB,OAAO,CAAA,kBAAA,4BAAA,MAAO,GAAG,MAAK,OAAO,CAAA,kBAAA,4BAAA,MAAO,IAAI,MAAK;AAC/C","sources":["packages/@react-aria/selection/src/useSelectableItem.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, FocusableElement, Key, LongPressEvent, PressEvent, RefObject} from '@react-types/shared';\nimport {focusSafely} from '@react-aria/focus';\nimport {isCtrlKeyPressed, isNonContiguousSelectionModifier} from './utils';\nimport {mergeProps, openLink, useRouter} from '@react-aria/utils';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {PressProps, useLongPress, usePress} from '@react-aria/interactions';\nimport {useEffect, useRef} from 'react';\n\nexport interface SelectableItemOptions {\n /**\n * An interface for reading and updating multiple selection state.\n */\n selectionManager: MultipleSelectionManager,\n /**\n * A unique key for the item.\n */\n key: Key,\n /**\n * Ref to the item.\n */\n ref: RefObject<FocusableElement | null>,\n /**\n * By default, selection occurs on pointer down. This can be strange if selecting an\n * item causes the UI to disappear immediately (e.g. menus).\n */\n shouldSelectOnPressUp?: boolean,\n /**\n * Whether selection requires the pointer/mouse down and up events to occur on the same target or triggers selection on\n * the target of the pointer/mouse up event.\n */\n allowsDifferentPressOrigin?: boolean,\n /**\n * Whether the option is contained in a virtual scroller.\n */\n isVirtualized?: boolean,\n /**\n * Function to focus the item.\n */\n focus?: () => void,\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean,\n /** Whether the item is disabled. */\n isDisabled?: boolean,\n /**\n * Handler that is called when a user performs an action on the item. The exact user event depends on\n * the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: () => void,\n /**\n * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n * - 'none': links are disabled for both selection and actions (e.g. handled elsewhere).\n * @default 'action'\n */\n linkBehavior?: 'action' | 'selection' | 'override' | 'none'\n}\n\nexport interface SelectableItemStates {\n /** Whether the item is currently in a pressed state. */\n isPressed: boolean,\n /** Whether the item is currently selected. */\n isSelected: boolean,\n /** Whether the item is currently focused. */\n isFocused: boolean,\n /**\n * Whether the item is non-interactive, i.e. both selection and actions are disabled and the item may\n * not be focused. Dependent on `disabledKeys` and `disabledBehavior`.\n */\n isDisabled: boolean,\n /**\n * Whether the item may be selected, dependent on `selectionMode`, `disabledKeys`, and `disabledBehavior`.\n */\n allowsSelection: boolean,\n /**\n * Whether the item has an action, dependent on `onAction`, `disabledKeys`,\n * and `disabledBehavior`. It may also change depending on the current selection state\n * of the list (e.g. when selection is primary). This can be used to enable or disable hover\n * styles or other visual indications of interactivity.\n */\n hasAction: boolean\n}\n\nexport interface SelectableItemAria extends SelectableItemStates {\n /**\n * Props to be spread on the item root node.\n */\n itemProps: DOMAttributes\n}\n\n/**\n * Handles interactions with an item in a selectable collection.\n */\nexport function useSelectableItem(options: SelectableItemOptions): SelectableItemAria {\n let {\n selectionManager: manager,\n key,\n ref,\n shouldSelectOnPressUp,\n shouldUseVirtualFocus,\n focus,\n isDisabled,\n onAction,\n allowsDifferentPressOrigin,\n linkBehavior = 'action'\n } = options;\n let router = useRouter();\n\n let onSelect = (e: PressEvent | LongPressEvent | PointerEvent) => {\n if (e.pointerType === 'keyboard' && isNonContiguousSelectionModifier(e)) {\n manager.toggleSelection(key);\n } else {\n if (manager.selectionMode === 'none') {\n return;\n }\n\n if (manager.isLink(key)) {\n if (linkBehavior === 'selection') {\n let itemProps = manager.getItemProps(key);\n router.open(ref.current, e, itemProps.href, itemProps.routerOptions);\n // Always set selected keys back to what they were so that select and combobox close.\n manager.setSelectedKeys(manager.selectedKeys);\n return;\n } else if (linkBehavior === 'override' || linkBehavior === 'none') {\n return;\n }\n }\n\n if (manager.selectionMode === 'single') {\n if (manager.isSelected(key) && !manager.disallowEmptySelection) {\n manager.toggleSelection(key);\n } else {\n manager.replaceSelection(key);\n }\n } else if (e && e.shiftKey) {\n manager.extendSelection(key);\n } else if (manager.selectionBehavior === 'toggle' || (e && (isCtrlKeyPressed(e) || e.pointerType === 'touch' || e.pointerType === 'virtual'))) {\n // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys\n manager.toggleSelection(key);\n } else {\n manager.replaceSelection(key);\n }\n }\n };\n\n // Focus the associated DOM node when this item becomes the focusedKey\n useEffect(() => {\n let isFocused = key === manager.focusedKey;\n if (isFocused && manager.isFocused && !shouldUseVirtualFocus) {\n if (focus) {\n focus();\n } else if (document.activeElement !== ref.current) {\n focusSafely(ref.current);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [ref, key, manager.focusedKey, manager.childFocusStrategy, manager.isFocused, shouldUseVirtualFocus]);\n\n isDisabled = isDisabled || manager.isDisabled(key);\n // Set tabIndex to 0 if the element is focused, or -1 otherwise so that only the last focused\n // item is tabbable. If using virtual focus, don't set a tabIndex at all so that VoiceOver\n // on iOS 14 doesn't try to move real DOM focus to the item anyway.\n let itemProps: SelectableItemAria['itemProps'] = {};\n if (!shouldUseVirtualFocus && !isDisabled) {\n itemProps = {\n tabIndex: key === manager.focusedKey ? 0 : -1,\n onFocus(e) {\n if (e.target === ref.current) {\n manager.setFocusedKey(key);\n }\n }\n };\n } else if (isDisabled) {\n itemProps.onMouseDown = (e) => {\n // Prevent focus going to the body when clicking on a disabled item.\n e.preventDefault();\n };\n }\n\n // With checkbox selection, onAction (i.e. navigation) becomes primary, and occurs on a single click of the row.\n // Clicking the checkbox enters selection mode, after which clicking anywhere on any row toggles selection for that row.\n // With highlight selection, onAction is secondary, and occurs on double click. Single click selects the row.\n // With touch, onAction occurs on single tap, and long press enters selection mode.\n let isLinkOverride = manager.isLink(key) && linkBehavior === 'override';\n let hasLinkAction = manager.isLink(key) && linkBehavior !== 'selection' && linkBehavior !== 'none';\n let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride;\n let allowsActions = (onAction || hasLinkAction) && !isDisabled;\n let hasPrimaryAction = allowsActions && (\n manager.selectionBehavior === 'replace'\n ? !allowsSelection\n : !allowsSelection || manager.isEmpty\n );\n let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === 'replace';\n let hasAction = hasPrimaryAction || hasSecondaryAction;\n let modality = useRef(null);\n\n let longPressEnabled = hasAction && allowsSelection;\n let longPressEnabledOnPressStart = useRef(false);\n let hadPrimaryActionOnPressStart = useRef(false);\n\n let performAction = (e) => {\n if (onAction) {\n onAction();\n }\n\n if (hasLinkAction) {\n let itemProps = manager.getItemProps(key);\n router.open(ref.current, e, itemProps.href, itemProps.routerOptions);\n }\n };\n\n // By default, selection occurs on pointer down. This can be strange if selecting an\n // item causes the UI to disappear immediately (e.g. menus).\n // If shouldSelectOnPressUp is true, we use onPressUp instead of onPressStart.\n // onPress requires a pointer down event on the same element as pointer up. For menus,\n // we want to be able to have the pointer down on the trigger that opens the menu and\n // the pointer up on the menu item rather than requiring a separate press.\n // For keyboard events, selection still occurs on key down.\n let itemPressProps: PressProps = {};\n if (shouldSelectOnPressUp) {\n itemPressProps.onPressStart = (e) => {\n modality.current = e.pointerType;\n longPressEnabledOnPressStart.current = longPressEnabled;\n if (e.pointerType === 'keyboard' && (!hasAction || isSelectionKey())) {\n onSelect(e);\n }\n };\n\n // If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.)\n // Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row)\n if (!allowsDifferentPressOrigin) {\n itemPressProps.onPress = (e) => {\n if (hasPrimaryAction || (hasSecondaryAction && e.pointerType !== 'mouse')) {\n if (e.pointerType === 'keyboard' && !isActionKey()) {\n return;\n }\n\n performAction(e);\n } else if (e.pointerType !== 'keyboard' && allowsSelection) {\n onSelect(e);\n }\n };\n } else {\n itemPressProps.onPressUp = hasPrimaryAction ? null : (e) => {\n if (e.pointerType !== 'keyboard' && allowsSelection) {\n onSelect(e);\n }\n };\n\n itemPressProps.onPress = hasPrimaryAction ? performAction : null;\n }\n } else {\n itemPressProps.onPressStart = (e) => {\n modality.current = e.pointerType;\n longPressEnabledOnPressStart.current = longPressEnabled;\n hadPrimaryActionOnPressStart.current = hasPrimaryAction;\n\n // Select on mouse down unless there is a primary action which will occur on mouse up.\n // For keyboard, select on key down. If there is an action, the Space key selects on key down,\n // and the Enter key performs onAction on key up.\n if (\n allowsSelection && (\n (e.pointerType === 'mouse' && !hasPrimaryAction) ||\n (e.pointerType === 'keyboard' && (!allowsActions || isSelectionKey()))\n )\n ) {\n onSelect(e);\n }\n };\n\n itemPressProps.onPress = (e) => {\n // Selection occurs on touch up. Primary actions always occur on pointer up.\n // Both primary and secondary actions occur on Enter key up. The only exception\n // is secondary actions, which occur on double click with a mouse.\n if (\n e.pointerType === 'touch' ||\n e.pointerType === 'pen' ||\n e.pointerType === 'virtual' ||\n (e.pointerType === 'keyboard' && hasAction && isActionKey()) ||\n (e.pointerType === 'mouse' && hadPrimaryActionOnPressStart.current)\n ) {\n if (hasAction) {\n performAction(e);\n } else if (allowsSelection) {\n onSelect(e);\n }\n }\n };\n }\n\n itemProps['data-key'] = key;\n itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;\n let {pressProps, isPressed} = usePress(itemPressProps);\n\n // Double clicking with a mouse with selectionBehavior = 'replace' performs an action.\n let onDoubleClick = hasSecondaryAction ? (e) => {\n if (modality.current === 'mouse') {\n e.stopPropagation();\n e.preventDefault();\n performAction(e);\n }\n } : undefined;\n\n // Long pressing an item with touch when selectionBehavior = 'replace' switches the selection behavior\n // to 'toggle'. This changes the single tap behavior from performing an action (i.e. navigating) to\n // selecting, and may toggle the appearance of a UI affordance like checkboxes on each item.\n let {longPressProps} = useLongPress({\n isDisabled: !longPressEnabled,\n onLongPress(e) {\n if (e.pointerType === 'touch') {\n onSelect(e);\n manager.setSelectionBehavior('toggle');\n }\n }\n });\n\n // Prevent native drag and drop on long press if we also select on long press.\n // Once the user is in selection mode, they can long press again to drag.\n // Use a capturing listener to ensure this runs before useDrag, regardless of\n // the order the props get merged.\n let onDragStartCapture = e => {\n if (modality.current === 'touch' && longPressEnabledOnPressStart.current) {\n e.preventDefault();\n }\n };\n\n // Prevent default on link clicks so that we control exactly\n // when they open (to match selection behavior).\n let onClick = manager.isLink(key) ? e => {\n if (!(openLink as any).isOpening) {\n e.preventDefault();\n }\n } : undefined;\n\n return {\n itemProps: mergeProps(\n itemProps,\n allowsSelection || hasPrimaryAction ? pressProps : {},\n longPressEnabled ? longPressProps : {},\n {onDoubleClick, onDragStartCapture, onClick}\n ),\n isPressed,\n isSelected: manager.isSelected(key),\n isFocused: manager.isFocused && manager.focusedKey === key,\n isDisabled,\n allowsSelection,\n hasAction\n };\n}\n\nfunction isActionKey() {\n let event = window.event as KeyboardEvent;\n return event?.key === 'Enter';\n}\n\nfunction isSelectionKey() {\n let event = window.event as KeyboardEvent;\n return event?.key === ' ' || event?.code === 'Space';\n}\n"],"names":[],"version":3,"file":"useSelectableItem.main.js.map"}
@@ -20,26 +20,26 @@ import {useEffect as $581M0$useEffect, useRef as $581M0$useRef} from "react";
20
20
 
21
21
 
22
22
  function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
23
- let { selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = "action" } = options;
23
+ let { selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = 'action' } = options;
24
24
  let router = (0, $581M0$useRouter)();
25
25
  let onSelect = (e)=>{
26
- if (e.pointerType === "keyboard" && (0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) manager.toggleSelection(key);
26
+ if (e.pointerType === 'keyboard' && (0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) manager.toggleSelection(key);
27
27
  else {
28
- if (manager.selectionMode === "none") return;
28
+ if (manager.selectionMode === 'none') return;
29
29
  if (manager.isLink(key)) {
30
- if (linkBehavior === "selection") {
30
+ if (linkBehavior === 'selection') {
31
31
  let itemProps = manager.getItemProps(key);
32
32
  router.open(ref.current, e, itemProps.href, itemProps.routerOptions);
33
33
  // Always set selected keys back to what they were so that select and combobox close.
34
34
  manager.setSelectedKeys(manager.selectedKeys);
35
35
  return;
36
- } else if (linkBehavior === "override" || linkBehavior === "none") return;
36
+ } else if (linkBehavior === 'override' || linkBehavior === 'none') return;
37
37
  }
38
- if (manager.selectionMode === "single") {
38
+ if (manager.selectionMode === 'single') {
39
39
  if (manager.isSelected(key) && !manager.disallowEmptySelection) manager.toggleSelection(key);
40
40
  else manager.replaceSelection(key);
41
41
  } else if (e && e.shiftKey) manager.extendSelection(key);
42
- else if (manager.selectionBehavior === "toggle" || e && ((0, $feb5ffebff200149$export$16792effe837dba3)(e) || e.pointerType === "touch" || e.pointerType === "virtual")) // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys
42
+ else if (manager.selectionBehavior === 'toggle' || e && ((0, $feb5ffebff200149$export$16792effe837dba3)(e) || e.pointerType === 'touch' || e.pointerType === 'virtual')) // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys
43
43
  manager.toggleSelection(key);
44
44
  else manager.replaceSelection(key);
45
45
  }
@@ -79,12 +79,12 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
79
79
  // Clicking the checkbox enters selection mode, after which clicking anywhere on any row toggles selection for that row.
80
80
  // With highlight selection, onAction is secondary, and occurs on double click. Single click selects the row.
81
81
  // With touch, onAction occurs on single tap, and long press enters selection mode.
82
- let isLinkOverride = manager.isLink(key) && linkBehavior === "override";
83
- let hasLinkAction = manager.isLink(key) && linkBehavior !== "selection" && linkBehavior !== "none";
82
+ let isLinkOverride = manager.isLink(key) && linkBehavior === 'override';
83
+ let hasLinkAction = manager.isLink(key) && linkBehavior !== 'selection' && linkBehavior !== 'none';
84
84
  let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride;
85
85
  let allowsActions = (onAction || hasLinkAction) && !isDisabled;
86
- let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : !allowsSelection || manager.isEmpty);
87
- let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === "replace";
86
+ let hasPrimaryAction = allowsActions && (manager.selectionBehavior === 'replace' ? !allowsSelection : !allowsSelection || manager.isEmpty);
87
+ let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === 'replace';
88
88
  let hasAction = hasPrimaryAction || hasSecondaryAction;
89
89
  let modality = (0, $581M0$useRef)(null);
90
90
  let longPressEnabled = hasAction && allowsSelection;
@@ -109,19 +109,19 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
109
109
  itemPressProps.onPressStart = (e)=>{
110
110
  modality.current = e.pointerType;
111
111
  longPressEnabledOnPressStart.current = longPressEnabled;
112
- if (e.pointerType === "keyboard" && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
112
+ if (e.pointerType === 'keyboard' && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
113
113
  };
114
114
  // If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.)
115
115
  // Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row)
116
116
  if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e)=>{
117
- if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== "mouse") {
118
- if (e.pointerType === "keyboard" && !$880e95eb8b93ba9a$var$isActionKey()) return;
117
+ if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== 'mouse') {
118
+ if (e.pointerType === 'keyboard' && !$880e95eb8b93ba9a$var$isActionKey()) return;
119
119
  performAction(e);
120
- } else if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
120
+ } else if (e.pointerType !== 'keyboard' && allowsSelection) onSelect(e);
121
121
  };
122
122
  else {
123
123
  itemPressProps.onPressUp = hasPrimaryAction ? null : (e)=>{
124
- if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
124
+ if (e.pointerType !== 'keyboard' && allowsSelection) onSelect(e);
125
125
  };
126
126
  itemPressProps.onPress = hasPrimaryAction ? performAction : null;
127
127
  }
@@ -133,24 +133,24 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
133
133
  // Select on mouse down unless there is a primary action which will occur on mouse up.
134
134
  // For keyboard, select on key down. If there is an action, the Space key selects on key down,
135
135
  // and the Enter key performs onAction on key up.
136
- if (allowsSelection && (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!allowsActions || $880e95eb8b93ba9a$var$isSelectionKey()))) onSelect(e);
136
+ if (allowsSelection && (e.pointerType === 'mouse' && !hasPrimaryAction || e.pointerType === 'keyboard' && (!allowsActions || $880e95eb8b93ba9a$var$isSelectionKey()))) onSelect(e);
137
137
  };
138
138
  itemPressProps.onPress = (e)=>{
139
139
  // Selection occurs on touch up. Primary actions always occur on pointer up.
140
140
  // Both primary and secondary actions occur on Enter key up. The only exception
141
141
  // is secondary actions, which occur on double click with a mouse.
142
- if (e.pointerType === "touch" || e.pointerType === "pen" || e.pointerType === "virtual" || e.pointerType === "keyboard" && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === "mouse" && hadPrimaryActionOnPressStart.current) {
142
+ if (e.pointerType === 'touch' || e.pointerType === 'pen' || e.pointerType === 'virtual' || e.pointerType === 'keyboard' && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === 'mouse' && hadPrimaryActionOnPressStart.current) {
143
143
  if (hasAction) performAction(e);
144
144
  else if (allowsSelection) onSelect(e);
145
145
  }
146
146
  };
147
147
  }
148
- itemProps["data-key"] = key;
148
+ itemProps['data-key'] = key;
149
149
  itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
150
150
  let { pressProps: pressProps, isPressed: isPressed } = (0, $581M0$usePress)(itemPressProps);
151
151
  // Double clicking with a mouse with selectionBehavior = 'replace' performs an action.
152
152
  let onDoubleClick = hasSecondaryAction ? (e)=>{
153
- if (modality.current === "mouse") {
153
+ if (modality.current === 'mouse') {
154
154
  e.stopPropagation();
155
155
  e.preventDefault();
156
156
  performAction(e);
@@ -162,9 +162,9 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
162
162
  let { longPressProps: longPressProps } = (0, $581M0$useLongPress)({
163
163
  isDisabled: !longPressEnabled,
164
164
  onLongPress (e) {
165
- if (e.pointerType === "touch") {
165
+ if (e.pointerType === 'touch') {
166
166
  onSelect(e);
167
- manager.setSelectionBehavior("toggle");
167
+ manager.setSelectionBehavior('toggle');
168
168
  }
169
169
  }
170
170
  });
@@ -173,7 +173,7 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
173
173
  // Use a capturing listener to ensure this runs before useDrag, regardless of
174
174
  // the order the props get merged.
175
175
  let onDragStartCapture = (e)=>{
176
- if (modality.current === "touch" && longPressEnabledOnPressStart.current) e.preventDefault();
176
+ if (modality.current === 'touch' && longPressEnabledOnPressStart.current) e.preventDefault();
177
177
  };
178
178
  // Prevent default on link clicks so that we control exactly
179
179
  // when they open (to match selection behavior).
@@ -196,13 +196,13 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
196
196
  }
197
197
  function $880e95eb8b93ba9a$var$isActionKey() {
198
198
  let event = window.event;
199
- return (event === null || event === void 0 ? void 0 : event.key) === "Enter";
199
+ return (event === null || event === void 0 ? void 0 : event.key) === 'Enter';
200
200
  }
201
201
  function $880e95eb8b93ba9a$var$isSelectionKey() {
202
202
  let event = window.event;
203
- return (event === null || event === void 0 ? void 0 : event.key) === " " || (event === null || event === void 0 ? void 0 : event.code) === "Space";
203
+ return (event === null || event === void 0 ? void 0 : event.key) === ' ' || (event === null || event === void 0 ? void 0 : event.code) === 'Space';
204
204
  }
205
205
 
206
206
 
207
207
  export {$880e95eb8b93ba9a$export$ecf600387e221c37 as useSelectableItem};
208
- //# sourceMappingURL=useSelectableItem.mjs.map
208
+ //# sourceMappingURL=useSelectableItem.module.js.map
@@ -20,26 +20,26 @@ import {useEffect as $581M0$useEffect, useRef as $581M0$useRef} from "react";
20
20
 
21
21
 
22
22
  function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
23
- let { selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = "action" } = options;
23
+ let { selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = 'action' } = options;
24
24
  let router = (0, $581M0$useRouter)();
25
25
  let onSelect = (e)=>{
26
- if (e.pointerType === "keyboard" && (0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) manager.toggleSelection(key);
26
+ if (e.pointerType === 'keyboard' && (0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) manager.toggleSelection(key);
27
27
  else {
28
- if (manager.selectionMode === "none") return;
28
+ if (manager.selectionMode === 'none') return;
29
29
  if (manager.isLink(key)) {
30
- if (linkBehavior === "selection") {
30
+ if (linkBehavior === 'selection') {
31
31
  let itemProps = manager.getItemProps(key);
32
32
  router.open(ref.current, e, itemProps.href, itemProps.routerOptions);
33
33
  // Always set selected keys back to what they were so that select and combobox close.
34
34
  manager.setSelectedKeys(manager.selectedKeys);
35
35
  return;
36
- } else if (linkBehavior === "override" || linkBehavior === "none") return;
36
+ } else if (linkBehavior === 'override' || linkBehavior === 'none') return;
37
37
  }
38
- if (manager.selectionMode === "single") {
38
+ if (manager.selectionMode === 'single') {
39
39
  if (manager.isSelected(key) && !manager.disallowEmptySelection) manager.toggleSelection(key);
40
40
  else manager.replaceSelection(key);
41
41
  } else if (e && e.shiftKey) manager.extendSelection(key);
42
- else if (manager.selectionBehavior === "toggle" || e && ((0, $feb5ffebff200149$export$16792effe837dba3)(e) || e.pointerType === "touch" || e.pointerType === "virtual")) // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys
42
+ else if (manager.selectionBehavior === 'toggle' || e && ((0, $feb5ffebff200149$export$16792effe837dba3)(e) || e.pointerType === 'touch' || e.pointerType === 'virtual')) // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys
43
43
  manager.toggleSelection(key);
44
44
  else manager.replaceSelection(key);
45
45
  }
@@ -79,12 +79,12 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
79
79
  // Clicking the checkbox enters selection mode, after which clicking anywhere on any row toggles selection for that row.
80
80
  // With highlight selection, onAction is secondary, and occurs on double click. Single click selects the row.
81
81
  // With touch, onAction occurs on single tap, and long press enters selection mode.
82
- let isLinkOverride = manager.isLink(key) && linkBehavior === "override";
83
- let hasLinkAction = manager.isLink(key) && linkBehavior !== "selection" && linkBehavior !== "none";
82
+ let isLinkOverride = manager.isLink(key) && linkBehavior === 'override';
83
+ let hasLinkAction = manager.isLink(key) && linkBehavior !== 'selection' && linkBehavior !== 'none';
84
84
  let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride;
85
85
  let allowsActions = (onAction || hasLinkAction) && !isDisabled;
86
- let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : !allowsSelection || manager.isEmpty);
87
- let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === "replace";
86
+ let hasPrimaryAction = allowsActions && (manager.selectionBehavior === 'replace' ? !allowsSelection : !allowsSelection || manager.isEmpty);
87
+ let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === 'replace';
88
88
  let hasAction = hasPrimaryAction || hasSecondaryAction;
89
89
  let modality = (0, $581M0$useRef)(null);
90
90
  let longPressEnabled = hasAction && allowsSelection;
@@ -109,19 +109,19 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
109
109
  itemPressProps.onPressStart = (e)=>{
110
110
  modality.current = e.pointerType;
111
111
  longPressEnabledOnPressStart.current = longPressEnabled;
112
- if (e.pointerType === "keyboard" && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
112
+ if (e.pointerType === 'keyboard' && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
113
113
  };
114
114
  // If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.)
115
115
  // Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row)
116
116
  if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e)=>{
117
- if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== "mouse") {
118
- if (e.pointerType === "keyboard" && !$880e95eb8b93ba9a$var$isActionKey()) return;
117
+ if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== 'mouse') {
118
+ if (e.pointerType === 'keyboard' && !$880e95eb8b93ba9a$var$isActionKey()) return;
119
119
  performAction(e);
120
- } else if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
120
+ } else if (e.pointerType !== 'keyboard' && allowsSelection) onSelect(e);
121
121
  };
122
122
  else {
123
123
  itemPressProps.onPressUp = hasPrimaryAction ? null : (e)=>{
124
- if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
124
+ if (e.pointerType !== 'keyboard' && allowsSelection) onSelect(e);
125
125
  };
126
126
  itemPressProps.onPress = hasPrimaryAction ? performAction : null;
127
127
  }
@@ -133,24 +133,24 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
133
133
  // Select on mouse down unless there is a primary action which will occur on mouse up.
134
134
  // For keyboard, select on key down. If there is an action, the Space key selects on key down,
135
135
  // and the Enter key performs onAction on key up.
136
- if (allowsSelection && (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!allowsActions || $880e95eb8b93ba9a$var$isSelectionKey()))) onSelect(e);
136
+ if (allowsSelection && (e.pointerType === 'mouse' && !hasPrimaryAction || e.pointerType === 'keyboard' && (!allowsActions || $880e95eb8b93ba9a$var$isSelectionKey()))) onSelect(e);
137
137
  };
138
138
  itemPressProps.onPress = (e)=>{
139
139
  // Selection occurs on touch up. Primary actions always occur on pointer up.
140
140
  // Both primary and secondary actions occur on Enter key up. The only exception
141
141
  // is secondary actions, which occur on double click with a mouse.
142
- if (e.pointerType === "touch" || e.pointerType === "pen" || e.pointerType === "virtual" || e.pointerType === "keyboard" && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === "mouse" && hadPrimaryActionOnPressStart.current) {
142
+ if (e.pointerType === 'touch' || e.pointerType === 'pen' || e.pointerType === 'virtual' || e.pointerType === 'keyboard' && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === 'mouse' && hadPrimaryActionOnPressStart.current) {
143
143
  if (hasAction) performAction(e);
144
144
  else if (allowsSelection) onSelect(e);
145
145
  }
146
146
  };
147
147
  }
148
- itemProps["data-key"] = key;
148
+ itemProps['data-key'] = key;
149
149
  itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
150
150
  let { pressProps: pressProps, isPressed: isPressed } = (0, $581M0$usePress)(itemPressProps);
151
151
  // Double clicking with a mouse with selectionBehavior = 'replace' performs an action.
152
152
  let onDoubleClick = hasSecondaryAction ? (e)=>{
153
- if (modality.current === "mouse") {
153
+ if (modality.current === 'mouse') {
154
154
  e.stopPropagation();
155
155
  e.preventDefault();
156
156
  performAction(e);
@@ -162,9 +162,9 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
162
162
  let { longPressProps: longPressProps } = (0, $581M0$useLongPress)({
163
163
  isDisabled: !longPressEnabled,
164
164
  onLongPress (e) {
165
- if (e.pointerType === "touch") {
165
+ if (e.pointerType === 'touch') {
166
166
  onSelect(e);
167
- manager.setSelectionBehavior("toggle");
167
+ manager.setSelectionBehavior('toggle');
168
168
  }
169
169
  }
170
170
  });
@@ -173,7 +173,7 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
173
173
  // Use a capturing listener to ensure this runs before useDrag, regardless of
174
174
  // the order the props get merged.
175
175
  let onDragStartCapture = (e)=>{
176
- if (modality.current === "touch" && longPressEnabledOnPressStart.current) e.preventDefault();
176
+ if (modality.current === 'touch' && longPressEnabledOnPressStart.current) e.preventDefault();
177
177
  };
178
178
  // Prevent default on link clicks so that we control exactly
179
179
  // when they open (to match selection behavior).
@@ -196,11 +196,11 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
196
196
  }
197
197
  function $880e95eb8b93ba9a$var$isActionKey() {
198
198
  let event = window.event;
199
- return (event === null || event === void 0 ? void 0 : event.key) === "Enter";
199
+ return (event === null || event === void 0 ? void 0 : event.key) === 'Enter';
200
200
  }
201
201
  function $880e95eb8b93ba9a$var$isSelectionKey() {
202
202
  let event = window.event;
203
- return (event === null || event === void 0 ? void 0 : event.key) === " " || (event === null || event === void 0 ? void 0 : event.code) === "Space";
203
+ return (event === null || event === void 0 ? void 0 : event.key) === ' ' || (event === null || event === void 0 ? void 0 : event.code) === 'Space';
204
204
  }
205
205
 
206
206