-
-
Notifications
You must be signed in to change notification settings - Fork 834
feat: @dnd-kit/vue
#1668
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
base: experimental
Are you sure you want to change the base?
feat: @dnd-kit/vue
#1668
Conversation
|
08f82a6 to
5b9c9a5
Compare
@dnd-kit/abstract
@dnd-kit/collision
@dnd-kit/dom
@dnd-kit/geometry
@dnd-kit/react
@dnd-kit/helpers
@dnd-kit/state
@dnd-kit/vue
commit: |
clauderic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heroic effort 🙌 Left a few initial questions as I was reading through the code, I haven't used vue much so I definitely learned a lot!
| }); | ||
| const trackedSortable = useDeepSignal(sortable); | ||
|
|
||
| watchEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should / can these use batch?
| const transition = computed(() => ({ | ||
| ...defaultSortableTransition, | ||
| ...toValue(input.transition), | ||
| })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we delegate this responsibility to @dnd-kit/dom? I don't remember why I did this in @dnd-kit/react in the first place and not in @dnd-kit/dom instead
| @@ -0,0 +1,78 @@ | |||
| { | |||
| "name": "@dnd-kit/vue", | |||
| "version": "0.1.0", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving a note here for us to make sure we sync this with whatever the latest versions are of other packages before merging
| } | ||
| ); | ||
|
|
||
| watchEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use batch here also?
| }; | ||
|
|
||
| function trackRendering(callback: () => void) { | ||
| if (rendering.value === Promise.resolve()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const renderer = { | ||
| get rendering() { | ||
| return rendering.value; | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be memoized at all? Not super familiar with vue best practices
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Vue, reactivity is opt-in unlike in react it's opt-out, that's why react has useMemo, useCallback, etc. So script will run only once, if we want to make it reactive, then we will have to opt-in using ref, computed, watch, watchEffect etc.
So no memoization is needed.
|
Is this moving forward? What needs to be done for this to get merged/supported? |

Vue wrapper for
dnd-kitA somewhat small wrapper mapping the dnd-kit core to the Vue reactivity system.
WIP
Currently doing a self review of all the changes, but I wanted to put this out there, for other people to start having a look.
Notes
This wrapper tries to maintain the same API as the React hooks provided in
@dnd-kit/react, notable differences being:hooksare renamed tocomposablesto fit the Vue nomenclatureuseDraggable/useDroppable/useSortablecomposables only accept anElementref, but don't return a bindablereffor the element, handle, etc. This is a lot more common in the Vue world, to the best of my knowledge, e.g. as seen in this popular composables library: https://vueuse.org/core/useElementSize/This allows for the following code, to make an element draggable
TODO
Closes #1221