bits-ui 2.8.8 → 2.8.10
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/dist/bits/context-menu/components/context-menu-content.svelte +6 -0
- package/dist/bits/dropdown-menu/components/dropdown-menu-content.svelte +6 -0
- package/dist/bits/menu/components/menu-content.svelte +5 -0
- package/dist/bits/menu/menu.svelte.js +7 -9
- package/dist/bits/navigation-menu/navigation-menu.svelte.d.ts +1 -2
- package/dist/bits/navigation-menu/navigation-menu.svelte.js +3 -0
- package/package.json +3 -3
|
@@ -41,6 +41,12 @@
|
|
|
41
41
|
function handleInteractOutside(e: PointerEvent) {
|
|
42
42
|
onInteractOutside(e);
|
|
43
43
|
if (e.defaultPrevented) return;
|
|
44
|
+
|
|
45
|
+
// don't close if the interaction is with a submenu content or items
|
|
46
|
+
if (e.target && e.target instanceof Element) {
|
|
47
|
+
const subContentSelector = `[${contentState.parentMenu.root.getBitsAttr("sub-content")}]`;
|
|
48
|
+
if (e.target.closest(subContentSelector)) return;
|
|
49
|
+
}
|
|
44
50
|
contentState.parentMenu.onClose();
|
|
45
51
|
}
|
|
46
52
|
|
|
@@ -41,6 +41,12 @@
|
|
|
41
41
|
if (e.defaultPrevented) return;
|
|
42
42
|
onInteractOutside(e);
|
|
43
43
|
if (e.defaultPrevented) return;
|
|
44
|
+
|
|
45
|
+
// don't close if the interaction is with a submenu content or items
|
|
46
|
+
if (e.target && e.target instanceof Element) {
|
|
47
|
+
const subContentSelector = `[${contentState.parentMenu.root.getBitsAttr("sub-content")}]`;
|
|
48
|
+
if (e.target.closest(subContentSelector)) return;
|
|
49
|
+
}
|
|
44
50
|
contentState.parentMenu.onClose();
|
|
45
51
|
}
|
|
46
52
|
function handleEscapeKeydown(e: KeyboardEvent) {
|
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
function handleInteractOutside(e: PointerEvent) {
|
|
43
43
|
onInteractOutside(e);
|
|
44
44
|
if (e.defaultPrevented) return;
|
|
45
|
+
// don't close if the interaction is with a submenu content or items
|
|
46
|
+
if (e.target && e.target instanceof Element) {
|
|
47
|
+
const subContentSelector = `[${contentState.parentMenu.root.getBitsAttr("sub-content")}]`;
|
|
48
|
+
if (e.target.closest(subContentSelector)) return;
|
|
49
|
+
}
|
|
45
50
|
contentState.parentMenu.onClose();
|
|
46
51
|
}
|
|
47
52
|
|
|
@@ -423,15 +423,13 @@ export class MenuItemState {
|
|
|
423
423
|
return;
|
|
424
424
|
const selectEvent = new CustomEvent("menuitemselect", { bubbles: true, cancelable: true });
|
|
425
425
|
this.opts.onSelect.current(selectEvent);
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
});
|
|
426
|
+
if (selectEvent.defaultPrevented) {
|
|
427
|
+
this.item.content.parentMenu.root.isUsingKeyboard.current = false;
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (this.opts.closeOnSelect.current) {
|
|
431
|
+
this.item.content.parentMenu.root.opts.onClose();
|
|
432
|
+
}
|
|
435
433
|
}
|
|
436
434
|
onkeydown(e) {
|
|
437
435
|
const isTypingAhead = this.item.content.search !== "";
|
|
@@ -10,7 +10,6 @@ import { type Direction, type Orientation } from "../../shared/index.js";
|
|
|
10
10
|
import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, RefAttachment } from "../../internal/types.js";
|
|
11
11
|
import type { FocusEventHandler, KeyboardEventHandler, MouseEventHandler, PointerEventHandler } from "svelte/elements";
|
|
12
12
|
import { RovingFocusGroup } from "../../internal/roving-focus-group.js";
|
|
13
|
-
declare const navigationMenuAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["root", "sub", "item", "list", "trigger", "content", "link", "viewport", "menu", "indicator"]>;
|
|
14
13
|
export declare const NavigationMenuItemContext: Context<NavigationMenuItemState>;
|
|
15
14
|
interface NavigationMenuProviderStateOpts extends ReadableBoxedValues<{
|
|
16
15
|
dir: Direction;
|
|
@@ -122,6 +121,7 @@ export declare class NavigationMenuItemState {
|
|
|
122
121
|
#private;
|
|
123
122
|
static create(opts: NavigationMenuItemStateOpts): NavigationMenuItemState;
|
|
124
123
|
readonly opts: NavigationMenuItemStateOpts;
|
|
124
|
+
readonly attachment: RefAttachment;
|
|
125
125
|
readonly listContext: NavigationMenuListState;
|
|
126
126
|
contentNode: HTMLElement | null;
|
|
127
127
|
triggerNode: HTMLElement | null;
|
|
@@ -142,7 +142,6 @@ export declare class NavigationMenuItemState {
|
|
|
142
142
|
onRootContentClose: () => void;
|
|
143
143
|
onContentFocusOutside: () => void;
|
|
144
144
|
props: {
|
|
145
|
-
readonly [navigationMenuAttrs.item]: "";
|
|
146
145
|
readonly id: string;
|
|
147
146
|
};
|
|
148
147
|
}
|
|
@@ -248,6 +248,7 @@ export class NavigationMenuItemState {
|
|
|
248
248
|
return NavigationMenuItemContext.set(new NavigationMenuItemState(opts, NavigationMenuListContext.get()));
|
|
249
249
|
}
|
|
250
250
|
opts;
|
|
251
|
+
attachment;
|
|
251
252
|
listContext;
|
|
252
253
|
contentNode = $state(null);
|
|
253
254
|
triggerNode = $state(null);
|
|
@@ -264,6 +265,7 @@ export class NavigationMenuItemState {
|
|
|
264
265
|
this.opts = opts;
|
|
265
266
|
this.listContext = listContext;
|
|
266
267
|
this.domContext = new DOMContext(opts.ref);
|
|
268
|
+
this.attachment = attachRef(this.opts.ref);
|
|
267
269
|
}
|
|
268
270
|
#handleContentEntry = (side = "start") => {
|
|
269
271
|
if (!this.contentNode)
|
|
@@ -287,6 +289,7 @@ export class NavigationMenuItemState {
|
|
|
287
289
|
props = $derived.by(() => ({
|
|
288
290
|
id: this.opts.id.current,
|
|
289
291
|
[navigationMenuAttrs.item]: "",
|
|
292
|
+
...this.attachment,
|
|
290
293
|
}));
|
|
291
294
|
}
|
|
292
295
|
export class NavigationMenuTriggerState {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bits-ui",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "github:huntabyte/bits-ui",
|
|
6
6
|
"funding": "https://github.com/sponsors/huntabyte",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"@floating-ui/core": "^1.7.1",
|
|
42
42
|
"@floating-ui/dom": "^1.7.1",
|
|
43
43
|
"esm-env": "^1.1.2",
|
|
44
|
-
"runed": "^0.
|
|
45
|
-
"svelte-toolbelt": "^0.9.
|
|
44
|
+
"runed": "^0.29.1",
|
|
45
|
+
"svelte-toolbelt": "^0.9.3",
|
|
46
46
|
"tabbable": "^6.2.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|