Replies: 10 comments 15 replies
-
@elilabes I looked into this. And |
Beta Was this translation helpful? Give feedback.
-
I'd really like to use Zag.js with Qwik as well. @anubra266, does @elilabes's idea make sense? Can Zag props just return |
Beta Was this translation helpful? Give feedback.
-
@anubra266 bit late to this but doesn't this help do it? |
Beta Was this translation helpful? Give feedback.
-
seems there's a proposal to fix this in qwik that is now being actively implemented: QwikDev/qwik#4496 (comment) curious if this would be sufficient for qwik support in Zag? |
Beta Was this translation helpful? Give feedback.
-
Started looking into this more, but seems it's blocked by QwikDev/qwik#5540 |
Beta Was this translation helpful? Give feedback.
-
@anubra266 there an upcoming fix for this issue in qwik's upcoming version |
Beta Was this translation helpful? Give feedback.
-
I've been looking into this a bit more now that there's an experimental implementation of Qwik's synchronous QRLs (ie event handlers that support preventDefault) sync QRL restrictions mean they can't be used directly with ZagAt a glance, the API seems like it should work with Zag: Qwik already supported spreading props and event handlers; the new preventDefault solution just requires wrapping the handlers with Unfortunately, though, there are very tight restrictions around what can be done in a synchronous handler that make them not directly usable with Zag. Specifically, the functions cannot be imported (ie they must be directly written in-line), and they can't access any component state. I think the no-import restriction makes them even more limited than the workaround of putting code in useVisibleTask(). This workaround was mentioned by @LazyClicks above, but not sure if anyone really looked into exactly how this could work with Zag? It's not immediately obvious how to make this work with the Zag prop-spreading API, but going to continue investigating Zag state machine needs to be serializedThe other (bigger?) issue, is Qwik's need to pause/serialize/resume component state. I'm currently poking around how to best make Zag's state machine play nice with Qwik's (de)serialization and resumability. Qwik does not currently support serializing custom types. In the case of the Zag state machine, though, there dosn't seem to be a lot of internal state in the object:
From a high level, it seems plausible that this state could perhaps be exposed to Qwik's existing scope capture/serialization infrastructure and resumed within the component. I'm still learning about how Zag's state machine works internally to see if that is really possible. Of course, even getting Qwik to work with the state machine still has the issue that sync events can't access Qwik-ified state anyway. One possible path forward may be to somehow just persist state machine state to the DOM directly (then the sync handler could access it, and wouldn't need to get Qwik's (de)serialization involved), but haven't fully worked through how that could function exactly. All in all, still some issues to overcome before Qwik can be natively supported. Qwik's support for embedding React componentsThe other entirely different option is using Qwik's React integration to just wrap the React version of Zag/Ark/Park components as islands within a Qwik app. It seems this should work, but is likely not ideal -- the recommendation is to use "wide islands", rather than wrapping many small, individual "leaf node" UI components (because each wrapped React component becomes it's own entire React app in the page, with no shared styling etc between) |
Beta Was this translation helpful? Give feedback.
-
See my comment QwikDev/qwik#4496 (comment) as how it could be achieved. |
Beta Was this translation helpful? Give feedback.
-
Some update on this one ? |
Beta Was this translation helpful? Give feedback.
-
@wmertens @plandem This is what I have for now: #1868 Full qwik context on Improving the final API is what I'm trying to achieve now. E.g. would be nice to not need to have |
Beta Was this translation helpful? Give feedback.
-
With Qwik JS fast gaining support it'd be great to use Zag with it.
I believe that it meets both requirements for prop spreading + strongly typed.
Beta Was this translation helpful? Give feedback.
All reactions