@pzerelles/headlessui-svelte 2.1.2-next.47 → 2.1.2-next.49
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.
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
*
|
|
28
28
|
* ```tsx
|
|
29
29
|
* <Transition show={true}>
|
|
30
|
-
* <
|
|
31
|
-
* <
|
|
30
|
+
* <TransitionChild enter="duration-100"><div>Child 1</div></TransitionChild>
|
|
31
|
+
* <TransitionChild enter="duration-200"><div>Child 2</div></TransitionChild>
|
|
32
32
|
* </Transition>
|
|
33
33
|
* ```
|
|
34
34
|
*
|
|
@@ -39,11 +39,17 @@
|
|
|
39
39
|
export function shouldForwardRef(props: TransitionRootProps) {
|
|
40
40
|
return (
|
|
41
41
|
// If we have any of the enter/leave classes
|
|
42
|
-
Boolean(
|
|
42
|
+
Boolean(
|
|
43
|
+
props.enter ||
|
|
44
|
+
props.enterFrom ||
|
|
45
|
+
props.enterTo ||
|
|
46
|
+
props.leave ||
|
|
47
|
+
props.leaveFrom ||
|
|
48
|
+
props.leaveTo ||
|
|
49
|
+
props.class
|
|
50
|
+
) ||
|
|
43
51
|
// If the `as` prop is not a Fragment
|
|
44
|
-
|
|
45
|
-
// If we have a single child, then we can forward the ref directly
|
|
46
|
-
props.children !== undefined
|
|
52
|
+
props.asChild
|
|
47
53
|
)
|
|
48
54
|
}
|
|
49
55
|
</script>
|
|
@@ -88,7 +94,7 @@
|
|
|
88
94
|
const { register, unregister } = $derived(parentNesting)
|
|
89
95
|
|
|
90
96
|
onMount(() => {
|
|
91
|
-
if (requiresRef) {
|
|
97
|
+
if (requiresRef || element) {
|
|
92
98
|
container.current = element ?? null
|
|
93
99
|
containerElement = element
|
|
94
100
|
}
|
|
@@ -115,10 +121,10 @@
|
|
|
115
121
|
//[state, container, register, unregister, show, strategy]
|
|
116
122
|
|
|
117
123
|
$effect(() => {
|
|
118
|
-
if (!requiresRef) return
|
|
124
|
+
if (!requiresRef && !element) return
|
|
119
125
|
|
|
120
126
|
if (_state === TreeStates.Visible && container.current === null) {
|
|
121
|
-
throw new Error("Did you forget to passthrough the
|
|
127
|
+
throw new Error("Did you forget to passthrough the actual DOM node as `element`?")
|
|
122
128
|
}
|
|
123
129
|
})
|
|
124
130
|
|
|
@@ -171,7 +177,7 @@
|
|
|
171
177
|
}
|
|
172
178
|
|
|
173
179
|
$effect(() => {
|
|
174
|
-
if (requiresRef && transition) return
|
|
180
|
+
if ((requiresRef || element) && transition) return
|
|
175
181
|
|
|
176
182
|
// When we don't transition, then we can complete the transition
|
|
177
183
|
// immediately.
|
|
@@ -185,7 +191,7 @@
|
|
|
185
191
|
if (!transition) return false
|
|
186
192
|
|
|
187
193
|
// If we don't require a ref, then we can't transition.
|
|
188
|
-
if (!requiresRef) return false
|
|
194
|
+
if (!requiresRef && !element) return false
|
|
189
195
|
|
|
190
196
|
// If the server handoff isn't completed yet, we can't transition.
|
|
191
197
|
//if (!ready) return false
|
|
@@ -221,7 +227,7 @@
|
|
|
221
227
|
classNames(
|
|
222
228
|
// Incoming classes if any
|
|
223
229
|
// all components accept className (but all HTML elements do)
|
|
224
|
-
theirProps.asChild
|
|
230
|
+
theirProps.asChild || !requiresRef
|
|
225
231
|
? undefined
|
|
226
232
|
: typeof theirProps.class === "function"
|
|
227
233
|
? theirProps.class({ element })
|
|
@@ -245,6 +251,7 @@
|
|
|
245
251
|
!transitionData.transition && show && entered
|
|
246
252
|
)?.trim() || undefined, // If `class` is an empty string, we can omit it
|
|
247
253
|
...transitionDataAttributes(transitionData),
|
|
254
|
+
...(!theirProps.asChild && !requiresRef ? { asChild: true } : {}),
|
|
248
255
|
})
|
|
249
256
|
)
|
|
250
257
|
|
|
@@ -9,8 +9,8 @@ import { type TransitionChildProps } from "./TransitionChild.svelte";
|
|
|
9
9
|
*
|
|
10
10
|
* ```tsx
|
|
11
11
|
* <Transition show={true}>
|
|
12
|
-
* <
|
|
13
|
-
* <
|
|
12
|
+
* <TransitionChild enter="duration-100"><div>Child 1</div></TransitionChild>
|
|
13
|
+
* <TransitionChild enter="duration-200"><div>Child 2</div></TransitionChild>
|
|
14
14
|
* </Transition>
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
@@ -18,7 +18,7 @@ import { type TransitionChildProps } from "./TransitionChild.svelte";
|
|
|
18
18
|
* `Transition` parent, which is a `Fragment`, is not. So we should not forward
|
|
19
19
|
* the ref to the `Fragment`.
|
|
20
20
|
*/
|
|
21
|
-
export declare function shouldForwardRef(props: TransitionRootProps): boolean;
|
|
21
|
+
export declare function shouldForwardRef(props: TransitionRootProps): boolean | undefined;
|
|
22
22
|
declare const InternalTransitionChild: import("svelte").Component<TransitionChildProps, {}, "element">;
|
|
23
23
|
type InternalTransitionChild = ReturnType<typeof InternalTransitionChild>;
|
|
24
24
|
export default InternalTransitionChild;
|
|
@@ -11,14 +11,14 @@ export var TreeStates;
|
|
|
11
11
|
export function useTransitionContext() {
|
|
12
12
|
const context = getContext("TransitionContext");
|
|
13
13
|
if (!context) {
|
|
14
|
-
throw new Error("A <
|
|
14
|
+
throw new Error("A <TransitionChild /> is used but it is missing a parent <Transition /> or <Transition.Root />.");
|
|
15
15
|
}
|
|
16
16
|
return context;
|
|
17
17
|
}
|
|
18
18
|
export function useParentNesting() {
|
|
19
19
|
const context = getContext("NestingContext");
|
|
20
20
|
if (!context) {
|
|
21
|
-
throw new Error("A <
|
|
21
|
+
throw new Error("A <TransitionChild /> is used but it is missing a parent <Transition /> or <Transition.Root />.");
|
|
22
22
|
}
|
|
23
23
|
return context;
|
|
24
24
|
}
|