feat(useDropZone): add dataTypes
option
#3471
Merged
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.
Before submitting the PR, please make sure you do the following
fixes #123
).Description
This PR introduces the dataTypes option to useDropZone, allowing for more precise control over accepted data types.
Additional context
Please review the useDropZone/demo .vue for the new features.
🤖 Generated by Copilot at 5b00749
Added a new feature and improved the functionality of
useDropZone
core function. The feature allows filtering the data types accepted by the drop zone using a newdataTypes
option. The functionality was improved by refactoring some code and adding a second drop zone example to the demo file. The documentation was updated accordingly.🤖 Generated by Copilot at 5b00749
dataTypes
option to filter the types of data to be received by the drop zone (link,link,link,link,link,link,link)useEventListener
from@vueuse/core
and create a refimageFilesData
to store the image files dropped into the second drop zone indemo.vue
(link)onImageDrop
to handle the image files dropped into the second drop zone and assign them toimageFilesData
indemo.vue
(link)imageDropZoneRef
to reference the second drop zone element and a refpngRef
to reference the png image element indemo.vue
(link)useDropZone
with thedropZoneRef
and theonDrop
function as before and calluseEventListener
with thepngRef
and adragstart
event handler to set the data transfer type toimage/png
indemo.vue
(link)useDropZone
with theimageDropZoneRef
and an options object that specifies thedataTypes
to beimage/png
and theonDrop
function to beonImageDrop
indemo.vue
(link)div
element with theimageDropZoneRef
and display theisOverImageDropZone
value and the image files data indemo.vue
(link)Usage
section of the documentation to show how to use thedataTypes
option to filter the types of data to be received by the drop zone inindex.md
(link)dataTypes
to theUseDropZoneReturn
interface to accept aMaybeRef
of an array of strings that represent the types of data to be received by the drop zone inindex.ts
(link)isDataTypeIncluded
to store a boolean value that indicates whether the data transfer types match thedataTypes
option and update it in thedragenter
event handler by checking if thedataTypes
option is provided and if it includes any of the data transfer types inindex.ts
(link)isDataTypeIncluded
value in thedragover
anddragleave
event handlers and return early if it is false without preventing the default behavior or calling theonOver
oronLeave
functions inindex.ts
(link)useEventListener
from@vueuse/core
instead of../useEventListener
to avoid circular dependencies and importMaybeRef
andunref
fromvue-demi
with eslint disabled for the restricted imports inindex.ts
(link)