@react-stately/dnd 3.7.4 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +3 -3
- package/dist/main.js +4 -4
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -3
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +4 -0
- package/package.json +17 -14
- package/src/index.ts +5 -4
- package/dist/types.d.ts +0 -79
- package/dist/types.d.ts.map +0 -1
- package/dist/useDraggableCollectionState.main.js +0 -109
- package/dist/useDraggableCollectionState.main.js.map +0 -1
- package/dist/useDraggableCollectionState.mjs +0 -104
- package/dist/useDraggableCollectionState.module.js +0 -104
- package/dist/useDraggableCollectionState.module.js.map +0 -1
- package/dist/useDroppableCollectionState.main.js +0 -128
- package/dist/useDroppableCollectionState.main.js.map +0 -1
- package/dist/useDroppableCollectionState.mjs +0 -123
- package/dist/useDroppableCollectionState.module.js +0 -123
- package/dist/useDroppableCollectionState.module.js.map +0 -1
- package/src/useDraggableCollectionState.ts +0 -174
- package/src/useDroppableCollectionState.ts +0 -226
package/dist/import.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {useDraggableCollectionState as $
|
|
2
|
-
import {useDroppableCollectionState as $
|
|
1
|
+
import {useDraggableCollectionState as $90fe908e79838c08$re_export$useDraggableCollectionState} from "react-stately/useDraggableCollectionState";
|
|
2
|
+
import {useDroppableCollectionState as $90fe908e79838c08$re_export$useDroppableCollectionState} from "react-stately/useDroppableCollectionState";
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -15,5 +15,5 @@ import {useDroppableCollectionState as $e672e8bc247525d1$export$926850f6ecef79d0
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
export {$
|
|
18
|
+
export {$90fe908e79838c08$re_export$useDraggableCollectionState as useDraggableCollectionState, $90fe908e79838c08$re_export$useDroppableCollectionState as useDroppableCollectionState};
|
|
19
19
|
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
1
|
+
var $6ZYq9$reactstatelyuseDraggableCollectionState = require("react-stately/useDraggableCollectionState");
|
|
2
|
+
var $6ZYq9$reactstatelyuseDroppableCollectionState = require("react-stately/useDroppableCollectionState");
|
|
3
3
|
|
|
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, "useDraggableCollectionState", ()
|
|
10
|
-
$parcel$export(module.exports, "useDroppableCollectionState", ()
|
|
9
|
+
$parcel$export(module.exports, "useDraggableCollectionState", function () { return $6ZYq9$reactstatelyuseDraggableCollectionState.useDraggableCollectionState; });
|
|
10
|
+
$parcel$export(module.exports, "useDroppableCollectionState", function () { return $6ZYq9$reactstatelyuseDroppableCollectionState.useDroppableCollectionState; });
|
|
11
11
|
/*
|
|
12
12
|
* Copyright 2020 Adobe. All rights reserved.
|
|
13
13
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/dnd/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/dnd/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useDraggableCollectionState} from 'react-stately/useDraggableCollectionState';\n\nexport {useDroppableCollectionState} from 'react-stately/useDroppableCollectionState';\nexport type {DraggableCollectionStateOptions, DraggableCollectionState} from 'react-stately/useDraggableCollectionState';\nexport type {DroppableCollectionStateOptions, DroppableCollectionState} from 'react-stately/useDroppableCollectionState';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {useDraggableCollectionState as $
|
|
2
|
-
import {useDroppableCollectionState as $
|
|
1
|
+
import {useDraggableCollectionState as $90fe908e79838c08$re_export$useDraggableCollectionState} from "react-stately/useDraggableCollectionState";
|
|
2
|
+
import {useDroppableCollectionState as $90fe908e79838c08$re_export$useDroppableCollectionState} from "react-stately/useDroppableCollectionState";
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -15,5 +15,5 @@ import {useDroppableCollectionState as $e672e8bc247525d1$export$926850f6ecef79d0
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
export {$
|
|
18
|
+
export {$90fe908e79838c08$re_export$useDraggableCollectionState as useDraggableCollectionState, $90fe908e79838c08$re_export$useDroppableCollectionState as useDroppableCollectionState};
|
|
19
19
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/dnd/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/dnd/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useDraggableCollectionState} from 'react-stately/useDraggableCollectionState';\n\nexport {useDroppableCollectionState} from 'react-stately/useDroppableCollectionState';\nexport type {DraggableCollectionStateOptions, DraggableCollectionState} from 'react-stately/useDraggableCollectionState';\nexport type {DroppableCollectionStateOptions, DroppableCollectionState} from 'react-stately/useDroppableCollectionState';\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useDraggableCollectionState } from 'react-stately/useDraggableCollectionState';
|
|
2
|
+
export { useDroppableCollectionState } from 'react-stately/useDroppableCollectionState';
|
|
3
|
+
export type { DraggableCollectionStateOptions, DraggableCollectionState } from 'react-stately/useDraggableCollectionState';
|
|
4
|
+
export type { DroppableCollectionStateOptions, DroppableCollectionState } from 'react-stately/useDroppableCollectionState';
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/dnd",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
8
|
"exports": {
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
"./dist/types.d.ts",
|
|
12
|
-
"./
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
9
|
+
".": {
|
|
10
|
+
"source": "./src/index.ts",
|
|
11
|
+
"types": "./dist/types/src/index.d.ts",
|
|
12
|
+
"import": "./dist/import.mjs",
|
|
13
|
+
"require": "./dist/main.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
16
|
},
|
|
17
|
-
"types": "dist/types.d.ts",
|
|
17
|
+
"types": "dist/types/src/index.d.ts",
|
|
18
18
|
"source": "src/index.ts",
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
@@ -26,15 +26,18 @@
|
|
|
26
26
|
"url": "https://github.com/adobe/react-spectrum"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
31
|
-
"@swc/helpers": "^0.5.0"
|
|
29
|
+
"@swc/helpers": "^0.5.0",
|
|
30
|
+
"react-stately": "3.46.0"
|
|
32
31
|
},
|
|
33
32
|
"peerDependencies": {
|
|
34
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
33
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
34
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"
|
|
39
|
+
"targets": {
|
|
40
|
+
"types": false
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
|
|
40
43
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
13
|
+
export {useDraggableCollectionState} from 'react-stately/useDraggableCollectionState';
|
|
14
|
+
|
|
15
|
+
export {useDroppableCollectionState} from 'react-stately/useDroppableCollectionState';
|
|
16
|
+
export type {DraggableCollectionStateOptions, DraggableCollectionState} from 'react-stately/useDraggableCollectionState';
|
|
17
|
+
export type {DroppableCollectionStateOptions, DroppableCollectionState} from 'react-stately/useDroppableCollectionState';
|
package/dist/types.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node, RefObject, DragTypes, DroppableCollectionProps, DropTarget } from "@react-types/shared";
|
|
2
|
-
import { MultipleSelectionManager } from "@react-stately/selection";
|
|
3
|
-
export interface DraggableCollectionStateOptions<T = object> extends DraggableCollectionProps<T> {
|
|
4
|
-
/** A collection of items. */
|
|
5
|
-
collection: Collection<Node<unknown>>;
|
|
6
|
-
/** An interface for reading and updating multiple selection state. */
|
|
7
|
-
selectionManager: MultipleSelectionManager;
|
|
8
|
-
/** Whether the drag events should be disabled. */
|
|
9
|
-
isDisabled?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface DraggableCollectionState {
|
|
12
|
-
/** A collection of items. */
|
|
13
|
-
collection: Collection<Node<unknown>>;
|
|
14
|
-
/** An interface for reading and updating multiple selection state. */
|
|
15
|
-
selectionManager: MultipleSelectionManager;
|
|
16
|
-
/** The key of the item that initiated a drag. */
|
|
17
|
-
draggedKey: Key | null;
|
|
18
|
-
/** The keys of the items that are currently being dragged. */
|
|
19
|
-
draggingKeys: Set<Key>;
|
|
20
|
-
/** Whether drag events are disabled. */
|
|
21
|
-
isDisabled?: boolean;
|
|
22
|
-
/** Returns whether the given key is currently being dragged. */
|
|
23
|
-
isDragging(key: Key): boolean;
|
|
24
|
-
/** Returns the keys of the items that will be dragged with the given key (e.g. selected items). */
|
|
25
|
-
getKeysForDrag(key: Key): Set<Key>;
|
|
26
|
-
/** Returns the items to drag for the given key. */
|
|
27
|
-
getItems(key: Key): DragItem[];
|
|
28
|
-
/** The ref of the element that will be rendered as the drag preview while dragging. */
|
|
29
|
-
preview?: RefObject<DragPreviewRenderer | null>;
|
|
30
|
-
/** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */
|
|
31
|
-
getAllowedDropOperations?: () => DropOperation[];
|
|
32
|
-
/** Begins a drag for the given key. This triggers the onDragStart event. */
|
|
33
|
-
startDrag(key: Key, event: DragStartEvent): void;
|
|
34
|
-
/** Triggers an onDragMove event. */
|
|
35
|
-
moveDrag(event: DragMoveEvent): void;
|
|
36
|
-
/** Ends the current drag, and emits an onDragEnd event. */
|
|
37
|
-
endDrag(event: DraggableCollectionEndEvent): void;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Manages state for a draggable collection.
|
|
41
|
-
*/
|
|
42
|
-
export function useDraggableCollectionState<T = object>(props: DraggableCollectionStateOptions<T>): DraggableCollectionState;
|
|
43
|
-
interface DropOperationEvent {
|
|
44
|
-
target: DropTarget;
|
|
45
|
-
types: DragTypes;
|
|
46
|
-
allowedOperations: DropOperation[];
|
|
47
|
-
isInternal: boolean;
|
|
48
|
-
draggingKeys: Set<Key>;
|
|
49
|
-
}
|
|
50
|
-
export interface DroppableCollectionStateOptions extends Omit<DroppableCollectionProps, 'onDropMove' | 'onDropActivate'> {
|
|
51
|
-
/** A collection of items. */
|
|
52
|
-
collection: Collection<Node<unknown>>;
|
|
53
|
-
/** An interface for reading and updating multiple selection state. */
|
|
54
|
-
selectionManager: MultipleSelectionManager;
|
|
55
|
-
/** Whether the drop events should be disabled. */
|
|
56
|
-
isDisabled?: boolean;
|
|
57
|
-
}
|
|
58
|
-
export interface DroppableCollectionState {
|
|
59
|
-
/** A collection of items. */
|
|
60
|
-
collection: Collection<Node<unknown>>;
|
|
61
|
-
/** An interface for reading and updating multiple selection state. */
|
|
62
|
-
selectionManager: MultipleSelectionManager;
|
|
63
|
-
/** The current drop target. */
|
|
64
|
-
target: DropTarget | null;
|
|
65
|
-
/** Whether drop events are disabled. */
|
|
66
|
-
isDisabled?: boolean;
|
|
67
|
-
/** Sets the current drop target. */
|
|
68
|
-
setTarget(target: DropTarget | null): void;
|
|
69
|
-
/** Returns whether the given target is equivalent to the current drop target. */
|
|
70
|
-
isDropTarget(target: DropTarget | null): boolean;
|
|
71
|
-
/** Returns the drop operation for the given parameters. */
|
|
72
|
-
getDropOperation(e: DropOperationEvent): DropOperation;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Manages state for a droppable collection.
|
|
76
|
-
*/
|
|
77
|
-
export function useDroppableCollectionState(props: DroppableCollectionStateOptions): DroppableCollectionState;
|
|
78
|
-
|
|
79
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;AAgBA,iDAAiD,CAAC,GAAG,MAAM,CAAE,SAAQ,yBAAyB,CAAC,CAAC;IAC9F,6BAA6B;IAC7B,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IACtC,sEAAsE;IACtE,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;IACE,6BAA6B;IAC7B,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAA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UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IACtC,sEAAsE;IACtE,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;IACE,6BAA6B;IAC7B,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IACtC,sEAAsE;IACtE,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,+BAA+B;IAC/B,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oCAAoC;IACpC,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;IAC3C,iFAAiF;IACjF,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,OAAO,CAAC;IACjD,2DAA2D;IAC3D,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAAA;CACvD;AAED;;GAEG;AACH,4CAA4C,KAAK,EAAE,+BAA+B,GAAG,wBAAwB,CAkJ5G","sources":["packages/@react-stately/dnd/src/packages/@react-stately/dnd/src/useDraggableCollectionState.ts","packages/@react-stately/dnd/src/packages/@react-stately/dnd/src/useDroppableCollectionState.ts","packages/@react-stately/dnd/src/packages/@react-stately/dnd/src/index.ts","packages/@react-stately/dnd/src/index.ts"],"sourcesContent":[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 {DraggableCollectionStateOptions, DraggableCollectionState} from './useDraggableCollectionState';\nexport type {DroppableCollectionStateOptions, DroppableCollectionState} from './useDroppableCollectionState';\nexport {useDraggableCollectionState} from './useDraggableCollectionState';\nexport {useDroppableCollectionState} from './useDroppableCollectionState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
var $ijIvR$react = require("react");
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function $parcel$export(e, n, v, s) {
|
|
5
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
$parcel$export(module.exports, "useDraggableCollectionState", () => $481a240e3d51b276$export$29efd034f1d79f81);
|
|
9
|
-
/*
|
|
10
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
11
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
-
* governing permissions and limitations under the License.
|
|
19
|
-
*/
|
|
20
|
-
function $481a240e3d51b276$export$29efd034f1d79f81(props) {
|
|
21
|
-
let { getItems: getItems, isDisabled: isDisabled, collection: collection, selectionManager: selectionManager, onDragStart: onDragStart, onDragMove: onDragMove, onDragEnd: onDragEnd, preview: preview, getAllowedDropOperations: getAllowedDropOperations } = props;
|
|
22
|
-
let [, setDragging] = (0, $ijIvR$react.useState)(false);
|
|
23
|
-
let draggingKeys = (0, $ijIvR$react.useRef)(new Set());
|
|
24
|
-
let draggedKey = (0, $ijIvR$react.useRef)(null);
|
|
25
|
-
let getKeys = (key)=>{
|
|
26
|
-
// The clicked item is always added to the drag. If it is selected, then all of the
|
|
27
|
-
// other selected items are also dragged. If it is not selected, then only the clicked
|
|
28
|
-
// item is dragged. This matches native macOS behavior.
|
|
29
|
-
// Additionally, we filter out any keys that are children of any of the other selected keys
|
|
30
|
-
let keys = new Set();
|
|
31
|
-
if (selectionManager.isSelected(key)) for (let currentKey of selectionManager.selectedKeys){
|
|
32
|
-
let node = collection.getItem(currentKey);
|
|
33
|
-
if (node) {
|
|
34
|
-
let isChild = false;
|
|
35
|
-
let parentKey = node.parentKey;
|
|
36
|
-
while(parentKey != null){
|
|
37
|
-
// eslint-disable-next-line max-depth
|
|
38
|
-
if (selectionManager.selectedKeys.has(parentKey)) {
|
|
39
|
-
isChild = true;
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
let parentNode = collection.getItem(parentKey);
|
|
43
|
-
parentKey = parentNode ? parentNode.parentKey : null;
|
|
44
|
-
}
|
|
45
|
-
if (!isChild) keys.add(currentKey);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else keys.add(key);
|
|
49
|
-
return keys;
|
|
50
|
-
};
|
|
51
|
-
return {
|
|
52
|
-
collection: collection,
|
|
53
|
-
selectionManager: selectionManager,
|
|
54
|
-
get draggedKey () {
|
|
55
|
-
return draggedKey.current;
|
|
56
|
-
},
|
|
57
|
-
get draggingKeys () {
|
|
58
|
-
return draggingKeys.current;
|
|
59
|
-
},
|
|
60
|
-
isDragging (key) {
|
|
61
|
-
return draggingKeys.current.has(key);
|
|
62
|
-
},
|
|
63
|
-
getKeysForDrag: getKeys,
|
|
64
|
-
getItems (key) {
|
|
65
|
-
let keys = getKeys(key);
|
|
66
|
-
let items = [];
|
|
67
|
-
for (let key of keys){
|
|
68
|
-
var _collection_getItem;
|
|
69
|
-
let value = (_collection_getItem = collection.getItem(key)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.value;
|
|
70
|
-
if (value != null) items.push(value);
|
|
71
|
-
}
|
|
72
|
-
return getItems(getKeys(key), items);
|
|
73
|
-
},
|
|
74
|
-
isDisabled: isDisabled,
|
|
75
|
-
preview: preview,
|
|
76
|
-
getAllowedDropOperations: getAllowedDropOperations,
|
|
77
|
-
startDrag (key, event) {
|
|
78
|
-
let keys = getKeys(key);
|
|
79
|
-
draggingKeys.current = keys;
|
|
80
|
-
draggedKey.current = key;
|
|
81
|
-
selectionManager.setFocused(false);
|
|
82
|
-
setDragging(true);
|
|
83
|
-
if (typeof onDragStart === 'function') onDragStart({
|
|
84
|
-
...event,
|
|
85
|
-
keys: keys
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
moveDrag (event) {
|
|
89
|
-
if (typeof onDragMove === 'function') onDragMove({
|
|
90
|
-
...event,
|
|
91
|
-
keys: draggingKeys.current
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
endDrag (event) {
|
|
95
|
-
let { isInternal: isInternal } = event;
|
|
96
|
-
if (typeof onDragEnd === 'function') onDragEnd({
|
|
97
|
-
...event,
|
|
98
|
-
keys: draggingKeys.current,
|
|
99
|
-
isInternal: isInternal
|
|
100
|
-
});
|
|
101
|
-
draggingKeys.current = new Set();
|
|
102
|
-
draggedKey.current = null;
|
|
103
|
-
setDragging(false);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
//# sourceMappingURL=useDraggableCollectionState.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA+CM,SAAS,0CAAwC,KAAyC;IAC/F,IAAI,YACF,QAAQ,cACR,UAAU,cACV,UAAU,oBACV,gBAAgB,eAChB,WAAW,cACX,UAAU,aACV,SAAS,WACT,OAAO,4BACP,wBAAwB,EACzB,GAAG;IACJ,IAAI,GAAG,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC/B,IAAI,eAAe,CAAA,GAAA,mBAAK,EAAE,IAAI;IAC9B,IAAI,aAAa,CAAA,GAAA,mBAAK,EAAc;IACpC,I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AY;gBACV,GAAG,KAAK;sBACR;YACF;QAEJ;QACA,UAAS,KAAK;YACZ,IAAI,OAAO,eAAe,YACxB,WAAW;gBACT,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;YAC5B;QAEJ;QACA,SAAQ,KAAK;YACX,IAAI,cACF,UAAU,EACX,GAAG;YAEJ,IAAI,OAAO,cAAc,YACvB,UAAU;gBACR,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;4BAC1B;YACF;YAGF,aAAa,OAAO,GAAG,IAAI;YAC3B,WAAW,OAAO,GAAG;YACrB,YAAY;QACd;IACF;AACF","sources":["packages/@react-stately/dnd/src/useDraggableCollectionState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node, RefObject} from '@react-types/shared';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {useRef, useState} from 'react';\n\nexport interface DraggableCollectionStateOptions<T = object> extends DraggableCollectionProps<T> {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** Whether the drag events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DraggableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** The key of the item that initiated a drag. */\n draggedKey: Key | null,\n /** The keys of the items that are currently being dragged. */\n draggingKeys: Set<Key>,\n /** Whether drag events are disabled. */\n isDisabled?: boolean,\n /** Returns whether the given key is currently being dragged. */\n isDragging(key: Key): boolean,\n /** Returns the keys of the items that will be dragged with the given key (e.g. selected items). */\n getKeysForDrag(key: Key): Set<Key>,\n /** Returns the items to drag for the given key. */\n getItems(key: Key): DragItem[],\n /** The ref of the element that will be rendered as the drag preview while dragging. */\n preview?: RefObject<DragPreviewRenderer | null>,\n /** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */\n getAllowedDropOperations?: () => DropOperation[],\n /** Begins a drag for the given key. This triggers the onDragStart event. */\n startDrag(key: Key, event: DragStartEvent): void,\n /** Triggers an onDragMove event. */\n moveDrag(event: DragMoveEvent): void,\n /** Ends the current drag, and emits an onDragEnd event. */\n endDrag(event: DraggableCollectionEndEvent): void\n}\n\n/**\n * Manages state for a draggable collection.\n */\nexport function useDraggableCollectionState<T = object>(props: DraggableCollectionStateOptions<T>): DraggableCollectionState {\n let {\n getItems,\n isDisabled,\n collection,\n selectionManager,\n onDragStart,\n onDragMove,\n onDragEnd,\n preview,\n getAllowedDropOperations\n } = props;\n let [, setDragging] = useState(false);\n let draggingKeys = useRef(new Set<Key>());\n let draggedKey = useRef<Key | null>(null);\n let getKeys = (key: Key) => {\n // The clicked item is always added to the drag. If it is selected, then all of the\n // other selected items are also dragged. If it is not selected, then only the clicked\n // item is dragged. This matches native macOS behavior.\n // Additionally, we filter out any keys that are children of any of the other selected keys\n let keys = new Set<Key>();\n if (selectionManager.isSelected(key)) {\n for (let currentKey of selectionManager.selectedKeys) {\n let node = collection.getItem(currentKey);\n if (node) {\n let isChild = false;\n let parentKey = node.parentKey;\n while (parentKey != null) {\n // eslint-disable-next-line max-depth\n if (selectionManager.selectedKeys.has(parentKey)) {\n isChild = true;\n break;\n }\n let parentNode = collection.getItem(parentKey);\n parentKey = parentNode ? parentNode.parentKey : null;\n }\n\n if (!isChild) {\n keys.add(currentKey);\n }\n }\n }\n } else {\n keys.add(key);\n }\n\n return keys;\n };\n\n return {\n collection,\n selectionManager,\n get draggedKey() {\n return draggedKey.current;\n },\n get draggingKeys() {\n return draggingKeys.current;\n },\n isDragging(key) {\n return draggingKeys.current.has(key);\n },\n getKeysForDrag: getKeys,\n getItems(key) {\n let keys = getKeys(key);\n let items: any[] = [];\n for (let key of keys) {\n let value = collection.getItem(key)?.value;\n if (value != null) {\n items.push(value);\n }\n }\n\n return getItems(getKeys(key), items);\n },\n isDisabled,\n preview,\n getAllowedDropOperations,\n startDrag(key, event) {\n let keys = getKeys(key);\n draggingKeys.current = keys;\n draggedKey.current = key;\n selectionManager.setFocused(false);\n setDragging(true);\n if (typeof onDragStart === 'function') {\n onDragStart({\n ...event,\n keys\n });\n }\n },\n moveDrag(event) {\n if (typeof onDragMove === 'function') {\n onDragMove({\n ...event,\n keys: draggingKeys.current\n });\n }\n },\n endDrag(event) {\n let {\n isInternal\n } = event;\n\n if (typeof onDragEnd === 'function') {\n onDragEnd({\n ...event,\n keys: draggingKeys.current,\n isInternal\n });\n }\n\n draggingKeys.current = new Set();\n draggedKey.current = null;\n setDragging(false);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableCollectionState.main.js.map"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import {useState as $8rdZD$useState, useRef as $8rdZD$useRef} from "react";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
function $b45bbbaf0c3785df$export$29efd034f1d79f81(props) {
|
|
15
|
-
let { getItems: getItems, isDisabled: isDisabled, collection: collection, selectionManager: selectionManager, onDragStart: onDragStart, onDragMove: onDragMove, onDragEnd: onDragEnd, preview: preview, getAllowedDropOperations: getAllowedDropOperations } = props;
|
|
16
|
-
let [, setDragging] = (0, $8rdZD$useState)(false);
|
|
17
|
-
let draggingKeys = (0, $8rdZD$useRef)(new Set());
|
|
18
|
-
let draggedKey = (0, $8rdZD$useRef)(null);
|
|
19
|
-
let getKeys = (key)=>{
|
|
20
|
-
// The clicked item is always added to the drag. If it is selected, then all of the
|
|
21
|
-
// other selected items are also dragged. If it is not selected, then only the clicked
|
|
22
|
-
// item is dragged. This matches native macOS behavior.
|
|
23
|
-
// Additionally, we filter out any keys that are children of any of the other selected keys
|
|
24
|
-
let keys = new Set();
|
|
25
|
-
if (selectionManager.isSelected(key)) for (let currentKey of selectionManager.selectedKeys){
|
|
26
|
-
let node = collection.getItem(currentKey);
|
|
27
|
-
if (node) {
|
|
28
|
-
let isChild = false;
|
|
29
|
-
let parentKey = node.parentKey;
|
|
30
|
-
while(parentKey != null){
|
|
31
|
-
// eslint-disable-next-line max-depth
|
|
32
|
-
if (selectionManager.selectedKeys.has(parentKey)) {
|
|
33
|
-
isChild = true;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
let parentNode = collection.getItem(parentKey);
|
|
37
|
-
parentKey = parentNode ? parentNode.parentKey : null;
|
|
38
|
-
}
|
|
39
|
-
if (!isChild) keys.add(currentKey);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else keys.add(key);
|
|
43
|
-
return keys;
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
46
|
-
collection: collection,
|
|
47
|
-
selectionManager: selectionManager,
|
|
48
|
-
get draggedKey () {
|
|
49
|
-
return draggedKey.current;
|
|
50
|
-
},
|
|
51
|
-
get draggingKeys () {
|
|
52
|
-
return draggingKeys.current;
|
|
53
|
-
},
|
|
54
|
-
isDragging (key) {
|
|
55
|
-
return draggingKeys.current.has(key);
|
|
56
|
-
},
|
|
57
|
-
getKeysForDrag: getKeys,
|
|
58
|
-
getItems (key) {
|
|
59
|
-
let keys = getKeys(key);
|
|
60
|
-
let items = [];
|
|
61
|
-
for (let key of keys){
|
|
62
|
-
var _collection_getItem;
|
|
63
|
-
let value = (_collection_getItem = collection.getItem(key)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.value;
|
|
64
|
-
if (value != null) items.push(value);
|
|
65
|
-
}
|
|
66
|
-
return getItems(getKeys(key), items);
|
|
67
|
-
},
|
|
68
|
-
isDisabled: isDisabled,
|
|
69
|
-
preview: preview,
|
|
70
|
-
getAllowedDropOperations: getAllowedDropOperations,
|
|
71
|
-
startDrag (key, event) {
|
|
72
|
-
let keys = getKeys(key);
|
|
73
|
-
draggingKeys.current = keys;
|
|
74
|
-
draggedKey.current = key;
|
|
75
|
-
selectionManager.setFocused(false);
|
|
76
|
-
setDragging(true);
|
|
77
|
-
if (typeof onDragStart === 'function') onDragStart({
|
|
78
|
-
...event,
|
|
79
|
-
keys: keys
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
moveDrag (event) {
|
|
83
|
-
if (typeof onDragMove === 'function') onDragMove({
|
|
84
|
-
...event,
|
|
85
|
-
keys: draggingKeys.current
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
endDrag (event) {
|
|
89
|
-
let { isInternal: isInternal } = event;
|
|
90
|
-
if (typeof onDragEnd === 'function') onDragEnd({
|
|
91
|
-
...event,
|
|
92
|
-
keys: draggingKeys.current,
|
|
93
|
-
isInternal: isInternal
|
|
94
|
-
});
|
|
95
|
-
draggingKeys.current = new Set();
|
|
96
|
-
draggedKey.current = null;
|
|
97
|
-
setDragging(false);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
export {$b45bbbaf0c3785df$export$29efd034f1d79f81 as useDraggableCollectionState};
|
|
104
|
-
//# sourceMappingURL=useDraggableCollectionState.module.js.map
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import {useState as $8rdZD$useState, useRef as $8rdZD$useRef} from "react";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
function $b45bbbaf0c3785df$export$29efd034f1d79f81(props) {
|
|
15
|
-
let { getItems: getItems, isDisabled: isDisabled, collection: collection, selectionManager: selectionManager, onDragStart: onDragStart, onDragMove: onDragMove, onDragEnd: onDragEnd, preview: preview, getAllowedDropOperations: getAllowedDropOperations } = props;
|
|
16
|
-
let [, setDragging] = (0, $8rdZD$useState)(false);
|
|
17
|
-
let draggingKeys = (0, $8rdZD$useRef)(new Set());
|
|
18
|
-
let draggedKey = (0, $8rdZD$useRef)(null);
|
|
19
|
-
let getKeys = (key)=>{
|
|
20
|
-
// The clicked item is always added to the drag. If it is selected, then all of the
|
|
21
|
-
// other selected items are also dragged. If it is not selected, then only the clicked
|
|
22
|
-
// item is dragged. This matches native macOS behavior.
|
|
23
|
-
// Additionally, we filter out any keys that are children of any of the other selected keys
|
|
24
|
-
let keys = new Set();
|
|
25
|
-
if (selectionManager.isSelected(key)) for (let currentKey of selectionManager.selectedKeys){
|
|
26
|
-
let node = collection.getItem(currentKey);
|
|
27
|
-
if (node) {
|
|
28
|
-
let isChild = false;
|
|
29
|
-
let parentKey = node.parentKey;
|
|
30
|
-
while(parentKey != null){
|
|
31
|
-
// eslint-disable-next-line max-depth
|
|
32
|
-
if (selectionManager.selectedKeys.has(parentKey)) {
|
|
33
|
-
isChild = true;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
let parentNode = collection.getItem(parentKey);
|
|
37
|
-
parentKey = parentNode ? parentNode.parentKey : null;
|
|
38
|
-
}
|
|
39
|
-
if (!isChild) keys.add(currentKey);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else keys.add(key);
|
|
43
|
-
return keys;
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
46
|
-
collection: collection,
|
|
47
|
-
selectionManager: selectionManager,
|
|
48
|
-
get draggedKey () {
|
|
49
|
-
return draggedKey.current;
|
|
50
|
-
},
|
|
51
|
-
get draggingKeys () {
|
|
52
|
-
return draggingKeys.current;
|
|
53
|
-
},
|
|
54
|
-
isDragging (key) {
|
|
55
|
-
return draggingKeys.current.has(key);
|
|
56
|
-
},
|
|
57
|
-
getKeysForDrag: getKeys,
|
|
58
|
-
getItems (key) {
|
|
59
|
-
let keys = getKeys(key);
|
|
60
|
-
let items = [];
|
|
61
|
-
for (let key of keys){
|
|
62
|
-
var _collection_getItem;
|
|
63
|
-
let value = (_collection_getItem = collection.getItem(key)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.value;
|
|
64
|
-
if (value != null) items.push(value);
|
|
65
|
-
}
|
|
66
|
-
return getItems(getKeys(key), items);
|
|
67
|
-
},
|
|
68
|
-
isDisabled: isDisabled,
|
|
69
|
-
preview: preview,
|
|
70
|
-
getAllowedDropOperations: getAllowedDropOperations,
|
|
71
|
-
startDrag (key, event) {
|
|
72
|
-
let keys = getKeys(key);
|
|
73
|
-
draggingKeys.current = keys;
|
|
74
|
-
draggedKey.current = key;
|
|
75
|
-
selectionManager.setFocused(false);
|
|
76
|
-
setDragging(true);
|
|
77
|
-
if (typeof onDragStart === 'function') onDragStart({
|
|
78
|
-
...event,
|
|
79
|
-
keys: keys
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
moveDrag (event) {
|
|
83
|
-
if (typeof onDragMove === 'function') onDragMove({
|
|
84
|
-
...event,
|
|
85
|
-
keys: draggingKeys.current
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
endDrag (event) {
|
|
89
|
-
let { isInternal: isInternal } = event;
|
|
90
|
-
if (typeof onDragEnd === 'function') onDragEnd({
|
|
91
|
-
...event,
|
|
92
|
-
keys: draggingKeys.current,
|
|
93
|
-
isInternal: isInternal
|
|
94
|
-
});
|
|
95
|
-
draggingKeys.current = new Set();
|
|
96
|
-
draggedKey.current = null;
|
|
97
|
-
setDragging(false);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
export {$b45bbbaf0c3785df$export$29efd034f1d79f81 as useDraggableCollectionState};
|
|
104
|
-
//# sourceMappingURL=useDraggableCollectionState.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AA+CM,SAAS,0CAAwC,KAAyC;IAC/F,IAAI,YACF,QAAQ,cACR,UAAU,cACV,UAAU,oBACV,gBAAgB,eAChB,WAAW,cACX,UAAU,aACV,SAAS,WACT,OAAO,4BACP,wBAAwB,EACzB,GAAG;IACJ,IAAI,GAAG,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IAC/B,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE,IAAI;IAC9B,IAAI,aAAa,CAAA,GAAA,aAAK,EAAc;IACpC,IAAI,UAAU,CAAC;QACb,mFAAmF;QACnF,sFAAsF;QACtF,uDAAuD;QACvD,2FAA2F;QAC3F,IAAI,OAAO,IAAI;QACf,IAAI,iBAAiB,UAAU,CAAC,MAC9B,KAAK,IAAI,cAAc,iBAAiB,YAAY,CAAE;YACpD,IAAI,OAAO,WAAW,OAAO,CAAC;YAC9B,IAAI,MA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vB,UAAU;gBACR,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;4BAC1B;YACF;YAGF,aAAa,OAAO,GAAG,IAAI;YAC3B,WAAW,OAAO,GAAG;YACrB,YAAY;QACd;IACF;AACF","sources":["packages/@react-stately/dnd/src/useDraggableCollectionState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node, RefObject} from '@react-types/shared';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {useRef, useState} from 'react';\n\nexport interface DraggableCollectionStateOptions<T = object> extends DraggableCollectionProps<T> {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** Whether the drag events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DraggableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** The key of the item that initiated a drag. */\n draggedKey: Key | null,\n /** The keys of the items that are currently being dragged. */\n draggingKeys: Set<Key>,\n /** Whether drag events are disabled. */\n isDisabled?: boolean,\n /** Returns whether the given key is currently being dragged. */\n isDragging(key: Key): boolean,\n /** Returns the keys of the items that will be dragged with the given key (e.g. selected items). */\n getKeysForDrag(key: Key): Set<Key>,\n /** Returns the items to drag for the given key. */\n getItems(key: Key): DragItem[],\n /** The ref of the element that will be rendered as the drag preview while dragging. */\n preview?: RefObject<DragPreviewRenderer | null>,\n /** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */\n getAllowedDropOperations?: () => DropOperation[],\n /** Begins a drag for the given key. This triggers the onDragStart event. */\n startDrag(key: Key, event: DragStartEvent): void,\n /** Triggers an onDragMove event. */\n moveDrag(event: DragMoveEvent): void,\n /** Ends the current drag, and emits an onDragEnd event. */\n endDrag(event: DraggableCollectionEndEvent): void\n}\n\n/**\n * Manages state for a draggable collection.\n */\nexport function useDraggableCollectionState<T = object>(props: DraggableCollectionStateOptions<T>): DraggableCollectionState {\n let {\n getItems,\n isDisabled,\n collection,\n selectionManager,\n onDragStart,\n onDragMove,\n onDragEnd,\n preview,\n getAllowedDropOperations\n } = props;\n let [, setDragging] = useState(false);\n let draggingKeys = useRef(new Set<Key>());\n let draggedKey = useRef<Key | null>(null);\n let getKeys = (key: Key) => {\n // The clicked item is always added to the drag. If it is selected, then all of the\n // other selected items are also dragged. If it is not selected, then only the clicked\n // item is dragged. This matches native macOS behavior.\n // Additionally, we filter out any keys that are children of any of the other selected keys\n let keys = new Set<Key>();\n if (selectionManager.isSelected(key)) {\n for (let currentKey of selectionManager.selectedKeys) {\n let node = collection.getItem(currentKey);\n if (node) {\n let isChild = false;\n let parentKey = node.parentKey;\n while (parentKey != null) {\n // eslint-disable-next-line max-depth\n if (selectionManager.selectedKeys.has(parentKey)) {\n isChild = true;\n break;\n }\n let parentNode = collection.getItem(parentKey);\n parentKey = parentNode ? parentNode.parentKey : null;\n }\n\n if (!isChild) {\n keys.add(currentKey);\n }\n }\n }\n } else {\n keys.add(key);\n }\n\n return keys;\n };\n\n return {\n collection,\n selectionManager,\n get draggedKey() {\n return draggedKey.current;\n },\n get draggingKeys() {\n return draggingKeys.current;\n },\n isDragging(key) {\n return draggingKeys.current.has(key);\n },\n getKeysForDrag: getKeys,\n getItems(key) {\n let keys = getKeys(key);\n let items: any[] = [];\n for (let key of keys) {\n let value = collection.getItem(key)?.value;\n if (value != null) {\n items.push(value);\n }\n }\n\n return getItems(getKeys(key), items);\n },\n isDisabled,\n preview,\n getAllowedDropOperations,\n startDrag(key, event) {\n let keys = getKeys(key);\n draggingKeys.current = keys;\n draggedKey.current = key;\n selectionManager.setFocused(false);\n setDragging(true);\n if (typeof onDragStart === 'function') {\n onDragStart({\n ...event,\n keys\n });\n }\n },\n moveDrag(event) {\n if (typeof onDragMove === 'function') {\n onDragMove({\n ...event,\n keys: draggingKeys.current\n });\n }\n },\n endDrag(event) {\n let {\n isInternal\n } = event;\n\n if (typeof onDragEnd === 'function') {\n onDragEnd({\n ...event,\n keys: draggingKeys.current,\n isInternal\n });\n }\n\n draggingKeys.current = new Set();\n draggedKey.current = null;\n setDragging(false);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableCollectionState.module.js.map"}
|