zag icon indicating copy to clipboard operation
zag copied to clipboard

[vue] Support for Vue 2

Open younho9 opened this issue 3 years ago • 4 comments

🚀 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 from vue + @vue/composition-api with plugin auto installing.
    • 2.7: exports from vue (Composition API is built-in in Vue 2.7).

younho9 avatar Jul 11 '22 06:07 younho9

@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.

anubra266 avatar Jul 12 '22 01:07 anubra266

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

younho9 avatar Jul 13 '22 04:07 younho9

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

anubra266 avatar Jul 13 '22 14:07 anubra266

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?

wobsoriano avatar Jul 28 '22 04:07 wobsoriano

After much thought, supporting Vue 2 isn't a priority for us now.

Kindly upgrade to Vue 3 to use Zag.

Thanks

segunadebayo avatar Aug 17 '22 13:08 segunadebayo