@pyreon/runtime-dom 0.11.4 → 0.11.6
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/README.md +16 -22
- package/lib/analysis/index.js.html +1 -1
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- package/package.json +12 -12
- package/src/delegate.ts +25 -25
- package/src/devtools.ts +37 -37
- package/src/hydrate.ts +30 -30
- package/src/hydration-debug.ts +2 -2
- package/src/index.ts +20 -20
- package/src/keep-alive.ts +6 -6
- package/src/mount.ts +46 -46
- package/src/nodes.ts +31 -19
- package/src/props.ts +93 -93
- package/src/template.ts +6 -6
- package/src/tests/coverage-gaps.test.ts +669 -669
- package/src/tests/coverage.test.ts +299 -299
- package/src/tests/mount.test.ts +1183 -1183
- package/src/tests/props.test.ts +219 -219
- package/src/tests/setup.ts +1 -1
- package/src/tests/show-context.test.ts +43 -43
- package/src/tests/template.test.ts +71 -71
- package/src/tests/transition.test.ts +124 -124
- package/src/transition-group.ts +22 -22
- package/src/transition.ts +18 -18
package/src/transition-group.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Props, VNode, VNodeChild } from
|
|
2
|
-
import { createRef, h, onMount, onUnmount } from
|
|
3
|
-
import { effect, runUntracked, signal } from
|
|
4
|
-
import { mountChild } from
|
|
1
|
+
import type { Props, VNode, VNodeChild } from '@pyreon/core'
|
|
2
|
+
import { createRef, h, onMount, onUnmount } from '@pyreon/core'
|
|
3
|
+
import { effect, runUntracked, signal } from '@pyreon/reactivity'
|
|
4
|
+
import { mountChild } from './mount'
|
|
5
5
|
|
|
6
6
|
export interface TransitionGroupProps<T = unknown> {
|
|
7
7
|
/** Wrapper element tag. Default: "div" */
|
|
@@ -69,8 +69,8 @@ type ItemEntry = {
|
|
|
69
69
|
* // .list-move { transition: transform 300ms ease; }
|
|
70
70
|
*/
|
|
71
71
|
export function TransitionGroup<T = unknown>(props: TransitionGroupProps<T>): VNodeChild {
|
|
72
|
-
const tag = props.tag ??
|
|
73
|
-
const n = props.name ??
|
|
72
|
+
const tag = props.tag ?? 'div'
|
|
73
|
+
const n = props.name ?? 'pyreon'
|
|
74
74
|
const cls = {
|
|
75
75
|
ef: props.enterFrom ?? `${n}-enter-from`,
|
|
76
76
|
ea: props.enterActive ?? `${n}-enter-active`,
|
|
@@ -95,13 +95,13 @@ export function TransitionGroup<T = unknown>(props: TransitionGroupProps<T>): VN
|
|
|
95
95
|
el.classList.remove(cls.ef)
|
|
96
96
|
el.classList.add(cls.et)
|
|
97
97
|
const done = () => {
|
|
98
|
-
el.removeEventListener(
|
|
99
|
-
el.removeEventListener(
|
|
98
|
+
el.removeEventListener('transitionend', done)
|
|
99
|
+
el.removeEventListener('animationend', done)
|
|
100
100
|
el.classList.remove(cls.ea, cls.et)
|
|
101
101
|
props.onAfterEnter?.(el)
|
|
102
102
|
}
|
|
103
|
-
el.addEventListener(
|
|
104
|
-
el.addEventListener(
|
|
103
|
+
el.addEventListener('transitionend', done, { once: true })
|
|
104
|
+
el.addEventListener('animationend', done, { once: true })
|
|
105
105
|
})
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -113,14 +113,14 @@ export function TransitionGroup<T = unknown>(props: TransitionGroupProps<T>): VN
|
|
|
113
113
|
el.classList.remove(cls.lf)
|
|
114
114
|
el.classList.add(cls.lt)
|
|
115
115
|
const done = () => {
|
|
116
|
-
el.removeEventListener(
|
|
117
|
-
el.removeEventListener(
|
|
116
|
+
el.removeEventListener('transitionend', done)
|
|
117
|
+
el.removeEventListener('animationend', done)
|
|
118
118
|
el.classList.remove(cls.la, cls.lt)
|
|
119
119
|
props.onAfterLeave?.(el)
|
|
120
120
|
onDone()
|
|
121
121
|
}
|
|
122
|
-
el.addEventListener(
|
|
123
|
-
el.addEventListener(
|
|
122
|
+
el.addEventListener('transitionend', done, { once: true })
|
|
123
|
+
el.addEventListener('animationend', done, { once: true })
|
|
124
124
|
})
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -152,7 +152,7 @@ export function TransitionGroup<T = unknown>(props: TransitionGroupProps<T>): VN
|
|
|
152
152
|
const itemRef = createRef<HTMLElement>()
|
|
153
153
|
const rawVNode = runUntracked(() => props.render(item, i))
|
|
154
154
|
const vnode: VNode =
|
|
155
|
-
typeof rawVNode.type ===
|
|
155
|
+
typeof rawVNode.type === 'string'
|
|
156
156
|
? { ...rawVNode, props: { ...rawVNode.props, ref: itemRef } as Props }
|
|
157
157
|
: rawVNode
|
|
158
158
|
const cleanup = mountChild(vnode, container, null)
|
|
@@ -166,15 +166,15 @@ export function TransitionGroup<T = unknown>(props: TransitionGroupProps<T>): VN
|
|
|
166
166
|
const startMoveAnimation = (el: HTMLElement) => {
|
|
167
167
|
requestAnimationFrame(() => {
|
|
168
168
|
el.classList.add(cls.mv)
|
|
169
|
-
el.style.transform =
|
|
170
|
-
el.style.transition =
|
|
169
|
+
el.style.transform = ''
|
|
170
|
+
el.style.transition = ''
|
|
171
171
|
const done = () => {
|
|
172
|
-
el.removeEventListener(
|
|
173
|
-
el.removeEventListener(
|
|
172
|
+
el.removeEventListener('transitionend', done)
|
|
173
|
+
el.removeEventListener('animationend', done)
|
|
174
174
|
el.classList.remove(cls.mv)
|
|
175
175
|
}
|
|
176
|
-
el.addEventListener(
|
|
177
|
-
el.addEventListener(
|
|
176
|
+
el.addEventListener('transitionend', done, { once: true })
|
|
177
|
+
el.addEventListener('animationend', done, { once: true })
|
|
178
178
|
})
|
|
179
179
|
}
|
|
180
180
|
|
|
@@ -186,7 +186,7 @@ export function TransitionGroup<T = unknown>(props: TransitionGroupProps<T>): VN
|
|
|
186
186
|
if (Math.abs(dx) < 1 && Math.abs(dy) < 1) return
|
|
187
187
|
const el = entry.ref.current
|
|
188
188
|
el.style.transform = `translate(${dx}px, ${dy}px)`
|
|
189
|
-
el.style.transition =
|
|
189
|
+
el.style.transition = 'none'
|
|
190
190
|
startMoveAnimation(el)
|
|
191
191
|
}
|
|
192
192
|
|
package/src/transition.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Props, VNode, VNodeChild } from
|
|
2
|
-
import { createRef, Fragment, h, onUnmount } from
|
|
3
|
-
import { effect, runUntracked, signal } from
|
|
1
|
+
import type { Props, VNode, VNodeChild } from '@pyreon/core'
|
|
2
|
+
import { createRef, Fragment, h, onUnmount } from '@pyreon/core'
|
|
3
|
+
import { effect, runUntracked, signal } from '@pyreon/reactivity'
|
|
4
4
|
|
|
5
|
-
const __DEV__ = typeof process !==
|
|
5
|
+
const __DEV__ = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production'
|
|
6
6
|
|
|
7
7
|
export interface TransitionProps {
|
|
8
8
|
/**
|
|
@@ -60,7 +60,7 @@ export interface TransitionProps {
|
|
|
60
60
|
* // .fade-enter-active, .fade-leave-active { transition: opacity 300ms ease; }
|
|
61
61
|
*/
|
|
62
62
|
export function Transition(props: TransitionProps): VNodeChild {
|
|
63
|
-
const n = props.name ??
|
|
63
|
+
const n = props.name ?? 'pyreon'
|
|
64
64
|
const cls = {
|
|
65
65
|
ef: props.enterFrom ?? `${n}-enter-from`,
|
|
66
66
|
ea: props.enterActive ?? `${n}-enter-active`,
|
|
@@ -89,13 +89,13 @@ export function Transition(props: TransitionProps): VNodeChild {
|
|
|
89
89
|
el.classList.add(cls.et)
|
|
90
90
|
const done = () => {
|
|
91
91
|
// Remove both listeners — only one fires, so clean up the other
|
|
92
|
-
el.removeEventListener(
|
|
93
|
-
el.removeEventListener(
|
|
92
|
+
el.removeEventListener('transitionend', done)
|
|
93
|
+
el.removeEventListener('animationend', done)
|
|
94
94
|
el.classList.remove(cls.ea, cls.et)
|
|
95
95
|
props.onAfterEnter?.(el)
|
|
96
96
|
}
|
|
97
|
-
el.addEventListener(
|
|
98
|
-
el.addEventListener(
|
|
97
|
+
el.addEventListener('transitionend', done, { once: true })
|
|
98
|
+
el.addEventListener('animationend', done, { once: true })
|
|
99
99
|
})
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -108,20 +108,20 @@ export function Transition(props: TransitionProps): VNodeChild {
|
|
|
108
108
|
el.classList.add(cls.lt)
|
|
109
109
|
const done = () => {
|
|
110
110
|
// Remove both listeners — only one fires, so clean up the other
|
|
111
|
-
el.removeEventListener(
|
|
112
|
-
el.removeEventListener(
|
|
111
|
+
el.removeEventListener('transitionend', done)
|
|
112
|
+
el.removeEventListener('animationend', done)
|
|
113
113
|
el.classList.remove(cls.la, cls.lt)
|
|
114
114
|
pendingLeaveCancel = null
|
|
115
115
|
isMounted.set(false)
|
|
116
116
|
props.onAfterLeave?.(el)
|
|
117
117
|
}
|
|
118
118
|
pendingLeaveCancel = () => {
|
|
119
|
-
el.removeEventListener(
|
|
120
|
-
el.removeEventListener(
|
|
119
|
+
el.removeEventListener('transitionend', done)
|
|
120
|
+
el.removeEventListener('animationend', done)
|
|
121
121
|
el.classList.remove(cls.lf, cls.la, cls.lt)
|
|
122
122
|
}
|
|
123
|
-
el.addEventListener(
|
|
124
|
-
el.addEventListener(
|
|
123
|
+
el.addEventListener('transitionend', done, { once: true })
|
|
124
|
+
el.addEventListener('animationend', done, { once: true })
|
|
125
125
|
})
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -166,15 +166,15 @@ export function Transition(props: TransitionProps): VNodeChild {
|
|
|
166
166
|
const emptyFragment = h(Fragment, null)
|
|
167
167
|
return (() => {
|
|
168
168
|
if (!isMounted()) return emptyFragment
|
|
169
|
-
if (!rawChild || typeof rawChild !==
|
|
169
|
+
if (!rawChild || typeof rawChild !== 'object' || Array.isArray(rawChild)) {
|
|
170
170
|
return rawChild ?? null
|
|
171
171
|
}
|
|
172
172
|
const vnode = rawChild as VNode
|
|
173
173
|
// Only inject ref into DOM element children — component children need ref forwarding
|
|
174
|
-
if (typeof vnode.type !==
|
|
174
|
+
if (typeof vnode.type !== 'string') {
|
|
175
175
|
if (__DEV__) {
|
|
176
176
|
console.warn(
|
|
177
|
-
|
|
177
|
+
'[Pyreon] Transition child is a component. Wrap it in a DOM element for enter/leave animations to work.',
|
|
178
178
|
)
|
|
179
179
|
}
|
|
180
180
|
return vnode
|