@pzerelles/headlessui-svelte 2.1.2-next.50 → 2.1.2-next.51
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.
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
<script lang="ts">
|
|
22
22
|
import { useId } from "../hooks/use-id.js"
|
|
23
23
|
import ElementOrComponent from "../utils/ElementOrComponent.svelte"
|
|
24
|
-
import { mergeProps } from "../utils/render.js"
|
|
25
|
-
import TransitionChild from "../transition/TransitionChild.svelte"
|
|
26
24
|
import {
|
|
27
25
|
createDisclosurePanelContext,
|
|
28
26
|
DisclosureStates,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { hasChildren, useNesting, } from "../transition/context.svelte.js";
|
|
1
2
|
import { disposables, useDisposables } from "../utils/disposables.js";
|
|
2
3
|
import { once } from "../utils/once.js";
|
|
3
|
-
import { untrack } from "svelte";
|
|
4
|
+
import { setContext, untrack } from "svelte";
|
|
4
5
|
/**
|
|
5
6
|
* ```
|
|
6
7
|
* ┌──────┐ │ ┌──────────────┐
|
|
@@ -42,6 +43,13 @@ export function useTransition(options) {
|
|
|
42
43
|
let inFlight = $state(false);
|
|
43
44
|
let cancelled = $state(false);
|
|
44
45
|
const d = useDisposables();
|
|
46
|
+
const nestingBag = useNesting({
|
|
47
|
+
done: () => {
|
|
48
|
+
if (show)
|
|
49
|
+
return;
|
|
50
|
+
visible = false;
|
|
51
|
+
},
|
|
52
|
+
});
|
|
45
53
|
function retry(enabled, show, node, d) {
|
|
46
54
|
if (!enabled)
|
|
47
55
|
return;
|
|
@@ -115,7 +123,7 @@ export function useTransition(options) {
|
|
|
115
123
|
}
|
|
116
124
|
inFlight = false;
|
|
117
125
|
flags = 0;
|
|
118
|
-
if (!show) {
|
|
126
|
+
if (!show && !hasChildren(nestingBag)) {
|
|
119
127
|
visible = false;
|
|
120
128
|
}
|
|
121
129
|
events?.end?.(show);
|
|
@@ -134,6 +142,23 @@ export function useTransition(options) {
|
|
|
134
142
|
leave: enabled ? !!(flags & TransitionState.Leave) : undefined,
|
|
135
143
|
transition: enabled ? !!(flags & (TransitionState.Enter | TransitionState.Leave)) : undefined,
|
|
136
144
|
});
|
|
145
|
+
$effect(() => {
|
|
146
|
+
if (enabled)
|
|
147
|
+
untrack(() => {
|
|
148
|
+
setContext("NestingContext", nestingBag);
|
|
149
|
+
setContext("TransitionContext", {
|
|
150
|
+
get show() {
|
|
151
|
+
return show;
|
|
152
|
+
},
|
|
153
|
+
get appear() {
|
|
154
|
+
return false;
|
|
155
|
+
},
|
|
156
|
+
get initial() {
|
|
157
|
+
return false;
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
|
137
162
|
return {
|
|
138
163
|
get visible() {
|
|
139
164
|
return enabled ? visible : show;
|