bits-ui 2.14.1 → 2.14.2
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,4 +1,4 @@
|
|
|
1
1
|
import type { MenubarRootProps } from "../types.js";
|
|
2
|
-
declare const Menubar: import("svelte").Component<MenubarRootProps, {}, "ref">;
|
|
2
|
+
declare const Menubar: import("svelte").Component<MenubarRootProps, {}, "value" | "ref">;
|
|
3
3
|
type Menubar = ReturnType<typeof Menubar>;
|
|
4
4
|
export default Menubar;
|
|
@@ -77,6 +77,7 @@ export declare class TooltipTriggerState {
|
|
|
77
77
|
readonly disabled: boolean;
|
|
78
78
|
readonly onpointerup: PointerEventHandler<HTMLElement>;
|
|
79
79
|
readonly onpointerdown: PointerEventHandler<HTMLElement>;
|
|
80
|
+
readonly onpointerenter: PointerEventHandler<HTMLElement>;
|
|
80
81
|
readonly onpointermove: PointerEventHandler<HTMLElement>;
|
|
81
82
|
readonly onpointerleave: PointerEventHandler<HTMLElement>;
|
|
82
83
|
readonly onfocus: FocusEventHandler<HTMLElement>;
|
|
@@ -159,12 +159,19 @@ export class TooltipTriggerState {
|
|
|
159
159
|
#hasPointerMoveOpened = $state(false);
|
|
160
160
|
#isDisabled = $derived.by(() => this.opts.disabled.current || this.root.disabled);
|
|
161
161
|
domContext;
|
|
162
|
+
#transitCheckTimeout = null;
|
|
162
163
|
constructor(opts, root) {
|
|
163
164
|
this.opts = opts;
|
|
164
165
|
this.root = root;
|
|
165
166
|
this.domContext = new DOMContext(opts.ref);
|
|
166
167
|
this.attachment = attachRef(this.opts.ref, (v) => (this.root.triggerNode = v));
|
|
167
168
|
}
|
|
169
|
+
#clearTransitCheck = () => {
|
|
170
|
+
if (this.#transitCheckTimeout !== null) {
|
|
171
|
+
clearTimeout(this.#transitCheckTimeout);
|
|
172
|
+
this.#transitCheckTimeout = null;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
168
175
|
handlePointerUp = () => {
|
|
169
176
|
this.#isPointerDown.current = false;
|
|
170
177
|
};
|
|
@@ -181,6 +188,27 @@ export class TooltipTriggerState {
|
|
|
181
188
|
this.handlePointerUp();
|
|
182
189
|
}, { once: true });
|
|
183
190
|
};
|
|
191
|
+
#onpointerenter = (e) => {
|
|
192
|
+
if (this.#isDisabled)
|
|
193
|
+
return;
|
|
194
|
+
if (e.pointerType === "touch")
|
|
195
|
+
return;
|
|
196
|
+
// if in transit, wait briefly to see if user is actually heading to old content or staying here
|
|
197
|
+
if (this.root.provider.isPointerInTransit.current) {
|
|
198
|
+
this.#clearTransitCheck();
|
|
199
|
+
this.#transitCheckTimeout = window.setTimeout(() => {
|
|
200
|
+
// if still in transit after delay, user is likely staying on this trigger
|
|
201
|
+
if (this.root.provider.isPointerInTransit.current) {
|
|
202
|
+
this.root.provider.isPointerInTransit.current = false;
|
|
203
|
+
this.root.onTriggerEnter();
|
|
204
|
+
this.#hasPointerMoveOpened = true;
|
|
205
|
+
}
|
|
206
|
+
}, 250);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
this.root.onTriggerEnter();
|
|
210
|
+
this.#hasPointerMoveOpened = true;
|
|
211
|
+
};
|
|
184
212
|
#onpointermove = (e) => {
|
|
185
213
|
if (this.#isDisabled)
|
|
186
214
|
return;
|
|
@@ -188,14 +216,16 @@ export class TooltipTriggerState {
|
|
|
188
216
|
return;
|
|
189
217
|
if (this.#hasPointerMoveOpened)
|
|
190
218
|
return;
|
|
191
|
-
|
|
192
|
-
|
|
219
|
+
// moving within trigger means we're definitely not in transit anymore
|
|
220
|
+
this.#clearTransitCheck();
|
|
221
|
+
this.root.provider.isPointerInTransit.current = false;
|
|
193
222
|
this.root.onTriggerEnter();
|
|
194
223
|
this.#hasPointerMoveOpened = true;
|
|
195
224
|
};
|
|
196
225
|
#onpointerleave = () => {
|
|
197
226
|
if (this.#isDisabled)
|
|
198
227
|
return;
|
|
228
|
+
this.#clearTransitCheck();
|
|
199
229
|
this.root.onTriggerLeave();
|
|
200
230
|
this.#hasPointerMoveOpened = false;
|
|
201
231
|
};
|
|
@@ -229,6 +259,7 @@ export class TooltipTriggerState {
|
|
|
229
259
|
disabled: this.opts.disabled.current,
|
|
230
260
|
onpointerup: this.#onpointerup,
|
|
231
261
|
onpointerdown: this.#onpointerdown,
|
|
262
|
+
onpointerenter: this.#onpointerenter,
|
|
232
263
|
onpointermove: this.#onpointermove,
|
|
233
264
|
onpointerleave: this.#onpointerleave,
|
|
234
265
|
onfocus: this.#onfocus,
|