@react-spectrum/list 3.0.1-nightly.3491 → 3.0.1-nightly.3506
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +19 -19
- package/dist/main.js.map +1 -1
- package/dist/module.js +19 -19
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +3 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +27 -27
- package/src/InsertionIndicator.tsx +2 -2
- package/src/ListView.tsx +13 -14
- package/src/ListViewItem.tsx +4 -4
- package/src/RootDropIndicator.tsx +4 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/list",
|
|
3
|
-
"version": "3.0.1-nightly.
|
|
3
|
+
"version": "3.0.1-nightly.3506+5c9db40f1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -32,34 +32,34 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.6.2",
|
|
35
|
-
"@react-aria/button": "3.0.0-nightly.
|
|
36
|
-
"@react-aria/focus": "3.0.0-nightly.
|
|
37
|
-
"@react-aria/gridlist": "3.0.1-nightly.
|
|
38
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
39
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
40
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
41
|
-
"@react-aria/virtualizer": "3.5.1-nightly.
|
|
42
|
-
"@react-aria/visually-hidden": "3.0.0-nightly.
|
|
43
|
-
"@react-spectrum/checkbox": "3.0.0-nightly.
|
|
44
|
-
"@react-spectrum/layout": "3.4.2-nightly.
|
|
45
|
-
"@react-spectrum/progress": "3.0.0-nightly.
|
|
46
|
-
"@react-spectrum/text": "3.3.2-nightly.
|
|
47
|
-
"@react-spectrum/utils": "3.0.0-nightly.
|
|
48
|
-
"@react-stately/collections": "3.0.0-nightly.
|
|
49
|
-
"@react-stately/layout": "3.7.2-nightly.
|
|
50
|
-
"@react-stately/list": "3.5.4-nightly.
|
|
51
|
-
"@react-stately/virtualizer": "3.3.1-nightly.
|
|
52
|
-
"@react-types/grid": "3.1.4-nightly.
|
|
53
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
54
|
-
"@spectrum-icons/ui": "3.0.0-nightly.
|
|
35
|
+
"@react-aria/button": "3.0.0-nightly.1806+5c9db40f1",
|
|
36
|
+
"@react-aria/focus": "3.0.0-nightly.1806+5c9db40f1",
|
|
37
|
+
"@react-aria/gridlist": "3.0.1-nightly.3506+5c9db40f1",
|
|
38
|
+
"@react-aria/i18n": "3.0.0-nightly.1806+5c9db40f1",
|
|
39
|
+
"@react-aria/interactions": "3.0.0-nightly.1806+5c9db40f1",
|
|
40
|
+
"@react-aria/utils": "3.0.0-nightly.1806+5c9db40f1",
|
|
41
|
+
"@react-aria/virtualizer": "3.5.1-nightly.3506+5c9db40f1",
|
|
42
|
+
"@react-aria/visually-hidden": "3.0.0-nightly.1806+5c9db40f1",
|
|
43
|
+
"@react-spectrum/checkbox": "3.0.0-nightly.1806+5c9db40f1",
|
|
44
|
+
"@react-spectrum/layout": "3.4.2-nightly.3506+5c9db40f1",
|
|
45
|
+
"@react-spectrum/progress": "3.0.0-nightly.1806+5c9db40f1",
|
|
46
|
+
"@react-spectrum/text": "3.3.2-nightly.3506+5c9db40f1",
|
|
47
|
+
"@react-spectrum/utils": "3.0.0-nightly.1806+5c9db40f1",
|
|
48
|
+
"@react-stately/collections": "3.0.0-nightly.1806+5c9db40f1",
|
|
49
|
+
"@react-stately/layout": "3.7.2-nightly.3506+5c9db40f1",
|
|
50
|
+
"@react-stately/list": "3.5.4-nightly.3506+5c9db40f1",
|
|
51
|
+
"@react-stately/virtualizer": "3.3.1-nightly.3506+5c9db40f1",
|
|
52
|
+
"@react-types/grid": "3.1.4-nightly.3506+5c9db40f1",
|
|
53
|
+
"@react-types/shared": "3.0.0-nightly.1806+5c9db40f1",
|
|
54
|
+
"@spectrum-icons/ui": "3.0.0-nightly.1806+5c9db40f1",
|
|
55
55
|
"react-transition-group": "^2.2.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@adobe/spectrum-css-temp": "3.0.0-nightly.
|
|
59
|
-
"@react-aria/dnd": "3.0.0-nightly.
|
|
60
|
-
"@react-spectrum/button": "3.0.0-nightly.
|
|
61
|
-
"@react-spectrum/dnd": "3.0.0-nightly.
|
|
62
|
-
"@react-stately/dnd": "3.0.0-nightly.
|
|
58
|
+
"@adobe/spectrum-css-temp": "3.0.0-nightly.1806+5c9db40f1",
|
|
59
|
+
"@react-aria/dnd": "3.0.0-nightly.3506+5c9db40f1",
|
|
60
|
+
"@react-spectrum/button": "3.0.0-nightly.1806+5c9db40f1",
|
|
61
|
+
"@react-spectrum/dnd": "3.0.0-nightly.3506+5c9db40f1",
|
|
62
|
+
"@react-stately/dnd": "3.0.0-nightly.3506+5c9db40f1"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@react-spectrum/provider": "^3.2.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "5c9db40f10b9e68d4eab0268b9775baf2a840987"
|
|
73
73
|
}
|
|
@@ -11,11 +11,11 @@ interface InsertionIndicatorProps {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export default function InsertionIndicator(props: InsertionIndicatorProps) {
|
|
14
|
-
let {dropState,
|
|
14
|
+
let {dropState, dragAndDropHooks} = useContext(ListViewContext);
|
|
15
15
|
const {target, isPresentationOnly} = props;
|
|
16
16
|
|
|
17
17
|
let ref = useRef();
|
|
18
|
-
let {dropIndicatorProps} =
|
|
18
|
+
let {dropIndicatorProps} = dragAndDropHooks.useDropIndicator(props, dropState, ref);
|
|
19
19
|
let {visuallyHiddenProps} = useVisuallyHidden();
|
|
20
20
|
|
|
21
21
|
let isDropTarget = dropState.isDropTarget(target);
|
package/src/ListView.tsx
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import {AriaGridListProps, useGridList} from '@react-aria/gridlist';
|
|
14
14
|
import {AsyncLoadable, DOMRef, LoadingState, SpectrumSelectionProps, StyleProps} from '@react-types/shared';
|
|
15
15
|
import {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';
|
|
16
|
-
import type {
|
|
16
|
+
import type {DragAndDropHooks} from '@react-spectrum/dnd';
|
|
17
17
|
import type {DraggableCollectionState, DroppableCollectionState} from '@react-stately/dnd';
|
|
18
18
|
import type {DroppableCollectionResult} from '@react-aria/dnd';
|
|
19
19
|
import {filterDOMProps, mergeProps, useLayoutEffect} from '@react-aria/utils';
|
|
@@ -56,17 +56,16 @@ export interface SpectrumListViewProps<T> extends AriaGridListProps<T>, StylePro
|
|
|
56
56
|
*/
|
|
57
57
|
onAction?: (key: Key) => void,
|
|
58
58
|
/**
|
|
59
|
-
* The drag and drop hooks returned by `
|
|
60
|
-
* @private
|
|
59
|
+
* The drag and drop hooks returned by `useDragAndDrop` used to enable drag and drop behavior for the ListView.
|
|
61
60
|
*/
|
|
62
|
-
|
|
61
|
+
dragAndDropHooks?: DragAndDropHooks['dragAndDropHooks']
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
interface ListViewContextValue<T> {
|
|
66
65
|
state: ListState<T>,
|
|
67
66
|
dragState: DraggableCollectionState,
|
|
68
67
|
dropState: DroppableCollectionState,
|
|
69
|
-
|
|
68
|
+
dragAndDropHooks: DragAndDropHooks['dragAndDropHooks'],
|
|
70
69
|
onAction:(key: Key) => void,
|
|
71
70
|
isListDraggable: boolean,
|
|
72
71
|
isListDroppable: boolean,
|
|
@@ -118,11 +117,11 @@ function ListView<T extends object>(props: SpectrumListViewProps<T>, ref: DOMRef
|
|
|
118
117
|
isQuiet,
|
|
119
118
|
overflowMode = 'truncate',
|
|
120
119
|
onAction,
|
|
121
|
-
|
|
120
|
+
dragAndDropHooks,
|
|
122
121
|
...otherProps
|
|
123
122
|
} = props;
|
|
124
|
-
let isListDraggable = !!
|
|
125
|
-
let isListDroppable = !!
|
|
123
|
+
let isListDraggable = !!dragAndDropHooks?.useDraggableCollectionState;
|
|
124
|
+
let isListDroppable = !!dragAndDropHooks?.useDroppableCollectionState;
|
|
126
125
|
let dragHooksProvided = useRef(isListDraggable);
|
|
127
126
|
let dropHooksProvided = useRef(isListDroppable);
|
|
128
127
|
if (dragHooksProvided.current !== isListDraggable) {
|
|
@@ -144,12 +143,12 @@ function ListView<T extends object>(props: SpectrumListViewProps<T>, ref: DOMRef
|
|
|
144
143
|
let dragState: DraggableCollectionState;
|
|
145
144
|
let preview = useRef(null);
|
|
146
145
|
if (isListDraggable) {
|
|
147
|
-
dragState =
|
|
146
|
+
dragState = dragAndDropHooks.useDraggableCollectionState({
|
|
148
147
|
collection,
|
|
149
148
|
selectionManager,
|
|
150
149
|
preview
|
|
151
150
|
});
|
|
152
|
-
|
|
151
|
+
dragAndDropHooks.useDraggableCollection({}, dragState, domRef);
|
|
153
152
|
}
|
|
154
153
|
let layout = useListLayout(
|
|
155
154
|
state,
|
|
@@ -160,16 +159,16 @@ function ListView<T extends object>(props: SpectrumListViewProps<T>, ref: DOMRef
|
|
|
160
159
|
layout.allowDisabledKeyFocus = state.selectionManager.disabledBehavior === 'selection' || !!dragState?.draggingKeys.size;
|
|
161
160
|
|
|
162
161
|
|
|
163
|
-
let DragPreview =
|
|
162
|
+
let DragPreview = dragAndDropHooks?.DragPreview;
|
|
164
163
|
let dropState: DroppableCollectionState;
|
|
165
164
|
let droppableCollection: DroppableCollectionResult;
|
|
166
165
|
let isRootDropTarget: boolean;
|
|
167
166
|
if (isListDroppable) {
|
|
168
|
-
dropState =
|
|
167
|
+
dropState = dragAndDropHooks.useDroppableCollectionState({
|
|
169
168
|
collection,
|
|
170
169
|
selectionManager
|
|
171
170
|
});
|
|
172
|
-
droppableCollection =
|
|
171
|
+
droppableCollection = dragAndDropHooks.useDroppableCollection({
|
|
173
172
|
keyboardDelegate: layout,
|
|
174
173
|
dropTargetDelegate: layout
|
|
175
174
|
}, dropState, domRef);
|
|
@@ -206,7 +205,7 @@ function ListView<T extends object>(props: SpectrumListViewProps<T>, ref: DOMRef
|
|
|
206
205
|
let hasAnyChildren = useMemo(() => [...collection].some(item => item.hasChildNodes), [collection]);
|
|
207
206
|
|
|
208
207
|
return (
|
|
209
|
-
<ListViewContext.Provider value={{state, dragState, dropState,
|
|
208
|
+
<ListViewContext.Provider value={{state, dragState, dropState, dragAndDropHooks, onAction, isListDraggable, isListDroppable, layout, loadingState}}>
|
|
210
209
|
<FocusScope>
|
|
211
210
|
<FocusRing focusRingClass={classNames(listStyles, 'focus-ring')}>
|
|
212
211
|
<Virtualizer
|
package/src/ListViewItem.tsx
CHANGED
|
@@ -49,7 +49,7 @@ export function ListViewItem<T>(props: ListViewItemProps<T>) {
|
|
|
49
49
|
isListDraggable,
|
|
50
50
|
isListDroppable,
|
|
51
51
|
layout,
|
|
52
|
-
|
|
52
|
+
dragAndDropHooks,
|
|
53
53
|
loadingState
|
|
54
54
|
} = useContext(ListViewContext);
|
|
55
55
|
let {direction} = useLocale();
|
|
@@ -82,7 +82,7 @@ export function ListViewItem<T>(props: ListViewItemProps<T>) {
|
|
|
82
82
|
let draggableItem: DraggableItemResult;
|
|
83
83
|
if (isListDraggable) {
|
|
84
84
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
85
|
-
draggableItem =
|
|
85
|
+
draggableItem = dragAndDropHooks.useDraggableItem({key: item.key, hasDragButton: true}, dragState);
|
|
86
86
|
if (isDisabled) {
|
|
87
87
|
draggableItem = null;
|
|
88
88
|
}
|
|
@@ -95,7 +95,7 @@ export function ListViewItem<T>(props: ListViewItemProps<T>) {
|
|
|
95
95
|
let target = {type: 'item', key: item.key, dropPosition: 'on'} as DropTarget;
|
|
96
96
|
isDropTarget = dropState.isDropTarget(target);
|
|
97
97
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
98
|
-
dropIndicator =
|
|
98
|
+
dropIndicator = dragAndDropHooks.useDropIndicator({target}, dropState, dropIndicatorRef);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
let dragButtonRef = React.useRef();
|
|
@@ -147,7 +147,7 @@ export function ListViewItem<T>(props: ListViewItemProps<T>) {
|
|
|
147
147
|
focusProps,
|
|
148
148
|
// Remove tab index from list row if performing a screenreader drag. This prevents TalkBack from focusing the row,
|
|
149
149
|
// allowing for single swipe navigation between row drop indicator
|
|
150
|
-
|
|
150
|
+
dragAndDropHooks?.isVirtualDragging() && {tabIndex: null}
|
|
151
151
|
);
|
|
152
152
|
|
|
153
153
|
let isFirstRow = item.prevKey == null;
|
|
@@ -3,9 +3,9 @@ import React, {useContext, useRef} from 'react';
|
|
|
3
3
|
import {useVisuallyHidden} from '@react-aria/visually-hidden';
|
|
4
4
|
|
|
5
5
|
export default function RootDropIndicator() {
|
|
6
|
-
let {dropState,
|
|
6
|
+
let {dropState, dragAndDropHooks} = useContext(ListViewContext);
|
|
7
7
|
let ref = useRef();
|
|
8
|
-
let {dropIndicatorProps} =
|
|
8
|
+
let {dropIndicatorProps} = dragAndDropHooks.useDropIndicator({
|
|
9
9
|
target: {type: 'root'}
|
|
10
10
|
}, dropState, ref);
|
|
11
11
|
let isDropTarget = dropState.isDropTarget({type: 'root'});
|
|
@@ -19,9 +19,8 @@ export default function RootDropIndicator() {
|
|
|
19
19
|
<div role="row" aria-hidden={dropIndicatorProps['aria-hidden']}>
|
|
20
20
|
<div
|
|
21
21
|
role="gridcell"
|
|
22
|
-
aria-selected="false"
|
|
23
|
-
{...visuallyHiddenProps}
|
|
24
|
-
<div role="button" {...dropIndicatorProps} ref={ref} />
|
|
22
|
+
aria-selected="false">
|
|
23
|
+
<div role="button" {...visuallyHiddenProps} {...dropIndicatorProps} ref={ref} />
|
|
25
24
|
</div>
|
|
26
25
|
</div>
|
|
27
26
|
);
|