@react-spectrum/dnd 3.0.0-nightly.3475 → 3.0.0-nightly.3479
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 +24 -17
- package/dist/main.js.map +1 -1
- package/dist/module.js +24 -16
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +26 -18
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +2 -4
- package/src/useDnDHooks.ts +112 -0
- package/src/useDragHooks.ts +0 -24
- package/src/useDropHooks.ts +0 -37
package/dist/main.js
CHANGED
|
@@ -1,39 +1,32 @@
|
|
|
1
|
-
var $9OUiQ$reactstatelydnd = require("@react-stately/dnd");
|
|
2
1
|
var $9OUiQ$reactariadnd = require("@react-aria/dnd");
|
|
2
|
+
var $9OUiQ$reactstatelydnd = require("@react-stately/dnd");
|
|
3
3
|
var $9OUiQ$react = require("react");
|
|
4
4
|
|
|
5
5
|
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, "
|
|
10
|
-
$parcel$export(module.exports, "useDropHooks", () => $eb31ce34e8964bed$export$c9cc1cdafc7aa18a);
|
|
9
|
+
$parcel$export(module.exports, "useDnDHooks", () => $a0113e7bf4cc21a8$export$44dc23a29ed4ffd8);
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
function $
|
|
15
|
-
|
|
13
|
+
function $a0113e7bf4cc21a8$export$44dc23a29ed4ffd8(options) {
|
|
14
|
+
let { onDrop: onDrop , onInsert: onInsert , onItemDrop: onItemDrop , onReorder: onReorder , onRootDrop: onRootDrop , getItems: getItems } = options;
|
|
15
|
+
let dragHooks = $9OUiQ$react.useMemo(()=>({
|
|
16
16
|
useDraggableCollectionState (props) {
|
|
17
17
|
return $9OUiQ$reactstatelydnd.useDraggableCollectionState({
|
|
18
18
|
...props,
|
|
19
19
|
...options
|
|
20
20
|
});
|
|
21
21
|
},
|
|
22
|
+
useDraggableCollection: $9OUiQ$reactariadnd.useDraggableCollection,
|
|
22
23
|
useDraggableItem: $9OUiQ$reactariadnd.useDraggableItem,
|
|
23
|
-
DragPreview: $9OUiQ$reactariadnd.DragPreview
|
|
24
|
-
isVirtualDragging: $9OUiQ$reactariadnd.isVirtualDragging
|
|
24
|
+
DragPreview: $9OUiQ$reactariadnd.DragPreview
|
|
25
25
|
})
|
|
26
26
|
, [
|
|
27
27
|
options
|
|
28
28
|
]);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
function $eb31ce34e8964bed$export$c9cc1cdafc7aa18a(options) {
|
|
36
|
-
return $9OUiQ$react.useMemo(()=>({
|
|
29
|
+
let dropHooks = $9OUiQ$react.useMemo(()=>({
|
|
37
30
|
useDroppableCollectionState (props) {
|
|
38
31
|
return $9OUiQ$reactstatelydnd.useDroppableCollectionState({
|
|
39
32
|
...props,
|
|
@@ -47,12 +40,26 @@ function $eb31ce34e8964bed$export$c9cc1cdafc7aa18a(options) {
|
|
|
47
40
|
...options
|
|
48
41
|
}, state, ref);
|
|
49
42
|
},
|
|
50
|
-
useDropIndicator: $9OUiQ$reactariadnd.useDropIndicator
|
|
51
|
-
isVirtualDragging: $9OUiQ$reactariadnd.isVirtualDragging
|
|
43
|
+
useDropIndicator: $9OUiQ$reactariadnd.useDropIndicator
|
|
52
44
|
})
|
|
53
45
|
, [
|
|
54
46
|
options
|
|
55
47
|
]);
|
|
48
|
+
let isDraggable = !!getItems;
|
|
49
|
+
let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);
|
|
50
|
+
let mergedHooks = {
|
|
51
|
+
...isDraggable ? dragHooks : {
|
|
52
|
+
},
|
|
53
|
+
...isDroppable ? dropHooks : {
|
|
54
|
+
},
|
|
55
|
+
...isDraggable || isDroppable ? {
|
|
56
|
+
isVirtualDragging: $9OUiQ$reactariadnd.isVirtualDragging
|
|
57
|
+
} : {
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
dndHooks: mergedHooks
|
|
62
|
+
};
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;SCqEgB,yCAAW,CAAC,OAAmB,EAAY,CAAC;IAC1D,GAAG,CAAC,CAAC,SACH,MAAM,aACN,QAAQ,eACR,UAAU,cACV,SAAS,eACT,UAAU,aACV,QAAQ,EACT,CAAC,GAAG,OAAO;IAEZ,GAAG,CAAC,SAAS,GAAc,oBAAO,MAAQ,CAAC;YACzC,2BAA2B,EAAC,KAAsC,EAAE,CAAC;gBACnE,MAAM,CAAC,kDAA2B,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC;YAC3D,CAAC;oCACD,0CAAsB;8BACtB,oCAAgB;yBAChB,+BAAW;QACb,CAAC;MAAG,CAAC;QAAA,OAAO;IAAA,CAAC;IAEb,GAAG,CAAC,SAAS,GAAc,oBAAO,MAAQ,CAAC;YACzC,2BAA2B,EAAC,KAAK,EAAE,CAAC;gBAClC,MAAM,CAAC,kDAA2B,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC;YAC3D,CAAC;8BACD,oCAAgB;YAChB,sBAAsB,EAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;gBACzC,MAAM,CAAC,0CAAsB,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC,EAAE,KAAK,EAAE,GAAG;YAClE,CAAC;8BACD,oCAAgB;QAClB,CAAC;MAAG,CAAC;QAAA,OAAO;IAAA,CAAC;IAEb,GAAG,CAAC,WAAW,KAAK,QAAQ;IAC5B,GAAG,CAAC,WAAW,MAAM,MAAM,IAAI,QAAQ,IAAI,UAAU,IAAI,SAAS,IAAI,UAAU;IAEhF,GAAG,CAAC,WAAW,GAAG,CAAC;WACb,WAAW,GAAG,SAAS,GAAG,CAAC;QAAA,CAAC;WAC5B,WAAW,GAAG,SAAS,GAAG,CAAC;QAAA,CAAC;WAC5B,WAAW,IAAI,WAAW,GAAG,CAAC;+BAAA,qCAAiB;QAAA,CAAC,GAAG,CAAC;QAAA,CAAC;IAC3D,CAAC;IAED,MAAM,CAAC,CAAC;QACN,QAAQ,EAAE,WAAW;IACvB,CAAC;AACH,CAAC","sources":["packages/@react-spectrum/dnd/src/index.ts","packages/@react-spectrum/dnd/src/useDnDHooks.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 {DnDOptions, DnDHooks} from './useDnDHooks';\nexport {useDnDHooks} from './useDnDHooks';\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';\n\nimport {DroppableCollectionProps} from '@react-types/shared';\nimport {Key, RefObject, useMemo} from 'react';\n\ninterface DragHooks {\n useDraggableCollectionState?: (props: Omit<DraggableCollectionStateOptions, 'getItems'>) => 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 DnDHooks {\n dndHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean}\n}\n\nexport interface DnDOptions 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\nexport function useDnDHooks(options: DnDOptions): DnDHooks {\n let {\n onDrop,\n onInsert,\n onItemDrop,\n onReorder,\n onRootDrop,\n getItems\n } = options;\n\n let dragHooks: DragHooks = useMemo(() => ({\n useDraggableCollectionState(props: DraggableCollectionStateOptions) {\n return useDraggableCollectionState({...props, ...options});\n },\n useDraggableCollection,\n useDraggableItem,\n DragPreview\n }), [options]);\n\n let dropHooks: DropHooks = useMemo(() => ({\n useDroppableCollectionState(props) {\n return useDroppableCollectionState({...props, ...options});\n },\n useDroppableItem,\n useDroppableCollection(props, state, ref) {\n return useDroppableCollection({...props, ...options}, state, ref);\n },\n useDropIndicator\n }), [options]);\n\n let isDraggable = !!getItems;\n let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);\n\n let mergedHooks = {\n ...(isDraggable ? dragHooks : {}),\n ...(isDroppable ? dropHooks : {}),\n ...(isDraggable || isDroppable ? {isVirtualDragging} : {})\n };\n\n return {\n dndHooks: mergedHooks\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,33 +1,27 @@
|
|
|
1
|
+
import {useDraggableCollection as $6PX7k$useDraggableCollection, useDraggableItem as $6PX7k$useDraggableItem, DragPreview as $6PX7k$DragPreview, useDroppableItem as $6PX7k$useDroppableItem, useDroppableCollection as $6PX7k$useDroppableCollection, useDropIndicator as $6PX7k$useDropIndicator, isVirtualDragging as $6PX7k$isVirtualDragging} from "@react-aria/dnd";
|
|
1
2
|
import {useDraggableCollectionState as $6PX7k$useDraggableCollectionState, useDroppableCollectionState as $6PX7k$useDroppableCollectionState} from "@react-stately/dnd";
|
|
2
|
-
import {useDraggableItem as $6PX7k$useDraggableItem, DragPreview as $6PX7k$DragPreview, isVirtualDragging as $6PX7k$isVirtualDragging, useDroppableItem as $6PX7k$useDroppableItem, useDroppableCollection as $6PX7k$useDroppableCollection, useDropIndicator as $6PX7k$useDropIndicator} from "@react-aria/dnd";
|
|
3
3
|
import {useMemo as $6PX7k$useMemo} from "react";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
function $
|
|
9
|
-
|
|
8
|
+
function $b182231e7d627f12$export$44dc23a29ed4ffd8(options) {
|
|
9
|
+
let { onDrop: onDrop , onInsert: onInsert , onItemDrop: onItemDrop , onReorder: onReorder , onRootDrop: onRootDrop , getItems: getItems } = options;
|
|
10
|
+
let dragHooks = $6PX7k$useMemo(()=>({
|
|
10
11
|
useDraggableCollectionState (props) {
|
|
11
12
|
return $6PX7k$useDraggableCollectionState({
|
|
12
13
|
...props,
|
|
13
14
|
...options
|
|
14
15
|
});
|
|
15
16
|
},
|
|
17
|
+
useDraggableCollection: $6PX7k$useDraggableCollection,
|
|
16
18
|
useDraggableItem: $6PX7k$useDraggableItem,
|
|
17
|
-
DragPreview: $6PX7k$DragPreview
|
|
18
|
-
isVirtualDragging: $6PX7k$isVirtualDragging
|
|
19
|
+
DragPreview: $6PX7k$DragPreview
|
|
19
20
|
})
|
|
20
21
|
, [
|
|
21
22
|
options
|
|
22
23
|
]);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function $d9620cb8af727810$export$c9cc1cdafc7aa18a(options) {
|
|
30
|
-
return $6PX7k$useMemo(()=>({
|
|
24
|
+
let dropHooks = $6PX7k$useMemo(()=>({
|
|
31
25
|
useDroppableCollectionState (props) {
|
|
32
26
|
return $6PX7k$useDroppableCollectionState({
|
|
33
27
|
...props,
|
|
@@ -41,16 +35,30 @@ function $d9620cb8af727810$export$c9cc1cdafc7aa18a(options) {
|
|
|
41
35
|
...options
|
|
42
36
|
}, state, ref);
|
|
43
37
|
},
|
|
44
|
-
useDropIndicator: $6PX7k$useDropIndicator
|
|
45
|
-
isVirtualDragging: $6PX7k$isVirtualDragging
|
|
38
|
+
useDropIndicator: $6PX7k$useDropIndicator
|
|
46
39
|
})
|
|
47
40
|
, [
|
|
48
41
|
options
|
|
49
42
|
]);
|
|
43
|
+
let isDraggable = !!getItems;
|
|
44
|
+
let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);
|
|
45
|
+
let mergedHooks = {
|
|
46
|
+
...isDraggable ? dragHooks : {
|
|
47
|
+
},
|
|
48
|
+
...isDroppable ? dropHooks : {
|
|
49
|
+
},
|
|
50
|
+
...isDraggable || isDroppable ? {
|
|
51
|
+
isVirtualDragging: $6PX7k$isVirtualDragging
|
|
52
|
+
} : {
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
dndHooks: mergedHooks
|
|
57
|
+
};
|
|
50
58
|
}
|
|
51
59
|
|
|
52
60
|
|
|
53
61
|
|
|
54
62
|
|
|
55
|
-
export {$
|
|
63
|
+
export {$b182231e7d627f12$export$44dc23a29ed4ffd8 as useDnDHooks};
|
|
56
64
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;SCqEgB,yCAAW,CAAC,OAAmB,EAAY,CAAC;IAC1D,GAAG,CAAC,CAAC,SACH,MAAM,aACN,QAAQ,eACR,UAAU,cACV,SAAS,eACT,UAAU,aACV,QAAQ,EACT,CAAC,GAAG,OAAO;IAEZ,GAAG,CAAC,SAAS,GAAc,cAAO,MAAQ,CAAC;YACzC,2BAA2B,EAAC,KAAsC,EAAE,CAAC;gBACnE,MAAM,CAAC,kCAA2B,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC;YAC3D,CAAC;oCACD,6BAAsB;8BACtB,uBAAgB;yBAChB,kBAAW;QACb,CAAC;MAAG,CAAC;QAAA,OAAO;IAAA,CAAC;IAEb,GAAG,CAAC,SAAS,GAAc,cAAO,MAAQ,CAAC;YACzC,2BAA2B,EAAC,KAAK,EAAE,CAAC;gBAClC,MAAM,CAAC,kCAA2B,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC;YAC3D,CAAC;8BACD,uBAAgB;YAChB,sBAAsB,EAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;gBACzC,MAAM,CAAC,6BAAsB,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC,EAAE,KAAK,EAAE,GAAG;YAClE,CAAC;8BACD,uBAAgB;QAClB,CAAC;MAAG,CAAC;QAAA,OAAO;IAAA,CAAC;IAEb,GAAG,CAAC,WAAW,KAAK,QAAQ;IAC5B,GAAG,CAAC,WAAW,MAAM,MAAM,IAAI,QAAQ,IAAI,UAAU,IAAI,SAAS,IAAI,UAAU;IAEhF,GAAG,CAAC,WAAW,GAAG,CAAC;WACb,WAAW,GAAG,SAAS,GAAG,CAAC;QAAA,CAAC;WAC5B,WAAW,GAAG,SAAS,GAAG,CAAC;QAAA,CAAC;WAC5B,WAAW,IAAI,WAAW,GAAG,CAAC;+BAAA,wBAAiB;QAAA,CAAC,GAAG,CAAC;QAAA,CAAC;IAC3D,CAAC;IAED,MAAM,CAAC,CAAC;QACN,QAAQ,EAAE,WAAW;IACvB,CAAC;AACH,CAAC","sources":["packages/@react-spectrum/dnd/src/index.ts","packages/@react-spectrum/dnd/src/useDnDHooks.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 {DnDOptions, DnDHooks} from './useDnDHooks';\nexport {useDnDHooks} from './useDnDHooks';\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';\n\nimport {DroppableCollectionProps} from '@react-types/shared';\nimport {Key, RefObject, useMemo} from 'react';\n\ninterface DragHooks {\n useDraggableCollectionState?: (props: Omit<DraggableCollectionStateOptions, 'getItems'>) => 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 DnDHooks {\n dndHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean}\n}\n\nexport interface DnDOptions 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\nexport function useDnDHooks(options: DnDOptions): DnDHooks {\n let {\n onDrop,\n onInsert,\n onItemDrop,\n onReorder,\n onRootDrop,\n getItems\n } = options;\n\n let dragHooks: DragHooks = useMemo(() => ({\n useDraggableCollectionState(props: DraggableCollectionStateOptions) {\n return useDraggableCollectionState({...props, ...options});\n },\n useDraggableCollection,\n useDraggableItem,\n DragPreview\n }), [options]);\n\n let dropHooks: DropHooks = useMemo(() => ({\n useDroppableCollectionState(props) {\n return useDroppableCollectionState({...props, ...options});\n },\n useDroppableItem,\n useDroppableCollection(props, state, ref) {\n return useDroppableCollection({...props, ...options}, state, ref);\n },\n useDropIndicator\n }), [options]);\n\n let isDraggable = !!getItems;\n let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);\n\n let mergedHooks = {\n ...(isDraggable ? dragHooks : {}),\n ...(isDroppable ? dropHooks : {}),\n ...(isDraggable || isDroppable ? {isVirtualDragging} : {})\n };\n\n return {\n dndHooks: mergedHooks\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
import { DraggableCollectionOptions,
|
|
2
|
-
import { DraggableCollectionProps, DroppableCollectionProps } from "@react-types/shared";
|
|
3
|
-
import {
|
|
4
|
-
import { RefObject } from "react";
|
|
5
|
-
|
|
6
|
-
useDraggableCollectionState(props: Omit<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { DraggableCollectionOptions, DraggableItemProps, DraggableItemResult, DragPreview, DropIndicatorAria, DropIndicatorProps, DroppableCollectionOptions, DroppableCollectionResult, DroppableItemOptions, DroppableItemResult } from "@react-aria/dnd";
|
|
2
|
+
import { DraggableCollectionProps, DragItem, DroppableCollectionProps } from "@react-types/shared";
|
|
3
|
+
import { DraggableCollectionState, DraggableCollectionStateOptions, DroppableCollectionState, DroppableCollectionStateOptions } from "@react-stately/dnd";
|
|
4
|
+
import { Key, RefObject } from "react";
|
|
5
|
+
interface DragHooks {
|
|
6
|
+
useDraggableCollectionState?: (props: Omit<DraggableCollectionStateOptions, 'getItems'>) => DraggableCollectionState;
|
|
7
|
+
useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject<HTMLElement>) => void;
|
|
8
|
+
useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult;
|
|
9
|
+
DragPreview?: typeof DragPreview;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
interface DropHooks {
|
|
12
|
+
useDroppableCollectionState?: (props: DroppableCollectionStateOptions) => DroppableCollectionState;
|
|
13
|
+
useDroppableCollection?: (props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DroppableCollectionResult;
|
|
14
|
+
useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DroppableItemResult;
|
|
15
|
+
useDropIndicator?: (props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DropIndicatorAria;
|
|
12
16
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
useDroppableItem(options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DroppableItemResult;
|
|
18
|
-
useDropIndicator(props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DropIndicatorAria;
|
|
19
|
-
isVirtualDragging(): boolean;
|
|
17
|
+
export interface DnDHooks {
|
|
18
|
+
dndHooks: DragHooks & DropHooks & {
|
|
19
|
+
isVirtualDragging?: () => boolean;
|
|
20
|
+
};
|
|
20
21
|
}
|
|
21
|
-
export
|
|
22
|
+
export interface DnDOptions extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {
|
|
23
|
+
/**
|
|
24
|
+
* A function that returns the items being dragged. If not specified, we assume that the collection is not draggable.
|
|
25
|
+
* @default () => []
|
|
26
|
+
*/
|
|
27
|
+
getItems?: (keys: Set<Key>) => DragItem[];
|
|
28
|
+
}
|
|
29
|
+
export function useDnDHooks(options: DnDOptions): DnDHooks;
|
|
22
30
|
|
|
23
31
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;
|
|
1
|
+
{"mappings":";;;;AA2CA;IACE,2BAA2B,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,+BAA+B,EAAE,UAAU,CAAC,KAAK,wBAAwB,CAAC;IACrH,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,QAAQ,EAAE,SAAS,GAAG,SAAS,GAAG;QAAC,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAA;KAAC,CAAA;CACtE;AAED,2BAA4B,SAAQ,IAAI,CAAC,wBAAwB,EAAE,SAAS,GAAG,UAAU,CAAC,EAAE,wBAAwB;IAClH;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAA;CAC1C;AAED,4BAA4B,OAAO,EAAE,UAAU,GAAG,QAAQ,CA0CzD","sources":["packages/@react-spectrum/dnd/src/packages/@react-spectrum/dnd/src/useDnDHooks.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 {DnDOptions, DnDHooks} from './useDnDHooks';\nexport {useDnDHooks} from './useDnDHooks';\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.3479+afb946c4a",
|
|
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.3479+afb946c4a",
|
|
36
|
+
"@react-stately/dnd": "3.0.0-nightly.3479+afb946c4a",
|
|
37
|
+
"@react-types/shared": "3.0.0-nightly.1779+afb946c4a"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@adobe/spectrum-css-temp": "3.0.0-nightly.
|
|
40
|
+
"@adobe/spectrum-css-temp": "3.0.0-nightly.1779+afb946c4a"
|
|
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": "afb946c4ab759b0dd19e024f8c0768d382134a7b"
|
|
50
50
|
}
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,5 @@
|
|
|
12
12
|
|
|
13
13
|
/// <reference types="css-module-types" />
|
|
14
14
|
|
|
15
|
-
export type {
|
|
16
|
-
export
|
|
17
|
-
export {useDragHooks} from './useDragHooks';
|
|
18
|
-
export {useDropHooks} from './useDropHooks';
|
|
15
|
+
export type {DnDOptions, DnDHooks} from './useDnDHooks';
|
|
16
|
+
export {useDnDHooks} from './useDnDHooks';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
DraggableCollectionOptions,
|
|
15
|
+
DraggableItemProps,
|
|
16
|
+
DraggableItemResult,
|
|
17
|
+
DragPreview,
|
|
18
|
+
DropIndicatorAria,
|
|
19
|
+
DropIndicatorProps,
|
|
20
|
+
DroppableCollectionOptions,
|
|
21
|
+
DroppableCollectionResult,
|
|
22
|
+
DroppableItemOptions,
|
|
23
|
+
DroppableItemResult,
|
|
24
|
+
isVirtualDragging,
|
|
25
|
+
useDraggableCollection,
|
|
26
|
+
useDraggableItem,
|
|
27
|
+
useDropIndicator,
|
|
28
|
+
useDroppableCollection,
|
|
29
|
+
useDroppableItem
|
|
30
|
+
} from '@react-aria/dnd';
|
|
31
|
+
import {DraggableCollectionProps, DragItem} from '@react-types/shared';
|
|
32
|
+
import {
|
|
33
|
+
DraggableCollectionState,
|
|
34
|
+
DraggableCollectionStateOptions,
|
|
35
|
+
DroppableCollectionState,
|
|
36
|
+
DroppableCollectionStateOptions,
|
|
37
|
+
useDraggableCollectionState,
|
|
38
|
+
useDroppableCollectionState
|
|
39
|
+
} from '@react-stately/dnd';
|
|
40
|
+
|
|
41
|
+
import {DroppableCollectionProps} from '@react-types/shared';
|
|
42
|
+
import {Key, RefObject, useMemo} from 'react';
|
|
43
|
+
|
|
44
|
+
interface DragHooks {
|
|
45
|
+
useDraggableCollectionState?: (props: Omit<DraggableCollectionStateOptions, 'getItems'>) => DraggableCollectionState,
|
|
46
|
+
useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject<HTMLElement>) => void,
|
|
47
|
+
useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult,
|
|
48
|
+
DragPreview?: typeof DragPreview
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface DropHooks {
|
|
52
|
+
useDroppableCollectionState?: (props: DroppableCollectionStateOptions) => DroppableCollectionState,
|
|
53
|
+
useDroppableCollection?: (props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DroppableCollectionResult,
|
|
54
|
+
useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DroppableItemResult,
|
|
55
|
+
useDropIndicator?: (props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>) => DropIndicatorAria
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface DnDHooks {
|
|
59
|
+
dndHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface DnDOptions extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {
|
|
63
|
+
/**
|
|
64
|
+
* A function that returns the items being dragged. If not specified, we assume that the collection is not draggable.
|
|
65
|
+
* @default () => []
|
|
66
|
+
*/
|
|
67
|
+
getItems?: (keys: Set<Key>) => DragItem[]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function useDnDHooks(options: DnDOptions): DnDHooks {
|
|
71
|
+
let {
|
|
72
|
+
onDrop,
|
|
73
|
+
onInsert,
|
|
74
|
+
onItemDrop,
|
|
75
|
+
onReorder,
|
|
76
|
+
onRootDrop,
|
|
77
|
+
getItems
|
|
78
|
+
} = options;
|
|
79
|
+
|
|
80
|
+
let dragHooks: DragHooks = useMemo(() => ({
|
|
81
|
+
useDraggableCollectionState(props: DraggableCollectionStateOptions) {
|
|
82
|
+
return useDraggableCollectionState({...props, ...options});
|
|
83
|
+
},
|
|
84
|
+
useDraggableCollection,
|
|
85
|
+
useDraggableItem,
|
|
86
|
+
DragPreview
|
|
87
|
+
}), [options]);
|
|
88
|
+
|
|
89
|
+
let dropHooks: DropHooks = useMemo(() => ({
|
|
90
|
+
useDroppableCollectionState(props) {
|
|
91
|
+
return useDroppableCollectionState({...props, ...options});
|
|
92
|
+
},
|
|
93
|
+
useDroppableItem,
|
|
94
|
+
useDroppableCollection(props, state, ref) {
|
|
95
|
+
return useDroppableCollection({...props, ...options}, state, ref);
|
|
96
|
+
},
|
|
97
|
+
useDropIndicator
|
|
98
|
+
}), [options]);
|
|
99
|
+
|
|
100
|
+
let isDraggable = !!getItems;
|
|
101
|
+
let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);
|
|
102
|
+
|
|
103
|
+
let mergedHooks = {
|
|
104
|
+
...(isDraggable ? dragHooks : {}),
|
|
105
|
+
...(isDroppable ? dropHooks : {}),
|
|
106
|
+
...(isDraggable || isDroppable ? {isVirtualDragging} : {})
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
dndHooks: mergedHooks
|
|
111
|
+
};
|
|
112
|
+
}
|
package/src/useDragHooks.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {DraggableCollectionOptions, DraggableCollectionState, useDraggableCollectionState} from '@react-stately/dnd';
|
|
2
|
-
import {DraggableCollectionProps} from '@react-types/shared';
|
|
3
|
-
import {DraggableItemProps, DraggableItemResult, DragPreview, isVirtualDragging, useDraggableItem} from '@react-aria/dnd';
|
|
4
|
-
import {useMemo} from 'react';
|
|
5
|
-
|
|
6
|
-
export interface DragHooks {
|
|
7
|
-
useDraggableCollectionState(props: Omit<DraggableCollectionOptions, 'getItems'>): DraggableCollectionState,
|
|
8
|
-
useDraggableItem(props: DraggableItemProps, state: DraggableCollectionState): DraggableItemResult,
|
|
9
|
-
DragPreview: typeof DragPreview,
|
|
10
|
-
isVirtualDragging(): boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface DragHookOptions extends Omit<DraggableCollectionProps, 'preview'> {}
|
|
14
|
-
|
|
15
|
-
export function useDragHooks(options: DragHookOptions): DragHooks {
|
|
16
|
-
return useMemo(() => ({
|
|
17
|
-
useDraggableCollectionState(props: DraggableCollectionOptions) {
|
|
18
|
-
return useDraggableCollectionState({...props, ...options});
|
|
19
|
-
},
|
|
20
|
-
useDraggableItem,
|
|
21
|
-
DragPreview,
|
|
22
|
-
isVirtualDragging
|
|
23
|
-
}), [options]);
|
|
24
|
-
}
|
package/src/useDropHooks.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DropIndicatorAria,
|
|
3
|
-
DropIndicatorProps,
|
|
4
|
-
DroppableCollectionOptions,
|
|
5
|
-
DroppableCollectionResult,
|
|
6
|
-
DroppableItemOptions,
|
|
7
|
-
DroppableItemResult,
|
|
8
|
-
isVirtualDragging,
|
|
9
|
-
useDropIndicator,
|
|
10
|
-
useDroppableCollection,
|
|
11
|
-
useDroppableItem
|
|
12
|
-
} from '@react-aria/dnd';
|
|
13
|
-
import {DroppableCollectionProps} from '@react-types/shared';
|
|
14
|
-
import {DroppableCollectionState, DroppableCollectionStateOptions, useDroppableCollectionState} from '@react-stately/dnd';
|
|
15
|
-
import {RefObject, useMemo} from 'react';
|
|
16
|
-
|
|
17
|
-
export interface DropHooks {
|
|
18
|
-
useDroppableCollectionState(props: DroppableCollectionStateOptions): DroppableCollectionState,
|
|
19
|
-
useDroppableCollection(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DroppableCollectionResult,
|
|
20
|
-
useDroppableItem(options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DroppableItemResult,
|
|
21
|
-
useDropIndicator(props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DropIndicatorAria,
|
|
22
|
-
isVirtualDragging(): boolean
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function useDropHooks(options: DroppableCollectionProps): DropHooks {
|
|
26
|
-
return useMemo(() => ({
|
|
27
|
-
useDroppableCollectionState(props) {
|
|
28
|
-
return useDroppableCollectionState({...props, ...options});
|
|
29
|
-
},
|
|
30
|
-
useDroppableItem,
|
|
31
|
-
useDroppableCollection(props, state, ref) {
|
|
32
|
-
return useDroppableCollection({...props, ...options}, state, ref);
|
|
33
|
-
},
|
|
34
|
-
useDropIndicator,
|
|
35
|
-
isVirtualDragging
|
|
36
|
-
}), [options]);
|
|
37
|
-
}
|