bits-ui 2.8.1 → 2.8.3
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/accordion/accordion.svelte.d.ts +6 -1
- package/dist/bits/accordion/accordion.svelte.js +15 -5
- package/dist/bits/aspect-ratio/aspect-ratio.svelte.d.ts +2 -1
- package/dist/bits/aspect-ratio/aspect-ratio.svelte.js +3 -1
- package/dist/bits/avatar/avatar.svelte.d.ts +4 -1
- package/dist/bits/avatar/avatar.svelte.js +9 -3
- package/dist/bits/calendar/calendar.svelte.d.ts +15 -1
- package/dist/bits/calendar/calendar.svelte.js +42 -14
- package/dist/bits/checkbox/checkbox.svelte.d.ts +4 -1
- package/dist/bits/checkbox/checkbox.svelte.js +13 -3
- package/dist/bits/collapsible/collapsible.svelte.d.ts +5 -1
- package/dist/bits/collapsible/collapsible.svelte.js +15 -4
- package/dist/bits/command/command.svelte.d.ts +13 -1
- package/dist/bits/command/command.svelte.js +36 -12
- package/dist/bits/date-field/date-field.svelte.d.ts +8 -2
- package/dist/bits/date-field/date-field.svelte.js +18 -6
- package/dist/bits/date-range-field/date-range-field.svelte.d.ts +3 -1
- package/dist/bits/date-range-field/date-range-field.svelte.js +6 -2
- package/dist/bits/dialog/dialog.svelte.d.ts +9 -1
- package/dist/bits/dialog/dialog.svelte.js +41 -19
- package/dist/bits/label/label.svelte.d.ts +2 -1
- package/dist/bits/label/label.svelte.js +3 -1
- package/dist/bits/link-preview/link-preview.svelte.d.ts +3 -1
- package/dist/bits/link-preview/link-preview.svelte.js +6 -2
- package/dist/bits/menu/menu.svelte.d.ts +12 -1
- package/dist/bits/menu/menu.svelte.js +37 -15
- package/dist/bits/menubar/components/menubar-trigger.svelte +4 -3
- package/dist/bits/menubar/menubar.svelte.d.ts +4 -1
- package/dist/bits/menubar/menubar.svelte.js +9 -3
- package/dist/bits/meter/meter.svelte.d.ts +2 -1
- package/dist/bits/meter/meter.svelte.js +3 -1
- package/dist/bits/navigation-menu/navigation-menu.svelte.d.ts +14 -3
- package/dist/bits/navigation-menu/navigation-menu.svelte.js +33 -13
- package/dist/bits/pagination/pagination.svelte.d.ts +4 -1
- package/dist/bits/pagination/pagination.svelte.js +9 -3
- package/dist/bits/pin-input/pin-input.svelte.d.ts +4 -1
- package/dist/bits/pin-input/pin-input.svelte.js +8 -3
- package/dist/bits/popover/popover.svelte.d.ts +4 -1
- package/dist/bits/popover/popover.svelte.js +9 -3
- package/dist/bits/progress/progress.svelte.d.ts +2 -1
- package/dist/bits/progress/progress.svelte.js +3 -1
- package/dist/bits/radio-group/radio-group.svelte.d.ts +3 -1
- package/dist/bits/radio-group/radio-group.svelte.js +6 -2
- package/dist/bits/range-calendar/range-calendar.svelte.d.ts +4 -1
- package/dist/bits/range-calendar/range-calendar.svelte.js +9 -3
- package/dist/bits/rating-group/rating-group.svelte.d.ts +3 -1
- package/dist/bits/rating-group/rating-group.svelte.js +6 -2
- package/dist/bits/scroll-area/scroll-area.svelte.d.ts +8 -1
- package/dist/bits/scroll-area/scroll-area.svelte.js +20 -7
- package/dist/bits/select/select.svelte.d.ts +10 -1
- package/dist/bits/select/select.svelte.js +27 -9
- package/dist/bits/separator/separator.svelte.d.ts +2 -1
- package/dist/bits/separator/separator.svelte.js +3 -1
- package/dist/bits/slider/slider.svelte.d.ts +7 -1
- package/dist/bits/slider/slider.svelte.js +18 -6
- package/dist/bits/switch/switch.svelte.d.ts +3 -1
- package/dist/bits/switch/switch.svelte.js +6 -2
- package/dist/bits/tabs/tabs.svelte.d.ts +5 -1
- package/dist/bits/tabs/tabs.svelte.js +12 -4
- package/dist/bits/time-field/time-field.svelte.d.ts +7 -1
- package/dist/bits/time-field/time-field.svelte.js +18 -6
- package/dist/bits/time-range-field/time-range-field.svelte.d.ts +3 -1
- package/dist/bits/time-range-field/time-range-field.svelte.js +6 -2
- package/dist/bits/toggle/toggle.svelte.d.ts +2 -1
- package/dist/bits/toggle/toggle.svelte.js +3 -1
- package/dist/bits/toggle-group/toggle-group.svelte.d.ts +3 -1
- package/dist/bits/toggle-group/toggle-group.svelte.js +6 -2
- package/dist/bits/toolbar/toolbar.svelte.d.ts +6 -1
- package/dist/bits/toolbar/toolbar.svelte.js +15 -5
- package/dist/bits/tooltip/tooltip.svelte.d.ts +3 -1
- package/dist/bits/tooltip/tooltip.svelte.js +6 -2
- package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.d.ts +9 -0
- package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.js +6 -3
- package/dist/internal/types.d.ts +2 -1
- package/package.json +9 -12
|
@@ -105,6 +105,7 @@ export class MenuContentState {
|
|
|
105
105
|
parentMenu;
|
|
106
106
|
rovingFocusGroup;
|
|
107
107
|
domContext;
|
|
108
|
+
attachment;
|
|
108
109
|
search = $state("");
|
|
109
110
|
#timer = 0;
|
|
110
111
|
#handleTypeaheadSearch;
|
|
@@ -114,6 +115,11 @@ export class MenuContentState {
|
|
|
114
115
|
this.opts = opts;
|
|
115
116
|
this.parentMenu = parentMenu;
|
|
116
117
|
this.domContext = new DOMContext(opts.ref);
|
|
118
|
+
this.attachment = attachRef(this.opts.ref, (v) => {
|
|
119
|
+
if (this.parentMenu.contentNode !== v) {
|
|
120
|
+
this.parentMenu.contentNode = v;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
117
123
|
parentMenu.contentId = opts.id;
|
|
118
124
|
this.#isSub = opts.isSub ?? false;
|
|
119
125
|
this.onkeydown = this.onkeydown.bind(this);
|
|
@@ -319,11 +325,7 @@ export class MenuContentState {
|
|
|
319
325
|
style: {
|
|
320
326
|
pointerEvents: "auto",
|
|
321
327
|
},
|
|
322
|
-
...
|
|
323
|
-
if (this.parentMenu.contentNode !== v) {
|
|
324
|
-
this.parentMenu.contentNode = v;
|
|
325
|
-
}
|
|
326
|
-
}),
|
|
328
|
+
...this.attachment,
|
|
327
329
|
}));
|
|
328
330
|
popperProps = {
|
|
329
331
|
onCloseAutoFocus: (e) => this.onCloseAutoFocus(e),
|
|
@@ -332,10 +334,12 @@ export class MenuContentState {
|
|
|
332
334
|
class MenuItemSharedState {
|
|
333
335
|
opts;
|
|
334
336
|
content;
|
|
337
|
+
attachment;
|
|
335
338
|
#isFocused = $state(false);
|
|
336
339
|
constructor(opts, content) {
|
|
337
340
|
this.opts = opts;
|
|
338
341
|
this.content = content;
|
|
342
|
+
this.attachment = attachRef(this.opts.ref);
|
|
339
343
|
this.onpointermove = this.onpointermove.bind(this);
|
|
340
344
|
this.onpointerleave = this.onpointerleave.bind(this);
|
|
341
345
|
this.onfocus = this.onfocus.bind(this);
|
|
@@ -393,7 +397,7 @@ class MenuItemSharedState {
|
|
|
393
397
|
onpointerleave: this.onpointerleave,
|
|
394
398
|
onfocus: this.onfocus,
|
|
395
399
|
onblur: this.onblur,
|
|
396
|
-
...
|
|
400
|
+
...this.attachment,
|
|
397
401
|
}));
|
|
398
402
|
}
|
|
399
403
|
export class MenuItemState {
|
|
@@ -481,12 +485,14 @@ export class MenuSubTriggerState {
|
|
|
481
485
|
item;
|
|
482
486
|
content;
|
|
483
487
|
submenu;
|
|
488
|
+
attachment;
|
|
484
489
|
#openTimer = null;
|
|
485
490
|
constructor(opts, item, content, submenu) {
|
|
486
491
|
this.opts = opts;
|
|
487
492
|
this.item = item;
|
|
488
493
|
this.content = content;
|
|
489
494
|
this.submenu = submenu;
|
|
495
|
+
this.attachment = attachRef(this.opts.ref, (v) => (this.submenu.triggerNode = v));
|
|
490
496
|
this.onpointerleave = this.onpointerleave.bind(this);
|
|
491
497
|
this.onpointermove = this.onpointermove.bind(this);
|
|
492
498
|
this.onkeydown = this.onkeydown.bind(this);
|
|
@@ -566,7 +572,7 @@ export class MenuSubTriggerState {
|
|
|
566
572
|
onpointermove: this.onpointermove,
|
|
567
573
|
onpointerleave: this.onpointerleave,
|
|
568
574
|
onkeydown: this.onkeydown,
|
|
569
|
-
...
|
|
575
|
+
...this.attachment,
|
|
570
576
|
}, this.item.props));
|
|
571
577
|
}
|
|
572
578
|
export class MenuCheckboxItemState {
|
|
@@ -624,17 +630,19 @@ export class MenuGroupState {
|
|
|
624
630
|
}
|
|
625
631
|
opts;
|
|
626
632
|
root;
|
|
633
|
+
attachment;
|
|
627
634
|
groupHeadingId = $state(undefined);
|
|
628
635
|
constructor(opts, root) {
|
|
629
636
|
this.opts = opts;
|
|
630
637
|
this.root = root;
|
|
638
|
+
this.attachment = attachRef(this.opts.ref);
|
|
631
639
|
}
|
|
632
640
|
props = $derived.by(() => ({
|
|
633
641
|
id: this.opts.id.current,
|
|
634
642
|
role: "group",
|
|
635
643
|
"aria-labelledby": this.groupHeadingId,
|
|
636
644
|
[this.root.getBitsAttr("group")]: "",
|
|
637
|
-
...
|
|
645
|
+
...this.attachment,
|
|
638
646
|
}));
|
|
639
647
|
}
|
|
640
648
|
export class MenuGroupHeadingState {
|
|
@@ -650,15 +658,17 @@ export class MenuGroupHeadingState {
|
|
|
650
658
|
}
|
|
651
659
|
opts;
|
|
652
660
|
group;
|
|
661
|
+
attachment;
|
|
653
662
|
constructor(opts, group) {
|
|
654
663
|
this.opts = opts;
|
|
655
664
|
this.group = group;
|
|
665
|
+
this.attachment = attachRef(this.opts.ref, (v) => (this.group.groupHeadingId = v?.id));
|
|
656
666
|
}
|
|
657
667
|
props = $derived.by(() => ({
|
|
658
668
|
id: this.opts.id.current,
|
|
659
669
|
role: "group",
|
|
660
670
|
[this.group.root.getBitsAttr("group-heading")]: "",
|
|
661
|
-
...
|
|
671
|
+
...this.attachment,
|
|
662
672
|
}));
|
|
663
673
|
}
|
|
664
674
|
export class MenuSeparatorState {
|
|
@@ -667,15 +677,17 @@ export class MenuSeparatorState {
|
|
|
667
677
|
}
|
|
668
678
|
opts;
|
|
669
679
|
root;
|
|
680
|
+
attachment;
|
|
670
681
|
constructor(opts, root) {
|
|
671
682
|
this.opts = opts;
|
|
672
683
|
this.root = root;
|
|
684
|
+
this.attachment = attachRef(this.opts.ref);
|
|
673
685
|
}
|
|
674
686
|
props = $derived.by(() => ({
|
|
675
687
|
id: this.opts.id.current,
|
|
676
688
|
role: "group",
|
|
677
689
|
[this.root.getBitsAttr("separator")]: "",
|
|
678
|
-
...
|
|
690
|
+
...this.attachment,
|
|
679
691
|
}));
|
|
680
692
|
}
|
|
681
693
|
export class MenuArrowState {
|
|
@@ -696,12 +708,14 @@ export class MenuRadioGroupState {
|
|
|
696
708
|
}
|
|
697
709
|
opts;
|
|
698
710
|
content;
|
|
711
|
+
attachment;
|
|
699
712
|
groupHeadingId = $state(null);
|
|
700
713
|
root;
|
|
701
714
|
constructor(opts, content) {
|
|
702
715
|
this.opts = opts;
|
|
703
716
|
this.content = content;
|
|
704
717
|
this.root = content.parentMenu.root;
|
|
718
|
+
this.attachment = attachRef(this.opts.ref);
|
|
705
719
|
}
|
|
706
720
|
setValue(v) {
|
|
707
721
|
this.opts.value.current = v;
|
|
@@ -711,7 +725,7 @@ export class MenuRadioGroupState {
|
|
|
711
725
|
[this.root.getBitsAttr("radio-group")]: "",
|
|
712
726
|
role: "group",
|
|
713
727
|
"aria-labelledby": this.groupHeadingId,
|
|
714
|
-
...
|
|
728
|
+
...this.attachment,
|
|
715
729
|
}));
|
|
716
730
|
}
|
|
717
731
|
export class MenuRadioItemState {
|
|
@@ -724,11 +738,13 @@ export class MenuRadioItemState {
|
|
|
724
738
|
opts;
|
|
725
739
|
item;
|
|
726
740
|
group;
|
|
741
|
+
attachment;
|
|
727
742
|
isChecked = $derived.by(() => this.group.opts.value.current === this.opts.value.current);
|
|
728
743
|
constructor(opts, item, group) {
|
|
729
744
|
this.opts = opts;
|
|
730
745
|
this.item = item;
|
|
731
746
|
this.group = group;
|
|
747
|
+
this.attachment = attachRef(this.opts.ref);
|
|
732
748
|
}
|
|
733
749
|
selectValue() {
|
|
734
750
|
this.group.setValue(this.opts.value.current);
|
|
@@ -739,7 +755,7 @@ export class MenuRadioItemState {
|
|
|
739
755
|
role: "menuitemradio",
|
|
740
756
|
"aria-checked": getAriaChecked(this.isChecked, false),
|
|
741
757
|
"data-state": getCheckedState(this.isChecked),
|
|
742
|
-
...
|
|
758
|
+
...this.attachment,
|
|
743
759
|
}));
|
|
744
760
|
}
|
|
745
761
|
export class DropdownMenuTriggerState {
|
|
@@ -748,9 +764,11 @@ export class DropdownMenuTriggerState {
|
|
|
748
764
|
}
|
|
749
765
|
opts;
|
|
750
766
|
parentMenu;
|
|
767
|
+
attachment;
|
|
751
768
|
constructor(opts, parentMenu) {
|
|
752
769
|
this.opts = opts;
|
|
753
770
|
this.parentMenu = parentMenu;
|
|
771
|
+
this.attachment = attachRef(this.opts.ref, (v) => (this.parentMenu.triggerNode = v));
|
|
754
772
|
}
|
|
755
773
|
onpointerdown = (e) => {
|
|
756
774
|
if (this.opts.disabled.current)
|
|
@@ -804,7 +822,7 @@ export class DropdownMenuTriggerState {
|
|
|
804
822
|
onpointerdown: this.onpointerdown,
|
|
805
823
|
onpointerup: this.onpointerup,
|
|
806
824
|
onkeydown: this.onkeydown,
|
|
807
|
-
...
|
|
825
|
+
...this.attachment,
|
|
808
826
|
}));
|
|
809
827
|
}
|
|
810
828
|
export class ContextMenuTriggerState {
|
|
@@ -813,6 +831,7 @@ export class ContextMenuTriggerState {
|
|
|
813
831
|
}
|
|
814
832
|
opts;
|
|
815
833
|
parentMenu;
|
|
834
|
+
attachment;
|
|
816
835
|
#point = $state({ x: 0, y: 0 });
|
|
817
836
|
virtualElement = box({
|
|
818
837
|
getBoundingClientRect: () => DOMRect.fromRect({ width: 0, height: 0, ...this.#point }),
|
|
@@ -821,6 +840,7 @@ export class ContextMenuTriggerState {
|
|
|
821
840
|
constructor(opts, parentMenu) {
|
|
822
841
|
this.opts = opts;
|
|
823
842
|
this.parentMenu = parentMenu;
|
|
843
|
+
this.attachment = attachRef(this.opts.ref, (v) => (this.parentMenu.triggerNode = v));
|
|
824
844
|
this.oncontextmenu = this.oncontextmenu.bind(this);
|
|
825
845
|
this.onpointerdown = this.onpointerdown.bind(this);
|
|
826
846
|
this.onpointermove = this.onpointermove.bind(this);
|
|
@@ -889,7 +909,7 @@ export class ContextMenuTriggerState {
|
|
|
889
909
|
onpointercancel: this.onpointercancel,
|
|
890
910
|
onpointerup: this.onpointerup,
|
|
891
911
|
oncontextmenu: this.oncontextmenu,
|
|
892
|
-
...
|
|
912
|
+
...this.attachment,
|
|
893
913
|
}));
|
|
894
914
|
}
|
|
895
915
|
export class MenuCheckboxGroupState {
|
|
@@ -899,11 +919,13 @@ export class MenuCheckboxGroupState {
|
|
|
899
919
|
opts;
|
|
900
920
|
content;
|
|
901
921
|
root;
|
|
922
|
+
attachment;
|
|
902
923
|
groupHeadingId = $state(null);
|
|
903
924
|
constructor(opts, content) {
|
|
904
925
|
this.opts = opts;
|
|
905
926
|
this.content = content;
|
|
906
927
|
this.root = content.parentMenu.root;
|
|
928
|
+
this.attachment = attachRef(this.opts.ref);
|
|
907
929
|
}
|
|
908
930
|
addValue(checkboxValue) {
|
|
909
931
|
if (!checkboxValue)
|
|
@@ -929,7 +951,7 @@ export class MenuCheckboxGroupState {
|
|
|
929
951
|
[this.root.getBitsAttr("checkbox-group")]: "",
|
|
930
952
|
role: "group",
|
|
931
953
|
"aria-labelledby": this.groupHeadingId,
|
|
932
|
-
...
|
|
954
|
+
...this.attachment,
|
|
933
955
|
}));
|
|
934
956
|
}
|
|
935
957
|
export class MenuSubmenuState {
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
const dropdownTriggerState = DropdownMenuTriggerState.create(triggerState.opts);
|
|
30
|
+
const triggerAttachment = attachRef(
|
|
31
|
+
(v: HTMLElement | null) => (dropdownTriggerState.parentMenu.triggerNode = v)
|
|
32
|
+
);
|
|
30
33
|
|
|
31
34
|
const mergedProps = $derived(
|
|
32
35
|
mergeProps(restProps, triggerState.props, {
|
|
33
|
-
...
|
|
34
|
-
(v: HTMLElement | null) => (dropdownTriggerState.parentMenu.triggerNode = v)
|
|
35
|
-
),
|
|
36
|
+
...triggerAttachment,
|
|
36
37
|
})
|
|
37
38
|
);
|
|
38
39
|
</script>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReadableBox, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
|
|
2
2
|
import type { InteractOutsideBehaviorType } from "../utilities/dismissible-layer/types.js";
|
|
3
3
|
import type { Direction } from "../../shared/index.js";
|
|
4
|
-
import type { OnChangeFn, WithRefOpts } from "../../internal/types.js";
|
|
4
|
+
import type { OnChangeFn, RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
5
5
|
import type { FocusEventHandler, KeyboardEventHandler, PointerEventHandler } from "svelte/elements";
|
|
6
6
|
import { RovingFocusGroup } from "../../internal/roving-focus-group.js";
|
|
7
7
|
interface MenubarRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
@@ -15,6 +15,7 @@ export declare class MenubarRootState {
|
|
|
15
15
|
static create(opts: MenubarRootStateOpts): MenubarRootState;
|
|
16
16
|
readonly opts: MenubarRootStateOpts;
|
|
17
17
|
readonly rovingFocusGroup: RovingFocusGroup;
|
|
18
|
+
readonly attachment: RefAttachment;
|
|
18
19
|
wasOpenedByKeyboard: boolean;
|
|
19
20
|
triggerIds: string[];
|
|
20
21
|
valueToChangeHandler: Map<string, ReadableBox<OnChangeFn<boolean>>>;
|
|
@@ -70,6 +71,7 @@ export declare class MenubarTriggerState {
|
|
|
70
71
|
readonly opts: MenubarTriggerStateOpts;
|
|
71
72
|
readonly menu: MenubarMenuState;
|
|
72
73
|
readonly root: MenubarRootState;
|
|
74
|
+
readonly attachment: RefAttachment;
|
|
73
75
|
isFocused: boolean;
|
|
74
76
|
constructor(opts: MenubarTriggerStateOpts, menu: MenubarMenuState);
|
|
75
77
|
onpointerdown: PointerEventHandler<HTMLElement>;
|
|
@@ -110,6 +112,7 @@ export declare class MenubarContentState {
|
|
|
110
112
|
readonly opts: MenubarContentStateOpts;
|
|
111
113
|
readonly menu: MenubarMenuState;
|
|
112
114
|
readonly root: MenubarRootState;
|
|
115
|
+
readonly attachment: RefAttachment;
|
|
113
116
|
constructor(opts: MenubarContentStateOpts, menu: MenubarMenuState);
|
|
114
117
|
onCloseAutoFocus: (e: Event) => void;
|
|
115
118
|
onFocusOutside: (e: FocusEvent) => void;
|
|
@@ -18,11 +18,13 @@ export class MenubarRootState {
|
|
|
18
18
|
}
|
|
19
19
|
opts;
|
|
20
20
|
rovingFocusGroup;
|
|
21
|
+
attachment;
|
|
21
22
|
wasOpenedByKeyboard = $state(false);
|
|
22
23
|
triggerIds = $state([]);
|
|
23
24
|
valueToChangeHandler = new Map();
|
|
24
25
|
constructor(opts) {
|
|
25
26
|
this.opts = opts;
|
|
27
|
+
this.attachment = attachRef(this.opts.ref);
|
|
26
28
|
this.rovingFocusGroup = new RovingFocusGroup({
|
|
27
29
|
rootNode: this.opts.ref,
|
|
28
30
|
candidateAttr: menubarAttrs.trigger,
|
|
@@ -83,7 +85,7 @@ export class MenubarRootState {
|
|
|
83
85
|
id: this.opts.id.current,
|
|
84
86
|
role: "menubar",
|
|
85
87
|
[menubarAttrs.root]: "",
|
|
86
|
-
...
|
|
88
|
+
...this.attachment,
|
|
87
89
|
}));
|
|
88
90
|
}
|
|
89
91
|
export class MenubarMenuState {
|
|
@@ -127,12 +129,14 @@ export class MenubarTriggerState {
|
|
|
127
129
|
opts;
|
|
128
130
|
menu;
|
|
129
131
|
root;
|
|
132
|
+
attachment;
|
|
130
133
|
isFocused = $state(false);
|
|
131
134
|
#tabIndex = $state(0);
|
|
132
135
|
constructor(opts, menu) {
|
|
133
136
|
this.opts = opts;
|
|
134
137
|
this.menu = menu;
|
|
135
138
|
this.root = menu.root;
|
|
139
|
+
this.attachment = attachRef(this.opts.ref, (v) => (this.menu.triggerNode = v));
|
|
136
140
|
onMount(() => {
|
|
137
141
|
return this.root.registerTrigger(opts.id.current);
|
|
138
142
|
});
|
|
@@ -204,7 +208,7 @@ export class MenubarTriggerState {
|
|
|
204
208
|
onkeydown: this.onkeydown,
|
|
205
209
|
onfocus: this.onfocus,
|
|
206
210
|
onblur: this.onblur,
|
|
207
|
-
...
|
|
211
|
+
...this.attachment,
|
|
208
212
|
}));
|
|
209
213
|
}
|
|
210
214
|
export class MenubarContentState {
|
|
@@ -214,10 +218,12 @@ export class MenubarContentState {
|
|
|
214
218
|
opts;
|
|
215
219
|
menu;
|
|
216
220
|
root;
|
|
221
|
+
attachment;
|
|
217
222
|
constructor(opts, menu) {
|
|
218
223
|
this.opts = opts;
|
|
219
224
|
this.menu = menu;
|
|
220
225
|
this.root = menu.root;
|
|
226
|
+
this.attachment = attachRef(this.opts.ref, (v) => (this.menu.contentNode = v));
|
|
221
227
|
}
|
|
222
228
|
onCloseAutoFocus = (e) => {
|
|
223
229
|
this.opts.onCloseAutoFocus.current(e);
|
|
@@ -280,7 +286,7 @@ export class MenubarContentState {
|
|
|
280
286
|
onkeydown: this.onkeydown,
|
|
281
287
|
"data-menu-content": "",
|
|
282
288
|
[menubarAttrs.content]: "",
|
|
283
|
-
...
|
|
289
|
+
...this.attachment,
|
|
284
290
|
}));
|
|
285
291
|
popperProps = {
|
|
286
292
|
onCloseAutoFocus: this.onCloseAutoFocus,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReadableBoxedValues } from "svelte-toolbelt";
|
|
2
|
-
import type { WithRefOpts } from "../../internal/types.js";
|
|
2
|
+
import type { RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
3
3
|
interface MeterRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
4
4
|
value: number;
|
|
5
5
|
max: number;
|
|
@@ -9,6 +9,7 @@ interface MeterRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
|
9
9
|
export declare class MeterRootState {
|
|
10
10
|
static create(opts: MeterRootStateOpts): MeterRootState;
|
|
11
11
|
readonly opts: MeterRootStateOpts;
|
|
12
|
+
readonly attachment: RefAttachment;
|
|
12
13
|
constructor(opts: MeterRootStateOpts);
|
|
13
14
|
readonly props: {
|
|
14
15
|
readonly role: "meter";
|
|
@@ -9,8 +9,10 @@ export class MeterRootState {
|
|
|
9
9
|
return new MeterRootState(opts);
|
|
10
10
|
}
|
|
11
11
|
opts;
|
|
12
|
+
attachment;
|
|
12
13
|
constructor(opts) {
|
|
13
14
|
this.opts = opts;
|
|
15
|
+
this.attachment = attachRef(this.opts.ref);
|
|
14
16
|
}
|
|
15
17
|
props = $derived.by(() => ({
|
|
16
18
|
role: "meter",
|
|
@@ -22,6 +24,6 @@ export class MeterRootState {
|
|
|
22
24
|
"data-max": this.opts.max.current,
|
|
23
25
|
"data-min": this.opts.min.current,
|
|
24
26
|
[meterAttrs.root]: "",
|
|
25
|
-
...
|
|
27
|
+
...this.attachment,
|
|
26
28
|
}));
|
|
27
29
|
}
|
|
@@ -7,7 +7,7 @@ import { Context } from "runed";
|
|
|
7
7
|
import { type Snippet } from "svelte";
|
|
8
8
|
import { SvelteMap } from "svelte/reactivity";
|
|
9
9
|
import { type Direction, type Orientation } from "../../shared/index.js";
|
|
10
|
-
import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent } from "../../internal/types.js";
|
|
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
13
|
declare const navigationMenuAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["root", "sub", "item", "list", "trigger", "content", "link", "viewport", "menu", "indicator"]>;
|
|
@@ -58,6 +58,7 @@ export declare class NavigationMenuRootState {
|
|
|
58
58
|
#private;
|
|
59
59
|
static create(opts: NavigationMenuRootStateOpts): NavigationMenuRootState;
|
|
60
60
|
readonly opts: NavigationMenuRootStateOpts;
|
|
61
|
+
readonly attachment: RefAttachment;
|
|
61
62
|
provider: NavigationMenuProviderState;
|
|
62
63
|
previousValue: WritableBox<string>;
|
|
63
64
|
isDelaySkipped: WritableBox<boolean>;
|
|
@@ -81,6 +82,7 @@ export declare class NavigationMenuSubState {
|
|
|
81
82
|
readonly context: NavigationMenuProviderState;
|
|
82
83
|
previousValue: WritableBox<string>;
|
|
83
84
|
readonly subProvider: NavigationMenuProviderState;
|
|
85
|
+
readonly attachment: RefAttachment;
|
|
84
86
|
constructor(opts: NavigationMenuSubStateOpts, context: NavigationMenuProviderState);
|
|
85
87
|
setValue: (newValue: string, itemState: NavigationMenuItemState | null) => void;
|
|
86
88
|
readonly props: {
|
|
@@ -92,10 +94,12 @@ interface NavigationMenuListStateOpts extends WithRefProps {
|
|
|
92
94
|
}
|
|
93
95
|
export declare class NavigationMenuListState {
|
|
94
96
|
static create(opts: NavigationMenuListStateOpts): NavigationMenuListState;
|
|
95
|
-
readonly opts: NavigationMenuListStateOpts;
|
|
96
|
-
readonly context: NavigationMenuProviderState;
|
|
97
97
|
wrapperId: WritableBox<string>;
|
|
98
98
|
wrapperRef: WritableBox<HTMLElement | null>;
|
|
99
|
+
readonly opts: NavigationMenuListStateOpts;
|
|
100
|
+
readonly context: NavigationMenuProviderState;
|
|
101
|
+
readonly attachment: RefAttachment;
|
|
102
|
+
readonly wrapperAttachment: RefAttachment;
|
|
99
103
|
listTriggers: HTMLElement[];
|
|
100
104
|
readonly rovingFocusGroup: RovingFocusGroup;
|
|
101
105
|
wrapperMounted: boolean;
|
|
@@ -149,8 +153,10 @@ interface NavigationMenuTriggerStateOpts extends WithRefProps, ReadableBoxedValu
|
|
|
149
153
|
export declare class NavigationMenuTriggerState {
|
|
150
154
|
static create(opts: NavigationMenuTriggerStateOpts): NavigationMenuTriggerState;
|
|
151
155
|
readonly opts: NavigationMenuTriggerStateOpts;
|
|
156
|
+
readonly attachment: RefAttachment;
|
|
152
157
|
focusProxyId: WritableBox<string>;
|
|
153
158
|
focusProxyRef: WritableBox<HTMLElement | null>;
|
|
159
|
+
readonly focusProxyAttachment: RefAttachment;
|
|
154
160
|
context: NavigationMenuProviderState;
|
|
155
161
|
itemContext: NavigationMenuItemState;
|
|
156
162
|
listContext: NavigationMenuListState;
|
|
@@ -203,6 +209,7 @@ export declare class NavigationMenuLinkState {
|
|
|
203
209
|
provider: NavigationMenuProviderState;
|
|
204
210
|
item: NavigationMenuItemState;
|
|
205
211
|
};
|
|
212
|
+
readonly attachment: RefAttachment;
|
|
206
213
|
isFocused: boolean;
|
|
207
214
|
constructor(opts: NavigationMenuLinkStateOpts, context: {
|
|
208
215
|
provider: NavigationMenuProviderState;
|
|
@@ -238,6 +245,7 @@ export declare class NavigationMenuIndicatorState {
|
|
|
238
245
|
export declare class NavigationMenuIndicatorImplState {
|
|
239
246
|
static create(opts: NavigationMenuIndicatorStateOpts): NavigationMenuIndicatorImplState;
|
|
240
247
|
readonly opts: NavigationMenuIndicatorStateOpts;
|
|
248
|
+
readonly attachment: RefAttachment;
|
|
241
249
|
context: NavigationMenuProviderState;
|
|
242
250
|
listContext: NavigationMenuListState;
|
|
243
251
|
position: {
|
|
@@ -278,6 +286,7 @@ export declare class NavigationMenuContentState {
|
|
|
278
286
|
readonly context: NavigationMenuProviderState;
|
|
279
287
|
readonly itemContext: NavigationMenuItemState;
|
|
280
288
|
readonly listContext: NavigationMenuListState;
|
|
289
|
+
readonly attachment: RefAttachment;
|
|
281
290
|
mounted: boolean;
|
|
282
291
|
readonly open: boolean;
|
|
283
292
|
readonly value: string;
|
|
@@ -304,6 +313,7 @@ export declare class NavigationMenuContentImplState {
|
|
|
304
313
|
readonly itemContext: NavigationMenuItemState;
|
|
305
314
|
readonly context: NavigationMenuProviderState;
|
|
306
315
|
readonly listContext: NavigationMenuListState;
|
|
316
|
+
readonly attachment: RefAttachment;
|
|
307
317
|
prevMotionAttribute: MotionAttribute | null;
|
|
308
318
|
readonly motionAttribute: MotionAttribute | null;
|
|
309
319
|
domContext: DOMContext;
|
|
@@ -327,6 +337,7 @@ export declare class NavigationMenuViewportState {
|
|
|
327
337
|
static create(opts: NavigationMenuViewportStateOpts): NavigationMenuViewportState;
|
|
328
338
|
readonly opts: NavigationMenuViewportStateOpts;
|
|
329
339
|
readonly context: NavigationMenuProviderState;
|
|
340
|
+
readonly attachment: RefAttachment;
|
|
330
341
|
readonly open: boolean;
|
|
331
342
|
readonly viewportWidth: string | undefined;
|
|
332
343
|
readonly viewportHeight: string | undefined;
|