@react-spectrum/dnd 3.0.0-nightly.3502 → 3.0.0-nightly.3506
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 +4 -4
- package/dist/main.js.map +1 -1
- package/dist/module.js +4 -4
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +11 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +2 -2
- package/src/{useDnDHooks.ts → useDragAndDrop.ts} +13 -8
package/dist/main.js
CHANGED
|
@@ -6,13 +6,13 @@ function $parcel$export(e, n, v, s) {
|
|
|
6
6
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
$parcel$export(module.exports, "
|
|
9
|
+
$parcel$export(module.exports, "useDragAndDrop", () => $e96ca2229d77f411$export$2cfc5be7a55829f6);
|
|
10
10
|
$parcel$export(module.exports, "DIRECTORY_DRAG_TYPE", () => $9OUiQ$reactariadnd.DIRECTORY_DRAG_TYPE);
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
function $
|
|
15
|
-
let
|
|
14
|
+
function $e96ca2229d77f411$export$2cfc5be7a55829f6(options) {
|
|
15
|
+
let dragAndDropHooks = $9OUiQ$react.useMemo(()=>{
|
|
16
16
|
let { onDrop: onDrop , onInsert: onInsert , onItemDrop: onItemDrop , onReorder: onReorder , onRootDrop: onRootDrop , getItems: getItems } = options;
|
|
17
17
|
let isDraggable = !!getItems;
|
|
18
18
|
let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);
|
|
@@ -50,7 +50,7 @@ function $a0113e7bf4cc21a8$export$44dc23a29ed4ffd8(options) {
|
|
|
50
50
|
options
|
|
51
51
|
]);
|
|
52
52
|
return {
|
|
53
|
-
|
|
53
|
+
dragAndDropHooks: dragAndDropHooks
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;SC0EgB,yCAAc,CAAC,OAA2B,EAAoB,CAAC;IAC7E,GAAG,CAAC,gBAAgB,GAAG,oBAAO,KAAO,CAAC;QACpC,GAAG,CAAC,CAAC,SACH,MAAM,aACN,QAAQ,eACR,UAAU,cACV,SAAS,eACT,UAAU,aACV,QAAQ,EACT,CAAC,GAAG,OAAO;QAEZ,GAAG,CAAC,WAAW,KAAK,QAAQ;QAC5B,GAAG,CAAC,WAAW,MAAM,MAAM,IAAI,QAAQ,IAAI,UAAU,IAAI,SAAS,IAAI,UAAU;QAEhF,GAAG,CAAC,KAAK,GAAG,CAAC;QAAA,CAAC;QACd,EAAE,EAAE,WAAW,EAAE,CAAC;YAChB,KAAK,CAAC,2BAA2B,GAAG,QAAQ,CAAC,mCAAmC,CAAC,KAAsC,EAAE,CAAC;gBACxH,MAAM,CAAC,kDAA2B,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC;YAC3D,CAAC;YACD,KAAK,CAAC,sBAAsB,GAAG,0CAAsB;YACrD,KAAK,CAAC,gBAAgB,GAAG,oCAAgB;YACzC,KAAK,CAAC,WAAW,GAAG,+BAAW;QACjC,CAAC;QAED,EAAE,EAAE,WAAW,EAAE,CAAC;YAChB,KAAK,CAAC,2BAA2B,GAAG,QAAQ,CAAC,mCAAmC,CAAC,KAAsC,EAAE,CAAC;gBACxH,MAAM,CAAC,kDAA2B,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC;YAC3D,CAAC,EACD,KAAK,CAAC,gBAAgB,GAAG,oCAAgB;YACzC,KAAK,CAAC,sBAAsB,GAAG,QAAQ,CAAC,8BAA8B,CAAC,KAAiC,EAAE,KAA+B,EAAE,GAA2B,EAAE,CAAC;gBACvK,MAAM,CAAC,0CAAsB,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC,EAAE,KAAK,EAAE,GAAG;YAClE,CAAC;YACD,KAAK,CAAC,gBAAgB,GAAG,oCAAgB;QAC3C,CAAC;QAED,EAAE,EAAE,WAAW,IAAI,WAAW,EAC5B,KAAK,CAAC,iBAAiB,GAAG,qCAAiB;QAG7C,MAAM,CAAC,KAAK;IACd,CAAC,EAAE,CAAC;QAAA,OAAO;IAAA,CAAC;IAEZ,MAAM,CAAC,CAAC;QACN,gBAAgB,EAAE,gBAAgB;IACpC,CAAC;AACH,CAAC","sources":["packages/@react-spectrum/dnd/src/index.ts","packages/@react-spectrum/dnd/src/useDragAndDrop.ts"],"sourcesContent":["/*\n * Copyright 2022 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\n/// <reference types=\"css-module-types\" />\n\nexport type {DragAndDropOptions, DragAndDropHooks} from './useDragAndDrop';\nexport {useDragAndDrop} from './useDragAndDrop';\nexport {DIRECTORY_DRAG_TYPE} from '@react-aria/dnd';\n","/*\n * Copyright 2022 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 {\n DraggableCollectionOptions,\n DraggableItemProps,\n DraggableItemResult,\n DragPreview,\n DropIndicatorAria,\n DropIndicatorProps,\n DroppableCollectionOptions,\n DroppableCollectionResult,\n DroppableItemOptions,\n DroppableItemResult,\n isVirtualDragging,\n useDraggableCollection,\n useDraggableItem,\n useDropIndicator,\n useDroppableCollection,\n useDroppableItem\n} from '@react-aria/dnd';\nimport {DraggableCollectionProps, DragItem} from '@react-types/shared';\nimport {\n DraggableCollectionState,\n DraggableCollectionStateOptions,\n DroppableCollectionState,\n DroppableCollectionStateOptions,\n useDraggableCollectionState,\n useDroppableCollectionState\n} from '@react-stately/dnd';\nimport {DroppableCollectionProps} from '@react-types/shared';\nimport {Key, RefObject, useMemo} from 'react';\n\ninterface DraggableCollectionStateOpts extends Omit<DraggableCollectionStateOptions, 'getItems'> {}\n\ninterface DragHooks {\n useDraggableCollectionState?: (props: DraggableCollectionStateOpts) => DraggableCollectionState,\n useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject<HTMLElement>) => void,\n useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult,\n DragPreview?: typeof DragPreview\n}\n\ninterface DropHooks {\n useDroppableCollectionState?: (props: DroppableCollectionStateOptions) => DroppableCollectionState,\n useDroppableCollection?: (props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DroppableCollectionResult,\n useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DroppableItemResult,\n useDropIndicator?: (props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DropIndicatorAria\n}\n\nexport interface DragAndDropHooks {\n /** Drag and drop hooks for the collection element. */\n dragAndDropHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean}\n}\n\nexport interface DragAndDropOptions extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {\n /**\n * A function that returns the items being dragged. If not specified, we assume that the collection is not draggable.\n * @default () => []\n */\n getItems?: (keys: Set<Key>) => DragItem[]\n}\n\n/**\n * Provides the hooks required to enable drag and drop behavior for a drag and drop compatible React Spectrum component.\n */\nexport function useDragAndDrop(options: DragAndDropOptions): DragAndDropHooks {\n let dragAndDropHooks = useMemo(() => {\n let {\n onDrop,\n onInsert,\n onItemDrop,\n onReorder,\n onRootDrop,\n getItems\n } = options;\n\n let isDraggable = !!getItems;\n let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);\n\n let hooks = {} as DragHooks & DropHooks & {isVirtualDragging?: () => boolean};\n if (isDraggable) {\n hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props: DraggableCollectionStateOptions) {\n return useDraggableCollectionState({...props, ...options});\n };\n hooks.useDraggableCollection = useDraggableCollection;\n hooks.useDraggableItem = useDraggableItem;\n hooks.DragPreview = DragPreview;\n }\n\n if (isDroppable) {\n hooks.useDroppableCollectionState = function useDroppableCollectionStateOverride(props: DroppableCollectionStateOptions) {\n return useDroppableCollectionState({...props, ...options});\n },\n hooks.useDroppableItem = useDroppableItem;\n hooks.useDroppableCollection = function useDroppableCollectionOverride(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>) {\n return useDroppableCollection({...props, ...options}, state, ref);\n };\n hooks.useDropIndicator = useDropIndicator;\n }\n\n if (isDraggable || isDroppable) {\n hooks.isVirtualDragging = isVirtualDragging;\n }\n\n return hooks;\n }, [options]);\n\n return {\n dragAndDropHooks: dragAndDropHooks\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -5,8 +5,8 @@ import {useMemo as $6PX7k$useMemo} from "react";
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
function $
|
|
9
|
-
let
|
|
8
|
+
function $8d44a09a765f4c9c$export$2cfc5be7a55829f6(options) {
|
|
9
|
+
let dragAndDropHooks = $6PX7k$useMemo(()=>{
|
|
10
10
|
let { onDrop: onDrop , onInsert: onInsert , onItemDrop: onItemDrop , onReorder: onReorder , onRootDrop: onRootDrop , getItems: getItems } = options;
|
|
11
11
|
let isDraggable = !!getItems;
|
|
12
12
|
let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);
|
|
@@ -44,7 +44,7 @@ function $b182231e7d627f12$export$44dc23a29ed4ffd8(options) {
|
|
|
44
44
|
options
|
|
45
45
|
]);
|
|
46
46
|
return {
|
|
47
|
-
|
|
47
|
+
dragAndDropHooks: dragAndDropHooks
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -52,5 +52,5 @@ function $b182231e7d627f12$export$44dc23a29ed4ffd8(options) {
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
export {$
|
|
55
|
+
export {$8d44a09a765f4c9c$export$2cfc5be7a55829f6 as useDragAndDrop, $bd7af2e3e7bb229d$re_export$DIRECTORY_DRAG_TYPE as DIRECTORY_DRAG_TYPE};
|
|
56
56
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;SC0EgB,yCAAc,CAAC,OAA2B,EAAoB,CAAC;IAC7E,GAAG,CAAC,gBAAgB,GAAG,cAAO,KAAO,CAAC;QACpC,GAAG,CAAC,CAAC,SACH,MAAM,aACN,QAAQ,eACR,UAAU,cACV,SAAS,eACT,UAAU,aACV,QAAQ,EACT,CAAC,GAAG,OAAO;QAEZ,GAAG,CAAC,WAAW,KAAK,QAAQ;QAC5B,GAAG,CAAC,WAAW,MAAM,MAAM,IAAI,QAAQ,IAAI,UAAU,IAAI,SAAS,IAAI,UAAU;QAEhF,GAAG,CAAC,KAAK,GAAG,CAAC;QAAA,CAAC;QACd,EAAE,EAAE,WAAW,EAAE,CAAC;YAChB,KAAK,CAAC,2BAA2B,GAAG,QAAQ,CAAC,mCAAmC,CAAC,KAAsC,EAAE,CAAC;gBACxH,MAAM,CAAC,kCAA2B,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC;YAC3D,CAAC;YACD,KAAK,CAAC,sBAAsB,GAAG,6BAAsB;YACrD,KAAK,CAAC,gBAAgB,GAAG,uBAAgB;YACzC,KAAK,CAAC,WAAW,GAAG,kBAAW;QACjC,CAAC;QAED,EAAE,EAAE,WAAW,EAAE,CAAC;YAChB,KAAK,CAAC,2BAA2B,GAAG,QAAQ,CAAC,mCAAmC,CAAC,KAAsC,EAAE,CAAC;gBACxH,MAAM,CAAC,kCAA2B,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC;YAC3D,CAAC,EACD,KAAK,CAAC,gBAAgB,GAAG,uBAAgB;YACzC,KAAK,CAAC,sBAAsB,GAAG,QAAQ,CAAC,8BAA8B,CAAC,KAAiC,EAAE,KAA+B,EAAE,GAA2B,EAAE,CAAC;gBACvK,MAAM,CAAC,6BAAsB,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC,EAAE,KAAK,EAAE,GAAG;YAClE,CAAC;YACD,KAAK,CAAC,gBAAgB,GAAG,uBAAgB;QAC3C,CAAC;QAED,EAAE,EAAE,WAAW,IAAI,WAAW,EAC5B,KAAK,CAAC,iBAAiB,GAAG,wBAAiB;QAG7C,MAAM,CAAC,KAAK;IACd,CAAC,EAAE,CAAC;QAAA,OAAO;IAAA,CAAC;IAEZ,MAAM,CAAC,CAAC;QACN,gBAAgB,EAAE,gBAAgB;IACpC,CAAC;AACH,CAAC","sources":["packages/@react-spectrum/dnd/src/index.ts","packages/@react-spectrum/dnd/src/useDragAndDrop.ts"],"sourcesContent":["/*\n * Copyright 2022 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\n/// <reference types=\"css-module-types\" />\n\nexport type {DragAndDropOptions, DragAndDropHooks} from './useDragAndDrop';\nexport {useDragAndDrop} from './useDragAndDrop';\nexport {DIRECTORY_DRAG_TYPE} from '@react-aria/dnd';\n","/*\n * Copyright 2022 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 {\n DraggableCollectionOptions,\n DraggableItemProps,\n DraggableItemResult,\n DragPreview,\n DropIndicatorAria,\n DropIndicatorProps,\n DroppableCollectionOptions,\n DroppableCollectionResult,\n DroppableItemOptions,\n DroppableItemResult,\n isVirtualDragging,\n useDraggableCollection,\n useDraggableItem,\n useDropIndicator,\n useDroppableCollection,\n useDroppableItem\n} from '@react-aria/dnd';\nimport {DraggableCollectionProps, DragItem} from '@react-types/shared';\nimport {\n DraggableCollectionState,\n DraggableCollectionStateOptions,\n DroppableCollectionState,\n DroppableCollectionStateOptions,\n useDraggableCollectionState,\n useDroppableCollectionState\n} from '@react-stately/dnd';\nimport {DroppableCollectionProps} from '@react-types/shared';\nimport {Key, RefObject, useMemo} from 'react';\n\ninterface DraggableCollectionStateOpts extends Omit<DraggableCollectionStateOptions, 'getItems'> {}\n\ninterface DragHooks {\n useDraggableCollectionState?: (props: DraggableCollectionStateOpts) => DraggableCollectionState,\n useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject<HTMLElement>) => void,\n useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult,\n DragPreview?: typeof DragPreview\n}\n\ninterface DropHooks {\n useDroppableCollectionState?: (props: DroppableCollectionStateOptions) => DroppableCollectionState,\n useDroppableCollection?: (props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DroppableCollectionResult,\n useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DroppableItemResult,\n useDropIndicator?: (props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DropIndicatorAria\n}\n\nexport interface DragAndDropHooks {\n /** Drag and drop hooks for the collection element. */\n dragAndDropHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean}\n}\n\nexport interface DragAndDropOptions extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {\n /**\n * A function that returns the items being dragged. If not specified, we assume that the collection is not draggable.\n * @default () => []\n */\n getItems?: (keys: Set<Key>) => DragItem[]\n}\n\n/**\n * Provides the hooks required to enable drag and drop behavior for a drag and drop compatible React Spectrum component.\n */\nexport function useDragAndDrop(options: DragAndDropOptions): DragAndDropHooks {\n let dragAndDropHooks = useMemo(() => {\n let {\n onDrop,\n onInsert,\n onItemDrop,\n onReorder,\n onRootDrop,\n getItems\n } = options;\n\n let isDraggable = !!getItems;\n let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);\n\n let hooks = {} as DragHooks & DropHooks & {isVirtualDragging?: () => boolean};\n if (isDraggable) {\n hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props: DraggableCollectionStateOptions) {\n return useDraggableCollectionState({...props, ...options});\n };\n hooks.useDraggableCollection = useDraggableCollection;\n hooks.useDraggableItem = useDraggableItem;\n hooks.DragPreview = DragPreview;\n }\n\n if (isDroppable) {\n hooks.useDroppableCollectionState = function useDroppableCollectionStateOverride(props: DroppableCollectionStateOptions) {\n return useDroppableCollectionState({...props, ...options});\n },\n hooks.useDroppableItem = useDroppableItem;\n hooks.useDroppableCollection = function useDroppableCollectionOverride(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>) {\n return useDroppableCollection({...props, ...options}, state, ref);\n };\n hooks.useDropIndicator = useDropIndicator;\n }\n\n if (isDraggable || isDroppable) {\n hooks.isVirtualDragging = isVirtualDragging;\n }\n\n return hooks;\n }, [options]);\n\n return {\n dragAndDropHooks: dragAndDropHooks\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { DraggableCollectionOptions, DraggableItemProps, DraggableItemResult, Dr
|
|
|
2
2
|
import { DraggableCollectionProps, DragItem, DroppableCollectionProps } from "@react-types/shared";
|
|
3
3
|
import { DraggableCollectionState, DraggableCollectionStateOptions, DroppableCollectionState, DroppableCollectionStateOptions } from "@react-stately/dnd";
|
|
4
4
|
import { Key, RefObject } from "react";
|
|
5
|
+
interface DraggableCollectionStateOpts extends Omit<DraggableCollectionStateOptions, 'getItems'> {
|
|
6
|
+
}
|
|
5
7
|
interface DragHooks {
|
|
6
|
-
useDraggableCollectionState?: (props:
|
|
8
|
+
useDraggableCollectionState?: (props: DraggableCollectionStateOpts) => DraggableCollectionState;
|
|
7
9
|
useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject<HTMLElement>) => void;
|
|
8
10
|
useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult;
|
|
9
11
|
DragPreview?: typeof DragPreview;
|
|
@@ -14,19 +16,23 @@ interface DropHooks {
|
|
|
14
16
|
useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DroppableItemResult;
|
|
15
17
|
useDropIndicator?: (props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DropIndicatorAria;
|
|
16
18
|
}
|
|
17
|
-
export interface
|
|
18
|
-
|
|
19
|
+
export interface DragAndDropHooks {
|
|
20
|
+
/** Drag and drop hooks for the collection element. */
|
|
21
|
+
dragAndDropHooks: DragHooks & DropHooks & {
|
|
19
22
|
isVirtualDragging?: () => boolean;
|
|
20
23
|
};
|
|
21
24
|
}
|
|
22
|
-
export interface
|
|
25
|
+
export interface DragAndDropOptions extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {
|
|
23
26
|
/**
|
|
24
27
|
* A function that returns the items being dragged. If not specified, we assume that the collection is not draggable.
|
|
25
28
|
* @default () => []
|
|
26
29
|
*/
|
|
27
30
|
getItems?: (keys: Set<Key>) => DragItem[];
|
|
28
31
|
}
|
|
29
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Provides the hooks required to enable drag and drop behavior for a drag and drop compatible React Spectrum component.
|
|
34
|
+
*/
|
|
35
|
+
export function useDragAndDrop(options: DragAndDropOptions): DragAndDropHooks;
|
|
30
36
|
export { DIRECTORY_DRAG_TYPE } from '@react-aria/dnd';
|
|
31
37
|
|
|
32
38
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;
|
|
1
|
+
{"mappings":";;;;AA0CA,sCAAuC,SAAQ,IAAI,CAAC,+BAA+B,EAAE,UAAU,CAAC;CAAG;AAEnG;IACE,2BAA2B,CAAC,EAAE,CAAC,KAAK,EAAE,4BAA4B,KAAK,wBAAwB,CAAC;IAChG,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,0BAA0B,EAAE,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,KAAK,IAAI,CAAC;IACnI,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,wBAAwB,KAAK,mBAAmB,CAAC;IACvG,WAAW,CAAC,EAAE,kBAAkB,CAAA;CACjC;AAED;IACE,2BAA2B,CAAC,EAAE,CAAC,KAAK,EAAE,+BAA+B,KAAK,wBAAwB,CAAC;IACnG,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,0BAA0B,EAAE,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,KAAK,yBAAyB,CAAC;IACxJ,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,KAAK,mBAAmB,CAAC;IACxI,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,KAAK,iBAAiB,CAAA;CAClI;AAED;IACE,uDAAuD;IACvD,gBAAgB,EAAE,SAAS,GAAG,SAAS,GAAG;QAAC,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAA;KAAC,CAAA;CAC9E;AAED,mCAAoC,SAAQ,IAAI,CAAC,wBAAwB,EAAE,SAAS,GAAG,UAAU,CAAC,EAAE,wBAAwB;IAC1H;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAA;CAC1C;AAED;;GAEG;AACH,+BAA+B,OAAO,EAAE,kBAAkB,GAAG,gBAAgB,CA6C5E;ACvGD,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC","sources":["packages/@react-spectrum/dnd/src/packages/@react-spectrum/dnd/src/useDragAndDrop.ts","packages/@react-spectrum/dnd/src/packages/@react-spectrum/dnd/src/index.ts","packages/@react-spectrum/dnd/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2022 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\n/// <reference types=\"css-module-types\" />\n\nexport type {DragAndDropOptions, DragAndDropHooks} from './useDragAndDrop';\nexport {useDragAndDrop} from './useDragAndDrop';\nexport {DIRECTORY_DRAG_TYPE} from '@react-aria/dnd';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/dnd",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.3506+5c9db40f1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.6.2",
|
|
35
|
-
"@react-aria/dnd": "3.0.0-nightly.
|
|
36
|
-
"@react-stately/dnd": "3.0.0-nightly.
|
|
37
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
35
|
+
"@react-aria/dnd": "3.0.0-nightly.3506+5c9db40f1",
|
|
36
|
+
"@react-stately/dnd": "3.0.0-nightly.3506+5c9db40f1",
|
|
37
|
+
"@react-types/shared": "3.0.0-nightly.1806+5c9db40f1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@adobe/spectrum-css-temp": "3.0.0-nightly.
|
|
40
|
+
"@adobe/spectrum-css-temp": "3.0.0-nightly.1806+5c9db40f1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@react-spectrum/provider": "^3.0.0",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "5c9db40f10b9e68d4eab0268b9775baf2a840987"
|
|
50
50
|
}
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
/// <reference types="css-module-types" />
|
|
14
14
|
|
|
15
|
-
export type {
|
|
16
|
-
export {
|
|
15
|
+
export type {DragAndDropOptions, DragAndDropHooks} from './useDragAndDrop';
|
|
16
|
+
export {useDragAndDrop} from './useDragAndDrop';
|
|
17
17
|
export {DIRECTORY_DRAG_TYPE} from '@react-aria/dnd';
|
|
@@ -37,12 +37,13 @@ import {
|
|
|
37
37
|
useDraggableCollectionState,
|
|
38
38
|
useDroppableCollectionState
|
|
39
39
|
} from '@react-stately/dnd';
|
|
40
|
-
|
|
41
40
|
import {DroppableCollectionProps} from '@react-types/shared';
|
|
42
41
|
import {Key, RefObject, useMemo} from 'react';
|
|
43
42
|
|
|
43
|
+
interface DraggableCollectionStateOpts extends Omit<DraggableCollectionStateOptions, 'getItems'> {}
|
|
44
|
+
|
|
44
45
|
interface DragHooks {
|
|
45
|
-
useDraggableCollectionState?: (props:
|
|
46
|
+
useDraggableCollectionState?: (props: DraggableCollectionStateOpts) => DraggableCollectionState,
|
|
46
47
|
useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject<HTMLElement>) => void,
|
|
47
48
|
useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult,
|
|
48
49
|
DragPreview?: typeof DragPreview
|
|
@@ -55,11 +56,12 @@ interface DropHooks {
|
|
|
55
56
|
useDropIndicator?: (props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DropIndicatorAria
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
export interface
|
|
59
|
-
|
|
59
|
+
export interface DragAndDropHooks {
|
|
60
|
+
/** Drag and drop hooks for the collection element. */
|
|
61
|
+
dragAndDropHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean}
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
export interface
|
|
64
|
+
export interface DragAndDropOptions extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {
|
|
63
65
|
/**
|
|
64
66
|
* A function that returns the items being dragged. If not specified, we assume that the collection is not draggable.
|
|
65
67
|
* @default () => []
|
|
@@ -67,8 +69,11 @@ export interface DnDOptions extends Omit<DraggableCollectionProps, 'preview' | '
|
|
|
67
69
|
getItems?: (keys: Set<Key>) => DragItem[]
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Provides the hooks required to enable drag and drop behavior for a drag and drop compatible React Spectrum component.
|
|
74
|
+
*/
|
|
75
|
+
export function useDragAndDrop(options: DragAndDropOptions): DragAndDropHooks {
|
|
76
|
+
let dragAndDropHooks = useMemo(() => {
|
|
72
77
|
let {
|
|
73
78
|
onDrop,
|
|
74
79
|
onInsert,
|
|
@@ -110,6 +115,6 @@ export function useDnDHooks(options: DnDOptions): DnDHooks {
|
|
|
110
115
|
}, [options]);
|
|
111
116
|
|
|
112
117
|
return {
|
|
113
|
-
|
|
118
|
+
dragAndDropHooks: dragAndDropHooks
|
|
114
119
|
};
|
|
115
120
|
}
|