zag-ripple 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zag-ripple",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "RippleJS Adapter for Zag JS",
5
5
  "keywords": [
6
6
  "js",
@@ -254,11 +254,27 @@ export function useMachine(
254
254
 
255
255
  let status = MachineStatus.NotStarted
256
256
 
257
- // Initialize machine immediately - RippleJS components run imperatively
258
- status = MachineStatus.Started
259
- debug("initializing...")
260
- const initialState = machine.initialState({ prop })
261
- state.set(initialState)
257
+ effect(() => {
258
+ queueMicrotask(() => {
259
+ const started = status === MachineStatus.Started
260
+ status = MachineStatus.Started
261
+ debug(started ? "rehydrating..." : "initializing...")
262
+ state.invoke(state.initial, INIT_STATE)
263
+ })
264
+
265
+ return () => {
266
+ debug("unmounting...")
267
+ status = MachineStatus.Stopped
268
+ effects.forEach((fn) => fn?.())
269
+ effects = new Map()
270
+ transitionRef.current = null
271
+ queueMicrotask(() => {
272
+ action(machine.exit)
273
+ })
274
+ }
275
+ })
276
+
277
+
262
278
 
263
279
  machine.watch?.(getParams())
264
280
 
@@ -34,16 +34,9 @@ export function toStyleString(style: Record<string, number | string>) {
34
34
  return string
35
35
  }
36
36
 
37
- const preserveKeys = new Set<string>(
38
- "viewBox,className,preserveAspectRatio,fillRule,clipPath,clipRule,strokeWidth,strokeLinecap,strokeLinejoin,strokeDasharray,strokeDashoffset,strokeMiterlimit".split(
39
- ",",
40
- ),
41
- )
42
-
43
37
  function toRippleProp(key: string) {
44
38
  if (key in propMap) return propMap[key]
45
- if (preserveKeys.has(key)) return key
46
- return key.toLowerCase()
39
+ return key
47
40
  }
48
41
 
49
42
  function toRipplePropValue(key: string, value: Dict[string]) {