@react-spectrum/dnd 3.0.0-alpha.2 → 3.0.0-alpha.5
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 +31 -26
- package/dist/main.js.map +1 -1
- package/dist/module.js +32 -16
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +14 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +4 -1
- package/src/useDragHooks.ts +9 -21
- package/src/useDropHooks.ts +34 -0
package/dist/main.js
CHANGED
|
@@ -2,45 +2,51 @@ var $9OUiQ$reactstatelydnd = require("@react-stately/dnd");
|
|
|
2
2
|
var $9OUiQ$reactariadnd = require("@react-aria/dnd");
|
|
3
3
|
var $9OUiQ$react = require("react");
|
|
4
4
|
|
|
5
|
-
function $parcel$exportWildcard(dest, source) {
|
|
6
|
-
Object.keys(source).forEach(function(key) {
|
|
7
|
-
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(dest, key, {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function get() {
|
|
14
|
-
return source[key];
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return dest;
|
|
20
|
-
}
|
|
21
5
|
function $parcel$export(e, n, v, s) {
|
|
22
6
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
23
7
|
}
|
|
24
|
-
var $bb595e9145c20bae$exports = {};
|
|
25
8
|
|
|
26
|
-
$parcel$export(
|
|
9
|
+
$parcel$export(module.exports, "useDragHooks", () => $bb595e9145c20bae$export$ca50582736fec395);
|
|
10
|
+
$parcel$export(module.exports, "useDropHooks", () => $eb31ce34e8964bed$export$c9cc1cdafc7aa18a);
|
|
27
11
|
|
|
28
12
|
|
|
29
13
|
|
|
30
14
|
function $bb595e9145c20bae$export$ca50582736fec395(options) {
|
|
31
15
|
return $9OUiQ$react.useMemo(()=>({
|
|
32
16
|
useDraggableCollectionState (props) {
|
|
33
|
-
let { collection: collection , selectionManager: selectionManager , allowsDraggingItem: allowsDraggingItem , getItems: getItems , renderPreview: renderPreview } = props;
|
|
34
17
|
return $9OUiQ$reactstatelydnd.useDraggableCollectionState({
|
|
35
|
-
|
|
36
|
-
selectionManager: selectionManager,
|
|
37
|
-
allowsDraggingItem: allowsDraggingItem,
|
|
38
|
-
getItems: getItems,
|
|
39
|
-
renderPreview: renderPreview,
|
|
18
|
+
...props,
|
|
40
19
|
...options
|
|
41
20
|
});
|
|
42
21
|
},
|
|
43
|
-
useDraggableItem: $9OUiQ$reactariadnd.useDraggableItem
|
|
22
|
+
useDraggableItem: $9OUiQ$reactariadnd.useDraggableItem,
|
|
23
|
+
DragPreview: $9OUiQ$reactariadnd.DragPreview
|
|
24
|
+
})
|
|
25
|
+
, [
|
|
26
|
+
options
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
function $eb31ce34e8964bed$export$c9cc1cdafc7aa18a(options) {
|
|
35
|
+
return $9OUiQ$react.useMemo(()=>({
|
|
36
|
+
useDroppableCollectionState (props) {
|
|
37
|
+
return $9OUiQ$reactstatelydnd.useDroppableCollectionState({
|
|
38
|
+
...props,
|
|
39
|
+
...options
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
useDroppableItem: $9OUiQ$reactariadnd.useDroppableItem,
|
|
43
|
+
useDroppableCollection (props, state, ref) {
|
|
44
|
+
return $9OUiQ$reactariadnd.useDroppableCollection({
|
|
45
|
+
...props,
|
|
46
|
+
...options
|
|
47
|
+
}, state, ref);
|
|
48
|
+
},
|
|
49
|
+
useDropIndicator: $9OUiQ$reactariadnd.useDropIndicator
|
|
44
50
|
})
|
|
45
51
|
, [
|
|
46
52
|
options
|
|
@@ -48,7 +54,6 @@ function $bb595e9145c20bae$export$ca50582736fec395(options) {
|
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
|
|
51
|
-
$parcel$exportWildcard(module.exports, $bb595e9145c20bae$exports);
|
|
52
57
|
|
|
53
58
|
|
|
54
59
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;SCagB,yCAAY,CAAC,OAAwB,EAAa,CAAC;IACjE,MAAM,CAAC,oBAAO,MAAQ,CAAC;YACrB,2BAA2B,EAAC,KAAiC,EAAE,CAAC;gBAC9D,MAAM,CAAC,kDAA2B,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC;YAC3D,CAAC;8BACD,oCAAgB;yBAChB,+BAAW;QACb,CAAC;MAAG,CAAC;QAAA,OAAO;IAAA,CAAC;AACf,CAAC;;;;;;SCCe,yCAAY,CAAC,OAAiC,EAAa,CAAC;IAC1E,MAAM,CAAC,oBAAO,MAAQ,CAAC;YACrB,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;AACf,CAAC;;","sources":["packages/@react-spectrum/dnd/src/index.ts","packages/@react-spectrum/dnd/src/useDragHooks.ts","packages/@react-spectrum/dnd/src/useDropHooks.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 {DragHooks, DragHookOptions} from './useDragHooks';\nexport type {DropHooks} from './useDropHooks';\nexport {useDragHooks} from './useDragHooks';\nexport {useDropHooks} from './useDropHooks';\n","import {DraggableCollectionOptions, DraggableCollectionState, useDraggableCollectionState} from '@react-stately/dnd';\nimport {DraggableCollectionProps} from '@react-types/shared';\nimport {DraggableItemProps, DraggableItemResult, DragPreview, useDraggableItem} from '@react-aria/dnd';\nimport {useMemo} from 'react';\n\nexport interface DragHooks {\n useDraggableCollectionState(props: Omit<DraggableCollectionOptions, 'getItems'>): DraggableCollectionState,\n useDraggableItem(props: DraggableItemProps, state: DraggableCollectionState): DraggableItemResult,\n DragPreview: typeof DragPreview\n}\n\nexport interface DragHookOptions extends Omit<DraggableCollectionProps, 'preview'> {}\n\nexport function useDragHooks(options: DragHookOptions): DragHooks {\n return useMemo(() => ({\n useDraggableCollectionState(props: DraggableCollectionOptions) {\n return useDraggableCollectionState({...props, ...options});\n },\n useDraggableItem,\n DragPreview\n }), [options]);\n}\n","import {\n DropIndicatorAria,\n DropIndicatorProps,\n DroppableCollectionOptions,\n DroppableCollectionResult,\n DroppableItemOptions,\n DroppableItemResult,\n useDropIndicator,\n useDroppableCollection,\n useDroppableItem\n} from '@react-aria/dnd';\nimport {DroppableCollectionProps} from '@react-types/shared';\nimport {DroppableCollectionState, DroppableCollectionStateOptions, useDroppableCollectionState} from '@react-stately/dnd';\nimport {RefObject, useMemo} from 'react';\n\nexport interface 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 function useDropHooks(options: DroppableCollectionProps): DropHooks {\n return 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"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,30 +1,46 @@
|
|
|
1
|
-
import {useDraggableCollectionState as $6PX7k$useDraggableCollectionState} from "@react-stately/dnd";
|
|
2
|
-
import {useDraggableItem as $6PX7k$useDraggableItem} from "@react-aria/dnd";
|
|
1
|
+
import {useDraggableCollectionState as $6PX7k$useDraggableCollectionState, useDroppableCollectionState as $6PX7k$useDroppableCollectionState} from "@react-stately/dnd";
|
|
2
|
+
import {useDraggableItem as $6PX7k$useDraggableItem, DragPreview as $6PX7k$DragPreview, 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
|
-
function $parcel$export(e, n, v, s) {
|
|
6
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
-
}
|
|
8
|
-
var $1d9ad6c92ef06635$exports = {};
|
|
9
|
-
|
|
10
|
-
$parcel$export($1d9ad6c92ef06635$exports, "useDragHooks", () => $1d9ad6c92ef06635$export$ca50582736fec395);
|
|
11
5
|
|
|
12
6
|
|
|
13
7
|
|
|
14
8
|
function $1d9ad6c92ef06635$export$ca50582736fec395(options) {
|
|
15
9
|
return $6PX7k$useMemo(()=>({
|
|
16
10
|
useDraggableCollectionState (props) {
|
|
17
|
-
let { collection: collection , selectionManager: selectionManager , allowsDraggingItem: allowsDraggingItem , getItems: getItems , renderPreview: renderPreview } = props;
|
|
18
11
|
return $6PX7k$useDraggableCollectionState({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
...props,
|
|
13
|
+
...options
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
useDraggableItem: $6PX7k$useDraggableItem,
|
|
17
|
+
DragPreview: $6PX7k$DragPreview
|
|
18
|
+
})
|
|
19
|
+
, [
|
|
20
|
+
options
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function $d9620cb8af727810$export$c9cc1cdafc7aa18a(options) {
|
|
29
|
+
return $6PX7k$useMemo(()=>({
|
|
30
|
+
useDroppableCollectionState (props) {
|
|
31
|
+
return $6PX7k$useDroppableCollectionState({
|
|
32
|
+
...props,
|
|
24
33
|
...options
|
|
25
34
|
});
|
|
26
35
|
},
|
|
27
|
-
|
|
36
|
+
useDroppableItem: $6PX7k$useDroppableItem,
|
|
37
|
+
useDroppableCollection (props, state, ref) {
|
|
38
|
+
return $6PX7k$useDroppableCollection({
|
|
39
|
+
...props,
|
|
40
|
+
...options
|
|
41
|
+
}, state, ref);
|
|
42
|
+
},
|
|
43
|
+
useDropIndicator: $6PX7k$useDropIndicator
|
|
28
44
|
})
|
|
29
45
|
, [
|
|
30
46
|
options
|
|
@@ -34,5 +50,5 @@ function $1d9ad6c92ef06635$export$ca50582736fec395(options) {
|
|
|
34
50
|
|
|
35
51
|
|
|
36
52
|
|
|
37
|
-
export {$1d9ad6c92ef06635$export$ca50582736fec395 as useDragHooks};
|
|
53
|
+
export {$1d9ad6c92ef06635$export$ca50582736fec395 as useDragHooks, $d9620cb8af727810$export$c9cc1cdafc7aa18a as useDropHooks};
|
|
38
54
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;SCagB,yCAAY,CAAC,OAAwB,EAAa,CAAC;IACjE,MAAM,CAAC,cAAO,MAAQ,CAAC;YACrB,2BAA2B,EAAC,KAAiC,EAAE,CAAC;gBAC9D,MAAM,CAAC,kCAA2B,CAAC,CAAC;uBAAG,KAAK;uBAAK,OAAO;gBAAA,CAAC;YAC3D,CAAC;8BACD,uBAAgB;yBAChB,kBAAW;QACb,CAAC;MAAG,CAAC;QAAA,OAAO;IAAA,CAAC;AACf,CAAC;;;;;;SCCe,yCAAY,CAAC,OAAiC,EAAa,CAAC;IAC1E,MAAM,CAAC,cAAO,MAAQ,CAAC;YACrB,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;AACf,CAAC;;","sources":["packages/@react-spectrum/dnd/src/index.ts","packages/@react-spectrum/dnd/src/useDragHooks.ts","packages/@react-spectrum/dnd/src/useDropHooks.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 {DragHooks, DragHookOptions} from './useDragHooks';\nexport type {DropHooks} from './useDropHooks';\nexport {useDragHooks} from './useDragHooks';\nexport {useDropHooks} from './useDropHooks';\n","import {DraggableCollectionOptions, DraggableCollectionState, useDraggableCollectionState} from '@react-stately/dnd';\nimport {DraggableCollectionProps} from '@react-types/shared';\nimport {DraggableItemProps, DraggableItemResult, DragPreview, useDraggableItem} from '@react-aria/dnd';\nimport {useMemo} from 'react';\n\nexport interface DragHooks {\n useDraggableCollectionState(props: Omit<DraggableCollectionOptions, 'getItems'>): DraggableCollectionState,\n useDraggableItem(props: DraggableItemProps, state: DraggableCollectionState): DraggableItemResult,\n DragPreview: typeof DragPreview\n}\n\nexport interface DragHookOptions extends Omit<DraggableCollectionProps, 'preview'> {}\n\nexport function useDragHooks(options: DragHookOptions): DragHooks {\n return useMemo(() => ({\n useDraggableCollectionState(props: DraggableCollectionOptions) {\n return useDraggableCollectionState({...props, ...options});\n },\n useDraggableItem,\n DragPreview\n }), [options]);\n}\n","import {\n DropIndicatorAria,\n DropIndicatorProps,\n DroppableCollectionOptions,\n DroppableCollectionResult,\n DroppableItemOptions,\n DroppableItemResult,\n useDropIndicator,\n useDroppableCollection,\n useDroppableItem\n} from '@react-aria/dnd';\nimport {DroppableCollectionProps} from '@react-types/shared';\nimport {DroppableCollectionState, DroppableCollectionStateOptions, useDroppableCollectionState} from '@react-stately/dnd';\nimport {RefObject, useMemo} from 'react';\n\nexport interface 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 function useDropHooks(options: DroppableCollectionProps): DropHooks {\n return 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"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { DraggableCollectionOptions, DraggableCollectionState } from "@react-stately/dnd";
|
|
2
|
-
import {
|
|
1
|
+
import { DraggableCollectionOptions, DraggableCollectionState, DroppableCollectionState, DroppableCollectionStateOptions } from "@react-stately/dnd";
|
|
2
|
+
import { DraggableCollectionProps, DroppableCollectionProps } from "@react-types/shared";
|
|
3
|
+
import { DraggableItemProps, DraggableItemResult, DragPreview, DropIndicatorAria, DropIndicatorProps, DroppableCollectionOptions, DroppableCollectionResult, DroppableItemOptions, DroppableItemResult } from "@react-aria/dnd";
|
|
4
|
+
import { RefObject } from "react";
|
|
3
5
|
export interface DragHooks {
|
|
4
6
|
useDraggableCollectionState(props: Omit<DraggableCollectionOptions, 'getItems'>): DraggableCollectionState;
|
|
5
7
|
useDraggableItem(props: DraggableItemProps, state: DraggableCollectionState): DraggableItemResult;
|
|
8
|
+
DragPreview: typeof DragPreview;
|
|
9
|
+
}
|
|
10
|
+
export interface DragHookOptions extends Omit<DraggableCollectionProps, 'preview'> {
|
|
6
11
|
}
|
|
7
|
-
export type DragHookOptions = Omit<DraggableCollectionOptions, 'collection' | 'selectionManager' | 'isDragging' | 'getKeysForDrag'>;
|
|
8
12
|
export function useDragHooks(options: DragHookOptions): DragHooks;
|
|
13
|
+
export interface DropHooks {
|
|
14
|
+
useDroppableCollectionState(props: DroppableCollectionStateOptions): DroppableCollectionState;
|
|
15
|
+
useDroppableCollection(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DroppableCollectionResult;
|
|
16
|
+
useDroppableItem(options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DroppableItemResult;
|
|
17
|
+
useDropIndicator(props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DropIndicatorAria;
|
|
18
|
+
}
|
|
19
|
+
export function useDropHooks(options: DroppableCollectionProps): DropHooks;
|
|
9
20
|
|
|
10
21
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;AAKA;IACE,2BAA2B,CAAC,KAAK,EAAE,IAAI,CAAC,0BAA0B,EAAE,UAAU,CAAC,GAAG,wBAAwB,CAAC;IAC3G,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,wBAAwB,GAAG,mBAAmB,CAAC;IAClG,aAAa,kBAAkB,CAAA;CAChC;AAED,gCAAiC,SAAQ,IAAI,CAAC,wBAAwB,EAAE,SAAS,CAAC;CAAG;AAErF,6BAA6B,OAAO,EAAE,eAAe,GAAG,SAAS,CAQhE;ACND;IACE,2BAA2B,CAAC,KAAK,EAAE,+BAA+B,GAAG,wBAAwB,CAAC;IAC9F,sBAAsB,CAAC,KAAK,EAAE,0BAA0B,EAAE,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,yBAAyB,CAAC;IACnJ,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,mBAAmB,CAAC;IACnI,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,iBAAiB,CAAA;CAC7H;AAED,6BAA6B,OAAO,EAAE,wBAAwB,GAAG,SAAS,CAWzE","sources":["packages/@react-spectrum/dnd/src/packages/@react-spectrum/dnd/src/useDragHooks.ts","packages/@react-spectrum/dnd/src/packages/@react-spectrum/dnd/src/useDropHooks.ts","packages/@react-spectrum/dnd/src/packages/@react-spectrum/dnd/src/index.ts","packages/@react-spectrum/dnd/src/index.ts"],"sourcesContent":[null,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 {DragHooks, DragHookOptions} from './useDragHooks';\nexport type {DropHooks} from './useDropHooks';\nexport {useDragHooks} from './useDragHooks';\nexport {useDropHooks} from './useDropHooks';\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-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.5",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -32,18 +32,19 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.6.2",
|
|
35
|
-
"@react-aria/dnd": "3.0.0-alpha.
|
|
36
|
-
"@react-stately/dnd": "3.0.0-alpha.
|
|
35
|
+
"@react-aria/dnd": "3.0.0-alpha.11",
|
|
36
|
+
"@react-stately/dnd": "3.0.0-alpha.9",
|
|
37
|
+
"@react-types/shared": "^3.14.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@adobe/spectrum-css-temp": "3.0.0-alpha.1"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"@react-spectrum/provider": "^3.0.0",
|
|
43
|
-
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
44
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
44
45
|
},
|
|
45
46
|
"publishConfig": {
|
|
46
47
|
"access": "public"
|
|
47
48
|
},
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "cd7c0ec917122c7612f653c22f8ed558f8b66ecd"
|
|
49
50
|
}
|
package/src/index.ts
CHANGED
|
@@ -12,4 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
/// <reference types="css-module-types" />
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export type {DragHooks, DragHookOptions} from './useDragHooks';
|
|
16
|
+
export type {DropHooks} from './useDropHooks';
|
|
17
|
+
export {useDragHooks} from './useDragHooks';
|
|
18
|
+
export {useDropHooks} from './useDropHooks';
|
package/src/useDragHooks.ts
CHANGED
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
import {DraggableCollectionOptions, DraggableCollectionState, useDraggableCollectionState} from '@react-stately/dnd';
|
|
2
|
-
import {
|
|
2
|
+
import {DraggableCollectionProps} from '@react-types/shared';
|
|
3
|
+
import {DraggableItemProps, DraggableItemResult, DragPreview, useDraggableItem} from '@react-aria/dnd';
|
|
3
4
|
import {useMemo} from 'react';
|
|
4
5
|
|
|
5
6
|
export interface DragHooks {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
useDraggableCollectionState(props: Omit<DraggableCollectionOptions, 'getItems'>): DraggableCollectionState,
|
|
8
|
+
useDraggableItem(props: DraggableItemProps, state: DraggableCollectionState): DraggableItemResult,
|
|
9
|
+
DragPreview: typeof DragPreview
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
export
|
|
12
|
+
export interface DragHookOptions extends Omit<DraggableCollectionProps, 'preview'> {}
|
|
11
13
|
|
|
12
14
|
export function useDragHooks(options: DragHookOptions): DragHooks {
|
|
13
15
|
return useMemo(() => ({
|
|
14
16
|
useDraggableCollectionState(props: DraggableCollectionOptions) {
|
|
15
|
-
|
|
16
|
-
collection,
|
|
17
|
-
selectionManager,
|
|
18
|
-
allowsDraggingItem,
|
|
19
|
-
getItems,
|
|
20
|
-
renderPreview
|
|
21
|
-
} = props;
|
|
22
|
-
|
|
23
|
-
return useDraggableCollectionState({
|
|
24
|
-
collection,
|
|
25
|
-
selectionManager,
|
|
26
|
-
allowsDraggingItem,
|
|
27
|
-
getItems,
|
|
28
|
-
renderPreview,
|
|
29
|
-
...options
|
|
30
|
-
});
|
|
17
|
+
return useDraggableCollectionState({...props, ...options});
|
|
31
18
|
},
|
|
32
|
-
useDraggableItem
|
|
19
|
+
useDraggableItem,
|
|
20
|
+
DragPreview
|
|
33
21
|
}), [options]);
|
|
34
22
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DropIndicatorAria,
|
|
3
|
+
DropIndicatorProps,
|
|
4
|
+
DroppableCollectionOptions,
|
|
5
|
+
DroppableCollectionResult,
|
|
6
|
+
DroppableItemOptions,
|
|
7
|
+
DroppableItemResult,
|
|
8
|
+
useDropIndicator,
|
|
9
|
+
useDroppableCollection,
|
|
10
|
+
useDroppableItem
|
|
11
|
+
} from '@react-aria/dnd';
|
|
12
|
+
import {DroppableCollectionProps} from '@react-types/shared';
|
|
13
|
+
import {DroppableCollectionState, DroppableCollectionStateOptions, useDroppableCollectionState} from '@react-stately/dnd';
|
|
14
|
+
import {RefObject, useMemo} from 'react';
|
|
15
|
+
|
|
16
|
+
export interface DropHooks {
|
|
17
|
+
useDroppableCollectionState(props: DroppableCollectionStateOptions): DroppableCollectionState,
|
|
18
|
+
useDroppableCollection(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DroppableCollectionResult,
|
|
19
|
+
useDroppableItem(options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DroppableItemResult,
|
|
20
|
+
useDropIndicator(props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DropIndicatorAria
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function useDropHooks(options: DroppableCollectionProps): DropHooks {
|
|
24
|
+
return useMemo(() => ({
|
|
25
|
+
useDroppableCollectionState(props) {
|
|
26
|
+
return useDroppableCollectionState({...props, ...options});
|
|
27
|
+
},
|
|
28
|
+
useDroppableItem,
|
|
29
|
+
useDroppableCollection(props, state, ref) {
|
|
30
|
+
return useDroppableCollection({...props, ...options}, state, ref);
|
|
31
|
+
},
|
|
32
|
+
useDropIndicator
|
|
33
|
+
}), [options]);
|
|
34
|
+
}
|