@react-aria/dnd 3.0.0-nightly.3449 → 3.0.0-nightly.3460

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -22,6 +22,7 @@ $parcel$export(module.exports, "useDraggableItem", () => $0cbbd00cda972c67$expor
22
22
  $parcel$export(module.exports, "useClipboard", () => $74f3dedaa4d234b4$export$2314ca2a3e892862);
23
23
  $parcel$export(module.exports, "DragPreview", () => $2dccaca1f4baa446$export$905ab40ac2179daa);
24
24
  $parcel$export(module.exports, "ListDropTargetDelegate", () => $2268795bbb597ecb$export$fbd65d14c79e28cc);
25
+ $parcel$export(module.exports, "isVirtualDragging", () => $28e10663603f5ea1$export$403bc76cbf68cf60);
25
26
 
26
27
 
27
28
 
@@ -45,6 +46,7 @@ const $76b1e110a27b1ccd$export$9bbdfc78cf083e16 = {
45
46
  uninitialized: $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.all
46
47
  };
47
48
  const $76b1e110a27b1ccd$export$dd0165308d8bff45 = $76b1e110a27b1ccd$var$invert($76b1e110a27b1ccd$export$9bbdfc78cf083e16);
49
+ $76b1e110a27b1ccd$export$dd0165308d8bff45[$76b1e110a27b1ccd$export$60b7b4bcf3903d8e.all] = 'all'; // ensure we don't map to 'uninitialized'.
48
50
  const $76b1e110a27b1ccd$export$d7ebf00f36b7a95e = $76b1e110a27b1ccd$var$invert($76b1e110a27b1ccd$export$60b7b4bcf3903d8e);
49
51
  const $76b1e110a27b1ccd$export$608ecc6f1b23c35d = {
50
52
  none: 'cancel',
@@ -265,6 +267,10 @@ function $4620ae0dc40f0031$var$getEntryFile(entry) {
265
267
  return new Promise((resolve, reject)=>entry.file(resolve, reject)
266
268
  );
267
269
  }
270
+ let $4620ae0dc40f0031$export$f0130eb70b6347b8 = $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.none;
271
+ function $4620ae0dc40f0031$export$6539bc8c3a0a2d67(o) {
272
+ $4620ae0dc40f0031$export$f0130eb70b6347b8 = o;
273
+ }
268
274
 
269
275
 
270
276
 
@@ -311,6 +317,9 @@ function $28e10663603f5ea1$export$418e185dd3f1b968() {
311
317
  }, []);
312
318
  return session;
313
319
  }
320
+ function $28e10663603f5ea1$export$403bc76cbf68cf60() {
321
+ return !!$28e10663603f5ea1$var$dragSession;
322
+ }
314
323
  function $28e10663603f5ea1$var$endDragging() {
315
324
  $28e10663603f5ea1$var$dragSession = null;
316
325
  for (let cb of $28e10663603f5ea1$var$subscriptions)cb();
@@ -913,8 +922,28 @@ $7e3982b34ddf1bdf$exports = {
913
922
  })}`
914
923
  ,
915
924
  "dragDescriptionKeyboard": `Press Enter to start dragging.`,
925
+ "dragDescriptionKeyboardAlt": `Press Alt + Enter to start dragging.`,
916
926
  "dragDescriptionTouch": `Double tap to start dragging.`,
917
927
  "dragDescriptionVirtual": `Click to start dragging.`,
928
+ "dragDescriptionLongPress": `Long press to start dragging.`,
929
+ "dragSelectedKeyboard": (args, formatter)=>`Press Enter to drag ${formatter.plural(args.count, {
930
+ one: ()=>`${formatter.number(args.count)} selected item`
931
+ ,
932
+ other: ()=>`${formatter.number(args.count)} selected items`
933
+ })}.`
934
+ ,
935
+ "dragSelectedKeyboardAlt": (args, formatter)=>`Press Alt + Enter to drag ${formatter.plural(args.count, {
936
+ one: ()=>`${formatter.number(args.count)} selected item`
937
+ ,
938
+ other: ()=>`${formatter.number(args.count)} selected items`
939
+ })}.`
940
+ ,
941
+ "dragSelectedLongPress": (args, formatter)=>`Long press to drag ${formatter.plural(args.count, {
942
+ one: ()=>`${formatter.number(args.count)} selected item`
943
+ ,
944
+ other: ()=>`${formatter.number(args.count)} selected items`
945
+ })}.`
946
+ ,
918
947
  "dragStartedKeyboard": `Started dragging. Press Tab to navigate to a drop target, then press Enter to drop, or press Escape to cancel.`,
919
948
  "dragStartedTouch": `Started dragging. Navigate to a drop target, then double tap to drop.`,
920
949
  "dragStartedVirtual": `Started dragging. Navigate to a drop target, then click or press Enter to drop.`,
@@ -1967,6 +1996,7 @@ const $dc204e8ec58447a6$var$MESSAGES = {
1967
1996
  }
1968
1997
  };
1969
1998
  function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
1999
+ let { hasDragButton: hasDragButton } = options;
1970
2000
  let stringFormatter = $4vY0V$reactariai18n.useLocalizedStringFormatter((/*@__PURE__*/$parcel$interopDefault($d624b4da796f302a$exports)));
1971
2001
  let state = $4vY0V$react.useRef({
1972
2002
  options: options,
@@ -1976,9 +2006,17 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
1976
2006
  state.options = options;
1977
2007
  let [isDragging, setDragging] = $4vY0V$react.useState(false);
1978
2008
  let { addGlobalListener: addGlobalListener , removeAllGlobalListeners: removeAllGlobalListeners } = $4vY0V$reactariautils.useGlobalListeners();
2009
+ let modalityOnPointerDown = $4vY0V$react.useRef(null);
1979
2010
  let onDragStart = (e1)=>{
1980
2011
  var ref;
1981
2012
  if (e1.defaultPrevented) return;
2013
+ // If this drag was initiated by a mobile screen reader (e.g. VoiceOver or TalkBack), enter virtual dragging mode.
2014
+ if (modalityOnPointerDown.current === 'virtual') {
2015
+ e1.preventDefault();
2016
+ startDragging(e1.target);
2017
+ modalityOnPointerDown.current = null;
2018
+ return;
2019
+ }
1982
2020
  if (typeof options.onDragStart === 'function') options.onDragStart({
1983
2021
  type: 'dragstart',
1984
2022
  x: e1.clientX,
@@ -1986,12 +2024,14 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
1986
2024
  });
1987
2025
  let items = options.getItems();
1988
2026
  $4620ae0dc40f0031$export$f9c1490890ddd063(e1.dataTransfer, items);
2027
+ let allowed = $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.all;
1989
2028
  if (typeof options.getAllowedDropOperations === 'function') {
1990
2029
  let allowedOperations = options.getAllowedDropOperations();
1991
- let allowed = $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.none;
2030
+ allowed = $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.none;
1992
2031
  for (let operation of allowedOperations)allowed |= $76b1e110a27b1ccd$export$60b7b4bcf3903d8e[operation] || $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.none;
1993
- e1.dataTransfer.effectAllowed = $76b1e110a27b1ccd$export$dd0165308d8bff45[allowed] || 'none';
1994
2032
  }
2033
+ $4620ae0dc40f0031$export$6539bc8c3a0a2d67(allowed);
2034
+ e1.dataTransfer.effectAllowed = $76b1e110a27b1ccd$export$dd0165308d8bff45[allowed] || 'none';
1995
2035
  // If there is a preview option, use it to render a custom preview image that will
1996
2036
  // appear under the pointer while dragging. If not, the element itself is dragged by the browser.
1997
2037
  if (typeof ((ref = options.preview) === null || ref === void 0 ? void 0 : ref.current) === 'function') options.preview.current(items, (node)=>{
@@ -2049,11 +2089,15 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
2049
2089
  });
2050
2090
  setDragging(false);
2051
2091
  removeAllGlobalListeners();
2092
+ $4620ae0dc40f0031$export$6539bc8c3a0a2d67($76b1e110a27b1ccd$export$60b7b4bcf3903d8e.none);
2093
+ };
2094
+ let onPress = (e)=>{
2095
+ if (e.pointerType !== 'keyboard' && e.pointerType !== 'virtual') return;
2096
+ startDragging(e.target);
2052
2097
  };
2053
- let onPress = (e2)=>{
2054
- if (e2.pointerType !== 'keyboard' && e2.pointerType !== 'virtual') return;
2098
+ let startDragging = (target)=>{
2055
2099
  if (typeof state.options.onDragStart === 'function') {
2056
- let rect = e2.target.getBoundingClientRect();
2100
+ let rect = target.getBoundingClientRect();
2057
2101
  state.options.onDragStart({
2058
2102
  type: 'dragstart',
2059
2103
  x: rect.x + rect.width / 2,
@@ -2061,7 +2105,7 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
2061
2105
  });
2062
2106
  }
2063
2107
  $28e10663603f5ea1$export$549dbcf8649bf3b2({
2064
- element: e2.target,
2108
+ element: target,
2065
2109
  items: state.options.getItems(),
2066
2110
  allowedDropOperations: typeof state.options.getAllowedDropOperations === 'function' ? state.options.getAllowedDropOperations() : [
2067
2111
  'move',
@@ -2076,9 +2120,51 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
2076
2120
  setDragging(true);
2077
2121
  };
2078
2122
  let modality = $4620ae0dc40f0031$export$49bac5d6d4b352ea();
2079
- let descriptionProps = $4vY0V$reactariautils.useDescription(stringFormatter.format(!isDragging ? $dc204e8ec58447a6$var$MESSAGES[modality].start : $dc204e8ec58447a6$var$MESSAGES[modality].end));
2123
+ let message;
2124
+ if (!isDragging) {
2125
+ if (modality === 'touch' && !hasDragButton) message = 'dragDescriptionLongPress';
2126
+ else message = $dc204e8ec58447a6$var$MESSAGES[modality].start;
2127
+ } else message = $dc204e8ec58447a6$var$MESSAGES[modality].end;
2128
+ let descriptionProps = $4vY0V$reactariautils.useDescription(stringFormatter.format(message));
2129
+ let interactions;
2130
+ if (!hasDragButton) // If there's no separate button to trigger accessible drag and drop mode,
2131
+ // then add event handlers to the draggable element itself to start dragging.
2132
+ // For keyboard, we use the Enter key in a capturing listener to prevent other
2133
+ // events such as selection from also occurring. We attempt to infer whether a
2134
+ // pointer event (e.g. long press) came from a touch screen reader, and then initiate
2135
+ // dragging in the native onDragStart listener above.
2136
+ interactions = {
2137
+ ...descriptionProps,
2138
+ onPointerDown ({ nativeEvent: e }) {
2139
+ // Try to detect virtual drags.
2140
+ if (e.width < 1 && e.height < 1) // iOS VoiceOver.
2141
+ modalityOnPointerDown.current = 'virtual';
2142
+ else {
2143
+ let rect = e.target.getBoundingClientRect();
2144
+ let centerX = rect.width / 2;
2145
+ let centerY = rect.height / 2;
2146
+ if (Math.abs(e.offsetX - centerX) < 0.5 && Math.abs(e.offsetY - centerY) < 0.5) // Android TalkBack.
2147
+ modalityOnPointerDown.current = 'virtual';
2148
+ else modalityOnPointerDown.current = e.pointerType;
2149
+ }
2150
+ },
2151
+ onKeyDownCapture (e) {
2152
+ if (e.target === e.currentTarget && e.key === 'Enter') {
2153
+ e.preventDefault();
2154
+ e.stopPropagation();
2155
+ }
2156
+ },
2157
+ onKeyUpCapture (e) {
2158
+ if (e.target === e.currentTarget && e.key === 'Enter') {
2159
+ e.preventDefault();
2160
+ e.stopPropagation();
2161
+ startDragging(e.target);
2162
+ }
2163
+ }
2164
+ };
2080
2165
  return {
2081
2166
  dragProps: {
2167
+ ...interactions,
2082
2168
  draggable: 'true',
2083
2169
  onDragStart: onDragStart,
2084
2170
  onDrag: onDrag,
@@ -2136,7 +2222,7 @@ function $1ca228bc9257ca16$export$ccdee5eaf73cf661(options) {
2136
2222
  y: 0,
2137
2223
  dragOverElements: new Set(),
2138
2224
  dropEffect: 'none',
2139
- effectAllowed: 'none',
2225
+ allowedOperations: $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.all,
2140
2226
  dropActivateTimer: null
2141
2227
  }).current;
2142
2228
  let fireDropEnter = (e)=>{
@@ -2164,7 +2250,8 @@ function $1ca228bc9257ca16$export$ccdee5eaf73cf661(options) {
2164
2250
  let onDragOver = (e)=>{
2165
2251
  e.preventDefault();
2166
2252
  e.stopPropagation();
2167
- if (e.clientX === state.x && e.clientY === state.y && e.dataTransfer.effectAllowed === state.effectAllowed) {
2253
+ let allowedOperations = $1ca228bc9257ca16$var$getAllowedOperations(e);
2254
+ if (e.clientX === state.x && e.clientY === state.y && allowedOperations === state.allowedOperations) {
2168
2255
  e.dataTransfer.dropEffect = state.dropEffect;
2169
2256
  return;
2170
2257
  }
@@ -2172,23 +2259,22 @@ function $1ca228bc9257ca16$export$ccdee5eaf73cf661(options) {
2172
2259
  state.y = e.clientY;
2173
2260
  let prevDropEffect = state.dropEffect;
2174
2261
  // Update drop effect if allowed drop operations changed (e.g. user pressed modifier key).
2175
- if (e.dataTransfer.effectAllowed !== state.effectAllowed) {
2176
- let allowedOperations = $1ca228bc9257ca16$var$effectAllowedToOperations(e.dataTransfer.effectAllowed);
2177
- let dropOperation = allowedOperations[0];
2262
+ if (allowedOperations !== state.allowedOperations) {
2263
+ let allowedOps = $1ca228bc9257ca16$var$allowedOperationsToArray(allowedOperations);
2264
+ let dropOperation = allowedOps[0];
2178
2265
  if (typeof options.getDropOperation === 'function') {
2179
2266
  let types = new $4620ae0dc40f0031$export$7f04ce188c91447c(e.dataTransfer);
2180
- dropOperation = $1ca228bc9257ca16$var$getDropOperation(e.dataTransfer.effectAllowed, options.getDropOperation(types, allowedOperations));
2267
+ dropOperation = $1ca228bc9257ca16$var$getDropOperation(allowedOperations, options.getDropOperation(types, allowedOps));
2181
2268
  }
2182
2269
  state.dropEffect = $76b1e110a27b1ccd$export$5eacb0769d26d3b2[dropOperation] || 'none';
2183
2270
  }
2184
2271
  if (typeof options.getDropOperationForPoint === 'function') {
2185
- let allowedOperations = $1ca228bc9257ca16$var$effectAllowedToOperations(e.dataTransfer.effectAllowed);
2186
2272
  let types = new $4620ae0dc40f0031$export$7f04ce188c91447c(e.dataTransfer);
2187
2273
  let rect = e.currentTarget.getBoundingClientRect();
2188
- let dropOperation = $1ca228bc9257ca16$var$getDropOperation(e.dataTransfer.effectAllowed, options.getDropOperationForPoint(types, allowedOperations, state.x - rect.x, state.y - rect.y));
2274
+ let dropOperation = $1ca228bc9257ca16$var$getDropOperation(allowedOperations, options.getDropOperationForPoint(types, $1ca228bc9257ca16$var$allowedOperationsToArray(allowedOperations), state.x - rect.x, state.y - rect.y));
2189
2275
  state.dropEffect = $76b1e110a27b1ccd$export$5eacb0769d26d3b2[dropOperation] || 'none';
2190
2276
  }
2191
- state.effectAllowed = e.dataTransfer.effectAllowed;
2277
+ state.allowedOperations = allowedOperations;
2192
2278
  e.dataTransfer.dropEffect = state.dropEffect;
2193
2279
  // If the drop operation changes, update state and fire events appropriately.
2194
2280
  if (state.dropEffect === 'none' && prevDropEffect !== 'none') fireDropExit(e);
@@ -2217,20 +2303,21 @@ function $1ca228bc9257ca16$export$ccdee5eaf73cf661(options) {
2217
2303
  e.stopPropagation();
2218
2304
  state.dragOverElements.add(e.target);
2219
2305
  if (state.dragOverElements.size > 1) return;
2220
- let allowedOperations = $1ca228bc9257ca16$var$effectAllowedToOperations(e.dataTransfer.effectAllowed);
2306
+ let allowedOperationsBits = $1ca228bc9257ca16$var$getAllowedOperations(e);
2307
+ let allowedOperations = $1ca228bc9257ca16$var$allowedOperationsToArray(allowedOperationsBits);
2221
2308
  let dropOperation = allowedOperations[0];
2222
2309
  if (typeof options.getDropOperation === 'function') {
2223
2310
  let types = new $4620ae0dc40f0031$export$7f04ce188c91447c(e.dataTransfer);
2224
- dropOperation = $1ca228bc9257ca16$var$getDropOperation(e.dataTransfer.effectAllowed, options.getDropOperation(types, allowedOperations));
2311
+ dropOperation = $1ca228bc9257ca16$var$getDropOperation(allowedOperationsBits, options.getDropOperation(types, allowedOperations));
2225
2312
  }
2226
2313
  if (typeof options.getDropOperationForPoint === 'function') {
2227
2314
  let types = new $4620ae0dc40f0031$export$7f04ce188c91447c(e.dataTransfer);
2228
2315
  let rect = e.currentTarget.getBoundingClientRect();
2229
- dropOperation = $1ca228bc9257ca16$var$getDropOperation(e.dataTransfer.effectAllowed, options.getDropOperationForPoint(types, allowedOperations, e.clientX - rect.x, e.clientY - rect.y));
2316
+ dropOperation = $1ca228bc9257ca16$var$getDropOperation(allowedOperationsBits, options.getDropOperationForPoint(types, allowedOperations, e.clientX - rect.x, e.clientY - rect.y));
2230
2317
  }
2231
2318
  state.x = e.clientX;
2232
2319
  state.y = e.clientY;
2233
- state.effectAllowed = e.dataTransfer.effectAllowed;
2320
+ state.allowedOperations = allowedOperationsBits;
2234
2321
  state.dropEffect = $76b1e110a27b1ccd$export$5eacb0769d26d3b2[dropOperation] || 'none';
2235
2322
  e.dataTransfer.dropEffect = state.dropEffect;
2236
2323
  if (dropOperation !== 'cancel') fireDropEnter(e);
@@ -2311,18 +2398,50 @@ function $1ca228bc9257ca16$export$ccdee5eaf73cf661(options) {
2311
2398
  isDropTarget: isDropTarget
2312
2399
  };
2313
2400
  }
2314
- function $1ca228bc9257ca16$var$effectAllowedToOperations(effectAllowed) {
2315
- let allowedOperationsBits = $76b1e110a27b1ccd$export$9bbdfc78cf083e16[effectAllowed];
2401
+ function $1ca228bc9257ca16$var$getAllowedOperations(e) {
2402
+ let allowedOperations = $76b1e110a27b1ccd$export$9bbdfc78cf083e16[e.dataTransfer.effectAllowed];
2403
+ // WebKit always sets effectAllowed to "copyMove" on macOS, and "all" on iOS, regardless of what was
2404
+ // set during the dragstart event: https://bugs.webkit.org/show_bug.cgi?id=178058
2405
+ //
2406
+ // Android Chrome also sets effectAllowed to "copyMove" in all cases: https://bugs.chromium.org/p/chromium/issues/detail?id=1359182
2407
+ //
2408
+ // If the drag started within the page, we can use a global variable to get the real allowed operations.
2409
+ // This needs to be intersected with the actual effectAllowed, which may have been filtered based on modifier keys.
2410
+ // Unfortunately, this means that link operations do not work at all in Safari.
2411
+ if ($4620ae0dc40f0031$export$f0130eb70b6347b8) allowedOperations &= $4620ae0dc40f0031$export$f0130eb70b6347b8;
2412
+ // Chrome and Safari on macOS will automatically filter effectAllowed when pressing modifier keys,
2413
+ // allowing the user to switch between move, link, and copy operations. Firefox on macOS and all
2414
+ // Windows browsers do not do this, so do it ourselves instead. The exact keys are platform dependent.
2415
+ // https://ux.stackexchange.com/questions/83748/what-are-the-most-common-modifier-keys-for-dragging-objects-with-a-mouse
2416
+ //
2417
+ // Note that none of these modifiers are ever set in WebKit due to a bug: https://bugs.webkit.org/show_bug.cgi?id=77465
2418
+ // However, Safari does update effectAllowed correctly, so we can just rely on that.
2419
+ let allowedModifiers = $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.none;
2420
+ if ($4vY0V$reactariautils.isMac()) {
2421
+ if (e.altKey) allowedModifiers |= $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.copy;
2422
+ // Chrome and Safari both use the Control key for link, even though Finder uses Command + Option.
2423
+ // iPadOS doesn't support link operations and will not fire the drop event at all if dropEffect is set to link.
2424
+ // https://bugs.webkit.org/show_bug.cgi?id=244701
2425
+ if (e.ctrlKey && !$4vY0V$reactariautils.isIPad()) allowedModifiers |= $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.link;
2426
+ if (e.metaKey) allowedModifiers |= $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.move;
2427
+ } else {
2428
+ if (e.altKey) allowedModifiers |= $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.link;
2429
+ if (e.shiftKey) allowedModifiers |= $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.move;
2430
+ if (e.ctrlKey) allowedModifiers |= $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.copy;
2431
+ }
2432
+ if (allowedModifiers) return allowedOperations & allowedModifiers;
2433
+ return allowedOperations;
2434
+ }
2435
+ function $1ca228bc9257ca16$var$allowedOperationsToArray(allowedOperationsBits) {
2316
2436
  let allowedOperations = [];
2317
2437
  if (allowedOperationsBits & $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.move) allowedOperations.push('move');
2318
2438
  if (allowedOperationsBits & $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.copy) allowedOperations.push('copy');
2319
2439
  if (allowedOperationsBits & $76b1e110a27b1ccd$export$60b7b4bcf3903d8e.link) allowedOperations.push('link');
2320
2440
  return allowedOperations;
2321
2441
  }
2322
- function $1ca228bc9257ca16$var$getDropOperation(effectAllowed, operation) {
2323
- let allowedOperationsBits = $76b1e110a27b1ccd$export$9bbdfc78cf083e16[effectAllowed];
2442
+ function $1ca228bc9257ca16$var$getDropOperation(allowedOperations, operation) {
2324
2443
  let op = $76b1e110a27b1ccd$export$60b7b4bcf3903d8e[operation];
2325
- return allowedOperationsBits & op ? operation : 'cancel';
2444
+ return allowedOperations & op ? operation : 'cancel';
2326
2445
  }
2327
2446
 
2328
2447
 
@@ -2859,14 +2978,32 @@ function $c5557edbed563ebf$export$8d0e41d2815afac5(props, state, ref1) {
2859
2978
 
2860
2979
 
2861
2980
 
2981
+
2982
+
2983
+ const $0cbbd00cda972c67$var$MESSAGES = {
2984
+ keyboard: {
2985
+ selected: 'dragSelectedKeyboard',
2986
+ notSelected: 'dragDescriptionKeyboard'
2987
+ },
2988
+ touch: {
2989
+ selected: 'dragSelectedLongPress',
2990
+ notSelected: 'dragDescriptionLongPress'
2991
+ },
2992
+ virtual: {
2993
+ selected: 'dragDescriptionVirtual',
2994
+ notSelected: 'dragDescriptionVirtual'
2995
+ }
2996
+ };
2862
2997
  function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
2863
2998
  let stringFormatter = $4vY0V$reactariai18n.useLocalizedStringFormatter((/*@__PURE__*/$parcel$interopDefault($d624b4da796f302a$exports)));
2999
+ let isDisabled = state.selectionManager.isDisabled(props.key);
2864
3000
  let { dragProps: dragProps , dragButtonProps: dragButtonProps } = $dc204e8ec58447a6$export$7941f8aafa4b6021({
2865
3001
  getItems () {
2866
3002
  return state.getItems(props.key);
2867
3003
  },
2868
3004
  preview: state.preview,
2869
3005
  getAllowedDropOperations: state.getAllowedDropOperations,
3006
+ hasDragButton: props.hasDragButton,
2870
3007
  onDragStart (e) {
2871
3008
  state.startDrag(props.key, e);
2872
3009
  },
@@ -2879,20 +3016,46 @@ function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
2879
3016
  });
2880
3017
  let item = state.collection.getItem(props.key);
2881
3018
  let numKeysForDrag = state.getKeysForDrag(props.key).size;
2882
- let isSelected = state.selectionManager.isSelected(props.key);
2883
- let message;
3019
+ let isSelected = numKeysForDrag > 1 && state.selectionManager.isSelected(props.key);
3020
+ let dragButtonLabel;
3021
+ let description;
3022
+ // Override description to include selected item count.
3023
+ let modality = $4620ae0dc40f0031$export$49bac5d6d4b352ea();
2884
3024
  var ref;
2885
- if (isSelected && numKeysForDrag > 1) message = stringFormatter.format('dragSelectedItems', {
3025
+ if (!props.hasDragButton) {
3026
+ let msg = $0cbbd00cda972c67$var$MESSAGES[modality][isSelected ? 'selected' : 'notSelected'];
3027
+ if (props.hasAction && modality === 'keyboard') msg += 'Alt';
3028
+ if (isSelected) description = stringFormatter.format(msg, {
3029
+ count: numKeysForDrag
3030
+ });
3031
+ else description = stringFormatter.format(msg);
3032
+ } else if (isSelected) dragButtonLabel = stringFormatter.format('dragSelectedItems', {
2886
3033
  count: numKeysForDrag
2887
3034
  });
2888
- else message = stringFormatter.format('dragItem', {
3035
+ else dragButtonLabel = stringFormatter.format('dragItem', {
2889
3036
  itemText: (ref = item === null || item === void 0 ? void 0 : item.textValue) !== null && ref !== void 0 ? ref : ''
2890
3037
  });
3038
+ let descriptionProps = $4vY0V$reactariautils.useDescription(description);
3039
+ if (description) Object.assign(dragProps, descriptionProps);
3040
+ if (!props.hasDragButton && props.hasAction) {
3041
+ let { onKeyDownCapture: onKeyDownCapture , onKeyUpCapture: onKeyUpCapture } = dragProps;
3042
+ if (modality === 'touch') // Remove long press description if an action is present, because in that case long pressing selects the item.
3043
+ delete dragProps['aria-describedby'];
3044
+ // Require Alt key if there is a conflicting action.
3045
+ dragProps.onKeyDownCapture = (e)=>{
3046
+ if (e.altKey) onKeyDownCapture(e);
3047
+ };
3048
+ dragProps.onKeyUpCapture = (e)=>{
3049
+ if (e.altKey) onKeyUpCapture(e);
3050
+ };
3051
+ }
2891
3052
  return {
2892
- dragProps: dragProps,
3053
+ dragProps: isDisabled ? {
3054
+ } : dragProps,
2893
3055
  dragButtonProps: {
2894
3056
  ...dragButtonProps,
2895
- 'aria-label': message
3057
+ isDisabled: isDisabled,
3058
+ 'aria-label': dragButtonLabel
2896
3059
  }
2897
3060
  };
2898
3061
  }
@@ -3093,4 +3256,5 @@ class $2268795bbb597ecb$export$fbd65d14c79e28cc {
3093
3256
 
3094
3257
 
3095
3258
 
3259
+
3096
3260
  //# sourceMappingURL=main.js.map