[vue] Support for Vue 2
🚀 Feature request
Please describe your request in one or two sentences.
Despite Vue 3 now being the default version, there are still many users who have to stay on Vue 2. (Read more)
Currently, Zag only supports Vue 3. Since Zag has a goal of providing framework-agnostic logic, I wish be able to reuse the same component logic in Vue 2 using Zag.
✅ Proposed solution or API
Please provide code snippets, gists, or links to the ideal design or API
- Using vue-demi to write Universal Vue Libraries for Vue 2 & 3
- Writing two separate wrapper for
vue2(adding@zag-js/vue2)-
<=2.6: exports fromvue+@vue/composition-apiwith plugin auto installing. -
2.7: exports fromvue(Composition API is built-in in Vue 2.7).
-
@younho9 I'm not much of a vue developer, but what would you say are the core differences between vue 2 and vue3, I'm not sure but depending on your answer, we might probably only need to create a normalizeProps method to support vue2.
vue<=2.6 does not have built-in composition api (e.g ref, onMounted, onUnmounted). To support vue<=2.6, these api must be imported from the @vue/composition-api plugin.
vue-demi is a library that handles these branches. Although vue-demi is experimental, it is a way to create a library that supports both vue3 and vue2. (See more details in this blog post
vue>=2.7 has built-in composition-api, but I faced a bug. Here is the reproduction
So @younho9 The process involved will be to basically write these 4 files in vue 2.: https://github.com/chakra-ui/zag/blob/main/packages/frameworks/vue/src/index.ts#L3-L6
BTW vue 2.7 will be the final minor release of Vue 2. EOL is EOY 2023.
vue-demi is a little bit buggy with workspaces iirc - check the issues here https://github.com/vueuse/vue-demi/issues
Why the request for Vue 2 support btw?
After much thought, supporting Vue 2 isn't a priority for us now.
Kindly upgrade to Vue 3 to use Zag.
Thanks