@react-aria/dnd 3.0.0-alpha.10 → 3.0.0-alpha.11

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/types.d.ts CHANGED
@@ -1,22 +1,8 @@
1
- import { AriaButtonProps } from "@react-types/button";
2
- import { DragEndEvent, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropMoveEvent, DragTypes, DroppableCollectionProps, DropTarget, KeyboardDelegate, DropItem } from "@react-types/shared";
3
1
  import React, { HTMLAttributes, RefObject, Key } from "react";
2
+ import { DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropMoveEvent, DropOperation, DragTypes, DroppableCollectionProps, DropTarget, KeyboardDelegate, DragEndEvent, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DOMAttributes, DropItem } from "@react-types/shared";
4
3
  import { DroppableCollectionState, DraggableCollectionState } from "@react-stately/dnd";
5
- interface DragOptions {
6
- onDragStart?: (e: DragStartEvent) => void;
7
- onDragMove?: (e: DragMoveEvent) => void;
8
- onDragEnd?: (e: DragEndEvent) => void;
9
- getItems: () => DragItem[];
10
- preview?: RefObject<DragPreviewRenderer>;
11
- getAllowedDropOperations?: () => DropOperation[];
12
- }
13
- interface DragResult {
14
- dragProps: HTMLAttributes<HTMLElement>;
15
- dragButtonProps: AriaButtonProps;
16
- isDragging: boolean;
17
- }
18
- export function useDrag(options: DragOptions): DragResult;
19
- interface DropOptions {
4
+ import { AriaButtonProps } from "@react-types/button";
5
+ export interface DropOptions {
20
6
  ref: RefObject<HTMLElement>;
21
7
  getDropOperation?: (types: DragTypes, allowedOperations: DropOperation[]) => DropOperation;
22
8
  getDropOperationForPoint?: (types: DragTypes, allowedOperations: DropOperation[], x: number, y: number) => DropOperation;
@@ -26,7 +12,7 @@ interface DropOptions {
26
12
  onDropExit?: (e: DropExitEvent) => void;
27
13
  onDrop?: (e: DropEvent) => void;
28
14
  }
29
- interface DropResult {
15
+ export interface DropResult {
30
16
  dropProps: HTMLAttributes<HTMLElement>;
31
17
  isDropTarget: boolean;
32
18
  }
@@ -53,6 +39,20 @@ export interface DropIndicatorAria {
53
39
  dropIndicatorProps: HTMLAttributes<HTMLElement>;
54
40
  }
55
41
  export function useDropIndicator(props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DropIndicatorAria;
42
+ export interface DragOptions {
43
+ onDragStart?: (e: DragStartEvent) => void;
44
+ onDragMove?: (e: DragMoveEvent) => void;
45
+ onDragEnd?: (e: DragEndEvent) => void;
46
+ getItems: () => DragItem[];
47
+ preview?: RefObject<DragPreviewRenderer>;
48
+ getAllowedDropOperations?: () => DropOperation[];
49
+ }
50
+ export interface DragResult {
51
+ dragProps: HTMLAttributes<HTMLElement>;
52
+ dragButtonProps: AriaButtonProps;
53
+ isDragging: boolean;
54
+ }
55
+ export function useDrag(options: DragOptions): DragResult;
56
56
  export interface DraggableItemProps {
57
57
  key: Key;
58
58
  }
@@ -61,19 +61,19 @@ export interface DraggableItemResult {
61
61
  dragButtonProps: AriaButtonProps;
62
62
  }
63
63
  export function useDraggableItem(props: DraggableItemProps, state: DraggableCollectionState): DraggableItemResult;
64
- interface ClipboardProps {
64
+ export interface DragPreviewProps {
65
+ children: (items: DragItem[]) => JSX.Element;
66
+ }
67
+ export let DragPreview: React.ForwardRefExoticComponent<DragPreviewProps & React.RefAttributes<DragPreviewRenderer>>;
68
+ export interface ClipboardProps {
65
69
  getItems?: () => DragItem[];
66
70
  onCopy?: () => void;
67
71
  onCut?: () => void;
68
72
  onPaste?: (items: DropItem[]) => void;
69
73
  }
70
- interface ClipboardResult {
71
- clipboardProps: HTMLAttributes<HTMLElement>;
74
+ export interface ClipboardResult {
75
+ clipboardProps: DOMAttributes;
72
76
  }
73
77
  export function useClipboard(options: ClipboardProps): ClipboardResult;
74
- export interface DragPreviewProps {
75
- children: (items: DragItem[]) => JSX.Element;
76
- }
77
- export let DragPreview: React.ForwardRefExoticComponent<DragPreviewProps & React.RefAttributes<DragPreviewRenderer>>;
78
78
 
79
79
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"mappings":";;;;AGwBA;IACE,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE,MAAM,QAAQ,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,UAAU,mBAAmB,CAAC,CAAC;IACzC,wBAAwB,CAAC,EAAE,MAAM,aAAa,EAAE,CAAA;CACjD;AAED;IACE,SAAS,EAAE,eAAe,WAAW,CAAC,CAAC;IACvC,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,OAAO,CAAA;CACpB;AAiBD,wBAAwB,OAAO,EAAE,WAAW,GAAG,UAAU,CAgKxD;AElMD;IACE,GAAG,EAAE,UAAU,WAAW,CAAC,CAAC;IAC5B,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,SAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,KAAK,aAAa,CAAC;IAC5F,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,SAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,aAAa,CAAC;IAC1H,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAGxC,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAChD,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAA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Q,EAAE,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAA;CACtC;AAED;IACE,cAAc,EAAE,eAAe,WAAW,CAAC,CAAA;CAC5C;AA6BD,6BAA6B,OAAO,EAAE,cAAc,GAAG,eAAe,CAkFrE;AC1HD;IACE,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,OAAO,CAAA;CAC7C;AAkCD,OAAA,IAAI,yGAA4C,CAAC","sources":["packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/constants.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/utils.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/DragManager.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDrag.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useVirtualDrop.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDrop.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useAutoScroll.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDroppableCollection.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDroppableItem.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDropIndicator.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDraggableItem.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useClipboard.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/DragPreview.tsx","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/index.ts","packages/@react-aria/dnd/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/*\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\nexport * from './useDrag';\nexport * from './useDrop';\nexport * from './useDroppableCollection';\nexport * from './useDroppableItem';\nexport * from './useDropIndicator';\nexport * from './useDraggableItem';\nexport * from './useClipboard';\nexport {DragPreview} from './DragPreview';\n\nexport type {DragPreviewProps} from './DragPreview';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;AKoBA;IACE,GAAG,EAAE,UAAU,WAAW,CAAC,CAAC;IAC5B,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,SAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,KAAK,aAAa,CAAC;IAC5F,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,SAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,aAAa,CAAC;IAC1H,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAGxC,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAChD,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAA;CAChC;AAED;IACE,SAAS,EAAE,eAAe,WAAW,CAAC,CAAC;IACvC,YAAY,EAAE,OAAO,CAAA;CACtB;AAID,wBAAwB,OAAO,EAAE,WAAW,GAAG,UAAU,CAsMxD;ACvND,2CAA4C,SAAQ,wBAAwB;IAC1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AAE,WAAW,GAAG,UAAU,CAgKxD;AClMD;IACE,GAAG,EAAE,GAAG,CAAA;CACT;AAED;IACE,SAAS,EAAE,eAAe,WAAW,CAAC,CAAC;IACvC,eAAe,EAAE,eAAe,CAAA;CACjC;AAED,iCAAiC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,wBAAwB,GAAG,mBAAmB,CAmChH;AChDD;IACE,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,OAAO,CAAA;CAC7C;AAkCD,OAAA,IAAI,yGAA4C,CAAC;AClCjD;IACE,QAAQ,CAAC,EAAE,MAAM,QAAQ,EAAE,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAA;CACtC;AAED;IACE,cAAc,EAAE,aAAa,CAAA;CAC9B;AA6BD,6BAA6B,OAAO,EAAE,cAAc,GAAG,eAAe,CAkFrE","sources":["packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/constants.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/utils.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/DragManager.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useAutoScroll.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useVirtualDrop.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDrop.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDroppableCollection.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDroppableItem.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDropIndicator.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDrag.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useDraggableItem.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/DragPreview.tsx","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/useClipboard.ts","packages/@react-aria/dnd/src/packages/@react-aria/dnd/src/index.ts","packages/@react-aria/dnd/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/*\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\nexport type {DroppableCollectionOptions, DroppableCollectionResult} from './useDroppableCollection';\nexport type {DroppableItemOptions, DroppableItemResult} from './useDroppableItem';\nexport type {DropIndicatorProps, DropIndicatorAria} from './useDropIndicator';\nexport type {DraggableItemProps, DraggableItemResult} from './useDraggableItem';\nexport type {DragPreviewProps} from './DragPreview';\nexport type {DragOptions, DragResult} from './useDrag';\nexport type {DropOptions, DropResult} from './useDrop';\nexport type {ClipboardProps, ClipboardResult} from './useClipboard';\n\nexport {useDrag} from './useDrag';\nexport {useDrop} from './useDrop';\nexport {useDroppableCollection} from './useDroppableCollection';\nexport {useDroppableItem} from './useDroppableItem';\nexport {useDropIndicator} from './useDropIndicator';\nexport {useDraggableItem} from './useDraggableItem';\nexport {useClipboard} from './useClipboard';\nexport {DragPreview} from './DragPreview';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/dnd",
3
- "version": "3.0.0-alpha.10",
3
+ "version": "3.0.0-alpha.11",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,16 +18,17 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-aria/i18n": "^3.4.1",
22
- "@react-aria/interactions": "^3.9.1",
23
- "@react-aria/live-announcer": "^3.1.0",
24
- "@react-aria/overlays": "^3.9.1",
25
- "@react-aria/utils": "^3.13.1",
26
- "@react-aria/visually-hidden": "^3.3.1",
27
- "@react-stately/dnd": "3.0.0-alpha.8",
28
- "@react-stately/selection": "^3.10.1",
29
- "@react-types/button": "^3.5.1",
30
- "@react-types/shared": "^3.13.1"
21
+ "@internationalized/string": "^3.0.0",
22
+ "@react-aria/i18n": "^3.5.0",
23
+ "@react-aria/interactions": "^3.10.0",
24
+ "@react-aria/live-announcer": "^3.1.1",
25
+ "@react-aria/overlays": "^3.10.0",
26
+ "@react-aria/utils": "^3.13.2",
27
+ "@react-aria/visually-hidden": "^3.4.0",
28
+ "@react-stately/dnd": "3.0.0-alpha.9",
29
+ "@react-stately/selection": "^3.10.2",
30
+ "@react-types/button": "^3.6.0",
31
+ "@react-types/shared": "^3.14.0"
31
32
  },
32
33
  "peerDependencies": {
33
34
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
@@ -36,5 +37,5 @@
36
37
  "publishConfig": {
37
38
  "access": "public"
38
39
  },
39
- "gitHead": "715c3f563ccf8c2e0102d3e18403d9db21a05a71"
40
+ "gitHead": "cd7c0ec917122c7612f653c22f8ed558f8b66ecd"
40
41
  }
@@ -12,8 +12,10 @@
12
12
 
13
13
  import {announce} from '@react-aria/live-announcer';
14
14
  import {ariaHideOutside} from '@react-aria/overlays';
15
- import {DragEndEvent, DragItem, DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropItem, DropOperation, DropTarget as DroppableCollectionTarget} from '@react-types/shared';
15
+ import {DragEndEvent, DragItem, DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropItem, DropOperation, DropTarget as DroppableCollectionTarget, FocusableElement} from '@react-types/shared';
16
16
  import {getDragModality, getTypes} from './utils';
17
+ import {getInteractionModality} from '@react-aria/interactions';
18
+ import type {LocalizedStringFormatter} from '@internationalized/string';
17
19
  import {useEffect, useState} from 'react';
18
20
 
19
21
  let dropTargets = new Map<Element, DropTarget>();
@@ -22,7 +24,7 @@ let dragSession: DragSession = null;
22
24
  let subscriptions = new Set<() => void>();
23
25
 
24
26
  interface DropTarget {
25
- element: HTMLElement,
27
+ element: FocusableElement,
26
28
  getDropOperation?: (types: Set<string>, allowedOperations: DropOperation[]) => DropOperation,
27
29
  onDropEnter?: (e: DropEnterEvent, dragTarget: DragTarget) => void,
28
30
  onDropExit?: (e: DropExitEvent) => void,
@@ -42,7 +44,7 @@ export function registerDropTarget(target: DropTarget) {
42
44
  }
43
45
 
44
46
  interface DroppableItem {
45
- element: HTMLElement,
47
+ element: FocusableElement,
46
48
  target: DroppableCollectionTarget,
47
49
  getDropOperation?: (types: Set<string>, allowedOperations: DropOperation[]) => DropOperation
48
50
  }
@@ -55,22 +57,24 @@ export function registerDropItem(item: DroppableItem) {
55
57
  }
56
58
 
57
59
  interface DragTarget {
58
- element: HTMLElement,
60
+ element: FocusableElement,
59
61
  items: DragItem[],
60
62
  allowedDropOperations: DropOperation[],
61
63
  onDragEnd?: (e: DragEndEvent) => void
62
64
  }
63
65
 
64
- export function beginDragging(target: DragTarget, formatMessage: (key: string) => string) {
66
+ export function beginDragging(target: DragTarget, stringFormatter: LocalizedStringFormatter) {
65
67
  if (dragSession) {
66
68
  throw new Error('Cannot begin dragging while already dragging');
67
69
  }
68
70
 
69
- dragSession = new DragSession(target, formatMessage);
71
+ dragSession = new DragSession(target, stringFormatter);
70
72
  requestAnimationFrame(() => {
71
73
  dragSession.setup();
72
-
73
- if (getDragModality() === 'keyboard') {
74
+ if (
75
+ getDragModality() === 'keyboard' ||
76
+ (getDragModality() === 'touch' && getInteractionModality() === 'virtual')
77
+ ) {
74
78
  dragSession.next();
75
79
  }
76
80
  });
@@ -153,15 +157,14 @@ class DragSession {
153
157
  currentDropItem: DroppableItem;
154
158
  dropOperation: DropOperation;
155
159
  private mutationObserver: MutationObserver;
156
- private mutationImmediate: NodeJS.Immediate;
157
160
  private restoreAriaHidden: () => void;
158
- private formatMessage: (key: string) => string;
161
+ private stringFormatter: LocalizedStringFormatter;
159
162
  private isVirtualClick: boolean;
160
163
  private initialFocused: boolean;
161
164
 
162
- constructor(target: DragTarget, formatMessage: (key: string) => string) {
165
+ constructor(target: DragTarget, stringFormatter: LocalizedStringFormatter) {
163
166
  this.dragTarget = target;
164
- this.formatMessage = formatMessage;
167
+ this.stringFormatter = stringFormatter;
165
168
 
166
169
  this.onKeyDown = this.onKeyDown.bind(this);
167
170
  this.onFocus = this.onFocus.bind(this);
@@ -188,7 +191,7 @@ class DragSession {
188
191
  );
189
192
  this.updateValidDropTargets();
190
193
 
191
- announce(this.formatMessage(MESSAGES[getDragModality()]));
194
+ announce(this.stringFormatter.format(MESSAGES[getDragModality()]));
192
195
  }
193
196
 
194
197
  teardown() {
@@ -204,9 +207,6 @@ class DragSession {
204
207
 
205
208
  this.mutationObserver.disconnect();
206
209
  this.restoreAriaHidden();
207
- if (this.mutationImmediate) {
208
- clearImmediate(this.mutationImmediate);
209
- }
210
210
  }
211
211
 
212
212
  onKeyDown(e: KeyboardEvent) {
@@ -488,7 +488,7 @@ class DragSession {
488
488
  this.dragTarget.element.focus();
489
489
  }
490
490
 
491
- announce(this.formatMessage('dropCanceled'));
491
+ announce(this.stringFormatter.format('dropCanceled'));
492
492
  }
493
493
 
494
494
  drop(item?: DroppableItem) {
@@ -526,7 +526,7 @@ class DragSession {
526
526
  }
527
527
 
528
528
  this.end();
529
- announce(this.formatMessage('dropComplete'));
529
+ announce(this.stringFormatter.format('dropComplete'));
530
530
  }
531
531
 
532
532
  activate() {
package/src/index.ts CHANGED
@@ -10,13 +10,20 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- export * from './useDrag';
14
- export * from './useDrop';
15
- export * from './useDroppableCollection';
16
- export * from './useDroppableItem';
17
- export * from './useDropIndicator';
18
- export * from './useDraggableItem';
19
- export * from './useClipboard';
20
- export {DragPreview} from './DragPreview';
21
-
13
+ export type {DroppableCollectionOptions, DroppableCollectionResult} from './useDroppableCollection';
14
+ export type {DroppableItemOptions, DroppableItemResult} from './useDroppableItem';
15
+ export type {DropIndicatorProps, DropIndicatorAria} from './useDropIndicator';
16
+ export type {DraggableItemProps, DraggableItemResult} from './useDraggableItem';
22
17
  export type {DragPreviewProps} from './DragPreview';
18
+ export type {DragOptions, DragResult} from './useDrag';
19
+ export type {DropOptions, DropResult} from './useDrop';
20
+ export type {ClipboardProps, ClipboardResult} from './useClipboard';
21
+
22
+ export {useDrag} from './useDrag';
23
+ export {useDrop} from './useDrop';
24
+ export {useDroppableCollection} from './useDroppableCollection';
25
+ export {useDroppableItem} from './useDroppableItem';
26
+ export {useDropIndicator} from './useDropIndicator';
27
+ export {useDraggableItem} from './useDraggableItem';
28
+ export {useClipboard} from './useClipboard';
29
+ export {DragPreview} from './DragPreview';
@@ -11,20 +11,20 @@
11
11
  */
12
12
 
13
13
  import {chain} from '@react-aria/utils';
14
- import {DragItem, DropItem} from '@react-types/shared';
15
- import {HTMLAttributes, useEffect, useRef} from 'react';
14
+ import {DOMAttributes, DragItem, DropItem} from '@react-types/shared';
16
15
  import {readFromDataTransfer, writeToDataTransfer} from './utils';
16
+ import {useEffect, useRef} from 'react';
17
17
  import {useFocus} from '@react-aria/interactions';
18
18
 
19
- interface ClipboardProps {
19
+ export interface ClipboardProps {
20
20
  getItems?: () => DragItem[],
21
21
  onCopy?: () => void,
22
22
  onCut?: () => void,
23
23
  onPaste?: (items: DropItem[]) => void
24
24
  }
25
25
 
26
- interface ClipboardResult {
27
- clipboardProps: HTMLAttributes<HTMLElement>
26
+ export interface ClipboardResult {
27
+ clipboardProps: DOMAttributes
28
28
  }
29
29
 
30
30
  const globalEvents = new Map();
package/src/useDrag.ts CHANGED
@@ -19,10 +19,10 @@ import {DROP_EFFECT_TO_DROP_OPERATION, DROP_OPERATION, EFFECT_ALLOWED} from './c
19
19
  import intlMessages from '../intl/*.json';
20
20
  import {useDescription, useGlobalListeners} from '@react-aria/utils';
21
21
  import {useDragModality} from './utils';
22
- import {useMessageFormatter} from '@react-aria/i18n';
22
+ import {useLocalizedStringFormatter} from '@react-aria/i18n';
23
23
  import {writeToDataTransfer} from './utils';
24
24
 
25
- interface DragOptions {
25
+ export interface DragOptions {
26
26
  onDragStart?: (e: DragStartEvent) => void,
27
27
  onDragMove?: (e: DragMoveEvent) => void,
28
28
  onDragEnd?: (e: DragEndEvent) => void,
@@ -31,7 +31,7 @@ interface DragOptions {
31
31
  getAllowedDropOperations?: () => DropOperation[]
32
32
  }
33
33
 
34
- interface DragResult {
34
+ export interface DragResult {
35
35
  dragProps: HTMLAttributes<HTMLElement>,
36
36
  dragButtonProps: AriaButtonProps,
37
37
  isDragging: boolean
@@ -53,7 +53,7 @@ const MESSAGES = {
53
53
  };
54
54
 
55
55
  export function useDrag(options: DragOptions): DragResult {
56
- let formatMessage = useMessageFormatter(intlMessages);
56
+ let stringFormatter = useLocalizedStringFormatter(intlMessages);
57
57
  let state = useRef({
58
58
  options,
59
59
  x: 0,
@@ -189,14 +189,14 @@ export function useDrag(options: DragOptions): DragResult {
189
189
  state.options.onDragEnd(e);
190
190
  }
191
191
  }
192
- }, formatMessage);
192
+ }, stringFormatter);
193
193
 
194
194
  setDragging(true);
195
195
  };
196
196
 
197
197
  let modality = useDragModality();
198
198
  let descriptionProps = useDescription(
199
- formatMessage(!isDragging ? MESSAGES[modality].start : MESSAGES[modality].end)
199
+ stringFormatter.format(!isDragging ? MESSAGES[modality].start : MESSAGES[modality].end)
200
200
  );
201
201
 
202
202
  return {
@@ -16,7 +16,7 @@ import {HTMLAttributes, Key} from 'react';
16
16
  // @ts-ignore
17
17
  import intlMessages from '../intl/*.json';
18
18
  import {useDrag} from './useDrag';
19
- import {useMessageFormatter} from '@react-aria/i18n';
19
+ import {useLocalizedStringFormatter} from '@react-aria/i18n';
20
20
 
21
21
  export interface DraggableItemProps {
22
22
  key: Key
@@ -28,7 +28,7 @@ export interface DraggableItemResult {
28
28
  }
29
29
 
30
30
  export function useDraggableItem(props: DraggableItemProps, state: DraggableCollectionState): DraggableItemResult {
31
- let formatMessage = useMessageFormatter(intlMessages);
31
+ let stringFormatter = useLocalizedStringFormatter(intlMessages);
32
32
  let {dragProps, dragButtonProps} = useDrag({
33
33
  getItems() {
34
34
  return state.getItems(props.key);
@@ -50,9 +50,9 @@ export function useDraggableItem(props: DraggableItemProps, state: DraggableColl
50
50
  let isSelected = state.selectionManager.isSelected(props.key);
51
51
  let message: string;
52
52
  if (isSelected && numKeysForDrag > 1) {
53
- message = formatMessage('dragSelectedItems', {count: numKeysForDrag});
53
+ message = stringFormatter.format('dragSelectedItems', {count: numKeysForDrag});
54
54
  } else {
55
- message = formatMessage('dragItem', {itemText: item?.textValue ?? ''});
55
+ message = stringFormatter.format('dragItem', {itemText: item?.textValue ?? ''});
56
56
  }
57
57
 
58
58
  return {
package/src/useDrop.ts CHANGED
@@ -18,7 +18,7 @@ import {DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropMoveEve
18
18
  import {useLayoutEffect} from '@react-aria/utils';
19
19
  import {useVirtualDrop} from './useVirtualDrop';
20
20
 
21
- interface DropOptions {
21
+ export interface DropOptions {
22
22
  ref: RefObject<HTMLElement>,
23
23
  getDropOperation?: (types: IDragTypes, allowedOperations: DropOperation[]) => DropOperation,
24
24
  getDropOperationForPoint?: (types: IDragTypes, allowedOperations: DropOperation[], x: number, y: number) => DropOperation,
@@ -31,7 +31,7 @@ interface DropOptions {
31
31
  onDrop?: (e: DropEvent) => void
32
32
  }
33
33
 
34
- interface DropResult {
34
+ export interface DropResult {
35
35
  dropProps: HTMLAttributes<HTMLElement>,
36
36
  isDropTarget: boolean // (??) whether the element is currently an active drop target
37
37
  }
@@ -19,7 +19,7 @@ import {HTMLAttributes, Key, RefObject} from 'react';
19
19
  import intlMessages from '../intl/*.json';
20
20
  import {useDroppableItem} from './useDroppableItem';
21
21
  import {useId} from '@react-aria/utils';
22
- import {useMessageFormatter} from '@react-aria/i18n';
22
+ import {useLocalizedStringFormatter} from '@react-aria/i18n';
23
23
 
24
24
  export interface DropIndicatorProps {
25
25
  target: DropTarget
@@ -33,7 +33,7 @@ export function useDropIndicator(props: DropIndicatorProps, state: DroppableColl
33
33
  let {target} = props;
34
34
  let {collection} = state;
35
35
 
36
- let formatMessage = useMessageFormatter(intlMessages);
36
+ let stringFormatter = useLocalizedStringFormatter(intlMessages);
37
37
  let dragSession = DragManager.useDragSession();
38
38
  let {dropProps} = useDroppableItem(props, state, ref);
39
39
  let id = useId();
@@ -42,10 +42,10 @@ export function useDropIndicator(props: DropIndicatorProps, state: DroppableColl
42
42
  let label = '';
43
43
  let labelledBy: string;
44
44
  if (target.type === 'root') {
45
- label = formatMessage('dropOnRoot');
45
+ label = stringFormatter.format('dropOnRoot');
46
46
  labelledBy = `${id} ${getDroppableCollectionId(state)}`;
47
47
  } else if (target.dropPosition === 'on') {
48
- label = formatMessage('dropOnItem', {
48
+ label = stringFormatter.format('dropOnItem', {
49
49
  itemText: getText(target.key)
50
50
  });
51
51
  } else {
@@ -57,16 +57,16 @@ export function useDropIndicator(props: DropIndicatorProps, state: DroppableColl
57
57
  : target.key;
58
58
 
59
59
  if (before && after) {
60
- label = formatMessage('insertBetween', {
60
+ label = stringFormatter.format('insertBetween', {
61
61
  beforeItemText: getText(before),
62
62
  afterItemText: getText(after)
63
63
  });
64
64
  } else if (before) {
65
- label = formatMessage('insertAfter', {
65
+ label = stringFormatter.format('insertAfter', {
66
66
  itemText: getText(before)
67
67
  });
68
68
  } else if (after) {
69
- label = formatMessage('insertBefore', {
69
+ label = stringFormatter.format('insertBefore', {
70
70
  itemText: getText(after)
71
71
  });
72
72
  }
@@ -76,7 +76,7 @@ export function useDropIndicator(props: DropIndicatorProps, state: DroppableColl
76
76
  dropIndicatorProps: {
77
77
  ...dropProps,
78
78
  id,
79
- 'aria-roledescription': formatMessage('dropIndicator'),
79
+ 'aria-roledescription': stringFormatter.format('dropIndicator'),
80
80
  'aria-label': label,
81
81
  'aria-labelledby': labelledBy,
82
82
  'aria-hidden': !dragSession ? 'true' : dropProps['aria-hidden'],
@@ -34,7 +34,7 @@ interface DroppingState {
34
34
  collection: Collection<Node<unknown>>,
35
35
  focusedKey: Key,
36
36
  selectedKeys: Set<Key>,
37
- timeout: NodeJS.Timeout
37
+ timeout: ReturnType<typeof setTimeout>
38
38
  }
39
39
 
40
40
  const DROP_POSITIONS: DropPosition[] = ['before', 'on', 'after'];
@@ -10,16 +10,16 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
+ import {DOMAttributes} from '@react-types/shared';
13
14
  import * as DragManager from './DragManager';
14
- import {HTMLAttributes} from 'react';
15
15
  // @ts-ignore
16
16
  import intlMessages from '../intl/*.json';
17
17
  import {useDescription} from '@react-aria/utils';
18
18
  import {useDragModality} from './utils';
19
- import {useMessageFormatter} from '@react-aria/i18n';
19
+ import {useLocalizedStringFormatter} from '@react-aria/i18n';
20
20
 
21
21
  interface VirtualDropResult {
22
- dropProps: HTMLAttributes<HTMLElement>
22
+ dropProps: DOMAttributes
23
23
  }
24
24
 
25
25
  const MESSAGES = {
@@ -29,10 +29,10 @@ const MESSAGES = {
29
29
  };
30
30
 
31
31
  export function useVirtualDrop(): VirtualDropResult {
32
- let formatMessage = useMessageFormatter(intlMessages);
32
+ let stringFormatter = useLocalizedStringFormatter(intlMessages);
33
33
  let modality = useDragModality();
34
34
  let dragSession = DragManager.useDragSession();
35
- let descriptionProps = useDescription(dragSession ? formatMessage(MESSAGES[modality]) : '');
35
+ let descriptionProps = useDescription(dragSession ? stringFormatter.format(MESSAGES[modality]) : '');
36
36
 
37
37
  return {
38
38
  dropProps: {