-
Notifications
You must be signed in to change notification settings - Fork 1.3k
ListView: Draggable Rows #2593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
ListView: Draggable Rows #2593
Changes from all commits
Commits
Show all changes
83 commits
Select commit
Hold shift + click to select a range
80e8863
initial setup
reidbarber fc59801
updating ListView types and improving defaults for drag state
LFDanLu 27ad57f
adding ListView drag story and supporting individual row drag disabling
LFDanLu 617145d
fixing ListViewItem outdated selection maanger
LFDanLu 772ac53
fixing disabling individual rows in drag and drop
LFDanLu c08a0dc
add drag handle UI
reidbarber 138247c
cleanup formatting
reidbarber 0da64d9
fix list item padding
reidbarber bded88c
improve drag handle focus ring
reidbarber a62be4d
initial render preview styles
reidbarber 80a689a
improve render preview styles
reidbarber 8d7a067
fix render preview border radius
reidbarber 92f7a95
fix logic to show handle
reidbarber c584521
add support for custom dragIcon
reidbarber 1c117fe
fix lint
reidbarber d1044cb
only drop draggable items if multiple selected
reidbarber 9d1e854
fix drag handle styles
reidbarber 76907f4
add border radius to drag handle
reidbarber 008cfc3
add isDraggable to item type
reidbarber a45f340
skip failing draggable tests for now
reidbarber 2f630e1
Merge branch 'main' into ListView-DnD
reidbarber d63382a
prevent selection when clicking draggable row
reidbarber fef5ffe
updates from design review
LFDanLu 8ac5a97
Merge branch 'main' of github.com:adobe/react-spectrum into ListView-DnD
LFDanLu 54ba449
removing skips from useDraggableCollection tests
LFDanLu 6b69aad
adding tests for dnd listview
LFDanLu 02cc4c1
removing stray comment
LFDanLu c156684
adding test to check for drag preview
LFDanLu 4057928
improve default render preview
reidbarber 72e1d9b
Merge branch 'ListView-DnD' of github.com:adobe/react-spectrum into L…
reidbarber 586538e
fixing lint and tests
LFDanLu 7b45217
fix render preview padding
reidbarber ed652c2
Merge branch 'ListView-DnD' of github.com:adobe/react-spectrum into L…
LFDanLu 8126c22
adding aria-label to render preview checkbox
LFDanLu 5f3c759
Merge branch 'main' into ListView-DnD
reidbarber 185e272
keep incoming onAction change
reidbarber 973ca32
Merge branch 'main' into ListView-DnD
devongovett 484246a
Merge branch 'ListView-DnD' of github.com:adobe/react-spectrum into L…
reidbarber 7122c7b
tentative fix to stop row selection on drag start
LFDanLu 59ec5a5
Merge branch 'main' of github.com:adobe/react-spectrum into ListView-DnD
LFDanLu 0abadce
fixing lint and adding tests for checkbox/menu clicks
LFDanLu a3b416e
fixing usePress tests
LFDanLu c3f3995
adding allowsDifferentPressOrigin to useSelectableItem
LFDanLu 7e28276
fixing lint
LFDanLu 7e3abda
Merge branch 'main' into ListView-DnD
reidbarber 6eaf932
Merge branch 'main' into ListView-DnD
reidbarber e4a2113
add useDragHooks
reidbarber 41e1130
fix test setup
reidbarber 905b0a3
Merge branch 'main' into ListView-DnD
reidbarber 2e38865
Merge branch 'main' of github.com:adobe/react-spectrum into ListView-DnD
LFDanLu 641384c
adding code comment and small cleanup
LFDanLu cb24f67
fix warning for changes hooks provided
reidbarber f96277d
add default itemAllowsDragging
reidbarber 81efd9b
add default getItems
reidbarber a774328
remove extra checkbox hit area for drag handle
reidbarber 052515f
fix lint
reidbarber 97dc2a8
addressing some review comments
LFDanLu 6ec8e77
updating tests and hiding drag handle via display: none
LFDanLu 951fe6e
making drag handle use visually hidden styles for screen readers
LFDanLu 7d16e8a
fixing weird safari drag handle positioning
LFDanLu 822dd2a
removing fallback
LFDanLu a9a9a22
move defaults to useDraggableCollectionState
reidbarber a9ed083
Merge branch 'main' of github.com:adobe/react-spectrum into ListView-DnD
LFDanLu a69fb51
optimize drag handle svg
reidbarber 1b23709
fix the changing hooks warning logic
reidbarber c36c3af
change itemAllowsDragging to allowsDraggingItem
reidbarber cecae00
add useDraggableItem to dragHooks
reidbarber e560660
make getItems required and remove default
reidbarber bcd0183
make getItems required on DragOptions
reidbarber ff9c6e7
fix getItems type required
reidbarber 9dcd709
add @react-spectrum/dnd package with useDragHooks
reidbarber 18bce37
fix import for draghooks
reidbarber 2a91432
remove old comments
reidbarber 8da0243
remove private: true from package.json
reidbarber 706debd
fix circular dep
reidbarber 4438f2b
fix react-aria/dnd dep in listview
reidbarber e9c7596
Revert "fix react-aria/dnd dep in listview"
reidbarber 59d2b11
fix DragHooks type
reidbarber 75967d2
Merge branch 'main' into ListView-DnD
reidbarber de099f2
Merge branch 'ListView-DnD' of github.com:adobe/react-spectrum into L…
reidbarber d36779c
making aria/stately dnd packages dev deps for list
LFDanLu ec9f91f
make getItems required
reidbarber 99a6ff0
fix type of dragHooks props
reidbarber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @react-spectrum/dnd | ||
|
||
This package is part of [react-spectrum](https://github.com/adobe/react-spectrum). See the repo for more details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright 2022 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
export * from './src'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "@react-spectrum/dnd", | ||
"version": "3.0.0-alpha.1", | ||
"description": "Spectrum UI components in React", | ||
"license": "Apache-2.0", | ||
"main": "dist/main.js", | ||
"module": "dist/module.js", | ||
"types": "dist/types.d.ts", | ||
"source": "src/index.ts", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"sideEffects": [ | ||
"*.css" | ||
], | ||
"targets": { | ||
"main": { | ||
"includeNodeModules": [ | ||
"@adobe/spectrum-css-temp" | ||
] | ||
}, | ||
"module": { | ||
"includeNodeModules": [ | ||
"@adobe/spectrum-css-temp" | ||
] | ||
} | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/adobe/react-spectrum" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.6.2", | ||
"@react-aria/dnd": "3.0.0-alpha.5", | ||
"@react-aria/utils": "^3.0.0", | ||
"@react-spectrum/utils": "^3.0.0", | ||
"@react-stately/dnd": "3.0.0-alpha.4", | ||
"@react-types/shared": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@adobe/spectrum-css-temp": "3.0.0-alpha.1" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.0 || ^17.0.0-rc.1", | ||
"@react-spectrum/provider": "^3.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright 2022 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
/// <reference types="css-module-types" /> | ||
|
||
export * from './useDragHooks'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {DraggableCollectionOptions, DraggableCollectionState, useDraggableCollectionState} from '@react-stately/dnd'; | ||
import {DraggableItemProps, DraggableItemResult, useDraggableItem} from '@react-aria/dnd'; | ||
import {useMemo} from 'react'; | ||
|
||
export interface DragHooks { | ||
useDraggableCollectionState(props: Omit<DraggableCollectionOptions, 'getItems'>): DraggableCollectionState, | ||
useDraggableItem(props: DraggableItemProps, state: DraggableCollectionState): DraggableItemResult | ||
} | ||
reidbarber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export type DragHookOptions = Omit<DraggableCollectionOptions, 'collection' | 'selectionManager' | 'isDragging' | 'getKeysForDrag'> | ||
|
||
export function useDragHooks(options: DragHookOptions): DragHooks { | ||
return useMemo(() => ({ | ||
useDraggableCollectionState(props: DraggableCollectionOptions) { | ||
let { | ||
collection, | ||
selectionManager, | ||
allowsDraggingItem, | ||
getItems, | ||
renderPreview | ||
} = props; | ||
|
||
return useDraggableCollectionState({ | ||
collection, | ||
selectionManager, | ||
allowsDraggingItem, | ||
getItems, | ||
renderPreview, | ||
...options | ||
}); | ||
}, | ||
useDraggableItem | ||
}), [options]); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2021 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
export default function DragHandle() { | ||
return ( | ||
<svg width="16" height="32" viewBox="0 0 16 32"> | ||
<g transform="translate(5.5 10.5)"> | ||
<circle cx="1" cy="1" r="1" transform="translate(0 9)" fill="#6e6e6e" /> | ||
<circle cx="1" cy="1" r="1" transform="translate(0 6)" fill="#6e6e6e" /> | ||
<circle cx="1" cy="1" r="1" transform="translate(0 3)" fill="#6e6e6e" /> | ||
<circle cx="1" cy="1" r="1" fill="#6e6e6e" /> | ||
<circle cx="1" cy="1" r="1" transform="translate(3 9)" fill="#6e6e6e" /> | ||
<circle cx="1" cy="1" r="1" transform="translate(3 6)" fill="#6e6e6e" /> | ||
<circle cx="1" cy="1" r="1" transform="translate(3 3)" fill="#6e6e6e" /> | ||
<circle cx="1" cy="1" r="1" transform="translate(3)" fill="#6e6e6e" /> | ||
</g> | ||
</svg> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.