@pzerelles/headlessui-svelte 2.1.2-next.12 → 2.1.2-next.14

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.
@@ -1,7 +1,7 @@
1
1
  import { getContext, setContext } from "svelte";
2
2
  export function useDescriptionContext() {
3
3
  let context = getContext("DescriptionContext");
4
- if (context === null) {
4
+ if (!context) {
5
5
  let err = new Error("You used a <Description /> component, but it is not inside a relevant parent.");
6
6
  if (Error.captureStackTrace)
7
7
  Error.captureStackTrace(err, useDescriptionContext);
@@ -6,7 +6,7 @@ export var DialogStates;
6
6
  })(DialogStates || (DialogStates = {}));
7
7
  export function useDialogContext(component) {
8
8
  const context = getContext("DialogContext");
9
- if (context === null) {
9
+ if (!context) {
10
10
  let err = new Error(`<${component} /> is missing a parent <Dialog /> component.`);
11
11
  if (Error.captureStackTrace)
12
12
  Error.captureStackTrace(err, useDialogContext);
@@ -234,7 +234,7 @@ function useResolvePxValue(options) {
234
234
  const immediateValue = $derived(computeValue(input, element)[0]);
235
235
  let explicitValue = $state();
236
236
  const setValue = (value) => (explicitValue = value);
237
- const value = explicitValue ?? immediateValue;
237
+ const value = $derived(explicitValue ?? immediateValue);
238
238
  $effect(() => {
239
239
  const [value, watcher] = computeValue(input, element);
240
240
  setValue(value);
@@ -1,7 +1,7 @@
1
1
  import { getContext, setContext } from "svelte";
2
2
  export function useLabelContext() {
3
3
  let context = getContext("LabelContext");
4
- if (context === null) {
4
+ if (!context) {
5
5
  let err = new Error("You used a <Label /> component, but it is not inside a relevant parent.");
6
6
  if (Error.captureStackTrace)
7
7
  Error.captureStackTrace(err, useLabelContext);
@@ -27,7 +27,8 @@ let {
27
27
  const usedInSelectedOption = getContext("SelectedOptionContext") === true;
28
28
  const data = useData("ListboxOption");
29
29
  const actions = useActions("ListboxOption");
30
- const active = $derived(data.activeOptionIndex !== null ? data.options[data.activeOptionIndex].id === id : false);
30
+ const { activeOptionIndex, options } = $derived(data);
31
+ const active = $derived(activeOptionIndex !== null ? options[activeOptionIndex].id === id : false);
31
32
  const selected = $derived(data.isSelected(value));
32
33
  const getTextValue = useTextValue({
33
34
  get element() {
@@ -245,13 +245,65 @@ const ourProps = $derived({
245
245
  }),
246
246
  ...transitionDataAttributes(transitionData)
247
247
  });
248
- const derivedData = {
248
+ const derivedData = $derived({
249
249
  ...data,
250
250
  get isSelected() {
251
251
  return data.mode === ValueMode.Multi ? data.isSelected : isSelected;
252
252
  }
253
- };
254
- setContext("ListboxDataContext", derivedData);
253
+ });
254
+ setContext("ListboxDataContext", {
255
+ get value() {
256
+ return data.value;
257
+ },
258
+ get disabled() {
259
+ return data.disabled;
260
+ },
261
+ get invalid() {
262
+ return data.invalid;
263
+ },
264
+ get mode() {
265
+ return data.mode;
266
+ },
267
+ get orientation() {
268
+ return data.orientation;
269
+ },
270
+ get activeOptionIndex() {
271
+ return data.activeOptionIndex;
272
+ },
273
+ get compare() {
274
+ return data.compare;
275
+ },
276
+ get isSelected() {
277
+ return data.mode === ValueMode.Multi ? data.isSelected : isSelected;
278
+ },
279
+ get optionsProps() {
280
+ return data.optionsProps;
281
+ },
282
+ get listElements() {
283
+ return data.listElements;
284
+ },
285
+ get buttonElement() {
286
+ return data.buttonElement;
287
+ },
288
+ get optionsElement() {
289
+ return data.optionsElement;
290
+ },
291
+ get listboxState() {
292
+ return data.listboxState;
293
+ },
294
+ get options() {
295
+ return data.options;
296
+ },
297
+ get searchQuery() {
298
+ return data.searchQuery;
299
+ },
300
+ get activationTrigger() {
301
+ return data.activationTrigger;
302
+ },
303
+ get __demoMode() {
304
+ return data.__demoMode;
305
+ }
306
+ });
255
307
  </script>
256
308
 
257
309
  <Portal enabled={portal ? theirProps.static || visible : false}>
@@ -26,7 +26,7 @@ export function useActions(component) {
26
26
  }
27
27
  export function useData(component) {
28
28
  const context = getContext("ListboxDataContext");
29
- if (context === null) {
29
+ if (!context) {
30
30
  let err = new Error(`<${component} /> is missing a parent <Listbox /> component.`);
31
31
  if (Error.captureStackTrace)
32
32
  Error.captureStackTrace(err, useData);
@@ -1,9 +1,8 @@
1
1
  <script lang="ts" module>import { useOutsideClick } from "../hooks/use-outside-click.svelte.js";
2
2
  import { useFloatingProvider } from "../internal/floating.svelte.js";
3
3
  import { createOpenClosedContext, State } from "../internal/open-closed.js";
4
- import { calculateActiveIndex, Focus } from "../utils/calculate-active-index.js";
5
4
  import ElementOrComponent from "../utils/ElementOrComponent.svelte";
6
- import { FocusableMode, isFocusableElement, sortByDomNode } from "../utils/focus-management.js";
5
+ import { FocusableMode, isFocusableElement } from "../utils/focus-management.js";
7
6
  import { match } from "../utils/match.js";
8
7
  let DEFAULT_MENU_TAG = "svelte:fragment";
9
8
  </script>
@@ -11,180 +10,9 @@ let DEFAULT_MENU_TAG = "svelte:fragment";
11
10
  <script lang="ts" generics="TTag extends ElementType = typeof DEFAULT_MENU_TAG">import { setContext } from "svelte";
12
11
  import {
13
12
  ActivationTrigger,
14
- MenuStates
13
+ MenuStates,
14
+ stateReducer
15
15
  } from "./context.svelte.js";
16
- function adjustOrderedState(state, adjustment = (i) => i) {
17
- let currentActiveItem = state.activeItemIndex !== null ? state.items[state.activeItemIndex] : null;
18
- let sortedItems = sortByDomNode(adjustment(state.items.slice()), (item) => item.dataRef.current.domRef.current);
19
- let adjustedActiveItemIndex = currentActiveItem ? sortedItems.indexOf(currentActiveItem) : null;
20
- if (adjustedActiveItemIndex === -1) {
21
- adjustedActiveItemIndex = null;
22
- }
23
- return {
24
- items: sortedItems,
25
- activeItemIndex: adjustedActiveItemIndex
26
- };
27
- }
28
- const stateReducer = (initialState) => {
29
- let _state2 = $state(initialState);
30
- return {
31
- get menuState() {
32
- return _state2.menuState;
33
- },
34
- get buttonElement() {
35
- return _state2.buttonElement;
36
- },
37
- get itemsElement() {
38
- return _state2.itemsElement;
39
- },
40
- get items() {
41
- return _state2.items;
42
- },
43
- get searchQuery() {
44
- return _state2.searchQuery;
45
- },
46
- get activeItemIndex() {
47
- return _state2.activeItemIndex;
48
- },
49
- get activationTrigger() {
50
- return _state2.activationTrigger;
51
- },
52
- get __demoMode() {
53
- return _state2.__demoMode;
54
- },
55
- closeMenu() {
56
- if (_state2.menuState === MenuStates.Closed) return _state2;
57
- _state2.activeItemIndex = null;
58
- _state2.menuState = MenuStates.Closed;
59
- return _state2;
60
- },
61
- openMenu() {
62
- if (_state2.menuState === MenuStates.Open) return _state2;
63
- _state2.__demoMode = false;
64
- _state2.menuState = MenuStates.Open;
65
- return _state2;
66
- },
67
- goToItem(action) {
68
- if (_state2.menuState === MenuStates.Closed) return _state2;
69
- _state2.searchQuery = "";
70
- _state2.activationTrigger = action.trigger ?? ActivationTrigger.Other;
71
- _state2.__demoMode = false;
72
- if (action.focus === Focus.Nothing) {
73
- _state2.activeItemIndex = null;
74
- return _state2;
75
- }
76
- if (action.focus === Focus.Specific) {
77
- _state2.activeItemIndex = _state2.items.findIndex((o) => o.id === action.id);
78
- return _state2;
79
- } else if (action.focus === Focus.Previous) {
80
- let activeItemIdx = _state2.activeItemIndex;
81
- if (activeItemIdx !== null) {
82
- let currentDom = _state2.items[activeItemIdx].dataRef.current.domRef;
83
- let previousItemIndex = calculateActiveIndex(action, {
84
- resolveItems: () => _state2.items,
85
- resolveActiveIndex: () => _state2.activeItemIndex,
86
- resolveId: (item) => item.id,
87
- resolveDisabled: (item) => item.dataRef.current.disabled
88
- });
89
- if (previousItemIndex !== null) {
90
- let previousDom = _state2.items[previousItemIndex].dataRef.current.domRef;
91
- if (
92
- // Next to each other
93
- currentDom.current?.previousElementSibling === previousDom.current || // Or already the first element
94
- previousDom.current?.previousElementSibling === null
95
- ) {
96
- _state2.activeItemIndex = previousItemIndex;
97
- return _state2;
98
- }
99
- }
100
- }
101
- } else if (action.focus === Focus.Next) {
102
- let activeItemIdx = _state2.activeItemIndex;
103
- if (activeItemIdx !== null) {
104
- let currentDom = _state2.items[activeItemIdx].dataRef.current.domRef;
105
- let nextItemIndex = calculateActiveIndex(action, {
106
- resolveItems: () => _state2.items,
107
- resolveActiveIndex: () => _state2.activeItemIndex,
108
- resolveId: (item) => item.id,
109
- resolveDisabled: (item) => item.dataRef.current.disabled
110
- });
111
- if (nextItemIndex !== null) {
112
- let nextDom = _state2.items[nextItemIndex].dataRef.current.domRef;
113
- if (
114
- // Next to each other
115
- currentDom.current?.nextElementSibling === nextDom.current || // Or already the last element
116
- nextDom.current?.nextElementSibling === null
117
- ) {
118
- _state2.activeItemIndex = nextItemIndex;
119
- return _state2;
120
- }
121
- }
122
- }
123
- }
124
- let adjustedState = adjustOrderedState(_state2);
125
- let activeItemIndex = calculateActiveIndex(action, {
126
- resolveItems: () => adjustedState.items,
127
- resolveActiveIndex: () => adjustedState.activeItemIndex,
128
- resolveId: (item) => item.id,
129
- resolveDisabled: (item) => item.dataRef.current.disabled
130
- });
131
- _state2.items = adjustedState.items;
132
- _state2.activeItemIndex = activeItemIndex;
133
- return _state2;
134
- },
135
- search(value) {
136
- let wasAlreadySearching = _state2.searchQuery !== "";
137
- let offset = wasAlreadySearching ? 0 : 1;
138
- let searchQuery = _state2.searchQuery + value.toLowerCase();
139
- let reOrderedItems = _state2.activeItemIndex !== null ? _state2.items.slice(_state2.activeItemIndex + offset).concat(_state2.items.slice(0, _state2.activeItemIndex + offset)) : _state2.items;
140
- let matchingItem = reOrderedItems.find(
141
- (item) => item.dataRef.current.textValue?.startsWith(searchQuery) && !item.dataRef.current.disabled
142
- );
143
- let matchIdx = matchingItem ? _state2.items.indexOf(matchingItem) : -1;
144
- if (matchIdx === -1 || matchIdx === _state2.activeItemIndex) {
145
- _state2.searchQuery = searchQuery;
146
- return _state2;
147
- }
148
- _state2.searchQuery = searchQuery;
149
- _state2.activeItemIndex = matchIdx;
150
- _state2.activationTrigger = ActivationTrigger.Other;
151
- return _state2;
152
- },
153
- clearSearch() {
154
- if (_state2.searchQuery === "") return _state2;
155
- _state2.searchQuery = "";
156
- return _state2;
157
- },
158
- registerItem(id, dataRef) {
159
- let item = { id, dataRef };
160
- let adjustedState = adjustOrderedState(_state2, (items) => [...items, item]);
161
- _state2.items = adjustedState.items;
162
- _state2.activeItemIndex = adjustedState.activeItemIndex;
163
- return _state2;
164
- },
165
- unregisterItem(id) {
166
- let adjustedState = adjustOrderedState(_state2, (items) => {
167
- let idx = items.findIndex((a) => a.id === id);
168
- if (idx !== -1) items.splice(idx, 1);
169
- return items;
170
- });
171
- _state2.items = adjustedState.items;
172
- _state2.activeItemIndex = adjustedState.activeItemIndex;
173
- _state2.activationTrigger = ActivationTrigger.Other;
174
- return _state2;
175
- },
176
- setButtonElement(element) {
177
- if (_state2.buttonElement === element) return _state2;
178
- _state2.buttonElement = element;
179
- return _state2;
180
- },
181
- setItemsElement(element) {
182
- if (_state2.itemsElement === element) return _state2;
183
- _state2.itemsElement = element;
184
- return _state2;
185
- }
186
- };
187
- };
188
16
  let { ref = $bindable(), __demoMode = false, ...theirProps } = $props();
189
17
  const _state = stateReducer({
190
18
  __demoMode,
@@ -1,4 +1,4 @@
1
- import type { Focus } from "../utils/calculate-active-index.js";
1
+ import { Focus } from "../utils/calculate-active-index.js";
2
2
  import type { MutableRefObject } from "../utils/ref.svelte.js";
3
3
  export declare enum MenuStates {
4
4
  Open = 0,
@@ -45,3 +45,32 @@ export type MenuContext = StateDefinition & {
45
45
  setItemsElement(element: HTMLElement | null): void;
46
46
  };
47
47
  export declare function useMenuContext(component: string): MenuContext;
48
+ export declare const stateReducer: (initialState: StateDefinition) => {
49
+ readonly menuState: MenuStates;
50
+ readonly buttonElement: HTMLButtonElement | null;
51
+ readonly itemsElement: HTMLElement | null;
52
+ readonly items: {
53
+ id: string;
54
+ dataRef: MenuItemDataRef;
55
+ }[];
56
+ readonly searchQuery: string;
57
+ readonly activeItemIndex: number | null;
58
+ readonly activationTrigger: ActivationTrigger;
59
+ readonly __demoMode: boolean;
60
+ closeMenu(): StateDefinition;
61
+ openMenu(): StateDefinition;
62
+ goToItem(action: {
63
+ focus: Focus.Specific;
64
+ id: string;
65
+ trigger?: ActivationTrigger;
66
+ } | {
67
+ focus: Exclude<Focus, Focus.Specific>;
68
+ trigger?: ActivationTrigger;
69
+ }): StateDefinition;
70
+ search(value: string): StateDefinition;
71
+ clearSearch(): StateDefinition;
72
+ registerItem(id: string, dataRef: MenuItemDataRef): StateDefinition;
73
+ unregisterItem(id: string): StateDefinition;
74
+ setButtonElement(element: HTMLButtonElement | null): StateDefinition;
75
+ setItemsElement(element: HTMLElement | null): StateDefinition;
76
+ };
@@ -1,3 +1,5 @@
1
+ import { calculateActiveIndex, Focus } from "../utils/calculate-active-index.js";
2
+ import { sortByDomNode } from "../utils/focus-management.js";
1
3
  import { getContext } from "svelte";
2
4
  export var MenuStates;
3
5
  (function (MenuStates) {
@@ -19,3 +21,209 @@ export function useMenuContext(component) {
19
21
  }
20
22
  return context;
21
23
  }
24
+ function adjustOrderedState(state, adjustment = (i) => i) {
25
+ let currentActiveItem = state.activeItemIndex !== null ? state.items[state.activeItemIndex] : null;
26
+ let sortedItems = sortByDomNode(adjustment(state.items.slice()), (item) => item.dataRef.current.domRef.current);
27
+ // If we inserted an item before the current active item then the active item index
28
+ // would be wrong. To fix this, we will re-lookup the correct index.
29
+ let adjustedActiveItemIndex = currentActiveItem ? sortedItems.indexOf(currentActiveItem) : null;
30
+ // Reset to `null` in case the currentActiveItem was removed.
31
+ if (adjustedActiveItemIndex === -1) {
32
+ adjustedActiveItemIndex = null;
33
+ }
34
+ return {
35
+ items: sortedItems,
36
+ activeItemIndex: adjustedActiveItemIndex,
37
+ };
38
+ }
39
+ export const stateReducer = (initialState) => {
40
+ let _state = $state(initialState);
41
+ return {
42
+ get menuState() {
43
+ return _state.menuState;
44
+ },
45
+ get buttonElement() {
46
+ return _state.buttonElement;
47
+ },
48
+ get itemsElement() {
49
+ return _state.itemsElement;
50
+ },
51
+ get items() {
52
+ return _state.items;
53
+ },
54
+ get searchQuery() {
55
+ return _state.searchQuery;
56
+ },
57
+ get activeItemIndex() {
58
+ return _state.activeItemIndex;
59
+ },
60
+ get activationTrigger() {
61
+ return _state.activationTrigger;
62
+ },
63
+ get __demoMode() {
64
+ return _state.__demoMode;
65
+ },
66
+ closeMenu() {
67
+ if (_state.menuState === MenuStates.Closed)
68
+ return _state;
69
+ _state.activeItemIndex = null;
70
+ _state.menuState = MenuStates.Closed;
71
+ return _state;
72
+ },
73
+ openMenu() {
74
+ if (_state.menuState === MenuStates.Open)
75
+ return _state;
76
+ /* We can turn off demo mode once we re-open the `Menu` */
77
+ _state.__demoMode = false;
78
+ _state.menuState = MenuStates.Open;
79
+ return _state;
80
+ },
81
+ goToItem(action) {
82
+ if (_state.menuState === MenuStates.Closed)
83
+ return _state;
84
+ _state.searchQuery = "";
85
+ _state.activationTrigger = action.trigger ?? ActivationTrigger.Other;
86
+ _state.__demoMode = false;
87
+ // Optimization:
88
+ //
89
+ // There is no need to sort the DOM nodes if we know that we don't want to focus anything
90
+ if (action.focus === Focus.Nothing) {
91
+ _state.activeItemIndex = null;
92
+ return _state;
93
+ }
94
+ // Optimization:
95
+ //
96
+ // There is no need to sort the DOM nodes if we know exactly where to go
97
+ if (action.focus === Focus.Specific) {
98
+ _state.activeItemIndex = _state.items.findIndex((o) => o.id === action.id);
99
+ return _state;
100
+ }
101
+ // Optimization:
102
+ //
103
+ // If the current DOM node and the previous DOM node are next to each other,
104
+ // or if the previous DOM node is already the first DOM node, then we don't
105
+ // have to sort all the DOM nodes.
106
+ else if (action.focus === Focus.Previous) {
107
+ let activeItemIdx = _state.activeItemIndex;
108
+ if (activeItemIdx !== null) {
109
+ let currentDom = _state.items[activeItemIdx].dataRef.current.domRef;
110
+ let previousItemIndex = calculateActiveIndex(action, {
111
+ resolveItems: () => _state.items,
112
+ resolveActiveIndex: () => _state.activeItemIndex,
113
+ resolveId: (item) => item.id,
114
+ resolveDisabled: (item) => item.dataRef.current.disabled,
115
+ });
116
+ if (previousItemIndex !== null) {
117
+ let previousDom = _state.items[previousItemIndex].dataRef.current.domRef;
118
+ if (
119
+ // Next to each other
120
+ currentDom.current?.previousElementSibling === previousDom.current ||
121
+ // Or already the first element
122
+ previousDom.current?.previousElementSibling === null) {
123
+ _state.activeItemIndex = previousItemIndex;
124
+ return _state;
125
+ }
126
+ }
127
+ }
128
+ }
129
+ // Optimization:
130
+ //
131
+ // If the current DOM node and the next DOM node are next to each other, or
132
+ // if the next DOM node is already the last DOM node, then we don't have to
133
+ // sort all the DOM nodes.
134
+ else if (action.focus === Focus.Next) {
135
+ let activeItemIdx = _state.activeItemIndex;
136
+ if (activeItemIdx !== null) {
137
+ let currentDom = _state.items[activeItemIdx].dataRef.current.domRef;
138
+ let nextItemIndex = calculateActiveIndex(action, {
139
+ resolveItems: () => _state.items,
140
+ resolveActiveIndex: () => _state.activeItemIndex,
141
+ resolveId: (item) => item.id,
142
+ resolveDisabled: (item) => item.dataRef.current.disabled,
143
+ });
144
+ if (nextItemIndex !== null) {
145
+ let nextDom = _state.items[nextItemIndex].dataRef.current.domRef;
146
+ if (
147
+ // Next to each other
148
+ currentDom.current?.nextElementSibling === nextDom.current ||
149
+ // Or already the last element
150
+ nextDom.current?.nextElementSibling === null) {
151
+ _state.activeItemIndex = nextItemIndex;
152
+ return _state;
153
+ }
154
+ }
155
+ }
156
+ }
157
+ // Slow path:
158
+ //
159
+ // Ensure all the items are correctly sorted according to DOM position
160
+ let adjustedState = adjustOrderedState(_state);
161
+ let activeItemIndex = calculateActiveIndex(action, {
162
+ resolveItems: () => adjustedState.items,
163
+ resolveActiveIndex: () => adjustedState.activeItemIndex,
164
+ resolveId: (item) => item.id,
165
+ resolveDisabled: (item) => item.dataRef.current.disabled,
166
+ });
167
+ _state.items = adjustedState.items;
168
+ _state.activeItemIndex = activeItemIndex;
169
+ return _state;
170
+ },
171
+ search(value) {
172
+ let wasAlreadySearching = _state.searchQuery !== "";
173
+ let offset = wasAlreadySearching ? 0 : 1;
174
+ let searchQuery = _state.searchQuery + value.toLowerCase();
175
+ let reOrderedItems = _state.activeItemIndex !== null
176
+ ? _state.items
177
+ .slice(_state.activeItemIndex + offset)
178
+ .concat(_state.items.slice(0, _state.activeItemIndex + offset))
179
+ : _state.items;
180
+ let matchingItem = reOrderedItems.find((item) => item.dataRef.current.textValue?.startsWith(searchQuery) && !item.dataRef.current.disabled);
181
+ let matchIdx = matchingItem ? _state.items.indexOf(matchingItem) : -1;
182
+ if (matchIdx === -1 || matchIdx === _state.activeItemIndex) {
183
+ _state.searchQuery = searchQuery;
184
+ return _state;
185
+ }
186
+ _state.searchQuery = searchQuery;
187
+ _state.activeItemIndex = matchIdx;
188
+ _state.activationTrigger = ActivationTrigger.Other;
189
+ return _state;
190
+ },
191
+ clearSearch() {
192
+ if (_state.searchQuery === "")
193
+ return _state;
194
+ _state.searchQuery = "";
195
+ return _state;
196
+ },
197
+ registerItem(id, dataRef) {
198
+ let item = { id, dataRef };
199
+ let adjustedState = adjustOrderedState(_state, (items) => [...items, item]);
200
+ _state.items = adjustedState.items;
201
+ _state.activeItemIndex = adjustedState.activeItemIndex;
202
+ return _state;
203
+ },
204
+ unregisterItem(id) {
205
+ let adjustedState = adjustOrderedState(_state, (items) => {
206
+ let idx = items.findIndex((a) => a.id === id);
207
+ if (idx !== -1)
208
+ items.splice(idx, 1);
209
+ return items;
210
+ });
211
+ _state.items = adjustedState.items;
212
+ _state.activeItemIndex = adjustedState.activeItemIndex;
213
+ _state.activationTrigger = ActivationTrigger.Other;
214
+ return _state;
215
+ },
216
+ setButtonElement(element) {
217
+ if (_state.buttonElement === element)
218
+ return _state;
219
+ _state.buttonElement = element;
220
+ return _state;
221
+ },
222
+ setItemsElement(element) {
223
+ if (_state.itemsElement === element)
224
+ return _state;
225
+ _state.itemsElement = element;
226
+ return _state;
227
+ },
228
+ };
229
+ };
@@ -10,14 +10,14 @@ export var TreeStates;
10
10
  })(TreeStates || (TreeStates = {}));
11
11
  export function useTransitionContext() {
12
12
  const context = getContext("TransitionContext");
13
- if (context === null) {
13
+ if (!context) {
14
14
  throw new Error("A <Transition.Child /> 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
  let context = getContext("NestingContext");
20
- if (context === null) {
20
+ if (!context) {
21
21
  throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");
22
22
  }
23
23
  return context;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pzerelles/headlessui-svelte",
3
- "version": "2.1.2-next.12",
3
+ "version": "2.1.2-next.14",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",