Skip to content
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

feat(useDropZone): add dataTypes option #3471

Merged
merged 4 commits into from Nov 9, 2023
Merged

feat(useDropZone): add dataTypes option #3471

merged 4 commits into from Nov 9, 2023

Conversation

rtugeek
Copy link
Contributor

@rtugeek rtugeek commented Oct 12, 2023

Before submitting the PR, please make sure you do the following

  • [✔ ] Read the Contributing Guidelines.
  • [✔] Read the Pull Request Guidelines.
  • [✔ ] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • [✔ ] Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • [✔] Ideally, include relevant tests that fail without this PR but pass with it.
⚠️ Slowing down new functions

Warning: Slowing down new functions

As the VueUse audience continues to grow, we have been inundated with an overwhelming number of feature requests and pull requests. As a result, maintaining the project has become increasingly challenging and has stretched our capacity to its limits. As such, in the near future, we may need to slow down our acceptance of new features and prioritize the stability and quality of existing functions. Please note that new features for VueUse may not be accepted at this time. If you have any new ideas, we suggest that you first incorporate them into your own codebase, iterate on them to suit your needs, and assess their generalizability. If you strongly believe that your ideas are beneficial to the community, you may submit a pull request along with your use cases, and we would be happy to review and discuss them. Thank you for your understanding.


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 new dataTypes 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

  • Add a second drop zone for image files and demonstrate how to use the dataTypes option to filter the types of data to be received by the drop zone (link,link,link,link,link,link,link)
  • Import useEventListener from @vueuse/core and create a ref imageFilesData to store the image files dropped into the second drop zone in demo.vue (link)
  • Define a function onImageDrop to handle the image files dropped into the second drop zone and assign them to imageFilesData in demo.vue (link)
  • Create a ref imageDropZoneRef to reference the second drop zone element and a ref pngRef to reference the png image element in demo.vue (link)
  • Call useDropZone with the dropZoneRef and the onDrop function as before and call useEventListener with the pngRef and a dragstart event handler to set the data transfer type to image/png in demo.vue (link)
  • Call useDropZone with the imageDropZoneRef and an options object that specifies the dataTypes to be image/png and the onDrop function to be onImageDrop in demo.vue (link)
  • Add a new section of the template to demonstrate the second drop zone for image files with two image elements and a div element with the imageDropZoneRef and display the isOverImageDropZone value and the image files data in demo.vue (link)
  • Add a comment to the Usage section of the documentation to show how to use the dataTypes option to filter the types of data to be received by the drop zone in index.md (link)
  • Add a new optional property dataTypes to the UseDropZoneReturn interface to accept a MaybeRef of an array of strings that represent the types of data to be received by the drop zone in index.ts (link)
  • Declare a variable isDataTypeIncluded to store a boolean value that indicates whether the data transfer types match the dataTypes option and update it in the dragenter event handler by checking if the dataTypes option is provided and if it includes any of the data transfer types in index.ts (link)
  • Check the isDataTypeIncluded value in the dragover and dragleave event handlers and return early if it is false without preventing the default behavior or calling the onOver or onLeave functions in index.ts (link)
  • Import useEventListener from @vueuse/core instead of ../useEventListener to avoid circular dependencies and import MaybeRef and unref from vue-demi with eslint disabled for the restricted imports in index.ts (link)

@antfu antfu enabled auto-merge November 9, 2023 16:59
@antfu antfu added this pull request to the merge queue Nov 9, 2023
Merged via the queue into vueuse:main with commit 3f3f153 Nov 9, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants